From 523de7df4e2ec42f9a7532e9825a0fffc75c7ff6 Mon Sep 17 00:00:00 2001 From: John Foerch Date: Sun, 28 Feb 2010 19:39:43 -0500 Subject: [PATCH] xkcd.js: whitespace/style --- modules/page-modes/xkcd.js | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/modules/page-modes/xkcd.js b/modules/page-modes/xkcd.js index 9cf4f64..8b6ad8b 100644 --- a/modules/page-modes/xkcd.js +++ b/modules/page-modes/xkcd.js @@ -7,30 +7,32 @@ require("content-buffer.js"); -define_variable( - 'xkcd_add_title', false, +define_variable('xkcd_add_title', false, "When true, xkcd-mode will insert the title caption of the comic "+ "into the page, below the comic."); -/* Add the XKCD title text below the image in the page */ -function xkcd_do_add_title(buffer) { +/** + * xkcd_do_add_title adds the XKCD title text below the image in the + * page + */ +function xkcd_do_add_title (buffer) { var document = buffer.document; // Find the tag - var img = document.evaluate( - "//div[@id='middleContent']//img", + var img = document.evaluate("//div[@id='middleContent']//img", document, null, Ci.nsIDOMXPathResult.ANY_TYPE,null).iterateNext(); - if(!img) return; + if (!img) + return; var title = img.title; // In some comics, the is a link, so walk up to the surrounding - if(img.parentNode.tagName == 'A') { + if (img.parentNode.tagName == 'A') img = img.parentNode; - } var node = img.nextSibling; - while(node && node.nodeName != 'BR') { + while (node && node.nodeName != 'BR') { node = node.nextSibling; } - if(!node) return; + if (!node) + return; // Insert the text inside a with a known ID var text = document.createTextNode(title); var span = document.createElement('span'); @@ -43,11 +45,10 @@ define_page_mode("xkcd_mode", $display_name = "XKCD", $enable = function (buffer) { if (xkcd_add_title) { - if(buffer.browser.webProgress.isLoadingDocument) { + if (buffer.browser.webProgress.isLoadingDocument) add_hook.call(buffer, "buffer_dom_content_loaded_hook", xkcd_do_add_title); - } else { + else xkcd_do_add_title(buffer); - } } buffer.page.local.browser_relationship_patterns = {}; buffer.page.local.browser_relationship_patterns[RELATIONSHIP_NEXT] = @@ -56,16 +57,16 @@ define_page_mode("xkcd_mode", [new RegExp("\\bprev","i")]; }, // When we disable the mode, remove the - $disable = function(buffer) { + $disable = function (buffer) { remove_hook.call(buffer, "buffer_dom_content_loaded_hook", xkcd_do_add_title); var span = buffer.document.getElementById('conkeror:xkcd-title-text'); - if(span) { + if (span) span.parentNode.removeChild(span); - } }); -var xkcd_re = build_url_regex($domain = "xkcd", - $allow_www = true, - $tlds = ["com", "net", "org"], - $path = /(\d+\/)?/); -auto_mode_list.push([xkcd_re, xkcd_mode]); +let (re = build_url_regex($domain = "xkcd", + $allow_www = true, + $tlds = ["com", "net", "org"], + $path = /(\d+\/)?/)) { + auto_mode_list.push([re, xkcd_mode]); +} -- 2.11.4.GIT