User:Mike Dillon/Scripts/recentpages.js: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 31:
for (var n in cookieItems) {
historyItems.push(decodeURIComponent(cookieItems[n]));
}
}
 
// Prepend the current page to the list, remove duplicates, and control item count
if (wgIsArticle) {
var currentPage = wgPageName.replace("_", " ");
historyItems.unshift(currentPage);
for (var n = 1; n < historyItems.length; n++) {
if (historyItems[n] == currentPage) {
historyItems.splice(n, 1);
}
}
while (historyItems.length > pageHistoryCookieItemCount) {
historyItems.pop();
}
}
Line 42 ⟶ 56:
var itemUrl = wgArticlePath.replace(/\$1/,
encodeURIComponent(historyItems[n]));
itemUrl = itemUrl.replace("%2f", "/");
var itemLabel = historyItems[n])));
var itemSlash = itemLabel.lastIndexOf("/");
if (itemSlash != -1) itemLabel = itemLabel.substr(itemSlash + 1);
historyList.appendChild(li(
a({ href: itemUrl, title: historyItems[n] }, itemLabel)));
historyItems[n])));
}
}
}
 
// Prepend the current page to the list, remove duplicates, and control item count
var currentPage = wgPageName.replace("_", " ");
historyItems.unshift(currentPage);
for (var n = 1; n < historyItems.length; n++) {
if (historyItems[n] == currentPage) {
historyItems.splice(n, 1);
}
}
while (historyItems.length > pageHistoryCookieItemCount) {
historyItems.pop();
}