User:Shine/valve.js
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
// addPurge addOnloadHook(function () { var hist; var url; if (!(hist = document.getElementById('ca-history') )) return; if (!(url = hist.getElementsByTagName('a')[0] )) return; if (!(url = url.href )) return; addPortletLink('p-cactions', url.replace(/([?&]action=)history([&#]|$)/, '$1purge$2'), 'Purge', 'ca-purge', 'Purge server cache for this page', '0'); }); // // Adds a "Replace" tab which pops up two prompt boxes; one for a regexp and one for a replacement function wpTextboxReplace() { var s = prompt("Search regexp:"); if(s){ var r = prompt("Replace /"+s+"/ with:"); if(!r && r != '') return; var txt = document.editform.wpTextbox1; txt.value = txt.value.replace(new RegExp(s, "mg"), r); } } addOnloadHook(function () { if (document.forms.editform) { addPortletLink('p-cactions', 'javascript:wpTextboxReplace()', 'Replace', 'ca-replace', 'Regexp replace for the edit window', 'R', document.getElementById('ca-history')); } }); // //<nowiki> //WikiMark // //A bookmarking tool for Wikipedia. // //By User:Twinzor on enwp. //Bookmark popup window functionality copied from //User:Js/popupBookmarks.js with some modifications // //If you improve my sloppy code, I would //appreaciate it if you could drop me //a line on my talkpage. Thanks! // //Reading configuration or setting defaults if not present: if(typeof WikimarkConfigWikimarksPage == 'undefined') { var wikimarkspage = "/WikiMarks"; } else { var wikimarkspage = "/"+WikimarkConfigWikimarksPage; } if(typeof WikimarkConfigKeepSection == 'undefined') { var wikimarksect = 0; } else { var wikimarksect = WikimarkConfigKeepSection; } if(typeof WikimarkConfigListType == 'undefined') { var listtype = "*"; } else { var listtype = WikimarkConfigListType; } if(typeof WikimarkConfigAddMenu == 'undefined') { var addMenulocation = "p-cactions"; var menuPrefix = "ca-"; } else if( WikimarkConfigAddMenu == "cactions" ) { var addMenulocation = "p-cactions"; var menuPrefix = "ca-"; } else if( WikimarkConfigAddMenu == "personal" ) { var addMenulocation = "p-personal"; var menuPrefix = "pt-"; } else if( WikimarkConfigAddMenu == "toolbox" ) { var addMenulocation = "p-tb"; var menuPrefix = "t-"; } else if( WikimarkConfigAddMenu == "navigation" ) { var addMenulocation = "p-navigation"; var menuPrefix = "n-"; } else { var addMenulocation = "p-cactions"; var menuPrefix = "ca-"; } if(typeof WikimarkConfigPopup == 'undefined') { var wmPopup = 0; } else if( WikimarkConfigPopup == 1 ) { var wmPopup = 1; } if(typeof WikimarkConfigViewMenu == 'undefined') { var viewMenulocation = "p-cactions"; var menuPrefixV = "ca-"; } else if( WikimarkConfigViewMenu == "cactions" ) { var viewMenulocation = "p-cactions"; var menuPrefixV = "ca-"; } else if( WikimarkConfigViewMenu == "personal" ) { var viewMenulocation = "p-personal"; var menuPrefixV = "pt-"; } else if( WikimarkConfigViewMenu == "toolbox" ) { var viewMenulocation = "p-tb"; var menuPrefixV = "t-"; } else if( WikimarkConfigViewMenu == "navigation" ) { var viewMenulocation = "p-navigation"; var menuPrefixV = "n-"; } else { var viewMenulocation = "p-cactions"; var menuPrefixV = "ca-"; } if(typeof WikimarkConfigWikimarksUsername == 'undefined') { var wikimarkEncodedUserName = encodeURIComponent(wgUserName); } else { var wikimarkEncodedUserName = WikimarkConfigWikimarksUsername; } var myBkmShowOnHover = WikimarkConfigPopShow; var myBkmHideOnHover = WikimarkConfigPopHide; var wikimarklinkprefix = wgServer+wgScript; addOnloadHook(WikiMarkInit); function WikiMarkInit () { if(typeof WikimarkConfigViewNextTo == 'undefined') { var viewNextto = ''; } else { var viewNextto = document.getElementById(menuPrefixV+WikimarkConfigViewNextTo); } if(typeof WikimarkConfigAddNextTo == 'undefined') { var addNextto = ''; } else { var addNextto = document.getElementById(menuPrefix+WikimarkConfigAddNextTo); } addPortletLink (addMenulocation, 'javascript:doAddWikiMark()', 'WikiMark', menuPrefix+'addwikimark', 'WikiMark this page', '', addNextto); if(wmPopup == 0) { addPortletLink (viewMenulocation, wikimarklinkprefix+"?title=User:"+wikimarkEncodedUserName+wikimarkspage, 'My WikiMarks', menuPrefixV+'showwikimark', 'Open your WikiMarks', '', viewNextto); } else { myBookmarksLoad(); } } function doAddWikiMark () { var wikimarkNewpage = wgPageName.replace(/_/g, " "); if(wikimarkNewpage.indexOf("File:")==0) { wikimarkNewpage = ":" + wikimarkNewpage; } else if(wikimarkNewpage.indexOf("Category:")==0) { wikimarkNewpage = ":" + wikimarkNewpage; } var wikimarkNewpageName = wikimarkNewpage; if(wikimarksect == 1) { var newpageURL = location.href; if(newpageURL.indexOf("#")) { anchor = newpageURL.split("#"); newpageSect = anchor[1]; var wikimarkNewpageLink = wikimarkNewpage; wikimarkNewpage = wikimarkNewpage + "#" + newpageSect; wikimarkNewpage = wikimarkNewpage.replace(/_/g, " "); wikimarkNewpageName = wikimarkNewpageLink + " (Section: " + newpageSect + ")"; } } var f; f=document.createElement("IFRAME"); f.id="WikiMarksLoader"; if(wikimarkNewpageName == wikimarkNewpage) { var wikimarkLinktext = wikimarkNewpage; } else { var wikimarkLinktext = wikimarkNewpage+"|"+wikimarkNewpageName; } f.onload=function() { var wikimark_cmt = "Adding [["+wikimarkNewpage+"]] to my WikiMarks list. (Using [[User:Twinzor/Wikimark|WikiMark]])"; e=f.contentWindow.document.editform,e.wpTextbox1.value+=listtype+"["+"["+wikimarkLinktext+"]"+"]\n",e.wpSummary.value=wikimark_cmt,e.wpSave.click(); var iframe = document.getElementById('WikiMarksLoader'); jsMsg("'''"+wikimarkNewpageName+"''' has been added to your WikiMarks."); iframe.style.display="none"; }; f.src=wikimarklinkprefix+"?title=User:"+wikimarkEncodedUserName+wikimarkspage+"&action=edit",document.body.appendChild(f); }; //Everything below here came from User:Js/popupBookmarks.js //with some modifications to make it compatible with WikiMark var myBkmPage = wikimarkspage; myBkmPage = 'User:' + wikimarkEncodedUserName + myBkmPage; var myBkmURL = wgServer + wgArticlePath.replace('$1','') + myBkmPage; function myBookmarksLoad() { var obj_id = viewMenulocation var obj = document.getElementById(obj_id) if (!obj) return var bkmLink if (obj.className && obj.className == 'portlet') { if(typeof WikimarkConfigViewNextTo == 'undefined') { var viewNextto = ''; } else { var viewNextto = document.getElementById(menuPrefixV+WikimarkConfigViewNextTo); } if(typeof WikimarkConfigAddNextTo == 'undefined') { var addNextto = ''; } else { var addNextto = document.getElementById(menuPrefix+WikimarkConfigAddNextTo); } addPortletLink(viewMenulocation, myBkmURL, 'my wikimarks', menuPrefixV+'bkmmenu', 'Open your WikiMarks', '', viewNextto) obj = document.getElementById(menuPrefixV+'bkmmenu') } if (window.myBkmShowOnHover != 2) addHandler(obj, 'click', myBookmarks) if (window.myBkmShowOnHover) addHandler(obj, 'mouseover', myBookmarks) } function myBookmarks(e){ if (e.preventDefault) e.preventDefault(); else e.returnValue = false //do not follow the link if (!window.bkmMenu) myBookmarksIni() bkmMenu.ShowHide(e) return false } function myBookmarksIni(){ var ht = sajax_init_object() ht.open('GET', myBkmURL + '?action=render', false) ht.send(null) bkmMenu = new mnuObj('papka', ht.responseText, (window.myBkmHideOnHover!=2), window.myBkmHideOnHover) if (window.myBkmNewWin){ var links = bkmMenu.div.getElementsByTagName('a') for (var i=0; i<links.length; i++) links[i].target = '_blank' } bkmMenu.div.innerHTML += '<div style="text-align:right">[<a href="' + myBkmURL + '">page</a>]' + ' [<a href="' + myBkmURL + '?action=edit">edit</a>]</div>' } /* MENU */ function mnuObj(id, html, isMouseUp, isMouseOut) { var d = document.createElement('div') d.id=id d.className = 'menudiv' d.innerHTML=html d.style.display='none' d.style.position='absolute' d.style.padding='5px' d.style.border='3px outset' d.style.zIndex = '50' d.style.backgroundColor='#EEEEEE' document.body.appendChild(d) this.div = d this.div.obj = this //backlink this.Hide = function (){ this.div.style.display = 'none' } this.ShowHide = function (e){ if (this.div.style.display == 'block') this.Hide() else this.Show(e) } this.Show = function (e){ this.div.style.display = 'block' var e = e || window.event if (!e) return var coords = getMousePos(e) var posx = coords[0], posy = coords[1] this.div.style.top = posy + 5 + 'px' posx -= elementWidth(this.div)/2 if (posx + elementWidth(this.div) > windowWidth()) posx = windowWidth() - elementWidth(this.div) - 20 else if (posx < 0) posx = 10 this.div.style.left = posx + 'px' } this.hideOnMouseUp = function (e){ var e = e || window.event if ((e.which && e.which == 3) || (e.button && e.button == 2)) return //except right-click var targ = e.srcElement || e.target while (targ && (!targ.className || targ.className != 'menudiv')) targ = targ.parentNode if (!targ) return targ.style.display = 'none' } this.hideOnMouseOut = function(e){ var e = e || window.event var targ = e.srcElement || e.target while (targ && (!targ.className || targ.className != 'menudiv')) targ = targ.parentNode if (!targ) return var toEl = e.toElement || e.relatedTarget while (toEl && toEl != targ && toEl.nodeName != 'BODY') toEl = toEl.parentNode if (toEl == targ) return targ.style.display = 'none' } if (isMouseUp) addHandler(this.div, 'mouseup', this.hideOnMouseUp) if (isMouseOut) addHandler(this.div, 'mouseout', this.hideOnMouseOut) } /*API */ function windowWidth(){ if (self.innerWidth) // all except Explorer return self.innerWidth else if (document.documentElement && document.documentElement.clientWidth)// Explorer 6 Strict Mode return document.documentElement.clientWidth else if (document.body) // other Explorers return document.body.clientWidth else return 0 } function elementWidth(el){ return Math.max(el.scrollWidth, el.offsetWidth) } function getMousePos(ev){ var posx = 0; var posy = 0 if (ev.pageX) return [ev.pageX, ev.pageY] else if (ev.clientX) return [ev.clientX + document.body.scrollLeft + document.documentElement.scrollLeft, ev.clientY + document.body.scrollTop + document.documentElement.scrollTop] else return null } // </nowiki>