Skip to content

Commit

Permalink
settings data
Browse files Browse the repository at this point in the history
  • Loading branch information
FallBackITA27 committed Jun 9, 2024
1 parent db276a7 commit a5a5267
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 51 deletions.
1 change: 1 addition & 0 deletions gtav-interactive-map/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<script defer src="./lib/fetching.js"></script>
<script defer src="./menus/tools/timers.js"></script>
<script defer src="./menus/settings/debug.js"></script>
<script defer src="./menus/settings/data.js"></script>
<script defer src="./menus/changelog.js"></script>
<script defer src="./menus/faq.js"></script>
<script defer src="./loadScripts/counties.js"></script>
Expand Down
46 changes: 46 additions & 0 deletions gtav-interactive-map/menus/settings/data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
function dataSettings() {
resetContentPart2();
let optionDiv = document.createElement("div");
optionDiv.innerHTML = "Backup Data<p>Click Here</p>";

optionDiv.addEventListener("click", function () {
saveDataSave();
var element = document.createElement("a");
element.setAttribute(
"href",
"data:text/plain;charset=utf-8," +
encodeURIComponent(localStorage.getItem("saveData"))
);
element.setAttribute("download", "GTA5InteractiveMapData.json");
element.style.display = "none";
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
});

contentPart2.append(optionDiv);

let option2Div = document.createElement("div");
option2Div.innerHTML = "Load Backup Data<p>Click Here</p>";

option2Div.addEventListener("click", function () {
var element = document.createElement("input");
element.type = "File";
element.accept = "application/json, text/plain";
element.addEventListener("change", function (e) {
let reader = new FileReader();
reader.addEventListener("load", function (res) {
console.log(res.target.result);
loadInSaveData(res.target.result);
saveDataSave();
window.location.reload();
});
reader.readAsText(e.target.files[0]);
});
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
});

contentPart2.append(option2Div);
}
55 changes: 4 additions & 51 deletions gtav-interactive-map/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,57 +291,10 @@ Array.from(document.getElementById("menuScroll").children).forEach((r) =>
);

/* Data Options */
let dataButton = addToContentPart1List("Data");

dataButton.addEventListener("click", function () {
resetContentPart2();
let optionDiv = document.createElement("div");
optionDiv.innerHTML = "Backup Data<p>Click Here</p>";

optionDiv.addEventListener("click", function () {
saveDataSave();
var element = document.createElement("a");
element.setAttribute(
"href",
"data:text/plain;charset=utf-8," +
encodeURIComponent(localStorage.getItem("saveData"))
);
element.setAttribute(
"download",
"GTA5InteractiveMapData.json"
);
element.style.display = "none";
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
});

contentPart2.append(optionDiv);

let option2Div = document.createElement("div");
option2Div.innerHTML = "Load Backup Data<p>Click Here</p>";

option2Div.addEventListener("click", function () {
var element = document.createElement("input");
element.type = "File";
element.accept = "application/json, text/plain";
element.addEventListener("change", function (e) {
let reader = new FileReader();
reader.addEventListener("load", function (res) {
console.log(res.target.result);
loadInSaveData(res.target.result);
saveDataSave();
window.location.reload();
});
reader.readAsText(e.target.files[0]);
});
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
});

contentPart2.append(option2Div);
});
addToContentPart1List("Data").addEventListener(
"click",
dataSettings
);

contentPart1.children[0].click();
return;
Expand Down

0 comments on commit a5a5267

Please sign in to comment.