mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2025-07-10 08:12:21 +03:00
live updates for date
This commit is contained in:
parent
a4b83d100c
commit
6c2b2eba30
|
@ -1,22 +1,30 @@
|
|||
function setStatusTo(msg) {
|
||||
'use strict';
|
||||
|
||||
renderPage();
|
||||
|
||||
function renderPage() {
|
||||
console.log('Rendering started.');
|
||||
|
||||
function setStatusTo(msg) {
|
||||
var status = document.querySelector('#status');
|
||||
if (msg) {
|
||||
status.classList.remove('off');
|
||||
status.innerHTML = msg;
|
||||
} else
|
||||
status.classList.add('off');
|
||||
}
|
||||
}
|
||||
|
||||
chrome.runtime.getBackgroundPage( backgroundPage => {
|
||||
chrome.runtime.getBackgroundPage( backgroundPage => {
|
||||
|
||||
var antiCensorRu = backgroundPage.antiCensorRu;
|
||||
|
||||
// DATE
|
||||
// SET DATE
|
||||
|
||||
var dateForUser = 'неизвестно';
|
||||
function setDate() {
|
||||
var dateForUser = '...';
|
||||
if( antiCensorRu.lastPacUpdateStamp ) {
|
||||
var diff = Date.now() - antiCensorRu.lastPacUpdateStamp;
|
||||
var units = ' мс'
|
||||
var units = ' мс';
|
||||
var gauges = [
|
||||
[1000, ' с'],
|
||||
[60, ' мин'],
|
||||
|
@ -39,8 +47,12 @@ chrome.runtime.getBackgroundPage( backgroundPage => {
|
|||
var dateElement = document.querySelector('.update-date');
|
||||
dateElement.innerText = dateForUser;
|
||||
dateElement.title = new Date(antiCensorRu.lastPacUpdateStamp).toLocaleString('ru-RU');
|
||||
}
|
||||
|
||||
// CLOSE
|
||||
setDate();
|
||||
chrome.storage.onChanged.addListener( setDate );
|
||||
|
||||
// CLOSE BUTTON
|
||||
|
||||
document.querySelector('.close-button').onclick = () => window.close();
|
||||
|
||||
|
@ -94,7 +106,9 @@ chrome.runtime.getBackgroundPage( backgroundPage => {
|
|||
|
||||
setStatusTo('');
|
||||
checkChosenProvider();
|
||||
if (antiCensorRu.ifNotInstalled)
|
||||
if (antiCensorRu.ifFirstInstall)
|
||||
triggerChosenProvider();
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
|
|
@ -49,7 +49,10 @@ window.antiCensorRu = {
|
|||
|
||||
get pacProvider() { return this.pacProviders[this.currentPacProviderKey] },
|
||||
|
||||
ifNotInstalled: true,
|
||||
/*
|
||||
Offer PAC choice if this is the first time extension was installed.
|
||||
*/
|
||||
ifFirstInstall: true,
|
||||
|
||||
// PROTECTED
|
||||
|
||||
|
@ -60,7 +63,7 @@ window.antiCensorRu = {
|
|||
if (Object.getOwnPropertyDescriptor(this, key).writable && typeof(this[key]) !== 'function')
|
||||
onlySettable[key] = this[key]
|
||||
|
||||
return chrome.storage.local.set(onlySettable, () => cb(chrome.runtime.lastError, onlySettable) );
|
||||
return chrome.storage.local.set(onlySettable, () => cb && cb(chrome.runtime.lastError, onlySettable) );
|
||||
},
|
||||
|
||||
pullFromStorage(cb) {
|
||||
|
@ -85,7 +88,7 @@ window.antiCensorRu = {
|
|||
updatePacProxyIps(
|
||||
this.pacProvider,
|
||||
() => {
|
||||
this.ifNotInstalled = false;
|
||||
this.ifFirstInstall = false;
|
||||
this.pushToStorage(cb)
|
||||
}
|
||||
)}
|
||||
|
@ -167,7 +170,7 @@ chrome.runtime.onInstalled.addListener( details => {
|
|||
//window.antiCensorRu.installPac();
|
||||
break;
|
||||
case 'install':
|
||||
window.antiCensorRu.ifNotInstalled = true;
|
||||
window.antiCensorRu.ifFirstInstall = true;
|
||||
chrome.runtime.openOptionsPage();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user