From 17c8702e0067c6118d8ac69ac0fd72c2a53b45a8 Mon Sep 17 00:00:00 2001 From: Roberto Guanciale Date: Sun, 13 Oct 2013 17:13:37 +0000 Subject: [PATCH] changed manifests and info page --- hostedapp/manifest_git.json | 2 +- src/js/app.js | 28 +++++++++++----- src/js/opensubtitle.js | 67 +++++++++++++++++++++++++++++-------- src/js/settings.js | 10 ------ src/manifest.json | 2 +- 5 files changed, 74 insertions(+), 35 deletions(-) diff --git a/hostedapp/manifest_git.json b/hostedapp/manifest_git.json index a87e7f9..ebae08d 100644 --- a/hostedapp/manifest_git.json +++ b/hostedapp/manifest_git.json @@ -1,6 +1,6 @@ { "name": "Subtitle Videoplayer Hosted", - "version": "1.4.0", + "version": "1.5.0", "manifest_version": 2, "icons": { "16": "camera.png", diff --git a/src/js/app.js b/src/js/app.js index 414d622..2eab0ab 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -202,16 +202,26 @@ MediaElementPlayer.prototype.buildsubdelay = function(player, controls, layers, $.extend(MediaElementPlayer.prototype, { buildinfo: function(player, controls, layers, media) { var - t = this, - info = $( + t = this; + var infoText = '' + '

Subtitle Videoplayer v1.5.0

' + + 'A small Chrome video player that supports external subtitles. Plase visit our project home page.

'; + if (!packaged_app) { + infoText = infoText + + 'Plase install the packaged app version of this application, that also integrate with opensubtitles.org

'; + } + + infoText = infoText + + 'This software is possible thanks to several open source projects:[Click the box to close the info window]' + + var info = $(infoText ).appendTo(controls[0].parentElement); info.find("a").click(function (e) { diff --git a/src/js/opensubtitle.js b/src/js/opensubtitle.js index fa452ff..1f242b8 100644 --- a/src/js/opensubtitle.js +++ b/src/js/opensubtitle.js @@ -115,17 +115,36 @@ var openSubsLang = [ player.setTrack(lang); }); + $('
') + .appendTo(layers); + player.opensubtitleBanner = $('.opensubtitleBanner'); + function info(text) { $('#label_opensubtitle')[0].textContent=text; }; + function infoBanner(text) { + player.opensubtitleBanner[0].textContent=text; + }; + function infoBoth(text) { + info(text); + infoBanner(text); + }; function openSubtitle(content, sub) { - info("5/6 Opening..."); + infoBoth("5/6 Opening..."); var blob = b64toBlob(content, "text/plain"); zip.createReader(new zip.BlobReader(blob),function(reader) { reader.gunzip(new zip.BlobWriter(), function(data){ info(sub.SubFileName); + infoBanner(sub.SubFileName + ' downloaded'); + t.subtitleBannerTimer = setTimeout(function() { + player.opensubtitleBanner.css('visibility','hidden'); + clearTimeout(t.subtitleBannerTimer); + delete t.subtitleBannerTimer; + t.subtitleBannerTimer = null; + }, 2000); + if (t.opensubtitleService.lastSubtitles.length > 1) { $('#select_opensubtitle').css('visibility','inherit'); @@ -156,13 +175,13 @@ var openSubsLang = [ } function downloadSubtitle(sub) { - info("4/6 Downloading..."); + infoBoth("4/6 Downloading..."); service.DownloadSubtitles({ params: [t.opensubtitleService.token, [ sub.IDSubtitleFile ]], onException:function(errorObj){ - info("Download failed..."); + infoBoth("Download failed..."); }, onComplete:function(responseObj){ var content = responseObj.result.data[0].data; @@ -175,7 +194,7 @@ var openSubsLang = [ var lang = "eng"; lang = $('#select_opensubtitle_lang')[0].value; // var lang = "ell"; - info("3/6 Searching..."); + infoBoth("3/6 Searching..."); service.SearchSubtitles({ params: [t.opensubtitleService.token, [ {query: t.openedFile.name, @@ -185,7 +204,7 @@ var openSubsLang = [ sublanguageid: lang} ], {limit:100}], onException:function(errorObj){ - info("Search failed"); + infoBoth("Search failed"); }, onComplete:function(responseObj){ // Check that at leat a subtitle has been found @@ -219,18 +238,18 @@ var openSubsLang = [ }; function movieHash() { - info("2/6 Hashing..."); + infoBoth("2/6 Hashing..."); OpenSubtitlesHash(t.openedFile, function(hash){ searchSubtitle(hash); }); }; function logIn() { - info("1/6 Authenticating..."); + infoBoth("1/6 Authenticating..."); service.LogIn({ params: ["", "", "", "ChromeSubtitleVideoplayer"], onException:function(errorObj){ - info("Authentiation failed"); + infoBoth("Authentiation failed"); }, onComplete:function(responseObj){ t.opensubtitleService.token = responseObj.result.token; @@ -239,20 +258,46 @@ var openSubsLang = [ }); }; + player.opensubtitleBanner.click(function(e) { + e.preventDefault(); + e.stopPropagation(); + logIn(); + return false; + }); + $('#opensubtitle_button').click(function (e) { $('#label_opensubtitle').css('visibility','inherit'); $('#select_opensubtitle').css('visibility','hidden'); + t.subtitleBannerTimer = setTimeout(function() { + clearTimeout(t.subtitleBannerTimer); + delete t.subtitleBannerTimer; + t.subtitleBannerTimer = null; + }, 10000); + logIn(); }); + // on load a new video media.addEventListener('loadeddata',function() { t.captionsButton .find('input[value=opensubtitle]') .prop('disabled',true); info("No subtitle"); + infoBanner("Click here to download subtitles from OpenSubtitles.org"); $('#label_opensubtitle').css('visibility','inherit'); $('#select_opensubtitle').css('visibility','hidden'); t.opensubtitleService.lastSubtitles = []; + var defaultValue = selectDefault.value; + $('#select_opensubtitle_lang').val(defaultValue); + + player.opensubtitleBanner.css('visibility','inherit'); + + t.subtitleBannerTimer = setTimeout(function() { + player.opensubtitleBanner.css('visibility','hidden'); + clearTimeout(t.subtitleBannerTimer); + delete t.subtitleBannerTimer; + t.subtitleBannerTimer = null; + }, 10000); }); @@ -280,12 +325,6 @@ var openSubsLang = [ }); }); - // on load a new video - media.addEventListener('loadeddata',function() { - var defaultValue = selectDefault.value; - $('#select_opensubtitle_lang').val(defaultValue); - }); - } }); })(mejs.$); diff --git a/src/js/settings.js b/src/js/settings.js index ab0b8e0..8ba2612 100644 --- a/src/js/settings.js +++ b/src/js/settings.js @@ -13,16 +13,6 @@ '[Click outside the box to close the settings]' ).appendTo(controls[0].parentElement); - // var settingsList = $('#settings_list')[0]; - // $('
  • ') - // .appendTo(settingsList) - // .append($('')) - // .append($('')); - // $('
  • ') - // .appendTo(settingsList) - // .append($('')) - // .append($('')); - function hide(e) { settingsPanel.css('visibility','hidden'); if (player.media.paused) diff --git a/src/manifest.json b/src/manifest.json index ceed8f0..8abfaeb 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,6 +1,6 @@ { "name": "Subtitle Videoplayer", - "version": "1.4.0", + "version": "1.5.0", "manifest_version": 2, "minimum_chrome_version": "28", "icons": {