Code cosmetics
This commit is contained in:
parent
d59be5faf4
commit
8c7a8a954a
|
@ -358,9 +358,11 @@ class Updater(threading.Thread):
|
||||||
def get_update_status(self):
|
def get_update_status(self):
|
||||||
return self.status
|
return self.status
|
||||||
|
|
||||||
|
@classmethod
|
||||||
def file_to_list(self, file):
|
def file_to_list(self, file):
|
||||||
return [x.strip() for x in open(file, 'r') if not x.startswith('#EXT')]
|
return [x.strip() for x in open(file, 'r') if not x.startswith('#EXT')]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
def one_minus_two(self, one, two):
|
def one_minus_two(self, one, two):
|
||||||
return [x for x in one if x not in set(two)]
|
return [x for x in one if x not in set(two)]
|
||||||
|
|
||||||
|
@ -384,6 +386,7 @@ class Updater(threading.Thread):
|
||||||
break
|
break
|
||||||
return list(set(new_delete))
|
return list(set(new_delete))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
def reduce_files(self, remove_items, exclude_items):
|
def reduce_files(self, remove_items, exclude_items):
|
||||||
rf = []
|
rf = []
|
||||||
for item in remove_items:
|
for item in remove_items:
|
||||||
|
@ -391,6 +394,7 @@ class Updater(threading.Thread):
|
||||||
rf.append(item)
|
rf.append(item)
|
||||||
return rf
|
return rf
|
||||||
|
|
||||||
|
@classmethod
|
||||||
def moveallfiles(self, root_src_dir, root_dst_dir):
|
def moveallfiles(self, root_src_dir, root_dst_dir):
|
||||||
change_permissions = True
|
change_permissions = True
|
||||||
if sys.platform == "win32" or sys.platform == "darwin":
|
if sys.platform == "win32" or sys.platform == "darwin":
|
||||||
|
|
|
@ -20,13 +20,13 @@ 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
|
||||||
jsFileLocation = jsFileLocation.replace("/static/js/edit_books.js", ''); // the js folder path
|
jsFileLocation = jsFileLocation.replace("/static/js/edit_books.js", ""); // the js folder path
|
||||||
return jsFileLocation;
|
return jsFileLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
var authors = new Bloodhound({
|
var authors = new Bloodhound({
|
||||||
name: "authors",
|
name: "authors",
|
||||||
datumTokenizer: function(datum) {
|
datumTokenizer(datum) {
|
||||||
return [datum.name];
|
return [datum.name];
|
||||||
},
|
},
|
||||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
|
@ -37,15 +37,15 @@ var authors = new Bloodhound({
|
||||||
|
|
||||||
var series = new Bloodhound({
|
var series = new Bloodhound({
|
||||||
name: "series",
|
name: "series",
|
||||||
datumTokenizer: function(datum) {
|
datumTokenizer(datum) {
|
||||||
return [datum.name];
|
return [datum.name];
|
||||||
},
|
},
|
||||||
queryTokenizer: function(query) {
|
queryTokenizer(query) {
|
||||||
return [query];
|
return [query];
|
||||||
},
|
},
|
||||||
remote: {
|
remote: {
|
||||||
url: getPath()+"/get_series_json?q=",
|
url: getPath()+"/get_series_json?q=",
|
||||||
replace: function(url, query) {
|
replace(url, query) {
|
||||||
return url+encodeURIComponent(query);
|
return url+encodeURIComponent(query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,10 +54,10 @@ var series = new Bloodhound({
|
||||||
|
|
||||||
var tags = new Bloodhound({
|
var tags = new Bloodhound({
|
||||||
name: "tags",
|
name: "tags",
|
||||||
datumTokenizer: function(datum) {
|
datumTokenizer(datum) {
|
||||||
return [datum.name];
|
return [datum.name];
|
||||||
},
|
},
|
||||||
queryTokenizer: function(query) {
|
queryTokenizer(query) {
|
||||||
var tokens = query.split(",");
|
var tokens = query.split(",");
|
||||||
tokens = [tokens[tokens.length-1].trim()];
|
tokens = [tokens[tokens.length-1].trim()];
|
||||||
return tokens;
|
return tokens;
|
||||||
|
@ -69,15 +69,15 @@ var tags = new Bloodhound({
|
||||||
|
|
||||||
var languages = new Bloodhound({
|
var languages = new Bloodhound({
|
||||||
name: "languages",
|
name: "languages",
|
||||||
datumTokenizer: function(datum) {
|
datumTokenizer(datum) {
|
||||||
return [datum.name];
|
return [datum.name];
|
||||||
},
|
},
|
||||||
queryTokenizer: function(query) {
|
queryTokenizer(query) {
|
||||||
return [query];
|
return [query];
|
||||||
},
|
},
|
||||||
remote: {
|
remote: {
|
||||||
url: getPath()+"/get_languages_json?q=",
|
url: getPath()+"/get_languages_json?q=",
|
||||||
replace: function(url, query) {
|
replace(url, query) {
|
||||||
return url+encodeURIComponent(query);
|
return url+encodeURIComponent(query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ var promiseAuthors = authors.initialize();
|
||||||
}, {
|
}, {
|
||||||
name: "authors",
|
name: "authors",
|
||||||
displayKey: "name",
|
displayKey: "name",
|
||||||
source: function(query, cb){
|
source(query, cb){
|
||||||
return sourceSplit(query, cb, "&", authors); //sourceSplit //("&")
|
return sourceSplit(query, cb, "&", authors); //sourceSplit //("&")
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -141,7 +141,7 @@ var promiseTags = tags.initialize();
|
||||||
}, {
|
}, {
|
||||||
name: "tags",
|
name: "tags",
|
||||||
displayKey: "name",
|
displayKey: "name",
|
||||||
source: function(query, cb){
|
source(query, cb){
|
||||||
return sourceSplit(query, cb, ",", tags);
|
return sourceSplit(query, cb, ",", tags);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -156,7 +156,7 @@ var promiseLanguages = languages.initialize();
|
||||||
}, {
|
}, {
|
||||||
name: "languages",
|
name: "languages",
|
||||||
displayKey: "name",
|
displayKey: "name",
|
||||||
source: function(query, cb){
|
source(query, cb){
|
||||||
return sourceSplit(query, cb, ",", languages); //(",")
|
return sourceSplit(query, cb, ",", languages); //(",")
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,6 +3,40 @@ var updateTimerID;
|
||||||
var updateText;
|
var updateText;
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
|
function restartTimer() {
|
||||||
|
$("#spinner").addClass("hidden");
|
||||||
|
$("#RestartDialog").modal("hide");
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateTimer() {
|
||||||
|
$.ajax({
|
||||||
|
dataType: "json",
|
||||||
|
url: window.location.pathname+"/../../get_updater_status",
|
||||||
|
success: function(data) {
|
||||||
|
// console.log(data.status);
|
||||||
|
$("#UpdateprogressDialog #Updatecontent").html(updateText[data.status]);
|
||||||
|
if (data.status >6){
|
||||||
|
clearInterval(updateTimerID);
|
||||||
|
$("#spinner2").hide();
|
||||||
|
$("#UpdateprogressDialog #updateFinished").removeClass("hidden");
|
||||||
|
$("#check_for_update").removeClass("hidden");
|
||||||
|
$("#perform_update").addClass("hidden");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error() {
|
||||||
|
// console.log('Done');
|
||||||
|
clearInterval(updateTimerID);
|
||||||
|
$("#spinner2").hide();
|
||||||
|
$("#UpdateprogressDialog #Updatecontent").html(updateText[7]);
|
||||||
|
$("#UpdateprogressDialog #updateFinished").removeClass("hidden");
|
||||||
|
$("#check_for_update").removeClass("hidden");
|
||||||
|
$("#perform_update").addClass("hidden");
|
||||||
|
},
|
||||||
|
timeout:2000
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$(".discover .row").isotope({
|
$(".discover .row").isotope({
|
||||||
// options
|
// options
|
||||||
itemSelector : ".book",
|
itemSelector : ".book",
|
||||||
|
@ -33,7 +67,7 @@ $(function() {
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
url: window.location.pathname+"/../../shutdown",
|
url: window.location.pathname+"/../../shutdown",
|
||||||
data: {"parameter":0},
|
data: {"parameter":0},
|
||||||
success: function(data) {
|
success(data) {
|
||||||
$("#spinner").show();
|
$("#spinner").show();
|
||||||
displaytext=data.text;
|
displaytext=data.text;
|
||||||
setTimeout(restartTimer, 3000);}
|
setTimeout(restartTimer, 3000);}
|
||||||
|
@ -44,7 +78,7 @@ $(function() {
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
url: window.location.pathname+"/../../shutdown",
|
url: window.location.pathname+"/../../shutdown",
|
||||||
data: {"parameter":1},
|
data: {"parameter":1},
|
||||||
success: function(data) {
|
success(data) {
|
||||||
return alert(data.text);}
|
return alert(data.text);}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -54,7 +88,7 @@ $(function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
url: window.location.pathname+"/../../get_update_status",
|
url: window.location.pathname+"/../../get_update_status",
|
||||||
success: function(data) {
|
success(data) {
|
||||||
$("#check_for_update").html(buttonText);
|
$("#check_for_update").html(buttonText);
|
||||||
if (data.status === true) {
|
if (data.status === true) {
|
||||||
$("#check_for_update").addClass("hidden");
|
$("#check_for_update").addClass("hidden");
|
||||||
|
@ -79,7 +113,7 @@ $(function() {
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: { start: "True"},
|
data: { start: "True"},
|
||||||
url: window.location.pathname+"/../../get_updater_status",
|
url: window.location.pathname+"/../../get_updater_status",
|
||||||
success: function(data) {
|
success(data) {
|
||||||
updateText=data.text;
|
updateText=data.text;
|
||||||
$("#UpdateprogressDialog #Updatecontent").html(updateText[data.status]);
|
$("#UpdateprogressDialog #Updatecontent").html(updateText[data.status]);
|
||||||
// console.log(data.status);
|
// console.log(data.status);
|
||||||
|
@ -87,40 +121,6 @@ $(function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function restartTimer() {
|
|
||||||
$("#spinner").addClass("hidden");
|
|
||||||
$("#RestartDialog").modal("hide");
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateTimer() {
|
|
||||||
$.ajax({
|
|
||||||
dataType: "json",
|
|
||||||
url: window.location.pathname+"/../../get_updater_status",
|
|
||||||
success: function(data) {
|
|
||||||
// console.log(data.status);
|
|
||||||
$("#UpdateprogressDialog #Updatecontent").html(updateText[data.status]);
|
|
||||||
if (data.status >6){
|
|
||||||
clearInterval(updateTimerID);
|
|
||||||
$("#spinner2").hide();
|
|
||||||
$("#UpdateprogressDialog #updateFinished").removeClass("hidden");
|
|
||||||
$("#check_for_update").removeClass("hidden");
|
|
||||||
$("#perform_update").addClass("hidden");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function() {
|
|
||||||
// console.log('Done');
|
|
||||||
clearInterval(updateTimerID);
|
|
||||||
$("#spinner2").hide();
|
|
||||||
$("#UpdateprogressDialog #Updatecontent").html(updateText[7]);
|
|
||||||
$("#UpdateprogressDialog #updateFinished").removeClass("hidden");
|
|
||||||
$("#check_for_update").removeClass("hidden");
|
|
||||||
$("#perform_update").addClass("hidden");
|
|
||||||
},
|
|
||||||
timeout:2000
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$(window).resize(function(event) {
|
$(window).resize(function(event) {
|
||||||
$(".discover .row").isotope("reLayout");
|
$(".discover .row").isotope("reLayout");
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user