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

View File

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

View File

@ -332,7 +332,11 @@ export default function getExcEditor(theState) {
</li> </li>
<li> <li>
<input id="this-yes" type="radio" name="if-proxy-this-site" checked={inputProxyingState === true} onClick={onradio}/> <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>
<li> <li>
<input id="this-no" type="radio" name="if-proxy-this-site" checked={inputProxyingState === false} onClick={onradio}/> <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, onConfChanged: this.handleModChange,
}; };
return createElement(TabPanel, { return createElement(TabPanel, Object.assign({}, props, {
tabs: [ tabs: [
{ {
label: 'PAC-скрипт', label: 'PAC-скрипт',
@ -160,7 +160,7 @@ export default function getMain(theState) {
alwaysShownWith: { alwaysShownWith: {
'applyMods': ['ownProxies', 'mods'], 'applyMods': ['ownProxies', 'mods'],
}, },
}); }));
} }

View File

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

View File

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