From 003862580fb809f0b0ef93f75d9dfea37de12e54 Mon Sep 17 00:00:00 2001 From: "caleb.mabry.15@cnu.edu" Date: Sun, 6 Mar 2022 17:33:07 -0500 Subject: Moved into another file and linted --- webAO/client.js | 39 ++------------------------------------- 1 file changed, 2 insertions(+), 37 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 7ff561b..eb7c7a2 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -18,6 +18,7 @@ import vanilla_background_arr from './backgrounds.js'; import vanilla_evidence_arr from './evidence.js'; import chatbox_arr from './styles/chatbox/chatboxes.js'; +import iniParse from './iniParse'; const version = process.env.npm_package_version; @@ -843,7 +844,7 @@ class Client extends EventEmitter { // If the ini doesn't exist on the server this will throw an error try { const cinidata = await request(`${AO_HOST}characters/${encodeURI(chargs[0].toLowerCase())}/char.ini`); - cini = INI.parse(cinidata); + cini = iniParse(cinidata); } catch (err) { cini = {}; img.classList.add('noini'); @@ -2410,42 +2411,6 @@ class Viewport { } } -class INI { - static parse(data) { - const regex = { - section: /^\s*\[\s*([^\]]*)\s*\]\s*$/, - param: /^\s*([\w.\-_]+)\s*=\s*(.*?)\s*$/, - comment: /^\s*;.*$/, - }; - const value = {}; - const lines = data.split(/\r\n|\r|\n/); - let section; - lines.forEach((line) => { - if (regex.comment.test(line)) { - - } else if (line.length === 0) { - - } else if (regex.param.test(line)) { - const match = line.match(regex.param); - if (section) { - if (match[1].toLowerCase() === 'showname') { // don't lowercase the showname - value[section].showname = match[2]; - } else { - value[section][match[1].toLowerCase()] = match[2].toLowerCase(); - } - // } else { // we don't care about attributes without a section - // value[match[1]] = match[2]; - } - } else if (regex.section.test(line)) { - const match = line.match(regex.section); - value[match[1].toLowerCase()] = {}; // lowercase everything else - section = match[1].toLowerCase(); - } - }); - return value; - } -} - /** * read a cookie from storage * got this from w3schools -- cgit