Move hash to App.js, add status to it, mend menus

This commit is contained in:
Ilya Ig. Petrov 2017-05-28 06:05:53 -07:00
parent 51cd8095d3
commit 9c5d3a5ea5
6 changed files with 34 additions and 27 deletions

View File

@ -6,21 +6,16 @@
getItemsAsObject: () => ({
hostTracker: {
title: 'Сайт доступен из-за границы? Is up?',
getUrl: (blockedUrl) => `data:text/html;charset=utf8,<title>Запрашиваю...</title>
<form class='tracker-form' method='POST'
action='https://www.host-tracker.com/ru/InstantCheck/Create'>
<input name='InstantCheckUrl' value='${new URL(blockedUrl).hostname}'
type='hidden'>
</form>
<script>document.querySelector('.tracker-form').submit()<\/script>`,
googleTranslate: {
title: 'Через Google Translate',
getUrl: (blockedUrl) => (
'https://translate.google.com/translate?hl=&sl=en&tl=ru&anno=2&sandbox=1&u=' + blockedUrl),
order: 0,
},
antizapretInfo: {
title: 'Сайт в реестре блокировок?',
getUrl: (blockedUrl) => 'https://antizapret.info/index.php?search=' + new URL(blockedUrl).hostname,
hostTracker: {
title: 'Из кэша Google',
getUrl: (blockedUrl) => 'http://webcache.googleusercontent.com/search?q=cache:' + blockedUrl,
order: 1,
},
@ -30,16 +25,15 @@
order: 2,
},
googleTranslate: {
title: 'Через Google Translate',
getUrl: (blockedUrl) => (
'https://translate.google.com/translate?hl=&sl=en&tl=ru&anno=2&sandbox=1&u=' + blockedUrl),
order: 3,
},
otherUnblock: {
title: 'Разблокировать по-другому',
getUrl: (blockedUrl) => ('https://rebrand.ly/ac-unblock#' + blockedUrl),
order: 3,
},
antizapretInfo: {
title: 'Сайт в реестре блокировок?',
getUrl: (blockedUrl) => 'https://antizapret.info/index.php?search=' + new URL(blockedUrl).hostname,
order: 4,
},

View File

@ -17,9 +17,15 @@ export default function getApp(theState) {
constructor(props) {
super(props);
const hash = window.location.hash.substr(1);
const hashParams = new URLSearchParams(hash);
console.log('GOT from', hash, hashParams.toString());
this.state = {
status: 'Загрузка...',
status: hashParams.get('status') || 'Загрузка...',
ifInputsDisabled: false,
hashParams,
};
}
@ -131,6 +137,7 @@ export default function getApp(theState) {
showErrors: this.showErrors.bind(this),
},
ifInputsDisabled: this.state.ifInputsDisabled,
hashParams: this.state.hashParams,
});
return createElement('div', null, [

View File

@ -332,7 +332,11 @@ export default function getExcEditor(theState) {
</li>
<li>
<input id="this-yes" type="radio" name="if-proxy-this-site" checked={inputProxyingState === true} onClick={onradio}/>
{' '}<label for="this-yes"><span class="emoji"></span>&nbsp;да</label>
{' '}<label for="this-yes">
<span
class="emoji____buggy"
></span>&nbsp;да
</label>
</li>
<li>
<input id="this-no" type="radio" name="if-proxy-this-site" checked={inputProxyingState === false} onClick={onradio}/>

View File

@ -110,7 +110,7 @@ export default function getMain(theState) {
onConfChanged: this.handleModChange,
};
return createElement(TabPanel, {
return createElement(TabPanel, Object.assign({}, props, {
tabs: [
{
label: 'PAC-скрипт',
@ -160,7 +160,7 @@ export default function getMain(theState) {
alwaysShownWith: {
'applyMods': ['ownProxies', 'mods'],
},
});
}));
}

View File

@ -114,7 +114,7 @@ export default function getTabPannel({ flags, baseCss }) {
constructor(props) {
super(props);
const fromHash = window.location.hash.substr(1)
const fromHash = props.hashParams.get('tab');
this.state = {
chosenTabKeyRaw: fromHash,
};
@ -133,8 +133,10 @@ export default function getTabPannel({ flags, baseCss }) {
}
const chosenTabKey = indexedTabs[chosenTabIndex].key;
console.log(chosenTabKey, chosenTabIndex, indexedTabs);
window.location.hash = chosenTabKey;
if (chosenTabKey !== props.hashParams.get('tab')) {
props.hashParams.set('tab', chosenTabKey);
window.location.hash = props.hashParams.toString();
}
return (
<div>

View File

@ -22,7 +22,7 @@ chrome.webNavigation.onErrorOccurred.addListener((details) => {
chrome.browserAction.setPopup({
tabId,
popup: './pages/options/index.html#exceptions',
popup: './pages/options/index.html#tab=exceptions&status=Правый клик по иконке = меню инструментов!',
});
window.chrome.browserAction.setBadgeBackgroundColor({