Moved suggested specific code to suggested file, and fixed issue where suggested sometimes dissapear

This commit is contained in:
Kasper Rynning-Tønnesen
2018-09-11 14:57:43 +02:00
parent d060a1c955
commit ba8eade984
3 changed files with 12 additions and 15 deletions

View File

@@ -168,11 +168,11 @@ var Channel = {
change_offline(true, offline);
}
if(!Helper.mobilecheck() && (document.querySelectorAll("#alreadychannel").length === 0 || !Hostcontroller.old_id || document.getElementById("code-text").innerText.toUpperCase() == "ABBADUR")) setup_host_initialization();
setup_suggested_listener();
if(document.querySelectorAll("#alreadychannel").length === 0 || Helper.mobilecheck()){
setup_now_playing_listener();
get_list_listener();
setup_suggested_listener();
if(!client) {
setup_viewers_listener();
}

View File

@@ -1128,18 +1128,8 @@ var List = {
song.querySelector(".vote-container").setAttribute("class", "clickable add-suggested");
song.querySelector(".add-suggested").setAttribute("title", video_title);
//Helper.addClass(song.querySelector(".delete_button"), del_attr);
song.querySelector(".list-votes").innerText = _song_info.extra;
if(_song_info.extra == "Added") {
var date = new Date(video_votes * 1000);
song.querySelector(".vote-text").innerText = Helper.pad(date.getHours()) + ":"
+ Helper.pad(date.getMinutes()) + " - "
+ Helper.pad(date.getDate()) + "."
+ Helper.pad(date.getMonth()) + "."
+ Helper.pad((date.getYear()-100));
} else if(_song_info.extra == "Views") {
song.querySelector(".vote-text").innerText = video_votes.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
song.querySelector(".vote-text").innerText = video_votes;
song.querySelector(attr).setAttribute("data-video-title", video_title);
song.querySelector(attr).setAttribute("data-video-length", _song_info.length);
song.querySelector(attr).setAttribute("data-added-by", added_by);

View File

@@ -30,7 +30,13 @@ var Suggestions = {
var duration = Helper.secondsToOther(params.duration);
var video_id = params.id;
var video_title = params.title;
var toSend = {id: video_id, title: video_title, length: params.duration, duration: duration, votes: params.added, extra: "Added"};
var date = new Date(params.added * 1000);
var addedTime = Helper.pad(date.getHours()) + ":"
+ Helper.pad(date.getMinutes()) + " - "
+ Helper.pad(date.getDate()) + "."
+ Helper.pad(date.getMonth()) + "."
+ Helper.pad((date.getYear()-100));
var toSend = {id: video_id, title: video_title, length: params.duration, duration: duration, votes: addedTime, extra: "Added"};
if(params.source) toSend.source = params.source;
if(params.thumbnail) toSend.thumbnail = params.thumbnail;
var song = List.generateSong(toSend, false, false, false, true);
@@ -84,9 +90,10 @@ var Suggestions = {
duration = Helper.secondsToOther(Search.durationToSeconds(duration));
var video_id = song.id;
var video_title = song.snippet.title;
var viewCount = song.statistics.viewCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
try {
document.getElementById("suggest-song-html").insertAdjacentHTML("beforeend", List.generateSong({id: video_id, title: video_title, length: length, duration: duration, votes: song.statistics.viewCount, extra: "Views"}, false, false, false));
document.getElementById("suggest-song-html").insertAdjacentHTML("beforeend", List.generateSong({id: video_id, title: video_title, length: length, duration: duration, votes: viewCount, extra: "Views"}, false, false, false));
} catch(e) {}
}
}