Skip to content

Commit

Permalink
Merge pull request #8 from tomten/2.15
Browse files Browse the repository at this point in the history
2.15
  • Loading branch information
tomten authored Nov 2, 2017
2 parents c9d2cc2 + a082778 commit 26c3cec
Show file tree
Hide file tree
Showing 19 changed files with 312 additions and 209 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
js/Filmtipset/warnings
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@ 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:
Version 2.15, November 2017:

- UI fixes to align with Chrome version 49(?) extension changes (see link). Changed default "question mark" icon into something more intuitive. https://groups.google.com/a/chromium.org/forum/#!searchin/chromium-extensions/upcoming/chromium-extensions/7As9MKhav5E/dNiZDoSCCQAJ
- Pop-up no longer stops working intermittently, hopefully. Stopped treating extension background page as persistent.
- Adding a movie to the want-to-see-list from the pop-up works now.
- Pop-up more intuitive, maybe
- Google Movies support for Sweden again, to replace Google Showtimes support (Google Showtimes was discontinued on 2016-11-01).
- jQuery 3 instead of 2

Version 2.14, September 2015:

- Rarat

Expand All @@ -12,25 +21,25 @@ Version 2.11:
- Movie info pop-over slightly easier to mouse-over.
- Extension internals remade to match new Chrome Extension guidelines (event page instead of background page, messaging API upgraded, persistent port for messaging).

Version 2.10:
Version 2.10, November 2013:

- Slightly better movie finding on Google Movies
- Less annoying progress bar?
- jQuery 2 instead of 1 since we have no need for IE support

Version 2.5:
Version 2.5, January 2014:

- Google Movies support for Sweden
- Google Movies (aka Google Showtimes) support for Sweden

Version 2.4:

- On-page Filmtipset integration also on IMDB. For example on directory/actor pages
- On-page Filmtipset integration also on IMDB. For example on director/actor pages

Version 2.3:

- User API key validation on personal settings page

Version 2.2:
Version 2.2, October 2013:

- Initial GitHub release
- Tooltips on on-page grade icons with movie information and a link to the movie on Filmtipset.
Expand Down
4 changes: 2 additions & 2 deletions _locales/sv/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"welcomeHtml": { "message": "<h1>Välkommen!</h1>För att använda detta tillägg <b>måste du <a target='filmtipset' href='http://www.filmtipset.se/api.cgi?keys=1'>skapa en personlig nyckel via Filmtipset</a></b> så att du kan få rekommendationer och sätta betyg. Fyll sedan i denna nyckel nedan. Nyckeln ska skapas för <b>pbolmsteds Chrome extension</b>" },
"accessKeyLabel": { "message": "Filmtipset API access key" },
"userKeyLabel": { "message": "Nyckel" },
"want": { "message": "Vill se" },
"filmtipsetpage": { "message": "Filmtipsetsida" },
"want": { "message": "Lägg till i 'vill se'-listan" },
"filmtipsetpage": { "message": "Gå till Filmtipset-sidan" },
"invalidApiKey": { "message": "Felaktig API-nyckel från Mina Sidor på Filmtipset! Kontrollera att du matat in exakt rätt!" },
"progressHtml": { "message": "Hämtar filmtips för <span id='filmLinkCount'> %linkCount% </span> filmer..." }
}
6 changes: 0 additions & 6 deletions content-scripts/jquery-2.0.3.min.js

This file was deleted.

1 change: 0 additions & 1 deletion content-scripts/jquery-2.0.3.min.map

This file was deleted.

4 changes: 4 additions & 0 deletions content-scripts/jquery-3.2.1.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions content-scripts/jquery-3.2.1.min.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions content-scripts/other.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$(function(){
var links = new FilmtipsetExtension.Links($);
window.setInterval(function(){
links.processLinks();
},
2000);
});
var links = new FilmtipsetExtension.Links($);
window.setInterval(
function(){ links.processLinks(); },
2000
); // HACK
});
25 changes: 23 additions & 2 deletions extension-pages/grade.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,28 @@
<head>
<style type="text/css">
body {
margin: 5px;
margin: 2em;
font-size: large;
font-family: sans-serif;
}
img {
cursor: pointer;
transition: all 0.1s ease-in-out;
}
a {
cursor: pointer;
}
div.voteimage {
margin-bottom: 1em;
}
img:hover {
transform: scale(1.2);
}
div.i18n {
transition: all 0.2s ease-in-out;
}
div.i18n:hover {
transform: scale(1.2);
}
</style>
<title>Filmtipset</title>
Expand All @@ -12,7 +33,7 @@
<div id="vote">
<!-- Grade buttons will appear here. -->
</div>
<script src="../content-scripts/jquery-2.0.3.min.js" type="text/javascript"></script>
<script src="../content-scripts/jquery-3.2.1.min.js" type="text/javascript"></script>
<script src="../js/Filmtipset/Filmtipset.js" type="text/javascript"></script>
<script src="../js/Filmtipset/Filmtipset.Common.js" type="text/javascript"></script>
<script src="../js/Filmtipset/Filmtipset.FilmtipsetApi.js" type="text/javascript"></script>
Expand Down
4 changes: 3 additions & 1 deletion extension-pages/grade.html.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ chrome.tabs.getSelected(
null,
function(selectedTab) {
var popup = new FilmtipsetExtension.Popup($);
popup.showGradeButtons(selectedTab); });
popup.showGradeButtons(selectedTab);
}
);
2 changes: 1 addition & 1 deletion extension-pages/personal.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@

</div>

<script src="../content-scripts/jquery-2.0.3.min.js"></script>
<script src="../content-scripts/jquery-3.2.1.min.js"></script>

<script src="../js/Filmtipset/Filmtipset.js"></script>

Expand Down
7 changes: 5 additions & 2 deletions js/Filmtipset/Filmtipset.Common.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,15 @@ FilmtipsetExtension.Common.prototype.getTitleFromGradeInfo = function(gradeInfo)
@constructor
@param {string} type Grade type ("seen", ...).
@param {number} grade Grade value (0-5).
@param {string} id Movie ID.
*/
FilmtipsetExtension.GradeInfo = function(
type,
grade
grade,
id
){
this.type = type;
this.grade = grade;
};
this.id = id;
};

21 changes: 14 additions & 7 deletions js/Filmtipset/Filmtipset.ExtensionHost.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
/**
* @constructor
* @param {Window} window Reference to background page window. Used for getting a reference to he Google Analytics Async Queue which is used for event tracking.
* @debug Run in debug mode?
* @param {Boolean} debug Run in debug mode?
*/
FilmtipsetExtension.ExtensionHost = function(window, debug){
this.window = window;
this.debug = debug;
this.cache = new Cache(
-1, // Maximum size of cache = maximum size of storage medium
this.debug, // Debug?
new Cache.LocalStorageCacheStorage("filmtipset2.14")); // Use this extension's Local Storage for persisting the cache
// TODO: When to clear out obsolete caches?
new Cache.LocalStorageCacheStorage("filmtipset2.15")); // Use this extension's Local Storage for persisting the cache
// TODO: Clear out obsolete caches (every Storage except the one used above)
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 Expand Up @@ -62,6 +62,7 @@ FilmtipsetExtension.ExtensionHost.prototype.showPageActionForTab = function(
chrome.pageAction.show(tabId);
chrome.pageAction.setIcon({ tabId: tabId, path: iconUrl });
chrome.pageAction.setTitle({ tabId: tabId, title: title });
chrome.pageAction.setPopup({ tabId: tabId, popup: "extension-pages/grade.html" }); // TODO
callback();
};

Expand All @@ -70,9 +71,15 @@ FilmtipsetExtension.ExtensionHost.prototype.hidePageActionForTab = function(
callback
) {
chrome.pageAction.hide(tabId);
chrome.pageAction.setPopup({ tabId: tabId, popup: "" }); // HACK: Is this needed?
callback();
};

/**
* Activates the extension for a page on IMDB.
* @param {string} tabId Current browser tab ID.
* @param {string} imdbId IMDB movie ID.
*/
FilmtipsetExtension.ExtensionHost.prototype.activateImdbPage = function(
tabId,
imdbId
Expand All @@ -83,17 +90,17 @@ FilmtipsetExtension.ExtensionHost.prototype.activateImdbPage = function(
this.cache,
this.log
);
var tips = this;
var self = this;
film.getInfoForImdbId(
imdbId,
/** @param {Object} movieInfo Filmtipset movie info. */
function(movieInfo) {
var gradeInfo = film.getGradeInfoMovie(movieInfo);
tips.gradeForTab["tab" + tabId] = gradeInfo;
self.gradeForTab["tab" + tabId] = gradeInfo;
var common = new FilmtipsetExtension.Common();
var iconUrl = common.getIconFromGradeInfo(gradeInfo);
var title = common.getTitleFromGradeInfo(gradeInfo);
tips.showPageActionForTab(
self.showPageActionForTab(
iconUrl,
title,
tabId,
Expand Down Expand Up @@ -182,7 +189,7 @@ FilmtipsetExtension.ExtensionHost.prototype.initializeMessageListener = function
var self = this;
// for complex messaging, use a port
chrome.runtime.onConnect.addListener(
/** @param {chrome.runtime.Port} port */
/** @param {Object} port */
function(port) {
self.log("Content script connected");
port.onDisconnect.addListener(function() { self.log("Content script disconnected"); });
Expand Down
24 changes: 13 additions & 11 deletions js/Filmtipset/Filmtipset.FilmtipsetApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ Date.prototype.addDays = function(days)
};

/**
* Find movies whose original or Swedish titles exactly match a query.
* Find movies whose original or Swedish title or alternative titles exactly match a query.
* @param {string} query Query to search for.
* @param {function(Array)} callback Function to run upon completion.
* Input parameter to function will be array of Filmtipset Movies.
Expand All @@ -286,10 +286,17 @@ FilmtipsetExtension.FilmtipsetApi.prototype.searchExact = function(
this.search(
query,
function(results){
var exactResults = results.filter(function(result){
var exactResults = results.filter(function(result) {
var isExactResult =
result.orgname == query ||
result.name == query; // TODO: Search alt_title.split(',') as well?
result.name == query ||
(
(result.alt_title || "")
.split(',')
.some(function(alt_tit) {
return alt_tit == query;
})
);
return isExactResult;
});
callback(exactResults);
Expand Down Expand Up @@ -347,7 +354,7 @@ FilmtipsetExtension.FilmtipsetApi.prototype.getInfoForImdbId = function(
/**
* Determines the grade and grade type for a Filmtipset Movie Info Response.
* @param {?} json Filmtipset Movie Info Response
* @return {(FilmtipsetExtension.GradeInfo|null)} Object with .grade, .type and .id for movie.
* @return {FilmtipsetExtension.GradeInfo} Object with .grade, .type and .id for movie.
* Or null on error.
*/
FilmtipsetExtension.FilmtipsetApi.prototype.getGradeInfo = function(json) {
Expand All @@ -372,7 +379,7 @@ FilmtipsetExtension.FilmtipsetApi.prototype.getGradeInfo = function(json) {
/**
* Determines the grade and grade type for a Filmtipset Movie.
* @param {?} movie Filmtipset Movie
* @return {(FilmtipsetExtension.GradeInfo|null)} Object with .grade, .type and .id for movie.
* @return {FilmtipsetExtension.GradeInfo} Object with .grade, .type and .id for movie.
* Or null on error.
*/
FilmtipsetExtension.FilmtipsetApi.prototype.getGradeInfoMovie = function(movie) {
Expand All @@ -385,12 +392,7 @@ FilmtipsetExtension.FilmtipsetApi.prototype.getGradeInfoMovie = function(movie)
if (grade) {
var gradevalue = grade.value; // null, "1", "2", "3", "4", "5"
var gradetype = grade.type; // "none", "seen", "calculated"
var gradeAndType =
{
"grade": gradevalue,
"type": gradetype,
"id": id
};
var gradeAndType = new FilmtipsetExtension.GradeInfo(gradetype, gradevalue, id);
return gradeAndType;
}
else {
Expand Down
Loading

0 comments on commit 26c3cec

Please sign in to comment.