Skip to content

Commit

Permalink
7.0.5
Browse files Browse the repository at this point in the history
Top 50 changes
Loading save data now redraws the design correctly (this fixes the images becoming huge when loading saves)
Resetting no longer clears all data for the entire site.
Reset all data button on main page
The "Load Save (From Other Counter)" button is now labelled "Load Save (From YT Studio)"
The "Prepend 0 To Ranks Less Than 100" option is now labelled "Add Leading Zeros on Ranks"
Warning when local storage is too large
Added public saves to Top 50
  • Loading branch information
RandomPerson3465 committed Aug 18, 2024
1 parent 4a09150 commit 8312351
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 74 deletions.
2 changes: 1 addition & 1 deletion about/faq.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h2>Livecountsedit FAQ</h2>
<li>If the site was recently updated, your browser may still have the old version cached. To fix this, visit <a href="https://github.com/livecountsedit/livecountsedit.github.io/wiki/New-Updates-Not-Working%3F">this article</a>.</li>
<li>Bugs, errors, or glitches: Please report them in our <a href="./discord.html">Discord server</a>.</li>
<li>JavaScript needs to be enabled on your browser, and make sure you're not blocking any parts of the site (or external libraries that the site uses, such as Highcharts for graphs) using firewalls, antivirus software, or browser extensions.</li>
<li>Corrupted save data (for counters that use save data): This could be a result of a bug, importing sketchy/corrupted save files, or pasting stuff into the browser console. If this is the case, reset your data (if possible), if not, then you will need to clear your browser's local storage for lcedit.com.</li>
<li>Corrupted save data (for counters that use save data): This could be a result of a bug, importing sketchy/corrupted save files, or pasting stuff into the browser console. If this is the case, reset your data (if possible), if not, then you will need to clear your browser's local storage for lcedit.com. You can clear local storage easily by going to the <a href="../">main page</a>, scrolling down, and pressing the red button that says "RESET ALL DATA."</li>
</div>
</div>
</div>
Expand Down
6 changes: 6 additions & 0 deletions index.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,10 @@ button {

.title {
font-size: 4vw;
}

.reset {
width: fit-content;
background-color: red;
color: white;
}
24 changes: 24 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,31 @@ <h1>Top 50</h1>

<h3>Disclaimer</h3>
<p>The counters on our website are parodies of live subscriber and follower count websites. All credit goes to the owners of the original websites for the designs of those pages. This website is for educational and entertainment purposes only, and we do not make any profit off of this site. We believe this constitutes fair use under Title 17 U.S.C. § 107 of the Copyright Act of 1976. No copyright infringement is intended. We also do not condone the use of this site for spreading misinformation.</p>

<h3>Reset All Data</h3>
<p>This button will reset local storage for lcedit.com (which means data for ALL counters that use save data will be wiped). Use this button if errors are preventing you from resetting corrupted data on a counter that uses save data. Be sure to reload the counter after using this.</p>
<button class="reset" onclick="resetAll()">RESET ALL DATA</button>

<div id="disqus_thread" style="width: 100%;"></div>
<script>
function resetAll() {
if (confirm("Are you sure you want to reset ALL data for every counter on our site? This cannot be undone!")) {
if (confirm("FINAL WARNING: Are you REALLY sure you want to reset ALL data for every counter on our site? This cannot be undone!")) {
try {
localStorage.clear();
alert("Successfully reset all data.")
} catch (error) {
console.error(error);
alert("Uh-oh. An error occured while resetting all data.")
}
} else {
alert("Action cancelled.")
}
} else {
alert("Action cancelled.")
}
}
</script>

<script>
var disqus_config = function () {
Expand Down
4 changes: 4 additions & 0 deletions top50/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,8 @@ textarea {

.discord {
font-size: 1.5em;
}

#storage-warning {
display: none;
}
12 changes: 8 additions & 4 deletions top50/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,26 @@
<button onclick="save()">Save (In Browser)</button>
</div>
<div>
<button onclick="save2()">Save (In File)</button>
<button onclick="save2(true)">Export Public Save (In File)</button>
</div>
<div>
<button onclick="save2()">Export Private Save (In File)</button>
</div>
<div>
<input type="checkbox" id="autosave" autocomplete="off"><label>Autosave (15s)</label>
</div>
<div>
<input type="checkbox" id="offline" autocomplete="off"><label>Offline Gains</label>
</div>
</div><br>
</div>
<p id="storage-warning"><strong>Warning: An error occurred when saving the data in your browser. This could be the result of your save file being too large. Learn more about this error in <a href="https://github.com/livecountsedit/livecountsedit.github.io/wiki/Problems-with-Local-Storage">this article</a>.</strong></p>
<div class="topSettings">
<div>
<label>Load Save (From Top 50 Save)</label><br>
<input type="file" id="loadData1" autocomplete="off">
</div>
<div>
<label>Load Save (From Other Counter)</label><br>
<label>Load Save (From YT Studio)</label><br>
<input type="file" id="loadData2" autocomplete="off">
</div>
<div>
Expand Down Expand Up @@ -262,7 +266,7 @@ <h2>Audit Settings</h2>
</div>
<div>
<br>
<input type="checkbox" id="prependZeros"><label>Prepend 0 To Ranks Less Than 100</label>
<input type="checkbox" id="prependZeros"><label>Add Leading Zeros to Ranks</label>
</div>
<div>
<br>
Expand Down
114 changes: 45 additions & 69 deletions top50/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -797,12 +797,24 @@ function edit() {
}

function save() {
localStorage.setItem("data", JSON.stringify(data));
alert("Saved!");
try {
localStorage.setItem("data", JSON.stringify(data));
document.getElementById("storage-warning").style.display = "none";
alert("Saved!");
} catch (error) {
alert(`Error: ${error}`)
document.getElementById("storage-warning").style.display = "block";
}
}

function saveData2() {
localStorage.setItem("data", JSON.stringify(data));
try {
localStorage.setItem("data", JSON.stringify(data));
document.getElementById("storage-warning").style.display = "none";
} catch (error) {
console.error(error);
document.getElementById("storage-warning").style.display = "block";
}
}

document.getElementById('loadData1').addEventListener('change', function () {
Expand All @@ -823,80 +835,52 @@ function load1() {

function load() {
var data3 = {};
document.getElementById('main').innerHTML = "";
if (document.getElementById('loadData1').files[0]) {
document.getElementById('loadData1').files[0].text().then(function (data2) {
data3 = JSON.parse(data2);
if (data3.data) {
clearInterval(updateInterval);
clearInterval(auditTimeout);
data = JSON.parse(data2);
for (let i = 0; i < data.data.length; i++) {
let id = data.data[i].id;
let image = data.data[i].image;
let name = data.data[i].name;
let count = data.data[i].count;
if (currentIndex < 10) {
num = "0" + (currentIndex).toString();
} else {
num = currentIndex;
}
let card = document.createElement('div');
card.className = "card";
card.id = "card_" + currentIndex;
card.setAttribute("cid", id);
let div = document.createElement('div');
div.className = "num";
div.id = "num_" + currentIndex;
div.innerHTML = num;
div.setAttribute("cid", id);
let img = document.createElement('img');
img.className = "img";
img.id = "img_" + currentIndex;
img.src = image;
img.setAttribute("cid", id);
let nameDiv = document.createElement('h1');
nameDiv.className = "name";
nameDiv.id = "name_" + currentIndex;
nameDiv.innerText = name;
nameDiv.setAttribute("cid", id);
let countDiv = document.createElement('h2');
countDiv.classList = "odometer";
countDiv.id = "count_" + currentIndex;
countDiv.innerText = getDisplayedCount(count);
countDiv.setAttribute("cid", id);
odo = new Odometer({
el: countDiv
});
card.appendChild(div);
card.appendChild(img);
card.appendChild(nameDiv);
card.appendChild(countDiv);
document.getElementById('main').appendChild(card);
currentIndex++;
}
document.body.style.backgroundColor = data.bgColor;
document.body.style.color = data.textColor;
adjustColors();
if (!data.uuid) {
data.uuid = uuidGen();
}
localStorage.setItem("data", JSON.stringify(data));
location.reload();
try {
localStorage.setItem("data", JSON.stringify(data));
} catch (error) {
console.error(error);
}
document.getElementById('main').innerHTML = "";
initLoad('redo')
}
});
}
}
function save2() {
let data2 = JSON.stringify(data);
let a = document.createElement('a');
let file = new Blob([data2], { type: 'text/json' });
a.href = URL.createObjectURL(file);
a.download = 'data.json';
a.click();
function save2(public = false) {
let data2;
if (public) {
data2 = structuredClone(data);
data2.apiUpdates.enabled = false;
data2.apiUpdates.url = '';
data2.apiUpdates.body = Object.create(null);
data2.apiUpdates.headers = Object.create(null);
data2.uuid = null;
} else {
data2 = data;
}
if (public || confirm("PLEASE READ: You are exporting a private save file. This means that the save file will include things like any API keys you have put in. If you do not wish for this data to be in your save file, export a public save that is safe to share publicly instead. Be sure to NEVER share the private save file with anyone you do not trust!")) {
let data3 = JSON.stringify(data2);
let a = document.createElement('a');
let file = new Blob([data3], { type: 'text/json' });
a.href = URL.createObjectURL(file);
a.download = public ? 'data.json' : 'data-PRIVATE.json';
a.click();
}
}

function reset() {
if (confirm("Are you sure you want to reset?")) {
localStorage.clear();
localStorage.removeItem("data");
location.reload();
}
}
Expand All @@ -914,14 +898,6 @@ function deleteChannel() {
if (selected !== null) {
if (confirm("Are you sure you want to delete this channel?")) {
let id = selected;
/*
let image = document.getElementById('image_' + id).src = "../default.png"
let name = document.getElementById('name_' + id).innerText = "Loading";
let count = document.getElementById('count_' + id).innerText = "0";
name.innerText = "";
count.innerText = "";
image.src = "";
*/
for (let i = 0; i < data.data.length; i++) {
if (data.data[i].id == id) {
data.data.splice(i, 1);
Expand Down

0 comments on commit 8312351

Please sign in to comment.