사용자:Senouis/RPGinCity.js: 두 판 사이의 차이
imported>Senouis 잔글편집 요약 없음 |
imported>Senouis 잔글편집 요약 없음 |
||
38번째 줄: | 38번째 줄: | ||
RPGinCity_Title(); | RPGinCity_Title(); | ||
RPGinCity_GoToCheckpoint(); | RPGinCity_GoToCheckpoint(); | ||
fetch( | fetch(mw.util.getUrl("사용자:"+usernameStr+"/RPG in City.json"), {action:"raw"}) | ||
.then(response => response.json()) | .then(response => response.json()) | ||
.then(response => RPGinCity_Callback_fetchUserInfomation(response)); | .then(response => RPGinCity_Callback_fetchUserInfomation(response)); |
2020년 12월 2일 (수) 11:39 판
let usernameStr = mw.user.getName();
let currentpage = mw.config.get("wgPageName");
console.log(currentpage);
function RPGinCity_Title() {
let startbuttondiv = document.getElementById("RPGinCityStart");
if (startbuttondiv !== null){
if (usernameStr === null) {
startbuttondiv.innerHTML = "<p>로그인이 필요합니다</p>";
} else {
let UserDBTitle = new mw.Title("사용자:"+usernameStr+"/RPG in City.json", 2);
if (UserDBTitle.exists === true){
startbuttondiv.innerHTML = "<p><big><a href=\""+mw.util.getUrl(UserDBTitle.toText())+ "\">계속하기</a></big></p>";
} else {
startbuttondiv.innerHTML = "<p><big><a href=\""+mw.util.getUrl(UserDBTitle.toText(),{action: 'edit', preload : '틀:RPG_in_City_DB_양식', summary:'생성'})+ "\">새 데이터 만들기</a></big></p>";
}
}
}
}
function RPGinCity_GoToCheckpoint () {
let JSONDatalist = document.getElementsByClassName("mw-json-value");
if (currentpage === ("사용자:"+usernameStr+"/RPG_in_City.json") && JSONDatalist.length !== 0) {
let MWContent = document.getElementById("mw-content-text");
let GotoLink= document.createElement("a");
GotoLink.href = mw.util.getUrl((JSONDatalist[0].innerText.substring(1, JSONDatalist[0].innerText.length-1)));
console.log(GotoLink.href);
GotoLink.innerText = "게임 계속하기";
MWContent.appendChild(GotoLink);
}
}
function RPGinCity_Callback_fetchUserInformation (jsonfile) {
console.log(jsonfile);
}
RPGinCity_Title();
RPGinCity_GoToCheckpoint();
fetch(mw.util.getUrl("사용자:"+usernameStr+"/RPG in City.json"), {action:"raw"})
.then(response => response.json())
.then(response => RPGinCity_Callback_fetchUserInfomation(response));