MediaWiki:SavedDrafts.js

/*** SavedDrafts.js by SlyCooperFan1 ***/

function deleteDraft(x, y){ if(confirm("Are you sure you want to discard your " + y + " draft? This can't be undone!")){ localStorage.removeItem(x); $("tr[data-draft-name='"+x+"']").fadeOut; } }

require(['wikia.window', 'jquery', 'mw'], function (window, $, mw){	$(".wds-global-navigation__user-menu .wds-list li:eq(3)").after("My Saved Drafts");

if(wgPageName=="Special:BlankPage/SavedDrafts"){ $(".page-header__title").text("Saved drafts"); $("title").text($("title").text.replace("Blank page", "Saved drafts")); $("#mw-content-text").html(" All of the following drafts are saved in your browser until you choose to discard them or clear your browser data. All timestamps are displayed in UTC. This page only displays your saved drafts on this wiki. To view your saved drafts on another wiki, you must visit this page on that wiki. "); for (var i = 0; i < localStorage.length; i++){ var draftName = localStorage.key(i); if(draftName.indexOf("-draft") !== -1){ var startTime = JSON.parse(localStorage.getItem(draftName)).startTime; var startYear = startTime.substring(0, 4); var startMonth = wgMonthNames[parseInt(startTime.substring(4, 6))]; var startDay = parseInt(startTime.substring(6, 8)); var startHour = startTime.substring(8, 10); var startMin = startTime.substring(10, 12); var startSec = startTime.substring(12); startTime = startMonth + " " + startDay + ", " + startYear + ", " + startHour + ":" + startMin + ":" + startSec; var draftDisplay = draftName.replace("-draft", ""); var draftLink = "/wiki/" + draftDisplay; draftDisplay = draftDisplay.replace(/_/g, " "); $("#draftTable").append("❌  " + draftDisplay + "  " + startTime + "  "); }		}	} });