2022-04-20 10:38:24 +02:00
|
|
|
'use strict';
|
2022-04-20 12:40:30 +02:00
|
|
|
var playlist_data = JSON.parse(document.getElementById('playlist_data').textContent);
|
2022-05-06 03:46:59 +02:00
|
|
|
var payload = 'csrf_token=' + playlist_data.csrf_token;
|
2020-03-15 22:46:08 +01:00
|
|
|
|
2020-04-07 20:34:40 +02: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');
|
|
|
|
|
2022-05-06 03:46:59 +02:00
|
|
|
helpers.xhr('POST', url, {payload: payload}, {
|
|
|
|
on200: function (response) {
|
|
|
|
option.innerText = '✓' + option.innerText;
|
2020-04-07 20:34:40 +02:00
|
|
|
}
|
2022-05-06 03:46:59 +02:00
|
|
|
});
|
2020-04-07 20:34:40 +02:00
|
|
|
}
|
|
|
|
|
2019-08-06 01:49:13 +02: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');
|
|
|
|
|
2022-05-06 03:46:59 +02:00
|
|
|
helpers.xhr('POST', url, {payload: payload}, {
|
|
|
|
onNon200: function (xhr) {
|
|
|
|
tile.style.display = '';
|
2019-08-06 01:49:13 +02:00
|
|
|
}
|
2022-05-06 03:46:59 +02:00
|
|
|
});
|
2019-08-06 01:49:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
2022-05-06 03:46:59 +02:00
|
|
|
helpers.xhr('POST', url, {payload: payload}, {
|
|
|
|
onNon200: function (xhr) {
|
|
|
|
tile.style.display = '';
|
2019-08-06 01:49:13 +02:00
|
|
|
}
|
2022-05-06 03:46:59 +02:00
|
|
|
});
|
2022-04-25 12:14:08 +02:00
|
|
|
}
|