本网站正在建设中(~ ̄▽ ̄)~
- 你好~!欢迎来到中文歌声合成个人收集站-VCPedia.cn!
- 若发现页面信息有误或投稿至本站,请联系管理员。
MediaWiki:Gadget-vote.js:修订间差异
跳到导航
跳到搜索
小无编辑摘要 |
小 (转ES5) |
||
第1行: | 第1行: | ||
"use strict"; | "use strict"; | ||
$(function() { | 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); | $(document.body).append(windowManager.$element); | ||
var button = $('<div></div>').addClass('vcep-button').text('管理员投票'); | |||
$('#footer').append(button); | $('#footer').append(button); | ||
var candidatePrompt = $('<div>').addClass('candidatePrompt'); | |||
var candidateDiv = $('<div>').addClass('candidate'); | |||
var candidate1 = new OO.ui.FieldLayout(new OO.ui.RadioSelectInputWidget({ | |||
options: [ | options: [ | ||
{ | { | ||
第26行: | 第37行: | ||
] | ] | ||
}), { | }), { | ||
label : '选举候选人:' + candidate[0], | label: '选举候选人:' + candidate[0], | ||
align : 'inline', | align: 'inline', | ||
}) | }); | ||
var candidate2 = new OO.ui.FieldLayout(new OO.ui.RadioSelectInputWidget({ | |||
options: [ | options: [ | ||
{ | { | ||
第41行: | 第52行: | ||
] | ] | ||
}), { | }), { | ||
label : '选举候选人:' + candidate[1], | label: '选举候选人:' + candidate[1], | ||
align : 'inline', | align: 'inline', | ||
}) | }); | ||
var candidate3 = new OO.ui.FieldLayout(new OO.ui.RadioSelectInputWidget({ | |||
options: [ | options: [ | ||
{ | { | ||
第56行: | 第67行: | ||
] | ] | ||
}), { | }), { | ||
label : '选举候选人:' + candidate[2], | label: '选举候选人:' + candidate[2], | ||
align : 'inline', | align: 'inline', | ||
}) | }); | ||
var candidate4 = new OO.ui.FieldLayout(new OO.ui.RadioSelectInputWidget({ | |||
options: [ | options: [ | ||
{ | { | ||
第71行: | 第82行: | ||
] | ] | ||
}), { | }), { | ||
label : '选举候选人:' + candidate[3], | label: '选举候选人:' + candidate[3], | ||
align : 'inline', | align: 'inline', | ||
}) | }); | ||
console.log(candidate1.getField().getValue()) | console.log(candidate1.getField().getValue()); | ||
candidateDiv.append(candidate1.$element, candidate2.$element, candidate3.$element, candidate4.$element) | candidateDiv.append(candidate1.$element, candidate2.$element, candidate3.$element, candidate4.$element); | ||
var dialogs = /** @class */ (function (_super) { | |||
class dialogs | __extends(dialogs, _super); | ||
function dialogs() { | |||
return _super !== null && _super.apply(this, arguments) || this; | |||
} | } | ||
dialogs.prototype.initialize = function () { | |||
initialize() { | _super.prototype.initialize.call(this); | ||
this.content = new OO.ui.PanelLayout({ | this.content = new OO.ui.PanelLayout({ | ||
padded: true, | padded: true, | ||
第90行: | 第99行: | ||
}); | }); | ||
this.$body.append(this.content.$element); | this.$body.append(this.content.$element); | ||
} | }; | ||
dialogs.prototype.getBodyHeight = function () { | |||
getBodyHeight() { | |||
return this.content.$element.outerHeight(true); | 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)) { | if (candidate.includes(voter)) { | ||
this.$body.append(candidatePrompt.append($('<p>').text('您是本届管理员选举的候选人,不可投票。')).append($('<p>').text('请耐心等待选举结果。'))); | this.$body.append(candidatePrompt.append($('<p>').text('您是本届管理员选举的候选人,不可投票。')).append($('<p>').text('请耐心等待选举结果。'))); | ||
return; | return; | ||
} else if (isVoted) { | } | ||
else if (isVoted) { | |||
this.$body.append(candidatePrompt.append($('<p>').text('您已投票完毕,感谢您的投票。')).append($('<p>').text('请耐心等待选举结果。'))); | this.$body.append(candidatePrompt.append($('<p>').text('您已投票完毕,感谢您的投票。')).append($('<p>').text('请耐心等待选举结果。'))); | ||
return; | return; | ||
} | } | ||
this.$body.append(candidateDiv); | this.$body.append(candidateDiv); | ||
} | }; | ||
main.prototype.getBodyHeight = function () { | |||
getBodyHeight() { | |||
if (candidate.includes(voter) || isVoted) { | if (candidate.includes(voter) || isVoted) { | ||
return 110; | return 110; | ||
} | } | ||
return 425; | return 425; | ||
} | }; | ||
main.prototype.getActionProcess = function (action) { | |||
getActionProcess(action) { | var _this = this; | ||
if (action === 'cancel') { | if (action === 'cancel') { | ||
return new OO.ui.Process(() | return new OO.ui.Process(function () { | ||
_this.close({ action: action }); | |||
}); | }); | ||
} else if (action === 'submit') { | } | ||
return new OO.ui.Process(() | else if (action === 'submit') { | ||
return new OO.ui.Process(function () { | |||
fetch( | 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'); | localStorage.setItem('isVoted', 'true'); | ||
isVoted = true; | isVoted = true; | ||
第140行: | 第149行: | ||
type: 'success', | type: 'success', | ||
autoHide: true | autoHide: true | ||
}) | }); | ||
_this.close({ action: action }); | |||
}); | }); | ||
} | } | ||
return | 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]); | windowManager.addWindows([dialog]); | ||
button.on('click', function() { | button.on('click', function () { | ||
windowManager.openWindow( dialog ); | windowManager.openWindow(dialog); | ||
}); | }); | ||
}) | }); |
2025年1月29日 (三) 16:25的版本
- "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('管理员投票');
- $('#footer').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);
- });
- });