Skip to content

Commit

Permalink
Merge pull request #7 from tomten/2.14
Browse files Browse the repository at this point in the history
2 14
  • Loading branch information
tomten committed Sep 24, 2015
2 parents ceb37ae + c362b7b commit c9d2cc2
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 14 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ filmtipset-chrome-extension

Chrome Extension for Filmtipset movie site. Released version available in Chrome Web Store: https://chrome.google.com/webstore/detail/filmtipset/faajjfnpkdjpceeodjnmhdphbgehjeji

Version 2.14:

- Rarat

Version 2.11:

- Movie info pop-over slightly easier to mouse-over.
Expand Down
5 changes: 4 additions & 1 deletion content-scripts/other.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
$(function(){
var links = new FilmtipsetExtension.Links($);
links.processLinks();
window.setInterval(function(){
links.processLinks();
},
2000);
});
2 changes: 1 addition & 1 deletion js/Filmtipset/Filmtipset.ExtensionHost.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ FilmtipsetExtension.ExtensionHost = function(window, debug){
this.cache = new Cache(
-1, // Maximum size of cache = maximum size of storage medium
this.debug, // Debug?
new Cache.LocalStorageCacheStorage("filmtipset2.11")); // Use this extension's Local Storage for persisting the cache
new Cache.LocalStorageCacheStorage("filmtipset2.14")); // Use this extension's Local Storage for persisting the cache
// TODO: When to clear out obsolete caches?
this.gradeForTab = {}; // Session-scoped storage for the current page action grades for different browser tabs
this.wantedList = undefined; // Session-scoped storage for items in the user's Filmtipset Wanted List
Expand Down
2 changes: 1 addition & 1 deletion js/Filmtipset/Filmtipset.FilmtipsetApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ FilmtipsetExtension.FilmtipsetApi.prototype.getGradeInfoMovie = function(movie)
/**
* GETs an URL.
* @param {string} url Request URL.
* @param {function(*)} callback Function to call upon completion.
* @param {function((null|Object))} callback Function to call upon completion.
* Input parameter will be response for request to URL, or null upon any error.
*/
FilmtipsetExtension.FilmtipsetApi.prototype.xmlHttpRequest = function(
Expand Down
35 changes: 25 additions & 10 deletions js/Filmtipset/Filmtipset.Links.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ FilmtipsetExtension.Links = function (jQuery){
this.jQuery = jQuery;
this.$links = [];
this.linkProcessingPort = null;
};
this.running = false;
};

/** @const */
FilmtipsetExtension.Links.image_html_template = '<img hidden style="position:absolute;" width="20" height="20" src="%grade%" />';
Expand Down Expand Up @@ -54,7 +55,8 @@ FilmtipsetExtension.Links.prototype.handleResponse = function(contentScriptReque
var gradeUrl = contentScriptRequestCallback.gradeIconUrl;
var movieInfo = contentScriptRequestCallback.movieInfo;
var $link = this.jQuery(this.$links[reference]);
if (
$link.attr("filmtipsified", "true");
if (
movieInfo &&
movieInfo.name
)
Expand All @@ -77,6 +79,7 @@ FilmtipsetExtension.Links.prototype.handleResponse = function(contentScriptReque
$link.append($gradeImage);
$gradeImage.fadeIn(200);
if (reference >= this.$links.length - 1) { // HACK: Should be == something
this.running = false;
this.jQuery("#filmtipsetImdbLinks").stop().slideUp(500, "linear", function(){});
this.linkProcessingPort.disconnect();
}
Expand All @@ -101,8 +104,11 @@ FilmtipsetExtension.Links.prototype.handleResponse = function(contentScriptReque
@private
*/
FilmtipsetExtension.Links.prototype.processLinksInternal = function(link_selector){
var self = this;
this.$links = this.jQuery(link_selector); // collect all links to follow
var self = this;
if (this.running)
return;
this.running = true;
this.$links = this.jQuery(link_selector).not('[filmtipsified]'); // collect all unprocessed links to follow
if (this.$links.length > 0) { // are there any links to follow?
this.linkProcessingPort = chrome.runtime.connect(); // setup the port used to communicate with the event page
this.linkProcessingPort.onMessage.addListener(
Expand All @@ -112,17 +118,26 @@ FilmtipsetExtension.Links.prototype.processLinksInternal = function(link_selecto
function(contentScriptRequestCallback){
self.handleResponse.call(self, contentScriptRequestCallback); // TODO: is .call() necessary?
}); // setup the response handler for the port
this.jQuery("body").append(
FilmtipsetExtension.Links.progress_html
.replace("%remsaUrl%", chrome.extension.getURL("images/progress.png"))
.replace("%linkCount%", this.$links.length)
);
this.jQuery("#filmtipsetImdbLinks")

if (this.jQuery("#filmtipsetImdbLinks").length === 0)
this.jQuery("body").append(
FilmtipsetExtension.Links.progress_html
.replace(
"%remsaUrl%",
chrome.extension.getURL("images/progress.png")
)
);

$("#filmLinkCount").html(this.$links.length);

this.jQuery("#filmtipsetImdbLinks")
//.hide() // Hide the progress bar and...
.delay(3000) // ...wait 3 seconds before...
.slideDown(500, "linear", function(){}); // ...showing it (to avoid it showing it at all if possible)
this.processOneLink(0);
}
else
this.running = false;
};

/**
Expand Down
5 changes: 5 additions & 0 deletions js/Filmtipset/warnings
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Filmtipset.ExtensionHost.js:112: ERROR - Bad type annotation. Unknown type chrome.runtime.Port
* @param {chrome.runtime.Port} port
^

1 error(s), 0 warning(s)
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"content_security_policy": "script-src 'self' https://ssl.google-analytics.com; object-src 'self'",
"name": "__MSG_extensionName__",
"short_name": "__MSG_extensionShortName__",
"version": "2.11",
"version": "2.14",
"web_accessible_resources": [
"extension-pages/filmtipset.html.js",
"extension-pages/grade.html.js",
Expand Down

0 comments on commit c9d2cc2

Please sign in to comment.