Skip to content

Commit

Permalink
- Added import feature
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonHanley committed May 24, 2011
1 parent 249d7e6 commit f7bb928
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
11 changes: 8 additions & 3 deletions web/index-src.php
Expand Up @@ -103,9 +103,14 @@ function autoVer($url) {
<br /><br />
<b style="color:red;">Can't find your old notes?</b> We changed addresses. Go to the old address at
<a href="http://note5.jasonhanley.com" target="_">note5.jasonhanley.com</a>,
sign in and synchronize. Then come back to the new address at
<a href="http://h5note.com" target="_">h5note.com</a>,
sign in and synchronize and you're good to go!
and export your notes.<br />
Then come back and <a href="#" onclick="$('#import_old').show();">click here to import</a>.
<div id="import_old" style="display:none;">
Paste your exported notes here:<br />
<textarea id="import_data" style="width:32em; height:12em;"></textarea><br />
<button onclick="Note5.importOld();">Import</button>
<br /><br />
</div>
<br /><br />
<b>Problems or suggestions?</b>
<a href="http://bit.ly/n5support" target="_">http://bit.ly/n5support</a>
Expand Down
24 changes: 23 additions & 1 deletion web/js/note5.js
Expand Up @@ -150,7 +150,7 @@ var Note5 = {
for(i = 0; i < this.notes.length; i++) {
if(!this.notes[i].docId)
this.notes[i].docId = guidGenerator(); // Set id if not already set
docId = this.notes[i].docId
docId = this.notes[i].docId;
this.docIds.push(docId);
}
}
Expand Down Expand Up @@ -569,6 +569,28 @@ var Note5 = {
$('#saved_message').html('Application has been reset: '+(new Date()).get8601Time());
},

importOld: function() {
var json = $('#import_data').val();
if(json) {
data = JSON.parse(json);
if(data) {
for(i = 0; i < data.length; i++) {
var newDoc = new Note5Doc();
newDoc.name = data[i].name;
newDoc.content = data[i].content;
Note5.doc.setIndex(Note5.doc.add(newDoc)-1);
Note5.doc.docIds.push(newDoc.docId);
}
}

Note5.doc.saveLocal(); // Update docIdList
Note5.view.refreshPage(true);
}

$('#import_old').hide();
$('#button_saved').click();
},

//Resize the app window width as necessary
onresize: function() {

Expand Down

0 comments on commit f7bb928

Please sign in to comment.