1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-25 09:18:50 -05:00
SickRage/gui/slick/js/ajaxEpSubtitles.js
Alexandre Beloin 3e1e3e61ff Fix subtitles display issues.
When multiSubtitles is not activated:
-Download history show flag of the last 2 chars before ext.
-Subtitle lang was always und.
-Keep lang value between refresh
2015-02-15 19:41:07 -05:00

50 lines
1.8 KiB
JavaScript

(function(){
$.fn.ajaxEpSubtitlesSearch = function(){
$('.epSubtitlesSearch').click(function(){
var subtitles_td = $(this).parent().siblings('.col-subtitles');
var subtitles_search_link = $(this);
// fill with the ajax loading gif
subtitles_search_link.empty();
subtitles_search_link.append($("<img/>").attr({"src": sbRoot+"/images/loading16.gif", "alt": "", "title": "loading"}));
$.getJSON($(this).attr('href'), function(data){
if (data.result != "failure" && data.result != "No subtitles downloaded") {
// clear and update the subtitles column with new informations
var subtitles = data.subtitles.split(',');
subtitles_td.empty()
$.each(subtitles,function(index, language){
if (language != "" && language != "und") {
if (index != subtitles.length - 1) {
subtitles_td.append($("<img/>").attr({"src": sbRoot+"/images/flags/"+language+".png", "alt": language, "width": 16, "height": 11}));
} else {
subtitles_td.append($("<img/>").attr({"src": sbRoot+"/images/flags/"+language+".png", "alt": language, "width": 16, "height": 11}));
}
}
});
// don't allow other searches
subtitles_search_link.remove();
} else {
subtitles_search_link.remove();
}
});
// don't follow the link
return false;
});
};
$.fn.ajaxEpMergeSubtitles = function(){
$('.epMergeSubtitles').click(function(){
var subtitles_merge_link = $(this);
// fill with the ajax loading gif
subtitles_merge_link.empty();
subtitles_merge_link.append($("<img/>").attr({"src": sbRoot+"/images/loading16.gif", "alt": "", "title": "loading"}));
$.getJSON($(this).attr('href'), function(data){
// don't allow other merges
subtitles_merge_link.remove();
});
// don't follow the link
return false;
});
}
})();