From 6e0723fe25e65036a47dc6830f346cbcfc05c373 Mon Sep 17 00:00:00 2001 From: redhoodsu Date: Wed, 14 Dec 2022 10:03:16 +0800 Subject: [PATCH] chore: remove resources hbs --- src/EntryBtn/EntryBtn.hbs | 3 - src/Resources/Resources.hbs | 184 ----------------------- src/Resources/Resources.js | 282 +++++++++++++++++++++++++++++++++--- 3 files changed, 258 insertions(+), 211 deletions(-) delete mode 100644 src/EntryBtn/EntryBtn.hbs delete mode 100644 src/Resources/Resources.hbs diff --git a/src/EntryBtn/EntryBtn.hbs b/src/EntryBtn/EntryBtn.hbs deleted file mode 100644 index c35564d..0000000 --- a/src/EntryBtn/EntryBtn.hbs +++ /dev/null @@ -1,3 +0,0 @@ -
- -
\ No newline at end of file diff --git a/src/Resources/Resources.hbs b/src/Resources/Resources.hbs deleted file mode 100644 index a8c0abf..0000000 --- a/src/Resources/Resources.hbs +++ /dev/null @@ -1,184 +0,0 @@ -
-

- Local Storage -
- -
-
- -
-
- -
- {{#if localStoreSearchKeyword}}
{{localStoreSearchKeyword}}
{{/if}} -

-
- - - {{#if localStoreData}} - {{#each localStoreData}} - - - - - - {{/each}} - {{else}} - - - - {{/if}} - -
{{key}}{{val}} - -
Empty
-
-
-
-

- Session Storage -
- -
-
- -
-
- -
- {{#if sessionStoreSearchKeyword}}
{{sessionStoreSearchKeyword}}
{{/if}} -

-
- - - {{#if sessionStoreData}} - {{#each sessionStoreData}} - - - - - - {{/each}} - {{else}} - - - - {{/if}} - -
{{key}}{{val}} - -
Empty
-
-
-
-

- Cookie -
- -
-
- -
-
- -
- {{#if cookieSearchKeyword}}
{{cookieSearchKeyword}}
{{/if}} -

-
- - - {{#if cookieData}} - {{#each cookieData}} - - - - - - {{/each}} - {{else}} - - - - {{/if}} - -
{{key}}{{val}} - -
Empty
-
-
-
-

- Script -
- -
-

- -
-
-

- Stylesheet -
- -
-

- -
-
-

- Iframe -
- -
-

- -
-
-

- Image -
- -
-

- -
diff --git a/src/Resources/Resources.js b/src/Resources/Resources.js index 5fc2753..99accfb 100644 --- a/src/Resources/Resources.js +++ b/src/Resources/Resources.js @@ -1,6 +1,8 @@ import Tool from '../DevTools/Tool' import Settings from '../Settings/Settings' import $ from 'licia/$' +import escape from 'licia/escape' +import isEmpty from 'licia/isEmpty' import unique from 'licia/unique' import each from 'licia/each' import isStr from 'licia/isStr' @@ -17,7 +19,7 @@ import lowerCase from 'licia/lowerCase' import contain from 'licia/contain' import filter from 'licia/filter' import map from 'licia/map' -import { safeStorage, isErudaEl } from '../lib/util' +import { safeStorage, isErudaEl, classPrefix as c } from '../lib/util' import evalCss from '../lib/evalCss' import chobitsu from '../lib/chobitsu' import LunaModal from 'luna-modal' @@ -41,7 +43,6 @@ export default class Resources extends Tool { this._iframeData = [] this._imageData = [] this._observeElement = true - this._tpl = require('./Resources.hbs') } init($el, container) { super.init($el) @@ -395,7 +396,6 @@ export default class Resources extends Tool { .separator() } _render() { - const cookieData = this._cookieData const scriptData = this._scriptData const stylesheetData = this._stylesheetData const imageData = this._imageData @@ -416,29 +416,263 @@ export default class Resources extends Tool { }) } - this._renderHtml( - this._tpl({ - localStoreData: filterData( - this._localStoreData, + const localStoreData = filterData( + this._localStoreData, + localStoreSearchKeyword + ) + let localStoreDataHtml = 'Empty' + if (!isEmpty(localStoreData)) { + localStoreDataHtml = map(localStoreData, ({ key, val }) => { + key = escape(key) + + return ` + ${key} + ${escape(val)} + + + + ` + }).join('') + } + + const localStorageHtml = `
+

+ Local Storage +
+ +
+
+ +
+
+ +
+ ${ localStoreSearchKeyword - ), - localStoreSearchKeyword, - sessionStoreData: filterData( - this._sessionStoreData, + ? `
${escape( + localStoreSearchKeyword + )}
` + : '' + } +

+
+ + + ${localStoreDataHtml} + +
+
+
` + + const sessionStoreData = filterData( + this._sessionStoreData, + sessionStoreSearchKeyword + ) + + let sessionStoreDataHtml = 'Empty' + if (!isEmpty(sessionStoreData)) { + sessionStoreDataHtml = map(sessionStoreData, ({ key, val }) => { + key = escape(key) + + return ` + ${key} + ${escape(val)} + + + + ` + }).join('') + } + + const sessionStorageHtml = `
+

+ Session Storage +
+ +
+
+ +
+
+ +
+ ${ sessionStoreSearchKeyword - ), - sessionStoreSearchKeyword, - cookieData: filterData(cookieData, cookieSearchKeyword), - cookieSearchKeyword, - cookieState: getState('cookie', cookieData.length), - scriptData, - scriptState: getState('script', scriptData.length), - stylesheetData, - stylesheetState: getState('stylesheet', stylesheetData.length), - iframeData: this._iframeData, - imageData, - imageState: getState('image', imageData.length), - }) + ? `
${escape( + sessionStoreSearchKeyword + )}
` + : '' + } +

+
+ + + ${sessionStoreDataHtml} + +
+
+
` + + const cookieData = filterData(this._cookieData, cookieSearchKeyword) + const cookieState = getState('cookie', this._cookieData.length) + + let cookieDataHtml = 'Empty' + if (!isEmpty(cookieData)) { + cookieDataHtml = map(cookieData, ({ key, val }) => { + key = escape(key) + + return ` + ${key} + ${escape(val)} + + + + ` + }).join('') + } + + const cookieHtml = `` + + const scriptState = getState('script', scriptData.length) + let scriptDataHtml = '
  • Empty
  • ' + if (!isEmpty(scriptData)) { + scriptDataHtml = map(scriptData, (script) => { + script = escape(script) + return `
  • ${script}
  • ` + }).join('') + } + + const scriptHtml = `
    +

    + Script +
    + +
    +

    + +
    ` + + const stylesheetState = getState('stylesheet', stylesheetData.length) + let stylesheetDataHtml = '
  • Empty
  • ' + if (!stylesheetData) { + stylesheetDataHtml = map(stylesheetData, (stylesheet) => { + stylesheet = escape(stylesheet) + return `
  • ${stylesheet}
  • ` + }).join('') + } + + const stylesheetHtml = `
    +

    + Stylesheet +
    + +
    +

    + +
    ` + + let iframeDataHtml = '
  • Empty
  • ' + if (!isEmpty(this._iframeData)) { + iframeDataHtml = map(this._iframeData, (iframe) => { + iframe = escape(iframe) + return `
  • ${iframe}
  • ` + }).join('') + } + const iframeHtml = `
    +

    + Iframe +
    + +
    +

    + +
    ` + + const imageState = getState('image', imageData.length) + let imageDataHtml = '
  • Empty
  • ' + if (!isEmpty(imageData)) { + imageDataHtml = map(imageData, (image) => { + return `
  • + +
  • ` + }).join('') + } + + const imageHtml = `
    +

    + Image +
    + +
    +

    + +
    ` + + this._renderHtml( + [ + localStorageHtml, + sessionStorageHtml, + cookieHtml, + scriptHtml, + stylesheetHtml, + iframeHtml, + imageHtml, + ].join('') ) } _renderHtml(html) {