הבדלים בין גרסאות בדף "מדיה ויקי:Common.js"
מתוך Math-Wiki
שורה 1: | שורה 1: | ||
/* כל סקריפט JavaScript שנכתב כאן ירוץ עבור כל המשתמשים בכל טעינת עמוד */ | /* כל סקריפט JavaScript שנכתב כאן ירוץ עבור כל המשתמשים בכל טעינת עמוד */ | ||
− | window.addEventListener('load',function(){ | + | window.addEventListener('load', function () { |
− | + | // fixes a bug that doesn't allow registered users to edit pages normally | |
− | if (a.href && a.href.indexOf('&action=edit') != -1 && a.href.indexOf('&internaledit=true') == -1) | + | for each(var a in document.getElementsByTagName('a')) |
− | + | if (a.href && a.href.indexOf('&action=edit') != -1 && a.href.indexOf('&internaledit=true') == -1) a.href += '&internaledit=true'; | |
− | + | ||
− | + | // improves the display of printable pages | |
− | + | if (document.URL.indexOf('&printable=yes') != -1) { | |
− | + | var e1 = document.getElementById('content').nextSibling, | |
− | + | e2 = document.getElementById('bodyContent'); | |
− | + | e2.removeChild(document.getElementsByClassName('printfooter')[0]); | |
− | + | for each(var id in ['siteSub', 'contentSub', 'catlinks']) | |
− | + | e2.removeChild(document.getElementById(id)); | |
− | + | while (e1) { | |
+ | e2 = e1.nextSibling; | ||
+ | document.body.removeChild(e1); | ||
+ | e1 = e2; | ||
+ | } | ||
} | } | ||
− | + | ||
− | },false); | + | // improves display of formulas: if a formula is preceded or followed by characters (such as punctuation marks), |
+ | //there won't be any line breaks between the formula and the character. | ||
+ | var e1, is1, e2, is2, con, par, texs = document.getElementsByClassName('tex'); | ||
+ | for each(var tex in texs) { | ||
+ | e1 = tex.previousSibling; | ||
+ | is1 = Boolean(e1 && e1.nodeType == 3 && /\S$/.test(e1.data)); | ||
+ | e2 = tex.nextSibling; | ||
+ | is2 = Boolean(e2 && e2.nodeType == 3 && /^\S/.test(e2.data)); | ||
+ | if (!is1 && !is2) continue; | ||
+ | con = document.createElement('span'); | ||
+ | con.style.display = 'inline-block'; | ||
+ | if (is1) con.appendChild(e1.splitText(e1.data.search(/\S+$/))); | ||
+ | if (is2) { | ||
+ | e2 = e2.splitText(e2.data.search(/\s|$/)).previousSibling; | ||
+ | con.appendChild(e2); | ||
+ | } | ||
+ | par = tex.parentNode; | ||
+ | con.insertBefore(tex, is2 ? e2 : null); | ||
+ | par.insertBefore(con, e1.nextSibling); | ||
+ | } | ||
+ | }, false); |
גרסה מ־21:27, 6 באוגוסט 2012
/* כל סקריפט JavaScript שנכתב כאן ירוץ עבור כל המשתמשים בכל טעינת עמוד */ window.addEventListener('load', function () { // fixes a bug that doesn't allow registered users to edit pages normally for each(var a in document.getElementsByTagName('a')) if (a.href && a.href.indexOf('&action=edit') != -1 && a.href.indexOf('&internaledit=true') == -1) a.href += '&internaledit=true'; // improves the display of printable pages if (document.URL.indexOf('&printable=yes') != -1) { var e1 = document.getElementById('content').nextSibling, e2 = document.getElementById('bodyContent'); e2.removeChild(document.getElementsByClassName('printfooter')[0]); for each(var id in ['siteSub', 'contentSub', 'catlinks']) e2.removeChild(document.getElementById(id)); while (e1) { e2 = e1.nextSibling; document.body.removeChild(e1); e1 = e2; } } // improves display of formulas: if a formula is preceded or followed by characters (such as punctuation marks), //there won't be any line breaks between the formula and the character. var e1, is1, e2, is2, con, par, texs = document.getElementsByClassName('tex'); for each(var tex in texs) { e1 = tex.previousSibling; is1 = Boolean(e1 && e1.nodeType == 3 && /\S$/.test(e1.data)); e2 = tex.nextSibling; is2 = Boolean(e2 && e2.nodeType == 3 && /^\S/.test(e2.data)); if (!is1 && !is2) continue; con = document.createElement('span'); con.style.display = 'inline-block'; if (is1) con.appendChild(e1.splitText(e1.data.search(/\S+$/))); if (is2) { e2 = e2.splitText(e2.data.search(/\s|$/)).previousSibling; con.appendChild(e2); } par = tex.parentNode; con.insertBefore(tex, is2 ? e2 : null); par.insertBefore(con, e1.nextSibling); } }, false);