跳转到内容

User:2011wp/test.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
  mw.loader.using( 'jquery.ui', function() {
    // Construct object (to prevent namespace conflicts)
    wikiTips = {
 

      displayError: function( form, error ) {
        $('#'+form+' div').hide(); // remove everything else from the dialog box
        $('#'+form).append ( $('<div style="color:#990000;margin-top:0.4em;"></div>').html( '錯誤: '+error ) );
      },
 
      getEditToken: function() {
        $.ajax({
          url: wgScriptPath + '/api.php?',
          data: 'action=query&prop=info&intoken=edit&titles=Main%20Page&indexpageids&format=json',
          dataType: 'json',
          success: function( data ) {
            if ( data.query.pages && data.query.pageids ) {
              var pageid = data.query.pageids[0];
              wikiTips.editToken = data.query.pages[pageid].edittoken;
            }
          }
        });
      },

      editPage: function( form, template, pnn ) {
        $.ajax({
          url: wgScriptPath + '/api.php?',
          data: 'action=edit&title='+encodeURIComponent(pnn)+'&text='+encodeURIComponent(template)+'&format=json&token='+encodeURIComponent(wikiTips.editToken),
          dataType: 'json',
          type: 'POST',
          success: function( data ) {
            if ( data.edit.result == "Success" ) {
              window.location.reload();
            } else {
              wikiTips.displayError( form, 'API結果不明。請嘗試登出維基百科,再次登入維基百科並返回本頁再次加入維基提示。' );
            }
          },
          error: function( xhr ) {
            wikiTips.displayError( form, xhr.code );
          }
        });
      },
 

      launchDialog: function( interface, emailOption ) {
        // Open the dialog box
        interface.dialog('open');
        // Retrieve the edit token so it will be available when the form is submitted
        wikiTips.getEditToken();
      },
 
      initialize: function() {
 
        // Function to make a list of images selectable
        $.fn.selectItem = function() {
          return this.each(function() {
            var containerId = this.id;
            var customId = 0;
            $('#'+containerId+' img').css('border', '8px solid transparent');
            $('#'+containerId+' img').each(function() {
              if (this.id == '') {
                this.id = 'select_img_' + customId;
                customId++;
              }
              $('#'+this.id).click(function() {
                  $('#'+containerId+'Selected').val(this.title);
                  $('#'+containerId+' img').css('border', '8px solid transparent');
                  $('#'+this.id).css('border', '8px solid #AED0EA');
              })
            });
          });
        };

        // Define edittips interface
        $wlEdittipss = $('<div id="edittipsForm" style="position:relative;"></div>').dialog({
            width: 500,
            autoOpen: false,
            title: '編輯提示',
            modal: true,
            buttons: { "發出這個提示": function() { 
              $(this).dialog({buttons:{}});
              if ( typeof wikiTips.editToken !== 'undefined' ) {
                if ( $('#edittipsForm input[name="notify"]').attr('checked') ) {
                  // Send email
                  wikiTips.sendEmail( 'edittipsForm', '維基百科編輯提示', '你好 '+wgTitle+'!\n\n有用戶給了你一個關於「'+$('#edittipsSelect').val()+'」的維基百科編輯提示,目前在你的中文維基百科用戶討論頁上待你查閱,希望你能積極參與維基百科。' );
                }
                // Perform edit to page
                var template = 'aaaaaaaaaaaaaaaaaa';
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa1');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa2');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa3');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa4');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa5');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa6');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa7');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa8');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa9');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa10');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa11');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa12');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa13');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa14');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa15');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa16');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa17');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa18');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa19');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa20');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa21');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa22');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa23');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa24');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa25');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa26');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa27');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa28');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa29');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa30');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa31');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa32');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa33');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa34');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa35');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa36');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa37');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa38');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa39');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa40');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa41');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa42');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa43');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa44');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa45');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa46');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa47');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa48');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa49');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa50');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa51');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa52');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa53');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa54');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa55');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa56');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa57');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa58');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa59');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa60');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa61');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa62');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa63');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa64');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa65');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa66');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa67');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa68');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa69');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa70');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa71');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa72');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa73');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa74');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa75');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa76');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa77');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa78');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa79');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa80');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa81');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa82');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa83');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa84');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa85');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa86');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa87');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa88');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa89');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa90');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa91');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa92');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa93');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa94');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa95');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa96');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa97');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa98');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa99');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa100');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa101');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa102');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa103');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa104');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa105');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa106');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa107');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa108');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa109');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa110');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa111');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa112');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa113');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa114');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa115');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa116');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa117');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa118');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa119');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa120');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa121');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa122');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa123');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa124');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa125');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa126');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa127');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa128');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa129');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa130');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa131');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa132');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa133');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa134');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa135');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa136');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa137');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa138');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa139');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa140');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa141');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa142');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa143');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa144');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa145');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa146');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa147');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa148');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa149');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa150');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa151');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa152');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa153');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa154');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa155');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa156');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa157');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa158');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa159');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa160');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa161');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa162');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa163');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa164');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa165');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa166');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa167');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa168');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa169');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa170');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa171');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa172');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa173');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa174');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa175');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa176');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa177');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa178');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa179');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa180');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa181');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa182');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa183');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa184');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa185');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa186');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa187');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa188');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa189');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa190');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa191');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa192');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa193');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa194');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa195');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa196');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa197');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa198');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa199');
                wikiTips.editPage( 'edittipsForm', template ,'User:2011wp/aaaa200');
              } else {
                wikiTips.displayError( 'edittipsForm', '無法完成編輯' );
              }
            }}
          });
        // Insert new tab into page
        var menuEdittips = '<li id="wl-edittips"><span><a onclick="wikiTips.launchDialog( $wlEdittipss, true ); return false;" href="#">提示</a></span></li>';
        var wikiTipsMenu = '<div class="vectorMenu" id="p-wikitips"><h5><span>WikiTips</span><a href="#" style="padding:0 0.4em;width:auto;"><span style="display:inline-block;height:2.5em;width:16px;margin-right:14px;background-position:0 60%;background-image:url(http://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Crystal_Clear_app_ktip.png/20px-Crystal_Clear_app_ktip.png);background-repeat:no-repeat;">&nbsp;</span></a></h5><div class="menu"><ul>'+menuEdittips+'</ul></div></div>';
        $('#p-cactions').after(wikiTipsMenu);
 
      } // close initialize function
 
    } // close wikiTips object
    wikiTips.initialize();
  }) // close mw.loader