Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Cmd-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (Cmd-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Clear the cache in Tools → Preferences
For details and instructions about other browsers, see Wikipedia:Bypass your cache.
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 central discussion page, Scriptorium. The code will be executed when previewing this page under some skins, including Monobook. You can in the interim if you wish to refresh the content sooner under another skin. |
Documentation for this script can be added at User:Inductiveload/Hyphenated word. |
/*
* Does a lookup on the previous page to see if there is a hyphenated
* word and tries to complete it
*
* To use this script, add the following to your .js:
* importScript('User:Inductiveload/Hyphenated word.js');
*
*/
function check_hws(data)
{
try {
var editbox = document.getElementsByName('wpTextbox1')[0];
if (editbox && !data.query.pages["-1"]) {
for (var ids in data.query.pages) {
var content = data.query.pages[ids].revisions[0]['*'];
var match = content.match( /{{ *([Hh]ws|[Hh]yphenated word start)\|([^\|}]*)\|?([^\|}]*)?}}/ )
if (match != undefined && match.length > 3) {
var hws = match[2];
var word = match[3];
var hwe = word.slice(hws.length)
var hwestring = '{{hwe|'+hwe+'|'+word+'}} '
editbox.value = hwestring + editbox.value
}
break;
}
}
}
catch (err) { }
}
function hyphenated_word()
{
var r = new RegExp("(\\d+)$");
var page = Number(r.exec(mw.config.get('wgPageName'))[1]) - 1; //previous page
var pagename = mw.config.get('wgPageName').replace(/\d+$/g, page);
var url = mw.config.get('wgServer') + wgScriptPath
+ "/api.php?action=query&prop=revisions&callback=check_hws&rvprop=content"
+ "&format=json&titles=" + encodeURIComponent(pagename);
$('body').append('<script type="text/javascript" src="' + url + '"/>');
}
$ (function (){
var tb = document.getElementById("toolbar");
if(tb){
var image = document.createElement("img");
image.width = 23;
image.height = 23;
image.border = 0;
image.className = "mw-toolbar-editbutton";
image.style.cursor = "pointer";
image.alt = "Hyph. word";
image.title = "Add hyphenated word started on the previous page";
image.src = "http://upload.wikimedia.org/wikipedia/commons/thumb/5/5a/Button_hyphenated_word.svg/23px-Button_hyphenated_word.svg.png";
image.onclick = hyphenated_word;
tb.appendChild(image);
}
}
);