blob: b7d95bd9b7f416d0a8a4c15365f801462e01dade [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<library>
<class name="resultPollWin" extends="labelExplorerBox" labelid="37"
docking="true" resizeable="false" closable="true" width="454" x="100"
height="454">
<attribute name="roomPoll" value="null" />
<attribute name="archPolls" value="null" />
<attribute name="resultpollvotes" value="null" />
<attribute name="displayedPoll" value="null" />
<handler name="oninit">
displayResults(roomPoll);
</handler>
<method name="displayResults" args="poll">
<![CDATA[
displayedPoll = poll;
this.content.setAttribute("visible", poll != null);
if (poll == null) {
this.head.setAttribute('text', canvas.getLabelName(41));
updateButtons();
return;
}
updateButtons();
this.head.setAttribute('text',
(canvas.user_id == poll.createdBy.user_id ? canvas
.getLabelName(1411) : poll.createdBy.login)
+ " " + canvas.getLabelName(36));
var totalVotes = poll.roomPollAnswerList.length;
this.content.question.text.setAttribute('text', poll.pollQuestion);
this.content.voteResultNum.setAttribute('text', totalVotes);
if (this.resultpollvotes != null) {
this.resultpollvotes.destroy();
}
this.resultpollvotes = new lz.view(this.content, {
y : 146,
x : 100
});
var isNumeric = poll.pollType.isNumericAnswer;
var resArray = new Array(isNumeric ? 10 : 2);
for (var i = 0; i < resArray.length; ++i) {
resArray[i] = 0;
}
for (var i = 0; i < totalVotes; ++i) {
var idx = isNumeric
? poll.roomPollAnswerList[i].pointList - 1
: (poll.roomPollAnswerList[i].answer ? 0 : 1);
resArray[idx]++;
}
if (content._chartType.getValue() == 0) {
new lz.simplelayout(this.resultpollvotes, {
axis : 'y',
spacing : 2
});
for (var i = 0; i < resArray.length; ++i) {
var pos = (totalVotes == 0) ? 0 : Math.round(100
* resArray[i] / totalVotes);
new lz.parentResultPollBalk(this.resultpollvotes, {
newX : pos * 2,
newPercent : pos + '%',
textA : isNumeric ? i + 1 : canvas
.getLabelName(i == 0 ? 34 : 35)
});
}
} else {
if (!isNumeric) {
//yes/no
new lz.resultPieCharPoll(this.resultpollvotes, {
xseries : ["yes", "no"],
yseries : resArray,
tooltipseries : ["yes ("+resArray[0]+")", "no ("+resArray[1]+")"]
});
} else {
if ($debug)
Debug.write("tObject 1 ", ["1", "2", "3", "4", "5",
"6", "7", "8", "9", "10"]);
if ($debug)
Debug.write("tObject 2 ", resArray);
var tooltipseries = new Array(resArray.length);
for (var i=0;i<resArray.length;i++) {
tooltipseries[i] = "N° "+i+" ("+ resArray[i] +")";
}
//numeric [1,2,3,4,5,6,7,8,9,10]
new lz.resultPieCharPoll(this.resultpollvotes, {
xseries : ["1", "2", "3", "4", "5", "6", "7", "8", "9",
"10"],
yseries : resArray,
tooltipseries : tooltipseries
});
}
}
]]>
</method>
<labelText y="22" name="archPollLbl" labelid="1412" />
<resetCombobox name="_archPolls" width="342" x="100" y="22"
editable="false" itemclassname="bigTextListItem">
<netRemoteCallHib name="getArchivedPollList"
funcname="pollservice.getArchivedPollList" remotecontext="$once{ canvas.thishib }">
<handler name="ondata" args="value">
<![CDATA[
parent.removeAll();
if ($debug)
Debug.write("getArchivedPollList ", value);
this.parent.parent.archPolls = value;
var noArch = (value == null || (value != null && value.length == 0));
parent.setAttribute("visible", !noArch);
parent.parent.archPollLbl.setAttribute("visible", !noArch);
if (noArch) {
return;
}
if (this.parent.parent.roomPoll != null) {
this.parent.addItem(
this.parent.parent.roomPoll.pollName + "("
+ canvas.getLabelName(1413) + ")", -1);
}
for (var i = 0; i < value.length; ++i) {
this.parent.addItem(value[i].pollName, i);
}
this.parent.selectItem(this.parent.parent.roomPoll == null
? 0
: -1);
]]>
</handler>
</netRemoteCallHib>
<handler name="oninit">
this.getArchivedPollList.doCall();
</handler>
<handler name="onselect" args="sel">
if ($debug)
Debug.write("onselect ", sel);
this.parent.displayResults(sel.value > -1
? this.parent.archPolls[sel.value]
: this.parent.roomPoll);
</handler>
<method name="removeAll">
<![CDATA[
var currentCount = this.cblist.getNumItems();
if ($debug) Debug.write("currentCount = ", currentCount);
for (var i = 0; i < currentCount; ++i) {
this.removeItemAt(0);
}
]]>
</method>
</resetCombobox>
<labelText x="2" y="42" name="head" fontstyle="bold" />
<view name="content">
<view name="question" x="2" y="62" width="440" height="60" bgcolor="0xFFFFFF">
<labelText x="0" y="0" name="text" multiline="true"
resize="false" width="$once{parent.width-14}" />
<om_vscrollbar/>
</view>
<labelText y="122" labelid="39" />
<labelText y="122" x="100" name="voteResultNum" />
<resetCombobox name="_chartType" width="302" x="140" y="122" editable="false" >
<labeldTextListItem labelid="1414" value="0"/>
<labeldTextListItem labelid="1415" value="1" selected="true" />
<handler name="onselect" args="sel">
if ($debug) Debug.write("onselect ", sel);
var val = parent.parent._archPolls.getValue();
parent.parent.displayResults(val > -1
? parent.parent.archPolls[val]
: parent.parent.roomPoll);
</handler>
</resetCombobox>
<labelText y="146" labelid="40" x="2" />
</view>
<method name="updateButtons">
<![CDATA[
_deletePoll.setAttribute("visible", canvas.ismoderator && displayedPoll != null);
var hasArch = _archPolls.cblist.getNumItems() > 0;
_closePoll.setAttribute("visible", _deletePoll.visible && (!hasArch || (hasArch && _archPolls.getValue() == -1)));
]]>
</method>
<simpleLabelButton name="_deletePoll" labelid="1420" width="100"
x="2" y="$once{ parent.height-22 }"
onclick="new lz.confirmDeleteWindow(parent, {refObj: this, labelid: 1420, messagelabelid: 1421});"
>
<netRemoteCallHib name="deletePoll" funcname="pollservice.deletePoll" remotecontext="$once{ canvas.thishib }" >
<netparam><method name="getValue"> var poll = parent.parent.parent.displayedPoll; return poll != null ? poll.roomPollId : -1; </method></netparam>
<handler name="ondata" args="value">
<![CDATA[
var p = parent.parent;
var archCount = p._archPolls.cblist.getNumItems();
var hasArch = archCount > 0;
if (!hasArch || (hasArch && p._archPolls.getValue() == -1)) {
p.roomPoll = null;
}
if (archCount) {
p.displayResults(null);
}
p._archPolls.getArchivedPollList.doCall();
]]>
</handler>
</netRemoteCallHib>
<method name="confirmDelete">
deletePoll.doCall();
</method>
</simpleLabelButton>
<simpleLabelButton name="_closePoll" labelid="1418" width="100"
x="104" y="$once{ parent.height-22 }"
onclick="new lz.confirmDeleteWindow(parent, {refObj: this, labelid: 1418, confirmlabelid: 85, messagelabelid: 1419});"
>
<netRemoteCallHib name="closePoll" funcname="pollservice.closePoll" remotecontext="$once{ canvas.thishib }" >
<handler name="ondata" args="value">
parent.parent.roomPoll = null;
parent.parent._archPolls.getArchivedPollList.doCall();
</handler>
</netRemoteCallHib>
<method name="confirmDelete">
if ($debug) Debug.write("parent._archPolls.getValue(); ", parent._archPolls.getValue());
closePoll.doCall();
</method>
</simpleLabelButton>
<simpleLabelButton labelid="25" width="100" x="$once{ parent.width-102 }"
y="$once{ parent.height-22 }" onclick="this.parent.close();" />
</class>
<class name="parentResultPollBalk" extends="view">
<attribute name="newX" value="0" type="number" />
<attribute name="newPercent" value="0%" type="string" />
<attribute name="answer" value="0" type="number" />
<attribute name="textA" value="" type="string" />
<text text="$once{ parent.textA }" resize="true" />
<resultPollBalk x="40" />
</class>
<class name="resultPollBalk" extends="view" bgcolor="black"
height="20" width="0">
<view bgcolor="red" width="${ parent.width-2 }" height="${ parent.height-2 }"
x="1" y="1" />
<text text="$once{ parent.parent.newPercent }" resize="true" y="2" />
<animator attribute="width" to="$once{ parent.parent.newX }"
duration="1000" />
</class>
<class name="resultPieCharPoll" extends="ompiechart" x="40" width="300"
height="280" style="omchartstyle">
<attribute name="xseries" value="null"/>
<attribute name="yseries" value="null"/>
<attribute name="tooltipseries" value="null"/>
<handler name="oninit">
this.legendbox.bringToFront();
</handler>
<!--- get the dataseries -->
<method name="getOMDataSeries">
<![CDATA[
var tObject = new Object();
tObject.xseries = this.xseries;
tObject.yseries = this.yseries;
tObject.tooltipseries = this.tooltipseries;
return tObject;
]]>
</method>
<strokestyle name="pieslicestyle" strokeColor="0x000000" strokeWidth="1"
strokeType="solid" />
<omlegend name="legendbox" legendFontsize="14" initstage="late"
legendborder="true" >
<handler name="onitemmouseover" args="item">
var piepiece = parent.plotarea.arrPiePieces[item.identifier];
piepiece.renderInnerWedge();
</handler>
<handler name="onitemmouseout" args="item">
var piepiece = parent.plotarea.arrPiePieces[item.identifier];
piepiece.renderWedge();
</handler>
</omlegend>
</class>
</library>