Content deleted Content added
create |
add |
||
Line 573:
async function getArchiveURL(url) {
try {
return { url: "", day: "", month: "", year: "" };
} catch (e) {
console.log("Could not fetch archive url: " + e);
return { url: "", day: "", month: "", year: "" };
}
}
async function saveButtonClicked(button) {
if (!currentlySelectedRef.item.replace && saveReference() !== currentlySelectedRef.item.wikitext) {
refsSaved++;
Line 602 ⟶ 607:
}
currentlySelectedRef.item.replace = saveReference();
const refText = currentlySelectedRef.refElem.querySelector(".reference-text");
button.parentElement.parentElement.remove();
refText.innerHTML = "Loading...";
refText.innerHTML = await wikitextToHTML(currentlySelectedRef.item.replace);
refText.children[0].style.display = "inline";
}
Line 634 ⟶ 643:
___location.reload();
}
async function wikitextToHTML(wikitext) {
let deferred = $.Deferred();
$.post("https://en.wikipedia.org/api/rest_v1/transform/wikitext/to/html",
"wikitext=" + encodeURIComponent(wikitext) + "&body_only=true",
function (data) {
deferred.resolve(data);
}
);
return deferred;
}
|