mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-24 22:43:37 +00:00
49 lines
1.6 KiB
JavaScript
49 lines
1.6 KiB
JavaScript
|
'use strict';
|
||
|
var compilation_data = JSON.parse(document.getElementById('compilation_data').textContent);
|
||
|
var payload = 'csrf_token=' + compilation_data.csrf_token;
|
||
|
|
||
|
function add_compilation_video(target) {
|
||
|
var select = target.parentNode.children[0].children[1];
|
||
|
var option = select.children[select.selectedIndex];
|
||
|
|
||
|
var url = '/compilation_ajax?action_add_video=1&redirect=false' +
|
||
|
'&video_id=' + target.getAttribute('data-id') +
|
||
|
'&compilation_id=' + option.getAttribute('data-compid');
|
||
|
|
||
|
helpers.xhr('POST', url, {payload: payload}, {
|
||
|
on200: function (response) {
|
||
|
option.textContent = '✓' + option.textContent;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function add_compilation_item(target) {
|
||
|
var tile = target.parentNode.parentNode.parentNode.parentNode.parentNode;
|
||
|
tile.style.display = 'none';
|
||
|
|
||
|
var url = '/compilation_ajax?action_add_video=1&redirect=false' +
|
||
|
'&video_id=' + target.getAttribute('data-id') +
|
||
|
'&compilation_id=' + target.getAttribute('data-compid');
|
||
|
|
||
|
helpers.xhr('POST', url, {payload: payload}, {
|
||
|
onNon200: function (xhr) {
|
||
|
tile.style.display = '';
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function remove_compilation_item(target) {
|
||
|
var tile = target.parentNode.parentNode.parentNode.parentNode.parentNode;
|
||
|
tile.style.display = 'none';
|
||
|
|
||
|
var url = '/compilation_ajax?action_remove_video=1&redirect=false' +
|
||
|
'&set_video_id=' + target.getAttribute('data-index') +
|
||
|
'&compilation_id=' + target.getAttribute('data-compid');
|
||
|
|
||
|
helpers.xhr('POST', url, {payload: payload}, {
|
||
|
onNon200: function (xhr) {
|
||
|
tile.style.display = '';
|
||
|
}
|
||
|
});
|
||
|
}
|