2022-04-20 01:38:24 -07:00
|
|
|
'use strict';
|
2022-04-20 03:40:30 -07:00
|
|
|
var playlist_data = JSON.parse(document.getElementById('playlist_data').textContent);
|
2020-03-15 14:46:08 -07:00
|
|
|
|
2020-04-07 11:34:40 -07:00
|
|
|
function add_playlist_video(target) {
|
|
|
|
var select = target.parentNode.children[0].children[1];
|
|
|
|
var option = select.children[select.selectedIndex];
|
|
|
|
|
|
|
|
var url = '/playlist_ajax?action_add_video=1&redirect=false' +
|
|
|
|
'&video_id=' + target.getAttribute('data-id') +
|
|
|
|
'&playlist_id=' + option.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 () {
|
2022-04-20 02:13:16 -07:00
|
|
|
if (xhr.readyState === 4) {
|
|
|
|
if (xhr.status === 200) {
|
2020-04-07 11:34:40 -07:00
|
|
|
option.innerText = '✓' + option.innerText;
|
|
|
|
}
|
|
|
|
}
|
2022-04-20 02:05:19 -07:00
|
|
|
};
|
2020-04-07 11:34:40 -07:00
|
|
|
|
|
|
|
xhr.send('csrf_token=' + playlist_data.csrf_token);
|
|
|
|
}
|
|
|
|
|
2019-08-05 16:49:13 -07:00
|
|
|
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 () {
|
2022-04-20 02:13:16 -07:00
|
|
|
if (xhr.readyState === 4) {
|
|
|
|
if (xhr.status !== 200) {
|
2019-08-05 16:49:13 -07:00
|
|
|
tile.style.display = '';
|
|
|
|
}
|
|
|
|
}
|
2022-04-20 02:05:19 -07:00
|
|
|
};
|
2019-08-05 16:49:13 -07:00
|
|
|
|
|
|
|
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 () {
|
2022-04-20 02:13:16 -07:00
|
|
|
if (xhr.readyState === 4) {
|
|
|
|
if (xhr.status !== 200) {
|
2019-08-05 16:49:13 -07:00
|
|
|
tile.style.display = '';
|
|
|
|
}
|
|
|
|
}
|
2022-04-20 02:05:19 -07:00
|
|
|
};
|
2019-08-05 16:49:13 -07:00
|
|
|
|
|
|
|
xhr.send('csrf_token=' + playlist_data.csrf_token);
|
2022-04-25 03:14:08 -07:00
|
|
|
}
|