From 1e4c307f97ae5d9ba11b2b84d681aca7d502fc96 Mon Sep 17 00:00:00 2001 From: Greg Jacobs Date: Sat, 1 Jun 2024 18:12:05 -0400 Subject: [PATCH] better organization, add in eslint as well as package and other helper bookmarklets found on confluence to have here if needed as a reference --- .gitignore | 2 + CHANGELOG.md | 15 ++++--- README.MD | 26 +++++++++---- eslint.config.mjs | 8 ++++ package.json | 21 ++++++++++ src/{helpers => utils/bookmarklets}/dag.js | 0 src/{helpers => utils/bookmarklets}/hashid.js | 0 src/{helpers => utils/bookmarklets}/jira.js | 0 src/{helpers => utils/bookmarklets}/moids.js | 0 .../bookmarklets}/rbc-di-featureflags.js | 0 .../bookmarklets}/workspace.js | 0 src/utils/others/jsToMsDate.js | 21 ++++++++++ src/utils/others/msToJsDate.js | 13 +++++++ src/utils/others/showDebugInfo.js | 39 +++++++++++++++++++ 14 files changed, 132 insertions(+), 13 deletions(-) create mode 100644 .gitignore create mode 100644 eslint.config.mjs create mode 100644 package.json rename src/{helpers => utils/bookmarklets}/dag.js (100%) rename src/{helpers => utils/bookmarklets}/hashid.js (100%) rename src/{helpers => utils/bookmarklets}/jira.js (100%) rename src/{helpers => utils/bookmarklets}/moids.js (100%) rename src/{helpers => utils/bookmarklets}/rbc-di-featureflags.js (100%) rename src/{helpers => utils/bookmarklets}/workspace.js (100%) create mode 100644 src/utils/others/jsToMsDate.js create mode 100644 src/utils/others/msToJsDate.js create mode 100644 src/utils/others/showDebugInfo.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fed401d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +package-lock.json +node_modules/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 50b4184..eee69f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,12 +5,15 @@ All notable changes to this project will be documented in this file. ## [0.0.1] - 2025-06-01 ### Added -- [helpers/dag.js](src/helpers/dag.js) -- [helpers/hashid.js](src/helpers/hashid.js) -- [helpers/jira.js](src/helpers/jira.js) -- [helpers/moids.js](src/helpers/moids.js) -- [helpers/rbc-di-featureflags.js](src/helpers/rbc-di-featureflags.js) -- [helpers/workspace.js](src/helpers/workspace.js) +- [utils/bookmarklets/dag.js](src/utils/bookmarklets/dag.js) +- [utils/bookmarklets/hashid.js](src/utils/bookmarklets/hashid.js) +- [utils/bookmarklets/jira.js](src/utils/bookmarklets/jira.js) +- [utils/bookmarklets/moids.js](src/utils/bookmarklets/moids.js) +- [utils/bookmarklets/rbc-di-featureflags.js](src/utils/bookmarklets/rbc-di-featureflags.js) +- [utils/bookmarklets/workspace.js](src/utils/bookmarklets/workspace.js) +- [utils/others/jsToMsDate.js](src/utils/others/jsToMsDate.js) +- [utils/others/msToJsDate.js](src/utils/others/msToJsDate.js) +- [utils/others/showDebugInfo.js](src/utils/others/showDebugInfo.js) - [ideas/newideashere.txt](src/ideas/newideashere.txt) - [ideas/released/featureflagging.txt](src/ideas/released/featureflagging.txt) - [data folder](src/data) diff --git a/README.MD b/README.MD index 4677de2..2101232 100644 --- a/README.MD +++ b/README.MD @@ -2,26 +2,38 @@ This project contains several files that perform various tasks. Here's a brief overview of each file: -## [DAG](src/helpers/dag.js) +## [DAG](src/utils/bookmarklets/dag.js) This JavaScript file contains a bookmarklet function that prompts the user for a list of DAG Task numbers, separated by commas. For each provided number, it opens a new browser tab with the corresponding DAG Task details page. If the user doesn't provide any input, it opens the default DAG Tasks page in a new tab. This can be useful for quickly accessing multiple DAG Task details pages based on user input. -## [hashid](src/helpers/hashid.js) +## [hashid](src/utils/bookmarklets/hashid.js) This JavaScript file contains a bookmarklet function that takes a string, decodes it using decodeURIComponent, alerts the decoded string, and copies the result to the clipboard. -## [jira.js](src/helpers/jira.js) +## [jira.js](src/utils/bookmarklets/jira.js) This JavaScript file contains a bookmarklet function that prompts the user for a JIRA ticket number and then opens a new browser tab with the corresponding JIRA page for that ticket. -## [moids.js](src/helpers/moids.js) +## [moids.js](src/utils/bookmarklets/moids.js) This JavaScript file contains a bookmarklet function that prompts the user for multiple MOID (Markit On Demand) numbers and then opens a new browser tab for each corresponding Jira page for those MOIDs. -## [rbc-di-featureflag.js](src/helpers/rbc-di-featureflags.js) +## [rbc-di-featureflag.js](src/utils/bookmarklets/rbc-di-featureflags.js) This JavaScript file contains a bookmarklet function that checks the feature flags set in the session storage and displays themm as checkboxes that the user can set then save -## [Workspace - WIP](src/helpers/workspace.js) +## [Workspace - WIP](src/utils/bookmarklets/workspace.js) -This is just so i can get up and running on a new window with all the pages i care about \ No newline at end of file +This is just so i can get up and running on a new window with all the pages i care about + +## [jsToMsDate.js](src/utils/others/jsToMsDate.js) + +This JavaScript file contains a function that converts a JavaScript Date object to a Microsoft Date string format. It can be useful when working with APIs or databases that require dates to be in the Microsoft Date format. + +## [msToJsDate.js](src/utils/others/msToJsDate.js) + +This JavaScript file contains a function that converts a Microsoft Date string format to a JavaScript Date object. It can be useful when working with APIs or databases that provide dates in the Microsoft Date format. + +## [showDebugInfo.js](src/utils/others/showDebugInfo.js) + +This JavaScript file contains a bookmarklet function that displays debug information about the current page. It can be useful for troubleshooting and understanding the state of the page during development. \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..1aa8477 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,8 @@ +import globals from "globals"; +import pluginJs from "@eslint/js"; + + +export default [ + {languageOptions: { globals: {...globals.browser, ...globals.node} }}, + pluginJs.configs.recommended, +]; \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..51fa7f5 --- /dev/null +++ b/package.json @@ -0,0 +1,21 @@ +{ + "name": "memorypalace", + "version": "0.0.1", + "description": "This project contains several files that perform various tasks. Here's a brief overview of each file:", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://stash.mgmt.local/users/greg.jacobs/repos/memorypalace/browse" + }, + "author": "Greg Jacobs", + "license": "ISC", + "devDependencies": { + "@eslint/js": "^9.4.0", + "eslint": "^9.4.0", + "globals": "^15.3.0", + "prettier": "^3.3.0" + } +} diff --git a/src/helpers/dag.js b/src/utils/bookmarklets/dag.js similarity index 100% rename from src/helpers/dag.js rename to src/utils/bookmarklets/dag.js diff --git a/src/helpers/hashid.js b/src/utils/bookmarklets/hashid.js similarity index 100% rename from src/helpers/hashid.js rename to src/utils/bookmarklets/hashid.js diff --git a/src/helpers/jira.js b/src/utils/bookmarklets/jira.js similarity index 100% rename from src/helpers/jira.js rename to src/utils/bookmarklets/jira.js diff --git a/src/helpers/moids.js b/src/utils/bookmarklets/moids.js similarity index 100% rename from src/helpers/moids.js rename to src/utils/bookmarklets/moids.js diff --git a/src/helpers/rbc-di-featureflags.js b/src/utils/bookmarklets/rbc-di-featureflags.js similarity index 100% rename from src/helpers/rbc-di-featureflags.js rename to src/utils/bookmarklets/rbc-di-featureflags.js diff --git a/src/helpers/workspace.js b/src/utils/bookmarklets/workspace.js similarity index 100% rename from src/helpers/workspace.js rename to src/utils/bookmarklets/workspace.js diff --git a/src/utils/others/jsToMsDate.js b/src/utils/others/jsToMsDate.js new file mode 100644 index 0000000..3109260 --- /dev/null +++ b/src/utils/others/jsToMsDate.js @@ -0,0 +1,21 @@ +javascript:(function() { + function jsToMsDate(jsdate) { + var ms = Date.UTC( + jsdate.getUTCFullYear(), + jsdate.getUTCMonth(), + jsdate.getUTCDate(), + jsdate.getUTCHours(), + jsdate.getUTCMinutes(), + jsdate.getUTCSeconds(), + jsdate.getUTCMilliseconds() + ); + var off = jsdate.getTimezoneOffset(); + return (ms - off * 60 * 1000) / 86400000 + 25569; + } + + var date = prompt("Enter date"); + if (date) { + date = new Date(date); + alert(jsToMsDate(date)); } + +})(); \ No newline at end of file diff --git a/src/utils/others/msToJsDate.js b/src/utils/others/msToJsDate.js new file mode 100644 index 0000000..cb8532b --- /dev/null +++ b/src/utils/others/msToJsDate.js @@ -0,0 +1,13 @@ +javascript:(function() { + function msToJsDate(msdate) { + var jscriptDateObj = new Date(((msdate - 25569) * 86400000)); + var timezoneOffset = jscriptDateObj.getTimezoneOffset(); + jscriptDateObj = new Date(((msdate - 25569 + (timezoneOffset / (60 * 24))) * 86400000)); + return jscriptDateObj; + } + + var date = prompt("Enter MSDate"); + if (date) { + alert(msToJsDate(date)); + } +})(); \ No newline at end of file diff --git a/src/utils/others/showDebugInfo.js b/src/utils/others/showDebugInfo.js new file mode 100644 index 0000000..1e3033f --- /dev/null +++ b/src/utils/others/showDebugInfo.js @@ -0,0 +1,39 @@ +javascript: (function () { + function setFlag(_flag, _state) { + function setFlagSub(_url, _flag, _state) { + if (_url.indexOf(_flag) == -1) { + _url += (/\?/.test(_url)) ? '&' : '?'; + _url += '..' + _flag + '..=' + _state; + } else { + var re = new RegExp('\\.\\.' + _flag + '\\.\\.=[^&]*'); + _url = _url.replace(re, '..' + _flag + '..=' + _state); + } + return _url; + }; + + function toggleParameter(ad, type, val) { + type = '..' + type + '..'; + if (m = ad.match(new RegExp('[?|&]' + type + '=(on|off)&?'))) { + ad = ad.replace(type + '=' + m[1], type + '=' + (val || (m[1] == 'on' ? 'off' : 'on'))); + } else { + ad += (/\?/.test(ad) ? '&' : '?') + type + '=' + (val || 'on'); + } + return ad; + }; + + var dependencies = { + 'debugchartsrv': ['showdebuginfo'], + 'scriptscachedebug': ['scriptscache'] + }; + + var url = new String(window.location.href).replace(/#.*/,); + if (dependencies[_flag] && _state != 'off') { + for (var i = 0; i < dependencies[_flag].length; i++) { + url = toggleParameter(url, dependencies[_flag][i], 'on'); + } + } + url = toggleParameter(url, _flag, _state || null); + window.location.href = url; + }; + setFlag('showdebuginfo'); +})(); \ No newline at end of file