summaryrefslogtreecommitdiffstats
path: root/assets/js/playlist_widget.js
diff options
context:
space:
mode:
authorOmar Roth <omarroth@protonmail.com>2019-10-15 21:29:34 -0400
committerGitHub <noreply@github.com>2019-10-15 21:29:34 -0400
commit5c6911065845d2724c7826f3d663a6ee6c7d4774 (patch)
tree5e0f15a15a5ceabcff4b5cbc3046bcfb2e0771f4 /assets/js/playlist_widget.js
parent1e34a61911bf786497793b6fe3f309a411a32aae (diff)
parentbe055d9dcb31fe64cb682d50dc70101484605741 (diff)
downloadinvidious-5c6911065845d2724c7826f3d663a6ee6c7d4774.tar.gz
invidious-5c6911065845d2724c7826f3d663a6ee6c7d4774.tar.bz2
invidious-5c6911065845d2724c7826f3d663a6ee6c7d4774.zip
Merge pull request #673 from omarroth/add-playlists
Add initial support for custom playlists
Diffstat (limited to 'assets/js/playlist_widget.js')
-rw-r--r--assets/js/playlist_widget.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/assets/js/playlist_widget.js b/assets/js/playlist_widget.js
new file mode 100644
index 00000000..5d6ddf87
--- /dev/null
+++ b/assets/js/playlist_widget.js
@@ -0,0 +1,47 @@
+function add_playlist_item(target) {
+ var tile = target.parentNode.parentNode.parentNode.parentNode.parentNode;
+ tile.style.display = 'none';
+
+ var url = '/playlist_ajax?action_add_video=1&redirect=false' +
+ '&video_id=' + target.getAttribute('data-id') +
+ '&playlist_id=' + target.getAttribute('data-plid');
+ var xhr = new XMLHttpRequest();
+ xhr.responseType = 'json';
+ xhr.timeout = 10000;
+ xhr.open('POST', url, true);
+ xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+
+ xhr.onreadystatechange = function () {
+ if (xhr.readyState == 4) {
+ if (xhr.status != 200) {
+ tile.style.display = '';
+ }
+ }
+ }
+
+ xhr.send('csrf_token=' + playlist_data.csrf_token);
+}
+
+function remove_playlist_item(target) {
+ var tile = target.parentNode.parentNode.parentNode.parentNode.parentNode;
+ tile.style.display = 'none';
+
+ var url = '/playlist_ajax?action_remove_video=1&redirect=false' +
+ '&set_video_id=' + target.getAttribute('data-index') +
+ '&playlist_id=' + target.getAttribute('data-plid');
+ var xhr = new XMLHttpRequest();
+ xhr.responseType = 'json';
+ xhr.timeout = 10000;
+ xhr.open('POST', url, true);
+ xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+
+ xhr.onreadystatechange = function () {
+ if (xhr.readyState == 4) {
+ if (xhr.status != 200) {
+ tile.style.display = '';
+ }
+ }
+ }
+
+ xhr.send('csrf_token=' + playlist_data.csrf_token);
+} \ No newline at end of file