משתמש:Kotz/מקפים.js
הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.
- פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
- גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
- אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
- אופרה: ללחוץ על Ctrl-F5.
// highlights dashes of different cases in differnt colors
//based on: [[מדיה ויקי:סקריפטים/45.js]]
var w7exception;
try
{
if(wordh===undefined||wordh===null) wordh="";
}
catch(w7exception)
{
wordh="";
}
function highlightdashes(n,p,wordh,colorx) //node, parent node
{
while(n!==null)
{
if(n.nodeType==3) //text node
{
if(n.data.indexOf(wordh.toLowerCase())!=-1)
{
var ix=n.data.toLowerCase().indexOf(wordh.toLowerCase());
var t1=ix?document.createTextNode(n.data.substr(0,ix)):null;
var t2=document.createTextNode(n.data.substr(ix,wordh.length));
var t3=ix+wordh.length==n.data.length?null:
document.createTextNode(n.data.substr(ix+wordh.length));
var s1=document.createElement("span");
s1.style.color=colorx;
s1.className="dash";
s1.appendChild(t2);
var s2=document.createElement("span");
if(t1!==null) s2.appendChild(t1);
s2.appendChild(s1);
if(t3!==null) s2.appendChild(t3);
p.replaceChild(s2,n);
if(t3!==null) highlightdashes(t3,s2,wordh,colorx); //find remaining occurences in the new nodes
n=s2.nextSibling;
}
else
n=n.nextSibling;
}
else
{
if(n.firstChild!==null) highlightdashes(n.firstChild,n,wordh,colorx);
n=n.nextSibling;
}
}
}
$(function() {
// The two occurrences of 'word7' in the following line are to prevent conflicts with
// other scripts I've written; don't change them to your own username (the script will
// change to your username automatically).
if(location.href.indexOf("?action=edit")==-1&&location.href.indexOf("?action=submit")==-1&&
location.href.indexOf("&action=edit")==-1&&location.href.indexOf("&action=submit")==-1&&
location.href.indexOf("&action=raw")==-1&&mw.config.get('wgPageName')!="Special:Preferences")
{
highlightdashes(document.getElementById('content').firstChild,
document.getElementById('content'),
"-",
"red");
highlightdashes(document.getElementById('content').firstChild,
document.getElementById('content'),
"–",
"green");
highlightdashes(document.getElementById('content').firstChild,
document.getElementById('content'),
"־",
"purple");
}
});