function save(){
var str=makeCookieString();
setCookie("sudoku_fingerprint",str);
alert("此数独九宫格已经保存了");
}
function load(){
clearer();
var str=getCookie("sudoku_fingerprint");
if(str==""||str==null){
alert("没有找到储存游戏")
return false;
}
compleated=0;
var index=0;
var puzzle_cells=str.split(";");
for(var a=0;a<9;a++){
for(var b=0;b<9;b++){
number=puzzle_cells[index];
if(number.charAt(0)=="."){
number=number.charAt(1);
cells[a][b].disabled=true;
}
cells[a][b].value=number;
index++;
}
}
}
function toggleTimer(){
if(!timer_paused){
clearTimeout(timer_clock);
timer_element.style.color="#f00";
$("timer_control").value="继续";
timer_paused=1;
var edit_mask=$("pause-hider");
edit_mask.style.display="block";
if(!timer_seconds)timer_seconds=0;
var secs=timer_seconds%60;
var mins=Math.floor(timer_seconds/60);
if(secs<10)secs="0"+secs;
if(mins<10)mins="0"+mins;
edit_mask.innerHTML="<br /><strong>游戏暂停于 "+mins+":"+secs+"</strong><br />"+
"<a onclick='toggleTimer()' style='CURSOR:pointer'>按此处继续...</a><br />"+
"<IFRAME FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=NO WIDTH=300 HEIGHT=250 ALLOWTRANSPARENCY=TRUE SRC='../ad.html'></IFRAME>";
}else{
$("timer_control").value="暂停一下";
timer_element.style.color="#000";
timer_paused=0;
timer();
var edit_mask=$("pause-hider");
edit_mask.style.display="none";
}
}
function checker(){
var found=0;
show("验算游戏...","#a84efa");
loop:
for(var a=0;a<9;a++){
for(var b=0;b<9;b++){
var ele=cells[a][b];
var id="c"+(a+1)+(b+1);
var value=ele.value
if(isNaN(value)||value<1||value>9){
if(value==""){
show("有未完成的单格","#d78601");
}else{
show("找到不正确的输入","#d78601");
}
found=1;
ele.style.background="red";
setTimeout("discolorCells('"+id+"')",2000);
break loop;
}
else if(value){
if(!checkForUnique(a,b,false)){
ele.style.background="red";
document.getElementById(repeated_at).style.background="red";
show("数字重复了哦","#d78601");
setTimeout("discolorCells('"+repeated_at+"','"+id+"')",2000);
found++;
break loop;
}
}else{
show("还有单格未完成，请完成后再试","#d78601");
ele.style.background="red";
setTimeout("discolorCells('"+id+"')",2000);
found=1;
break loop;
}
}
}
if(!found){
if(compleated)
alert("太可惜了，放弃以后的游戏不能算赢哦。请重新在来吧！");
else
alert("恭喜聪明的你已经完成了游戏，可以向更高难度再下一城哦！");
stopTimer();
show("游戏已经结束！不如再下一城吧！","#000000");
}
}
function reloadGame(){
if(confirm("将会清空数独表！\n请确认是否继续!\n")){
str2pos(orginal_game);
}
}
function solve(){
show("正在揭开此数独表之谜底...");
if(confirm("将会为您揭示此数独表之答案\n真的就此放弃吗？\n")){
str2pos(this_puzzle);
compleated=1;
show("此数独表已经破解完成");
stopTimer();
}
}
function checkStatus(){
var invalid_cells=0;
var empty_cells=0;
for(var a=0;a<9;a++){
for(var b=0;b<9;b++){
var ele=cells[a][b];
var value=ele.value
if(isNaN(value)||value<1||value>9){
if(value==""){
empty_cells++;
}else{
invalid_cells++;
}
}
else if(value){
if(!checkForUnique(a,b,true)){
ele.style.background="red";
var id="c"+(a+1)+(b+1);
$(repeated_at).style.background="red";
setTimeout("discolorCells('"+repeated_at+"','"+id+"')",2000);
return;
}
}else{
empty_cells++;
}
}
}
show("您暂时来说还完成得不错哦。还有 "+(invalid_cells+empty_cells)+" 个小格格未填上。","#006600");
fadeColor("display_area","#ffff00","#ffffff",30,100,"b");
}
function BnewGame(){
if(confirm("将会为您计算出一个全新的数独表\n确定开始一个新的游戏吗？\n"))
newGame();
}