From a740491ce651500c75ead81d7760c57195245f13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Kriv=C3=A1cs=20Schr=C3=B8der?= Date: Sat, 15 Apr 2017 19:42:13 +0200 Subject: [PATCH 01/25] Turn off maximum line length code style requirement --- .jscsrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.jscsrc b/.jscsrc index c68fc16..3ffa3ba 100644 --- a/.jscsrc +++ b/.jscsrc @@ -72,13 +72,13 @@ "requireParamDescription": true, "requireReturnDescription": true }, */ - "maximumLineLength": { - "value": 80, + /*"maximumLineLength": { + "value": 0, "tabSize": 4, "allExcept": [ "regex" ] - }, + },*/ "requireAlignedMultilineParams": 0, "requireAnonymousFunctions": { "allExcept": [ From ed76ef3dfd1e9e3d4475910a1173534d067f0978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Kriv=C3=A1cs=20Schr=C3=B8der?= Date: Sat, 15 Apr 2017 20:09:01 +0200 Subject: [PATCH 02/25] =?UTF-8?q?Don't=20reinvent=20the=20wheel=20?= =?UTF-8?q?=E2=80=94=20use=20Angular's=20date=20formatting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also, since the date formatting is now done at the template level rather than on comic data load, changing the 12h/24h time setting doesn't require a full refresh of the comic data in order to reformat. --- Gruntfile.js | 3 +- assets/js/qc-ext-qcDateDirective.js | 69 +++---------------------- assets/js/qc-ext-qcSettingsDirective.js | 2 - assets/templates/changeLog.html | 5 ++ assets/templates/date.html | 23 +++++++++ 5 files changed, 38 insertions(+), 64 deletions(-) create mode 100644 assets/templates/date.html diff --git a/Gruntfile.js b/Gruntfile.js index 67c1e81..6fce414 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -153,7 +153,8 @@ module.exports = function (grunt) { '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/changeLog.html': 'assets/templates/changeLog.html' + 'assets/generated/changeLog.html': 'assets/templates/changeLog.html', + 'assets/generated/date.html': 'assets/templates/date.html' } } } diff --git a/assets/js/qc-ext-qcDateDirective.js b/assets/js/qc-ext-qcDateDirective.js index 7b71717..1c59996 100644 --- a/assets/js/qc-ext-qcDateDirective.js +++ b/assets/js/qc-ext-qcDateDirective.js @@ -47,82 +47,29 @@ var qcExt; this.$apply(fn); } }; - - function formatDate(dateTime) { - var monthNames = [ - 'January', 'February', 'March', - 'April', 'May', 'June', 'July', - 'August', 'September', 'October', - 'November', 'December' - ]; - - var weekDayNames = [ - 'Sunday', 'Monday', 'Tuesday', - 'Wednesday', 'Thursday', 'Friday', - 'Saturday' - ]; - - var dayIndex = dateTime.getDay(); - var date = dateTime.getDate(); - var monthIndex = dateTime.getMonth(); - var year = dateTime.getFullYear(); - - var dateText = weekDayNames[dayIndex] + ', ' + - monthNames[monthIndex] + ' ' + date + ', ' + year; - - var hours = dateTime.getHours(); - var minutes = dateTime.getMinutes(); - - if (minutes < 10) { - minutes = '0' + minutes; - } - - var timeText; - if (qcExt.settings.useCorrectTimeFormat) { - if (hours < 10) { - hours = '0' + hours; - } - timeText = hours + ':' + minutes; - } else { - var meridiem; - if (hours < 12) { - meridiem = 'a.m.'; - } else { - meridiem = 'p.m.'; - } - hours = hours % 12; - if (hours === 0) { - hours = 12; - } - - timeText = hours + ':' + minutes + ' ' + meridiem; - } - - return dateText + ' ' + timeText; - } var self = this; - this.date = ''; + this.settings = qcExt.settings; + this.date = null; + this.approximateDate = false; comicDataLoadingEvent.subscribe($scope, function() { $scope.safeApply(function() { - self.date = ''; + self.date = null; }); }); comicDataLoadedEvent.subscribe($scope, function(event, comicData) { $scope.safeApply(function() { + self.approximateDate = !comicData.isAccuratePublishDate; var publishDate = comicData.publishDate; $log.debug('qcDate(): ', publishDate); if (publishDate !== null && publishDate !== undefined) { var date = new Date(publishDate); - self.date = formatDate(date); - if (!comicData.isAccuratePublishDate) { - self.date += ' (Approximately)'; - } + self.date = date; } else { - self.date = ''; + self.date = null; } }); }); @@ -130,7 +77,7 @@ var qcExt; $log.debug('END qcDate()'); }], controllerAs: 'd', - template: '
{{d.date}}
' + template: qcExt.variables.angularTemplates.date }; }); })(qcExt || (qcExt = {})); diff --git a/assets/js/qc-ext-qcSettingsDirective.js b/assets/js/qc-ext-qcSettingsDirective.js index b6c93d3..e503788 100644 --- a/assets/js/qc-ext-qcSettingsDirective.js +++ b/assets/js/qc-ext-qcSettingsDirective.js @@ -36,8 +36,6 @@ var qcExt; return self.settings.showAllMembers; }, function() { return self.settings.editMode; - }, function() { - return self.settings.useCorrectTimeFormat; }], function() { comicService.refreshComicData(); }); diff --git a/assets/templates/changeLog.html b/assets/templates/changeLog.html index 1c9da41..343b426 100644 --- a/assets/templates/changeLog.html +++ b/assets/templates/changeLog.html @@ -29,6 +29,11 @@

Script updated!

Script installed!

Thank you for installing Questionable Content Extensions!

+

NextVersion NextDate

+ +

0.5.1 April 8, 2017