diff --git a/index.html b/index.html index c3efff3..2fdb382 100755 --- a/index.html +++ b/index.html @@ -21,7 +21,8 @@ var clear = () => { var reload = () => { $('.wiki') - .html(Wiki.get('./_view').text) + .html(Wiki.title[0] == '_' ? Wiki.text : Wiki.get('./_view').text) + .ready(update_editor) // XXX save... localStorage['wiki-data'] = JSON.stringify(Wiki.__wiki_data) @@ -34,28 +35,33 @@ var update_editor = function(){ // XXX make this update on enter... $('.title') .on('blur', () => { - Wiki.title = $('.title').text() - reload() + //Wiki.title = $('.title').text() + //reload() }) // live update text... // XXX is this the right way to go for large documents??? $('.text') - .focus(() => { - console.log('EDITING...') - $('.text').prop('contenteditable', $('.text').prop('contenteditable') != 'true') - reload() + .focus(function(){ + console.log('EDITING:', Wiki.path) + + $(this) + .prop('contenteditable', 'true') + .html(Wiki.raw) + + //reload() }) .on('keyup', () => { - if($('.text').prop('contenteditable') == 'true'){ - Wiki.raw = clearWikiWords($('.text').clone()).html() - } + console.log('SAVING:', Wiki.path) + //if($(this).prop('contenteditable') == 'true'){ + // Wiki.raw = clearWikiWords($('.text').clone()).html() + //} }) // XXX do this live, but on a timeout after user input... // XXX need to place the cursor in the same position... .blur(() => { - $('.text').prop('contenteditable', false) - reload() + $(this).removeAttr('contenteditable') + //reload() }) } @@ -65,13 +71,14 @@ var go = (path) => { path = path.trim() path = path[0] == '[' ? path.slice(1, -1) : path + Wiki.location = path + history.pushState({ - wikipath: path + wikipath: Wiki.location }, Wiki.title, window.location) - Wiki.location = path reload() } @@ -95,6 +102,7 @@ $(() => { //update_editor() + // XXX need to resolve relative hashes... $(window).on('hashchange', function(evt){ evt.preventDefault() @@ -116,11 +124,6 @@ $(() => {
- -