사용자:Senouis/RPGinCity.js: 두 판 사이의 차이
imported>Senouis 잔글편집 요약 없음 |
imported>Senouis (정보 틀 구현) |
||
33번째 줄: | 33번째 줄: | ||
function RPGinCity_Callback_fetchUserInformation(jsonfile) { | function RPGinCity_Callback_fetchUserInformation(jsonfile) { | ||
let playerinfo = document.getElementsByClassName("Playerinfo"); | |||
let LevelUpButton = document.getElementById("LevelUp"); | |||
playerinfo[0].innerText = jsonfile.레벨; | |||
playerinfo[1].innerText = jsonfile.체력; | |||
playerinfo[2].innerText = jsonfile.경험치; | |||
playerinfo[3].innerText = jsonfile.잼; | |||
playerinfo[4].innerText = jsonfile.배쨈; | |||
playerinfo[5].innerText = jsonfile.차단폭탄; | |||
playerinfo[6].innerText = jsonfile.돈; | |||
playerinfo[7].innerText = jsonfile.무기; | |||
if (jsonfile.경험치 > 128 && jsonfile.레벨 + jsonfile.경험치 /128 <= 50) { | |||
LevelUpButton.innerHTML = "<a href= \"https://libertygame.miraheze.org/wiki/RPG_in_City/레벨_업\">레벨 업!</a>"; | |||
} | |||
} | } | ||
RPGinCity_Title(); | // ----------------------------------------------------Main------------------------------------------------------------ | ||
RPGinCity_GoToCheckpoint(); | if (currentpage === "RPG in City") { | ||
fetch("https://libertygame.miraheze.org/w/index.php?title="+"사용자:"+usernameStr+"/RPG_in_City.json"+"&action=raw") | RPGinCity_Title(); | ||
} | |||
else if (currentpage === "사용자:"+usernameStr+"/RPG in City.json"){ | |||
RPGinCity_GoToCheckpoint(); | |||
} | |||
else if (currentpage.substring(0,10) === "RPG in City") { // in game but not in title screen | |||
fetch("https://libertygame.miraheze.org/w/index.php?title="+"사용자:"+usernameStr+"/RPG_in_City.json"+"&action=raw") | |||
.then(response => response.json()) | |||
.then(response => RPGinCity_Callback_fetchUserInformation(response)); | |||
} |
2020년 12월 2일 (수) 12:04 판
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) {
let playerinfo = document.getElementsByClassName("Playerinfo");
let LevelUpButton = document.getElementById("LevelUp");
playerinfo[0].innerText = jsonfile.레벨;
playerinfo[1].innerText = jsonfile.체력;
playerinfo[2].innerText = jsonfile.경험치;
playerinfo[3].innerText = jsonfile.잼;
playerinfo[4].innerText = jsonfile.배쨈;
playerinfo[5].innerText = jsonfile.차단폭탄;
playerinfo[6].innerText = jsonfile.돈;
playerinfo[7].innerText = jsonfile.무기;
if (jsonfile.경험치 > 128 && jsonfile.레벨 + jsonfile.경험치 /128 <= 50) {
LevelUpButton.innerHTML = "<a href= \"https://libertygame.miraheze.org/wiki/RPG_in_City/레벨_업\">레벨 업!</a>";
}
}
// ----------------------------------------------------Main------------------------------------------------------------
if (currentpage === "RPG in City") {
RPGinCity_Title();
}
else if (currentpage === "사용자:"+usernameStr+"/RPG in City.json"){
RPGinCity_GoToCheckpoint();
}
else if (currentpage.substring(0,10) === "RPG in City") { // in game but not in title screen
fetch("https://libertygame.miraheze.org/w/index.php?title="+"사용자:"+usernameStr+"/RPG_in_City.json"+"&action=raw")
.then(response => response.json())
.then(response => RPGinCity_Callback_fetchUserInformation(response));
}