Diferencia entre revisiones de «Usuario:He7d3r/Tools/LanguageConverter.js»
Contenido eliminado Contenido añadido
Sin resumen de edición |
Solo en text-container |
||
Línea 73:
t.conv_callback=function(i){t.conv_typo_document();var o,a,s,r,g,c,l,p,d,_,u,h,f,v,m=t.settings.global_dic_page[t.lang],w=[],y=e.config.get("skin");if(!m)return alert(t.getLocalMsg("error_missing_dict_name")+t.lang),n.removeSpinner("var-spinner"),!1;if(!i)return n.removeSpinner("var-spinner"),!1;if(o=i.query,o&&(a=o.pages,s=o.pageids),!o||!a||!s)return n.removeSpinner("var-spinner"),!1;for(typeof m=="object"&&(m=m.pages||m.page),m=m.split("|"),d=0;s.length>d;d+=1)a[s[d]].pageid?w.push([a[s[d]].revisions[0]["*"],m.indexOf(a[s[d]].title)]):(alert(t.getLocalMsg("error_missing_dict")+a[s[d]].title),location.href=e.util.getUrl(null,{variant:e.config.get("wgContentLanguage")}));if(!w.length)return n.removeSpinner("var-spinner"),void 0;for(w.sort(function(e,n){return e[1]-n[1]}),d=0;w.length>d;d+=1){r=w[d][0],g=r.split("\n");for(c in g)h=/^\*\s*(\S[^:]*?)\s*:\s*([\S].*?)\s*(?:\/\/.*?)?$/.exec(g[c]),h&&(t.dictionary[h[1]]=h[2])}if(_=t.settings.local_dic_id,_&&(_=_[t.lang]),u=_?document.getElementById(_):null){r=u.innerHTML,g=r.split("\n");for(d in g)h=/^<li>\s*(\S[^:]*?)(?:\s| | )*:\s*([\S].*?)\s*(?:\/\/.*?)?<\/li>$/i.exec(g[d]),h&&(t.dictionary[h[1]]=h[2])}n.cookie(t.cookie,t.lang,{expires:7,path:"/",secure:t.secure}),v=!1,l=t.conv_text_from_dic(document.title,v),l&&(document.title=l),t.conv_node_from_dic(t.$target[0]),t.conv_text_from_template(),f=t.settings.variants_list;for(p in f)f[p]!==null&&n("#ca-conv-"+p).toggleClass("selected",p===t.lang&&y==="vector");t.settings.show_menu_title&&n("#p-variants-js").find("span").text(f[t.lang]).attr("class","flag-"+t.lang),n("#ca-conv-show-hide-changes").toggle(t.lang!==e.config.get("wgContentLanguage")),t.mustReload=!0,n.removeSpinner("var-spinner")},
t.startConversion=function(i){var o,a,s,r,g,c,l;if(t.lang=i,t.regClass=RegExp("(?:\\s|^)(?:v-"+t.lang+"|diff-(?:context|deletedline|addedline)|"+t.settings.no_conversion_class+")(?:\\s|$)"),t.regTypoChanges=[],r=t.settings.typo_changes,r&&(r=r[t.lang]),r) if(r.constructor===Array)for(o=0;r.length>o;o+=1)g=r[o],g.length===2&&g[1]!==null&&(typeof g[0]=="string"&&(g[0]=RegExp(e.RegExp.escape(g[0]),"g")),t.regTypoChanges.push(g));else if(r.constructor===Object)for(o in r)if(r.hasOwnProperty&&r[o]!==null)try{a=RegExp(e.RegExp.escape(o),"g"),t.regTypoChanges.push([a,r[o]])} catch(p){alert(t.getLocalMsg("error_typo_processing")+o+": "+r[o]+".\n\n"+p.message)} return i===e.config.get("wgContentLanguage")?!1:(n("#p-variants-js").injectSpinner({id:"var-spinner"}),s=t.settings.global_dic_page[t.lang],typeof s=="object"?(c=s.api,typeof c=="object"&&c.length===2&&(c=t.secure?c[1]:c[0]),s=s.pages||s.page,l=c===e.config.get("wgServer")+e.util.wikiScript("api")?"json":"jsonp"):(c=e.util.wikiScript("api"),l="json"),n.ajax({url:c,dataType:l,data:{format:"json",action:"query",titles:s,prop:"revisions",rvprop:"content",indexpageids:"1"},success:t.conv_callback}),void 0)},
t.isAllowed=function(){var n=t.settings.ns_list,i="*"===n||n[e.config.get("wgNamespaceNumber")],o=t.settings.local_dic_id,a=o[e.config.get("wgContentLanguage")]?document.getElementById(o[e.config.get("wgContentLanguage")]):!1;switch(t.settings.selection_mode){case"AND":if(!i||!a)return!1;break;case"OR":if(!i&&!a)return!1}return!0},t.load=function(){t.settings={msg:{error_missing_dict:"The following dictionary was not found:\n",error_missing_dict_name:"It is necessary to define the page name of the dictionary for ",error_word_processing:"Error has occurred while processing the following word:\n",error_typo_processing:"Error has occurred while processing the following typographic change:\n",help_page_link:"Open help page",show_changes_link:"Show changes",hide_changes_link:"Hide changes",menu_title:"Variants"},word_chars:"a-zA-Z'-",typo_changes:{},variants_list:{},ns_list:{0:!0},local_dic_id:"modernization",no_conversion_class:"no-conversion",global_dic_page:"Project:Dictionary",help_page:"Project:Language Converter",show_changes:!1,show_menu_title:!0,selection_mode:"AND",max_seq:3},n.extend(!0,t.settings,t.config),t.isAllowed()&&(t.secure=location.protocol==="https:",t.$target=n("#
// </nowiki>
|