diff --git a/background.js b/background.js index 7f84796..16eef35 100644 --- a/background.js +++ b/background.js @@ -6,22 +6,58 @@ var main = { chrome.storage.sync.get('youtube_queue_extension_queue', function(data){ if(data['youtube_queue_extension_queue'] == undefined) { - data['youtube_queue_extension_queue'] = []; + // data['youtube_queue_extension_queue'] = []; + saveQueue([]); } else{ main.songs = data['youtube_queue_extension_queue']; } }); +//New Feature Popup Starts +//Think about it +//New Feature Popup Ends + function saveQueue(currentQueue){ chrome.storage.sync.set({'youtube_queue_extension_queue': currentQueue}, function(){ - + main.songs = currentQueue; }); -} +}; + var tabId = 0; var next_video = 1; +function reorderQueue(newPositions){ + //change + var current = 0; + if(main.songs.length == 1){ + return; + } + console.log(newPositions); + console.log("Next video:" + next_video); + if(next_video == 0){ + current = main.songs.length-1; + } + else + { + current = next_video-1; + } + console.log("Current Video" + current); + // alert(current); + for(var ghi = 0; ghi 0){ chrome.tabs.create({'url': main.songs[0].url}, function(tab) { @@ -74,22 +110,29 @@ function playSpecificVideo(songnum){ chrome.browserAction.setBadgeBackgroundColor({ color: [0, 0, 0, 255] }); chrome.browserAction.setBadgeText({text: left.toString()}); } + else{ + next_video = 0; + } } function removeCertainVideo(songnum){ - //songnum is index var curr = next_video-1; if(curr == -1) curr = main.songs.length-1; - var n = Number(songnum); + var n = Number(songnum); if(n>=0 && n