From f3c2fa1e1c4f0f98d28ffecde632b3929c9e4510 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 7 Aug 2009 14:41:43 -0400 Subject: [PATCH 1/6] small fixes so big things work --- functions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions.php b/functions.php index 7bb3d83..fd3c1e4 100644 --- a/functions.php +++ b/functions.php @@ -19,9 +19,9 @@ function __comicpress_init() { $addons = array(); if (get_magic_quotes_gpc()) { - $_POST = stripslashes_deep($_POST); - $_GET = stripslashes_deep($_GET); - $_REQUEST = stripslashes_deep($_REQUEST); + $_POST = array_map('stripslashes_deep', $_POST); + $_GET = array_map('stripslashes_deep', $_GET); + $_REQUEST = array_map('stripslashes_deep', $_REQUEST); } if (is_dir($addons_dir = (dirname(__FILE__) . '/addons'))) { @@ -98,7 +98,7 @@ function include_partial($partials = '') { if (($result = $comicpress->get_options_partial($partials)) !== false) { list($target, $code) = $result; - ob_start(); eval('?>' . $code . '' . $code . 'get_partial_path($partials); From 05d9e1bc568eea99cff8b0f51fbc018dde0d4b99 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 7 Aug 2009 15:50:06 -0400 Subject: [PATCH 2/6] quotes are not magic --- addons/Core/Core.inc | 4 +- functions.php | 466 +++++++++++++++++++++---------------------- 2 files changed, 232 insertions(+), 238 deletions(-) diff --git a/addons/Core/Core.inc b/addons/Core/Core.inc index 3ecc229..61501ca 100644 --- a/addons/Core/Core.inc +++ b/addons/Core/Core.inc @@ -575,7 +575,7 @@ class ComicPressAddonCore extends ComicPressAddon { function handle_update_override_partial($info) { switch ($info['action']) { case __('Update partial', 'comicpress'): - $this->comicpress->comicpress_options['override_partials'][$info['partial']] = $info['code']; + $this->comicpress->comicpress_options['override_partials'][$info['partial']] = stripslashes($info['code']); break; case __('Delete override partial', 'comicpress'): unset($this->comicpress->comicpress_options['override_partials'][$info['partial']]); @@ -643,4 +643,4 @@ class ComicPressAddonCore extends ComicPressAddon { } } -?> \ No newline at end of file +?> diff --git a/functions.php b/functions.php index fd3c1e4..7612938 100644 --- a/functions.php +++ b/functions.php @@ -1,236 +1,230 @@ -init(); - $addons = array(); - - if (get_magic_quotes_gpc()) { - $_POST = array_map('stripslashes_deep', $_POST); - $_GET = array_map('stripslashes_deep', $_GET); - $_REQUEST = array_map('stripslashes_deep', $_REQUEST); - } - - if (is_dir($addons_dir = (dirname(__FILE__) . '/addons'))) { - $entries = glob($addons_dir . '/*'); - if (is_array($entries)) { - foreach ($entries as $entry) { - if (is_dir($entry)) { - $classname = basename($entry); - if (file_exists($entry . "/${classname}.inc")) { - require_once($entry . "/${classname}.inc"); - $classname = "ComicPressAddon${classname}"; - if (class_exists($classname)) { - $addon =& new $classname(); - - $addon->init(&$comicpress); - if (current_user_can('edit_posts')) { - if (is_array($_REQUEST['cp'])) { - if (isset($_REQUEST['cp']['_nonce'])) { - if (wp_verify_nonce($_REQUEST['cp']['_nonce'], 'comicpress')) { - if (method_exists($addon, 'handle_update')) { - $addon->handle_update(); - $comicpress->load(); - } - } - } - } - if (is_admin()) { - add_action('admin_notices', array(&$addon, 'display_messages')); - } else { - add_action('wp_head', array(&$addon, 'display_messages')); - } - } - $addons[] = $addon; - } - } - } - } - } - } - - $layouts = $comicpress->get_layout_choices(); - if (isset($layouts[$comicpress->comicpress_options['layout']])) { - if (isset($layouts[$comicpress->comicpress_options['layout']]['Sidebars'])) { - foreach (explode(",", $layouts[$comicpress->comicpress_options['layout']]['Sidebars']) as $sidebar) { - $sidebar = trim($sidebar); - register_sidebar($sidebar); - } - } - } -} - -function comicpress_init() { - global $post, $comicpress; - - if (!empty($post)) { - if (in_comic_category() && $comicpress->is_multicomic() && !is_index()) { - $comicpress->setup_multicomic_partial_paths($post->ID); - } - } - - $comicpress->partial_paths[] = get_template_directory() . '/partials'; -} - -function comicpress_get_header() { - get_header(); -} - -function include_partial($partials = '') { - global $comicpress, $post, $nav_comics; - - if (!is_array($partials)) { $partials = func_get_args(); } - - $content = $target = null; - - if (($result = $comicpress->get_options_partial($partials)) !== false) { - list($target, $code) = $result; - ob_start(); eval(' ?>' . $code . 'get_partial_path($partials); - - if ($target !== false) { - ob_start(); include($target); $content = ob_get_clean(); - } - - $target = str_replace(".inc", "", $target); - } - - if (!empty($target) && !empty($content)) { - echo apply_filters("comicpress_partial", $content, $target); - } -} - -function in_comic_category() { - global $post, $comicpress; - - return $comicpress->in_comic_category($post->ID); -} - -/** - * Display the list of Storyline categories. - */ -function comicpress_list_storyline_categories($args = "") { - global $category_tree; - - $defaults = array( - 'style' => 'list', 'title_li' => __('Storyline') - ); - - $r = wp_parse_args($args, $defaults); - - extract($r); - - $categories_by_id = get_all_category_objects_by_id(); - - $output = ''; - if ($style == "list") { $output .= '
  • '; } - if ($title_li && ($style == "list")) { $output .= $title_li; } - if ($style == "list") { $output .= "
      "; } - $current_depth = 0; - foreach ($category_tree as $node) { - $parts = explode("/", $node); - $category_id = end($parts); - $target_depth = count($parts) - 2; - if ($target_depth > $current_depth) { - $output .= str_repeat("
      • ", ($target_depth - $current_depth)); - } - if ($target_depth < $current_depth) { - $output .= str_repeat("
    • ", ($current_depth - $target_depth)); - } - $output .= '
    • '; - $output .= $categories_by_id[$category_id]->cat_name; - $output .= "
    • "; - $current_depth = $target_depth; - } - if ($current_depth > 0) { - $output .= str_repeat("
  • ", $current_depth); - } - if ($style == "list") { $output .= ""; } - echo $output; -} - -/** -* Display the comic transcript -* Transcript must be entered into a custom field named "transcript" -* @param string $displaymode, "raw" (straight from the field), "br" (includes html line breaks), "styled" (fully css styled with JavaScript expander) -*/ -function the_transcript($displaymode = 'raw') { - $transcript = get_post_meta( get_the_ID(), "transcript", true ); - switch ($displaymode) { - case "raw": - echo $transcript; - break; - case "br": - echo nl2br($transcript); - break; - case "styled": - if (!empty($transcript)) { ?> - - - -
  • -

    Latest Comics

    -
      - -
    • - -
    -
  • - -
  • -

    ? Random Comic

    -
  • - -
  • - -
  • - +init(); + $addons = array(); + + if (is_dir($addons_dir = (dirname(__FILE__) . '/addons'))) { + $entries = glob($addons_dir . '/*'); + if (is_array($entries)) { + foreach ($entries as $entry) { + if (is_dir($entry)) { + $classname = basename($entry); + if (file_exists($entry . "/${classname}.inc")) { + require_once($entry . "/${classname}.inc"); + $classname = "ComicPressAddon${classname}"; + if (class_exists($classname)) { + $addon =& new $classname(); + + $addon->init(&$comicpress); + if (current_user_can('edit_posts')) { + if (is_array($_REQUEST['cp'])) { + if (isset($_REQUEST['cp']['_nonce'])) { + if (wp_verify_nonce($_REQUEST['cp']['_nonce'], 'comicpress')) { + if (method_exists($addon, 'handle_update')) { + $addon->handle_update(); + $comicpress->load(); + } + } + } + } + if (is_admin()) { + add_action('admin_notices', array(&$addon, 'display_messages')); + } else { + add_action('wp_head', array(&$addon, 'display_messages')); + } + } + $addons[] = $addon; + } + } + } + } + } + } + + $layouts = $comicpress->get_layout_choices(); + if (isset($layouts[$comicpress->comicpress_options['layout']])) { + if (isset($layouts[$comicpress->comicpress_options['layout']]['Sidebars'])) { + foreach (explode(",", $layouts[$comicpress->comicpress_options['layout']]['Sidebars']) as $sidebar) { + $sidebar = trim($sidebar); + register_sidebar($sidebar); + } + } + } +} + +function comicpress_init() { + global $post, $comicpress; + + if (!empty($post)) { + if (in_comic_category() && $comicpress->is_multicomic() && !is_index()) { + $comicpress->setup_multicomic_partial_paths($post->ID); + } + } + + $comicpress->partial_paths[] = get_template_directory() . '/partials'; +} + +function comicpress_get_header() { + get_header(); +} + +function include_partial($partials = '') { + global $comicpress, $post, $nav_comics; + + if (!is_array($partials)) { $partials = func_get_args(); } + + $content = $target = null; + + if (($result = $comicpress->get_options_partial($partials)) !== false) { + list($target, $code) = $result; + ob_start(); eval(' ?>' . $code . 'get_partial_path($partials); + + if ($target !== false) { + ob_start(); include($target); $content = ob_get_clean(); + } + + $target = str_replace(".inc", "", $target); + } + + if (!empty($target) && !empty($content)) { + echo apply_filters("comicpress_partial", $content, $target); + } +} + +function in_comic_category() { + global $post, $comicpress; + + return $comicpress->in_comic_category($post->ID); +} + +/** + * Display the list of Storyline categories. + */ +function comicpress_list_storyline_categories($args = "") { + global $category_tree; + + $defaults = array( + 'style' => 'list', 'title_li' => __('Storyline') + ); + + $r = wp_parse_args($args, $defaults); + + extract($r); + + $categories_by_id = get_all_category_objects_by_id(); + + $output = ''; + if ($style == "list") { $output .= '
  • '; } + if ($title_li && ($style == "list")) { $output .= $title_li; } + if ($style == "list") { $output .= "
      "; } + $current_depth = 0; + foreach ($category_tree as $node) { + $parts = explode("/", $node); + $category_id = end($parts); + $target_depth = count($parts) - 2; + if ($target_depth > $current_depth) { + $output .= str_repeat("
      • ", ($target_depth - $current_depth)); + } + if ($target_depth < $current_depth) { + $output .= str_repeat("
    • ", ($current_depth - $target_depth)); + } + $output .= '
    • '; + $output .= $categories_by_id[$category_id]->cat_name; + $output .= "
    • "; + $current_depth = $target_depth; + } + if ($current_depth > 0) { + $output .= str_repeat("
  • ", $current_depth); + } + if ($style == "list") { $output .= ""; } + echo $output; +} + +/** +* Display the comic transcript +* Transcript must be entered into a custom field named "transcript" +* @param string $displaymode, "raw" (straight from the field), "br" (includes html line breaks), "styled" (fully css styled with JavaScript expander) +*/ +function the_transcript($displaymode = 'raw') { + $transcript = get_post_meta( get_the_ID(), "transcript", true ); + switch ($displaymode) { + case "raw": + echo $transcript; + break; + case "br": + echo nl2br($transcript); + break; + case "styled": + if (!empty($transcript)) { ?> + + + +
  • +

    Latest Comics

    +
      + +
    • + +
    +
  • + +
  • +

    ? Random Comic

    +
  • + +
  • + +
  • + From 51332cef0bbe39d5080ae27511a3e751d5556ed1 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 7 Aug 2009 16:01:29 -0400 Subject: [PATCH 3/6] tweak nav includes --- partials/index-comic-post.inc | 4 ++-- partials/single-comic-post.inc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/partials/index-comic-post.inc b/partials/index-comic-post.inc index a6192bf..70442c3 100644 --- a/partials/index-comic-post.inc +++ b/partials/index-comic-post.inc @@ -1,6 +1,6 @@
    - +

    @@ -14,4 +14,4 @@


    -
    \ No newline at end of file +
    diff --git a/partials/single-comic-post.inc b/partials/single-comic-post.inc index e8b2279..86d1500 100644 --- a/partials/single-comic-post.inc +++ b/partials/single-comic-post.inc @@ -1,7 +1,7 @@
    - +
    From fa64f7773843c5e1332930e560873e24d70605a1 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sat, 22 Aug 2009 18:31:10 -0400 Subject: [PATCH 4/6] fix bug in post normailzation --- classes/ComicPressComicPost.inc | 12 +++++++++--- test/ComicPressComicPostTest.php | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/classes/ComicPressComicPost.inc b/classes/ComicPressComicPost.inc index 5e458c3..6bb91a8 100644 --- a/classes/ComicPressComicPost.inc +++ b/classes/ComicPressComicPost.inc @@ -170,10 +170,16 @@ class ComicPressComicPost { usort($remaining_posts_to_sort[$type], array(&$this, 'sort_remaining_comic_images')); } - $result = array_merge($comic_image_ordering, $remaining_posts_to_sort); + foreach ($remaining_posts_to_sort as $type => $posts) { + if (is_array($comic_image_ordering[$type])) { + $comic_image_ordering[$type] = array_merge($comic_image_ordering[$type], $posts); + } else { + $comic_image_ordering[$type] = $posts; + } + } - update_post_meta($this->post->ID, 'comic_ordering', $this->build_comic_ordering_string($result)); - return $result; + update_post_meta($this->post->ID, 'comic_ordering', $this->build_comic_ordering_string($comic_image_ordering)); + return $comic_image_ordering; } } diff --git a/test/ComicPressComicPostTest.php b/test/ComicPressComicPostTest.php index 286ca56..da35d04 100644 --- a/test/ComicPressComicPostTest.php +++ b/test/ComicPressComicPostTest.php @@ -151,7 +151,7 @@ class ComicPressComicPostTest extends PHPUnit_Framework_TestCase { $p->expects($this->any())->method('get_comic_image_attachments')->will($this->returnValue($attachments)); wp_insert_post((object)array('ID' => 1)); - update_post_meta(1, 'comic_ordering', "comic:3,2"); + update_post_meta(1, 'comic_ordering', "comic:3"); $p->post = (object)array('ID' => 1); From 88c75878e40390fde8b5a1db64c4a72c2f40b96b Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sun, 23 Aug 2009 16:44:54 -0400 Subject: [PATCH 5/6] working on making bookmark widget work w/ prototype and cookiejar --- addons/BookmarkWidget/BookmarkWidget.inc | 96 +++++++++-- addons/Core/Core.inc | 15 +- addons/Core/partials/options-admin.inc | 43 ++++- .../SearchTranscripts/SearchTranscripts.inc | 1 + classes/ComicPress.inc | 3 +- functions.php | 41 +++-- js/cookiejar.js | 157 ++++++++++++++++++ 7 files changed, 316 insertions(+), 40 deletions(-) create mode 100644 js/cookiejar.js diff --git a/addons/BookmarkWidget/BookmarkWidget.inc b/addons/BookmarkWidget/BookmarkWidget.inc index a6bfed0..aa5eb74 100644 --- a/addons/BookmarkWidget/BookmarkWidget.inc +++ b/addons/BookmarkWidget/BookmarkWidget.inc @@ -1,6 +1,8 @@ __('Let your readers save their place via a cookie.', 'comicpress'))); @@ -8,31 +10,99 @@ class ComicPressAddonBookmarkWidget extends ComicPressAddon { add_action('wp_head', array(&$this, 'wp_head')); $this->comicpress->additional_javascripts[] = '/js/bookmark.js'; + + wp_enqueue_script('prototype'); + wp_enqueue_script('cookiejar', get_template_directory_uri() . '/js/cookiejar.js', array('prototype')); } function wp_head() { $last_comic = $this->comicpress->get_last_comic(); ?> -
    - +
    + + + +
    comicpress->comicpress_options['helpers'] = array(); + foreach (array('helpers', 'options') as $type) { + $this->comicpress->comicpress_options[$type] = array(); + } foreach ($this->comicpress->comicpress_options as $option => $value) { if (isset($_POST['cp'][$option])) { switch ($option) { @@ -550,8 +556,9 @@ class ComicPressAddonCore extends ComicPressAddon { $this->comicpress->comicpress_options[$option] = $_POST['cp'][$option]; break; case 'helpers': - foreach ($_POST['cp'][$option] as $helper => $set) { - $this->comicpress->comicpress_options['helpers'][$helper] = true; + case 'addons': + foreach ($_POST['cp'][$option] as $type => $set) { + $this->comicpress->comicpress_options[$option][$type] = true; } break; } diff --git a/addons/Core/partials/options-admin.inc b/addons/Core/partials/options-admin.inc index aba14f2..de16393 100644 --- a/addons/Core/partials/options-admin.inc +++ b/addons/Core/partials/options-admin.inc @@ -69,7 +69,7 @@ -

    (categories can be modified on the Posts -> Categories page)

    +

    Categories page)', 'comicpress') ?>

    @@ -98,20 +98,51 @@

    - + + all_addons)) { ?> + + + + +
    - Enable editing helpers - __('Show partials info', 'comicpress'), "show_inline_comic_ordering" => __('Show inline comic ordering', 'comicpress') ) as $key => $label) { ?> -
    + +
    + all_addons as $addon) { + if (!empty($addon->name)) { + $enabled = ($addon->is_addon_manager !== true); + $checked = $enabled && $this->comicpress->comicpress_options['addons'][$addon->name]; + ?> + +
    + +
    - " /> + +
    diff --git a/addons/SearchTranscripts/SearchTranscripts.inc b/addons/SearchTranscripts/SearchTranscripts.inc index 81fc28c..c91b42f 100644 --- a/addons/SearchTranscripts/SearchTranscripts.inc +++ b/addons/SearchTranscripts/SearchTranscripts.inc @@ -7,6 +7,7 @@ class ComicPressAddonSearchTranscripts extends ComicPressAddon { var $custom_template_default = 'search-transcript.php'; + var $name = "Search Transcripts"; function init($comicpress) { add_filter('posts_join', array(&$this, 'search_custom_join')); diff --git a/classes/ComicPress.inc b/classes/ComicPress.inc index e55c7ac..67262da 100644 --- a/classes/ComicPress.inc +++ b/classes/ComicPress.inc @@ -16,7 +16,8 @@ class ComicPress { 'category_usage' => 'storyline', 'layout' => 'classic.inc', 'helpers' => array(), - 'override_partials' => array() + 'override_partials' => array(), + 'addons' => array() ); var $additional_stylesheets = array(); diff --git a/functions.php b/functions.php index 7612938..1dfc6eb 100644 --- a/functions.php +++ b/functions.php @@ -16,7 +16,7 @@ function __comicpress_init() { $comicpress = new ComicPress(); $comicpress->init(); - $addons = array(); + $addons = array(); if (is_dir($addons_dir = (dirname(__FILE__) . '/addons'))) { $entries = glob($addons_dir . '/*'); @@ -29,24 +29,29 @@ function __comicpress_init() { $classname = "ComicPressAddon${classname}"; if (class_exists($classname)) { $addon =& new $classname(); - - $addon->init(&$comicpress); - if (current_user_can('edit_posts')) { - if (is_array($_REQUEST['cp'])) { - if (isset($_REQUEST['cp']['_nonce'])) { - if (wp_verify_nonce($_REQUEST['cp']['_nonce'], 'comicpress')) { - if (method_exists($addon, 'handle_update')) { - $addon->handle_update(); - $comicpress->load(); + + if ( + $comicpress->comicpress_options['addons'][$addon->name] || + $addon->is_addon_manager + ) { + $addon->init(&$comicpress); + if (current_user_can('edit_posts')) { + if (is_array($_REQUEST['cp'])) { + if (isset($_REQUEST['cp']['_nonce'])) { + if (wp_verify_nonce($_REQUEST['cp']['_nonce'], 'comicpress')) { + if (method_exists($addon, 'handle_update')) { + $addon->handle_update(); + $comicpress->load(); + } } } } - } - if (is_admin()) { - add_action('admin_notices', array(&$addon, 'display_messages')); - } else { - add_action('wp_head', array(&$addon, 'display_messages')); - } + if (is_admin()) { + add_action('admin_notices', array(&$addon, 'display_messages')); + } else { + add_action('wp_head', array(&$addon, 'display_messages')); + } + } } $addons[] = $addon; } @@ -54,6 +59,10 @@ function __comicpress_init() { } } } + } + + foreach ($addons as $addon) { + if ($addon->is_addon_manager) { $addon->all_addons =& $addons; break; } } $layouts = $comicpress->get_layout_choices(); diff --git a/js/cookiejar.js b/js/cookiejar.js new file mode 100644 index 0000000..9ddbfdd --- /dev/null +++ b/js/cookiejar.js @@ -0,0 +1,157 @@ +/** + * Javascript code to store data as JSON strings in cookies. + * It uses prototype.js 1.5.1 (http://www.prototypejs.org) + * + * Author : Lalit Patel + * Website: http://www.lalit.org/lab/jsoncookies + * License: Apache Software License 2 + * http://www.apache.org/licenses/LICENSE-2.0 + * Version: 0.5 + * Updated: Jan 26, 2009 + * + * Chnage Log: + * v 0.5 + * - Changed License from CC to Apache 2 + * v 0.4 + * - Removed a extra comma in options (was breaking in IE and Opera). (Thanks Jason) + * - Removed the parameter name from the initialize function + * - Changed the way expires date was being calculated. (Thanks David) + * v 0.3 + * - Removed dependancy on json.js (http://www.json.org/json.js) + * - empty() function only deletes the cookies set by CookieJar + */ + +var CookieJar = Class.create(); + +CookieJar.prototype = { + + /** + * Append before all cookie names to differntiate them. + */ + appendString: "__CJ_", + + /** + * Initializes the cookie jar with the options. + */ + initialize: function(options) { + this.options = { + expires: 3600, // seconds (1 hr) + path: '', // cookie path + domain: '', // cookie domain + secure: '' // secure ? + }; + Object.extend(this.options, options || {}); + + if (this.options.expires != '') { + var date = new Date(); + date = new Date(date.getTime() + (this.options.expires * 1000)); + this.options.expires = '; expires=' + date.toGMTString(); + } + if (this.options.path != '') { + this.options.path = '; path=' + escape(this.options.path); + } + if (this.options.domain != '') { + this.options.domain = '; domain=' + escape(this.options.domain); + } + if (this.options.secure == 'secure') { + this.options.secure = '; secure'; + } else { + this.options.secure = ''; + } + }, + + /** + * Adds a name values pair. + */ + put: function(name, value) { + name = this.appendString + name; + cookie = this.options; + var type = typeof value; + switch(type) { + case 'undefined': + case 'function' : + case 'unknown' : return false; + case 'boolean' : + case 'string' : + case 'number' : value = String(value.toString()); + } + var cookie_str = name + "=" + escape(Object.toJSON(value)); + try { + document.cookie = cookie_str + cookie.expires + cookie.path + cookie.domain + cookie.secure; + } catch (e) { + return false; + } + return true; + }, + + /** + * Removes a particular cookie (name value pair) form the Cookie Jar. + */ + remove: function(name) { + name = this.appendString + name; + cookie = this.options; + try { + var date = new Date(); + date.setTime(date.getTime() - (3600 * 1000)); + var expires = '; expires=' + date.toGMTString(); + document.cookie = name + "=" + expires + cookie.path + cookie.domain + cookie.secure; + } catch (e) { + return false; + } + return true; + }, + + /** + * Return a particular cookie by name; + */ + get: function(name) { + name = this.appendString + name; + var cookies = document.cookie.match(name + '=(.*?)(;|$)'); + if (cookies) { + return (unescape(cookies[1])).evalJSON(); + } else { + return null; + } + }, + + /** + * Empties the Cookie Jar. Deletes all the cookies. + */ + empty: function() { + keys = this.getKeys(); + size = keys.size(); + for(i=0; i Date: Sun, 23 Aug 2009 17:18:36 -0400 Subject: [PATCH 6/6] bookmark widget finished --- addons/BookmarkWidget/BookmarkWidget.inc | 88 ++------------ js/bookmark.js | 139 +++++++++++------------ js/cookiejar.js | 2 +- 3 files changed, 72 insertions(+), 157 deletions(-) diff --git a/addons/BookmarkWidget/BookmarkWidget.inc b/addons/BookmarkWidget/BookmarkWidget.inc index aa5eb74..f277495 100644 --- a/addons/BookmarkWidget/BookmarkWidget.inc +++ b/addons/BookmarkWidget/BookmarkWidget.inc @@ -13,88 +13,15 @@ class ComicPressAddonBookmarkWidget extends ComicPressAddon { wp_enqueue_script('prototype'); wp_enqueue_script('cookiejar', get_template_directory_uri() . '/js/cookiejar.js', array('prototype')); + wp_enqueue_script('bookmark', get_template_directory_uri() . '/js/bookmark.js', array('prototype', 'cookiejar')); } - function wp_head() { - $last_comic = $this->comicpress->get_last_comic(); ?> - - + + @@ -102,7 +29,6 @@ class ComicPressAddonBookmarkWidget extends ComicPressAddon { -
    COMIC BOOKMARK
    Click "Tag Page" to bookmark a comic page. When you return to the site, click "Goto Tag" to continue where you left off.'); - if (isHome) { - document.write('
    Tag This Page'); - document.write('Goto Tag'); - document.write('Clear Tag'); - document.write(''); - } else if (isSingle) { - document.write('Tag This Page'); - document.write('Goto Tag'); - document.write('Clear Tag'); - document.write(''); - } - } -} \ No newline at end of file + Event.observe(hrefs['tag-page'], 'click', function(e) { + Event.stop(e); + info.permalink = permalink; + bookmark_info.write(info); + }); + + Event.observe(hrefs['clear-tag'], 'click', function(e) { + Event.stop(e); + info.permalink = false; + bookmark_info.write(info); + }); + + Event.observe(hrefs['goto-tag'], 'click', function(e) { + if (hrefs['goto-tag'].href == "#") { Event.stop(e); } + }); +}); diff --git a/js/cookiejar.js b/js/cookiejar.js index 9ddbfdd..a7c4a8d 100644 --- a/js/cookiejar.js +++ b/js/cookiejar.js @@ -107,7 +107,7 @@ CookieJar.prototype = { get: function(name) { name = this.appendString + name; var cookies = document.cookie.match(name + '=(.*?)(;|$)'); - if (cookies) { + if (cookies) { return (unescape(cookies[1])).evalJSON(); } else { return null;