mirror of
https://bitbucket.org/skobkin/chrome_point_plus.git
synced 2024-12-28 17:24:20 +00:00
getVersion() removed. options.js now not including to the page. Manifect fix. New version detect implementation in background.js.
This commit is contained in:
parent
fa5c12539e
commit
1820146431
|
@ -40,7 +40,7 @@ function injectJS(tabId, files, onAllInjected) {
|
|||
// Message listener
|
||||
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
|
||||
// @todo Check if sender.tab may be undefined in some cases
|
||||
console.log('Received message from tab #%i: %O', sender.tab.id, message);
|
||||
console.log('Received message from tab #%s: %O', sender.tab ? sender.tab.id : 'undefined', message);
|
||||
|
||||
if (message) {
|
||||
switch (message.type) {
|
||||
|
@ -74,6 +74,11 @@ chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
|
|||
return true;
|
||||
break;
|
||||
|
||||
case 'getManifestVersion':
|
||||
sendResponse({version: getVersion()});
|
||||
return true;
|
||||
break;
|
||||
|
||||
case 'listenNotificationClicks':
|
||||
// Adding notification click event listener
|
||||
chrome.notifications.onClicked.addListener(function(notificationId) {
|
||||
|
@ -186,7 +191,12 @@ chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
|
|||
});
|
||||
|
||||
// Getting version from manifest.json
|
||||
function getVersion() {
|
||||
function getVersion() {
|
||||
/**
|
||||
* @deprecated XMLHttpRequest in the background worker is deprecated
|
||||
* according to the Chrome warning. But we definitely need synchronous
|
||||
* AJAX here
|
||||
*/
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', chrome.extension.getURL('manifest.json'), false);
|
||||
xhr.send(null);
|
||||
|
|
|
@ -1,19 +1,3 @@
|
|||
/**
|
||||
* Получает версию настроек из манифеста
|
||||
* @returns {String} Версия настроек
|
||||
*/
|
||||
function getVersion() {
|
||||
var xhr = new XMLHttpRequest(),
|
||||
manifest;
|
||||
|
||||
xhr.open('GET', chrome.extension.getURL('manifest.json'), false);
|
||||
xhr.send(null);
|
||||
|
||||
manifest = JSON.parse(xhr.responseText);
|
||||
|
||||
return manifest.version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Объект, управляющий сохранением настроек на странице настроек
|
||||
*
|
||||
|
@ -21,14 +5,20 @@ function getVersion() {
|
|||
* @constructor
|
||||
*/
|
||||
function Options() {
|
||||
this.version = getVersion();
|
||||
this.form = document.querySelector('form');
|
||||
|
||||
this.showVersion();
|
||||
this.restore();
|
||||
|
||||
this.form.addEventListener('change', this._onChange.bind(this));
|
||||
this.listenTabs();
|
||||
|
||||
chrome.runtime.sendMessage(null, {
|
||||
type: 'getManifestVersion'
|
||||
}, null, function(response) {
|
||||
this.version = response.version || 'undefined';
|
||||
|
||||
this.showVersion();
|
||||
this.restore();
|
||||
|
||||
this.form.addEventListener('change', this._onChange.bind(this));
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,6 +5,7 @@ chrome.runtime.sendMessage({
|
|||
console.debug('showPageAction response: %O', response);
|
||||
});
|
||||
|
||||
// @todo Move OptionsManager to the separate file
|
||||
/**
|
||||
* Объект для получения опций
|
||||
* @param {Object} options Хеш настроек
|
||||
|
@ -43,10 +44,18 @@ OptionsManager.prototype.getOptions = function() {
|
|||
return this._options;
|
||||
};
|
||||
|
||||
var ppVersion;
|
||||
|
||||
chrome.runtime.sendMessage(null, {
|
||||
type: 'getManifestVersion'
|
||||
}, null, function(response) {
|
||||
ppVersion = response.version || 'undefined';
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
// Grouping console log
|
||||
console.group('point-plus');
|
||||
console.info('Point+ %s', getVersion());
|
||||
console.info('Point+ %s', ppVersion);
|
||||
|
||||
// Проверяем, загрузились ли мы
|
||||
var point_plus_debug = $('#point-plus-debug');
|
||||
|
@ -55,8 +64,8 @@ $(document).ready(function() {
|
|||
return;
|
||||
}
|
||||
$('<div id="point-plus-debug">').attr({
|
||||
'data-point-plus-version': getVersion()
|
||||
}).text('Point+ ' + getVersion() + ' loading...')
|
||||
'data-point-plus-version': ppVersion
|
||||
}).text('Point+ ' + ppVersion + ' loading...')
|
||||
.insertBefore('#user-menu-cb');
|
||||
|
||||
// Черновики. Ставим хандлер и восстанавливаем предыдущее состояние
|
||||
|
|
|
@ -29,10 +29,8 @@
|
|||
"js": [
|
||||
"vendor/jquery/jquery.min.js",
|
||||
|
||||
"js/markitup/sets/markdown/set.js",
|
||||
|
||||
"js/bquery_ajax.js",
|
||||
"js/options.js",
|
||||
|
||||
"js/point-plus.js"
|
||||
],
|
||||
"css": [
|
||||
|
@ -57,6 +55,7 @@
|
|||
"http://player.soundcloud.com/*",
|
||||
"https://player.soundcloud.com/*",
|
||||
"https://api.kanaria.ru/point/*",
|
||||
"https://*.twitter.com/*",
|
||||
"storage",
|
||||
"notifications",
|
||||
"tabs"
|
||||
|
|
Loading…
Reference in a new issue