You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.9 KiB
HTML
48 lines
1.9 KiB
HTML
2 months ago
|
<!doctype html>
|
||
|
<html>
|
||
|
<head>
|
||
|
<style>
|
||
|
ins { color: green }
|
||
|
del { color: red }
|
||
|
#comment { font-style: italic; }
|
||
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<button id="next">next</button>
|
||
|
<div id="timestamp"></div>
|
||
|
<div id="user"></div>
|
||
|
<div id="comment"></div>
|
||
|
<div id="result"></div>
|
||
|
<script>
|
||
|
let r = {
|
||
|
action: "compare",
|
||
|
format: "json",
|
||
|
fromtitle: "Han Kang",
|
||
|
totitle: "Han Kang",
|
||
|
torelative: "next",
|
||
|
formatversion: 2,
|
||
|
prop: "diff|ids|title|user|comment|parsedcomment|timestamp",
|
||
|
difftype: "inline", // table, inline, unified
|
||
|
origin: "*"
|
||
|
}
|
||
|
let api_url = "https://en.wikipedia.org/w/api.php"
|
||
|
let revid = 376586279;
|
||
|
// let url = "https://en.wikipedia.org/w/api.php?action=compare&format=json&fromtitle=Han%20Kang&fromrev=376586279&totitle=Han%20Kang&torelative=next&formatversion=2&origin=*";
|
||
|
let next = document.querySelector("button#next");
|
||
|
next.addEventListener("click", e=> {
|
||
|
r.fromrev = revid;
|
||
|
fetch(api_url + "?" + new URLSearchParams(r)).then(resp => resp.json()).then(data => {
|
||
|
console.log("data", data);
|
||
|
let result = document.querySelector("#result");
|
||
|
result.innerHTML = data.compare.body;
|
||
|
revid = data.compare.torevid;
|
||
|
console.log("next revid", revid);
|
||
|
document.querySelector("#user").textContent = data.compare.touser;
|
||
|
document.querySelector("#timestamp").textContent = data.compare.totimestamp;
|
||
|
document.querySelector("#comment").textContent = data.compare.tocomment;
|
||
|
});
|
||
|
|
||
|
})
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|