From 2da11c6502beaceead0f04d8999a5ecd25c79249 Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Tue, 18 Feb 2014 15:31:32 +0330 Subject: [PATCH] fixed bg with sketchy projects --- Mobile/js/mobile.js | 13 +++++++++---- Web/js/main.js | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Mobile/js/mobile.js b/Mobile/js/mobile.js index 9be3917..3d61cba 100755 --- a/Mobile/js/mobile.js +++ b/Mobile/js/mobile.js @@ -53,13 +53,16 @@ window.save = function() { var data = $c[0].toDataURL(); if( save.type == 'sketchy project' ) { var list = JSON.parse(localStorage.getItem('projects')); - if( list && list.some(function(a) { return a.name == save['file name'] }) ) { + var index; + if( list && list.some(function(a, i) { if( a.name == save['file name'] ) {index = i; return true} return false }) ) { if( confirm('A sketch with this name already exists. Do you want to overwrite ' + save['file name']) + '?' ) { - list.push({ + console.log(index); + list[index] = { name: save['file name'], data: data, - points: window.points - }) + points: window.points, + settings: settings + } localStorage.setItem('projects', JSON.stringify(list)); } } @@ -90,6 +93,8 @@ window.load = function() { c.drawImage(img, 0, 0); window.points = file.points; window.points.history = [{ data: c.createImageData($c.width(), $c.height()), points: []}, { data: c.getImageData(0, 0, width(), height()), points: file.points}]; + $c.first().css('background', file.settings.bg); + window.settings.bg = file.settings.bg; } } diff --git a/Web/js/main.js b/Web/js/main.js index 2aa1b23..c79ec61 100755 --- a/Web/js/main.js +++ b/Web/js/main.js @@ -73,13 +73,16 @@ $(document).ready(function() { if( save.type == 'sketchy project' ) { var list = JSON.parse(localStorage.getItem('projects')); - if( list && list.some(function(a) { return a.name == save['file name'] }) ) { + var index; + if( list && list.some(function(a, i) { if( a.name == save['file name'] ) {index = i; return true} return false }) ) { if( confirm('A sketch with this name already exists. Do you want to overwrite ' + save['file name']) + '?' ) { - list.push({ + console.log(index); + list[index] = { name: save['file name'], data: data, - points: window.points - }) + points: window.points, + settings: settings + } localStorage.setItem('projects', JSON.stringify(list)); } } @@ -110,6 +113,8 @@ $(document).ready(function() { c.drawImage(img, 0, 0); window.points = file.points; window.points.history = [{ data: c.createImageData($c.width(), $c.height()), points: []}, { data: c.getImageData(0, 0, width(), height()), points: file.points}]; + $c.first().css('background', file.settings.bg); + window.settings.bg = file.settings.bg; } } window.load = load;