Skip to content
This repository has been archived by the owner on Nov 12, 2019. It is now read-only.

Commit

Permalink
Merge pull request #127 from yjlintw/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
yjlintw authored Jul 24, 2017
2 parents c6419f4 + 18cd2c2 commit 5839de5
Show file tree
Hide file tree
Showing 19 changed files with 95 additions and 35 deletions.
7 changes: 6 additions & 1 deletion assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ h2 {
display: block;
border-bottom: 0;
flex-basis: auto; }
.sidebar .func-area .setting:not(:last-child) {
.sidebar .func-area .setting:first-child {
border-top: 0; }
.sidebar .func-area .setting:hover {
color: #857af8;
Expand All @@ -384,6 +384,8 @@ h2 {
@media only screen and (max-width: 768px) {
.sidebar .func-area .setting {
display: none; } }
.sidebar .func-area .setting.loading {
border: 0; }

/* SEARCH VIEW */
@media only screen and (max-width: 768px) {
Expand Down Expand Up @@ -956,3 +958,6 @@ h2 {
padding: 15px 0 0; }
#about-view .app-info .update-btn {
margin: 0 0 30px; }

#about-view .checkbox:hover {
color: #fff; }
8 changes: 7 additions & 1 deletion assets/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ h2 {
border-bottom: 0;
flex-basis: auto;

&:not(:last-child) {
&:first-child {
border-top: 0;
}

Expand All @@ -503,6 +503,9 @@ h2 {
@media #{$info-mobile} {
display: none;
}
&.loading {
border: 0;
}
}
}
}
Expand Down Expand Up @@ -1309,5 +1312,8 @@ h2 {
}

}
.checkbox:hover {
color: #fff;
}

}
12 changes: 9 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ const url = require('url');
const settings = require('electron-settings');
const log = require('electron-log');
const {autoUpdater} = require("electron-updater");
const EA = require("electron-analytics");
const ipc = electron.ipcMain;
EA.init("Bkles-YA1-");

require('electron-debug')({showDevTools: false});

// Logging
autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = "info";
// autoUpdater.autoDownload = false;
autoUpdater.allowPrerelease = false;
// autoUpdater.allowPrerelease = false;
log.info('App Starting');

let manualupdate = false;
Expand Down Expand Up @@ -51,6 +49,11 @@ function createWindow () {
}

}
if (settings.has("system.update")) {
autoUpdater.allowPrerelease = settings.get("system.update.allowbeta")
} else {
autoUpdater.allowPrerelease = false
}
win = new BrowserWindow({
width: w,
height: h,
Expand Down Expand Up @@ -200,5 +203,8 @@ ipc.on('comic-update', function(event, count) {
app.setBadgeCount(count);
})

ipc.on('update-beta', function(event, cont) {
autoUpdater.allowPrerelease = true;
})
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "comic-reader",
"productName": "Comic Reader",
"author": "Team Comic Reader",
"version": "0.1.53",
"version": "0.1.58-beta",
"description": "A quicker, smoother and cooler reading experience. The best way to read comics.",
"main": "main.js",
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion renderer-process/load-after.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ $(document).ready(function() {
subscriber.checkUpdate();
// console.log(scheduledTask);
if (!scheduledTask) {
scheduledTask = schedule.scheduleJob('0 10 5,11,17,23 * * *', function(){
scheduledTask = schedule.scheduleJob('25 * * * *', function(){
// console.log("schedule update");
subscriber.checkUpdate();
});
Expand Down
5 changes: 5 additions & 0 deletions renderer-process/parsers/8comic.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ function grabChapters(titlekey, link, callback) {
* @param see npm request module
*/
function onChapterGrabbed(error, response, body) {
if (error) {
console.error("8comic: " + error);
this.callback(null, null);
return;
}
let hostpath = response.request.host;
let tmp = $("#content", "<div>" + body + "</div>").find('table tr:nth-child(n+3):nth-last-child(n+1) td');
let result = [];
Expand Down
5 changes: 5 additions & 0 deletions renderer-process/parsers/dm5.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ function grabChapters(titlekey, link, callback) {
* @param see npm request module
*/
function onChapterGrabbed(error, response, body) {
if (error) {
console.error("dm5: " + error);
this.callback(null, null);
return;
}
// let hostpath = response.request.host;
let tmp = $("<div>" + body + "</div>").find('[id^=cbc] li a');
let result = [];
Expand Down
5 changes: 5 additions & 0 deletions renderer-process/parsers/readcomicbooksonline.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ function grabChapters(titlekey, link, callback) {
* @param see npm request module
*/
function onChapterGrabbed(error, response, body) {
if (error) {
console.error("rco: " + error);
this.callback([], "");
return;
}
let hostpath = response.request.host;
let tmp = $("#chapterlist", "<div>" + body + "</div>").find(".chapter");
let comic_title = $("#content-wrap", "<div>" + body + "</div>").find(".page-title").text();
Expand Down
5 changes: 5 additions & 0 deletions renderer-process/parsers/sfacg.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ function grabChapters(titlekey, link, callback) {
* @param see npm request module
*/
function onChapterGrabbed(error, response, body) {
if (error) {
console.error("sfacg: " + error);
this.callback(null, null);
return;
}
let hostpath = response.request.host;
let tmp = $("table:nth-of-type(9)", "<div>" + body + "</div>").find("ul.serialise_list.Blue_link2");
let result = [];
Expand Down
11 changes: 11 additions & 0 deletions renderer-process/viewcontrollers/about-viewcontroller.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// 3rd party library
let settings = require('electron-settings');

const ipc = require('electron').ipcRenderer;
let pjson = require('../../package.json');
const {shell} = require('electron');
Expand All @@ -9,6 +12,12 @@ function lateInit() {
}
);

$("#beta-checkbox").click(function(e) {
console.log(this.checked)
settings.set("system.update.allowbeta", this.checked);
ipc.send("update-beta", this.checked)
})

$(document.getElementById("about-view")).find('.other-info .github-link').click(function(e) {
e.stopPropagation();
shell.openExternal('https://github.com/yjlintw/comic-reader');
Expand All @@ -22,6 +31,8 @@ function lateInit() {
about_view.find(".app-name").text(pjson.productName)
about_view.find(".description").text(pjson.description);
about_view.find(".version").text(pjson.version);

$("#beta-checkbox").prop("checked", settings.get("system.update.allowbeta"));
}

$(document).ready(lateInit);
3 changes: 0 additions & 3 deletions renderer-process/viewcontrollers/favorite-viewcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* ./subscriber.js
*/
const util = require('../util');
const EA = require('electron-analytics');
let fs = require('fs');

/**
Expand Down Expand Up @@ -99,13 +98,11 @@ function createFavEntry(link, titlekey, imguri, title, host, lastread, newest)
view.attr("host", host);

view.find(".subscribe-btn").click(function(e){
EA.send("MOUSE_CLICKED_FAVORITE_SUBSCRIBE");
e.stopPropagation();
unsubscribeFunc(host, titlekey);
});

view.click(function(e){
EA.send("MOUSE_CLICKED_FAVORITE_ENTRY");
let sel = util.getSelected().toString();
if (sel === '') {
selectComicFunc(host, link, title, titlekey, imguri);
Expand Down
13 changes: 0 additions & 13 deletions renderer-process/viewcontrollers/read-viewcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* ../sections/page.html,
* ./comic-parser.js
*/
const EA = require('electron-analytics');
let fs = require('fs');

/**
Expand Down Expand Up @@ -255,7 +254,6 @@ function lateInit() {
});

$("#comic-header .subscribe-btn").click(function(e) {
EA.send("MOUSE_CLICKED_READVIEW_SUBSCRIBE");
e.stopPropagation();
subscribeFunc(current_host, current_titlekey, current_title, current_link, current_imguri);
});
Expand All @@ -265,12 +263,10 @@ function lateInit() {
});

$(".chapToggle").click(function(e) {
EA.send("MOUSE_CLICKED_READVIEW_CHAP_TOGGLE");
$('.middle-panel, #read-area, .toggleTag').addClass("active");
$('.sidebar').addClass("active");
});
$(".toggleTag").click(function(e) {
EA.send("MOUSE_CLICKED_READVIEW_TOGGLE_TAG");
$('.sidebar').removeClass("active");
$('.middle-panel, #read-area, .toggleTag').removeClass("active");

Expand Down Expand Up @@ -328,7 +324,6 @@ function createChapterEntry(ch_group, ch_key, ch_name, ch_link, domid, index) {

view.html(ch_name);
view.click(function(){
EA.send("MOUSE_CLICKED_READVIEW_CHAPTER_ENTRY");
if ($("#comic-header").css("top") == "85px") {
// toggle chapter selector
toggleChapterSelector();
Expand Down Expand Up @@ -357,7 +352,6 @@ function createComicPage(imguri, id, idx) {
view.find("img").attr("src", imguri);

view.find('.zoom-btn').click(function() {
EA.send("MOUSE_CLICKED_READVIEW_ZOOM");
view.zoom({
on:'click',
magnify: '1.5',
Expand All @@ -371,7 +365,6 @@ function createComicPage(imguri, id, idx) {

});
view.find("img").click(function() {
EA.send("MOUSE_CLICKED_READVIEW_IMAGE_CLICK");
current_page_idx = idx;
nextPic();
});
Expand Down Expand Up @@ -423,26 +416,20 @@ function onKeydown(e) {
if (!$('#read-view').hasClass('is-hidden')) {
switch(e.which) {
case 33: // pageup
EA.send("KEYDOWN_READVIEW_PAGE_UP");
case 37: // left
EA.send("KEYDOWN_READVIEW_LEFT");
prevChapter();
break;

case 38: // up
EA.send("KEYDOWN_READVIEW_UP");
prevPic();
break;

case 34: // pagedown
EA.send("KEYDOWN_READVIEW_PAGE_DOWN");
case 39: // right
EA.send("KEYDOWN_READVIEW_RIGHT");
nextChapter();
break;

case 40: // down
EA.send("KEYDOWN_READVIEW_DOWN");
nextPic();
break;

Expand Down
6 changes: 0 additions & 6 deletions renderer-process/viewcontrollers/search-viewcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/
const util = require('../util');
const values = require('../models/values');
const EA = require("electron-analytics");
let fs = require('fs');

/**
Expand Down Expand Up @@ -59,15 +58,13 @@ function createResultView(link, titlekey, imguri, title, host, updateinfo, descr
view.attr("host", host);

view.click(function() {
EA.send("MOUSE_CLICKED_SEARCH_ENTRY");
let sel = util.getSelected();
if (sel === '') {
selectComicFunc(host, link, title, titlekey, imguri);
}
})

view.find(".subscribe-btn").click(function(e) {
EA.send("MOUSE_CLICKED_SEARCH_SUBSCRIBE");
e.stopPropagation();
subscribeFunc(host, titlekey, title, link, imguri);
});
Expand Down Expand Up @@ -184,7 +181,6 @@ function lateInit() {
// SearchAnimate

$("#search-btn").click(function() {
EA.send("MOUSE_CLICKED_SEARCH_SEARCH_BTN");
$('#search-header h2').addClass('active');
$('#search-results').addClass('active');
});
Expand All @@ -193,7 +189,6 @@ function lateInit() {
$('#search-input').keypress(function(e){
if(e.keyCode == 13)
{
EA.send("KEYDOWN_SEARCH_ENTER");
$(this).trigger("enterKey");
$('#search-header h2').addClass('active');
$('#search-results').addClass('active');
Expand All @@ -212,7 +207,6 @@ function lateInit() {
view.attr('host', key);
view.append('<button class="delete is-small"></button>');
view.click(function () {
EA.send("MOUSE_CLICKED_SEARCH_FILTER");
let host = $(this).attr('host');
let activate = $(this).hasClass('active');
console.log(activate);
Expand Down
2 changes: 0 additions & 2 deletions renderer-process/viewcontrollers/translate-viewcontroller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
let fs = require("fs");
const EA = require('electron-analytics');

function read(f) {
return fs.readFileSync(f).toString();
Expand Down Expand Up @@ -38,7 +37,6 @@ $(document).ready(function () {
//chinese convert
let zhconvert = document.getElementById("zh-convert");
zhconvert.onclick = function () {
EA.send("MOUSE_CLICKED_TRANSLATE");
if (zhconvert.dataset.zh == "tw") {
to_traditional_chinese = false;
setTimeout(function () { $('.convert span').toggleClass('icon-zhtw icon-zhcn'); }, 250);
Expand Down
Loading

0 comments on commit 5839de5

Please sign in to comment.