|
|
| שורה 1: |
שורה 1: |
| // הוספת שורת "קישורי חב"דציטוט" בתחתית הדף, אם היא לא קיימת כבר. | | /* Empty. */ |
| // נכתב על־ידי [[משתמש:דולב]].
| |
| //
| |
| function addLinksTemplate() {
| |
| // פונקציית עזר: יצירה מהירה של אלמנט קישור.
| |
| function createLink(pageName, text) {
| |
| var link = null;
| |
| if (mw.config.get('wgTitle') == pageName) {
| |
| link = document.createElement("strong");
| |
| link.setAttribute("class", "selflink");
| |
| } else {
| |
| link = document.createElement("a");
| |
| link.href = "/wiki/" + pageName.replace(/ /g, "_");
| |
| link.title = pageName;
| |
| }
| |
| link.appendChild(document.createTextNode(text));
| |
| return link;
| |
| }
| |
| | |
| if ( mw.config.get('wgUserName') ) return; // יוצא מהפונקציה אם המשתמש רשום
| |
| // אם התבנית לא קיימת, הדף נמצא במרחב הראשי, זה לא העמוד הראשי
| |
| // והפעולה היא צפייה או עריכת הדף
| |
| if (document.getElementById("linksTemplate") == null && mw.config.get('wgNamespaceNumber') == 0 && mw.config.get('wgTitle') != "עמוד ראשי" && (mw.config.get('wgAction') == "view" || mw.config.get('wgAction') == "edit" || mw.config.get('wgAction') == "submit")) {
| |
| // בודק אם פעולת הצפייה היא בדף הפניה או בדף ריק
| |
| // אם כן, יוצא מהפונקציה
| |
| if (mw.config.get('wgAction') == "view" && (document.getElementById("contentSub").innerHTML == "דף הפניה" || wgCurRevisionId == false)) {
| |
| return;
| |
| }
| |
| | |
| // בונה את התבנית
| |
| var horizontalLine = document.createElement("hr")
| |
| horizontalLine.setAttribute("style", "clear: both;");
| |
| var linksTemplate = document.createElement("div");
| |
| linksTemplate.id = "linksTemplate";
| |
| linksTemplate.setAttribute("align", "center"); /* this is for IE */
| |
| linksTemplate.setAttribute("style", "font-size: smaller; text-align: center;"); /* this doesn't work in IE */
| |
| linksTemplate.appendChild(document.createElement("b"));
| |
| linksTemplate.firstChild.appendChild(document.createTextNode("קישורי חב"דציטוט: "));
| |
| linksTemplate.firstChild.appendChild(createLink("קטגוריה:אישים", "אישים"));
| |
| linksTemplate.firstChild.appendChild(document.createTextNode(" - "));
| |
| linksTemplate.firstChild.appendChild(createLink("קטגוריה:יצירות ספרותיות","יצירות ספרותיות"));
| |
| linksTemplate.firstChild.appendChild(document.createTextNode(" - "));
| |
| linksTemplate.firstChild.appendChild(createLink("קטגוריה:פתגמים", "פתגמים"));
| |
| linksTemplate.firstChild.appendChild(document.createTextNode(" - "));
| |
| linksTemplate.firstChild.appendChild(createLink("קטגוריה:סרטים", "סרטים"));
| |
| linksTemplate.firstChild.appendChild(document.createTextNode(" - "));
| |
| linksTemplate.firstChild.appendChild(createLink("קטגוריה:תוכניות טלוויזיה", "תוכניות טלוויזיה"));
| |
| linksTemplate.firstChild.appendChild(document.createTextNode(" - "));
| |
| linksTemplate.firstChild.appendChild(createLink("קטגוריה:נושאים", "נושאים"));
| |
| linksTemplate.firstChild.appendChild(document.createTextNode(" - "));
| |
| linksTemplate.firstChild.appendChild(createLink("קטגוריה:קטגוריות", "קטגוריות"));
| |
| | |
| // מחפש מיקום מתאים ומוסיף את התבנית לדף
| |
| if (document.getElementById("wikiPreview") != null) { // אם קיים מקטע "תצוגה מקדימה", כלומר חלון עריכה
| |
| if (document.getElementById("wikiPreview").childNodes.length > 0) { // אם התצוגה המקדימה לא ריקה
| |
| document.getElementById("wikiPreview").appendChild(horizontalLine);
| |
| document.getElementById("wikiPreview").appendChild(linksTemplate);
| |
| }
| |
| } else if (document.getElementById("catlinks") != null) { // אם קיים מקטע קטגוריות
| |
| var divCatlinks = document.getElementById("catlinks");
| |
| divCatlinks.parentNode.insertBefore(horizontalLine, divCatlinks);
| |
| divCatlinks.parentNode.insertBefore(linksTemplate, divCatlinks);
| |
| } else if (document.getElementById("bodyContent") != null) { // אם קיים המקטע הראשי
| |
| document.getElementById("bodyContent").appendChild(horizontalLine);
| |
| document.getElementById("bodyContent").appendChild(linksTemplate);
| |
| }
| |
| }
| |
| }
| |
| | |
| jQuery(document).ready(addLinksTemplate);
| |