├── install.png ├── img ├── logo128.png ├── logo16.png ├── logo19.png ├── logo256.png ├── logo32.png ├── logo38.png └── logo48.png ├── sounds └── notify.mp3 ├── src ├── css │ ├── fontawesome │ │ ├── fonts │ │ │ └── fontawesome-webfont.woff2 │ │ └── css │ │ │ └── font-awesome.min.css │ ├── optionsView.css │ └── notificationsView.css └── js │ ├── util.js │ ├── chrDesktopNotificationsView.js │ ├── extensionController.js │ ├── mediator.js │ ├── optionsModel.js │ ├── notificationsView.js │ ├── sourceController.js │ ├── optionsView.js │ └── Source.js ├── README.md ├── _locales ├── en │ └── messages.json └── it │ └── messages.json ├── html ├── popup.html └── options.html ├── manifest.json ├── lib ├── async.js └── message-bus.js └── LICENSE /install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alepolidori/chrome-discourse-notifications/HEAD/install.png -------------------------------------------------------------------------------- /img/logo128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alepolidori/chrome-discourse-notifications/HEAD/img/logo128.png -------------------------------------------------------------------------------- /img/logo16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alepolidori/chrome-discourse-notifications/HEAD/img/logo16.png -------------------------------------------------------------------------------- /img/logo19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alepolidori/chrome-discourse-notifications/HEAD/img/logo19.png -------------------------------------------------------------------------------- /img/logo256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alepolidori/chrome-discourse-notifications/HEAD/img/logo256.png -------------------------------------------------------------------------------- /img/logo32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alepolidori/chrome-discourse-notifications/HEAD/img/logo32.png -------------------------------------------------------------------------------- /img/logo38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alepolidori/chrome-discourse-notifications/HEAD/img/logo38.png -------------------------------------------------------------------------------- /img/logo48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alepolidori/chrome-discourse-notifications/HEAD/img/logo48.png -------------------------------------------------------------------------------- /sounds/notify.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alepolidori/chrome-discourse-notifications/HEAD/sounds/notify.mp3 -------------------------------------------------------------------------------- /src/css/fontawesome/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alepolidori/chrome-discourse-notifications/HEAD/src/css/fontawesome/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Chrome Discourse Notifications 2 | ============================== 3 | 4 | A Google Chrome extension that shows notifications of your specified Discourse community account. 5 | 6 | Installation 7 | ============ 8 | 9 | [![Chrome Web Store][install-image]][webstore-url] 10 | 11 | [webstore-url]: https://chrome.google.com/webstore/detail/discourse/okmkhbdimfnmdhpclfbamachjcpcgcmi 12 | [install-image]: install.png -------------------------------------------------------------------------------- /_locales/en/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "extName": { 3 | "message": "Discourse Forum Notifications", 4 | "description": "Extension name." 5 | }, 6 | "extDescription": { 7 | "message": "Shows notifications of all added discourse forum sites.", 8 | "description": "Extension description." 9 | }, 10 | "save": { "message": "Save" }, 11 | "options_saved": { "message": "Options saved" } 12 | } -------------------------------------------------------------------------------- /_locales/it/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "extName": { 3 | "message": "Discourse Forum Notifications", 4 | "description": "Nome dell'estensione." 5 | }, 6 | "extDescription": { 7 | "message": "Visualizza le notifiche di ogni forum discourse aggiunto.", 8 | "description": "Descrizione dell'estensione." 9 | }, 10 | "save": { "message": "Salva" }, 11 | "options_saved": { "message": "Opzioni salvate" } 12 | } -------------------------------------------------------------------------------- /src/js/util.js: -------------------------------------------------------------------------------- 1 | var util = new function () { 2 | 'use strict'; 3 | 4 | var that = this; 5 | 6 | this.ID = 'util'; 7 | this.audio = new Audio(); 8 | 9 | this.playSound = function (audioFile) { 10 | try { 11 | this.audio.src = audioFile; 12 | this.audio.play(); 13 | } catch (err) { 14 | console.error(err.stack); 15 | } 16 | }; 17 | 18 | this.playNotificationSound = function () { 19 | try { 20 | this.playSound('../sounds/notify.mp3'); 21 | } catch (err) { 22 | console.error(err.stack); 23 | } 24 | }; 25 | }; 26 | -------------------------------------------------------------------------------- /html/popup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Notifications 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 | 15 |
16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/css/optionsView.css: -------------------------------------------------------------------------------- 1 | body { font-size: 1em; } 2 | body > div { margin: 10px 0px; } 3 | body > :first-child { 4 | text-align: right; 5 | color: #919191; 6 | } 7 | i, a, input, label, button { vertical-align: middle; } 8 | a { 9 | color: #08c; 10 | text-decoration: none; 11 | } 12 | #version-lbl { font-size: 0.7em; } 13 | #add-source-input { width: 250px; } 14 | .hide { display: none; } 15 | .remove-source-btn { 16 | margin-right: 5px; 17 | color: #7a7a7a; 18 | cursor: pointer; 19 | } 20 | #add-source-btn { 21 | display: inline-block; 22 | vertical-align: middle; 23 | } 24 | .btn { 25 | border: none; 26 | outline: 0; 27 | color: #fff; 28 | background: #08c; 29 | border-radius: 60px; 30 | cursor: pointer; 31 | display: table-cell; 32 | width: 32px; 33 | height: 30px; 34 | text-align: center; 35 | padding-top: 2px; 36 | } 37 | .btn:hover { 38 | color: #fff !important; 39 | background: #006ca5 !important; 40 | border: none; 41 | outline: 0; 42 | } 43 | #source-output-lbl { 44 | margin-top: 10px; 45 | display: inline-block; 46 | font-size: 0.8em; 47 | color: red; 48 | height: 1.5em; 49 | } 50 | .spinner { color: #08c; } 51 | .cursorPointer { cursor: pointer; } 52 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "__MSG_extName__", 3 | "description": "__MSG_extDescription__", 4 | "version": "1.1.4", 5 | "author": "Alessandro Polidori", 6 | "manifest_version": 2, 7 | "default_locale": "en", 8 | "options_page": "html/options.html", 9 | "background": { 10 | "scripts": [ 11 | "lib/async.js", 12 | "lib/jquery-2.1.4.min.js", 13 | "lib/message-bus.js", 14 | "src/js/util.js", 15 | "src/js/mediator.js", 16 | "src/js/chrDesktopNotificationsView.js", 17 | "src/js/Source.js", 18 | "src/js/optionsModel.js", 19 | "src/js/extensionController.js", 20 | "src/js/sourceController.js" 21 | ] 22 | }, 23 | "permissions": [ 24 | "tabs", 25 | "storage", 26 | "http://*/", 27 | "https://*/", 28 | "notifications" 29 | ], 30 | "icons": { 31 | "16": "img/logo16.png", 32 | "32": "img/logo32.png", 33 | "48": "img/logo48.png", 34 | "128": "img/logo128.png", 35 | "256": "img/logo256.png" 36 | }, 37 | "browser_action": { 38 | "default_icon": { 39 | "19": "img/logo19.png", 40 | "38": "img/logo38.png" 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /html/options.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Chrome Discourse Notifications Options 5 | 6 | 7 | 8 | 9 |
10 | 11 |
12 | 13 | 14 | 15 |
16 | 17 |
18 | 19 | 20 |
21 | 22 |
23 | 24 | 25 |
26 | 27 |
28 | 29 | 30 | 31 |
32 | 33 |
34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
42 | 43 |
44 |
45 | 46 |
47 |
48 |
49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/css/notificationsView.css: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing: border-box; 3 | } 4 | 5 | html, 6 | body { 7 | margin: 0px; 8 | min-height: 300px; 9 | } 10 | 11 | html { 12 | margin: 0; 13 | } 14 | 15 | section { 16 | width: 35em; 17 | min-height: 60px; 18 | marign: 0.5em 0; 19 | font-size: 12px; 20 | } 21 | 22 | #loader { 23 | margin-top: 20px; 24 | text-align: center; 25 | } 26 | 27 | .spinner { 28 | text-align: center; 29 | margin-top: 20px; 30 | color: #00bad2; 31 | } 32 | 33 | .notification { 34 | display: block; 35 | padding: 0.5em 0.5em; 36 | text-decoration: none; 37 | outline: none; 38 | } 39 | 40 | .notification.unread { 41 | background: #e0f5ff; 42 | font-weight: bold; 43 | } 44 | 45 | .notification:hover { 46 | background-color: rgb(240, 240, 240); 47 | } 48 | 49 | .notification-username { 50 | margin-right: 0.5em; 51 | color: #222; 52 | } 53 | .notification-title { 54 | color: #08c; 55 | } 56 | .notification i { 57 | margin-right: 5px; 58 | } 59 | .notification .fa { 60 | color: #919191; 61 | } 62 | 63 | .source-header { 64 | width: 100%; 65 | display: table; 66 | border-collapse: separate; 67 | border-spacing: 0 0.5em; 68 | font-size: 1.2em; 69 | color: #fff; 70 | background: #00bad2; 71 | padding-left: 16px; 72 | font-weight: bold; 73 | text-decoration: none; 74 | outline: none; 75 | } 76 | 77 | .source-header img { 78 | margin-right: 5px; 79 | } 80 | 81 | .source-header > * { 82 | vertical-align: middle; 83 | } 84 | 85 | .btn { 86 | display: inline-block; 87 | margin: 0; 88 | padding: 6px 12px; 89 | font-size: 1em; 90 | line-height: 18px; 91 | text-align: center; 92 | cursor: pointer; 93 | transition: all .25s; 94 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 95 | border: none; 96 | color: #222; 97 | font-weight: normal; 98 | background: #e9e9e9; 99 | } 100 | .btn:hover { 101 | background: #b2b2b2; 102 | color: #fff; 103 | } 104 | .source-actions { 105 | text-align: right; 106 | } 107 | hr { 108 | display: block; 109 | height: 1px; 110 | border: 0; 111 | border-top: 1px solid #e9e9e9; 112 | padding: 0; 113 | margin: 0px; 114 | } 115 | 116 | .toolbar { 117 | padding: 3px 0px; 118 | font-size: 1.5em; 119 | color: #919191; 120 | } 121 | .toolbar a { 122 | text-decoration: none; 123 | color: #919191; 124 | } 125 | .toolbar-text { 126 | color: #919191; 127 | margin-left: 5px; 128 | margin-right: 20px; 129 | } 130 | .cursorPointer { 131 | cursor: pointer; 132 | } 133 | .closePopup { 134 | position: absolute; 135 | right: 5px; 136 | } 137 | .showOptionsView { 138 | margin-left: 5px; 139 | } 140 | -------------------------------------------------------------------------------- /src/js/chrDesktopNotificationsView.js: -------------------------------------------------------------------------------- 1 | var chrDesktopNotificationsView = new function () { 2 | 'use strict'; 3 | 4 | var that = this; 5 | 6 | this.ID = 'chrDesktopNotificationsView'; 7 | this.ns = {}; 8 | 9 | this.showChrRichNotificationProgress = function (title, body, sourceUrl, noturl, iconUrl) { 10 | try { 11 | var opt = { 12 | type: 'progress', 13 | title: title, 14 | message: body, 15 | iconUrl: iconUrl, 16 | contextMessage: sourceUrl, 17 | progress: 0 18 | }; 19 | chrome.notifications.create(opt, function (nid) { 20 | try { 21 | that.ns[nid] = { clickUrl: noturl }; 22 | that.startUpdateChrNotificationProgress(nid); 23 | } catch (err) { 24 | console.error(err.stack); 25 | } 26 | }); 27 | 28 | } catch (err) { 29 | console.error(err.stack); 30 | } 31 | }; 32 | 33 | this.startUpdateChrNotificationProgress = function (nid) { 34 | try { 35 | var value = 0; 36 | var idInterval = setInterval(function () { 37 | value += 15; 38 | if (value > 100) { 39 | chrome.notifications.update(nid, { progress: 100 }, function (wasUpdated) {}); 40 | that.stopUpdateChrNotificationProgress(nid); 41 | } 42 | else { 43 | chrome.notifications.update(nid, { progress: value }, function (wasUpdated) {}); 44 | } 45 | }, 1000); 46 | this.ns[nid].updateIdInterval = idInterval; 47 | 48 | } catch (err) { 49 | console.error(err.stack); 50 | } 51 | }; 52 | 53 | this.stopUpdateChrNotificationProgress = function (nid) { 54 | try { 55 | if (this.ns[nid] && this.ns[nid].updateIdInterval) { 56 | clearInterval(this.ns[nid].updateIdInterval); 57 | } 58 | } catch (err) { 59 | console.error(err.stack); 60 | } 61 | }; 62 | 63 | this.onClosedNotification = function (nid) { 64 | try { 65 | that.stopUpdateChrNotificationProgress(nid); 66 | delete that.ns[nid]; 67 | } catch (err) { 68 | console.error(err.stack); 69 | } 70 | }; 71 | 72 | this.onClickedNotification = function (nid) { 73 | try { 74 | if (that.ns[nid]) { 75 | var url = that.ns[nid].clickUrl; 76 | var urlToSearch = sourceController.removePostMessageNumber(url); 77 | mediator.showTab(url, true, true, urlToSearch); 78 | chrome.notifications.clear(nid, function (wasCleared) {}); 79 | } 80 | else { 81 | chrome.notifications.clear(nid, function (wasCleared) {}); 82 | } 83 | } catch (err) { 84 | console.error(err.stack); 85 | } 86 | }; 87 | 88 | (function init() { 89 | try { 90 | chrome.notifications.onClosed.addListener(that.onClosedNotification); 91 | chrome.notifications.onClicked.addListener(that.onClickedNotification); 92 | } catch (err) { 93 | console.error(err.stack); 94 | } 95 | }()); 96 | }; 97 | -------------------------------------------------------------------------------- /src/js/extensionController.js: -------------------------------------------------------------------------------- 1 | var extensionController = new function () { 2 | 'use strict'; 3 | 4 | var that = this; 5 | 6 | this.ID = 'extensionController'; 7 | this.debug = true; 8 | this.popupUrl = 'html/popup.html'; 9 | this.optionsUrl = mediator.getOptionsUrl(); 10 | this.options = {}; 11 | 12 | this.onInstalled = function (details) { 13 | try { 14 | if (details.reason === 'install') { 15 | that.showOptionsView(); 16 | } 17 | else if (details.reason === 'update' && 18 | details.previousVersion === '0.3') { 19 | 20 | that.migrateOptionsFromVer03(); 21 | } 22 | } catch (err) { 23 | console.error(err.stack); 24 | } 25 | }; 26 | 27 | this.init = function () { 28 | try { 29 | optionsModel.$dispatcher.on(optionsModel.EVT_SOURCE_ADDED, this.updateExtensionBtnBehaviour); 30 | optionsModel.$dispatcher.on(optionsModel.EVT_SOURCE_REMOVED, this.updateExtensionBtnBehaviour); 31 | 32 | optionsModel.loadOptions(this.onOptionsLoaded); 33 | } catch (err) { 34 | console.error(err.stack); 35 | } 36 | }; 37 | 38 | this.onOptionsLoaded = function () { 39 | try { 40 | that.updateExtensionBtnBehaviour(); 41 | sourceController.init(); 42 | } catch (err) { 43 | console.error(err.stack); 44 | } 45 | }; 46 | 47 | this.updateExtensionBtnBehaviour = function () { 48 | try { 49 | that.removeExtensionBtnListeners(); 50 | if (optionsModel.sourcesNum() > 0) { 51 | mediator.setExtensionIconPopup({ popup: that.popupUrl }); 52 | } 53 | else { 54 | mediator.extensionIconOnClicked(that.showOptionsView); 55 | } 56 | } catch (err) { 57 | console.error(err.stack); 58 | } 59 | }; 60 | 61 | this.removeExtensionBtnListeners = function () { 62 | try { 63 | mediator.setExtensionIconPopup({ popup: '' }); 64 | mediator.extensionIconOnClicked(that.showOptionsView); 65 | } catch (err) { 66 | console.error(err.stack); 67 | } 68 | }; 69 | 70 | this.setCounterBadge = function (val) { 71 | try { 72 | mediator.setExtensionBtnText({ text: val.toString() }); 73 | } catch (err) { 74 | console.error(err.stack); 75 | } 76 | }; 77 | 78 | this.showOptionsView = function () { 79 | try { 80 | mediator.showTab(that.optionsUrl, true, true); 81 | } catch (err) { 82 | console.error(err.stack); 83 | } 84 | }; 85 | 86 | this.logger = function (str, obj) { 87 | try { 88 | if (that.debug) { 89 | console.log('[' + this.ID + '] - ' + str); 90 | if (obj) { console.log(obj); } 91 | } 92 | } catch (err) { 93 | console.error(err.stack); 94 | } 95 | } 96 | 97 | this.warn = function (str, obj) { 98 | try { 99 | console.warn('[' + this.ID + '] - ' + str); 100 | if (obj) { console.warn(obj); } 101 | } catch (err) { 102 | console.error(err.stack); 103 | } 104 | } 105 | 106 | this.migrateOptionsFromVer03 = function () { 107 | try { 108 | mediator.getStorage(function (items) { 109 | if (items && items.discourseUrl) { 110 | optionsModel.addSource(items.discourseUrl, function (err) { 111 | mediator.storageRemoveItem('discourseUrl', function () {}); 112 | }); 113 | } 114 | }); 115 | } catch (err) { 116 | console.error(err.stack); 117 | } 118 | }; 119 | 120 | (function () { 121 | mediator.doOnInstalled(that.onInstalled); 122 | }()); 123 | }; 124 | 125 | extensionController.init(); 126 | -------------------------------------------------------------------------------- /src/js/mediator.js: -------------------------------------------------------------------------------- 1 | var mediator = new function () { 2 | 'use strict'; 3 | 4 | var that = this; 5 | 6 | this.ID = 'mediator'; 7 | 8 | /** 9 | * If "update" is false it opens a new tab to url specified by "urlToOpen". Otherwise it looks for an 10 | * already opened tab with url "urlToSearch". In this case the following scenarios could be present: 11 | * - a tab does not exist: it creates a new one and gives it the focus if "active" is true 12 | * - a tab exists: it updates the tab with url "urlToOpen" gives it the focus if "active" is true 13 | * 14 | * The considered tabs are those of the current window. 15 | * 16 | * @method showTab 17 | * @param {string} urlToOpen Url to be opened or updated 18 | * @param {boolean} active Whether the tab should be activated 19 | * @param {boolean} [update] If true it checks for an already opened tab and if so, it updates the tab 20 | * @param {string} [urlToSearch] The url used to search an already opened tab. If it is not specified, 21 | * "urlToOpen" will be used. It requires "update" set to true. 22 | */ 23 | this.showTab = function (urlToOpen, active, update, urlToSearch) { 24 | try { 25 | active = active ? active : false; 26 | update = update ? update : false; 27 | urlToSearch = urlToSearch ? (urlToSearch + '/*') : urlToOpen; 28 | if (update) { 29 | chrome.tabs.query({ url: urlToSearch, currentWindow: true }, function (tabs) { 30 | if (tabs.length > 0) { 31 | chrome.tabs.update(tabs[0].id, { active: active, url: urlToOpen }); 32 | } 33 | else { 34 | chrome.tabs.create({ url: urlToOpen, active: active }); 35 | } 36 | }); 37 | } 38 | else { 39 | chrome.tabs.create({ url: urlToOpen, active: active }); 40 | } 41 | } catch (err) { 42 | console.error(err.stack); 43 | } 44 | }; 45 | 46 | this.getBackgroundPage = function () { 47 | try { 48 | return chrome.extension.getBackgroundPage(); 49 | } catch (err) { 50 | console.error(err.stack); 51 | } 52 | }; 53 | 54 | this.isDiscourseSiteOpened = function (url, cb) { 55 | try { 56 | chrome.tabs.query({}, function (tabs) { 57 | var i; 58 | for (i = 0; i < tabs.length; i++) { 59 | if (tabs[i].url.indexOf(url) > -1) { 60 | cb(null, true); 61 | return; 62 | } 63 | } 64 | cb(null, false); 65 | }); 66 | } catch (err) { 67 | console.error(err.stack); 68 | cb(err); 69 | } 70 | }; 71 | 72 | this.getStorage = function (cb) { 73 | try { 74 | chrome.storage.sync.get(cb); 75 | } catch (err) { 76 | console.error(err.stack); 77 | } 78 | }; 79 | 80 | this.getStorageWithDefaults = function (defaults, cb) { 81 | try { 82 | chrome.storage.sync.get(defaults, cb); 83 | } catch (err) { 84 | console.error(err.stack); 85 | } 86 | }; 87 | 88 | this.storageRemoveItem = function (item, cb) { 89 | try { 90 | chrome.storage.sync.remove(item, cb); 91 | } catch (err) { 92 | console.error(err.stack); 93 | } 94 | }; 95 | 96 | this.setStorageItems = function (items, cb) { 97 | try { 98 | chrome.storage.sync.set(items, cb); 99 | } catch (err) { 100 | console.error(err.stack); 101 | } 102 | }; 103 | 104 | this.getAppVersion = function () { 105 | try { 106 | return chrome.runtime.getManifest().version; 107 | } catch (err) { 108 | console.error(err.stack); 109 | } 110 | }; 111 | 112 | this.getBackgroundPage = function () { 113 | try { 114 | return chrome.extension.getBackgroundPage(); 115 | } catch (err) { 116 | console.error(err.stack); 117 | } 118 | }; 119 | 120 | this.getOptionsUrl = function () { 121 | try { 122 | return chrome.extension.getURL('html/options.html'); 123 | } catch (err) { 124 | console.error(err.stack); 125 | } 126 | }; 127 | 128 | this.doOnInstalled = function (cb) { 129 | try { 130 | chrome.runtime.onInstalled.addListener(function (details) { 131 | cb(details); 132 | }); 133 | } catch (err) { 134 | console.error(err.stack); 135 | } 136 | }; 137 | 138 | this.setExtensionIconPopup = function (obj) { 139 | try { 140 | chrome.browserAction.setPopup(obj); 141 | } catch (err) { 142 | console.error(err.stack); 143 | } 144 | }; 145 | 146 | this.extensionIconOnClicked = function (cb) { 147 | try { 148 | chrome.browserAction.onClicked.addListener(cb); 149 | } catch (err) { 150 | console.error(err.stack); 151 | } 152 | }; 153 | 154 | this.setExtensionBtnText = function (obj) { 155 | try { 156 | chrome.browserAction.setBadgeText(obj); 157 | } catch (err) { 158 | console.error(err.stack); 159 | } 160 | }; 161 | 162 | this.showNotification = function (title, body, sourceUrl, noturl, iconUrl) { 163 | try { 164 | chrDesktopNotificationsView.showChrRichNotificationProgress(title, body, sourceUrl, noturl, iconUrl); 165 | } catch (err) { 166 | console.error(err.stack); 167 | } 168 | }; 169 | }; 170 | -------------------------------------------------------------------------------- /src/js/optionsModel.js: -------------------------------------------------------------------------------- 1 | var optionsModel = new function () { 2 | 'use strict'; 3 | 4 | var that = this; 5 | 6 | this.ID = 'optionsModel'; 7 | this.defaults = { 8 | sources: {}, 9 | fontSize: '1', 10 | openPagesBackgroundEnabled: true, 11 | desktopNotificationsEnabled: true, 12 | desktopNotificationsSoundEnabled: true 13 | }; 14 | this.options = {}; 15 | this.$dispatcher = $({}); 16 | this.EVT_SOURCE_ADDED = 'EVT_SOURCE_ADDED'; 17 | this.EVT_SOURCE_REMOVED = 'EVT_SOURCE_REMOVED'; 18 | 19 | this.loadOptions = function (cb) { 20 | try { 21 | mediator.getStorageWithDefaults(this.defaults, function (items) { 22 | try { 23 | var k; 24 | for (k in that.defaults) { 25 | if (items[k] !== undefined) { 26 | that.options[k] = items[k]; 27 | } 28 | } 29 | cb(); 30 | 31 | } catch (err) { 32 | console.error(err.stack); 33 | cb(err); 34 | } 35 | }); 36 | } catch (err) { 37 | console.error(err.stack); 38 | cb(err); 39 | } 40 | }; 41 | 42 | this.setFontSize = function (value) { 43 | try { 44 | mediator.setStorageItems({ 45 | fontSize: value 46 | }, function (items) { 47 | that.options.fontSize = value; 48 | }); 49 | } catch (err) { 50 | console.error(err.stack); 51 | } 52 | }; 53 | 54 | this.setEnableOpenPagesBackground = function (value) { 55 | try { 56 | mediator.setStorageItems({ 57 | openPagesBackgroundEnabled: value 58 | }, function (items) { 59 | that.options.openPagesBackgroundEnabled = value; 60 | }); 61 | } catch (err) { 62 | console.error(err.stack); 63 | } 64 | }; 65 | 66 | this.setEnableDesktopNotifications = function (value) { 67 | try { 68 | mediator.setStorageItems({ 69 | desktopNotificationsEnabled: value 70 | }, function (items) { 71 | that.options.desktopNotificationsEnabled = value; 72 | }); 73 | } catch (err) { 74 | console.error(err.stack); 75 | } 76 | }; 77 | 78 | this.setEnableDesktopNotificationsSound = function (value) { 79 | try { 80 | mediator.setStorageItems({ 81 | desktopNotificationsSoundEnabled: value 82 | }, function (items) { 83 | that.options.desktopNotificationsSoundEnabled = value; 84 | }); 85 | } catch (err) { 86 | console.error(err.stack); 87 | } 88 | }; 89 | 90 | this.normalizeBaseUrl = function (url) { 91 | try { 92 | var arr = url.split('/'); 93 | var urlParts = [arr[0], arr[2]]; 94 | var returnUrl = urlParts.join('//'); 95 | if (arr[3]) { 96 | var subParts = arr.slice(3); 97 | returnUrl += '/' + subParts.join('/'); 98 | } 99 | return returnUrl; 100 | } catch (err) { 101 | console.error(err.stack); 102 | return url; 103 | } 104 | }; 105 | 106 | this.addSource = function (url, cb) { 107 | try { 108 | url = this.normalizeBaseUrl(url); 109 | mediator.getStorageWithDefaults(this.defaults, function (items) { 110 | try { 111 | items.sources[url] = ''; 112 | 113 | mediator.setStorageItems({ 114 | sources: items.sources 115 | }, function () { 116 | that.options.sources = items.sources; 117 | that.$dispatcher.trigger(that.EVT_SOURCE_ADDED, url); 118 | cb(); 119 | }); 120 | } catch (err) { 121 | console.error(err.stack); 122 | cb(err); 123 | } 124 | }); 125 | } catch (err) { 126 | console.error(err.stack); 127 | cb(err); 128 | } 129 | }; 130 | 131 | this.removeSource = function (url, cb) { 132 | try { 133 | mediator.getStorageWithDefaults(this.defaults, function (items) { 134 | try { 135 | delete items.sources[url]; 136 | 137 | mediator.setStorageItems({ 138 | sources: items.sources 139 | }, function () { 140 | delete that.options.sources[url]; 141 | that.$dispatcher.trigger(that.EVT_SOURCE_REMOVED, url); 142 | cb(); 143 | }); 144 | } catch (err) { 145 | console.error(err.stack); 146 | cb(err.stack); 147 | } 148 | }); 149 | } catch (err) { 150 | console.error(err.stack); 151 | cb(err); 152 | } 153 | }; 154 | 155 | this.sourcesNum = function () { 156 | try { 157 | return this.options.sources ? Object.keys(this.options.sources).length : 0; 158 | } catch (err) { 159 | console.error(err.stack); 160 | } 161 | }; 162 | 163 | this.isDesktopNotificationsEnabled = function () { 164 | try { 165 | return this.options.desktopNotificationsEnabled; 166 | } catch (err) { 167 | console.error(err.stack); 168 | } 169 | }; 170 | 171 | this.isDesktopNotificationsSoundsEnabled = function () { 172 | try { 173 | return this.options.desktopNotificationsSoundEnabled; 174 | } catch (err) { 175 | console.error(err.stack); 176 | } 177 | }; 178 | 179 | this.isOpenPagesBackgroundEnabled = function () { 180 | try { 181 | return this.options.openPagesBackgroundEnabled; 182 | } catch (err) { 183 | console.error(err.stack); 184 | } 185 | }; 186 | }; 187 | -------------------------------------------------------------------------------- /src/js/notificationsView.js: -------------------------------------------------------------------------------- 1 | var notificationsView = new function () { 2 | 'use strict'; 3 | 4 | var that = this; 5 | 6 | this.ID = 'notificationsView'; 7 | this.bg = mediator.getBackgroundPage(); 8 | this.$notificationsPage; 9 | this.numNotifications = 10; 10 | this.iconClassMap = { 11 | 2: 'fa-reply', 12 | 5: 'fa-heart', 13 | 9: 'fa-reply', 14 | 12: 'fa-certificate' 15 | }; 16 | 17 | $(function () { 18 | try { 19 | that.$notificationsPage = $('#notifications-page'); 20 | that.$notificationsPage.css('font-size', notificationsView.bg.optionsModel.options.fontSize + 'em'); 21 | that.bg.sourceController.getAllSourcesNotifications(function (err, data) { 22 | if (err) { 23 | that.$notificationsPage.html(err); 24 | } 25 | else { 26 | that.$notificationsPage.html(that.viewTemplate(data)); 27 | that.initLinks(); 28 | } 29 | }); 30 | } catch (err) { 31 | console.error(err.stack); 32 | } 33 | }); 34 | 35 | this.appendUrl = function (url, n) { 36 | try { 37 | if (!n.data.badge_id) { 38 | n.url = url + '/t/' + n.slug + '/' + n.topic_id + '/' + n.post_number; 39 | } 40 | else { 41 | n.url = url + '/badges/' + n.data.badge_id + '/' + n.data.badge_name.replace(/[^A-Za-z0-9_]+/g, '-').toLowerCase(); 42 | } 43 | return n; 44 | } catch (err) { 45 | console.error(err.stack); 46 | } 47 | }; 48 | 49 | this.appendSourceId = function (id, n) { 50 | try { 51 | n.sourceId = id; 52 | return n; 53 | } catch (err) { 54 | console.error(err.stack); 55 | } 56 | }; 57 | 58 | this.extractData = function (n) { 59 | try { 60 | n.popNot = { icon: that.iconClassMap[n.notification_type] }; 61 | if (!n.data.badge_id) { 62 | n.popNot.key = n.data.display_username; 63 | n.popNot.value = n.data.topic_title; 64 | } else { 65 | n.popNot.key = 'Earned'; 66 | n.popNot.value = '\'' + n.data.badge_name + '\''; 67 | } 68 | return n; 69 | } catch (err) { 70 | console.error(err.stack); 71 | } 72 | }; 73 | 74 | this.sourceNotificationTemplate = function (n) { 75 | try { 76 | var classes = 'notification js-notification-link'; 77 | if (!n.read) { classes += ' unread'; } 78 | return [ 79 | '', 80 | '', 81 | '', 82 | n.popNot.key, 83 | '', 84 | '', 85 | n.popNot.value, 86 | '', 87 | '' 88 | ].join(''); 89 | } catch (err) { 90 | console.error(err.stack); 91 | } 92 | }; 93 | 94 | this.sourceHeaderTemplate = function (sourceId) { 95 | try { 96 | var name = that.bg.sourceController.sources[sourceId].name; 97 | var faviconUrl = that.bg.sourceController.sources[sourceId].faviconUrl; 98 | return [ 99 | '', 100 | '', 101 | '', name, '', 102 | '' 103 | ].join(''); 104 | } catch (err) { 105 | console.error(err.stack); 106 | } 107 | }; 108 | 109 | this.oldSourceNotificationsLinkTemplate = function (url) { 110 | try { 111 | var classes = 'notification js-notification-link unread'; 112 | return [ 113 | '', 114 | '', 115 | 'view older notifications...', 116 | '', 117 | '' 118 | ].join(''); 119 | } catch (err) { 120 | console.error(err.stack); 121 | } 122 | }; 123 | 124 | this.toolbarTemplate = function () { 125 | try { 126 | var optUrl = mediator.getOptionsUrl(); 127 | return [ 128 | '
', 129 | '', 130 | '', 131 | 'Options', 132 | '', 133 | '', 134 | '', 135 | '', 136 | '
' 137 | ].join(''); 138 | } catch (err) { 139 | console.error(err.stack); 140 | } 141 | }; 142 | 143 | this.initLinks = function () { 144 | try { 145 | var links = $('a[href]'); 146 | [].forEach.call(links, function (link) { 147 | link.addEventListener('click', function (e) { 148 | e.preventDefault(); 149 | var urlToSearch = that.bg.sourceController.removePostMessageNumber(e.currentTarget.href); 150 | mediator.showTab(e.currentTarget.href, !notificationsView.bg.optionsModel.isOpenPagesBackgroundEnabled(), true, urlToSearch); 151 | }, false); 152 | }); 153 | 154 | $('.showOptionsView').click(function (ev) { 155 | that.bg.extensionController.showOptionsView(); 156 | }); 157 | 158 | $('.closePopup').click(function (ev) { 159 | window.close(); 160 | }); 161 | } catch (err) { 162 | console.error(err.stack); 163 | } 164 | }; 165 | 166 | this.sourceErrorTemplate = function (str, url) { 167 | try { 168 | var classes = 'notification js-notification-link'; 169 | return [ 170 | '', 171 | '', 172 | str, 173 | '', 174 | '' 175 | ].join(''); 176 | } catch (err) { 177 | console.error(err.stack); 178 | } 179 | }; 180 | 181 | this.viewTemplate = function (data) { 182 | try { 183 | var ns, sourceId; 184 | var html = ''; 185 | html += that.toolbarTemplate(); 186 | for (sourceId in data) { 187 | html += that.sourceHeaderTemplate(sourceId); 188 | if (data[sourceId].notifications) { 189 | ns = data[sourceId].notifications.slice(0, that.numNotifications); 190 | ns.map(that.appendUrl.bind(null, sourceId)); 191 | ns.map(that.appendSourceId.bind(null, sourceId)); 192 | ns.map(that.extractData); 193 | html += ns.map(that.sourceNotificationTemplate).join(''); 194 | html += that.oldSourceNotificationsLinkTemplate(sourceId); 195 | } 196 | else if (data[sourceId].error) { 197 | html += that.sourceErrorTemplate(data[sourceId].error, sourceId); 198 | } 199 | } 200 | return html; 201 | } catch (err) { 202 | console.error(err.stack); 203 | } 204 | }; 205 | }; 206 | -------------------------------------------------------------------------------- /src/js/sourceController.js: -------------------------------------------------------------------------------- 1 | var sourceController = new function () { 2 | 'use strict'; 3 | 4 | var that = this; 5 | 6 | this.ID = 'sourceController'; 7 | this.counter = 0; 8 | this.sources = {}; 9 | this.TIMEOUT_CHECK_URL = 2000; 10 | 11 | this.init = function () { 12 | try { 13 | optionsModel.$dispatcher.on(optionsModel.EVT_SOURCE_ADDED, this.onEvtSourceAdded); 14 | optionsModel.$dispatcher.on(optionsModel.EVT_SOURCE_REMOVED, this.onEvtSourceRemoved); 15 | this.addSources(); 16 | } catch (err) { 17 | console.error(err.stack); 18 | } 19 | }; 20 | 21 | this.addSource = function (url) { 22 | try { 23 | if (that.sources[url] === undefined) { 24 | var source = new Source(url); 25 | source.$dispatcher.on(source.EVT_NOTIFICATION_COUNTER_UPDATE, this.onEvtNotificationCounterUpdate); 26 | source.$dispatcher.on(source.EVT_NEW_NOTIFICATION_ALERT, this.onEvtNewNotificationAlert); 27 | this.sources[source.sourceId] = source; 28 | } 29 | } catch (err) { 30 | console.error(err.stack); 31 | } 32 | }; 33 | 34 | this.addSources = function () { 35 | try { 36 | var url; 37 | for (url in optionsModel.options.sources) { 38 | this.addSource(url); 39 | } 40 | } catch (err) { 41 | console.error(err.stack); 42 | } 43 | }; 44 | 45 | this.onEvtSourceAdded = function (evt, url) { 46 | try { 47 | that.addSource(url); 48 | } catch (err) { 49 | console.error(err.stack); 50 | } 51 | }; 52 | 53 | this.onEvtSourceRemoved = function (evt, url) { 54 | try { 55 | that.removeSource(url); 56 | } catch (err) { 57 | console.error(err.stack); 58 | } 59 | }; 60 | 61 | this.removeSource = function (url) { 62 | try { 63 | this.sources[url].$dispatcher.off(this.sources[url].EVT_NOTIFICATION_COUNTER_UPDATE, this. onEvtNotificationCounterUpdate); 64 | this.sources[url].$dispatcher.off(this.sources[url].EVT_NEW_NOTIFICATION_ALERT, this.onEvtNewNotificationAlert); 65 | delete this.sources[url]; 66 | this.updateCounter(); 67 | } catch (err) { 68 | console.error(err.stack); 69 | } 70 | }; 71 | 72 | this.onEvtNotificationCounterUpdate = function () { 73 | try { 74 | that.updateCounter(); 75 | } catch (err) { 76 | console.error(err.stack); 77 | } 78 | }; 79 | 80 | this.onEvtNewNotificationAlert = function (ev, data) { 81 | try { 82 | if (optionsModel.isDesktopNotificationsEnabled() === true) { 83 | var sourceUrl = that.sources[data.sourceId].url; 84 | mediator.isDiscourseSiteOpened(sourceUrl, function (err, opened) { 85 | if (!err && opened === false) { 86 | var title = that.extractNotificationTitle(data.data); 87 | var noturl = [ sourceUrl, data.data.post_url].join(''); 88 | var iconUrl = that.sources[data.sourceId].faviconUrl; 89 | mediator.showNotification(title, data.data.excerpt, sourceUrl, noturl, iconUrl); 90 | } 91 | }); 92 | } 93 | if (optionsModel.isDesktopNotificationsSoundsEnabled() === true) { 94 | util.playNotificationSound(); 95 | } 96 | } catch (err) { 97 | console.error(err.stack); 98 | } 99 | }; 100 | 101 | this.extractNotificationTitle = function (data) { 102 | try { 103 | var notificationTypes = [ 104 | undefined, 105 | 'mentioned', 106 | 'replied', 107 | 'quoted', 108 | 'edited', 109 | 'liked', 110 | 'private_message', 111 | 'invited_to_private_message', 112 | 'invitee_accepted', 113 | 'posted', 114 | 'moved_post', 115 | 'linked', 116 | 'granted_badge', 117 | 'invited_to_topic' 118 | ]; 119 | 120 | var templates = { 121 | mentioned: '{{username}} mentioned you in "{{topic}}" - {{site_title}}', 122 | quoted: '{{username}} quoted you in "{{topic}}" - {{site_title}}', 123 | replied: '{{username}} replied to you in "{{topic}}" - {{site_title}}', 124 | posted: '{{username}} posted in "{{topic}}" - {{site_title}}', 125 | private_message: '{{username}} sent you a private message in "{{topic}}" - {{site_title}}', 126 | linked: '{{username}} linked to your post from "{{topic}}" - {{site_title}}' 127 | }; 128 | 129 | var title = templates[notificationTypes[data.notification_type]]; 130 | title = title.replace('{{username}}', data.username); 131 | title = title.replace('{{topic}}', data.topic_title); 132 | title = title.replace(' - {{site_title}}', ''); 133 | 134 | return title; 135 | 136 | } catch (err) { 137 | console.error(err.stack); 138 | return ''; 139 | } 140 | }; 141 | 142 | this.updateCounter = function () { 143 | try { 144 | this.counter = 0; 145 | var s; 146 | for (s in this.sources) { 147 | this.counter += this.sources[s].counter; 148 | } 149 | if (this.counter > 0) { 150 | extensionController.setCounterBadge(this.counter); 151 | } 152 | else { 153 | extensionController.setCounterBadge(''); 154 | } 155 | } catch (err) { 156 | console.error(err.stack); 157 | } 158 | }; 159 | 160 | this.getAllSourcesNotifications = function (cb) { 161 | try { 162 | var results = {}; 163 | async.each(this.sources, function (source, callback) { 164 | source.getNotifications(function (err, data) { 165 | if (err) { 166 | results[source.sourceId] = { error: err }; 167 | } 168 | else { 169 | results[source.sourceId] = { notifications: data }; 170 | } 171 | callback(); 172 | }); 173 | }, 174 | function (err) { 175 | cb(null, results); 176 | }); 177 | } catch (err) { 178 | console.error(err.stack); 179 | cb(err.stack); 180 | } 181 | }; 182 | 183 | this.checkUrl = function (url, cb) { 184 | try { 185 | $.ajax({ 186 | url: url, 187 | type: 'HEAD', 188 | timeout: this.TIMEOUT_CHECK_URL 189 | 190 | }).success(function (data, textStatus, jqXHR){ 191 | cb(null, { status: jqXHR.status }) 192 | 193 | }).error(function (jqXHR, textStatus, errorThrown) { 194 | cb({ status: jqXHR.status }); 195 | }); 196 | } catch (err) { 197 | console.error(err.stack); 198 | cb(err); 199 | } 200 | }; 201 | 202 | this.isUrlValid = function (url) { 203 | try { 204 | return /^(https?):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(url); 205 | } catch (err) { 206 | console.error(err.stack); 207 | } 208 | }; 209 | 210 | /** 211 | * Returns the url without the number of the post message to be read. 212 | * 213 | * @method removePostMessageNumber 214 | * @param {string} url The url to be manipulated 215 | * @return {string} The url without the number of the post message to be read. 216 | */ 217 | this.removePostMessageNumber = function (url) { 218 | try { 219 | var value = url.split('/'); 220 | value.pop(); 221 | return value.join('/'); 222 | } catch (err) { 223 | console.error(err.stack); 224 | } 225 | }; 226 | }; 227 | -------------------------------------------------------------------------------- /src/js/optionsView.js: -------------------------------------------------------------------------------- 1 | var optionsView = new function () { 2 | 'use strict'; 3 | 4 | var that = this; 5 | 6 | this.ID = 'optionsView'; 7 | this.bg = mediator.getBackgroundPage(); 8 | this.$enableDesktopNotificationsChk; 9 | this.$enableDesktopNotificationsSoundChk; 10 | this.$openPagesBackgroundChk; 11 | this.$playNotificationSoundBtn; 12 | this.$addSourceBtn; 13 | this.$addSourceInput; 14 | this.$sourceSpinner; 15 | this.$sourceOutput; 16 | this.$sourcesList; 17 | this.$version; 18 | this.$fontSizeRange; 19 | this.$fontSizeLbl; 20 | this.$body; 21 | 22 | $(function () { 23 | try { 24 | var value; 25 | that.$body = $('body'); 26 | that.$version = $('#version-lbl'); 27 | that.$version.text('Version ' + mediator.getAppVersion()); 28 | that.$openPagesBackgroundChk = $('#open-pages-background-chk'); 29 | that.$enableDesktopNotificationsChk = $('#desktop-notifications-chk'); 30 | that.$enableDesktopNotificationsSoundChk = $('#desktop-notifications-sound-chk'); 31 | that.$playNotificationSoundBtn = $('#play-notification-sound'); 32 | that.$addSourceBtn = $('#add-source-btn'); 33 | that.$addSourceInput = $('#add-source-input'); 34 | that.$sourcesList = $('#sources-list'); 35 | that.$sourceOutput = $('#source-output-lbl'); 36 | that.$sourceSpinner = $('#source-spinner'); 37 | that.$fontSizeLbl = $('#font-size-lbl'); 38 | that.$fontSizeRange = $('#font-size-range'); 39 | value = that.bg.optionsModel.options.fontSize || that.bg.optionsModel.defaults.fontSize; 40 | that.$fontSizeLbl.text(value); 41 | that.$fontSizeRange.val(value); 42 | that.setFontSize(value); 43 | 44 | that.$addSourceInput.on('keyup', that.onEvtSourceInputKeyup); 45 | that.$openPagesBackgroundChk.on('click', that.onEvtOpenPagesBackgroundClicked); 46 | that.$enableDesktopNotificationsChk.on('click', that.onEvtEnableDesktopNotificationsClicked); 47 | that.$enableDesktopNotificationsSoundChk.on('click', that.onEvtEnableDesktopNotificationsSoundClicked); 48 | that.$playNotificationSoundBtn.on('click', that.onEvtPlayNotificationSound); 49 | that.$addSourceBtn.on('click', that.onEvtAddSource); 50 | that.$sourcesList.on('click', '.remove-source-btn', that.onEvtRemoveSource); 51 | that.$fontSizeRange.on('input', that.onEvtFontSizeRangeInput); 52 | that.$fontSizeRange.on('change', that.onEvtFontSizeRangeChanged); 53 | value = that.bg.optionsModel.options.desktopNotificationsEnabled === undefined ? 54 | that.bg.optionsModel.defaults.desktopNotificationsEnabled : 55 | that.bg.optionsModel.options.desktopNotificationsEnabled; 56 | that.$enableDesktopNotificationsChk.prop('checked', value); 57 | value = that.bg.optionsModel.options.desktopNotificationsSoundEnabled === undefined ? 58 | that.bg.optionsModel.defaults.desktopNotificationsSoundEnabled : 59 | that.bg.optionsModel.options.desktopNotificationsSoundEnabled; 60 | that.$enableDesktopNotificationsSoundChk.prop('checked', value); 61 | value = that.bg.optionsModel.options.openPagesBackgroundEnabled === undefined ? 62 | that.bg.optionsModel.defaults.openPagesBackgroundEnabled : 63 | that.bg.optionsModel.options.openPagesBackgroundEnabled; 64 | that.$openPagesBackgroundChk.prop('checked', value); 65 | that.updateSourcesList(); 66 | } catch (err) { 67 | console.error(err.stack); 68 | } 69 | }); 70 | 71 | this.setFontSize = function (value) { 72 | try { 73 | that.$body.css('font-size', value + 'em'); 74 | } catch (err) { 75 | console.error(err.stack); 76 | } 77 | }; 78 | 79 | this.onEvtFontSizeRangeChanged = function (ev) { 80 | try { 81 | that.setFontSize($(this).val()); 82 | } catch (err) { 83 | console.error(err.stack); 84 | } 85 | }; 86 | 87 | this.onEvtFontSizeRangeInput = function (ev) { 88 | try { 89 | var value = $(this).val(); 90 | that.$fontSizeLbl.text(value); 91 | that.bg.optionsModel.setFontSize(value); 92 | } catch (err) { 93 | console.error(err.stack); 94 | } 95 | }; 96 | 97 | this.onEvtSourceInputKeyup = function (ev) { 98 | try { 99 | if (ev.keyCode === 13) { that.onEvtAddSource(); } 100 | } catch (err) { 101 | console.error(err.stack); 102 | } 103 | }; 104 | 105 | this.onEvtOpenPagesBackgroundClicked = function () { 106 | try { 107 | var value = $(this).prop('checked'); 108 | that.bg.optionsModel.setEnableOpenPagesBackground(value); 109 | } catch (err) { 110 | console.error(err.stack); 111 | } 112 | }; 113 | 114 | this.onEvtEnableDesktopNotificationsClicked = function () { 115 | try { 116 | var value = $(this).prop('checked'); 117 | that.bg.optionsModel.setEnableDesktopNotifications(value); 118 | } catch (err) { 119 | console.error(err.stack); 120 | } 121 | }; 122 | 123 | this.onEvtEnableDesktopNotificationsSoundClicked = function () { 124 | try { 125 | var value = $(this).prop('checked'); 126 | that.bg.optionsModel.setEnableDesktopNotificationsSound(value); 127 | } catch (err) { 128 | console.error(err.stack); 129 | } 130 | }; 131 | 132 | this.blockWaitingSourceInput = function () { 133 | try { 134 | that.$addSourceInput.prop('disabled', true); 135 | $('#add-source-btn').toggle(); 136 | $('#source-spinner').toggle(); 137 | } catch (err) { 138 | console.error(err.stack); 139 | } 140 | }; 141 | 142 | this.unblockWaitingSourceInput = function () { 143 | try { 144 | that.$addSourceInput.prop('disabled', false); 145 | $('#add-source-btn').toggle(); 146 | $('#source-spinner').toggle(); 147 | } catch (err) { 148 | console.error(err.stack); 149 | } 150 | }; 151 | 152 | this.onEvtAddSource = function () { 153 | try { 154 | var checkProtocols = false; 155 | var url = that.$addSourceInput.val(); 156 | 157 | that.$sourceOutput.text(''); 158 | that.blockWaitingSourceInput(); 159 | 160 | if (!url.startsWith('http')) { 161 | checkProtocols = true; 162 | url = 'https://' + url; 163 | } 164 | if (!that.bg.sourceController.isUrlValid(url)) { 165 | that.$sourceOutput.text('invalid url'); 166 | that.unblockWaitingSourceInput(); 167 | return; 168 | } 169 | 170 | that.bg.sourceController.checkUrl(url, function (err, res) { 171 | if (err && !checkProtocols) { 172 | that.$sourceOutput.text('url is unreachable'); 173 | that.unblockWaitingSourceInput(); 174 | } 175 | else if (err && checkProtocols) { 176 | url = url.replace('https://', 'http://'); 177 | that.bg.sourceController.checkUrl(url, function (err, res) { 178 | if (err) { 179 | that.$sourceOutput.text('url is unreachable'); 180 | } 181 | else { 182 | that.bg.optionsModel.addSource(url, that.updateSourcesList); 183 | optionsView.$addSourceInput.val(''); 184 | } 185 | that.unblockWaitingSourceInput(); 186 | }); 187 | } 188 | else if (!err) { 189 | that.bg.optionsModel.addSource(url, that.updateSourcesList); 190 | optionsView.$addSourceInput.val(''); 191 | that.unblockWaitingSourceInput(); 192 | } 193 | }); 194 | } catch (err) { 195 | console.error(err.stack); 196 | that.unblockWaitingSourceInput(); 197 | } 198 | }; 199 | 200 | this.onEvtPlayNotificationSound = function () { 201 | try { 202 | util.playNotificationSound(); 203 | } catch (err) { 204 | console.error(err.stack); 205 | that.unblockWaitingSourceInput(); 206 | } 207 | }; 208 | 209 | this.onEvtRemoveSource = function () { 210 | try { 211 | var url = $(this).data('url'); 212 | that.bg.optionsModel.removeSource(url, that.updateSourcesList); 213 | } catch (err) { 214 | console.error(err.stack); 215 | } 216 | }; 217 | 218 | this.sourceTemplate = function (url) { 219 | try { 220 | return [ 221 | '
', 222 | '', 223 | '', url, '', 224 | '
' 225 | ].join(''); 226 | } catch (err) { 227 | console.error(err.stack); 228 | } 229 | }; 230 | 231 | this.updateSourcesList = function () { 232 | try { 233 | var url; 234 | var html = ''; 235 | for (url in that.bg.optionsModel.options.sources) { 236 | html += that.sourceTemplate(url); 237 | } 238 | that.$sourcesList.html(html); 239 | } catch (err) { 240 | console.error(err.stack); 241 | } 242 | }; 243 | }; 244 | -------------------------------------------------------------------------------- /src/js/Source.js: -------------------------------------------------------------------------------- 1 | var Source = function (url) { 2 | 'use strict'; 3 | 4 | var that = this; 5 | 6 | this.ID = 'Source'; 7 | this.USER_DATA_FAIL_TIMEOUT_POLLING = 15000; 8 | this.url = url; 9 | this.notificationsUrl = [ this.url, '/notifications?', 'recent=true' ].join(''); 10 | this.sourceId = url; 11 | this.userId; 12 | this.username; 13 | this.mb; 14 | this.name; 15 | this.messagesUrl; 16 | this.faviconUrl = [ 'http://www.google.com/s2/favicons?domain=', this.url ].join(''); 17 | this.counter = 0; 18 | this.$dispatcher = $({}); 19 | this.EVT_NEW_NOTIFICATION_ALERT = 'EVT_NEW_NOTIFICATION_ALERT'; 20 | this.EVT_NOTIFICATION_COUNTER_UPDATE = 'EVT_NOTIFICATION_COUNTER_UPDATE'; 21 | this.notificationsErrorMap = { 22 | not_logged_in: 'login to view notifications' 23 | }; 24 | 25 | this.getUserData = function (cb) { 26 | try { 27 | var url = [ this.url, '/session/current.json' ].join(''); 28 | 29 | $.ajax({ 30 | url: url, 31 | type: 'GET', 32 | cache: false, 33 | dataType: 'json' 34 | 35 | }).done(function (data, textStatus, jqXHR) { 36 | try { 37 | if (typeof data === 'object' && 38 | typeof data.current_user === 'object' && 39 | typeof data.current_user.id === 'number' && 40 | typeof data.current_user.username === 'string' && 41 | typeof data.current_user.unread_notifications === 'number' && 42 | typeof data.current_user.unread_private_messages === 'number') { 43 | 44 | that.userId = data.current_user.id; 45 | that.username = data.current_user.username; 46 | that.messagesUrl = [ 47 | that.url, 48 | '/users/', 49 | that.username, 50 | '/messages' 51 | ].join(''); 52 | 53 | that.counter = data.current_user.unread_notifications + data.current_user.unread_private_messages; 54 | that.$dispatcher.trigger(that.EVT_NOTIFICATION_COUNTER_UPDATE); 55 | cb(); 56 | } 57 | else { 58 | cb(new Error('malformed data')); 59 | } 60 | } catch (err) { 61 | console.error(err.stack); 62 | cb(err); 63 | } 64 | }).fail(function (jqXHR, textStatus, errorThrown) { 65 | try { 66 | cb(jqXHR.status); 67 | } catch (err) { 68 | console.error(err.stack); 69 | cb(err); 70 | } 71 | }); 72 | } catch (err) { 73 | console.error(err.stack); 74 | cb(err); 75 | } 76 | }; 77 | 78 | this.getHomePage = function (cb) { 79 | try { 80 | $.ajax({ 81 | url: this.url, 82 | type: 'GET', 83 | dataType: 'html' 84 | 85 | }).done(function (data, textStatus, jqXHR) { 86 | try { 87 | if (typeof data === 'string') { 88 | cb(null, data); 89 | } 90 | else { 91 | cb(new Error('wrong home page data received')); 92 | } 93 | } catch (err) { 94 | console.error(err.stack); 95 | cb(err); 96 | } 97 | }).fail(function (jqXHR, textStatus, errorThrown) { 98 | try { 99 | cb(jqXHR.status); 100 | } catch (err) { 101 | console.error(err.stack); 102 | cb(err); 103 | } 104 | }); 105 | } catch (err) { 106 | console.error(err.stack); 107 | cb(err); 108 | } 109 | }; 110 | 111 | this.extractFaviconUrl = function (data) { 112 | try { 113 | var value = $('link[rel="icon"][type="image/png"]', $('').html(data)).attr('href'); 114 | if (value.indexOf('http://') !== 0 && value.indexOf('https://') !== 0) { 115 | value = this.url + 116 | (value.substring(0, 1) !== '/' ? '/' : '') + 117 | value; 118 | } 119 | return value; 120 | } catch (err) { 121 | console.error(err.stack); 122 | cb(err); 123 | } 124 | }; 125 | 126 | this.extractTitle = function (data) { 127 | try { 128 | return $('title', $('').html(data)).text(); 129 | } catch (err) { 130 | console.error(err.stack); 131 | cb(err); 132 | } 133 | }; 134 | 135 | this.unsubscribeMbAll = function () { 136 | try { 137 | that.mb.unsubscribe('/notification/*'); 138 | that.mb.unsubscribe('/notification-alert/*'); 139 | } catch (err) { 140 | console.error(err.stack); 141 | } 142 | }; 143 | 144 | this.subscribeMbReceiveNotificationsCounters = function () { 145 | try { 146 | var str = [ '/notification/', that.userId ].join(''); 147 | that.mb.subscribe(str, function (data) { 148 | try { 149 | if (typeof data === 'object' && 150 | typeof data.unread_notifications === 'number' && 151 | typeof data.unread_private_messages === 'number') { 152 | 153 | that.counter = data.unread_notifications + data.unread_private_messages; 154 | that.$dispatcher.trigger(that.EVT_NOTIFICATION_COUNTER_UPDATE); 155 | } 156 | else { 157 | throw new Error('malformed data'); 158 | } 159 | } catch (err) { 160 | console.error(err.stack); 161 | } 162 | }); 163 | } catch (err) { 164 | console.error(err.stack); 165 | } 166 | }; 167 | 168 | this.subscribeMbReceiveNotificationsAlert = function () { 169 | try { 170 | var str = [ '/notification-alert/', that.userId ].join(''); 171 | that.mb.subscribe(str, function (data) { 172 | try { 173 | that.$dispatcher.trigger(that.EVT_NEW_NOTIFICATION_ALERT, { sourceId: that.sourceId, data: data }); 174 | } catch (err) { 175 | console.error(err.stack); 176 | } 177 | }); 178 | } catch (err) { 179 | console.error(err.stack); 180 | } 181 | }; 182 | 183 | this.stopReceiveMbUpdates = function () { 184 | try { 185 | that.mb.stop(); 186 | } catch (err) { 187 | console.error(err.stack); 188 | } 189 | }; 190 | 191 | this.startReceiveMbUpdates = function () { 192 | try { 193 | that.mb.start(); 194 | } catch (err) { 195 | console.error(err.stack); 196 | } 197 | }; 198 | 199 | this.getNotifications = function (cb) { 200 | try { 201 | var options = { 202 | credentials: 'include', 203 | headers: { 204 | 'Accept': 'application/json' 205 | } 206 | }; 207 | var req = fetch(that.notificationsUrl, options); 208 | req.then(function (res) { 209 | if (res.json) { 210 | res.json().then(function (data) { 211 | if (typeof data === 'object' && 212 | data.notifications && 213 | data.notifications instanceof Array === true) { 214 | 215 | cb(null, data.notifications); 216 | } 217 | else if (typeof data === 'object' && 218 | typeof data.error_type === 'string') { 219 | 220 | cb(that.notificationsErrorMap[data.error_type] ? that.notificationsErrorMap[data.error_type] : data.error_type); 221 | } 222 | else { 223 | cb('unknown data received'); 224 | } 225 | }); 226 | } 227 | else { 228 | cb('incomplete response received'); 229 | } 230 | }); 231 | req.catch(function (err) { 232 | cb('network request failed'); 233 | }); 234 | } catch (err) { 235 | console.error(err.stack); 236 | cb('cannot get notifications'); 237 | } 238 | }; 239 | 240 | (function init () { 241 | try { 242 | that.getHomePage(function (err, data) { 243 | if (err) { 244 | console.error(err); 245 | } 246 | else { 247 | that.faviconUrl = that.extractFaviconUrl(data); 248 | that.name = that.extractTitle(data); 249 | } 250 | }); 251 | that.getUserData(function (err) { 252 | if (err === 404) { 253 | setTimeout(function () { init(); }, that.USER_DATA_FAIL_TIMEOUT_POLLING); 254 | } 255 | else { 256 | that.mb = MyMessageBus(window, document); 257 | that.mb.baseUrl = [ that.url, '/' ].join(''); 258 | that.mb.start(); 259 | that.subscribeMbReceiveNotificationsCounters(); 260 | that.subscribeMbReceiveNotificationsAlert(); 261 | } 262 | }); 263 | } catch (err) { 264 | console.error(err.stack); 265 | } 266 | })(); 267 | }; 268 | -------------------------------------------------------------------------------- /lib/async.js: -------------------------------------------------------------------------------- 1 | !function(){function n(){}function t(n){return n}function e(n){return!!n}function r(n){return!n}function u(n){return function(){if(null===n)throw new Error("Callback was already called.");n.apply(this,arguments),n=null}}function i(n){return function(){null!==n&&(n.apply(this,arguments),n=null)}}function o(n){return U(n)||"number"==typeof n.length&&n.length>=0&&n.length%1===0}function c(n,t){return o(n)?a(n,t):p(n,t)}function a(n,t){for(var e=-1,r=n.length;++er?r:null}):(e=B(n),t=e.length,function(){return r++,t>r?e[r]:null})}function y(n,t){return t=null==t?n.length-1:+t,function(){for(var e=Math.max(arguments.length-t,0),r=Array(e),u=0;e>u;u++)r[u]=arguments[u+t];switch(t){case 0:return n.call(this,r);case 1:return n.call(this,arguments[0],r)}}}function v(n){return function(t,e,r){return n(t,r)}}function d(t){return function(e,r,o){o=i(o||n),e=e||[];var c=m(e);if(0>=t)return o(null);var a=!1,f=0,l=!1;!function s(){if(a&&0>=f)return o(null);for(;t>f&&!l;){var n=c();if(null===n)return a=!0,void(0>=f&&o(null));f+=1,r(e[n],n,u(function(n){f-=1,n?(o(n),l=!0):s()}))}}()}}function g(n){return function(t,e,r){return n(P.eachOf,t,e,r)}}function k(n){return function(t,e,r,u){return n(d(e),t,r,u)}}function b(n){return function(t,e,r){return n(P.eachOfSeries,t,e,r)}}function w(t,e,r,u){u=i(u||n);var o=[];t(e,function(n,t,e){r(n,function(n,r){o[t]=r,e(n)})},function(n){u(n,o)})}function O(n,t,e,r){var u=[];n(t,function(n,t,r){e(n,function(e){e&&u.push({index:t,value:n}),r()})},function(){r(f(u.sort(function(n,t){return n.index-t.index}),function(n){return n.value}))})}function S(n,t,e,r){O(n,t,function(n,t){e(n,function(n){t(!n)})},r)}function E(n,t,e){return function(r,u,i,o){function c(){o&&o(e(!1,void 0))}function a(n,r,u){return o?void i(n,function(r){o&&t(r)&&(o(e(!0,n)),o=i=!1),u()}):u()}arguments.length>3?n(r,u,a,c):(o=i,i=u,n(r,a,c))}}function x(n,t){return t}function L(t,e,r){r=r||n;var u=o(e)?[]:{};t(e,function(n,t,e){n(y(function(n,r){r.length<=1&&(r=r[0]),u[t]=r,e(n)}))},function(n){r(n,u)})}function j(n,t,e,r){var u=[];n(t,function(n,t,r){e(n,function(n,t){u=u.concat(t||[]),r(n)})},function(n){r(n,u)})}function I(t,e,r){function i(t,e,r,u){if(null!=u&&"function"!=typeof u)throw new Error("task callback must be a function");return t.started=!0,U(e)||(e=[e]),0===e.length&&t.idle()?P.setImmediate(function(){t.drain()}):(a(e,function(e){var i={data:e,callback:u||n};r?t.tasks.unshift(i):t.tasks.push(i),t.tasks.length===t.concurrency&&t.saturated()}),void P.setImmediate(t.process))}function o(n,t){return function(){c-=1;var e=arguments;a(t,function(n){n.callback.apply(n,e)}),n.tasks.length+c===0&&n.drain(),n.process()}}if(null==e)e=1;else if(0===e)throw new Error("Concurrency must not be zero");var c=0,l={tasks:[],concurrency:e,payload:r,saturated:n,empty:n,drain:n,started:!1,paused:!1,push:function(n,t){i(l,n,!1,t)},kill:function(){l.drain=n,l.tasks=[]},unshift:function(n,t){i(l,n,!0,t)},process:function(){if(!l.paused&&c=t;t++)P.setImmediate(l.process)}}};return l}function T(n){return y(function(t,e){t.apply(null,e.concat([y(function(t,e){"object"==typeof console&&(t?console.error&&console.error(t):console[n]&&a(e,function(t){console[n](t)}))})]))})}function A(n){return function(t,e,r){n(l(t),e,r)}}function z(n){return y(function(t,e){var r=y(function(e){var r=this,u=e.pop();return n(t,function(n,t,u){n.apply(r,e.concat([u]))},u)});return e.length?r.apply(this,e):r})}function q(n){return y(function(t){var e=t.pop();t.push(function(){var n=arguments;r?P.setImmediate(function(){e.apply(null,n)}):e.apply(null,n)});var r=!0;n.apply(this,t),r=!1})}var C,P={},H="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||this;null!=H&&(C=H.async),P.noConflict=function(){return H.async=C,P};var M=Object.prototype.toString,U=Array.isArray||function(n){return"[object Array]"===M.call(n)},W=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},B=Object.keys||function(n){var t=[];for(var e in n)n.hasOwnProperty(e)&&t.push(e);return t},D="function"==typeof setImmediate&&setImmediate,F=D?function(n){D(n)}:function(n){setTimeout(n,0)};"object"==typeof process&&"function"==typeof process.nextTick?P.nextTick=process.nextTick:P.nextTick=F,P.setImmediate=D?F:P.nextTick,P.forEach=P.each=function(n,t,e){return P.eachOf(n,v(t),e)},P.forEachSeries=P.eachSeries=function(n,t,e){return P.eachOfSeries(n,v(t),e)},P.forEachLimit=P.eachLimit=function(n,t,e,r){return d(t)(n,v(e),r)},P.forEachOf=P.eachOf=function(t,e,r){function a(n){n?r(n):(l+=1,l>=f&&r(null))}r=i(r||n),t=t||[];var f=o(t)?t.length:B(t).length,l=0;return f?void c(t,function(n,r){e(t[r],r,u(a))}):r(null)},P.forEachOfSeries=P.eachOfSeries=function(t,e,r){function o(){var n=!0;return null===a?r(null):(e(t[a],a,u(function(t){if(t)r(t);else{if(a=c(),null===a)return r(null);n?P.nextTick(o):o()}})),void(n=!1))}r=i(r||n),t=t||[];var c=m(t),a=c();o()},P.forEachOfLimit=P.eachOfLimit=function(n,t,e,r){d(t)(n,e,r)},P.map=g(w),P.mapSeries=b(w),P.mapLimit=k(w),P.inject=P.foldl=P.reduce=function(n,t,e,r){P.eachOfSeries(n,function(n,r,u){e(t,n,function(n,e){t=e,u(n)})},function(n){r(n||null,t)})},P.foldr=P.reduceRight=function(n,e,r,u){var i=f(n,t).reverse();P.reduce(i,e,r,u)},P.select=P.filter=g(O),P.selectLimit=P.filterLimit=k(O),P.selectSeries=P.filterSeries=b(O),P.reject=g(S),P.rejectLimit=k(S),P.rejectSeries=b(S),P.any=P.some=E(P.eachOf,e,t),P.someLimit=E(P.eachOfLimit,e,t),P.all=P.every=E(P.eachOf,r,r),P.everyLimit=E(P.eachOfLimit,r,r),P.detect=E(P.eachOf,t,x),P.detectSeries=E(P.eachOfSeries,t,x),P.detectLimit=E(P.eachOfLimit,t,x),P.sortBy=function(n,t,e){function r(n,t){var e=n.criteria,r=t.criteria;return r>e?-1:e>r?1:0}P.map(n,function(n,e){t(n,function(t,r){t?e(t):e(null,{value:n,criteria:r})})},function(n,t){return n?e(n):void e(null,f(t.sort(r),function(n){return n.value}))})},P.auto=function(t,e){function r(n){m.unshift(n)}function u(n){var t=h(m,n);t>=0&&m.splice(t,1)}function o(){f--,a(m.slice(0),function(n){n()})}e=i(e||n);var c=B(t),f=c.length;if(!f)return e(null);var l={},m=[];r(function(){f||e(null,l)}),a(c,function(n){function i(){return s(v,function(n,t){return n&&l.hasOwnProperty(t)},!0)&&!l.hasOwnProperty(n)}function c(){i()&&(u(c),f[f.length-1](m,l))}for(var a,f=U(t[n])?t[n]:[t[n]],m=y(function(t,r){if(r.length<=1&&(r=r[0]),t){var u={};p(l,function(n,t){u[t]=n}),u[n]=r,e(t,u)}else l[n]=r,P.setImmediate(o)}),v=f.slice(0,f.length-1),d=v.length;d--;){if(!(a=t[v[d]]))throw new Error("Has inexistant dependency");if(U(a)&&h(a,n)>=0)throw new Error("Has cyclic dependencies")}i()?f[f.length-1](m,l):r(c)})},P.retry=function(n,t,e){function r(n,t){if("number"==typeof t)n.times=parseInt(t,10)||i;else{if("object"!=typeof t)throw new Error("Unsupported argument type for 'times': "+typeof t);n.times=parseInt(t.times,10)||i,n.interval=parseInt(t.interval,10)||o}}function u(n,t){function e(n,e){return function(r){n(function(n,t){r(!n||e,{err:n,result:t})},t)}}function r(n){return function(t){setTimeout(function(){t(null)},n)}}for(;a.times;){var u=!(a.times-=1);c.push(e(a.task,u)),!u&&a.interval>0&&c.push(r(a.interval))}P.series(c,function(t,e){e=e[e.length-1],(n||a.callback)(e.err,e.result)})}var i=5,o=0,c=[],a={times:i,interval:o},f=arguments.length;if(1>f||f>3)throw new Error("Invalid arguments - must be either (task), (task, callback), (times, task) or (times, task, callback)");return 2>=f&&"function"==typeof n&&(e=t,t=n),"function"!=typeof n&&r(a,n),a.callback=e,a.task=t,a.callback?u():u},P.waterfall=function(t,e){function r(n){return y(function(t,u){if(t)e.apply(null,[t].concat(u));else{var i=n.next();i?u.push(r(i)):u.push(e),q(n).apply(null,u)}})}if(e=i(e||n),!U(t)){var u=new Error("First argument to waterfall must be an array of functions");return e(u)}return t.length?void r(P.iterator(t))():e()},P.parallel=function(n,t){L(P.eachOf,n,t)},P.parallelLimit=function(n,t,e){L(d(t),n,e)},P.series=function(n,t){L(P.eachOfSeries,n,t)},P.iterator=function(n){function t(e){function r(){return n.length&&n[e].apply(null,arguments),r.next()}return r.next=function(){return er;){var i=r+(u-r+1>>>1);e(t,n[i])>=0?r=i:u=i-1}return r}function i(t,e,i,o){if(null!=o&&"function"!=typeof o)throw new Error("task callback must be a function");return t.started=!0,U(e)||(e=[e]),0===e.length?P.setImmediate(function(){t.drain()}):void a(e,function(e){var c={data:e,priority:i,callback:"function"==typeof o?o:n};t.tasks.splice(u(t.tasks,c,r)+1,0,c),t.tasks.length===t.concurrency&&t.saturated(),P.setImmediate(t.process)})}var o=P.queue(t,e);return o.push=function(n,t,e){i(o,n,t,e)},delete o.unshift,o},P.cargo=function(n,t){return I(n,1,t)},P.log=T("log"),P.dir=T("dir"),P.memoize=function(n,e){var r={},u={};e=e||t;var i=y(function(t){var i=t.pop(),o=e.apply(null,t);o in r?P.nextTick(function(){i.apply(null,r[o])}):o in u?u[o].push(i):(u[o]=[i],n.apply(null,t.concat([y(function(n){r[o]=n;var t=u[o];delete u[o];for(var e=0,i=t.length;i>e;e++)t[e].apply(null,n)})])))});return i.memo=r,i.unmemoized=n,i},P.unmemoize=function(n){return function(){return(n.unmemoized||n).apply(null,arguments)}},P.times=A(P.map),P.timesSeries=A(P.mapSeries),P.timesLimit=function(n,t,e,r){return P.mapLimit(l(n),t,e,r)},P.seq=function(){var t=arguments;return y(function(e){var r=this,u=e[e.length-1];"function"==typeof u?e.pop():u=n,P.reduce(t,e,function(n,t,e){t.apply(r,n.concat([y(function(n,t){e(n,t)})]))},function(n,t){u.apply(r,[n].concat(t))})})},P.compose=function(){return P.seq.apply(null,Array.prototype.reverse.call(arguments))},P.applyEach=z(P.eachOf),P.applyEachSeries=z(P.eachOfSeries),P.forever=function(t,e){function r(n){return n?i(n):void o(r)}var i=u(e||n),o=q(t);r()},P.ensureAsync=q,P.constant=y(function(n){var t=[null].concat(n);return function(n){return n.apply(this,t)}}),P.wrapSync=P.asyncify=function(n){return y(function(t){var e,r=t.pop();try{e=n.apply(this,t)}catch(u){return r(u)}W(e)&&"function"==typeof e.then?e.then(function(n){r(null,n)})["catch"](function(n){r(n.message?n:new Error(n))}):r(null,e)})},"object"==typeof module&&module.exports?module.exports=P:"function"==typeof define&&define.amd?define([],function(){return P}):H.async=P}(); 2 | //# sourceMappingURL=async.min.map -------------------------------------------------------------------------------- /lib/message-bus.js: -------------------------------------------------------------------------------- 1 | /*jshint bitwise: false*/ 2 | // (function(global, document, undefined) { 3 | var MyMessageBus = function(global, document, undefined) { 4 | 'use strict'; 5 | var previousMessageBus = global.MessageBus; 6 | 7 | // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript 8 | var callbacks, clientId, failCount, shouldLongPoll, queue, responseCallbacks, uniqueId, baseUrl; 9 | var me, started, stopped, longPoller, pollTimeout, paused, later, jQuery, interval, chunkedBackoff; 10 | 11 | uniqueId = function() { 12 | return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) { 13 | var r, v; 14 | r = Math.random() * 16 | 0; 15 | v = c === 'x' ? r : (r & 0x3 | 0x8); 16 | return v.toString(16); 17 | }); 18 | }; 19 | 20 | clientId = uniqueId(); 21 | responseCallbacks = {}; 22 | callbacks = []; 23 | queue = []; 24 | interval = null; 25 | failCount = 0; 26 | baseUrl = "/"; 27 | paused = false; 28 | later = []; 29 | chunkedBackoff = 0; 30 | jQuery = global.jQuery; 31 | var hiddenProperty; 32 | 33 | (function(){ 34 | var prefixes = ["","webkit","ms","moz"]; 35 | for(var i=0; i 0) { 120 | chunkedBackoff--; 121 | chunked = false; 122 | } 123 | 124 | var headers = { 125 | 'X-SILENCE-LOGGER': 'true' 126 | }; 127 | for (var name in me.headers){ 128 | headers[name] = me.headers[name]; 129 | } 130 | 131 | if (!chunked){ 132 | headers["Dont-Chunk"] = 'true'; 133 | } 134 | 135 | var dataType = chunked ? "text" : "json"; 136 | 137 | var handle_progress = function(payload, position) { 138 | 139 | var separator = "\r\n|\r\n"; 140 | var endChunk = payload.indexOf(separator, position); 141 | 142 | if (endChunk === -1) { 143 | return position; 144 | } 145 | 146 | var chunk = payload.substring(position, endChunk); 147 | chunk = chunk.replace(/\r\n\|\|\r\n/g, separator); 148 | 149 | try { 150 | reqSuccess(JSON.parse(chunk)); 151 | } catch(e) { 152 | if (console.log) { 153 | console.log("FAILED TO PARSE CHUNKED REPLY"); 154 | console.log(data); 155 | } 156 | } 157 | 158 | return handle_progress(payload, endChunk + separator.length); 159 | } 160 | 161 | var disableChunked = function(){ 162 | if (me.longPoll) { 163 | me.longPoll.abort(); 164 | chunkedBackoff = 30; 165 | } 166 | }; 167 | 168 | var setOnProgressListener = function(xhr) { 169 | var position = 0; 170 | // if it takes longer than 3000 ms to get first chunk, we have some proxy 171 | // this is messing with us, so just backoff from using chunked for now 172 | var chunkedTimeout = setTimeout(disableChunked,3000); 173 | xhr.onprogress = function () { 174 | clearTimeout(chunkedTimeout); 175 | if(xhr.getResponseHeader('Content-Type') === 'application/json; charset=utf-8') { 176 | // not chunked we are sending json back 177 | chunked = false; 178 | return; 179 | } 180 | position = handle_progress(xhr.responseText, position); 181 | } 182 | }; 183 | if (!me.ajax){ 184 | throw new Error("Either jQuery or the ajax adapter must be loaded"); 185 | } 186 | var req = me.ajax({ 187 | url: me.baseUrl + "message-bus/" + me.clientId + "/poll" + (!longPoll ? "?dlp=t" : ""), 188 | data: data, 189 | cache: false, 190 | async: true, 191 | dataType: dataType, 192 | type: 'POST', 193 | headers: headers, 194 | messageBus: { 195 | chunked: chunked, 196 | onProgressListener: function(xhr) { 197 | var position = 0; 198 | // if it takes longer than 3000 ms to get first chunk, we have some proxy 199 | // this is messing with us, so just backoff from using chunked for now 200 | var chunkedTimeout = setTimeout(disableChunked,3000); 201 | return xhr.onprogress = function () { 202 | clearTimeout(chunkedTimeout); 203 | if(xhr.getResponseHeader('Content-Type') === 'application/json; charset=utf-8') { 204 | chunked = false; // not chunked, we are sending json back 205 | } else { 206 | position = handle_progress(xhr.responseText, position); 207 | } 208 | } 209 | } 210 | }, 211 | xhr: function() { 212 | var xhr = jQuery.ajaxSettings.xhr(); 213 | if (!chunked) { 214 | return xhr; 215 | } 216 | this.messageBus.onProgressListener(xhr); 217 | return xhr; 218 | }, 219 | success: function(messages) { 220 | if (!chunked) { 221 | // we may have requested text so jQuery will not parse 222 | if (typeof(messages) === "string") { 223 | messages = JSON.parse(messages); 224 | } 225 | gotData = reqSuccess(messages); 226 | } 227 | }, 228 | error: function(xhr, textStatus, err) { 229 | if(textStatus === "abort") { 230 | aborted = true; 231 | } else { 232 | failCount += 1; 233 | totalAjaxFailures += 1; 234 | } 235 | }, 236 | complete: function() { 237 | var interval; 238 | try { 239 | if (gotData || aborted) { 240 | interval = 100; 241 | } else { 242 | interval = me.callbackInterval; 243 | if (failCount > 2) { 244 | interval = interval * failCount; 245 | } else if (!shouldLongPoll()) { 246 | interval = me.backgroundCallbackInterval; 247 | } 248 | if (interval > me.maxPollInterval) { 249 | interval = me.maxPollInterval; 250 | } 251 | 252 | interval -= (new Date() - lastAjax); 253 | 254 | if (interval < 100) { 255 | interval = 100; 256 | } 257 | } 258 | } catch(e) { 259 | if(console.log && e.message) { 260 | console.log("MESSAGE BUS FAIL: " + e.message); 261 | } 262 | } 263 | 264 | pollTimeout = setTimeout(function(){pollTimeout=null; poll();}, interval); 265 | me.longPoll = null; 266 | } 267 | }); 268 | 269 | return req; 270 | }; 271 | 272 | me = { 273 | enableChunkedEncoding: true, 274 | enableLongPolling: true, 275 | callbackInterval: 15000, 276 | backgroundCallbackInterval: 60000, 277 | maxPollInterval: 3 * 60 * 1000, 278 | callbacks: callbacks, 279 | clientId: clientId, 280 | alwaysLongPoll: false, 281 | baseUrl: baseUrl, 282 | headers: {}, 283 | ajax: (jQuery && jQuery.ajax), 284 | noConflict: function(){ 285 | global.MessageBus = global.MessageBus.previousMessageBus; 286 | return this; 287 | }, 288 | diagnostics: function(){ 289 | console.log("Stopped: " + stopped + " Started: " + started); 290 | console.log("Current callbacks"); 291 | console.log(callbacks); 292 | console.log("Total ajax calls: " + totalAjaxCalls + " Recent failure count: " + failCount + " Total failures: " + totalAjaxFailures); 293 | console.log("Last ajax call: " + (new Date() - lastAjax) / 1000 + " seconds ago") ; 294 | }, 295 | 296 | pause: function() { 297 | paused = true; 298 | }, 299 | 300 | resume: function() { 301 | paused = false; 302 | processMessages(later); 303 | later = []; 304 | }, 305 | 306 | stop: function() { 307 | stopped = true; 308 | started = false; 309 | }, 310 | 311 | // Start polling 312 | start: function() { 313 | var poll, delayPollTimeout; 314 | 315 | if (started) return; 316 | started = true; 317 | stopped = false; 318 | 319 | poll = function() { 320 | var data; 321 | 322 | if(stopped) { 323 | return; 324 | } 325 | 326 | if (callbacks.length === 0) { 327 | if(!delayPollTimeout) { 328 | delayPollTimeout = setTimeout(function(){ delayPollTimeout = null; poll();}, 500); 329 | } 330 | return; 331 | } 332 | 333 | data = {}; 334 | for (var i=0;i=0; i--) { 404 | 405 | var callback = callbacks[i]; 406 | var keep; 407 | 408 | if (glob) { 409 | keep = callback.channel.substr(0, channel.length) !== channel; 410 | } else { 411 | keep = callback.channel !== channel; 412 | } 413 | 414 | if(!keep && func && callback.func !== func){ 415 | keep = true; 416 | } 417 | 418 | if (!keep) { 419 | callbacks.splice(i,1); 420 | removed = true; 421 | } 422 | } 423 | 424 | if (removed && me.longPoll) { 425 | me.longPoll.abort(); 426 | } 427 | 428 | return removed; 429 | } 430 | }; 431 | global.MessageBus = me; 432 | return me; 433 | // })(window, document); 434 | }; 435 | -------------------------------------------------------------------------------- /src/css/fontawesome/css/font-awesome.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome 4.3.0 by @davegandy - http://fontawesome.io - @fontawesome 3 | * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) 4 | */@font-face{font-family:'FontAwesome';src:url('../fonts/fontawesome-webfont.eot?v=4.3.0');src:url('../fonts/fontawesome-webfont.eot?#iefix&v=4.3.0') format('embedded-opentype'),url('../fonts/fontawesome-webfont.woff2?v=4.3.0') format('woff2'),url('../fonts/fontawesome-webfont.woff?v=4.3.0') format('woff'),url('../fonts/fontawesome-webfont.ttf?v=4.3.0') format('truetype'),url('../fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transform:translate(0, 0)}.fa-lg{font-size:1.33333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.28571429em;text-align:center}.fa-ul{padding-left:0;margin-left:2.14285714em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.14285714em;width:2.14285714em;top:.14285714em;text-align:center}.fa-li.fa-lg{left:-1.85714286em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);-webkit-transform:scale(-1, 1);-ms-transform:scale(-1, 1);transform:scale(-1, 1)}.fa-flip-vertical{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1);-webkit-transform:scale(1, -1);-ms-transform:scale(1, -1);transform:scale(1, -1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before,.fa-gratipay:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-genderless:before,.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}.fa-buysellads:before{content:"\f20d"}.fa-connectdevelop:before{content:"\f20e"}.fa-dashcube:before{content:"\f210"}.fa-forumbee:before{content:"\f211"}.fa-leanpub:before{content:"\f212"}.fa-sellsy:before{content:"\f213"}.fa-shirtsinbulk:before{content:"\f214"}.fa-simplybuilt:before{content:"\f215"}.fa-skyatlas:before{content:"\f216"}.fa-cart-plus:before{content:"\f217"}.fa-cart-arrow-down:before{content:"\f218"}.fa-diamond:before{content:"\f219"}.fa-ship:before{content:"\f21a"}.fa-user-secret:before{content:"\f21b"}.fa-motorcycle:before{content:"\f21c"}.fa-street-view:before{content:"\f21d"}.fa-heartbeat:before{content:"\f21e"}.fa-venus:before{content:"\f221"}.fa-mars:before{content:"\f222"}.fa-mercury:before{content:"\f223"}.fa-transgender:before{content:"\f224"}.fa-transgender-alt:before{content:"\f225"}.fa-venus-double:before{content:"\f226"}.fa-mars-double:before{content:"\f227"}.fa-venus-mars:before{content:"\f228"}.fa-mars-stroke:before{content:"\f229"}.fa-mars-stroke-v:before{content:"\f22a"}.fa-mars-stroke-h:before{content:"\f22b"}.fa-neuter:before{content:"\f22c"}.fa-facebook-official:before{content:"\f230"}.fa-pinterest-p:before{content:"\f231"}.fa-whatsapp:before{content:"\f232"}.fa-server:before{content:"\f233"}.fa-user-plus:before{content:"\f234"}.fa-user-times:before{content:"\f235"}.fa-hotel:before,.fa-bed:before{content:"\f236"}.fa-viacoin:before{content:"\f237"}.fa-train:before{content:"\f238"}.fa-subway:before{content:"\f239"}.fa-medium:before{content:"\f23a"} -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | 676 | --------------------------------------------------------------------------------