Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonhellman committed May 24, 2018
1 parent 9db0599 commit 65564d9
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
node_modules
2 changes: 2 additions & 0 deletions .vscode/settings.json
@@ -0,0 +1,2 @@
{
}
10 changes: 10 additions & 0 deletions background/.eslintrc.json
@@ -0,0 +1,10 @@
{
"globals": {
"Fetch": false,
"StorageGetKey": false,
"mturkDate": false,

"HTML": false,
"ENCODE": false
}
}
9 changes: 9 additions & 0 deletions js/fetch-with-timeout.js
@@ -0,0 +1,9 @@
// eslint-disable-next-line no-unused-vars
function Fetch(input, init, timeout) {
return Promise.race([
fetch(input, init),
new Promise((resolve, reject) =>
setTimeout(() => reject(new Error(`Fetch timeout.`)), timeout)
)
]);
}
15 changes: 15 additions & 0 deletions js/mturk-date.js
@@ -0,0 +1,15 @@
// eslint-disable-next-line no-unused-vars
function MturkDate(offset = 0) {
const date = new Date(Date.now() - offset);

const toPST = date.toLocaleString(`en-US`, {
timeZone: `America/Los_Angeles`
});

const isPST = new Date(toPST);
const yyyy = isPST.getFullYear();
const mm = `0${isPST.getMonth()}`.slice(-2);
const dd = `0${isPST.getDate()}`.slice(-2);

return `${yyyy}${mm}${dd}`;
}
19 changes: 19 additions & 0 deletions js/storage.js
@@ -0,0 +1,19 @@
function StorageGet(keys) {
return new Promise(resolve => chrome.storage.local.get(keys, resolve));
}

async function StorageGetKey(key) {
const storage = await StorageGet(key);
return storage[key];
}

// eslint-disable-next-line no-unused-vars
function Enabled(name) {
return new Promise(async resolve => {
const options = await StorageGetKey(`options`);

if (options[name]) resolve();
else
window.console.warn(`"${name}" did not resolve because it is disabled.`);
});
}
14 changes: 14 additions & 0 deletions mturk/.eslintrc.json
@@ -0,0 +1,14 @@
{
"globals": {
"StorageGetKey": false,

"HTML": false,

"ReactDOM": false,
"ReactProps": false,

"Enabled": false,

"mturkDate": false
}
}
1 change: 1 addition & 0 deletions mturk/logged-in.js
@@ -0,0 +1 @@
chrome.runtime.sendMessage({ loggedIn: true });
23 changes: 23 additions & 0 deletions package.json
@@ -0,0 +1,23 @@
{
"name": "mturk-suite",
"version": "1.0.0",
"devDependencies": {
"eslint": "^4.9.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.4.0"
},
"eslintConfig": {
"extends": ["airbnb-base", "prettier"],
"env": {
"browser": true,
"webextensions": true
},
"rules": {
"camelcase": 0,
"linebreak-style": 0
}
}
}

0 comments on commit 65564d9

Please sign in to comment.