Content deleted Content added
Mike Dillon (talk | contribs) No edit summary |
m Maintenance: Replacing addOnloadHook with native jQuery (mw:ResourceLoader/Migration_guide_(users)#addOnloadHook - phab:T130879) |
||
(6 intermediate revisions by one other user not shown) | |||
Line 1:
// Requires: [[User:Mike Dillon/Scripts/i18n.js]], [[User:Mike Dillon/Scripts/easydom.js]], [[User:Mike Dillon/Scripts/cookies.js]]
/* <pre><nowiki> */
Line 8:
var pageHistoryExpiresInDays;
/* Messages */
addOnloadHook(function () {▼
// pageHistoryTitle: title of page history portlet
wfAddMsg("en", "pageHistoryTitle", "Page history");
wfAddMsg("es", "pageHistoryTitle", "Historial de páginas");
// clearHistoryLabel: label of the "clear history" link
wfAddMsg("en", "clearHistoryLabel", "clear history");
wfAddMsg("es", "clearHistoryLabel", "borrar historial");
// clearHistoryTitle: tooltip of the "clear history" link
wfAddMsg("en", "clearHistoryTitle", "Clear page history");
wfAddMsg("es", "clearHistoryTitle", "Borrar historial de páginas");
// noPageHistoryText: text to display when there is no page history
wfAddMsg("en", "noPageHistoryText", "No page history");
wfAddMsg("es", "noPageHistoryText", "Ningún historial de páginas");
// Set defaults for variables
if (!pageHistoryCookieName) pageHistoryCookieName = "pageHistory";
Line 18 ⟶ 35:
with (easyDom) {
var historyPortlet = div({ "class": "portlet", "id": "p-history" },
h5(wfMsg("
var historyList = ul();
var historyPBody = div({ "class": "pBody" }, historyList);
Line 60 ⟶ 77:
}
with (easyDom) {
historyList.appendChild(li(em(wfMsg("
}
deleteCookie(pageHistoryCookieName, { path: "/" });
Line 69 ⟶ 86:
with (easyDom) {
if (historyItems.length == 0) {
historyList.appendChild(li(em(wfMsg("
} else {
for (var n in historyItems) {
Line 78 ⟶ 95:
var itemLabel = historyItems[n].replace(/_/g, " ");
// Add zero-width spaces before some punctuation
itemLabel = itemLabel.replace(/([\/(])/g, "\u200B
// Add zero-width spaces after other punctuation
itemLabel = itemLabel.replace(/([:;,.)-])/g, "$1\u200B");
historyList.appendChild(li(
Line 84 ⟶ 104:
}
var clearHistoryLink = a({ "href": "#", "title": wfMsg("
em(wfMsg("clearHistoryLabel")));
clearHistoryLink.onclick = clearHistory;
historyPBody.appendChild(div(
Line 103 ⟶ 124:
}
writeCookie(pageHistoryCookieName, historyCookie,
{ "path": "/", "expiresInDays": pageHistoryExpiresInDays });
});
|