用户:A2569875/SpecialWikitext/小工具编译测试

已使用自架wiki站点进行小工具编译:

自架wiki站點/load.php?lang=zh-tw&modules=ext.gadget.SpecialWikitext,site-lib
内容讯息:
  • 编译原始码:Special:PermaLink/65562390
  • 编译前大小:21,130个位元组(20.63 kb)
  • 编译后大小:15,250个位元组(14.89 kb)
  • 编译器版本:
    • MediaWiki :1.35.1
    • Gadgets :(in MediaWiki 1.35.1)
    • PHP :7.4.11
  • 小工具编译器设定:
    • *SpecialWikitext[ResourceLoader|default|dependencies=ext.gadget.site-lib,mediawiki.api|hidden|targets=desktop,mobile|type=general]|SpecialWikitext.js
错误讯息:
暂无。
编译结果:
mw.loader.implement("ext.gadget.SpecialWikitext@1ubz8",function($,jQuery,require,module){(function($,mw){var wikiTextKey="_addText";function _check(input_string,content_model){var contentModel=(content_model||mw.config.get('wgPageContentModel')).toString().toLowerCase();switch(contentModel){case'json':return _getJSONwikitext(input_string);case'js':case'javascript':return _getJSwikitext(input_string);case'css':case'sanitized-css':return _getCSSwikitext(input_string);default:return'';}}function _addText(input_str,new_str,_escape){if(new_str!==''){if(input_str!=='')input_str=input_str+'\n';var text=new_str;if(_escape){var escape_str=JSON.stringify(new_str.toString());escape_str=escape_str.substr(1,escape_str.length-2);text=escape_str;}input_str+=text;}return input_str;}function _getString(str){var test_str=/[^\n]*\*\//.exec(str);if(test_str){test_str=test_str[0]||'';test_str=test_str.substr(0,test_str.length-2);}else test_str=str;var trim_check=test_str.trim();var first_char=trim_check.
charAt(0);if(first_char===trim_check.charAt(trim_check.length-1)&&(first_char==="'"||first_char==='"'))return trim_check.substr(1,trim_check.length-2);else return test_str;}function _getContentText(str){var wikitext='';try{str.replace(new RegExp(wikiTextKey+"\\s*\\{[^c\\}]*content\\s*:\\s*[^\n]*",'g'),function(text){var temp_text=(/content\s*:\s*[^\n]*/.exec(text)||['content:'])[0].replace(/^[\s\uFEFF\xA0\t\r\n\f ;}]+|[\s\uFEFF\xA0\t\r\n\f ;}]+$/g,'').replace(/\s*content\s*:\s*/,'');if(wikitext!=='')wikitext+='\n';wikitext+=_getString(temp_text);return text;});}catch(ex){return'';}return wikitext;}function _getObjText(str){var wikitext='';try{str.replace(new RegExp(wikiTextKey+"\\s*[\\=:]\\s*[^\n]*",'g'),function(text){var temp_text=text.replace(/^[\s\uFEFF\xA0\t\r\n\f ;}]+|[\s\uFEFF\xA0\t\r\n\f ;}]+$/g,'').replace(new RegExp(wikiTextKey+"\\s*[\\=:]\\s*"),'');if(wikitext!=='')wikitext+='\n';wikitext+=_getString(temp_text);return text;});}catch(ex){return'';}return wikitext;}function
_getCSSwikitext(input_string){var wikitext='';var css_text=input_string||$("#wpTextbox1").val()||'';if(css_text.trim()==='')return'';wikitext=_addText(wikitext,_getContentText(css_text),true);wikitext=_addText(wikitext,_getObjText(css_text));return wikitext;}function _getJSwikitext(input_string){var wikitext='';var js_text=input_string||$("#wpTextbox1").val()||'';if(js_text.trim()==='')return'';wikitext=_addText(wikitext,_getObjText(js_text));return wikitext;}function _getJSONwikitext(input_string){var wikitext='';var json_text=input_string||$("#wpTextbox1").val()||'';if(json_text.trim()==='')return'';try{var json_data=JSON.parse(json_text);Object.keys(json_data).forEach(function(key){var k=key,v=json_data[key];if(new RegExp(wikiTextKey).exec(k)&&typeof(v)===typeof('')){wikitext=_addText(wikitext,v);}if(typeof(v)!==typeof('')){for(var prop in v){if(Object.hasOwnProperty.call(v,prop)){var testArr_k=prop,testArr_v=v[prop];if(new RegExp(wikiTextKey).exec(testArr_k)&&typeof(testArr_v)===
typeof('')){wikitext=_addText(wikitext,testArr_v);}}}}});}catch(ex){return'';}return wikitext;}function previewTool(){var _notice_addText="{{Twinkle standard installation}}{{ambox| type  = notice| sect  = 腳本| issue = 為[[Module:Special wikitext]]的[[JavaScript]]實現,功能為在頁面預覽時運作[[Module:Special wikitext]]的效果。| fix   = 修改本腳本時請確定相關算法與[[Module:Special wikitext]]一致。}}";var _data_addText="{{ambox| type  = notice| sect  = 腳本| issue = 主要功能是以[[AJAX]]實現未能以介面完成文字插入的頁面模板放置。}}";var _notice_loading=
'<div id="mw-_addText-preview-loading"><div class="quotebox" style="margin: auto; width: 50%; padding: 6px; border: 1px solid #aaa; font-size: 88%; background-color: #F9F9F9;"><div id="mw-_addText-preview-loading-content" style="background-color: #F9F9F9; color: black; text-align: center; font-size: larger;"><img src="//upload.wikimedia.org/wikipedia/commons/d/de/Ajax-loader.gif" decoding="async" data-file-width="32" data-file-height="32" width="32" height="32"> '+wgULS('预览加载中...','預覽載入中...')+' </div></div></div>';var _notice_fail=
'<img src="//upload.wikimedia.org/wikipedia/commons/thumb/e/e9/Gnome-dialog-warning2.svg/32px-Gnome-dialog-warning2.svg.png" decoding="async" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/e/e9/Gnome-dialog-warning2.svg/48px-Gnome-dialog-warning2.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/e/e9/Gnome-dialog-warning2.svg/64px-Gnome-dialog-warning2.svg.png 2x" data-file-width="48" data-file-height="48" width="32" height="32">'+wgULS('预览加载失败','預覽載入失敗');function _elementExist(selectors){var selector_array=Array.isArray(selectors)?selectors:(selectors?[selectors]:[]);var ele_count=0;for(var i in selector_array){if(Object.hasOwnProperty.call(selector_array,i))ele_count+=$(selector_array[i]).length;}return ele_count>0;}function _checkMwConfig(checkTarget,mwConfigs){var mwConfigData=mw.config.get(checkTarget);if(!mwConfigData||(mwConfigData.toString().trim()===''))return false;mwConfigData=mwConfigData.toString().toLowerCase();var mwConfig_array
=Array.isArray(mwConfigs)?mwConfigs:(mwConfigs?[mwConfigs]:[]);return mwConfig_array.indexOf(mwConfigData)>-1;}function _addParsedWikitext(parsedWikitext){var _html_obj=$(parsedWikitext);if(_elementExist('#mw-_addText-preview-loading'))$('#mw-_addText-preview-loading').html(parsedWikitext);else if(_elementExist('.diff-currentversion-title'))_html_obj.insertAfter('.diff-currentversion-title');else if(_elementExist('.previewnote'))_html_obj.insertAfter('.previewnote');else if(_elementExist('#mw-undelete-revision'))_html_obj.insertAfter('#mw-undelete-revision');else if(_elementExist('#mw-content-text'))_html_obj.insertBefore('#mw-content-text');}function _setHtml(selector,html_content){if(_elementExist(selector))$(selector).html(html_content);}function _addLoadingNotice(){if((_notice_addText||_data_addText)&&_notice_loading)_addParsedWikitext(_notice_loading);}function _loadingFailNotice(){_setHtml('#mw-_addText-preview-loading-content',_notice_fail);}function _removeLoadingNotice(){
_setHtml('#mw-_addText-preview-loading','');}function _needPreview(){return document.body.innerHTML.search("_addText")>-1;}function _addWikiText(wikiText,pagename,is_preview){if(wikiText.toString().trim()!==''){var params={action:'parse',title:pagename+'/temp',text:wikiText,contentmodel:"wikitext",prop:"text",format:'json'};if(is_preview){params.preview=1;params.disableeditsection=1;}new mw.Api().get(params).done(function(data){var parsed_wiki=(data.parse.text['*']||'').toString().trim();if(parsed_wiki!==''){_addParsedWikitext(parsed_wiki);}else _removeLoadingNotice();}).fail(function(){_loadingFailNotice();});}else _removeLoadingNotice();}function _addLuaText(wikiText,pagename,is_preview,call_back){var temp_module_name="AddText/Temp/Module/Data.lua";var module_call={wikitext:"#invoke:",pagename:"Module:"};if(wikiText.toString().trim()!==''){var params={action:"parse",format:"json",title:pagename,text:"{{"+module_call.wikitext+temp_module_name+"|main}}",prop:"text",contentmodel:
"wikitext",templatesandboxtitle:module_call.pagename+temp_module_name,templatesandboxtext:"return {main=function()\nxpcall(function()\n"+wikiText+"\nend,function()end)\nlocal moduleWikitext = package.loaded[\"Module:Module wikitext\"]\nif moduleWikitext then\nlocal wikitext = moduleWikitext.main()\nif mw.text.trim(wikitext)~=''then\nreturn mw.getCurrentFrame():preprocess(moduleWikitext.main())\nend\nend\nreturn ''\nend}",templatesandboxcontentmodel:"Scribunto",templatesandboxcontentformat:"text/plain"};if(is_preview){params.preview=1;params.disableeditsection=1;}new mw.Api().get(params).done(function(data){var parsed_wiki=(data.parse.text['*']||'').toString().trim();if(parsed_wiki!==''){if($(parsed_wiki).find(".scribunto-error").text().search(temp_module_name)<0){if(typeof(call_back)===typeof($.noop))call_back(parsed_wiki);else _addParsedWikitext(parsed_wiki);}else _removeLoadingNotice();}else _removeLoadingNotice();}).fail(function(){_loadingFailNotice();});}else _removeLoadingNotice(
);}function _applyRevision(revisionId,current_page_name){new mw.Api().get({action:'parse',oldid:mw.config.get('wgRevisionId'),prop:'wikitext',format:'json'}).done(function(data){var page_content=_check((data.parse.wikitext['*']||'').toString().trim());page_content=(_elementExist('#mw-clearyourcache')?("{{int:clearyourcache}}"+(page_content.toString().trim()===''?'':'\n')):"")+page_content.toString();if(page_content.toString().trim()!=='')_addWikiText(page_content,current_page_name);else _removeLoadingNotice();}).fail(function(){_removeLoadingNotice();});}function _applyNotice(current_page_name){new mw.Api().get({action:'parse',title:current_page_name,text:'{{#ifexist:Template:Editnotices/Page/'+current_page_name+'|{{Editnotices/Page/'+current_page_name+'}} }}',prop:'text',format:'json'}).done(function(data){var html=data.parse.text['*'];if($(html.toString()).text().trim()!=='')_addParsedWikitext(html);});}function wikitextPreviewTestcase(is_preview){if(!_needPreview())return;var
testcase_list=$('.special-wikitext-preview-testcase');if(testcase_list.length<0)return;var testcase_data_list=[],i,testcase_it;for(i=0;i<testcase_list.length;++i){testcase_it=testcase_list[i];var code_it=$(testcase_it).find('.mw-highlight');if(code_it.length>0){var code_id=(/(?:mw-highlight-lang-)([^\s]+)/.exec($(code_it[0]).attr("class"))||[])[1];var load_index=testcase_data_list.length;$(testcase_it).attr("preview-id",load_index);testcase_data_list.push({element:testcase_it,lang:code_id,code:code_it.text().toString()});}}var package_wikitext='';for(i in testcase_data_list){if(Object.hasOwnProperty.call(testcase_data_list,i)){testcase_it=testcase_data_list[i];if(testcase_it.code.trim()!==''){if(['javascript','js','css','json'].indexOf(testcase_it.lang.toLowerCase())>-1){var addWiki=_check(testcase_it.code,testcase_it.lang);if(addWiki.toString().trim()!==''){$(testcase_it.element).prepend(_notice_loading);package_wikitext+='<div class="special-wikitext-preview-testcase-'+i+'">'+addWiki
+'</div>';}}else if(['lua','scribunto'].indexOf(testcase_it.lang.toLowerCase())>-1){_addLuaText(testcase_it.code,mw.config.get("wgPageName"),is_preview,(function(index){return function(wikitext){$(testcase_data_list[index].element).prepend(wikitext);};})(i));}}}}if(package_wikitext.trim()!==''){package_wikitext='<div class="special-wikitext-preview-testcase-undefined">'+package_wikitext+'</div>';var params={action:'parse',text:package_wikitext,contentmodel:"wikitext",prop:"text",format:'json'};if(is_preview){params.preview=1;params.disableeditsection=1;}new mw.Api().get(params).done(function(data){var parsed_wiki=(data.parse.text['*']||'').toString().trim();if(parsed_wiki!==''){var parsed_element=$(parsed_wiki);for(var i in testcase_data_list){if(Object.hasOwnProperty.call(testcase_data_list,i)){var testcase_it=testcase_data_list[i];if(['javascript','js','css','json'].indexOf(testcase_it.lang.toLowerCase())>-1){var check_parse_result=parsed_element.find(
".special-wikitext-preview-testcase-undefined > .special-wikitext-preview-testcase-"+i);if(check_parse_result.length>0){$(testcase_it.element).find('#mw-_addText-preview-loading').html(check_parse_result);}}}}}});}}function _addPreview(){var current_page_name=mw.config.get("wgPageName");if(_checkMwConfig('wgPageContentModel',['javascript','js','json','css','sanitized-css'])){if(_elementExist('.previewnote')){var preview_selector=$('.previewnote .warningbox > p > b a');if(preview_selector.length>0){var path_path=decodeURI(preview_selector.attr('href')||('/wiki/'+current_page_name)).replace(/^\/?wiki\//,'');if(path_path!==current_page_name)return;}var addWiki=_check();if(addWiki.toString().trim()!==''){_addLoadingNotice();_addWikiText(addWiki,current_page_name,true);}}else if(!_elementExist('#mw-clearyourcache')&&_checkMwConfig('wgAction','view')){if(!_needPreview())return;if(!_elementExist("#wpTextbox1")){_addLoadingNotice();_applyRevision(mw.config.get('wgRevisionId'),current_page_name
);}}else if(_elementExist('#mw-revision-info')&&_checkMwConfig('wgAction','view')){if(!_elementExist("#wpTextbox1")){$('#mw-clearyourcache').html(_notice_loading);_applyRevision(mw.config.get('wgRevisionId'),current_page_name);}}else _removeLoadingNotice();}else if(_checkMwConfig('wgPageContentModel',['Scribunto','scribunto','lua'])){if(!_needPreview())return;if(_elementExist("#wpTextbox1")&&_elementExist("table.diff")&&!_elementExist('.previewnote')&&!_checkMwConfig('wgAction','view')){$(_notice_loading).insertAfter('#wikiDiff');_addLuaText($("#wpTextbox1").val(),current_page_name,true);}}else if(_elementExist('#mw-undelete-revision')){if(!_needPreview())return;if(_elementExist(['.mw-highlight','pre','.mw-json'])){var tryGetWiki=$('textarea').val();var tryAddWiki=_getJSONwikitext(tryGetWiki);if(tryAddWiki.trim()==='')tryAddWiki=_getCSSwikitext(tryGetWiki);if(tryAddWiki.trim()!==''){_addLoadingNotice();_addWikiText(tryAddWiki,mw.config.get("wgRelevantPageName"),true);}else if(
/Module[_ ]wikitext.*_addText/i.exec($('.mw-parser-output').text())){}}}else if(!_elementExist('.mw-editnotice')&&_checkMwConfig('wgCanonicalNamespace','special')){var pagename=mw.config.get('wgCanonicalSpecialPageName');if(pagename!==false&&pagename!==null&&pagename.toString().trim()!==''){var fullpagename=mw.config.get('wgCanonicalNamespace')+':'+pagename;_applyNotice(fullpagename);}}else _removeLoadingNotice();}if(mw.config.get("wgIsSpecialWikitextPreview")!==true){mw.config.set("wgIsSpecialWikitextPreview",true);_addPreview();wikitextPreviewTestcase(true);}}mw.loader.using('ext.gadget.site-lib').done(previewTool).fail(function(){if(typeof wgULS!==typeof($.noop))wgULS=function(a){return a;};previewTool();});})(jQuery,mw);});mw.loader.implement("ext.gadget.site-lib@1rqnr",function($,jQuery,require,module){window.wgUXS=function(wg,hans,hant,cn,tw,hk,sg,zh,mo,my){var ret={'zh':zh||hans||hant||cn||tw||hk||sg||mo||my,'zh-hans':hans||cn||sg||my,'zh-hant':hant||tw||hk||mo,'zh-cn':cn||hans||sg||my,'zh-sg':sg||hans||cn||my,'zh-tw':tw||hant||hk||mo,'zh-hk':hk||hant||mo||tw,'zh-mo':mo||hant||hk||tw}
return ret[wg]||zh||hans||hant||cn||tw||hk||sg||mo||my;}
window.wgULS=function(hans,hant,cn,tw,hk,sg,zh,mo,my){return wgUXS(mw.config.get('wgUserLanguage'),hans,hant,cn,tw,hk,sg,zh,mo,my);};window.wgUVS=function(hans,hant,cn,tw,hk,sg,zh,mo,my){return wgUXS(mw.config.get('wgUserVariant'),hans,hant,cn,tw,hk,sg,zh,mo,my);};mw.log.deprecate(window,'addPortletLink',function(){return mw.util.addPortletLink.apply(mw.util,arguments);},'Use mw.util.addPortletLink() instead');mw.log.deprecate(window,'getURLParamValue',function(){return mw.util.getParamValue.apply(mw.util,arguments);},'Use mw.util.getParamValue() instead');mw.log.deprecate(window,'hasClass',function(element,className){return $(element).hasClass(className);},'Use jQuery.hasClass() instead');window.importScriptCallback=function(page,ready){importScriptURICallback(mw.config.get('wgServer')+mw.config.get('wgScript')+'?title='+mw.util.wikiUrlencode(page)+'&action=raw&ctype=text/javascript',ready);};window.importScriptURICallback=jQuery.getScript;});