mirror of
https://github.com/AleziaKurdis/Overte-community-apps.git
synced 2025-04-05 13:37:41 +02:00
Minor formatting adjustment.
This commit is contained in:
parent
39d588c203
commit
fa751c0667
2 changed files with 33 additions and 33 deletions
|
@ -9,7 +9,7 @@
|
|||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
/* global Script Tablet Messages MyAvatar Uuid*/
|
||||
/* global Script Tablet Messages MyAvatar AvatarList Uuid SoundCache*/
|
||||
|
||||
// TODO: Documentation
|
||||
// FIXME: Handle ties: kill both of tied results
|
||||
|
@ -73,7 +73,7 @@
|
|||
active = true;
|
||||
|
||||
if (poll.id != '') {
|
||||
return _findWhereWeNeedToBe()
|
||||
return _findWhereWeNeedToBe();
|
||||
}
|
||||
|
||||
// Request a list of active polls if we are not already in one
|
||||
|
@ -148,7 +148,7 @@
|
|||
|
||||
// Confirm to user if they want to close the poll
|
||||
if (!bypassPrompt) {
|
||||
var answer = Window.confirm('Are you sure you want to close the poll?')
|
||||
var answer = Window.confirm('Are you sure you want to close the poll?');
|
||||
if (!answer) return;
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@
|
|||
Messages.sendMessage("ga-polls", JSON.stringify({type: "close_poll", poll: {id: poll.id}}));
|
||||
|
||||
// Update the UI screen
|
||||
_emitEvent({type: "close_poll", poll: {id: poll.id}, change_page: true});
|
||||
_emitEvent({type: "close_poll", poll: {id: poll.id}, changePage: true});
|
||||
|
||||
// Clear our active poll data
|
||||
_resetNetworking();
|
||||
|
@ -249,7 +249,7 @@
|
|||
if (!voteResults[candidate]) voteResults[candidate] = 0;
|
||||
|
||||
// Increment value for each vote
|
||||
voteResults[candidate]++
|
||||
voteResults[candidate]++;
|
||||
}
|
||||
|
||||
const totalVotes = Object.keys(pollStats.responses).length; // Total votes to expect to be counted.
|
||||
|
@ -323,7 +323,7 @@
|
|||
ballot.splice(indexToRemove, ballot.length - indexToRemove);
|
||||
|
||||
const responsesKeyName = Object.keys(pollStats.responses).length.toString();
|
||||
responses[responsesKeyName] = ballot;
|
||||
pollStats.responses[responsesKeyName] = ballot;
|
||||
|
||||
function getRandomOrder(...words) {
|
||||
for (let i = words.length - 1; i > 0; i--) {
|
||||
|
@ -348,10 +348,11 @@
|
|||
|
||||
function _emitSound(type){
|
||||
switch (type) {
|
||||
case "new_prompt":
|
||||
const newPollSound = SoundCache.getSound(Script.resolvePath("./sound/new_vote.mp3"))
|
||||
Audio.playSystemSound(newPollSound, {volume: 0.5});
|
||||
break;
|
||||
case "new_prompt": {
|
||||
let newPollSound = SoundCache.getSound(Script.resolvePath("./sound/new_vote.mp3"));
|
||||
Audio.playSystemSound(newPollSound, {volume: 0.5});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -377,7 +378,7 @@
|
|||
case "prompt":
|
||||
poll.question = event.prompt.question;
|
||||
poll.options = event.prompt.options.filter(String); // Clean empty options
|
||||
poll.canHostVote = event.canHostVote
|
||||
poll.canHostVote = event.canHostVote;
|
||||
pollStats = {iterations: 0, responses: {}, winnerSelected: false, winnerName: "", votesReceived: 0, votesCounted: 0 };
|
||||
emitPrompt();
|
||||
break;
|
||||
|
@ -437,7 +438,7 @@
|
|||
var isOurPoll = poll.id == message.poll.id;
|
||||
|
||||
// Tell UI to close poll
|
||||
_emitEvent({type: "close_poll", change_page: isOurPoll, poll: {id: message.poll.id}});
|
||||
_emitEvent({type: "close_poll", changePage: isOurPoll, poll: {id: message.poll.id}});
|
||||
|
||||
// Unregister self from poll
|
||||
if (isOurPoll) leavePoll();
|
||||
|
@ -513,7 +514,6 @@
|
|||
Messages.sendMessage(poll.id, JSON.stringify({type: "sync", poll: poll, pollStats: pollStats}));
|
||||
emitPrompt();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -13,8 +13,8 @@ Rectangle {
|
|||
property var poll: {}
|
||||
property var pollStats: { winnerSelected: false }
|
||||
property bool canHostVote: false
|
||||
property bool is_host: false
|
||||
property bool votes_tallied: false
|
||||
property bool isHost: false
|
||||
property bool votesTallied: false
|
||||
|
||||
// Poll List view
|
||||
ColumnLayout {
|
||||
|
@ -606,14 +606,14 @@ Rectangle {
|
|||
RowLayout {
|
||||
width: parent.width
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
visible: !votes_tallied
|
||||
visible: !votesTallied
|
||||
|
||||
// Recast vote
|
||||
Rectangle {
|
||||
width: 150
|
||||
height: 40
|
||||
color: "#c0bfbc"
|
||||
visible: ((is_host && canHostVote) || !is_host) && !pollStats.winnerSelected
|
||||
visible: ((isHost && canHostVote) || !isHost) && !pollStats.winnerSelected
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
|
@ -633,13 +633,13 @@ Rectangle {
|
|||
|
||||
// Host actions
|
||||
RowLayout {
|
||||
visible: is_host
|
||||
visible: isHost
|
||||
width: parent.width
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
// Preform Election
|
||||
Rectangle {
|
||||
visible: !votes_tallied
|
||||
visible: !votesTallied
|
||||
width: 150
|
||||
height: 40
|
||||
color: "#c0bfbc"
|
||||
|
@ -655,14 +655,14 @@ Rectangle {
|
|||
anchors.fill: parent
|
||||
onClicked: {
|
||||
toScript({type: "run_election"});
|
||||
votes_tallied = true;
|
||||
votesTallied = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return to poll settings
|
||||
Rectangle {
|
||||
visible: !votes_tallied
|
||||
visible: !votesTallied
|
||||
width: 150
|
||||
height: 40
|
||||
color: "#c0bfbc"
|
||||
|
@ -684,7 +684,7 @@ Rectangle {
|
|||
|
||||
// Make a new question
|
||||
Rectangle {
|
||||
visible: is_host && votes_tallied
|
||||
visible: isHost && votesTallied
|
||||
width: 150
|
||||
height: 40
|
||||
color: "#c0bfbc"
|
||||
|
@ -701,7 +701,7 @@ Rectangle {
|
|||
onClicked: {
|
||||
_clearHost();
|
||||
_changePage("poll_host_view");
|
||||
votes_tallied = false;
|
||||
votesTallied = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -959,7 +959,7 @@ Rectangle {
|
|||
_changePage("poll_host_view");
|
||||
|
||||
// Set variables
|
||||
is_host = true
|
||||
isHost = true
|
||||
|
||||
break;
|
||||
|
||||
|
@ -981,7 +981,7 @@ Rectangle {
|
|||
// Set values
|
||||
_populateClient()
|
||||
|
||||
if (is_host) return;
|
||||
if (isHost) return;
|
||||
|
||||
_changePage("poll_client_view");
|
||||
|
||||
|
@ -993,7 +993,7 @@ Rectangle {
|
|||
|
||||
// Close the poll and remove it from the list of active polls
|
||||
case "close_poll":
|
||||
if (message.change_page == true) _changePage("poll_list");
|
||||
if (message.changePage == true) _changePage("poll_list");
|
||||
|
||||
// Find the poll with the matching ID and remove it from active polls
|
||||
for (var i = 0; i < active_polls.count; i++) {
|
||||
|
@ -1004,14 +1004,14 @@ Rectangle {
|
|||
}
|
||||
|
||||
// Set variables
|
||||
is_host = false
|
||||
isHost = false
|
||||
poll_to_create_host_can_vote.checked = false;
|
||||
|
||||
break;
|
||||
case "poll_winner":
|
||||
pollStats = message.pollStats;
|
||||
_populateResults();
|
||||
votes_tallied = true;
|
||||
votesTallied = true;
|
||||
break;
|
||||
case "received_vote":
|
||||
pollStats = message.pollStats;
|
||||
|
@ -1021,19 +1021,19 @@ Rectangle {
|
|||
current_page = message.page;
|
||||
if (message.poll) poll = message.poll;
|
||||
if (message.pollStats) pollStats = message.pollStats;
|
||||
if (message.isHost) is_host = true;
|
||||
if (message.isHost) isHost = true;
|
||||
|
||||
if (message.page == "poll_client_view") {
|
||||
_populateClient();
|
||||
if (is_host) _populateHost();
|
||||
if (isHost) _populateHost();
|
||||
}
|
||||
if (message.page == "poll_results") {
|
||||
_populateClient();
|
||||
_populateResults();
|
||||
if (is_host) _populateHost();
|
||||
if (isHost) _populateHost();
|
||||
};
|
||||
if (message.page == "poll_host_view"){
|
||||
if (is_host) _populateHost();
|
||||
if (isHost) _populateHost();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue