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

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

MediaWiki:Gadget-vote.js:修订间差异

VCPedia.cn ——关于中文歌声合成的一切。
跳到导航 跳到搜索
无编辑摘要
(转ES5)
第1行: 第1行:
"use strict";
"use strict";
$(function() {
var __extends = (this && this.__extends) || (function () {
    const candidate = ['JackBlock', '不可逆', 'MilkBoy', 'LFTW']
   var extendStatics = function (d, b) {
    const voter = mw.config.get("wgUserName");
     extendStatics = Object.setPrototypeOf ||
    let isVoted = localStorage.getItem('isVoted') === 'true';
       ({ __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]; };
    const windowManager = new OO.ui.WindowManager();
     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('管理员投票');
    const button = $('<div></div>').addClass('vcep-button').text('管理员投票');
    $('#footer').append(button);
    $('#footer').append(button);
    
    var candidatePrompt = $('<div>').addClass('candidatePrompt');
   const candidatePrompt = $('<div>').addClass('candidatePrompt')
    var candidateDiv = $('<div>').addClass('candidate');
 
    var candidate1 = new OO.ui.FieldLayout(new OO.ui.RadioSelectInputWidget({
    const candidateDiv = $('<div>').addClass('candidate')
    const candidate1 = new OO.ui.FieldLayout(new OO.ui.RadioSelectInputWidget({
      options: [
      options: [
        {
        {
第26行: 第37行:
      ]
      ]
    }), {
    }), {
      label : '选举候选人:' + candidate[0],
      label: '选举候选人:' + candidate[0],
      align : 'inline',
      align: 'inline',
    })
    });
    const candidate2 = new OO.ui.FieldLayout(new OO.ui.RadioSelectInputWidget({
    var candidate2 = new OO.ui.FieldLayout(new OO.ui.RadioSelectInputWidget({
      options: [
      options: [
        {
        {
第41行: 第52行:
      ]
      ]
    }), {
    }), {
      label : '选举候选人:' + candidate[1],
      label: '选举候选人:' + candidate[1],
      align : 'inline',
      align: 'inline',
    })
    });
    const candidate3 = new OO.ui.FieldLayout(new OO.ui.RadioSelectInputWidget({
    var candidate3 = new OO.ui.FieldLayout(new OO.ui.RadioSelectInputWidget({
      options: [
      options: [
        {
        {
第56行: 第67行:
      ]
      ]
    }), {
    }), {
      label : '选举候选人:' + candidate[2],
      label: '选举候选人:' + candidate[2],
      align : 'inline',
      align: 'inline',
    })
    });
    const candidate4 = new OO.ui.FieldLayout(new OO.ui.RadioSelectInputWidget({
    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 OO.ui.Dialog {
     __extends(dialogs, _super);
      static static = {
      function dialogs() {
        name: 'voteResult',
        return _super !== null && _super.apply(this, arguments) || this;
       title: '投票结果',
      }
      }
 
      dialogs.prototype.initialize = function () {
      initialize() {
        _super.prototype.initialize.call(this);
        super.initialize();
        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);
   class main extends OO.ui.ProcessDialog{
     static static = {
       name: 'vote',
       title: 'VCPedia第1届(2025)管理员选举',
       size: 'medium',
       actions: [{ action: 'cancel', label: '取消', flags: [ 'safe', 'close' ] },
            { action: 'submit', label: '提交', flags: [ 'primary', 'progressive' ] }]
     }
 
     initialize() {
        super.initialize();
        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 });
            _this.close({ action: action });
          });
          });
        } else if (action === 'submit') {
        }
          return new OO.ui.Process(() => {
       else if (action === 'submit') {
            const vote = [candidate1.getField().getValue(), candidate2.getField().getValue(), candidate3.getField().getValue(), candidate4.getField().getValue()];
          return new OO.ui.Process(function () {
            fetch(`http://m8.ctymc.cn:26613/api/vote/vote?id=${1}&vote=${vote.join('')}`, {method: 'POST'})
            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 });
            _this.close({ action: action });
          });
          });
        }
        }
        return super.getActionProcess(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));
    const dialog = new main();
    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的版本

  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. $('#footer').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. });