(function () { "use strict"; version.extensions.hoverreplaceMacro = { major: 1, minor: 0, revision: 1 }; var mnames = ["mouseremove", "mousereplace", "mousecontinue", "hoverremove", "hoverreplace"]; var mobj = { handler: function (g, e, f, b) { var rpm = "replacement", hv = (e.indexOf("hover") > -1 ? "hover" : "mouse"), de = "data-enabled", I, II, c, d, k, elem; function showVer(n) { if(!n.innerHTML) { new Wikifier(n, n.tweecode); } n.style.display = "inline"; n.classList.remove(rpm + "-out"); n.classList.add(rpm + "-in"); if(n.timeout) clearTimeout(n.timeout); n.timeout = setTimeout(function () { n.classList.remove(rpm + "-in"); }, 1); } function hideVer(n) { n.classList.remove(rpm + "-in"); n.classList.add(rpm + "-out"); if(n.timeout) clearTimeout(n.timeout); n.timeout = setTimeout(function () { n.classList.remove(rpm + "-out"); n.style.display = "none"; n.innerHTML = ""; }, 1000); } function tagcontents(b, starttags, desttags, endtags, k) { function tagfound(i, e) { for(var j = 0; j < e.length; j++) { if(a.indexOf(e[j], i) == i) { return e[j]; } } } var a = b.source.slice(k); var l = 0; var c = ""; var tg; for(var i = 0; i < a.length; i++) { if(tg = tagfound(i, starttags)) { l++; } else if((tg = tagfound(i, desttags)) && l == 0) { b.nextMatch = k + i + tg.length; return [c, tg]; } else if(tg = tagfound(i, endtags)) { l--; if(l < 0) { return null; } } c += a.charAt(i); } return null; } var begintags = [], endtags = [], rw = ["<>", "<>"], etr = ["<>"]; mnames.forEach(function (i) { begintags.push("<<" + i); endtags.push("<>', b.matchStart) + 2; if(e.indexOf("replace") == -1) { c = tagcontents(b, begintags, etr, endtags, k); if(c) { if(e.indexOf("continue") > -1) { d = [b.source.slice(b.nextMatch), ""]; b.nextMatch += d[0].length; } else { d = ["", ""]; } } } else { c = tagcontents(b, begintags, rw, endtags, k); d = tagcontents(b, begintags, etr, endtags, c ? b.nextMatch : k); } if(c && d) { c[1] = c[1].replace("<<", "").replace(">>", ""); if(d[0]) { g = insertElement(g, "span", null, hv + rpm + "s"); elem = g; } I = insertElement(g, "span", null, hv + rpm + " " + (d[0] ? "initial" : e)); I.tweecode = c[0]; showVer(I); if(d[0]) { II = insertElement(g, "span", null, hv + rpm + " " + c[1]); II.tweecode = d[0]; hideVer(II); } else { elem = I; } elem.onmouseover = function () { if(II) { showVer(II); } if(hv == "mouse") { elem.onmouseover = null; } if(c[1].indexOf("gains") == -1) { hideVer(I); } }; if(hv == "hover") { elem.onmouseout = function () { if(II) { hideVer(II); } if(c[1].indexOf("gains") == -1) { showVer(I); } } } } else { throwError(g, "can't find matching " + (!c ? rw : "end" + e)); return; } } } var nullobj = { handler: function () {} }; mnames.forEach(function (e) { macros[e] = mobj; macros['end' + e] = nullobj; }); macros.gains = macros.becomes = nullobj; }());