From 0734d5a505dfdb987417aa66f5a895ae1a0a3bbb Mon Sep 17 00:00:00 2001 From: edoardoo Date: Tue, 23 Jun 2015 23:50:09 +0200 Subject: [PATCH] minor oprimisations on setVideoListener --- main.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/main.js b/main.js index 89df13b..5a7a4fd 100644 --- a/main.js +++ b/main.js @@ -2,10 +2,12 @@ function setupVideoObject(){ return { target: null, gifUrl: null, - name: null + name: null, + permalink: null }; } + function setLilikLogo(){ console.log(chrome.extension.getURL("assets/logo100.png")); jQuery(" header#top-nav a.logo").css({ @@ -22,21 +24,14 @@ function setLongPostListener(){ jQuery("#list-view-2").on( "click", ".badge-evt.post-read-more", function( event ) { event.preventDefault(); post = jQuery(event.target); - // var image = post.parent().find("img"); var sidebar = jQuery("#sidebar-longPost"); sidebar.removeClass("closed"); sidebar.html(""); var image = jQuery("#sidebar-longPost img"); -// image.on('error', function(){ -// image.attr("src", post.attr('href').replace("/gag/", "http://img-9gag-fun.9cache.com/photo/") + "_700b_v1.jpg"); -// }); -// -// image.attr("src", post.attr('href').replace("/gag/", "http://img-9gag-fun.9cache.com/photo/") + "_700b.jpg"); jQuery.get(post.attr('href'), function(content) { image.attr("src", jQuery(content).find('.badge-item-img').attr("src")); }) - // post.remove(); }); @@ -67,12 +62,14 @@ function setVideoListener(){ }); jQuery("#list-view-2").on('contextmenu', "a", function(e) { currentVideo.target = jQuery(event.target) ; - previous = currentVideo.target.parents("article").prev(); + var previous = currentVideo.target.parents("article").prev(); + var id = currentVideo.target.parents("article").data("entry-id"); + if (previous.length > 0){ - currentVideo.permalink = "http://9gag.com/?id=" + previous.data("entry-id"); - }else{ - currentVideo.permalink = "http://9gag.com/?id=" + currentVideo.target.parents("article").data("entry-id"); + id = previous.data("entry-id"); } + + cur if (currentVideo.permalink == undefined){ console.log("Warning: unable to find the permalink for this post") }