Skip to content

Commit

Permalink
Merge branch 'release/0.5.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyvion committed Apr 8, 2017
2 parents 5df9507 + aa3bd9a commit 8f3b235
Show file tree
Hide file tree
Showing 26 changed files with 804 additions and 66 deletions.
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"futurehostile": true,
"globals": {
"angular": true,
"GM_info": true,
"GM_xmlhttpRequest": true,
"GM_getValue": true,
"GM_setValue": true,
Expand Down
5 changes: 4 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,12 @@ module.exports = function (grunt) {
'assets/generated/addItem.html': 'assets/templates/addItem.html',
'assets/generated/setTitle.html': 'assets/templates/setTitle.html',
'assets/generated/setTagline.html': 'assets/templates/setTagline.html',
'assets/generated/setPublishDate.html': 'assets/templates/setPublishDate.html',
'assets/generated/donut.html': 'assets/templates/donut.html',
'assets/generated/ribbon.html': 'assets/templates/ribbon.html',
'assets/generated/itemDetails.html': 'assets/templates/itemDetails.html',
'assets/generated/comicNav.html': 'assets/templates/comicNav.html'
'assets/generated/comicNav.html': 'assets/templates/comicNav.html',
'assets/generated/changeLog.html': 'assets/templates/changeLog.html'
}
}
}
Expand Down
14 changes: 11 additions & 3 deletions assets/js/constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 Alexander Krivács Schrøder <[email protected]>
* Copyright (C) 2016, 2017 Alexander Krivács Schrøder <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -27,8 +27,8 @@ var constants;

// Set this to true when working against your local test server.
// NEVER CHECK THIS FILE IN WITH developmentMode = true!
var developmentMode = false;
if (developmentMode) {
constants.developmentMode = false;
if (constants.developmentMode) {
constants.baseUrl =
'http://localhost/questionablecontentextensions/web/';
constants.webServiceBaseUrl = constants.baseUrl + 'app_dev.php/';
Expand All @@ -42,6 +42,7 @@ var constants;
constants.removeItemFromComicUrl = constants.comicDataUrl + 'removeitem';
constants.setComicTitleUrl = constants.comicDataUrl + 'settitle';
constants.setComicTaglineUrl = constants.comicDataUrl + 'settagline';
constants.setPublishDateUrl = constants.comicDataUrl + 'setpublishdate';
constants.setGuestComicUrl = constants.comicDataUrl + 'setguest';
constants.setNonCanonUrl = constants.comicDataUrl + 'setnoncanon';

Expand All @@ -59,4 +60,11 @@ var constants;
constants.comicdataLoadedEvent = 'comicdata-loaded';
constants.comicdataErrorEvent = 'comicdata-error';
constants.itemsChangedEvent = 'items-changed';

constants.messages = {
maintenance: 'The Questionable Extensions' +
' server is currently undergoing maintenance.' +
' Normal operation should resume within a' +
' few minutes.'
};
})(constants || (constants = {}));
17 changes: 16 additions & 1 deletion assets/js/dom-operations.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 Alexander Krivács Schrøder <[email protected]>
* Copyright (C) 2016, 2017 Alexander Krivács Schrøder <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -22,10 +22,13 @@ var qcExt;
(function(qcExt) {
'use strict';

// Add our modal windows
$('body').prepend('<qc-settings></qc-settings>');
$('body').prepend('<qc-edit-comic-data></qc-edit-comic-data>');
$('body').prepend('<qc-item-details></qc-item-details>');
$('body').prepend('<qc-change-log></qc-change-log>');

// Take control over the page's title
$('title').replaceWith('<title ng-controller="titleController as t">' +
'{{t.title}}</title>');

Expand Down Expand Up @@ -85,6 +88,9 @@ var qcExt;
comicImg.attr('ng-click', 'c.next($event)');
comicImg.attr('on-error', 'c.comicService.canFallback() ' +
'&& c.comicService.tryFallback()');

// #comicDirective.attr('id', 'comic-anchor');
comicDirective.append($('<qc-ribbon></qc-ribbon>'));

var comicImage = comicImg.get(0);
var comicLinkUrl = comicImage.src;
Expand All @@ -110,6 +116,15 @@ var qcExt;

$('body #comicnav')
.replaceWith('<qc-nav random-comic="randomComic"></qc-nav>');

if ($('#news, #newspost').prev().prop('tagName') === 'QC-NAV') {
// There's no date section: Insert our own
$('#news, #newspost').before('<qc-date></qc-date>');
} else {
// There's a date section: Replace with our own
$('#news, #newspost').prev().replaceWith('<qc-date></qc-date>');
}

$('#news, #newspost').replaceWith('<qc-news></qc-news>');

// $('#side').prepend('<qc-extra></qc-extra>');
Expand Down
6 changes: 5 additions & 1 deletion assets/js/module.decorateHttpService.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ var qcExt;
GM_xmlhttpRequest({
method: 'GET',
url: url,
headers: {
Accept: APPLICATION_JSON
},
onload: function(gmResponse) {
var headers = getHeaderFunction(
gmResponse.responseHeaders
Expand Down Expand Up @@ -154,7 +157,8 @@ var qcExt;
url: url,
data: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
'Content-Type': APPLICATION_JSON,
Accept: APPLICATION_JSON
},
onload: function(gmResponse) {
var headers = getHeaderFunction(
Expand Down
27 changes: 24 additions & 3 deletions assets/js/qc-ext-comicService.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 Alexander Krivács Schrøder <[email protected]>
* Copyright (C) 2016, 2017 Alexander Krivács Schrøder <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -69,7 +69,12 @@ var qcExt;
});

function onErrorLog(response) {
messageReportingService.reportError(response.data);
if (response.status !== 503) {
messageReportingService.reportError(response.data);
} else {
messageReportingService.reportError(
constants.messages.maintenance);
}
return response;
}

Expand Down Expand Up @@ -103,8 +108,13 @@ var qcExt;

$http.get(comicDataUrl)
.then(function(response) {
if (response.status === 503) {
comicDataErrorEvent.notify(response);
return;
}
if (response.status !== 200) {
onErrorLog(response);
comicDataErrorEvent.notify(response);
return;
}

Expand Down Expand Up @@ -158,7 +168,7 @@ var qcExt;
comicDataLoadedEvent.notify(self.comicData);
}, function(errorResponse) {
onErrorLog(errorResponse);
comicDataErrorEvent.notify(errorResponse.data);
comicDataErrorEvent.notify(errorResponse);
});
};

Expand Down Expand Up @@ -211,6 +221,17 @@ var qcExt;
.then(onSuccessRefreshElseErrorLog, onErrorLog);
};

this.setPublishDate = function(publishDate, isAccurate) {
var data = {
token: qcExt.settings.editModeToken,
comic: self.comic,
publishDate: publishDate,
isAccuratePublishDate: isAccurate
};
return $http.post(constants.setPublishDateUrl, data)
.then(onSuccessRefreshElseErrorLog, onErrorLog);
};

this.setGuestComic = function(value) {
var data = {
token: qcExt.settings.editModeToken,
Expand Down
19 changes: 18 additions & 1 deletion assets/js/qc-ext-messageReportingService.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ var qcExt;
var messageQueue = [];
var isProcessing = false;

function escapeHtml(text) {
return text.replace(/[\"&'\/<>]/g, function(a) {
return {
'"': '&quot;',
'&': '&amp;',
'\'': '&#39;',
'/': '&#47;',
'<': '&lt;',
'>': '&gt;'
}[a];
});
}

function processMessages() {
isProcessing = true;

Expand All @@ -43,7 +56,7 @@ var qcExt;
'id="' + unique + '" ' +
'style="display: none;" ' +
'role="alert">' +
nextMessage.message +
escapeHtml(nextMessage.message) +
'</div>';

$('#messageSeat').append(messageHtml);
Expand Down Expand Up @@ -75,6 +88,10 @@ var qcExt;
reportMessage('danger', message);
};

this.reportWarning = function(message) {
reportMessage('warning', message);
};

$log.debug('END messageReportingService()');
}]);
})(qcExt || (qcExt = {}));
5 changes: 4 additions & 1 deletion assets/js/qc-ext-qcAddItemDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ var qcExt;
function loadItemData() {
$http.get(constants.itemDataUrl)
.then(function(response) {
var itemData = response.data;
var itemData = [];
if (response.status === 200) {
itemData = response.data;
}

itemData.push(addCastItem);
itemData.push(addStorylineItem);
Expand Down
79 changes: 79 additions & 0 deletions assets/js/qc-ext-qcChangeLogDirective.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright (C) 2016, 2017 Alexander Krivács Schrøder <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/* global constants */

var qcExt;

(function(qcExt) {
'use strict';

qcExt.app.directive('qcChangeLog', function() {
return {
restrict: 'E',
replace: true,
scope: {},
controller: ['$log', 'eventFactory', '$scope',
function($log, Event, $scope) {
$log.debug('START qcChangeLog()');

$log.debug();

this.versionUpdated = false;
this.currentVersion = GM_info.script.version;
this.previousVersion = null;
var self = this;

var comicDataLoadedEvent =
new Event(constants.comicdataLoadedEvent);

comicDataLoadedEvent.subscribe($scope,
function() {
if (qcExt.settings.version === undefined) {
// Version is undefined. We're a new user!
$log.debug('qcChangeLog(): Version undefined!');
} else if (qcExt.settings.version !==
self.currentVersion) {
// Version is changed. Script has been updated!
// Show the change log dialog.
self.previousVersion = qcExt.settings.version;
$log.debug('qcChangeLog(): Version different!');
} else {
return;
}
$('#changeLogDialog').modal('show');
self.versionUpdated = true;
});

$('#changeLogDialog').on('hide.bs.modal', function() {
$log.debug('Saving settings...');
qcExt.settings.version = self.currentVersion;
GM_setValue(constants.settingsKey,
JSON.stringify(qcExt.settings));
});

this.close = function() {
$('#changeLogDialog').modal('hide');
};

$log.debug('END qcChangeLog()');
}],
controllerAs: 'clvm',
template: qcExt.variables.angularTemplates.changeLog
};
});
})(qcExt || (qcExt = {}));
7 changes: 7 additions & 0 deletions assets/js/qc-ext-qcComicNavDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ var qcExt;
comicService.gotoComic(self.currentComic);
};

this.keyPress = function(event) {
if (event.keyCode === 13) {
// ENTER key
self.go();
}
};

comicDataLoadedEvent.subscribe($scope,
function(event, comicData) {
self.currentComic = comicData.comic;
Expand Down
Loading

0 comments on commit 8f3b235

Please sign in to comment.