本网站正在建设中(~ ̄▽ ̄)~
- 你好~!欢迎来到中文歌声合成个人收集站-VCPedia.cn!
- 若发现页面信息有误或投稿至本站,请联系管理员。
MediaWiki:Gadget-vote.js
跳到导航
跳到搜索
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
- Opera:按 Ctrl-F5。
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- $(function () {
- var candidate = ['JackBlock', '不可逆', 'MilkBoy', 'LFTW'];
- var voter = mw.config.get("wgUserName");
- var isVoted = localStorage.getItem('isVoted') === 'true';
- var windowManager = new OO.ui.WindowManager();
- $(document.body).append(windowManager.$element);
- var button = $('<div></div>').addClass('vcep-button').text('管理员投票');
- $('body').append(button);
- var candidatePrompt = $('<div>').addClass('candidatePrompt');
- var candidateDiv = $('<div>').addClass('candidate');
- var candidate1 = new OO.ui.FieldLayout(new OO.ui.RadioSelectInputWidget({
- options: [
- {
- data: '1',
- label: '同意'
- },
- {
- data: '0',
- label: '弃权'
- }
- ]
- }), {
- label: '选举候选人:' + candidate[0],
- align: 'inline',
- });
- var candidate2 = new OO.ui.FieldLayout(new OO.ui.RadioSelectInputWidget({
- options: [
- {
- data: '1',
- label: '同意'
- },
- {
- data: '0',
- label: '弃权'
- }
- ]
- }), {
- label: '选举候选人:' + candidate[1],
- align: 'inline',
- });
- var candidate3 = new OO.ui.FieldLayout(new OO.ui.RadioSelectInputWidget({
- options: [
- {
- data: '1',
- label: '同意'
- },
- {
- data: '0',
- label: '弃权'
- }
- ]
- }), {
- label: '选举候选人:' + candidate[2],
- align: 'inline',
- });
- var candidate4 = new OO.ui.FieldLayout(new OO.ui.RadioSelectInputWidget({
- options: [
- {
- data: '1',
- label: '同意'
- },
- {
- data: '0',
- label: '弃权'
- }
- ]
- }), {
- label: '选举候选人:' + candidate[3],
- align: 'inline',
- });
- console.log(candidate1.getField().getValue());
- candidateDiv.append(candidate1.$element, candidate2.$element, candidate3.$element, candidate4.$element);
- var dialogs = /** @class */ (function (_super) {
- __extends(dialogs, _super);
- function dialogs() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- dialogs.prototype.initialize = function () {
- _super.prototype.initialize.call(this);
- this.content = new OO.ui.PanelLayout({
- padded: true,
- expanded: false
- });
- this.$body.append(this.content.$element);
- };
- dialogs.prototype.getBodyHeight = function () {
- return this.content.$element.outerHeight(true);
- };
- dialogs.static = {
- name: 'voteResult',
- title: '投票结果',
- };
- return dialogs;
- }(OO.ui.Dialog));
- var main = /** @class */ (function (_super) {
- __extends(main, _super);
- function main() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- main.prototype.initialize = function () {
- _super.prototype.initialize.call(this);
- if (candidate.includes(voter)) {
- this.$body.append(candidatePrompt.append($('<p>').text('您是本届管理员选举的候选人,不可投票。')).append($('<p>').text('请耐心等待选举结果。')));
- return;
- }
- else if (isVoted) {
- this.$body.append(candidatePrompt.append($('<p>').text('您已投票完毕,感谢您的投票。')).append($('<p>').text('请耐心等待选举结果。')));
- return;
- }
- this.$body.append(candidateDiv);
- };
- main.prototype.getBodyHeight = function () {
- if (candidate.includes(voter) || isVoted) {
- return 110;
- }
- return 425;
- };
- main.prototype.getActionProcess = function (action) {
- var _this = this;
- if (action === 'cancel') {
- return new OO.ui.Process(function () {
- _this.close({ action: action });
- });
- }
- else if (action === 'submit') {
- return new OO.ui.Process(function () {
- var vote = [candidate1.getField().getValue(), candidate2.getField().getValue(), candidate3.getField().getValue(), candidate4.getField().getValue()];
- fetch("http://m8.ctymc.cn:26613/api/vote/vote?id=".concat(1, "&vote=").concat(vote.join('')), { method: 'POST' });
- localStorage.setItem('isVoted', 'true');
- isVoted = true;
- mw.notify('感谢您的参与!', {
- title: '投票成功',
- type: 'success',
- autoHide: true
- });
- _this.close({ action: action });
- });
- }
- return _super.prototype.getActionProcess.call(this, action);
- };
- ;
- main.static = {
- name: 'vote',
- title: 'VCPedia第1届(2025)管理员选举',
- size: 'medium',
- actions: [{ action: 'cancel', label: '取消', flags: ['safe', 'close'] },
- { action: 'submit', label: '提交', flags: ['primary', 'progressive'] }]
- };
- return main;
- }(OO.ui.ProcessDialog));
- var dialog = new main();
- windowManager.addWindows([dialog]);
- button.on('click', function () {
- windowManager.openWindow(dialog);
- });
- });