ensl_gathers/public/js/gather.js
2015-07-28 16:54:29 +01:00

282 lines
No EOL
30 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";
var VoteButton = React.createClass({displayName: "VoteButton",
cancelVote: function (e) {
socket.emit("gather:vote", {
leader: {
candidate: null
}
});
},
vote: function (e) {
e.preventDefault();
socket.emit("gather:vote", {
leader: {
candidate: parseInt(e.target.value, 10)
}
});
},
render: function () {
if (this.props.currentGatherer === null) {
return false;
}
if (this.props.currentGatherer.leaderVote === this.props.candidate.id) {
return (
React.createElement("button", {
onClick: this.cancelVote,
className: "btn btn-xs btn-success"}, "Voted"
)
);
} else {
return (
React.createElement("button", {
onClick: this.vote,
className: "btn btn-xs btn-default",
value: this.props.candidate.id}, "Vote"
)
);
}
}
});
var JoinGatherButton = React.createClass({displayName: "JoinGatherButton",
joinGather: function (e) {
e.preventDefault();
socket.emit("gather:join", {});
},
render: function () {
var message = this.props.buttonName || "Join Gather";
var buttonClass = "btn btn-primary";
if (this.props.buttonClass) {
buttonClass += " " + this.props.buttonClass;
}
return (React.createElement("button", {
onClick: this.joinGather,
className: buttonClass}, message))
}
});
var GatherProgress = React.createClass({displayName: "GatherProgress",
stateDescription: function () {
switch(this.props.gather.state) {
case "gathering":
return "Waiting for more gatherers.";
case "election":
return "Currently voting for team leaders.";
case "selection":
return "Waiting for leaders to picking teams.";
case "done":
return "Gather completed.";
default:
return "Initialising gather.";
}
},
gatheringProgress: function () {
var num = this.props.gather.gatherers.length;
var den = 12;
var remaining = den - num;
var message = (remaining === 1) ? "Waiting for last player" : "Waiting for " + remaining + " more players";
return {
num: num,
den: den,
message: message
};
},
electionProgress: function () {
var num = this.props.gather.gatherers.reduce(function (acc, gatherer) {
if (gatherer.leaderVote) acc++;
return acc;
}, 0);
var den = 12;
return {
num: num,
den: den,
message: den - num + " more votes required"
};
},
selectionProgress: function () {
var num = this.props.gather.gatherers.reduce(function (acc, gatherer) {
if (gatherer.team !== "lobby") acc++;
return acc;
}, 0);
var den = 12;
return {
num: num,
den: den,
message: num + " out of " + den + " players assigned"
};
},
render: function () {
var progress;
var gatherState = this.props.gather.state;
if (gatherState === 'gathering' && this.props.gather.gatherers.length) {
progress = this.gatheringProgress();
} else if (gatherState === 'election') {
progress = this.electionProgress();
} else if (gatherState === 'selection') {
progress = this.selectionProgress();
}
if (progress) {
var style = {
width: Math.round((progress.num / progress.den * 100)) + "%"
};
return (
React.createElement("div", {className: "panel-body"},
React.createElement("p", null, React.createElement("strong", null, this.stateDescription()), " ", progress.message),
React.createElement("div", {className: "progress"},
React.createElement("div", {className: "progress-bar progress-bar-striped active",
"data-role": "progressbar",
"data-aria-valuenow": progress.num,
"data-aria-valuemin": "0",
"data-aria-valuemax": progress.den,
style: style}
)
)
)
);
} else {
return false;
}
}
});
var Gather = React.createClass({displayName: "Gather",
getDefaultProps: function () {
return {
gather: {
gatherers: []
}
}
},
joinedGather: function () {
var self = this;
return this.props.gather.gatherers.some(function (gatherer) {
return gatherer.user.id === self.props.currentUser.id;
});
},
componentDidMount: function () {
var self = this;
socket.on("gather:refresh", function (data) {
self.setProps({
gather: data.gather,
currentUser: data.currentUser
});
});
},
leaveGather: function (e) {
e.preventDefault();
socket.emit("gather:leave", {});
},
inviteToGather: function (e) {
e.preventDefault();
},
currentGatherer: function () {
var current = null;
var self = this;
this.props.gather.gatherers.forEach(function (gatherer) {
if (gatherer.id === self.props.currentUser.id) current = gatherer;
});
return current;
},
render: function () {
var joinButton;
if (this.joinedGather()) {
joinButton = (React.createElement("li", null, React.createElement("button", {
onClick: this.leaveGather,
className: "btn btn-danger"}, "Leave Gather")));
} else {
joinButton = (React.createElement("li", null, React.createElement(JoinGatherButton, null)));
}
var inviteButton;
if (this.props.gather.state === 'gathering') {
inviteButton = (React.createElement("li", null, React.createElement("button", {
onClick: this.inviteToGather,
className: "btn btn-primary"}, "Invite to Gather")));
}
return (
React.createElement("div", {className: "panel panel-default"},
React.createElement("div", {className: "panel-heading"},
React.createElement("strong", null, "NS2 Gather "),
React.createElement("span", {className: "badge add-left"}, this.props.gather.gatherers.length)
),
React.createElement(Gatherers, {gather: this.props.gather, currentGatherer: this.currentGatherer()}),
React.createElement(GatherProgress, {gather: this.props.gather}),
React.createElement("div", {className: "panel-footer text-right"},
React.createElement("ul", {className: "list-inline"},
inviteButton,
joinButton
)
)
)
);
}
});
var Gatherers = React.createClass({displayName: "Gatherers",
render: function () {
var self = this;
var gatherers = this.props.gather.gatherers.map(function (gatherer) {
var lifeforms = (
gatherer.user.ability.lifeforms.map(function (lifeform) {
return (React.createElement("span", {className: "label label-default"}, lifeform));
})
);
var commBadge;
if (gatherer.user.ability.commander) {
commBadge = (React.createElement("img", {src: "/images/commander.png",
alt: "Commander",
height: "20",
width: "20"}));
}
var division = (React.createElement("span", {className: "label label-primary"}, gatherer.user.ability.division));
var action = lifeforms;
if (self.props.gather.state === "election") {
var votes = self.props.gather.gatherers.reduce(function (acc, voter) {
if (voter.leaderVote === gatherer.id) acc++;
return acc;
}, 0)
action = (
React.createElement("span", null,
React.createElement("small", null, votes + " votes", "  "),
React.createElement(VoteButton, {currentGatherer: self.props.currentGatherer, candidate: gatherer})
)
);
}
return (
React.createElement("tr", {key: gatherer.user.id},
React.createElement("td", {className: "col-md-1"}, commBadge),
React.createElement("td", {className: "col-md-5"}, gatherer.user.username),
React.createElement("td", {className: "col-md-3"}, division, " "),
React.createElement("td", {className: "col-md-2 text-right"}, action, " ")
)
);
})
if (this.props.gather.gatherers.length) {
return (
React.createElement("div", {className: "panel-body"},
React.createElement("div", {className: "panel panel-default"},
React.createElement("div", {className: "panel-heading"},
React.createElement("h5", {className: "panel-title"}, "Roster")
),
React.createElement("table", {className: "table roster-table"},
React.createElement("tbody", null,
gatherers
)
)
)
)
);
} else {
return (React.createElement("div", {className: "panel-body text-center"}, React.createElement(JoinGatherButton, {buttonClass: "btn-lg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