mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-24 18:47:23 +00:00
Fix #1843 (get path to script via html file and known js file instead of randomly picking last one)
This commit is contained in:
parent
a866dbaa80
commit
1e5af21000
@ -78,10 +78,10 @@ function prefixedSource(prefix, query, cb, bhAdapter) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPath() {
|
/*function getPath() {
|
||||||
var jsFileLocation = $("script[src*=edit_books]").attr("src"); // the js file path
|
var jsFileLocation = $("script[src*=edit_books]").attr("src"); // the js file path
|
||||||
return jsFileLocation.substr(0, jsFileLocation.search("/static/js/edit_books.js")); // the js folder path
|
return jsFileLocation.substr(0, jsFileLocation.search("/static/js/edit_books.js")); // the js folder path
|
||||||
}
|
}*/
|
||||||
|
|
||||||
var authors = new Bloodhound({
|
var authors = new Bloodhound({
|
||||||
name: "authors",
|
name: "authors",
|
||||||
|
@ -15,6 +15,11 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function getPath() {
|
||||||
|
var jsFileLocation = $("script[src*=jquery]").attr("src"); // the js file path
|
||||||
|
return jsFileLocation.substr(0, jsFileLocation.search("/static/js/libs/jquery.min.js")); // the js folder path
|
||||||
|
}
|
||||||
// Generic control/related handler to show/hide fields based on a checkbox' value
|
// Generic control/related handler to show/hide fields based on a checkbox' value
|
||||||
// e.g.
|
// e.g.
|
||||||
// <input type="checkbox" data-control="stuff-to-show">
|
// <input type="checkbox" data-control="stuff-to-show">
|
||||||
@ -110,15 +115,13 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function ConfirmDialog(id, dataValue, yesFn, noFn) {
|
function ConfirmDialog(id, dataValue, yesFn, noFn) {
|
||||||
var pathname = document.getElementsByTagName("script"), src = pathname[pathname.length - 1].src;
|
|
||||||
var path = src.substring(0, src.lastIndexOf("/"));
|
|
||||||
var $confirm = $("#GeneralDeleteModal");
|
var $confirm = $("#GeneralDeleteModal");
|
||||||
// var dataValue= e.data('value'); // target.data('value');
|
// var dataValue= e.data('value'); // target.data('value');
|
||||||
$confirm.modal('show');
|
$confirm.modal('show');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method:"get",
|
method:"get",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
url: path + "/../../ajax/loaddialogtexts/" + id,
|
url: getPath() + "/ajax/loaddialogtexts/" + id,
|
||||||
success: function success(data) {
|
success: function success(data) {
|
||||||
$("#header").html(data.header);
|
$("#header").html(data.header);
|
||||||
$("#text").html(data.main);
|
$("#text").html(data.main);
|
||||||
@ -140,15 +143,13 @@ function ConfirmDialog(id, dataValue, yesFn, noFn) {
|
|||||||
|
|
||||||
$("#delete_confirm").click(function() {
|
$("#delete_confirm").click(function() {
|
||||||
//get data-id attribute of the clicked element
|
//get data-id attribute of the clicked element
|
||||||
var pathname = document.getElementsByTagName("script"), src = pathname[pathname.length - 1].src;
|
|
||||||
var path = src.substring(0, src.lastIndexOf("/"));
|
|
||||||
var deleteId = $(this).data("delete-id");
|
var deleteId = $(this).data("delete-id");
|
||||||
var bookFormat = $(this).data("delete-format");
|
var bookFormat = $(this).data("delete-format");
|
||||||
if (bookFormat) {
|
if (bookFormat) {
|
||||||
window.location.href = path + "/../../delete/" + deleteId + "/" + bookFormat;
|
window.location.href = getPath() + "/delete/" + deleteId + "/" + bookFormat;
|
||||||
} else {
|
} else {
|
||||||
if ($(this).data("delete-format")) {
|
if ($(this).data("delete-format")) {
|
||||||
path = path + "/../../ajax/delete/" + deleteId;
|
path = getPath() + "/ajax/delete/" + deleteId;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method:"get",
|
method:"get",
|
||||||
url: path,
|
url: path,
|
||||||
@ -168,7 +169,7 @@ $("#delete_confirm").click(function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
window.location.href = path + "/../../delete/" + deleteId;
|
window.location.href = getPath() + "/delete/" + deleteId;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,7 +225,7 @@ $(function() {
|
|||||||
function updateTimer() {
|
function updateTimer() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
url: window.location.pathname + "/../../get_updater_status",
|
url: window.location.pathname + "/get_updater_status",
|
||||||
success: function success(data) {
|
success: function success(data) {
|
||||||
// console.log(data.status);
|
// console.log(data.status);
|
||||||
$("#DialogContent").html(updateText[data.status]);
|
$("#DialogContent").html(updateText[data.status]);
|
||||||
@ -484,12 +485,9 @@ $(function() {
|
|||||||
$(this).attr('id'),
|
$(this).attr('id'),
|
||||||
$(this).data('value'),
|
$(this).data('value'),
|
||||||
function (value) {
|
function (value) {
|
||||||
var pathname = document.getElementsByTagName("script");
|
|
||||||
var src = pathname[pathname.length - 1].src;
|
|
||||||
var path = src.substring(0, src.lastIndexOf("/"));
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: path + "/../../kobo_auth/deleteauthtoken/" + value,
|
url: getPath() + "/kobo_auth/deleteauthtoken/" + value,
|
||||||
});
|
});
|
||||||
$("#config_delete_kobo_token").hide();
|
$("#config_delete_kobo_token").hide();
|
||||||
}
|
}
|
||||||
@ -582,12 +580,10 @@ $(function() {
|
|||||||
$("#DialogFinished").addClass("hidden");
|
$("#DialogFinished").addClass("hidden");
|
||||||
$("#DialogContent").html("");
|
$("#DialogContent").html("");
|
||||||
$("#spinner2").show();
|
$("#spinner2").show();
|
||||||
var pathname = document.getElementsByTagName("script"), src = pathname[pathname.length - 1].src;
|
|
||||||
var path = src.substring(0, src.lastIndexOf("/"));
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method:"get",
|
method:"get",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
url: path + "/../../import_ldap_users",
|
url: getPath() + "/import_ldap_users",
|
||||||
success: function success(data) {
|
success: function success(data) {
|
||||||
$("#spinner2").hide();
|
$("#spinner2").hide();
|
||||||
$("#DialogContent").html(data.text);
|
$("#DialogContent").html(data.text);
|
||||||
|
@ -256,13 +256,11 @@ $(function() {
|
|||||||
$("#h4").addClass("hidden");
|
$("#h4").addClass("hidden");
|
||||||
});
|
});
|
||||||
function startTable(type, user_id) {
|
function startTable(type, user_id) {
|
||||||
var pathname = document.getElementsByTagName("script"), src = pathname[pathname.length - 1].src;
|
|
||||||
var path = src.substring(0, src.lastIndexOf("/"));
|
|
||||||
$("#restrict-elements-table").bootstrapTable({
|
$("#restrict-elements-table").bootstrapTable({
|
||||||
formatNoMatches: function () {
|
formatNoMatches: function () {
|
||||||
return "";
|
return "";
|
||||||
},
|
},
|
||||||
url: path + "/../../ajax/listrestriction/" + type + "/" + user_id,
|
url: getPath() + "/ajax/listrestriction/" + type + "/" + user_id,
|
||||||
rowStyle: function(row) {
|
rowStyle: function(row) {
|
||||||
// console.log('Reihe :' + row + " Index :" + index);
|
// console.log('Reihe :' + row + " Index :" + index);
|
||||||
if (row.id.charAt(0) === "a") {
|
if (row.id.charAt(0) === "a") {
|
||||||
@ -276,13 +274,13 @@ $(function() {
|
|||||||
$.ajax ({
|
$.ajax ({
|
||||||
type: "Post",
|
type: "Post",
|
||||||
data: "id=" + row.id + "&type=" + row.type + "&Element=" + encodeURIComponent(row.Element),
|
data: "id=" + row.id + "&type=" + row.type + "&Element=" + encodeURIComponent(row.Element),
|
||||||
url: path + "/../../ajax/deleterestriction/" + type + "/" + user_id,
|
url: getPath() + "/ajax/deleterestriction/" + type + "/" + user_id,
|
||||||
async: true,
|
async: true,
|
||||||
timeout: 900,
|
timeout: 900,
|
||||||
success:function() {
|
success:function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method:"get",
|
method:"get",
|
||||||
url: path + "/../../ajax/listrestriction/" + type + "/" + user_id,
|
url: getPath() + "/ajax/listrestriction/" + type + "/" + user_id,
|
||||||
async: true,
|
async: true,
|
||||||
timeout: 900,
|
timeout: 900,
|
||||||
success:function(data) {
|
success:function(data) {
|
||||||
@ -298,7 +296,7 @@ $(function() {
|
|||||||
$("#restrict-elements-table").removeClass("table-hover");
|
$("#restrict-elements-table").removeClass("table-hover");
|
||||||
$("#restrict-elements-table").on("editable-save.bs.table", function (e, field, row) {
|
$("#restrict-elements-table").on("editable-save.bs.table", function (e, field, row) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: path + "/../../ajax/editrestriction/" + type + "/" + user_id,
|
url: getPath() + "/ajax/editrestriction/" + type + "/" + user_id,
|
||||||
type: "Post",
|
type: "Post",
|
||||||
data: row
|
data: row
|
||||||
});
|
});
|
||||||
@ -306,13 +304,13 @@ $(function() {
|
|||||||
$("[id^=submit_]").click(function() {
|
$("[id^=submit_]").click(function() {
|
||||||
$(this)[0].blur();
|
$(this)[0].blur();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: path + "/../../ajax/addrestriction/" + type + "/" + user_id,
|
url: getPath() + "/ajax/addrestriction/" + type + "/" + user_id,
|
||||||
type: "Post",
|
type: "Post",
|
||||||
data: $(this).closest("form").serialize() + "&" + $(this)[0].name + "=",
|
data: $(this).closest("form").serialize() + "&" + $(this)[0].name + "=",
|
||||||
success: function () {
|
success: function () {
|
||||||
$.ajax ({
|
$.ajax ({
|
||||||
method:"get",
|
method:"get",
|
||||||
url: path + "/../../ajax/listrestriction/" + type + "/" + user_id,
|
url: getPath() + "/ajax/listrestriction/" + type + "/" + user_id,
|
||||||
async: true,
|
async: true,
|
||||||
timeout: 900,
|
timeout: 900,
|
||||||
success:function(data) {
|
success:function(data) {
|
||||||
|
Loading…
Reference in New Issue
Block a user