本网站正在建设中(~ ̄▽ ̄)~

  • 你好~!欢迎来到中文歌声合成个人收集站-VCPedia.cn!
  • 若发现页面信息有误投稿至本站,请联系管理员。

MediaWiki:Gadget-vote.js

VCPedia.cn ——关于中文歌声合成的一切。
MilkBoy讨论 | 贡献2025年1月29日 (三) 16:30的版本
跳到导航 跳到搜索

注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:Ctrl-F5
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. if (typeof b !== "function" && b !== null)
  11. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  12. extendStatics(d, b);
  13. function __() { this.constructor = d; }
  14. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15. };
  16. })();
  17. $(function () {
  18. var candidate = ['JackBlock', '不可逆', 'MilkBoy', 'LFTW'];
  19. var voter = mw.config.get("wgUserName");
  20. var isVoted = localStorage.getItem('isVoted') === 'true';
  21. var windowManager = new OO.ui.WindowManager();
  22. $(document.body).append(windowManager.$element);
  23. var button = $('<div></div>').addClass('vcep-button').text('管理员投票');
  24. $('body').append(button);
  25. var candidatePrompt = $('<div>').addClass('candidatePrompt');
  26. var candidateDiv = $('<div>').addClass('candidate');
  27. var candidate1 = new OO.ui.FieldLayout(new OO.ui.RadioSelectInputWidget({
  28. options: [
  29. {
  30. data: '1',
  31. label: '同意'
  32. },
  33. {
  34. data: '0',
  35. label: '弃权'
  36. }
  37. ]
  38. }), {
  39. label: '选举候选人:' + candidate[0],
  40. align: 'inline',
  41. });
  42. var candidate2 = new OO.ui.FieldLayout(new OO.ui.RadioSelectInputWidget({
  43. options: [
  44. {
  45. data: '1',
  46. label: '同意'
  47. },
  48. {
  49. data: '0',
  50. label: '弃权'
  51. }
  52. ]
  53. }), {
  54. label: '选举候选人:' + candidate[1],
  55. align: 'inline',
  56. });
  57. var candidate3 = new OO.ui.FieldLayout(new OO.ui.RadioSelectInputWidget({
  58. options: [
  59. {
  60. data: '1',
  61. label: '同意'
  62. },
  63. {
  64. data: '0',
  65. label: '弃权'
  66. }
  67. ]
  68. }), {
  69. label: '选举候选人:' + candidate[2],
  70. align: 'inline',
  71. });
  72. var candidate4 = new OO.ui.FieldLayout(new OO.ui.RadioSelectInputWidget({
  73. options: [
  74. {
  75. data: '1',
  76. label: '同意'
  77. },
  78. {
  79. data: '0',
  80. label: '弃权'
  81. }
  82. ]
  83. }), {
  84. label: '选举候选人:' + candidate[3],
  85. align: 'inline',
  86. });
  87. console.log(candidate1.getField().getValue());
  88. candidateDiv.append(candidate1.$element, candidate2.$element, candidate3.$element, candidate4.$element);
  89. var dialogs = /** @class */ (function (_super) {
  90. __extends(dialogs, _super);
  91. function dialogs() {
  92. return _super !== null && _super.apply(this, arguments) || this;
  93. }
  94. dialogs.prototype.initialize = function () {
  95. _super.prototype.initialize.call(this);
  96. this.content = new OO.ui.PanelLayout({
  97. padded: true,
  98. expanded: false
  99. });
  100. this.$body.append(this.content.$element);
  101. };
  102. dialogs.prototype.getBodyHeight = function () {
  103. return this.content.$element.outerHeight(true);
  104. };
  105. dialogs.static = {
  106. name: 'voteResult',
  107. title: '投票结果',
  108. };
  109. return dialogs;
  110. }(OO.ui.Dialog));
  111. var main = /** @class */ (function (_super) {
  112. __extends(main, _super);
  113. function main() {
  114. return _super !== null && _super.apply(this, arguments) || this;
  115. }
  116. main.prototype.initialize = function () {
  117. _super.prototype.initialize.call(this);
  118. if (candidate.includes(voter)) {
  119. this.$body.append(candidatePrompt.append($('<p>').text('您是本届管理员选举的候选人,不可投票。')).append($('<p>').text('请耐心等待选举结果。')));
  120. return;
  121. }
  122. else if (isVoted) {
  123. this.$body.append(candidatePrompt.append($('<p>').text('您已投票完毕,感谢您的投票。')).append($('<p>').text('请耐心等待选举结果。')));
  124. return;
  125. }
  126. this.$body.append(candidateDiv);
  127. };
  128. main.prototype.getBodyHeight = function () {
  129. if (candidate.includes(voter) || isVoted) {
  130. return 110;
  131. }
  132. return 425;
  133. };
  134. main.prototype.getActionProcess = function (action) {
  135. var _this = this;
  136. if (action === 'cancel') {
  137. return new OO.ui.Process(function () {
  138. _this.close({ action: action });
  139. });
  140. }
  141. else if (action === 'submit') {
  142. return new OO.ui.Process(function () {
  143. var vote = [candidate1.getField().getValue(), candidate2.getField().getValue(), candidate3.getField().getValue(), candidate4.getField().getValue()];
  144. fetch("http://m8.ctymc.cn:26613/api/vote/vote?id=".concat(1, "&vote=").concat(vote.join('')), { method: 'POST' });
  145. localStorage.setItem('isVoted', 'true');
  146. isVoted = true;
  147. mw.notify('感谢您的参与!', {
  148. title: '投票成功',
  149. type: 'success',
  150. autoHide: true
  151. });
  152. _this.close({ action: action });
  153. });
  154. }
  155. return _super.prototype.getActionProcess.call(this, action);
  156. };
  157. ;
  158. main.static = {
  159. name: 'vote',
  160. title: 'VCPedia第1届(2025)管理员选举',
  161. size: 'medium',
  162. actions: [{ action: 'cancel', label: '取消', flags: ['safe', 'close'] },
  163. { action: 'submit', label: '提交', flags: ['primary', 'progressive'] }]
  164. };
  165. return main;
  166. }(OO.ui.ProcessDialog));
  167. var dialog = new main();
  168. windowManager.addWindows([dialog]);
  169. button.on('click', function () {
  170. windowManager.openWindow(dialog);
  171. });
  172. });