Added an icon to the video results to show the type

This commit is contained in:
Fabio Manganiello 2018-04-26 15:23:06 +02:00
parent 7fb0a5bb55
commit 797d6a0fe8
2 changed files with 24 additions and 0 deletions

View file

@ -32,6 +32,10 @@ form#video-ctrl {
cursor: pointer;
}
.video-icon-container {
margin-right: 1rem;
}
.video-result.selected {
background-color: #c8ffd0 !important;
}

View file

@ -14,10 +14,30 @@ $(document).ready(function() {
.attr('data-url', video['url'])
.html('title' in video ? video['title'] : video['url']);
var $icon = getVideoIconByUrl(video['url']);
$icon.prependTo($videoResult);
$videoResult.appendTo($videoResults);
}
};
var getVideoIconByUrl = function(url) {
var $icon = $('<i class="fa"></i>');
if (url.startsWith('file://')) {
$icon.addClass('fa-hdd');
} else if (url.startsWith('https://www.youtube.com/')) {
$icon.addClass('fa-youtube');
} else if (url.startsWith('magnet:?')) {
$icon.addClass('fa-wifi');
} else {
$icon.addClass('fa-video');
}
var $iconContainer = $('<span></span>').addClass('video-icon-container');
$icon.appendTo($iconContainer);
return $iconContainer;
};
var initBindings = function() {
$searchForm.on('submit', function(event) {
var $input = $(this).find('input[name=video-search-text]');