Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

Commit

Permalink
Add ability to autoload/set which splits to load at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
iotku committed Mar 13, 2015
1 parent 1949a95 commit 73f2497
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
16 changes: 16 additions & 0 deletions css/timer.css
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,20 @@ input[type=text]:nth-child(3n+1),input:disabled:nth-child(3n+1) {
width: 200px;
}
#split-selector ul {

border: white 2px solid;
background-color: #222;
list-style: square inside;
}

#split-selector li {
margin-left: 20px;
}
#split-selector ul:hover {
border: white 2px solid;
background-color: #333;
list-style: square inside;
cursor: pointer;
}

#split-selector .delete,#split-selector .delete a:link,#split-selector .delete a:visited {
Expand All @@ -248,4 +254,14 @@ input[type=text]:nth-child(3n+1),input:disabled:nth-child(3n+1) {
/*top: 10px;*/
font-size: 30px;
color: red;
}

#split-selector .defaultSplit,#split-selector .defaultSplit a:link,#split-selector .defaultSplit a:visited {
position: absolute;
text-decoration: none;
font-weight: bolder;
left: 20px;
/*top: 10px;*/
font-size: 30px;
color: green;
}
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>RTA Timer</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<!-- Mobile Support kinda, prevents zooming -->
<meta name="viewport" content="height = 400, width = 250, user-scalable = no" />
<meta name="viewport" content="height = 400, width = 215, user-scalable = no" />
<link rel="stylesheet" type="text/css" href="css/timer.css" />
<!--[if gte IE 9]>
<style type="text/css">
Expand Down
13 changes: 11 additions & 2 deletions js/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,12 @@ function GameTimer(d) {
localStorage.splitsListTracker = JSON.stringify(splitsList);
localStorage["PB" + this.splitID] = JSON.stringify(splitsObject);
console.log(localStorage.splitsListTracker);
this.genSplits();
this.makeDefaultSplits(0);
} else {
if (localStorage.splitsDefault && localStorage.splitsDefault in splitsList) {
this.selectPB(localStorage.splitsDefault);
return false;
}
this.splitSelector();
}
};
Expand All @@ -317,7 +321,7 @@ function GameTimer(d) {
var pbid;
for (pbid in splitsList) { // Gets numbers hopefully
splitsObject = JSON.parse(localStorage["PB" + pbid]);
document.getElementById("split-selector").innerHTML += '<span class="delete"><a href="#" onclick="t.deleteSplitFile(' + pbid + ')">X</a></span><ul onclick="t.selectPB(' + pbid + ')"><li>' + splitsObject.info[0] + '</li><li>' + splitsObject.info[1] + '</li></ul>';
document.getElementById("split-selector").innerHTML += '<span class="delete"><a href="#" onclick="t.deleteSplitFile(' + pbid + ')">X</a></span><span class="defaultSplit"><a href="#" onclick="t.makeDefaultSplits(' + pbid + ')">✓</a></span><ul onclick="t.selectPB(' + pbid + ')"><li>' + splitsObject.info[0] + '</li><li>' + splitsObject.info[1] + '</li></ul>';
}
// Now that the loop has run, pbid should be the last object in the element supposibly.
var nextpbid = parseInt(pbid, 10) + 1;
Expand Down Expand Up @@ -353,6 +357,11 @@ function GameTimer(d) {
this.timerReset();
};

this.makeDefaultSplits = function (pbid) {
localStorage.splitsDefault = pbid;
this.selectPB(pbid);
};

this.deleteSplitFile = function (id) {
if (confirm("WARNING!:This will irrevocably delete the selected splits, Are you SURE you want to continue?")) {/* Cancel */
} else {
Expand Down

0 comments on commit 73f2497

Please sign in to comment.