From ecf44bdf6e827ce95dda6f74ba4f86ea106f996e Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Fri, 7 Sep 2007 23:03:12 +0000 Subject: [PATCH] Made code dealing with "all notes" in link pulldown work better (or at all). --- static/js/Editor.js | 2 +- static/js/Wiki.js | 29 +++++++++++++++++++++-------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/static/js/Editor.js b/static/js/Editor.js index 2b4c948..ae42445 100644 --- a/static/js/Editor.js +++ b/static/js/Editor.js @@ -167,7 +167,7 @@ Editor.prototype.finish_init = function () { if ( this.init_focus ) this.focus(); - signal( self, "init_complete" ); + signal( this, "init_complete" ); } Editor.prototype.highlight = function ( scroll ) { diff --git a/static/js/Wiki.js b/static/js/Wiki.js index e9353f1..c1b0776 100644 --- a/static/js/Wiki.js +++ b/static/js/Wiki.js @@ -334,18 +334,24 @@ Wiki.prototype.load_editor = function ( note_title, note_id, revision, link ) { } Wiki.prototype.resolve_link = function ( note_title, link, callback ) { - if ( note_title == "all notes" ) - return; - // if the title looks like a URL, then make it a link to an external site if ( /^\w+:\/\//.test( note_title ) ) { link.target = "_new"; link.href = note_title; if ( callback ) callback( "web link" ); - return + return; } link.removeAttribute( "target" ); + if ( note_title == "all notes" ) { + link.href = "/notebooks/" + this.notebook_id + "?" + queryString( + [ "title", "note_id" ], + [ note_title, "null" ] + ); + if ( callback ) callback( "list of all notes in this notebook" ); + return; + } + var id = parse_query( link ).note_id; // if the link already has a valid-looking id, it's already resolved, so bail @@ -524,7 +530,7 @@ Wiki.prototype.editor_key_pressed = function ( editor, event ) { if ( event.modifier().ctrl ) { // ctrl-backtick: alert with frame HTML contents (temporary for debugging) if ( code == 192 || code == 96 ) { - alert( editor.document.body.innerHTML ); + alert( editor.contents() ); event.stop(); // ctrl-b: bold } else if ( code == 66 ) { @@ -1195,16 +1201,23 @@ function Link_pulldown( wiki, notebook_id, invoker, editor, link ) { // links with targets are considered links to external sites if ( link.target ) { - self.title_field.value = link.href; - replaceChildNodes( self.note_preview, "web link" ); + this.title_field.value = link.href; + replaceChildNodes( this.note_preview, "web link" ); return; } - // if the note has no destination note id set, try loading the note from the server by title var query = parse_query( link ); var title = link_title( link, query ); var id = query.note_id; + + // if the note has no destination note id set, try loading the note from the server by title if ( ( id == undefined || id == "new" || id == "null" ) && title.length > 0 ) { + if ( title == "all notes" ) { + this.title_field.value = title; + this.display_preview( title, "list of all notes in this notebook" ); + return; + } + this.invoker.invoke( "/notebooks/load_note_by_title", "GET", { "notebook_id": this.notebook_id,