Skip to content

Commit

Permalink
feat[WIP]: trying to update status by tab for #351
Browse files Browse the repository at this point in the history
  • Loading branch information
ffoodd committed May 9, 2019
1 parent 52e8672 commit 785e504
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 107 deletions.
Binary file modified a11ycss-webextension-chrome.zip
Binary file not shown.
Binary file modified a11ycss-webextension-firefox.zip
Binary file not shown.
72 changes: 36 additions & 36 deletions webextension/scripts/a11ycss.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ let button = document.getElementById("a11ycssBtnApply");
* @param {String} strLevel
*/
function storeA11ycss(strLevel) {
// Get a11y.css stored levels
let getLevel = browser.storage.local.get("a11ycssLevel");
getLevel.then(
// when we got something
(item) => {
if (item && item.a11ycssLevel) {
// Get current tab ID
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
// Get current stored value
// Get current tab ID
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
let a11ycssLevel = [];
// Get a11y.css stored levels
let getLevel = browser.storage.local.get("a11ycssLevel");
getLevel.then(
// when we got something
(item) => {
if (item && item.a11ycssLevel) {
let a11ycssLevel = item.a11ycssLevel;
// Add or replace current tab's value
a11ycssLevel[tabs[0].id] = {"level": strLevel};
// Abnd set it back to the storage
let setting = browser.storage.local.set({ a11ycssLevel });
setting.then(null, onError); // just in case
});
}
}
}
);
);
// Add or replace current tab's value
a11ycssLevel[tabs[0].id] = {"level": strLevel};
// And set it back to the storage
let setting = browser.storage.local.set({ a11ycssLevel });
setting.then(null, onError); // just in case
});
}

// store choice when one radio button is chosen
Expand Down Expand Up @@ -67,25 +67,25 @@ function removeA11ycss() {
}

function storeStatus(strStatus) {
// Get a11y.css stored levels
let getStatus = browser.storage.local.get("a11ycssStatus");
getStatus.then(
// when we got something
(item) => {
if (item && item.a11ycssStatus) {
// Get current tab ID
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
// Get current stored value
// Get current tab ID
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
let a11ycssStatus = [];
// Get a11y.css stored levels
let getStatus = browser.storage.local.get("a11ycssStatus");
getStatus.then(
// when we got something
(item) => {
if (item && item.a11ycssStatus) {
let a11ycssStatus = item.a11ycssStatus;
// Add or replace current tab's value
a11ycssStatus[tabs[0].id] = {"status": strStatus};
// Abnd set it back to the storage
let setting = browser.storage.local.set({ a11ycssStatus });
setting.then(null, onError); // just in case
});
}
}
}
);
);
// Add or replace current tab's value
a11ycssStatus[tabs[0].id] = {"status": strStatus};
// And set it back to the storage
let setting = browser.storage.local.set({ a11ycssStatus });
setting.then(null, onError); // just in case
});
}

button.addEventListener('click', function () {
Expand All @@ -107,7 +107,7 @@ function a11ycssOnload() {
let getLevel = browser.storage.local.get("a11ycssLevel");
getLevel.then(
// when we got something
function (item) {
(item) => {
if (item && item.a11ycssLevel) {
// Get current tab ID
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
Expand All @@ -132,7 +132,7 @@ function a11ycssOnload() {
let getStatus = browser.storage.local.get("a11ycssStatus");
getStatus.then(
// when we got something
function (item) {
(item) => {
if (item && item.a11ycssStatus) {
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
// If a setting is found for this tab
Expand Down
36 changes: 18 additions & 18 deletions webextension/scripts/checkalts.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
let btnCheckalts = document.getElementById('btnCheckalts');

function storeCheckAltsStatus(strStatus) {
// Get a11y.css stored levels
let getStatus = browser.storage.local.get("checkAltsStatus");
getStatus.then(
// when we got something
(item) => {
if (item && item.checkAltsStatus) {
// Get current tab ID
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
// Get current stored value
// Get current tab ID
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
let checkAltsStatus = [];
// Get a11y.css stored status
let getStatus = browser.storage.local.get("checkAltsStatus");
getStatus.then(
// when we got something
(item) => {
if (item && item.checkAltsStatus) {
let checkAltsStatus = item.checkAltsStatus;
// Add or replace current tab's value
checkAltsStatus[tabs[0].id] = {"status": strStatus};
// Abnd set it back to the storage
let setting = browser.storage.local.set({ checkAltsStatus });
setting.then(null, onError); // just in case
});
}
}
}
);
);
// Add or replace current tab's value
checkAltsStatus[tabs[0].id] = {"status": strStatus};
// And set it back to the storage
let setting = browser.storage.local.set({ checkAltsStatus });
setting.then(null, onError); // just in case
});
}

btnCheckalts.addEventListener('click', function () {
Expand Down Expand Up @@ -52,7 +52,7 @@ function checkAltsOnload() {
let getStatus = browser.storage.local.get("checkAltsStatus");
getStatus.then(
// when we got something
function (item) {
(item) => {
if (item && item.checkAltsStatus) {
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
// If a setting is found for this tab
Expand Down
36 changes: 18 additions & 18 deletions webextension/scripts/outline.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,25 @@ function removeOutline() {
}

function storeOutlineStatus(strStatus) {
// Get a11y.css stored levels
let getStatus = browser.storage.local.get("outlineStatus");
getStatus.then(
// when we got something
(item) => {
if (item && item.outlineStatus) {
// Get current tab ID
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
// Get current stored value
// Get current tab ID
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
let outlineStatus = [];
// Get a11y.css stored status
let getStatus = browser.storage.local.get("outlineStatus");
getStatus.then(
// when we got something
(item) => {
if (item && item.outlineStatus) {
let outlineStatus = item.outlineStatus;
// Add or replace current tab's value
outlineStatus[tabs[0].id] = {"status": strStatus};
// Abnd set it back to the storage
let setting = browser.storage.local.set({ outlineStatus });
setting.then(null, onError); // just in case
});
}
}
}
);
);
// Add or replace current tab's value
outlineStatus[tabs[0].id] = {"status": strStatus};
// And set it back to the storage
let setting = browser.storage.local.set({ outlineStatus });
setting.then(null, onError); // just in case
});
}

btnOutline.addEventListener('click', function() {
Expand All @@ -58,7 +58,7 @@ function outlineOnload() {
let getStatus = browser.storage.local.get("outlineStatus");
getStatus.then(
// when we got something
function (item) {
(item) => {
if (item && item.outlineStatus) {
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
// If a setting is found for this tab
Expand Down
34 changes: 17 additions & 17 deletions webextension/scripts/showlangattribute.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
let btnShowLangAttribute = document.getElementById('btnShowLangAttribute');

function storeShowLangStatus(strStatus) {
// Get a11y.css stored levels
let getStatus = browser.storage.local.get("showLangStatus");
getStatus.then(
// when we got something
(item) => {
if (item && item.showLangStatus) {
// Get current tab ID
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
// Get current stored value
// Get current tab ID
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
let showLangStatus = [];
// Get a11y.css stored status
let getStatus = browser.storage.local.get("showLangStatus");
getStatus.then(
// when we got something
(item) => {
if (item && item.showLangStatus) {
let showLangStatus = item.showLangStatus;
// Add or replace current tab's value
showLangStatus[tabs[0].id] = {"status": strStatus};
// Abnd set it back to the storage
let setting = browser.storage.local.set({ showLangStatus });
setting.then(null, onError); // just in case
});
}
}
}
);
);
// Add or replace current tab's value
showLangStatus[tabs[0].id] = {"status": strStatus};
// And set it back to the storage
let setting = browser.storage.local.set({ showLangStatus });
setting.then(null, onError); // just in case
});
}

function showLangAttribute() {
Expand Down
38 changes: 20 additions & 18 deletions webextension/scripts/textspacing.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
let btnTextspacing = document.getElementById('btnTextspacing');
let textSpacingStatus = [];

function storeTextSpacingStatus(strStatus) {
// Get a11y.css stored levels
let getStatus = browser.storage.local.get("textSpacingStatus");
getStatus.then(
// when we got something
(item) => {
if (item && item.textSpacingStatus) {
// Get current tab ID
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
// Get current stored value
// Get current tab ID
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
// Get a11y.css stored status
let getStatus = browser.storage.local.get("textSpacingStatus");
getStatus.then(
// when we got something
(item) => {
if (item && item.textSpacingStatus) {
let textSpacingStatus = item.textSpacingStatus;
// Add or replace current tab's value
textSpacingStatus[tabs[0].id] = {"status": strStatus};
// Abnd set it back to the storage
let setting = browser.storage.local.set({ textSpacingStatus });
setting.then(null, onError); // just in case
});
}
}
}
);
);
// Add or replace current tab's value
textSpacingStatus[tabs[0].id] = {"status": strStatus};
console.log(textSpacingStatus);
// And set it back to the storage
let setting = browser.storage.local.set({ textSpacingStatus });
setting.then(null, onError); // just in case
});
}

btnTextspacing.addEventListener('click', function () {
Expand All @@ -41,8 +42,9 @@ function textSpacingOnload() {
let getStatus = browser.storage.local.get("textSpacingStatus");
getStatus.then(
// when we got something
function (item) {
(item) => {
if (item && item.textSpacingStatus) {
console.log(item.textSpacingStatus);
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
// If a setting is found for this tab
if (item.textSpacingStatus[tabs[0].id]) {
Expand Down

0 comments on commit 785e504

Please sign in to comment.