From a46ccf72cef30eccf4cb3f9cdea9c461bb44f8b2 Mon Sep 17 00:00:00 2001 From: Caleb Mabry Date: Fri, 15 Jul 2022 00:44:10 -0400 Subject: Resolving issue with name display and encoding issue --- webAO/utils/__tests__/paths.test.ts | 13 +++++++++++++ webAO/utils/paths.ts | 1 + 2 files changed, 14 insertions(+) create mode 100644 webAO/utils/__tests__/paths.test.ts create mode 100644 webAO/utils/paths.ts (limited to 'webAO/utils') diff --git a/webAO/utils/__tests__/paths.test.ts b/webAO/utils/__tests__/paths.test.ts new file mode 100644 index 0000000..4f41d09 --- /dev/null +++ b/webAO/utils/__tests__/paths.test.ts @@ -0,0 +1,13 @@ +import {getFilenameFromPath} from '../paths' +jest.mock('../fileExists') + +describe('getFilenameFromPath', () => { + const EXAMPLE_PATH = "localhost/stoneddiscord/assets.png" + it('Should get the last value from a path', async () => { + const actual = getFilenameFromPath(EXAMPLE_PATH); + const expected = 'assets.png'; + expect(actual).toBe(expected); + }); +}) + + diff --git a/webAO/utils/paths.ts b/webAO/utils/paths.ts new file mode 100644 index 0000000..f4284b6 --- /dev/null +++ b/webAO/utils/paths.ts @@ -0,0 +1 @@ +export const getFilenameFromPath = (path: string) => path.substring(path.lastIndexOf('/') + 1) -- cgit From 23da8c8f171e34e1a4aa151ea12c48144f7f07f2 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Sat, 16 Jul 2022 13:43:51 +0200 Subject: finally fix testimony and guilty "bubbles" --- webAO/utils/getResources.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'webAO/utils') diff --git a/webAO/utils/getResources.js b/webAO/utils/getResources.js index a0c513e..859e63b 100644 --- a/webAO/utils/getResources.js +++ b/webAO/utils/getResources.js @@ -16,22 +16,22 @@ const getResources = (AO_HOST, THEME) => ({ duration: 840, }, witnesstestimony: { - src: `${AO_HOST}themes/${THEME}/witnesstestimony.gif`, + src: `${AO_HOST}themes/${THEME}/witnesstestimony_bubble.gif`, duration: 1560, sfx: `${AO_HOST}sounds/general/sfx-testimony.opus`, }, crossexamination: { - src: `${AO_HOST}themes/${THEME}/crossexamination.gif`, + src: `${AO_HOST}themes/${THEME}/crossexamination_bubble.gif`, duration: 1600, sfx: `${AO_HOST}sounds/general/sfx-testimony2.opus`, }, guilty: { - src: `${AO_HOST}themes/${THEME}/guilty.gif`, + src: `${AO_HOST}themes/${THEME}/guilty_bubble.gif`, duration: 2870, sfx: `${AO_HOST}sounds/general/sfx-guilty.opus`, }, notguilty: { - src: `${AO_HOST}themes/${THEME}/notguilty.gif`, + src: `${AO_HOST}themes/${THEME}/notguilty_bubble.gif`, duration: 2440, sfx: `${AO_HOST}sounds/general/sfx-notguilty.opus`, }, -- cgit From 9bec7d0fba8c80284e260469ed3045e9dfdb5d79 Mon Sep 17 00:00:00 2001 From: Caleb Date: Thu, 25 Aug 2022 21:34:08 -0400 Subject: Remove handleMS and separate queryParser --- webAO/utils/queryParser.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 webAO/utils/queryParser.ts (limited to 'webAO/utils') diff --git a/webAO/utils/queryParser.ts b/webAO/utils/queryParser.ts new file mode 100644 index 0000000..3110c14 --- /dev/null +++ b/webAO/utils/queryParser.ts @@ -0,0 +1,22 @@ +interface QueryParams { + ip: string; + serverIP: string; + mode: string; + asset: string; + theme: string; +} +interface StringMap { + [key: string]: any; +} + +const queryParser = (): QueryParams => { + const queryDict: StringMap = {}; + location.search + .substr(1) + .split("&") + .forEach((item) => { + queryDict[item.split("=")[0]] = item.split("=")[1]; + }); + return queryDict as QueryParams; +}; +export default queryParser; -- cgit From 2e5e164bbde1b024834430a91a5c1b81b6e33ae4 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Tue, 30 Aug 2022 19:53:47 +0200 Subject: fix #112 --- webAO/utils/calculateApngLength.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'webAO/utils') diff --git a/webAO/utils/calculateApngLength.js b/webAO/utils/calculateApngLength.js index 932f581..d6a40b6 100644 --- a/webAO/utils/calculateApngLength.js +++ b/webAO/utils/calculateApngLength.js @@ -13,13 +13,18 @@ const calculateApngLength = (apngFile) => { && d[i + 2] === 0x54 && d[i + 3] === 0x4C) { // numerator and denominator - const delay = ((d[i + 21] / d[i + 23]) * 1000); - + const delay_num = Number(d[i + 23]); + const delay_den = Number(d[i + 25]); + let delay; // minimum is 100ms - duration += delay < 100 ? 100 : delay; + if (delay_den == 0) + delay = delay_num / 100; + else + delay = delay_num / delay_den; + + duration = duration + delay; } } - console.debug(duration); return duration * 10; }; export default calculateApngLength; -- cgit From 2838fbe91a270ed3d69ac708dac85b108b6f09dc Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Tue, 30 Aug 2022 20:53:31 +0200 Subject: use the typescript version of queryparser --- webAO/utils/queryParser.js | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 webAO/utils/queryParser.js (limited to 'webAO/utils') diff --git a/webAO/utils/queryParser.js b/webAO/utils/queryParser.js deleted file mode 100644 index 1c2b83a..0000000 --- a/webAO/utils/queryParser.js +++ /dev/null @@ -1,9 +0,0 @@ -// Get the arguments from the URL bar -const queryParser = () => { - const queryDict = {}; - location.search.substr(1).split('&').forEach((item) => { - queryDict[item.split('=')[0]] = item.split('=')[1]; - }); - return queryDict; -}; -export default queryParser; -- cgit From 325aa41d1216facbb7228743930a8ad21afec7aa Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Tue, 30 Aug 2022 20:58:25 +0200 Subject: convert cookie stuff to ts --- webAO/utils/getCookie.js | 26 -------------------------- webAO/utils/getCookie.ts | 26 ++++++++++++++++++++++++++ webAO/utils/setCookie.js | 10 ---------- webAO/utils/setCookie.ts | 10 ++++++++++ 4 files changed, 36 insertions(+), 36 deletions(-) delete mode 100644 webAO/utils/getCookie.js create mode 100644 webAO/utils/getCookie.ts delete mode 100644 webAO/utils/setCookie.js create mode 100644 webAO/utils/setCookie.ts (limited to 'webAO/utils') diff --git a/webAO/utils/getCookie.js b/webAO/utils/getCookie.js deleted file mode 100644 index 3be0733..0000000 --- a/webAO/utils/getCookie.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * read a cookie from storage - * got this from w3schools - * https://www.w3schools.com/js/js_cookies.asp - * @param {String} cname The name of the cookie to return - */ -const getCookie = (cname) => { - try { - const name = `${cname}=`; - const decodedCookie = decodeURIComponent(document.cookie); - const ca = decodedCookie.split(';'); - for (let i = 0; i < ca.length; i++) { - let c = ca[i]; - while (c.charAt(0) === ' ') { - c = c.substring(1); - } - if (c.indexOf(name) === 0) { - return c.substring(name.length, c.length); - } - } - return ''; - } catch (error) { - return ''; - } -}; -export default getCookie; diff --git a/webAO/utils/getCookie.ts b/webAO/utils/getCookie.ts new file mode 100644 index 0000000..f5b9679 --- /dev/null +++ b/webAO/utils/getCookie.ts @@ -0,0 +1,26 @@ +/** + * read a cookie from storage + * got this from w3schools + * https://www.w3schools.com/js/js_cookies.asp + * @param {String} cname The name of the cookie to return + */ +const getCookie = (cname: String) => { + try { + const name = `${cname}=`; + const decodedCookie = decodeURIComponent(document.cookie); + const ca = decodedCookie.split(';'); + for (let i = 0; i < ca.length; i++) { + let c = ca[i]; + while (c.charAt(0) === ' ') { + c = c.substring(1); + } + if (c.indexOf(name) === 0) { + return c.substring(name.length, c.length); + } + } + return ''; + } catch (error) { + return ''; + } +}; +export default getCookie; diff --git a/webAO/utils/setCookie.js b/webAO/utils/setCookie.js deleted file mode 100644 index 9734eae..0000000 --- a/webAO/utils/setCookie.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * set a cookie - * the version from w3schools expects these to expire - * @param {String} cname The name of the cookie to return - * @param {String} value The value of that cookie option - */ -const setCookie = (cname, value) => { - document.cookie = `${cname}=${value}`; -}; -export default setCookie; diff --git a/webAO/utils/setCookie.ts b/webAO/utils/setCookie.ts new file mode 100644 index 0000000..084fa20 --- /dev/null +++ b/webAO/utils/setCookie.ts @@ -0,0 +1,10 @@ +/** + * set a cookie + * the version from w3schools expects these to expire + * @param {String} cname The name of the cookie to return + * @param {any} value The value of that cookie option + */ +const setCookie = (cname: String, value: any) => { + document.cookie = `${cname}=${value}`; +}; +export default setCookie; -- cgit