init: add new project files
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
$(document).on("submit", "#object-add", function (e) {
|
||||
e.preventDefault();
|
||||
$("#loader").css("display", "");
|
||||
$.ajax({
|
||||
url: location.pathname,
|
||||
type: "POST",
|
||||
data: $(this).serialize(),
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
$("#loader").css("display", "none");
|
||||
if (resp.status) {
|
||||
location.href = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
|
||||
} else {
|
||||
alert(resp.error);
|
||||
}
|
||||
},
|
||||
failure: function (err) {
|
||||
$("#loader").css("display", "none");
|
||||
alert(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
$(document).on("submit", "#object-add", function (e) {
|
||||
e.preventDefault();
|
||||
$("#loader").css("display", "");
|
||||
$.ajax({
|
||||
url: location.pathname,
|
||||
type: "POST",
|
||||
data: $(this).serialize(),
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
$("#loader").css("display", "none");
|
||||
if (resp.status) {
|
||||
location.href = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
|
||||
} else {
|
||||
alert(resp.error);
|
||||
}
|
||||
},
|
||||
failure: function (err) {
|
||||
$("#loader").css("display", "none");
|
||||
alert(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
$("#auth").on("submit", function submit(e) {
|
||||
e.preventDefault();
|
||||
$.ajax({
|
||||
url: "/auth",
|
||||
type: "POST",
|
||||
data: $("#auth").serialize(),
|
||||
dataType: "json",
|
||||
success: function(resp) {
|
||||
if (resp.status) {
|
||||
location.reload();
|
||||
} else {
|
||||
alert(resp.error);
|
||||
}
|
||||
},
|
||||
failure: function(err) {
|
||||
alert(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
$(document).on("submit", "#object-edit", function (e) {
|
||||
e.preventDefault();
|
||||
$("#loader").css("display", "");
|
||||
$.ajax({
|
||||
url: location.pathname + "/edit",
|
||||
type: "POST",
|
||||
data: $(this).serialize(),
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
$("#loader").css("display", "none");
|
||||
if (!resp.status) {
|
||||
alert(resp.error);
|
||||
}
|
||||
},
|
||||
failure: function (err) {
|
||||
$("#loader").css("display", "none");
|
||||
alert(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,88 @@
|
||||
$(document).on("input", "#file-tags-filter", function (e) {
|
||||
let filter = $(this).val().toLowerCase();
|
||||
let unfiltered = $("#file-tags-other > .tag-preview");
|
||||
if (filter === "") {
|
||||
unfiltered.css("display", "");
|
||||
return;
|
||||
}
|
||||
unfiltered.each((index, element) => {
|
||||
let current = $(element);
|
||||
if (current.text().toLowerCase().includes(filter)) {
|
||||
current.css("display", "");
|
||||
} else {
|
||||
current.css("display", "none");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", "#file-tags-other > .tag-preview", function (e) {
|
||||
$("#loader").css("display", "");
|
||||
$.ajax({
|
||||
url: location.pathname + "/tag",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({add: true, tag_id: $(this).attr("tag_id")}),
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
$("#loader").css("display", "none");
|
||||
if (resp.status) {
|
||||
resp.tags.forEach((tag_id) => {
|
||||
$(`#file-tags-other > .tag-preview[tag_id='${tag_id}']`).css("display", "none");
|
||||
$(`#file-tags-selected > .tag-preview[tag_id='${tag_id}']`).css("display", "");
|
||||
});
|
||||
} else {
|
||||
alert(resp.error);
|
||||
}
|
||||
},
|
||||
failure: function (err) {
|
||||
$("#loader").css("display", "none");
|
||||
alert(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", "#file-tags-selected > .tag-preview", function (e) {
|
||||
$("#loader").css("display", "");
|
||||
let tag_id = $(this).attr("tag_id");
|
||||
$.ajax({
|
||||
url: location.pathname + "/tag",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({add: false, tag_id: $(this).attr("tag_id")}),
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
$("#loader").css("display", "none");
|
||||
if (resp.status) {
|
||||
$(`#file-tags-selected > .tag-preview[tag_id='${tag_id}']`).css("display", "none");
|
||||
$(`#file-tags-other > .tag-preview[tag_id='${tag_id}']`).css("display", "");
|
||||
} else {
|
||||
alert(resp.error);
|
||||
}
|
||||
},
|
||||
failure: function (err) {
|
||||
$("#loader").css("display", "none");
|
||||
alert(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("submit", "#object-edit", function (e) {
|
||||
e.preventDefault();
|
||||
$("#loader").css("display", "");
|
||||
$.ajax({
|
||||
url: location.pathname + "/edit",
|
||||
type: "POST",
|
||||
data: $(this).serialize(),
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
$("#loader").css("display", "none");
|
||||
if (!resp.status) {
|
||||
alert(resp.error);
|
||||
}
|
||||
},
|
||||
failure: function (err) {
|
||||
$("#loader").css("display", "none");
|
||||
alert(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,130 @@
|
||||
var curr_page = 0;
|
||||
var load_lock = false;
|
||||
var init_filter = null;
|
||||
|
||||
function files_load() {
|
||||
if (load_lock) {
|
||||
return;
|
||||
}
|
||||
load_lock = true;
|
||||
let container = $("main");
|
||||
$("#loader").css("display", "");
|
||||
$.ajax({
|
||||
url: "/api/files?limit=50&offset=" + curr_page*50 + (init_filter ? "&filter=" + encodeURIComponent("{" + init_filter + "}") : ""),
|
||||
type: "GET",
|
||||
contentType: "application/json",
|
||||
async: false,
|
||||
success: function (resp) {
|
||||
$("#loader").css("display", "none");
|
||||
resp.forEach((file) => {
|
||||
container.append(`<div class="item-preview file-preview" file_id="${file.id}"><img src="/static/thumbs/${file.id}.${file.extension}" alt="" class="file-thumb"><div class="overlay"></div></div>`);
|
||||
});
|
||||
if (resp.length == 50) {
|
||||
load_lock = false;
|
||||
}
|
||||
},
|
||||
error: function (xhr, status) {
|
||||
$("#loader").css("display", "none");
|
||||
alert(xhr.responseText);
|
||||
location.href = "/files";
|
||||
}
|
||||
});
|
||||
curr_page++;
|
||||
}
|
||||
|
||||
function tags_load(target) {
|
||||
$("#loader").css("display", "");
|
||||
$.ajax({
|
||||
url: "/api/tags",
|
||||
type: "GET",
|
||||
contentType: "application/json",
|
||||
async: false,
|
||||
success: function (resp) {
|
||||
$("#loader").css("display", "none");
|
||||
resp.forEach((tag) => {
|
||||
target.append(`<div class="filtering-token" val="t=${tag.id}" style="background-color: #${tag.category_color}">${escapeHTML(tag.name)}</div>`);
|
||||
});
|
||||
},
|
||||
error: function (xhr, status) {
|
||||
$("#loader").css("display", "none");
|
||||
alert(status);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function filter_load() {
|
||||
if (!init_filter) {
|
||||
return;
|
||||
}
|
||||
$("#files-filter").html("");
|
||||
let filtering_tokens = init_filter.split(',');
|
||||
filtering_tokens.forEach((element) => {
|
||||
$(`.filtering-block .filtering-token[val='${element}']`).clone().appendTo("#files-filter");
|
||||
});
|
||||
}
|
||||
|
||||
$(window).on("load", function (e) {
|
||||
init_filter = /filter=\{([^\}]+)/.exec(decodeURIComponent(location.search));
|
||||
init_filter = init_filter ? init_filter[1] : null;
|
||||
let container = $("main");
|
||||
while (!load_lock && container.scrollTop() + container.innerHeight() >= container[0].scrollHeight) {
|
||||
files_load();
|
||||
}
|
||||
tags_load($("#filtering-tokens-all"));
|
||||
filter_load();
|
||||
});
|
||||
|
||||
$("main").scroll(function (e) {
|
||||
if ($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight) {
|
||||
files_load();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("click", "#files-filter", function (e) {
|
||||
if ($(".filtering-block").is(":hidden")) {
|
||||
$(".filtering-block").slideDown("fast");
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("click", "#filtering-apply", function (e) {
|
||||
let filtering_tokens = [];
|
||||
$("#files-filter > .filtering-token").each((index, element) => {
|
||||
filtering_tokens.push($(element).attr("val"));
|
||||
});
|
||||
location.href = "/files?filter=" + encodeURIComponent("{" + filtering_tokens.join(',') + "}");
|
||||
});
|
||||
|
||||
$(document).on("click", "#filtering-reset", function (e) {
|
||||
$(".filtering-block").slideUp("fast");
|
||||
filter_load();
|
||||
$("#filter-filtering").val("").trigger("input");
|
||||
});
|
||||
|
||||
$(document).on("click", ".filtering-block .filtering-token", function (e) {
|
||||
$(this).clone().appendTo("#files-filter");
|
||||
});
|
||||
|
||||
$(document).on("click", "#files-filter > .filtering-token", function (e) {
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
$(document).on("input", "#filter-filtering", function (e) {
|
||||
let filter = $(this).val().toLowerCase();
|
||||
let unfiltered = $("#filtering-tokens-all > .filtering-token");
|
||||
if (filter === "") {
|
||||
unfiltered.css("display", "");
|
||||
return;
|
||||
}
|
||||
unfiltered.each((index, element) => {
|
||||
let current = $(element);
|
||||
if (current.text().toLowerCase().includes(filter)) {
|
||||
current.css("display", "");
|
||||
} else {
|
||||
current.css("display", "none");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", "#filter-filtering", function (e) {
|
||||
$(this).val("").trigger("input");
|
||||
});
|
||||
@@ -0,0 +1,363 @@
|
||||
var lazy_loader;
|
||||
|
||||
function escapeHTML(unsafe) {
|
||||
return unsafe
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'");
|
||||
}
|
||||
|
||||
function beautify_date(date_string) {
|
||||
if (date_string == null) {
|
||||
return null;
|
||||
}
|
||||
let ts = new Date(date_string).getTime();
|
||||
let tz = new Date().getTimezoneOffset();
|
||||
return new Date(ts-tz*60000).toISOString().slice(0, 19).replace("T", " ");
|
||||
}
|
||||
|
||||
function close_select_manager() {
|
||||
$(".item-selected").removeClass("item-selected");
|
||||
$(".selection-manager").css("display", "none");
|
||||
$("#selection-count").text(0);
|
||||
$("main").css("padding-bottom", "");
|
||||
$("#selection-tags-other > .tag-preview").css("display", "");
|
||||
$("#selection-tags-selected > .tag-preview").css("display", "none");
|
||||
$("#selection-tags-filter").val("").trigger("input");
|
||||
$(".selection-tags").css("display", "none");
|
||||
}
|
||||
|
||||
function refresh_selection_tags() {
|
||||
$("#loader").css("display", "");
|
||||
let file_id_list = [];
|
||||
$("main > .file-preview.item-selected").each((index, element) => {
|
||||
file_id_list.push($(element).attr("file_id"));
|
||||
});
|
||||
$("#selection-tags-other > .tag-preview").css("display", "");
|
||||
$("#selection-tags-selected > .tag-preview").css("display", "none");
|
||||
$.ajax({
|
||||
url: location.pathname + "/tags",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({action: "get", file_id_list: file_id_list}),
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
$("#loader").css("display", "none");
|
||||
if (resp.status) {
|
||||
resp.tag_id_list.forEach((tag_id) => {
|
||||
$(`#selection-tags-other > .tag-preview[tag_id='${tag_id}']`).css("display", "none");
|
||||
$(`#selection-tags-selected > .tag-preview[tag_id='${tag_id}']`).css("display", "");
|
||||
});
|
||||
} else {
|
||||
alert(resp.error);
|
||||
}
|
||||
},
|
||||
failure: function (err) {
|
||||
$("#loader").css("display", "none");
|
||||
alert(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function select_handler(curr) {
|
||||
let selection_count = +$("#selection-count").text();
|
||||
if (curr.hasClass("item-selected")) {
|
||||
curr.removeClass("item-selected");
|
||||
selection_count--;
|
||||
$("#selection-count").text(selection_count);
|
||||
if (!selection_count) {
|
||||
close_select_manager();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
curr.addClass("item-selected");
|
||||
$(".selection-manager").css("display", "");
|
||||
$("main").css("padding-bottom", "80px");
|
||||
selection_count++;
|
||||
$("#selection-count").text(selection_count);
|
||||
}
|
||||
refresh_selection_tags();
|
||||
}
|
||||
|
||||
// $(window).on("load", function () {
|
||||
// lazy_loader = $(".file-thumb").Lazy({
|
||||
// scrollDirection: "vertical",
|
||||
// effect: "fadeIn",
|
||||
// visibleOnly: true,
|
||||
// appendScroll: $("main")[0],
|
||||
// chainable: false,
|
||||
// });
|
||||
// });
|
||||
|
||||
$(document).keyup(function (e) {
|
||||
switch (e.key) {
|
||||
case "Esc":
|
||||
case "Escape":
|
||||
close_select_manager();
|
||||
break;
|
||||
// case "Left":
|
||||
// case "ArrowLeft":
|
||||
// if (current_sasa_index >= 0) {
|
||||
// file_prev();
|
||||
// }
|
||||
// break;
|
||||
// case "Right":
|
||||
// case "ArrowRight":
|
||||
// if (current_sasa_index >= 0) {
|
||||
// file_next();
|
||||
// }
|
||||
// break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("selectstart", ".item-preview", function (e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$(document).on("click", "#select", function (e) {
|
||||
if ($(".selection-manager").is(":visible")) {
|
||||
close_select_manager();
|
||||
return;
|
||||
}
|
||||
$(".selection-manager").css("display", "");
|
||||
$("main").css("padding-bottom", "80px");
|
||||
selection_count++;
|
||||
$("#selection-count").text(selection_count);
|
||||
});
|
||||
|
||||
$(document).on("click", "main > .file-preview", function (e) {
|
||||
e.preventDefault();
|
||||
if ($(".selection-manager").is(":visible")) {
|
||||
select_handler($(this));
|
||||
return;
|
||||
}
|
||||
let id = $(this).attr("file_id");
|
||||
$("#viewer").attr("src", "/files/" + id);
|
||||
$("#view-prev").attr("file_id", $(this).prev(":visible").attr("file_id"));
|
||||
$("#view-next").attr("file_id", $(this).next(":visible").attr("file_id"));
|
||||
$(".viewer-wrapper").css("display", "");
|
||||
});
|
||||
|
||||
$(document).on("click", "main > .tag-preview", function (e) {
|
||||
e.preventDefault();
|
||||
if ($(".selection-manager").is(":visible")) {
|
||||
select_handler($(this));
|
||||
return;
|
||||
}
|
||||
let id = $(this).attr("tag_id");
|
||||
location.href = "/tags/" + id;
|
||||
});
|
||||
|
||||
$(document).on("click", "main > .category-preview", function (e) {
|
||||
e.preventDefault();
|
||||
if ($(".selection-manager").is(":visible")) {
|
||||
select_handler($(this));
|
||||
return;
|
||||
}
|
||||
let id = $(this).attr("category_id");
|
||||
location.href = "/categories/" + id;
|
||||
});
|
||||
|
||||
$(document).on("click", "#sorting", function (e) {
|
||||
$("#sorting-options").slideToggle("fast");
|
||||
if ($("#sorting-options").is(":visible")) {
|
||||
key_prev = $("input[name='sorting'][prev-checked]").val();
|
||||
key_curr = $("input[name='sorting']:checked").val();
|
||||
asc_prev = $("input[name='order'][prev-checked]").val();
|
||||
asc_curr = $("input[name='order']:checked").val();
|
||||
if (key_curr != key_prev || asc_curr != asc_prev) {
|
||||
$.ajax({
|
||||
url: "/settings/sorting",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({[location.pathname.split('/')[1]]: {key: key_curr, asc: (asc_curr == "asc")}}),
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
if (resp.status) {
|
||||
location.reload();
|
||||
} else {
|
||||
alert(resp.error);
|
||||
}
|
||||
},
|
||||
failure: function (err) {
|
||||
alert(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("input", "#filter", function (e) {
|
||||
let filter = $(this).val().toLowerCase();
|
||||
let unfiltered = $("main > .item-preview");
|
||||
if (filter === "") {
|
||||
unfiltered.css("display", "");
|
||||
return;
|
||||
}
|
||||
unfiltered.each((index, element) => {
|
||||
let current = $(element);
|
||||
if (current.text().toLowerCase().includes(filter)) {
|
||||
current.css("display", "");
|
||||
} else {
|
||||
current.css("display", "none");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", ".filtering", function (e) {
|
||||
$(this).val("").trigger("input");
|
||||
})
|
||||
|
||||
$(document).on("click", "#selection-info", function (e) {
|
||||
close_select_manager();
|
||||
});
|
||||
|
||||
$(document).on("click", "#selection-edit-tags", function (e) {
|
||||
$(".selection-tags").slideToggle("fast");
|
||||
});
|
||||
|
||||
$(document).on("click", "#selection-delete", function (e) {
|
||||
if (!confirm("Delete selected?")) {
|
||||
return;
|
||||
}
|
||||
let file_id_list = [];
|
||||
$("main > .file-preview.item-selected").each((index, element) => {
|
||||
file_id_list.push($(element).attr("file_id"));
|
||||
});
|
||||
$.ajax({
|
||||
url: location.pathname + "/delete",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({file_id_list: file_id_list}),
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
$("#loader").css("display", "none");
|
||||
if (resp.status) {
|
||||
location.reload();
|
||||
} else {
|
||||
alert(resp.error);
|
||||
}
|
||||
},
|
||||
failure: function (err) {
|
||||
$("#loader").css("display", "none");
|
||||
alert(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", "#selection-tags-other > .tag-preview", function (e) {
|
||||
$("#loader").css("display", "");
|
||||
let tag_id = $(this).attr("tag_id");
|
||||
let file_id_list = [];
|
||||
$("main > .file-preview.item-selected").each((index, element) => {
|
||||
file_id_list.push($(element).attr("file_id"));
|
||||
});
|
||||
$.ajax({
|
||||
url: location.pathname + "/tags",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({action: "add", file_id_list: file_id_list, tag_id: tag_id}),
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
$("#loader").css("display", "none");
|
||||
if (resp.status) {
|
||||
resp.tag_id_list.forEach((tag_id) => {
|
||||
$(`#selection-tags-other > .tag-preview[tag_id='${tag_id}']`).css("display", "none");
|
||||
$(`#selection-tags-selected > .tag-preview[tag_id='${tag_id}']`).css("display", "");
|
||||
});
|
||||
} else {
|
||||
alert(resp.error);
|
||||
}
|
||||
},
|
||||
failure: function (err) {
|
||||
$("#loader").css("display", "none");
|
||||
alert(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", "#selection-tags-selected > .tag-preview", function (e) {
|
||||
$("#loader").css("display", "");
|
||||
let tag_id = $(this).attr("tag_id");
|
||||
let file_id_list = [];
|
||||
$("main > .file-preview.item-selected").each((index, element) => {
|
||||
file_id_list.push($(element).attr("file_id"));
|
||||
});
|
||||
$.ajax({
|
||||
url: location.pathname + "/tags",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({action: "remove", file_id_list: file_id_list, tag_id: tag_id}),
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
$("#loader").css("display", "none");
|
||||
if (resp.status) {
|
||||
$(`#selection-tags-selected > .tag-preview[tag_id='${tag_id}']`).css("display", "none");
|
||||
$(`#selection-tags-other > .tag-preview[tag_id='${tag_id}']`).css("display", "");
|
||||
} else {
|
||||
alert(resp.error);
|
||||
}
|
||||
},
|
||||
failure: function (err) {
|
||||
$("#loader").css("display", "none");
|
||||
alert(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("input", "#selection-tags-filter", function (e) {
|
||||
let filter = $(this).val().toLowerCase();
|
||||
let unfiltered = $("#selection-tags-other > .item-preview");
|
||||
if (filter === "") {
|
||||
unfiltered.css("display", "");
|
||||
return;
|
||||
}
|
||||
unfiltered.each((index, element) => {
|
||||
let current = $(element);
|
||||
if (current.text().toLowerCase().includes(filter)) {
|
||||
current.css("display", "");
|
||||
} else {
|
||||
current.css("display", "none");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("scroll", $("#viewer").contents(), function (e) {
|
||||
let pos = $(this).scrollTop();
|
||||
$(window.parent.document).find(".viewer-nav").css({
|
||||
top: (-pos) + "px",
|
||||
bottom: pos + "px"
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", "#view-next", function (e) {
|
||||
let id = $(this).attr("file_id");
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
let curr = $(`.file-preview[file_id='${id}']`)
|
||||
$("#viewer").attr("src", "/files/" + id);
|
||||
$("#view-prev").attr("file_id", curr.prev(":visible").attr("file_id"));
|
||||
$("#view-next").attr("file_id", curr.next(":visible").attr("file_id"));
|
||||
$(".viewer-wrapper").css("display", "");
|
||||
});
|
||||
|
||||
$(document).on("click", "#view-prev", function (e) {
|
||||
let id = $(this).attr("file_id");
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
let curr = $(`.file-preview[file_id='${id}']`)
|
||||
$("#viewer").attr("src", "/files/" + id);
|
||||
$("#view-prev").attr("file_id", curr.prev(":visible").attr("file_id"));
|
||||
$("#view-next").attr("file_id", curr.next(":visible").attr("file_id"));
|
||||
$(".viewer-wrapper").css("display", "");
|
||||
});
|
||||
|
||||
$(document).on("click", "#view-close", function (e) {
|
||||
$(".viewer-wrapper").css("display", "none");
|
||||
});
|
||||
Vendored
+2
File diff suppressed because one or more lines are too long
@@ -0,0 +1,18 @@
|
||||
$(window).on("load", function () {
|
||||
$.ajax({
|
||||
url: "/api/get_my_sessions",
|
||||
type: "GET",
|
||||
contentType: "application/json",
|
||||
success: function (resp) {
|
||||
let timezone_offset = new Date().getTimezoneOffset();
|
||||
resp.forEach((session) => {
|
||||
let s_started = beautify_date(session.started);
|
||||
let s_expires = beautify_date(session.expires);
|
||||
$("#sessions-table").append(`<tr><td>${session.user_agent_name}</td><td>${s_started}</td><td>${s_expires === null ? "-" : session.expires}</td><td align="right"><img src="/static/images/icon-terminate.svg" alt="Terminate" class="btn-terminate" session_id="${session.id}"></td></tr>`);
|
||||
});
|
||||
},
|
||||
failure: function (err) {
|
||||
alert(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,89 @@
|
||||
$(document).on("input", "#parent-tags-filter", function (e) {
|
||||
let filter = $(this).val().toLowerCase();
|
||||
let unfiltered = $("#parent-tags-other > .tag-preview");
|
||||
if (filter === "") {
|
||||
unfiltered.css("display", "");
|
||||
return;
|
||||
}
|
||||
unfiltered.each((index, element) => {
|
||||
let current = $(element);
|
||||
if (current.text().toLowerCase().includes(filter)) {
|
||||
current.css("display", "");
|
||||
} else {
|
||||
current.css("display", "none");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", "#parent-tags-other > .tag-preview", function (e) {
|
||||
$("#loader").css("display", "");
|
||||
let tag_id = $(this).attr("tag_id");
|
||||
$.ajax({
|
||||
url: location.pathname + "/parent",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({add: true, tag_id: $(this).attr("tag_id")}),
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
$("#loader").css("display", "none");
|
||||
if (resp.status) {
|
||||
$(`#parent-tags-other > .tag-preview[tag_id='${tag_id}']`).css("display", "none");
|
||||
$(`#parent-tags-selected > .tag-preview[tag_id='${tag_id}']`).css("display", "");
|
||||
} else {
|
||||
alert(resp.error);
|
||||
}
|
||||
},
|
||||
failure: function (err) {
|
||||
$("#loader").css("display", "none");
|
||||
alert(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", "#parent-tags-selected > .tag-preview", function (e) {
|
||||
$("#loader").css("display", "");
|
||||
let tag_id = $(this).attr("tag_id");
|
||||
$.ajax({
|
||||
url: location.pathname + "/parent",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({add: false, tag_id: $(this).attr("tag_id")}),
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
$("#loader").css("display", "none");
|
||||
if (resp.status) {
|
||||
$(`#parent-tags-selected > .tag-preview[tag_id='${tag_id}']`).css("display", "none");
|
||||
$(`#parent-tags-other > .tag-preview[tag_id='${tag_id}']`).css("display", "");
|
||||
} else {
|
||||
alert(resp.error);
|
||||
}
|
||||
},
|
||||
failure: function (err) {
|
||||
$("#loader").css("display", "none");
|
||||
alert(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("submit", "#object-edit", function (e) {
|
||||
e.preventDefault();
|
||||
$("#loader").css("display", "");
|
||||
$.ajax({
|
||||
url: location.pathname + "/edit",
|
||||
type: "POST",
|
||||
data: $(this).serialize(),
|
||||
dataType: "json",
|
||||
success: function (resp) {
|
||||
$("#loader").css("display", "none");
|
||||
if (resp.status) {
|
||||
location.href = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
|
||||
} else {
|
||||
alert(resp.error);
|
||||
}
|
||||
},
|
||||
failure: function (err) {
|
||||
$("#loader").css("display", "none");
|
||||
alert(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user