Skip to content

Commit

Permalink
Added Cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
OshidaBCF committed Jan 13, 2024
1 parent 6139a7a commit 4b8fe28
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
15 changes: 8 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,26 @@
</head>
<body>
<h1>Arma 3 Toolkit</h1>
<p>Modpack string generator for servers commandline</p>
<p>This tool generate the string needed by servers to run with mods "@mod1;@mod2"</p>
<p>Modpack string generator for servers commandline.</p>
<p>This tool generate the string needed by servers to run with mods "@mod1;@mod2".</p>
<p>The modIgnoreList and checkbox states are saved in cookies, so to make it faster if your configuration happen to not be the default one.</p>

<label for="armaModpackFile">Select a file:</label>
<input type="file" id="armaModpackFile" accept=".html">
<br><br>
<label for="ignoreList">Mods IDs to be ignored, one per line : </label>
<br><br>
<textarea id="ignoreList" autocorrect="off" style="width: 500px; height: 130px;"></textarea>
<br>
<input type="checkbox" id="supportSpaceAndDash">Does your server use support spaces, - and _, check the download folder of your server to see if the mods folder contain spaces or not.</checkbox>
<textarea id="ignoreList" autocorrect="off" style="width: 500px; height: 130px;"></textarea>
<br><br>
<input type="checkbox" id="supportSpaceAndDash" onclick="setCBCookie(this)">Does your server use support spaces, - and _, check the download folder of your server to see if the mods folder contain spaces or not.</checkbox>
<br>
<input type="checkbox" id="needDLCInString">Does the string need to include the DLCs.</checkbox>
<input type="checkbox" id="needDLCInString" onclick="setCBCookie(this)">Does the string need to include the DLCs.</checkbox>
<br><br>
<button type="button" onclick="parseArmaModpackPreset()">Run Parser</button>
<br><br>
<label for="modString">Modpack String : </label>
<button id="copyStringToClipboardBtn" onclick="copyStringToClipboard()">Copy String</button>
<br><br>
<br>
<textarea id="modString" autocorrect="off" style="width: 800px; height: 300px;" readonly></textarea>
</body>
</html>
35 changes: 33 additions & 2 deletions js/arma3.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,30 @@ function parseArmaModpackPreset()
}
}

function setCBCookie(cb)
{
setCookie(cb.id, cb.checked)
}

function setCookie(cname, cvalue) {
document.cookie = cname + "=" + cvalue
}

function getCookie(cname) {
let decodedCookie = decodeURIComponent(document.cookie)
let cookieList = decodedCookie.split(';')
let returnValue = ""
cookieList.forEach(cookie => {
[cookieName, cookieValue] = cookie.split("=")
if (cookieName == cname)
{
returnValue = cookieValue
return
}
});
return returnValue
}

function copyStringToClipboard()
{
var copyText = document.getElementById("modString")
Expand Down Expand Up @@ -150,7 +174,14 @@ function copyTextToClipboard(text) {
)
}

waitForElm("body > button").then((elm) => {
uploadInput = document.getElementById("armaModpackFile")
waitForElm("#armaModpackFile").then((elm) => {
uploadInput = elm
})

waitForElm("#supportSpaceAndDash").then((elm) => {
elm.checked = getCookie("supportSpaceAndDash") == "true"
})

waitForElm("#needDLCInString").then((elm) => {
elm.checked = getCookie("needDLCInString") == "true"
})

0 comments on commit 4b8fe28

Please sign in to comment.