Code cosmetics
This commit is contained in:
+14
-14
@@ -6,8 +6,8 @@
|
||||
Takes a prefix, query typeahead callback, Bloodhound typeahead adapter
|
||||
and returns the completions it gets from the bloodhound engine prefixed.
|
||||
*/
|
||||
function prefixed_source(prefix, query, cb, bh_adapter) {
|
||||
bh_adapter(query, function(retArray){
|
||||
function prefixed_source(prefix, query, cb, bhAdapter) {
|
||||
bhAdapter(query, function(retArray){
|
||||
var matches = [];
|
||||
for (var i = 0; i < retArray.length; i++) {
|
||||
var obj = {name : prefix + retArray[i].name};
|
||||
@@ -23,7 +23,7 @@ function get_path(){
|
||||
}
|
||||
|
||||
var authors = new Bloodhound({
|
||||
name: 'authors',
|
||||
name: "authors",
|
||||
datumTokenizer: function(datum) {
|
||||
return [datum.name];
|
||||
},
|
||||
@@ -34,7 +34,7 @@ var authors = new Bloodhound({
|
||||
});
|
||||
|
||||
function authors_source(query, cb) {
|
||||
var bh_adapter = authors.ttAdapter();
|
||||
var bhAdapter = authors.ttAdapter();
|
||||
|
||||
var tokens = query.split("&");
|
||||
var current_author = tokens[tokens.length-1].trim();
|
||||
@@ -46,7 +46,7 @@ function authors_source(query, cb) {
|
||||
prefix += author + " & ";
|
||||
}
|
||||
|
||||
prefixed_source(prefix, current_author, cb, bh_adapter);
|
||||
prefixed_source(prefix, current_author, cb, bhAdapter);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ var promise = authors.initialize();
|
||||
});
|
||||
|
||||
var series = new Bloodhound({
|
||||
name: 'series',
|
||||
name: "series",
|
||||
datumTokenizer: function(datum) {
|
||||
return [datum.name];
|
||||
},
|
||||
@@ -94,7 +94,7 @@ var promise = series.initialize();
|
||||
});
|
||||
|
||||
var tags = new Bloodhound({
|
||||
name: 'tags',
|
||||
name: "tags",
|
||||
datumTokenizer: function(datum) {
|
||||
return [datum.name];
|
||||
},
|
||||
@@ -104,12 +104,12 @@ var tags = new Bloodhound({
|
||||
return tokens
|
||||
},
|
||||
remote: {
|
||||
url: get_path()+'/get_tags_json?q=%QUERY'
|
||||
url: get_path()+"/get_tags_json?q=%QUERY"
|
||||
}
|
||||
});
|
||||
|
||||
function tag_source(query, cb) {
|
||||
var bh_adapter = tags.ttAdapter();
|
||||
var bhAdapter = tags.ttAdapter();
|
||||
|
||||
var tokens = query.split(",");
|
||||
var current_tag = tokens[tokens.length-1].trim();
|
||||
@@ -121,7 +121,7 @@ function tag_source(query, cb) {
|
||||
prefix += tag + ", ";
|
||||
}
|
||||
|
||||
prefixed_source(prefix, current_tag, cb, bh_adapter);
|
||||
prefixed_source(prefix, current_tag, cb, bhAdapter);
|
||||
}
|
||||
|
||||
var promise = tags.initialize();
|
||||
@@ -138,7 +138,7 @@ var promise = tags.initialize();
|
||||
});
|
||||
|
||||
var languages = new Bloodhound({
|
||||
name: 'languages',
|
||||
name: "languages",
|
||||
datumTokenizer: function(datum) {
|
||||
return [datum.name];
|
||||
},
|
||||
@@ -155,10 +155,10 @@ var languages = new Bloodhound({
|
||||
});
|
||||
|
||||
function language_source(query, cb) {
|
||||
var bh_adapter = languages.ttAdapter();
|
||||
var bhAdapter = languages.ttAdapter();
|
||||
|
||||
var tokens = query.split(",");
|
||||
var current_language = tokens[tokens.length-1].trim();
|
||||
var currentLanguage = tokens[tokens.length-1].trim();
|
||||
|
||||
tokens.splice(tokens.length-1, 1); // remove last element
|
||||
var prefix = "";
|
||||
@@ -167,7 +167,7 @@ function language_source(query, cb) {
|
||||
prefix += tag + ", ";
|
||||
}
|
||||
|
||||
prefixed_source(prefix, current_language, cb, bh_adapter);
|
||||
prefixed_source(prefix, currentLanguage, cb, bhAdapter);
|
||||
}
|
||||
|
||||
var promise = languages.initialize();
|
||||
|
||||
+16
-16
@@ -7,7 +7,7 @@
|
||||
|
||||
$(document).ready(function () {
|
||||
var msg = i18n_msg;
|
||||
var douban = 'https://api.douban.com';
|
||||
var douban = "https://api.douban.com";
|
||||
var db_search = '/v2/book/search';
|
||||
var db_get_info = '/v2/book/';
|
||||
var db_get_info_by_isbn = '/v2/book/isbn/ ';
|
||||
@@ -23,7 +23,7 @@ $(document).ready(function () {
|
||||
var show_flag = 0;
|
||||
String.prototype.replaceAll = function (s1, s2) {
|
||||
return this.replace(new RegExp(s1, "gm"), s2);
|
||||
}
|
||||
};
|
||||
|
||||
gg_search_book = function (title) {
|
||||
title = title.replaceAll(/\s+/, '+');
|
||||
@@ -45,38 +45,38 @@ $(document).ready(function () {
|
||||
|
||||
get_meta = function (source, id) {
|
||||
var meta;
|
||||
if (source == 'google') {;
|
||||
if (source == "google") {
|
||||
meta = gg_results[id];
|
||||
$('#description').val(meta.volumeInfo.description);
|
||||
$('#bookAuthor').val(meta.volumeInfo.authors.join(' & '));
|
||||
$('#book_title').val(meta.volumeInfo.title);
|
||||
$("#description").val(meta.volumeInfo.description);
|
||||
$("#bookAuthor").val(meta.volumeInfo.authors.join(' & '));
|
||||
$("#book_title").val(meta.volumeInfo.title);
|
||||
if (meta.volumeInfo.categories) {
|
||||
var tags = meta.volumeInfo.categories.join(',');
|
||||
$('#tags').val(tags);
|
||||
$("#tags").val(tags);
|
||||
}
|
||||
if (meta.volumeInfo.averageRating) {
|
||||
$('#rating').val(Math.round(meta.volumeInfo.averageRating));
|
||||
$("#rating").val(Math.round(meta.volumeInfo.averageRating));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (source == 'douban') {
|
||||
if (source == "douban") {
|
||||
meta = db_results[id];
|
||||
$('#description').val(meta.summary);
|
||||
$('#bookAuthor').val(meta.author.join(' & '));
|
||||
$('#book_title').val(meta.title);
|
||||
$("#description").val(meta.summary);
|
||||
$("#bookAuthor").val(meta.author.join(' & '));
|
||||
$("#book_title").val(meta.title);
|
||||
var tags = '';
|
||||
for (var i = 0; i < meta.tags.length; i++) {
|
||||
tags = tags + meta.tags[i].title + ',';
|
||||
}
|
||||
$('#tags').val(tags);
|
||||
$('#rating').val(Math.round(meta.rating.average / 2));
|
||||
$("#tags").val(tags);
|
||||
$("#rating").val(Math.round(meta.rating.average / 2));
|
||||
return;
|
||||
}
|
||||
}
|
||||
do_search = function (keyword) {
|
||||
show_flag = 0;
|
||||
$('#meta-info').text(msg.loading);
|
||||
var keyword = $('#keyword').val();
|
||||
$("#meta-info").text(msg.loading);
|
||||
var keyword = $("#keyword").val();
|
||||
if (keyword) {
|
||||
db_search_book(keyword);
|
||||
gg_search_book(keyword);
|
||||
|
||||
+20
-20
@@ -5,11 +5,11 @@ var updateText;
|
||||
$(function() {
|
||||
$('.discover .row').isotope({
|
||||
// options
|
||||
itemSelector : '.book',
|
||||
layoutMode : 'fitRows'
|
||||
itemSelector : ".book",
|
||||
layoutMode : "fitRows"
|
||||
});
|
||||
|
||||
$('.load-more .row').infinitescroll({
|
||||
$(".load-more .row").infinitescroll({
|
||||
debug: false,
|
||||
navSelector : ".pagination",
|
||||
// selector for the paged navigation (it will be hidden)
|
||||
@@ -20,13 +20,13 @@ $(function() {
|
||||
extraScrollPx: 300,
|
||||
// selector for all items you'll retrieve
|
||||
}, function(data){
|
||||
$('.load-more .row').isotope( 'appended', $(data), null );
|
||||
$(".load-more .row").isotope( 'appended', $(data), null );
|
||||
});
|
||||
|
||||
$('#sendbtn').click(function(){
|
||||
var $this = $(this);
|
||||
$this.text('Please wait...');
|
||||
$this.addClass('disabled');
|
||||
$this.text("Please wait...");
|
||||
$this.addClass("disabled");
|
||||
});
|
||||
$("#restart").click(function() {
|
||||
$.ajax({
|
||||
@@ -57,10 +57,10 @@ $(function() {
|
||||
success: function(data) {
|
||||
$("#check_for_update").html(button_text);
|
||||
if (data.status == true) {
|
||||
$("#check_for_update").addClass('hidden');
|
||||
$("#perform_update").removeClass('hidden');
|
||||
$("#update_info").removeClass('hidden');
|
||||
$("#update_info").find('span').html(data.commit);
|
||||
$("#check_for_update").addClass("hidden");
|
||||
$("#perform_update").removeClass("hidden");
|
||||
$("#update_info").removeClass("hidden");
|
||||
$("#update_info").find("span").html(data.commit);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -73,14 +73,14 @@ $(function() {
|
||||
});
|
||||
});
|
||||
$("#perform_update").click(function() {
|
||||
$('#spinner2').show();
|
||||
$("#spinner2").show();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
data: { start: "True"},
|
||||
url: window.location.pathname+"/../../get_updater_status",
|
||||
success: function(data) {
|
||||
updateText=data.text
|
||||
updateText=data.text;
|
||||
$("#UpdateprogressDialog #Updatecontent").html(updateText[data.status]);
|
||||
console.log(data.status);
|
||||
updateTimerID=setInterval(updateTimer, 2000);}
|
||||
@@ -90,8 +90,8 @@ $(function() {
|
||||
|
||||
|
||||
function restartTimer() {
|
||||
$('#spinner').hide();
|
||||
$('#RestartDialog').modal('hide');
|
||||
$("#spinner").hide();
|
||||
$("#RestartDialog").modal("hide");
|
||||
}
|
||||
|
||||
function updateTimer() {
|
||||
@@ -110,13 +110,13 @@ function updateTimer() {
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
console.log('Done');
|
||||
// console.log('Done');
|
||||
clearInterval(updateTimerID);
|
||||
$('#spinner2').hide();
|
||||
$("#spinner2").hide();
|
||||
$("#UpdateprogressDialog #Updatecontent").html(updateText[7]);
|
||||
$('#UpdateprogressDialog #updateFinished').removeClass('hidden');
|
||||
$("#check_for_update").removeClass('hidden');
|
||||
$("#perform_update").addClass('hidden');
|
||||
$("#UpdateprogressDialog #updateFinished").removeClass("hidden");
|
||||
$("#check_for_update").removeClass("hidden");
|
||||
$("#perform_update").addClass("hidden");
|
||||
},
|
||||
timeout:2000
|
||||
});
|
||||
@@ -124,5 +124,5 @@ function updateTimer() {
|
||||
|
||||
|
||||
$(window).resize(function(event) {
|
||||
$('.discover .row').isotope('reLayout');
|
||||
$(".discover .row").isotope("reLayout");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user