Skip to content

Commit

Permalink
https://github.com/WWBN/AVideo/issues/8576
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel authored and daniel committed Oct 26, 2023
1 parent 05237b4 commit 62e69b8
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 166 deletions.
20 changes: 13 additions & 7 deletions objects/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1208,13 +1208,19 @@ function getCategoriesSelect($id) {
<select class="form-control categories_id" id="<?php echo $id; ?>" name="<?php echo $id; ?>">

<option value="0"><?php echo __('Category - Use site default'); ?></option>
<?php
array_multisort(array_column($_SESSION['login']->categories, 'hierarchyAndName'), SORT_ASC, $_SESSION['login']->categories);
foreach ($_SESSION['login']->categories as $key => $value) {
echo '<option value="' . $value->id . '">' . $value->hierarchyAndName . '</option>';
}
?>
</select>
<?php
array_multisort(array_column($_SESSION['login']->categories, 'hierarchyAndName'), SORT_ASC, $_SESSION['login']->categories);
foreach ($_SESSION['login']->categories as $key => $value) {
echo '<option value="' . $value->id . '">' . $value->hierarchyAndName . '</option>';
}
?>
</select>
if (Login::canCreateCategory()) {
?>
<button class="btn btn-primary" type="button" onclick="addNewCategory();"><i class="fas fa-plus"></i></button>
<?php
}

?>
<?php
}
56 changes: 0 additions & 56 deletions view/index_shareVideos.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,34 +65,6 @@
<?php
echo getCategoriesSelect('download_categories_id');
?>
<?php
if (Login::canCreateCategory()) {
?>
<button class="btn btn-primary" type="button" onclick="addNewCategory();"><i class="fas fa-plus"></i></button>
<script>
var reloadIfIsNotEditingCategoryTimeout;
function addNewCategory() {
clearTimeout(reloadIfIsNotEditingCategoryTimeout);
avideoModalIframe('<?php echo $streamerURL; ?>categories');
reloadIfIsNotEditingCategoryTimeout = setTimeout(function () {
reloadIfIsNotEditingCategory();
}, 500);
}

function reloadIfIsNotEditingCategory() {
clearTimeout(reloadIfIsNotEditingCategoryTimeout);
if (!avideoModalIframeIsVisible()) {
loadCategories();
} else {
reloadIfIsNotEditingCategoryTimeout = setTimeout(function () {
reloadIfIsNotEditingCategory();
}, 500);
}
}
</script>
<?php
}
?>
</div>
</div>
<?php
Expand Down Expand Up @@ -144,34 +116,6 @@ function reloadIfIsNotEditingCategory() {
<?php
echo getCategoriesSelect('bulk_categories_id');
?>
<?php
if (Login::canCreateCategory()) {
?>
<button class="btn btn-primary" type="button" onclick="addNewCategory();"><i class="fas fa-plus"></i></button>
<script>
var reloadIfIsNotEditingCategoryTimeout;
function addNewCategory() {
clearTimeout(reloadIfIsNotEditingCategoryTimeout);
avideoModalIframe('<?php echo $streamerURL; ?>categories');
reloadIfIsNotEditingCategoryTimeout = setTimeout(function () {
reloadIfIsNotEditingCategory();
}, 500);
}

function reloadIfIsNotEditingCategory() {
clearTimeout(reloadIfIsNotEditingCategoryTimeout);
if (!avideoModalIframeIsVisible()) {
loadCategories();
} else {
reloadIfIsNotEditingCategoryTimeout = setTimeout(function () {
reloadIfIsNotEditingCategory();
}, 500);
}
}
</script>
<?php
}
?>
</div>
</div>
<?php
Expand Down
50 changes: 0 additions & 50 deletions view/jquery-file-upload/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,58 +19,8 @@
<?php
echo getCategoriesSelect('categories_id_upload');
?>
<?php
if (Login::canCreateCategory()) {
?>
<button class="btn btn-primary" type="button" onclick="addNewCategory();"><i class="fas fa-plus"></i></button>
<script>
var reloadIfIsNotEditingCategoryTimeout;
function addNewCategory() {
clearTimeout(reloadIfIsNotEditingCategoryTimeout);
avideoModalIframe('<?php echo $streamerURL; ?>categories');
reloadIfIsNotEditingCategoryTimeout = setTimeout(function () {
reloadIfIsNotEditingCategory();
}, 500);
}

function reloadIfIsNotEditingCategory() {
clearTimeout(reloadIfIsNotEditingCategoryTimeout);
if (!avideoModalIframeIsVisible()) {
loadCategories();
} else {
reloadIfIsNotEditingCategoryTimeout = setTimeout(function () {
reloadIfIsNotEditingCategory();
}, 500);
}
}
</script>
<?php
}
?>
</div>
</div>
<script>
function loadCategories() {
console.log('loadCategories');
modal.showPleaseWait();
$.ajax({
url: '<?php echo $streamerURL; ?>objects/categories.json.php',
success: function (response) {
$('.categories_id').empty();
for (var item in response.rows) {
if (typeof response.rows[item] != 'object') {
continue;
}
$('.categories_id').append('<option value="' + response.rows[item].id + '"> ' + response.rows[item].hierarchyAndName + '</option>');
}
modal.hidePleaseWait();
}
});
}
$(document).ready(function () {
//loadCategories();
});
</script>
<?php
}
?>
Expand Down
88 changes: 63 additions & 25 deletions view/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,75 @@ var modal;
* @param {type} href
* @returns {Element|getLocation.l}
* var l = getLocation("http://example.com/path");
console.debug(l.hostname)
>> "example.com"
console.debug(l.pathname)
>> "/path"
console.debug(l.hostname)
>> "example.com"
console.debug(l.pathname)
>> "/path"
*/
var getLocation = function(href) {
var getLocation = function (href) {
var l = document.createElement("a");
l.href = href;
return l;
};

$(function () {
modal = modal || (function () {
var pleaseWaitDiv = $("#pleaseWaitDialog");
if (pleaseWaitDiv.length === 0) {
pleaseWaitDiv = $('<div id="pleaseWaitDialog" class="modal fade" data-backdrop="static" data-keyboard="false"><div class="modal-dialog"><div class="modal-content"><div class="modal-body"><h2>Processing...</h2><div class="progress"><div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%"></div></div></div></div></div></div>').appendTo('body');
modal = modal || (function () {
var pleaseWaitDiv = $("#pleaseWaitDialog");
if (pleaseWaitDiv.length === 0) {
pleaseWaitDiv = $('<div id="pleaseWaitDialog" class="modal fade" data-backdrop="static" data-keyboard="false"><div class="modal-dialog"><div class="modal-content"><div class="modal-body"><h2>Processing...</h2><div class="progress"><div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%"></div></div></div></div></div></div>').appendTo('body');
}

return {
showPleaseWait: function () {
pleaseWaitDiv.modal();
},
hidePleaseWait: function () {
pleaseWaitDiv.modal('hide');
},
setProgress: function (valeur) {
pleaseWaitDiv.find('.progress-bar').css('width', valeur + '%').attr('aria-valuenow', valeur);
},
setText: function (text) {
pleaseWaitDiv.find('h2').html(text);
},
};
})();
});

var reloadIfIsNotEditingCategoryTimeout;
function addNewCategory(streamerURL) {
clearTimeout(reloadIfIsNotEditingCategoryTimeout);
avideoModalIframe(streamerURL + 'categories');
reloadIfIsNotEditingCategoryTimeout = setTimeout(function () {
reloadIfIsNotEditingCategory();
}, 500);
}

function reloadIfIsNotEditingCategory() {
clearTimeout(reloadIfIsNotEditingCategoryTimeout);
if (!avideoModalIframeIsVisible()) {
loadCategories();
} else {
reloadIfIsNotEditingCategoryTimeout = setTimeout(function () {
reloadIfIsNotEditingCategory();
}, 500);
}
}

return {
showPleaseWait: function () {
pleaseWaitDiv.modal();
},
hidePleaseWait: function () {
pleaseWaitDiv.modal('hide');
},
setProgress: function (valeur) {
pleaseWaitDiv.find('.progress-bar').css('width', valeur + '%').attr('aria-valuenow', valeur);
},
setText: function (text) {
pleaseWaitDiv.find('h2').html(text);
},
};
})();
});
function loadCategories(streamerURL) {
console.log('loadCategories');
modal.showPleaseWait();
$.ajax({
url: streamerURL + 'objects/categories.json.php',
success: function (response) {
$('.categories_id').empty();
for (var item in response.rows) {
if (typeof response.rows[item] != 'object') {
continue;
}
$('.categories_id').append('<option value="' + response.rows[item].id + '"> ' + response.rows[item].hierarchyAndName + '</option>');
}
modal.hidePleaseWait();
}
});
}
28 changes: 0 additions & 28 deletions view/mini-upload-form/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,6 @@
<?php
echo getCategoriesSelect('categories_id_miniupload');
?>
<?php
if (Login::canCreateCategory()) {
?>
<button class="btn btn-primary" type="button" onclick="addNewCategory();"><i class="fas fa-plus"></i></button>
<script>
var reloadIfIsNotEditingCategoryTimeout;
function addNewCategory() {
clearTimeout(reloadIfIsNotEditingCategoryTimeout);
avideoModalIframe('<?php echo $streamerURL; ?>categories');
reloadIfIsNotEditingCategoryTimeout = setTimeout(function () {
reloadIfIsNotEditingCategory();
}, 500);
}

function reloadIfIsNotEditingCategory() {
clearTimeout(reloadIfIsNotEditingCategoryTimeout);
if (!avideoModalIframeIsVisible()) {
loadCategories();
} else {
reloadIfIsNotEditingCategoryTimeout = setTimeout(function () {
reloadIfIsNotEditingCategory();
}, 500);
}
}
</script>
<?php
}
?>
</div>
</div>
<?php
Expand Down

0 comments on commit 62e69b8

Please sign in to comment.