Skip to content

Commit

Permalink
added search for exact match and found subs highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Richter committed Aug 23, 2014
1 parent 4044d19 commit d46f8bd
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 6 deletions.
8 changes: 7 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
Zbývá udělat:
- v pozadavcich ciselne hodnoceni z CSFD a IMDB misto textu, klikaci odkazy na dane weby
- vypsat existenci (ano/ne) anglickych titulek k filmu z subtitleseeker api?
- vytvořit vlastní API wrapper
- pouzit CSFDapi v2 pro overeni nalezeni spravneho filmu dle IMDB

Hotovo:
- u CSFD hodnoceni barevne odlisit pozadi (modre/cervene 70%+)
- pridat hodnoceni a odkazy do vypisu konkretniho filmu
- vypsat existenci (ano/ne) anglickych titulek k filmu z subtitleseekr api?


*IMDB api http://www.omdbapi.com/
*CSFD api http://csfdapi.cz/
56 changes: 53 additions & 3 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ function searchMovieCsfd (title,year) {
makeMagicCsfd(data["rating"],data["csfd_url"]);
});
}

});
}

Expand Down Expand Up @@ -49,7 +48,22 @@ function makeMagicImdb (rating) {
}

$(document).ready(function() {
$("a[href$='Logoff=true']").closest("table").after("<a href =\"http://www.titulky.com/index.php?Preklad=0\" class =\"plus-new\">Nový překlad</a>");

// kdokoliv je prihlasen, odkaz na vytvoreni noveho prekladu
$("a[href$='Logoff=true']").closest("table").after("<a href =\"http://www.titulky.com/index.php?Preklad=0\" class =\"plus-new\">Nový překlad</a>");

// pouze prihlaseni
if ($("a[href$='Logoff=true']").length)
{
$("#search_submit").after("<a title =\"Vyhledat přesnou shodu (pouze pro premium uživatele)\" href =\"\" class=\"tlacitko plus-search\">Vyhledat přesně</a>");
$(".plus-search").click(function(event){
window.location.href ="http://www.titulky.com/index.php?Searching=AdvancedResult&AFulltext=&ARelease=&ARok=&ANazev="+$("#searchTitulky").val();
return false;
});
$("#tablesearch").css("margin-bottom","20px");
}

// sekce pozadavky
if (location.href.indexOf("Stat=6") !== -1)
{
$(".detailh:first").text("Poslední").attr("width",70);
Expand All @@ -66,14 +80,50 @@ $(document).ready(function() {
});
}

// detail titulku
if ($("h1").length && $("a[target='imdb']").length)
{
var titleArray = $("h1").text().split(" ("),
title = titleArray[0],
spaceTitle = title.replace(new RegExp(" ", 'g'), "+"),
spaceTitle = title.replace(new RegExp(" ", 'g'), "+").replace("&",""),
year = titleArray[1].substring(0,4),
imdb = $("a[target='imdb']").attr("href").split("title/")[1].slice(0,-1);

// pouze prihlaseni
if ($("a[href$='Logoff=true']").length)
{
//odkaz pro prime vyhledani dalsich verzi, pouze prihlase premium, zadny fulltext
$("a[href^='index.php?Fulltext']").after("<a title =\"Další verze titulků konkrétního filmu (pouze pro premium uživatele)\" class =\"plus-version\" href=\"http://www.titulky.com/index.php?Searching=AdvancedResult&AFulltext=&ANazev="+title+"&ARelease=&ARok="+year+"\">Další přesné verze</a>");
}

searchMovieCsfd(spaceTitle,year);
searchMovieImdb(imdb);
}

// vysledky vyhledavani
if (location.href.indexOf("Fulltext") !== -1)
{
var search = $("#searchTitulky").val().toLowerCase();
if (search.length)
{
$.get("http://www.omdbapi.com/?s="+search,function(data) {
data = JSON.parse(data);
if (typeof data.Search !== "undefined")
{
var year = data["Search"][0]["Year"];
}
$(".soupis td:nth-child(1)").slice(1).filter(function() {
return $(this).text().trim().toLowerCase().replace(new RegExp(/ s\d{2}e\d{2}.*/), "") == search;
}).closest("tr").addClass("plus-topped")/*.insertBefore($(".soupis tr:nth-child(2)"))*/;
$(".plus-topped:first").attr("id","titulek").attr("name","titulek");
window.location.hash="titulek";
});
}
}

// vyhledavej vzdy naprimo, bez fulltextu
/*$("form[name='searchformsub']").submit(function(event){
window.location.href = "http://www.titulky.com/index.php?Searching=AdvancedResult&AFulltext=&ARelease=&ARok=&ANazev="+$("#searchTitulky").val();
return false;
});*/
});
26 changes: 25 additions & 1 deletion cstyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,28 @@

.plus-rating-black {
background: #535353;
}
}

.plus-version {
margin-left: 10px;
}

.plus-topped.r1 td {
background: rgba(255,0,0,.2) !important;
}

.plus-topped.r td {
background: rgba(255,0,0,.1) !important;
}

.plus-search {
box-sizing: border-box;
position: absolute;
width: 298px;
left: 0px;
top: 205px;
-webkit-border-radius: 0 0 4px 4px !important;
border-radius: 0 0 4px 4px !important;
border: 1px solid #C1C1C1 !important;
border-top:none !important;
}
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Titulky plus",
"author": "Jan Richter aka richja",
"version": "0.0.1",
"version": "0.3",
"description": "Vylepšení webu titulky.com pro pohodlnější práci",
"manifest_version": 2,
"icons": {
Expand Down

0 comments on commit d46f8bd

Please sign in to comment.