diff --git a/.gitignore b/.gitignore index f703c5f..a9e3dfc 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ /nbproject/private /node_modules /.vagrant +/.tmp + diff --git a/.jscsrc b/.jscsrc index c68fc16..d5cba18 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": [ @@ -146,7 +146,7 @@ }, "safeContextKeyword": ["self"], "validateIndentation": "\t", - "validateLineBreaks": "LF", + "validateLineBreaks": null, "validateParameterSeparator": ", ", "validateQuoteMarks": "'" } diff --git a/.jshintrc b/.jshintrc index efcdba3..f24af91 100644 --- a/.jshintrc +++ b/.jshintrc @@ -11,7 +11,8 @@ "GM_xmlhttpRequest": true, "GM_getValue": true, "GM_setValue": true, - "unsafeWindow": true + "unsafeWindow": true, + "GM": true }, "latedef": true, "nocomma": true, diff --git a/.travis.yml b/.travis.yml index 45c926f..53b5036 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - "4.5.0" + - "4.7.0" before_install: - npm install -g grunt-cli - rvm install 2.4.1 diff --git a/Gruntfile.js b/Gruntfile.js index 67c1e81..7813203 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -86,6 +86,7 @@ module.exports = function (grunt) { banner: '<%= pkg.licenseBanner %>\n<%= pkg.userscriptBanner %>' }, src: [ + 'assets/js/gm4-shim.js', 'assets/js/constants.js', 'assets/generated/variables.pass2.js', 'assets/js/settings.js', @@ -153,7 +154,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/dom-operations.js b/assets/js/dom-operations.js index ac82559..f552f7b 100644 --- a/assets/js/dom-operations.js +++ b/assets/js/dom-operations.js @@ -109,6 +109,7 @@ var qcExt; } if (qcExt.settings.showDebugLogs) { + console.debug('Running QC Extensions v' + GM_info.script.version); console.debug('Latest URL:', latestUrl, 'Latest Comic:', latestComic); } @@ -127,8 +128,7 @@ var qcExt; $('#news, #newspost').replaceWith(''); - // $('#side').prepend(''); - $('#container .small-2').prepend(''); + comicDirective.parent().siblings('.small-2').prepend(''); // Set a base (required by Angular's html5Mode) $('head').append(''); diff --git a/assets/js/gm4-shim.js b/assets/js/gm4-shim.js new file mode 100644 index 0000000..9226e0d --- /dev/null +++ b/assets/js/gm4-shim.js @@ -0,0 +1,61 @@ +/* +Functions copied from https://gist.github.com/arantius/3123124 +The MIT License (MIT) + +Copyright (c) 2014 Anthony Lieuallen + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +*/ + +/*jshint unused:false, esversion: 6, latedef: false*/ + +if (typeof GM !== 'undefined' && typeof GM_getValue === 'undefined') { + if (typeof GM_info === 'undefined') { const GM_info = GM.info; } + var GM_xmlhttpRequest = GM.xmlHttpRequest; + var storagePrefix = GM.info.script.name.replace(/[^A-Z]*/g, '') + '-'; + + // The following functions all use local storage, and thus could be accessed + // by the host. They are also restricted to a single domain. + + var GM_deleteValue = function(aKey) { + 'use strict'; + + localStorage.removeItem(storagePrefix + aKey); + }; + + var GM_getValue = function(aKey, aDefault) { + 'use strict'; + + var aValue = localStorage.getItem(storagePrefix + aKey); + if (null === aValue && 'undefined' !== typeof aDefault) { return aDefault; } + return aValue; + }; + + var GM_listValues = function() { + 'use strict'; + + var prefixLen = storagePrefix.length; + var values = []; + for (var i = 0; i < localStorage.length; i++) { + var k = localStorage.key(i); + if (k.substr(0, prefixLen) === storagePrefix) { + values.push(k.substr(prefixLen)); + } + } + return values; + }; + + var GM_setValue = function(aKey, aVal) { + 'use strict'; + + localStorage.setItem(storagePrefix + aKey, aVal); + }; +} diff --git a/assets/js/qc-ext-qcChangeLogDirective.js b/assets/js/qc-ext-qcChangeLogDirective.js index 10b7d63..ba2e5f7 100644 --- a/assets/js/qc-ext-qcChangeLogDirective.js +++ b/assets/js/qc-ext-qcChangeLogDirective.js @@ -55,7 +55,6 @@ var qcExt; } else { return; } - $('#changeLogDialog').modal('show'); self.versionUpdated = true; }); diff --git a/assets/js/qc-ext-qcDateDirective.js b/assets/js/qc-ext-qcDateDirective.js index 7b71717..4b19b87 100644 --- a/assets/js/qc-ext-qcDateDirective.js +++ b/assets/js/qc-ext-qcDateDirective.js @@ -47,82 +47,30 @@ 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; + self.approximateDate = false; }); }); 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 +78,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-qcExtraDirective.js b/assets/js/qc-ext-qcExtraDirective.js index d6c6928..4eb3245 100644 --- a/assets/js/qc-ext-qcExtraDirective.js +++ b/assets/js/qc-ext-qcExtraDirective.js @@ -185,6 +185,17 @@ var qcExt; comicService.comic > constants.taglineThreshold) { self.missingDataInfo.push('a tagline'); } + + if (qcExt.settings.version === undefined) { + // Version is undefined. We're a new user! + $log.debug('qcExtra(): Version undefined!'); + self.showWelcomeMessage = true; + } else if (qcExt.settings.version !== + self.currentVersion) { + // Version is changed. Script has been updated! + $log.debug('qcExtra(): Version different!'); + self.showUpdateMessage = true; + } }); }); @@ -239,6 +250,11 @@ var qcExt; $log.debug(item); }; + this.showChangeLog = function() { + self.showWelcomeMessage = false; + self.showUpdateMessage = false; + $('#changeLogDialog').modal('show'); + }; } qcExt.app.directive('qcExtra', function() { 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/sass/style.scss b/assets/sass/style.scss index fc12f3b..c82ffba 100644 --- a/assets/sass/style.scss +++ b/assets/sass/style.scss @@ -59,7 +59,15 @@ $link-color: #2ba6cb; margin-top: 10px; &.first-header { - margin-top: 0px; + margin-top: 0; + } + + &.update-header { + margin-top: 0; + margin-bottom: 0; + + color: #e43; + font-weight: bold; } small { diff --git a/assets/templates/changeLog.html b/assets/templates/changeLog.html index 1c9da41..977e523 100644 --- a/assets/templates/changeLog.html +++ b/assets/templates/changeLog.html @@ -28,7 +28,21 @@

Script updated!

Script installed!

Thank you for installing Questionable Content Extensions!

-
+ + + + +

0.5.2 October 3, 2018

+ +

0.5.1 April 8, 2017