mirror of
https://github.com/janeczku/calibre-web
synced 2025-10-28 22:07:41 +00:00
Code cosmetics
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
/**
|
||||
* Created by SpeedProg on 05.04.2015.
|
||||
*/
|
||||
/* global Bloodhound */
|
||||
|
||||
|
||||
/*
|
||||
Takes a prefix, query typeahead callback, Bloodhound typeahead adapter
|
||||
@@ -33,38 +35,6 @@ var authors = new Bloodhound({
|
||||
}
|
||||
});
|
||||
|
||||
function authors_source(query, cb) {
|
||||
var bhAdapter = authors.ttAdapter();
|
||||
|
||||
var tokens = query.split("&");
|
||||
var current_author = tokens[tokens.length-1].trim();
|
||||
|
||||
tokens.splice(tokens.length-1, 1); // remove last element
|
||||
var prefix = "";
|
||||
for (var i = 0; i < tokens.length; i++) {
|
||||
var author = tokens[i].trim();
|
||||
prefix += author + " & ";
|
||||
}
|
||||
|
||||
prefixed_source(prefix, current_author, cb, bhAdapter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
var promise = authors.initialize();
|
||||
promise.done(function(){
|
||||
$("#bookAuthor").typeahead(
|
||||
{
|
||||
highlight: true, minLength: 1,
|
||||
hint: true
|
||||
}, {
|
||||
name: "authors",
|
||||
displayKey: "name",
|
||||
source: authors_source
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
var series = new Bloodhound({
|
||||
name: "series",
|
||||
datumTokenizer: function(datum) {
|
||||
@@ -80,19 +50,7 @@ var series = new Bloodhound({
|
||||
}
|
||||
}
|
||||
});
|
||||
var promise = series.initialize();
|
||||
promise.done(function(){
|
||||
$("#series").typeahead(
|
||||
{
|
||||
highlight: true, minLength: 0,
|
||||
hint: true
|
||||
}, {
|
||||
name: "series",
|
||||
displayKey: "name",
|
||||
source: series.ttAdapter()
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
|
||||
var tags = new Bloodhound({
|
||||
name: "tags",
|
||||
@@ -109,36 +67,6 @@ var tags = new Bloodhound({
|
||||
}
|
||||
});
|
||||
|
||||
function tag_source(query, cb) {
|
||||
var bhAdapter = tags.ttAdapter();
|
||||
|
||||
var tokens = query.split(",");
|
||||
var current_tag = tokens[tokens.length-1].trim();
|
||||
|
||||
tokens.splice(tokens.length-1, 1); // remove last element
|
||||
var prefix = "";
|
||||
for (var i = 0; i < tokens.length; i++) {
|
||||
var tag = tokens[i].trim();
|
||||
prefix += tag + ", ";
|
||||
}
|
||||
|
||||
prefixed_source(prefix, current_tag, cb, bhAdapter);
|
||||
}
|
||||
|
||||
var promise = tags.initialize();
|
||||
promise.done(function(){
|
||||
$("#tags").typeahead(
|
||||
{
|
||||
highlight: true, minLength: 0,
|
||||
hint: true
|
||||
}, {
|
||||
name: "tags",
|
||||
displayKey: "name",
|
||||
source: tag_source
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
var languages = new Bloodhound({
|
||||
name: "languages",
|
||||
datumTokenizer: function(datum) {
|
||||
@@ -156,24 +84,72 @@ var languages = new Bloodhound({
|
||||
}
|
||||
});
|
||||
|
||||
function language_source(query, cb) {
|
||||
var bhAdapter = languages.ttAdapter();
|
||||
function sourceSplit(query, cb, split, source) {
|
||||
var bhAdapter = source.ttAdapter();
|
||||
|
||||
var tokens = query.split(",");
|
||||
var currentLanguage = tokens[tokens.length-1].trim();
|
||||
var tokens = query.split(split);
|
||||
var currentSource = tokens[tokens.length-1].trim();
|
||||
|
||||
tokens.splice(tokens.length-1, 1); // remove last element
|
||||
var prefix = "";
|
||||
for (var i = 0; i < tokens.length; i++) {
|
||||
var tag = tokens[i].trim();
|
||||
prefix += tag + ", ";
|
||||
var newSplit;
|
||||
if (split === "&"){
|
||||
newSplit = " " + split + " ";
|
||||
}else{
|
||||
newSplit = split + " ";
|
||||
}
|
||||
|
||||
prefixed_source(prefix, currentLanguage, cb, bhAdapter);
|
||||
for (var i = 0; i < tokens.length; i++) {
|
||||
prefix += tokens[i].trim() + newSplit;
|
||||
}
|
||||
prefixed_source(prefix, currentSource, cb, bhAdapter);
|
||||
}
|
||||
|
||||
var promise = languages.initialize();
|
||||
promise.done(function(){
|
||||
var promiseAuthors = authors.initialize();
|
||||
promiseAuthors.done(function(){
|
||||
$("#bookAuthor").typeahead(
|
||||
{
|
||||
highlight: true, minLength: 1,
|
||||
hint: true
|
||||
}, {
|
||||
name: "authors",
|
||||
displayKey: "name",
|
||||
source: function(query, cb){
|
||||
return sourceSplit(query, cb, "&", authors); //sourceSplit //("&")
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var promiseSeries = series.initialize();
|
||||
promiseSeries.done(function(){
|
||||
$("#series").typeahead(
|
||||
{
|
||||
highlight: true, minLength: 0,
|
||||
hint: true
|
||||
}, {
|
||||
name: "series",
|
||||
displayKey: "name",
|
||||
source: series.ttAdapter()
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
var promiseTags = tags.initialize();
|
||||
promiseTags.done(function(){
|
||||
$("#tags").typeahead(
|
||||
{
|
||||
highlight: true, minLength: 0,
|
||||
hint: true
|
||||
}, {
|
||||
name: "tags",
|
||||
displayKey: "name",
|
||||
source: function(query, cb){
|
||||
return sourceSplit(query, cb, ",", tags);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var promiseLanguages = languages.initialize();
|
||||
promiseLanguages.done(function(){
|
||||
$("#languages").typeahead(
|
||||
{
|
||||
highlight: true, minLength: 0,
|
||||
@@ -181,10 +157,11 @@ var promise = languages.initialize();
|
||||
}, {
|
||||
name: "languages",
|
||||
displayKey: "name",
|
||||
source: language_source
|
||||
}
|
||||
)
|
||||
});
|
||||
source: function(query, cb){
|
||||
return sourceSplit(query, cb, ",", languages); //(",")
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("form").on("change input typeahead:selected", function(data){
|
||||
var form = $("form").serialize();
|
||||
|
||||
@@ -86,42 +86,42 @@ $(function() {
|
||||
updateTimerID=setInterval(updateTimer, 2000);}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function restartTimer() {
|
||||
$("#spinner").hide();
|
||||
$("#RestartDialog").modal("hide");
|
||||
}
|
||||
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){
|
||||
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");
|
||||
}
|
||||
},
|
||||
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
|
||||
},
|
||||
timeout:2000
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$(window).resize(function(event) {
|
||||
$(".discover .row").isotope("reLayout");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$(window).resize(function(event) {
|
||||
$(".discover .row").isotope("reLayout");
|
||||
});
|
||||
});
|
||||
@@ -1,3 +1,5 @@
|
||||
/* global Sortable,sortTrue */
|
||||
|
||||
var sortable = Sortable.create(sortTrue, {
|
||||
group: "sorting",
|
||||
sort: true
|
||||
|
||||
Reference in New Issue
Block a user