User:Poccil/myskin.js
From Wikipedia, the free encyclopedia
If a message on your talk page led you here, please be wary of who left it. Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. If this is a .js page, the code will be executed when previewing the page.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
function getPname() { z=document.getElementById("content").childNodes; for (var n=0;n<z.length;n++) { if (z[n].className=="firstHeading") { var text = z[n].textContent ? z[n].textContent : z[n].innerText; return text; } } } function import_module(page){ if( document.createElement && document.childNodes ) { var url = 'http://en.wikipedia.org/w/index.php?title=' + page + '&action=raw&ctype=text/javascript'; var scriptElem = document.createElement('script'); scriptElem.setAttribute('src',url); scriptElem.setAttribute('type','text/javascript'); document.getElementsByTagName('head')[0].appendChild(scriptElem); } } function replace() { var s = prompt("Search regexp?"); if(s) { var r = prompt("Replace regexp?"); if(!r && r != '') return; var txt = document.editform.wpTextbox1; txt.value = txt.value.replace(new RegExp(s, "g"), r); } } // User:Gimmetrow/replace.js addOnloadHook(function () { if(document.forms.editform) { addLink('p-cactions', 'javascript:replace()', 'replace', 'ca-replace', 'Regexp replace for the edit window', '', 'ca-history'); } }); var ta=[] function addLink(where, url, name, id, title, key, after){ //* where is the id of the toolbar where the button should be added; // i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb". // //* url is the URL which will be called when the button is clicked. // javascript: urls can be used to do more complex things. // //* name is what will appear as the name of the button. // //* id is the id of the button; it's best to define one. // Use a prefix to make sure its unique. Optional. // //* title is the tooltip title that gives a longer description // of the button; if you define a accesskey, mention it here. Optional. // //* key is the char you want for the accesskey. Optional. // //* after is the id of the button you want to follow this one. Optional. // var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); if(id) li.id = id; li.appendChild(na); var tabs = document.getElementById(where) tabs=tabs.getElementsByTagName('ul')[0]; if(after) { tabs.insertBefore(li,document.getElementById(after)); } else { tabs.appendChild(li); } if(id) { if(key && title) { ta[id] = [key, title]; } else if(key) { ta[id] = [key, '']; } else if(title) { ta[id] = ['', title];} } // re-render the title and accesskeys from existing code in wikibits.js akeytt(); return li; } function getElementsByClassName(oElm, strTagName, strClassName){ var arrElements=(strTagName=="*"&&oElm.all)?oElm.all: oElm.getElementsByTagName(strTagName); var arrReturnElements = new Array(); strClassName = strClassName.replace(/\-/g, "\\-"); var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)"); var oElement; for(var i=0; i<arrElements.length; i++){ oElement = arrElements[i]; if(oRegExp.test(oElement.className)){ arrReturnElements.push(oElement); } } return (arrReturnElements) } function getelbyclass(cls){ var e=getElementsByClassName(document,"*",cls) return e?e[0]:null } function getspclpagelist(cls){ var e=document.getElementById("bodyContent") e=e.getElementsByTagName("ul") return e?e[0]:null } function sortfunc(a,b){ return a[2]-b[2] } function sortlist(){ var a=[] var listel=getelbyclass('special') var list=listel.childNodes for(var i=0;i<list.length;i++){ var itxt=list[i].innerText itm=itxt.match(/\[([\d,]+)\s+bytes/i) if(itm&&itm[1]){ itm=parseInt(itm[1].replace(/[\.,]/g,"")) a[i]=[i,list[i],itm] } else { a[i]=[i,list[i],0] } } a=a.sort(sortfunc) for(var i=0;i<a.length;i++){ listel.appendChild(a[i][1]) } } function removeimagereverts(){ var a=[] var listel=getspclpagelist() var list=listel.childNodes for(var i=0;i<list.length;i++){ var itxt=list[i].innerText if(/reverted\s+to\s+earlier/i.exec(itxt)){ a[a.length]=list[i] } } for(var i=0;i<a.length;i++){ listel.removeChild(a[i]) } } var oldonload=onload onload=function(){ addLink("p-navigation",'javascript:sortlist()',"Sort items","poccil-sort") addLink("p-navigation",'javascript:removeimagereverts()', "Remove image reverts","poccil-noimgrev") if(oldonload)oldonload() } function importPage(site){ var s=site.replace(/ /g,"_") s = s.replace(/^\[\[/, '').replace(/\]\]$/, ''); s=escape(s) s=s.replace(/([\/\[\]])/g, function(a,b){ return "%"+b.charCodeAt(0).toString(16).toUpperCase() }) var x='<scr'+'ipt type="text/javascript" src="http://en.wikipedia.org/w/index.php?title=' + s + '&action=raw&ctype=text/javascript&dontcountme=s"></sc'+'ript>' // alert(x) document.write(x); } //Import two prerequisites for some scripts. importPage('Wikipedia:WikiProject User scripts/Scripts/addLink'); importPage('Wikipedia:WikiProject User scripts/Scripts/addTab'); if(0){ //add in cacyle's editor // include comfortable javascript editor by cacycle // levels of undo (each level holds the whole text) undoBufferMax = 20; // style for preview box stylePreviewBox = 'background-color: #f9f9f9;'; // style for custom edit buttons styleButtons = 'font-size: smaller; padding-left: 0.1em; padding-right: 0.1em'; // presets for input field dropdown options findHistoryLength = 10; // preset for combo box select options presetOptions = []; presetOptions['summary'] = [ 'Copyedit', 'Linkfix', 'Reverting vandalism', 'Formatting source text' ]; // expiration time span for history cookies in seconds cookieExpireSec = (365 * 24 * 60 * 60); // enable cursor horizontal position memory cursorMemory = true; // show at least this number of lines ahead of cursor movement scrollMargin = 1; // show at least this number of lines ahead of cursor movement for findMargin = 2; // find ahead checkbox selected by default findAheadSelected = true; // css for change indicators styleDelete = 'font-weight: normal; text-decoration: none; color: #ffffff; background-color: #990033;'; styleInsert = 'font-weight: normal; text-decoration: none; color: #ffffff; background-color: #009933;'; styleMoved = 'font-weight: bold; vertical-align: text-bottom; font-size: xx-small; padding: 0; border: solid 1px;'; styleBlock = [ 'background-color: #ffff44;', 'background-color: #b0ff90;', 'background-color: #ffcc99;', 'background-color: #99ffff;', 'background-color: #99ccff;', 'background-color: #cc99ff;', 'background-color: #ff99cc;', 'background-color: #ffd040;', 'background-color: #d0d0d0;' ]; // html for change indicators, {number} is replaced by the block number, {block} is replaced by the block style htmlMovedRight = '<input type="button" value=">" style="' + styleMoved + ' {block}">'; htmlMovedLeft = '<input type="button" value="<" style="' + styleMoved + ' {block}">'; htmlBlockStart = '<span style="{block}">'; htmlBlockEnd = '</span>'; htmlDeleteStart = '<del style="' + styleDelete + '">'; htmlDeleteEnd = '</del>'; htmlInsertStart = '<ins style="' + styleInsert + '">'; htmlInsertEnd = '</ins>'; // minimal number of real words for a moved block (0 for always displaying block move indicators) blockMinLength = 3; // exclude identical sequence starts and endings from change marking wordDiff = true; // enable recursive diff to resolve problematic sequences recursiveDiff = true; // enable block move display showBlockMoves = true; } importPage('[[User:Cacycle/diff.js]]') function getAnchors() { var s=[''], anchs=document.getElementsByTagName('A'); for (var i=0; i<anchs.length; ++i) if (anchs[i].name && anchs[i].name!='top') s.push(anchs[i].name); return s; } window.handleKeys=function(evt){ if (window.handleKeys.disabled) { return true; } var k = window.event ? window.event.keyCode : ( evt.keyCode ? evt.keyCode : evt.which); if (!k) return; var letter=String.fromCharCode(k); switch (letter) { case 'j': changeAnchor(1); return false; case 'J': changeAnchor('last'); return false; case 'k': changeAnchor(-1); return false; case 'K': changeAnchor('first'); return false; default: return true; } } window.handleKeys.disabled=false; window.handleKeys.disableFlags=[]; function setupFocusHandlers(elType, startAt) { var inputs=document.getElementsByTagName(elType); var j=startAt || 0; for (var i=0; i<inputs.length; ++i) { if (elType=='input' && inputs[i].type.toLowerCase()!='text') { continue; } window.handleKeys.disableFlags[j]=false; inputs[i].onfocus=function(){ window.handleKeys.disableFlags[j]=true; updateDisabledFlag(); } inputs[i].onblur=function(){ window.handleKeys.disableFlags[j]=false; updateDisabledFlag(); } ++j; } //alert(j + ' handlers installed'); return j; } function updateDisabledFlag() { for (var i=0; i<window.handleKeys.disableFlags.length; ++i) { if (window.handleKeys.disableFlags[i]===true) { window.handleKeys.disabled=true; return true; } } window.handleKeys.disabled=false; return false; } var anchs, pos; window.changeAnchor=function(step, loop) { if(!anchs && !(anchs=getAnchors()) ) return; var loc=document.location.toString().split('#'); switch (step) { case 'first': pos=0; break; case 'last': pos=anchs.length-1; break; default: if (loc.length > 0) { var target=loc.slice(1).join('#'); for (var i=0; i<anchs.length; ++i) { if (anchs[i]==target) { pos=i; break; } } } if(typeof pos==='number') { pos += step; if (loop) { while(pos < 0) pos += anchs.length; pos %= anchs.length; } else { if (pos<0) pos=0; if(pos>=anchs.length) pos=anchs.length-1; } } else pos = 0; } /* switch */ var newloc=loc[0] + '#' + anchs[pos]; if(document.location!=newloc) document.location=newloc; } var sectionKeysPage=( ! /^(Editing|Search -|Confirm|Move page|Logs|E-mail user|All pages|Block user)/.test(document.title) && ! /([?&]=|wiki\/)[Ss]pecial:/.test(document.location) ); if (sectionKeysPage) { addOnloadHook(function(){ var j=setupFocusHandlers('input'); setupFocusHandlers('textarea', j); document.onkeypress=window.handleKeys; }); } if(0){ // CHECK THAT I'VE REMEMBERED TO SIGN TALK PAGES AND IF SURE DO IT AUTOMATIC: // *** aut. signing / (automatische Unterschrift) *** 23. Apr. 2006 by [[User:Olliminatore]] // updated by [[:en:User:Ilmari Karonen]] v1.43 //<pre><nowiki> // helper-function String.prototype.trim = function(){return this.replace(/^\s*|\s*$/g,"")}; addOnloadHook(function () { if(!document.editform) return; title = document.title; // Object to String // regarded pages regpages=new Array('talk:', 'Talk:', ':Village pump', ':Articles for deletion', ':Requests for adminship', ':Current surveys'); for (p in regpages) if(title.indexOf(regpages[p])!=-1){ regpages=false; break } if(regpages) return; var txtObj=document.editform.wpTextbox1; var txtOld=txtObj.value.trim(); txtOld_l=txtOld.length var txtOldEnd=txtOld.slice(-24); function doSign(){ if(document.editform.onsubmit==''){ // only once! removeEvent(document.editform.wpSave,"click",doSign); removeEvent(document.editform.wpPreview,"click",doSign); } if(document.editform.wpMinoredit.checked) return true; signing = ' --\ ~\~\~ ~\~\~\~\~\n'; if(!txtObj.value.match(/~{3}/)){ txt=txtObj.value.trim(); txtEnd=txt.slice(-24); if(txtOldEnd!=txtEnd) return txtObj.value = txt + signing; // aut. underwrite else { // post between pos = getCaretPos(txtObj); pos = txt.indexOf('\n', pos); // go to the post-end txtEnds = txt.substr(pos,24).replace(/^\s*/,""); // after txtpEnds = txt.slice(pos-18,pos); // before olldp = txtOld.indexOf(txtEnds); if(olldp!=-1 && olldp < pos - 3 && txtOld.search(txtpEnds+txtEnds)==-1) // if some added return txtObj.value = txt.slice(0,pos).trim() + signing + txt.slice(pos+1); } // FIXME: the edit-end is not found } else if(txtOld.search(/~{3}/)==-1 || !txtOld.match(/<nowiki>.*?~{3}.*?<\/nowiki>/i)) return 1; else if(txtOld.match(/~{3}/g).length < txtObj.value.match(/~{3}/g).length) return 1; return document.editform.onsubmit=new Function("document.editform.onsubmit='';return confirm('No signing was found. Save anyway?')"); }; addEvent(document.editform.wpSave,"click", doSign) addEvent(document.editform.wpPreview,"click", doSign) }); } function getCaretPos(txtObj) { if(txtObj.setSelectionRange) return txtObj.selectionStart; // NS like else if(!document.selection) return 0; // not IE like txtObj.focus(); var c="\001", pos=0; var range=document.selection.createRange(); var txt=range.text, dul=range.duplicate(); dul.moveToElementText(txtObj); range.text=txt+c; pos=(dul.text.indexOf(c)); range.moveStart('character',-1); range.text=""; return pos; }; function addEvent(obj,type,fn){if(obj.addEventListener){obj.addEventListener(type,fn,false)}else if(obj.attachEvent){var eProp=type+fn;obj["e"+eProp]=fn;obj[eProp]=function(){obj["e"+eProp](window.event)};obj.attachEvent("on"+type,obj[eProp])}else{obj['on'+type]=fn}}; function removeEvent(obj,type,fn){if(obj.removeEventListener){obj.removeEventListener(type,fn,false)}else if(obj.detachEvent){var eProp=type+fn;obj.detachEvent("on"+type,obj[eProp]);obj['e'+eProp]=null;obj[eProp]=null}else{obj['on'+type]=null}}; //*** end *** //</nowiki></pre> // Interwiki <noinclude>[[de:Benutzer:Olliminatore/Signatur.js]]</noinclude> //User:Lupin/popups.js popupShortcutKeys=true; // optional: enable keyboard shortcuts popupAdminLinks=false; // optional: enable admin links popupDelay=.7; popupFixRedits=true; popupInitialWidth=200; popupFixRedirs=true; popupFixDabs=true; popupLastModified=true; popupMaxPreviewSentences=1; popupImages=false; popupSubpopups=true; popupWatchRedirredPages=false; popupRedirAutoClick='wpSave'; popupRedlinkRemoval=true; popupLastModified=true; popupDiffDates=true; popupOnlyArticleLinks=true; imagePopupsForImages=false; popupStructure='fancy2'; importPage('[[User:Lupin/popups.js]]') importPage('Wikipedia:WikiProject_User_scripts/Scripts/Fix_diff_width'); //Formats the article by removing excess whitespace and simplifying links. importPage('Wikipedia:WikiProject User scripts/Scripts/Formatter'); importPage('[[User:Howcheng/quickimgdelete.js]]') importPage('[[User:Poccil/quickafd.js]]') /* Syntax highlighter */ if(document.title.indexOf(".js") == -1) // Ignore pages that end in .js addOnloadHook(function () { /* CSS syntax highlighting */ multicommentRE = new RegExp('(/\\*[\\s\\S]*?\\*/)', 'g'); ruleRE = new RegExp('([^\\{]+)\\{([^\\}]+)\\}', 'g'); idselectorRE = new RegExp('(#[a-zA-Z0-9\-\_]+)\\b', 'g'); classselectorRE = new RegExp('(\\.[a-zA-Z0-9\-\_]+)\\b', 'g'); pairRE = new RegExp('([a-zA-Z-]+):([^;]+);', 'g'); css = document.getElementsByTagName('pre'); for (i = 0; i < css.length; i++) { c = css[i]; content = c.innerHTML; content=content.replace(multicommentRE, '<span class="comment">$1</span>'); content = content.replace(ruleRE, function(text, selector, body) { selector = selector.replace(idselectorRE, '<span class="idselector">$1</span>'); selector = selector.replace(classselectorRE, '<span class="classselector">$1</span>'); body = body.replace(pairRE, '<span class="property">$1</span>:<span class="value">$2</span>;'); return selector + '{' + body + '}'; }); c.innerHTML = content; } }); importPage('User:Zocky/SearchBox.js'); importPage("User:Lupin/recent2.js"); /* <pre> */ /* This function is used to include scripts from other Wikipedia pages in mine. I got it from [[User:Quarl/monobook.js]]. */ function winc(s) { s = s.replace(/^\[\[/, '').replace(/\]\]$/, ''); document.write('<scr' + 'ipt type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=' + s + '&action=raw&ctype=text/javascript&dontcountme=s"></scr' + 'ipt>'); } /* Included functions */ winc('[[User:Omegatron/monobook.js/addlink.js]]'); /* Adds links to lists on the page, such as the personal tools section */ winc('[[User:Omegatron/monobook.js/fixdiffwidth.js]]'); winc('[[User:Omegatron/monobook.js/edittop.js]]'); winc('[[User:Omegatron/monobook.js/namedredirect.js]]'); winc('[[User:Omegatron/monobook.js/autolinker.js]]'); /* Add some extra tabs with different functionalities. */ winc('[[User:Omegatron/monobook.js/replacetab.js]]'); // Regex replacements in the text (from [[User:Trilobite/Tools]]) winc('[[User:Omegatron/monobook.js/unverified.js]]'); // Tag unverified images (from [[User:Trilobite/Tools]]) // winc('[[User:Omegatron/monobook.js/addsincetab.js]]'); // Shows difference between my last edit and current version ([[Wikipedia:WikiProject User scripts/Scripts/Changes since I last edited]]) winc('[[User:Omegatron/monobook.js/dashfixer.js]]'); // Converts -- into — and so on (User:Omegatron) winc('[[User:Omegatron/monobook.js/unitformatter.js]]'); // Formats units according to SI (User:Omegatron) winc('[[User:Omegatron/monobook.js/mathcharacterfixer.js]]'); // Fixes up some math characters (not TeX) (User:Omegatron) winc('[[User:Omegatron/monobook.js/headingformattingfixer.js]]'); // Adds and removes whitespace to make formatting consistent and readable (User:Omegatron) /* This function is used to include individual scripts from Quarl's pages in mine. */ function qinc(s) { // alert("qinc") var x='<scr' + 'ipt type="text/javascript" src="' + 'http://wikipedia.quarl.org/scripts/' + s + '.js"></scr' + 'ipt>' // alert(x) document.write(x); } /* All kinds of scripts from [[User:Quarl]] */ if(0){ qinc('module'); qinc('datetime'); qinc('msg'); qinc('util'); qinc('wikiwidget'); qinc('wikins'); qinc('wikipage'); } var $diff = new Object() var $util = new Object() $util.trimSpaces = function(s) { if (!s) return s; s = s.replace(/^\s+/,''); s = s.replace(/\s+$/,''); return s; } function ReverseString(s) { var ret = ''; for (var i = s.length-1; i >= 0; --i) { ret += s.charAt(i); } return ret; } $util.pprintf = function(fmt) { // start at last argument in case we have more than 9 arguments for (var i = arguments.length; i >= 1; --i) { fmt = fmt.replace(new RegExp('\\$' + i,'g'), arguments[i]); } return fmt; }; $diff.options = { // if more than this many words of changes, use overflow string summary_maxwords: 40, summary_overflow: "$1 words changed" }; $diff.diff = function(o, n) { var ns = {}; var os = {}; for ( var i = 0; i < n.length; i++ ) { // note we have to check that it is in fact an object with "rows", in // case ns[i] happens to match a javascript member function of class // Array, e.g. "some"! if ( ns[ n[i] ] == null || !ns[n[i]].rows ) ns[ n[i] ] = { rows: new Array(), o: null }; ns[ n[i] ].rows.push( i ); } for ( var i = 0; i < o.length; i++ ) { if ( os[ o[i] ] == null || !os[o[i]].rows ) os[ o[i] ] = { rows: new Array(), n: null }; os[ o[i] ].rows.push( i ); } for ( var i in ns ) { if ( ns[i].rows.length == 1 && typeof(os[i]) != "undefined" && os[i].rows.length == 1 ) { n[ ns[i].rows[0] ] = { text: n[ ns[i].rows[0] ], row: os[i].rows[0] }; o[ os[i].rows[0] ] = { text: o[ os[i].rows[0] ], row: ns[i].rows[0] }; } } for ( var i = 0; i < n.length - 1; i++ ) { if ( n[i].text != null && n[i+1].text == null && 0 <= n[i].row+1 && n[i].row+1 < o.length && o[ n[i].row + 1 ].text == null && n[i+1] == o[ n[i].row + 1 ] ) { n[i+1] = { text: n[i+1], row: n[i].row + 1 }; o[n[i].row+1] = { text: o[n[i].row+1], row: i + 1 }; } } for ( var i = n.length - 1; i > 0; i-- ) { if ( n[i].text != null && n[i-1].text == null && 0 <= n[i].row-1 && n[i].row-1 < o.length && o[ n[i].row - 1 ].text == null && n[i-1] == o[ n[i].row - 1 ] ) { n[i-1] = { text: n[i-1], row: n[i].row - 1 }; o[n[i].row-1] = { text: o[n[i].row-1], row: i - 1 }; } } return { o: o, n: n }; } $diff._split = function(s) { //return $util.trimSpaces(s).split(/(?:\s|[.,;\'\"`])+/); return s.split(/\s+/); } $diff.aggregate = function(words) { var phrases = new Array(); var cur = null; var wordcount = 0; // start at virtual index -1 to check for removed words at beginning of // text for ( var i = -1; i < words.n.length; i++ ) { if ( i!=-1 && words.n[i].text == null ) { if (!cur) { cur = { o: "", n: "" }; phrases.push(cur); } cur.n += " " + words.n[i]; wordcount ++; } else { var pre = ""; var j = i==-1 ? 0 : words.n[i].row + 1; while ( j < words.o.length && words.o[j].text == null ) { pre += " " + words.o[j]; j++; wordcount ++; } if (pre) { if (!cur) { cur = { o: "", n: "" }; phrases.push(cur); } cur.o += pre; } if (pre && words.n[i+1] && words.n[i+1].text == null) { // If there's an addition following, treat this as part of the // same change. } else { cur = null; } } } for (var i=0;i<phrases.length;i++) { phrases[i].n = $util.trimSpaces(phrases[i].n); phrases[i].o = $util.trimSpaces(phrases[i].o); } return { phrases: phrases, wordcount: wordcount }; } $diff.wikiQuote = function(s) { if (!s) return s; if (s.match(/^\{\{.*\}\}$/)) return s; s = s.replace(/\"/g, "'"); return '"'+s+'"'; } // trim the equal chars from the front and back of o,n at a word boundary $diff.stringTrim = function(o, n) { var r = $diff.stringTrim0(ReverseString(o), ReverseString(n)); return $diff.stringTrim0(ReverseString(r.o), ReverseString(r.n)); } $diff.stringTrim0 = function(o, n) { var i = 0; while (i < o.length && i < n.length && o[i] == n[i]) { ++i; } // find index of last non-word character var prefix = o.substr(0, i); // if prefix ends with word characters and suffix starts with non-word, // then erase entire prefix if (prefix.match(/\w$/) && !o.substr(i, 1).match(/^\w/) && !n.substr(i, 1).match(/^\w/)) { o = o.substr(i); n = n.substr(i); } else if (prefix.match(/.*\W/)) { i = RegExp.lastMatch.length; o = o.substr(i); n = n.substr(i); } else { // keep entire prefix } // alert(o) // alert(n) return { o: o, n: n }; } $diff._wikiQuoteWords = function(s) { var words = $diff._split(s); if (words.length > $diff.options.summary_maxwords) { return $util.pprintf('($1 words)', words.length); } else { return $diff.wikiQuote(words.join(' ')); } } $diff.diffSummary = function(o, n) { o = $util.trimSpaces(o); n = $util.trimSpaces(n); if (o == n) return ""; if (!o) { return "new: +" + $diff._wikiQuoteWords(n); } if (!n) { return "blank: -" + $diff._wikiQuoteWords(o); } var words = $diff.diff( $diff._split(o), $diff._split(n) ); var r = $diff.aggregate(words); if (!r.wordcount) return ""; if (r.wordcount > $diff.options.summary_maxwords) { return $util.pprintf($diff.options.summary_overflow, r.wordcount); } var phrases = r.phrases; var str = []; for (var i=0;i<phrases.length;i++) { var r = $diff.stringTrim(phrases[i].o, phrases[i].n); var ro = $diff.wikiQuote(r.o), rn = $diff.wikiQuote(r.n); if (ro && rn) { str.push(ro + ' --> ' + rn); } else if (ro) { str.push('-' + ro); } else if (rn) { str.push('+' + rn); } else { // alert("## internal error 15e1b13f-bae3-4399-86c5-721786822fa2"); } } return str.join(", "); } if(0){ qinc('shortcuts'); qinc('diffsince'); qinc('wikiwatch'); qinc('watchlist'); qinc('watchbutton'); qinc('autofocus'); qinc('newmessages'); qinc('tabsince'); } var oldtext="" function editsum(){ if(document.editform.wpSection.value!="new"){ var sum=document.editform.wpSummary.value var newtext=document.editform.wpTextbox1.value var newsum=$diff.diffSummary(oldtext,newtext) var semic=((sum&&newsum)?"; ":"") var m=sum.match(/\/\*.*?\*\//) if(m){ sum=sum.replace(m[0],"") sum=m[0]+newsum+semic+sum } else { sum=newsum+semic+sum } document.editform.wpSummary.value=sum } } function hookEventObj(a,b,c){ a['on'+b]=c } function saveoldtext(){ if(document.editform){ oldtext=document.editform.wpTextbox1.value hookEventObj(document.editform.wpSave, 'click', function(){editsum();}); hookEventObj(document.editform.wpDiff, 'click', function(){editsum();}); hookEventObj(document.editform.wpPreview, 'click', function(){editsum();}); } } function justredirs(){ var els=document.getElementsByTagName("li") for(var i=0;i<els.length;i++){ if(els[i].innerText.indexOf("(redirect page)")<0){ els[i].style.display="none" els[i].innerHTML="" } } } addOnloadHook(function () { //$watchbutton.widgetLoad(); //$tabsince.widgetLoad(); //$watchlist.widgetLoad(); saveoldtext() /* uncomment this to hide alert() errors */ //$msg.alert_disabled=true; }); addOnloadHook(function () { addLink('p-personal', '/wiki/User:Poccil/myskin.js', 'My monobook.js', 'pt-monobookjs', 'monobook.js is used for storing user javascripts', '', 'pt-logout'); addLink('p-personal', '/wiki/User:Poccil/myskin.css', 'My monobook.css', 'pt-monobookcss', 'monobook.css is used for storing user CSS styles', '', 'pt-logout'); addLink('p-personal', '/w/index.php?title=Special%3AAllpages&from=Poccil&namespace=2', 'My subpages', 'pt-subpages', 'Subpages of my userspace', '', 'pt-logout'); addLink('p-personal', '/w/index.php?title=Special:Whatlinkshere&limit=5000&from=0&fakeaction=redirs&target='+escape(getPname())+'&from=Poccil&namespace=2', 'Redirs', 'pt-redirs', 'What redirects here', '', 'pt-logout'); addLink('p-personal', 'javascript:catlen()', 'Category items', 'pt-redirs', 'What redirects here', '', 'pt-logout'); if(location.href.indexOf("fakeaction=redirs")>=0){ justredirs() document.forms[0].style.display="none" } }); function GetXmlHTTP() { var A; try { A=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { A=new ActiveXObject("Microsoft.XMLHTTP"); } catch (oc) {A=null;} } if(!A && typeof XMLHttpRequest != "undefined") A = new XMLHttpRequest(); return A; } function SajaxCall(uri, target) { var i, x, n; uri="http://en.wikipedia.org/wiki/"+uri; var post_data; var sajax_request_type = "GET"; if (sajax_request_type == "GET") { post_data = null; } else { } x = GetXmlHTTP(); if (!x) { alert("AJAX not supported"); return false; } x.open(sajax_request_type, uri, true); if (sajax_request_type == "POST") { x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1"); x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); } x.setRequestHeader("Content-Type", "text/xml"); x.setRequestHeader("Pragma", "cache=yes"); x.setRequestHeader("Cache-Control", "no-transform"); x.onreadystatechange = function() { if (x.readyState != 4) return; if ( typeof( target ) == 'function' ) { var rt=x.responseText .replace(/\ \;/," ") .replace(/\®\;/,"®") x.responseXML.loadXML(rt) target( x.responseXML ); } else if ( typeof( target ) == 'object' ) { x.responseXML.loadXML(x.responseText) target[0]=x.responseXML target[1]=1 } return; } x.send(post_data); delete x; return true; } function upage(xml){ var atags=xml.getElementsByTagName("a") var images=[] for(var i=0;i<atags.length;i++){ var href=atags[i].getAttribute("href") var title=atags[i].getAttribute("title") var ie=(href)?href.indexOf("Image:"):-1 if(ie>=0&&title){ images[images.length]=title } } alert(images) } function getatt(tag,a){ var re=new RegExp("\\s+"+a+"\\s*\\=\\s*([\"\'])(.*?)(\\1)") var e=re.exec(tag) if(e){ return e[2] } return "" } function upage2(ae){ // alert(ae) var atags=ae.match(/<[Aa]\s+.*?>/g) var images=[] for(var i=0;atags&&i<atags.length;i++){ var href=getatt(atags[i],"href") var title=getatt(atags[i],"title") status=[href,title] var ie=(href)?href.indexOf("Image:"):-1 if(ie>=0){ images[images.length]=href.substr(ie+6) } } // alert(images) } function catlen(){ upage2(document.body.innerHTML) } //addOnloadHook(function () { // upage2(document) //})