User:Iriman/common.js
Jump to navigation
Jump to search
Note: After publishing, 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)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
mediaWiki.loader.load('/w/index.php?title=User:Iriman/dataitemeditor.js&action=raw&ctype=text/javascript');
function bidiSwitchSetup() {
var editform = document.getElementById("editform");
if (editform === null) {
return;
}
bidiAddButton(editform, "Default", function(style) {
style.direction = "inherit";
style.unicodeBidi = "inherit";
});
bidiAddButton(editform, "dir=ltr", function(style) {
style.direction = "ltr";
});
bidiAddButton(editform, "dir=rtl", function(style) {
style.direction = "rtl";
});
bidiAddButton(editform, "bidi=normal", function(style) {
style.unicodeBidi = "normal";
});
bidiAddButton(editform, "bidi=override", function(style) {
style.unicodeBidi = "bidi-override";
});
}
function bidiAddButton(before, label, action) {
var button = document.createElement("input");
button.type = "button";
button.value = label;
button.onclick = function(event) {
var q = 1;
var box = document.getElementsByClassName("CodeMirror-line");
if (box.length === 0) {
var q = 0;
box = document.getElementById("wpTextbox1");
}
if (box === null) {
alert("Broken! Edit box missing.");
} else if (q) {
var i;
for (i = 0; i < box.length; i++) {
var style = box[i].style
action(style);
}
} else {
//var style = document.getOverrideStyle(box, null);
var style = box.style;
action(style);
}
};
before.parentNode.insertBefore(button, before);
}
$(bidiSwitchSetup);
// [[Category:Gadgets|BiDiEditing.js]]
/*
mw.loader.load('/w/index.php?title=User:ZeLonewolf/taginfo.css&action=raw&ctype=text/css', 'text/css');
mw.loader.load('/w/index.php?title=User:ZeLonewolf/taginfo.js&action=raw&ctype=text/javascript');
//[[User:ZeLonewolf/taginfo.js]]
*/