User:Danski454/codeEditWindowSize.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
This user script seems to have a documentation page at User:Danski454/codeEditWindowSize. |
window.codeEditorHeight = window.codeEditorHeight || 700;
$(function(){
var inited = false;
var attempts = 0;
function loop(){//we may have to wait for code editor to load
if ($(".wikiEditor-ui-text div").first().is(".ui-resizable")) {
if (!inited){
$(".tool[rel='codeEditor'] a").first().click(loop);
inited = true;
}
//do resize
$(".wikiEditor-ui-text div").first().css("height",
window.codeEditorHeight.toString() + "px");
//resizing the edit window causes part of the edit window to appear empty
//calling the resize event fixes this.
window.dispatchEvent(new Event("resize"));
attempts = 0;//reset attempt tracker
} else if (attempts < 100) {//try again later
attempts++;
window.setTimeout(loop, 50);
}//after 100 attempts (min 5 seconds), give up
else {
attempts = 0;//reset attempt tracker
}
}
if ((mw.config.get("wgAction") === "edit" ||
mw.config.get("wgAction") === "submit") //are we in edit mode
&& ["javascript", "css", "Scribunto"].indexOf(mw.config.get("wgPageContentModel")) !== -1) {//and on a code page?
loop();
}
});