Skip to content

Commit 54c3e88

Browse files
committed
Fix error with saving cookie.
CSS tweeks
1 parent 0439abb commit 54c3e88

File tree

5 files changed

+20
-85
lines changed

5 files changed

+20
-85
lines changed

Encoding.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,18 @@ function saveToCookie() {
108108
var values = document.cookie.replace(/(?:(?:^|.*;\s*)state\s*\=\s*((?:[^;](?!;))*[^;]?).*)|.*/, '$1');
109109

110110

111-
if (values && confirm("A save already exists. Are you sure you want to overwrite it?")) {
112-
document.cookie = 'state=' + encode() + '; expires=Fri, 31 Dec 9999 23:59:59 GMT';
111+
if (values) {
112+
if(!confirm("A save already exists. Are you sure you want to overwrite it?")) {
113+
return false;
114+
}
115+
}
116+
117+
document.cookie = 'state=' + encode() + '; expires=Fri, 31 Dec 9999 23:59:59 GMT';
118+
119+
if (document.cookie) {
120+
alert("Save successful.");
121+
} else {
122+
alert("Save failed. Make sure cookies are enabled in your browser.");
113123
}
114124

115125
}

Puzzle.js

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -605,77 +605,3 @@ function Puzzle(givens) {
605605

606606
solution = solve(givens);
607607
}
608-
609-
// window.onload = function() {
610-
611-
612-
// var a = [].concat;
613-
// var objWindow = a();
614-
615-
// document.getElementById("hi").innerText = (objWindow) + "";
616-
617-
// alert("Hello World!");
618-
619-
620-
/* _=+!![],$=_+_;$_=[][(![]+'')[$+_]+({}+'')[_]+(!![]+'')[_]+(!![]+'')[+[]]]+'';$$=[]
621-
[({}+'')[$+_+$]+(''+{})[_]+$_[$]+({}+'')[$+_+$]+(![]+'')[_]+(!![]+'')[+[]]];_$=(![
622-
]+'')[_+$+_]+$_[$+''+(_+$)]+(![]+'')[_]+(![]+'')[$];___=(($$()[+[]][_$]("'\\"+_+_+
623-
(+[])+"'"))+(![]+'')[$+$]+(![]+'')[$]+(![]+'')[$]+(''+{})[_]+(''+{})[$+_+$+$]+($$(
624-
)+"")[$*$*$]+(''+{})[_]+(!![]+'')[_]+(![]+'')[$]+$_[$*(_+$+_+$+_)*$]+'!');$$()[+[]
625-
][_$]((![]+'')[_]+(![]+'')[$]+(![]+'')[$+$]+(!![]+'')[_]+(!![]+'')[+[]]+'(___);');
626-
*/
627-
// console.log(a());
628-
// console.log(objWindow);
629-
// var p = [];
630-
// p.push(new Puzzle("530070000600195000098000060800060003400803001700020006060000280000419005000080079")); // singles only
631-
// p.push(new Puzzle("000000000000003085001020000000507000004000100090000000500000073002010000000040009")); // singles and hidden singles only
632-
// p.push(new Puzzle("100920000524010000000000070050008102000000000402700090060000000000030945000071006")); // no guesses
633-
// p.push(new Puzzle("120400300300010050006000100700090000040603000003002000500080700007000005000000098")); // this one needs guesses
634-
// p.push(new Puzzle("000000000000000000000000000000000000000000000000000000000000000000000000000000000")); // blank
635-
636-
// for (var i = 0; i < p.length; i++) {
637-
638-
// console.log("The solution is: " + p[i].toString());
639-
// if(p[i].hasSolution()) {
640-
// console.log("Solved puzzle "+ i + ".");
641-
// } else {
642-
// console.log("Puzzle is unsolved.");
643-
// }
644-
// }
645-
// }
646-
647-
/* function Puzzle(values) {
648-
var cells[];
649-
var guessCell;
650-
var guessCellCandidates;
651-
var solution; // String
652-
653-
this.Cell = function Cell(index, value) {
654-
this.neighbors = [];
655-
this.rowNeighbors = [];
656-
this.columnNeighbors = [];
657-
this.blockNeighbors = [];
658-
this.candidates = [];
659-
this.setValue = function() {}; // Set value. If value equals zero, reset candidates.
660-
this.toString = function() {};
661-
}
662-
663-
var process = function(values) {
664-
// Perform function of grid.
665-
// Reset cells to values.
666-
// Process singles, hidden singles.
667-
// Set guessCell to the index of the cell with the least number of candidates; set guessCellCandidates.
668-
// Return each cell's value concatenated in a string.
669-
};
670-
671-
var isValid = function(values) {}; // Don't count on cell values being accurate (neighbors OK). Use values from parameter.
672-
var isFilled = function(values) { return values.indexOf("0") === -1; };
673-
674-
var solve = function() {
675-
// For each string in stack push the string created by replacing the char at index guessCell.index with the candidates in guessCellCandidates. See solve above.
676-
}
677-
// Initialize cells.
678-
} */
679-
680-
681-
// d.cookie = 'labelWidth=' + w + '; expires=Fri, 31 Dec 9999 23:59:59 GMT"'

Sudoku.css

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,9 @@ a:active {
6565
border-style: solid;
6666
border-width: 2px;
6767
display: none;
68-
float: left;
69-
margin-top: 8px;
70-
margin-right: 0px;
71-
margin-bottom: 0px;
72-
margin-left: 8px;
68+
position: absolute;
69+
top: 8px;
70+
left: 552px;
7371
width: 425px;
7472
}
7573

@@ -122,7 +120,8 @@ a:active {
122120
z-index: 2;
123121
position: fixed;
124122
top: 0px;
125-
right: -450px;
123+
right: 0px;
124+
display: none;
126125
height: 100%;
127126
background-color: #AAA;
128127
/* cursor: w-resize; */

Sudoku.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ function savePuzzle() {
266266
}
267267

268268
function saveLoadPuzzle() {
269-
document.getElementById('side_bar').style.right='0px';
269+
document.getElementById("side_bar").style.display="block";
270270

271271
document.getElementById("copy_puzzle").value = cells.toString().replace(/[^0-9]/g, "");
272272
document.getElementById("export_save").value = encode();
@@ -322,7 +322,7 @@ function submitGivens() {
322322
document.getElementById("grid_table").style.position = "static";
323323
document.getElementById("grid_table").style.marginTop = "8px";
324324
document.getElementById("grid_table").style.marginLeft = "8px";
325-
document.getElementById("side_bar").style.right = "-450px";
325+
document.getElementById("side_bar").style.display = "none";
326326

327327
document.getElementById("import_save_button").title = "This option is disabled when a sudoku puzzle is in progress.";
328328
document.getElementById("import_save_button").disabled = true;

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
</div>
143143

144144
<div id="side_bar">
145-
<div id="side_bar_close"><a href="javascript:void(0);" onclick="document.getElementById('side_bar').style.right='-450px';">Close</a></div>
145+
<div id="side_bar_close"><a href="javascript:void(0);" onclick="document.getElementById('side_bar').style.display='none';">Close</a></div>
146146

147147
<div class="small_header">Paste Puzzle:</div>
148148
<ul>

0 commit comments

Comments
 (0)