@samitouri / QOSami-HFS / commits / 65006812

plugins: HFS.urlParams

Massimo Melina committed Nov 20, 2024 at 11:33 UTC 65006812bf977f4369fdcea52a6149529737d941
3 files changed +8 -6
dev-plugins.md
+5 -3
@@ -271,7 +271,7 @@ The HFS objects contains many properties:
271 - `iconBtn(icon: string, onClick: function, props?: any)` render a React Icon Button. For icons, refer to `Icon` component.
272 - `domOn(eventName: string, cb: function, { target }?): function` convenient alternative to addEventListener/removeEventListener.
273 The default target is window. Returns a callback to remove the listener.
274 -- `useBatch(worker, job): any`
274 +- `useBatch(worker, job): { data }` this is a bit complicated, please refer to source `shared/react.ts`.
275 - `getNotifications(channel: string, cb: (eventName: string, data:any) => void)`
276 receive messages when the backend uses `notifyClient` on the same channel.
277 - `html(html: string): ReactNode` convert html code to React
@@ -284,7 +284,8 @@ The HFS objects contains many properties:
284 - `DirEntry: class_constructor(n :string, otherProps?: DirEntry)` this is the class of the objects inside `HFS.state.list`;
285 in case you need to add to the list, do it by instantiating this class. E.g. `new HFS.DirEntry(name)`
286 - `fileShow(entry: DirEntry, options?: { startPlaying: true )` open file-show on the specified entry.
287 -- `copyTextToClipboard(text: string)` self-explanatory
287 +- `copyTextToClipboard(text: string)` self-explanatory.
288 +- `urlParams: object` you'll find each parameter in the URL mapped in this object as string.
289
290 The following properties are accessible only immediately at top-level; don't call it later in a callback.
291 - `getPluginConfig()` returns object of all config keys that are declared frontend-accessible by this plugin.
@@ -677,8 +678,9 @@ If you want to override a text regardless of the language, use the special langu
678
679 ## API version history
680
680 -- 10 (v0.55.0)
681 +- 10.1 (v0.55.0)
682 - HFS.copyTextToClipboard
683 + - HFS.urlParams
684 - exports.beforePlugin + afterPlugin
685 - config.type: color
686 - 9.6 (v0.54.0)
shared/index.ts
+2 -2
@@ -22,6 +22,7 @@ export const cpuSpeedIndex = (() => {
22 return 1 / ms
23 })()
24
25 +export const urlParams = Object.fromEntries(new URLSearchParams(window.location.search).entries())
26
27 const HFS = getHFS()
28 Object.assign(HFS, {
@@ -32,6 +33,7 @@ Object.assign(HFS, {
33 userBelongsTo: (groupOrUser: string) => HFS.state.expandedUsername.includes(groupOrUser),
34 cpuSpeedIndex,
35 copyTextToClipboard,
36 + urlParams,
37 })
38
39 export const IMAGE_FILEMASK = '*.jpg|*.jpeg|*.gif|*.svg'
@@ -47,8 +49,6 @@ function getScriptAttr(k: string) {
49 || console.error("this function must be called at the very top of your file")
50 }
51
50 -export const urlParams = Object.fromEntries(new URLSearchParams(window.location.search).entries())
51 -
52 export function buildUrlQueryString(params: Dict) { // not using URLSearchParams.toString as it doesn't work on firefox50
53 return '?' + Object.entries(params).map(pair => pair.map(encodeURIComponent).join('=') ).join('&')
54 }
src/const.ts
+1 -1
@@ -7,7 +7,7 @@ import _ from 'lodash'
7 import { basename, dirname, join } from 'path'
8 export * from './cross-const'
9
10 -export const API_VERSION = 10
10 +export const API_VERSION = 10.1
11 export const COMPATIBLE_API_VERSION = 1 // while changes in the api are not breaking, this number stays the same, otherwise it is made equal to API_VERSION
12 export const HFS_REPO = 'rejetto/hfs'
13