close #71; fix bugs

This commit is contained in:
Henrique Dias
2016-06-07 18:15:55 +01:00
parent acc4c92b15
commit 4cd72ca58d
11 changed files with 38 additions and 32 deletions

View File

@@ -1,10 +1,14 @@
var basePath = "/";
$(document).ready(function() {
basePath += window.location.pathname.split('/')[0];
// Log out the user sending bad credentials to the server
$("#logout").click(function(event) {
event.preventDefault();
$.ajax({
type: "GET",
url: "/admin",
url: basePath + "",
async: false,
username: "username",
password: "password",

View File

@@ -247,7 +247,7 @@ $(document).on('page:browse', function() {
}
if (filename.substring(0, 1) != "/") {
filename = window.location.pathname.replace("/admin/browse/", "") + '/' + filename;
filename = window.location.pathname.replace(basePath + "/browse/", "") + '/' + filename;
}
var content = {
@@ -323,7 +323,7 @@ $(document).on('page:browse', function() {
}
var request = new XMLHttpRequest();
request.open("POST", "/admin/git");
request.open("POST", basePath + "/git");
request.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
request.send(JSON.stringify({
command: value

View File

@@ -103,6 +103,8 @@ $(document).on('page:editor', function() {
regenerate: button.data("regenerate")
}
console.log(JSON.stringify(data));
var request = new XMLHttpRequest();
request.open("POST", window.location);
request.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
@@ -155,7 +157,6 @@ $(document).on('page:editor', function() {
input = input.replace(/\[/, '\\[');
input = input.replace(/\]/, '\\]');
block.append('<div id="' + newID + '-' + $('#' + input + ' > div').length + '" data-type="array-item"><input name="' + newID + ':auto" id="' + newID + '"></input><span class="actions"> <button class="delete">&#8722;</button></span></div></div>');
console.log('New array item added.');
}
// Main add button, after all blocks
@@ -241,8 +242,6 @@ $(document).on('page:editor', function() {
template = template.replace("${type}", type);
newItem.after(template);
newItem.remove();
console.log('"' + blockID + '" block of type "' + type + '" added.');
}
return false;
@@ -260,7 +259,6 @@ $(document).on('page:editor', function() {
name = button.parent().parent().attr("for") || button.parent().parent().attr("id") || button.parent().parent().parent().attr("id");
name = name.replace(/\[/, '\\[');
name = name.replace(/\]/, '\\]');
console.log(name)
$('label[for="' + name + '"]').fadeOut().remove();
$('#' + name).fadeOut().remove();