This repository has been archived by the owner on Nov 7, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from mrepol742/master
Initial PR
- Loading branch information
Showing
4 changed files
with
200 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/*jshint esversion: 9 */ | ||
/*jshint -W018 */ | ||
/*jshint -W069 */ | ||
/*jshint -W083 */ | ||
/*jshint -W088 */ | ||
/*jshint -W038 */ | ||
|
||
const fs = require("fs"); | ||
|
||
let settings = JSON.parse(fs.readFileSync(__dirname + "/accountPreferences.json", "utf8")); | ||
let settingsThread = JSON.parse(fs.readFileSync(__dirname + "/threadPreferences.json", "utf8")); | ||
|
||
let data = "insertData account value:true".split(" "); | ||
|
||
let location = data[1]; | ||
let tbs = data[2].split(":"); | ||
if (location == "account") { | ||
for (account in settings) { | ||
settings[account][tbs[0]] = getTrueValue(tbs[1]); | ||
} | ||
} else if (location == "thread") { | ||
for (thread in settingsThread) { | ||
settingsThread[thread][tbs[0]] = getTrueValue(tbs[1]); | ||
} | ||
} | ||
|
||
function getTrueValue(value) { | ||
if (/^\d+$/.test(value)) { | ||
// str > int | ||
value = parseInt(value); | ||
} else if (/^[+-]?\d+(\.\d+)?$/.test(value)) { | ||
// str > fl/db | ||
value = parseFloat(value); | ||
} else if (/^(true|false)$/.test(value)) { | ||
// str > bn | ||
value = value === "true"; | ||
} | ||
return value; | ||
} | ||
|
||
console.log(JSON.stringify(settings, null, 4)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters