Skip to content

Commit

Permalink
Condensed import(), moved def + dependencies inside dependencies
Browse files Browse the repository at this point in the history
…for improved structure ↞ [auto-sync from https://github.com/KudoAI/chatgpt.js-chrome-starter]
  • Loading branch information
kudo-sync-bot committed Dec 5, 2024
1 parent 089d84d commit b24dc8f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
5 changes: 3 additions & 2 deletions starters/chrome/extension/components/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

window.icons = {

import(dependencies) { Object.entries(dependencies).forEach(([name, dependency]) => this[name] = dependency) },
import(dependencies) { // { app }
for (const name in dependencies) this[name] = dependencies[name] },

create({ name, size = 16, width, height, ...additionalAttrs }) {
const iconData = icons[name],
Expand All @@ -24,6 +25,6 @@ window.icons = {

questionMark: {
type: 'png',
get src() { return `${icons.app.urls.assetHost}@b5551ac/images/icons/question-mark/icon16.png` }
get src() { return `${icons.dependencies.app.urls.assetHost}@b5551ac/images/icons/question-mark/icon16.png` }
}
};
26 changes: 14 additions & 12 deletions starters/chrome/extension/components/modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
window.modals = {
stack: [], // of types of undismissed modals

import(dependencies) { // { app, siteAlert }
Object.entries(dependencies).forEach(([name, dependency]) => this[name] = dependency) },
dependencies: {
import(dependencies) { // { app, siteAlert }
for (const name in dependencies) this[name] = dependencies[name] }
},

open(modalType) {
this.stack.unshift(modalType) // add to stack
Expand Down Expand Up @@ -71,23 +73,23 @@ window.modals = {

// Init buttons
const modalBtns = [
function getSupport(){ modals.safeWinOpen(`${modals.app.urls.gitHub}/issues`) },
function rateUs() { modals.safeWinOpen(`${modals.app.urls.gitHub}/discussions`) },
function moreAiExtensions(){ modals.safeWinOpen(modals.app.urls.relatedExtensions) }
function getSupport(){ modals.safeWinOpen(`${modals.dependencies.app.urls.gitHub}/issues`) },
function rateUs() { modals.safeWinOpen(`${modals.dependencies.app.urls.gitHub}/discussions`) },
function moreAiExtensions(){ modals.safeWinOpen(modals.dependencies.app.urls.relatedExtensions) }
]

// Show modal
const aboutModal = this.siteAlert(
`${this.app.symbol} ${chrome.runtime.getManifest().name}`, // title
const aboutModal = this.dependencies.siteAlert(
`${this.dependencies.app.symbol} ${chrome.runtime.getManifest().name}`, // title
`<span style="${headingStyle}"><b>🏷️ <i>Version</i></b>: </span>`
+ `<span style="${pStyle}">${this.app.version}</span>\n`
+ `<span style="${pStyle}">${this.dependencies.app.version}</span>\n`
+ `<span style="${headingStyle}"><b>⚡ <i>Powered by</i></b>: </span>`
+ `<span style="${pStyle}">`
+ `<a style="${aStyle}" href="${this.app.urls.chatgptJS}" target="_blank" rel="noopener">`
+ 'chatgpt.js</a></span>\n'
+ `<a style="${aStyle}" href="${this.dependencies.app.urls.chatgptJS}" target="_blank"`
+ ' rel="noopener">chatgpt.js</a></span>\n'
+ `<span style="${headingStyle}"><b>📜 <i>Open source code</i></b>:</span>\n`
+ `<span style="${pBrStyle}"><a href="${this.app.urls.gitHub}" target="_blank" rel="nopener">`
+ this.app.urls.gitHub + '</a></span>',
+ `<span style="${pBrStyle}"><a href="${this.dependencies.app.urls.gitHub}" target="_blank"`
+ ` rel="nopener">${this.dependencies.app.urls.gitHub}</a></span>`,
modalBtns, '', 451
)

Expand Down
2 changes: 1 addition & 1 deletion starters/chrome/extension/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

// Import APP data
const { app } = await chrome.storage.sync.get('app')
modals.import({ app, siteAlert })
modals.dependencies.import({ app, siteAlert })

// Add CHROME MSG listener
chrome.runtime.onMessage.addListener(req => { // from service-worker.js + popup/index.html
Expand Down
2 changes: 1 addition & 1 deletion starters/chrome/extension/popup/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// Import APP data
const { app } = await chrome.storage.sync.get('app')
icons.import({ app }) // for src's using app.urls.assetHost
icons.dependencies.import({ app }) // for src's using app.urls.assetHost

// Define FUNCTIONS

Expand Down

0 comments on commit b24dc8f

Please sign in to comment.