User:לערי ריינהארט/monobook.js
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Internet Explorer / Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
- Opera:按 Ctrl-F5。
- 此腳本缺少說明文檔。您可以協助創建。
- 相關-{zh-hans:链接; zh-hant:連接}-:根頁面 • 根頁面的子頁面 • -{zh-hans:链入; zh-hant:連入}- • -{zh-hans:重定向; zh-hant:重新導向}- • 您的對應頁面
本JavaScript腳本會在User:לערי ריינהארט使用Monobook外觀時,在每次לערי ריינהארט載入頁面時執行。
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 box = document.getElementById("wpTextbox1");
if (box == null) {
alert("Broken! Edit box missing.");
} else {
//var style = document.getOverrideStyle(box, null);
var style = box.style;
action(style);
}
}
before.parentNode.insertBefore(button, before);
}
hookEvent('load', bidiSwitchSetup);