Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@iannisz/node-cms

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iannisz/node-cms - npm Package Compare versions

Comparing version 0.0.43 to 0.0.44

static/root/admin-panel/js/searchboxes.js

2

package.json
{
"name": "@iannisz/node-cms",
"version": "0.0.43",
"version": "0.0.44",
"description": "Node CMS",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,2 +0,2 @@

const popup = (title, body, buttons = [], inputs = [], disappearsAfterMs) => new Promise((resolve, reject) => {
const popup = (title, body, buttons = [], inputs = [], disappearsAfterMs) => new Promise(resolve => {
const popupEl = document.createElement('div');

@@ -9,2 +9,4 @@ popupEl.classList.add('popup');

`;
// Add popup to the page
document.body.appendChild(popupEl);
const getInputValues = () => {

@@ -34,7 +36,7 @@ const inputResults = new Map();

const inputEl = document.createElement('input');
// Add it to the popup
popupEl.appendChild(inputEl);
inputEl.type = input.type;
inputEl.placeholder = input.placeholder;
// Todo: fix this bug: the value is not shown
if (input.value != undefined) {
inputEl.value = input.value;
if (input.placeholder != undefined) {
inputEl.placeholder = input.placeholder;
}

@@ -45,3 +47,7 @@ inputEl.setAttribute('data-name', input.name);

inputEl.setAttribute('data-id', randomId);
popupEl.appendChild(inputEl);
// Todo: fix this bug: the value is not shown
if (input.value != undefined) {
// html value="X" will set the default value, js el.value does not work
inputEl.setAttribute('value', input.value);
}
popupEl.innerHTML += /* html */ `

@@ -78,18 +84,18 @@ <br><br>

}
buttonEl.addEventListener('click', () => {
const inputResults = getInputValues();
removePopup();
resolve({
buttonName: button.name,
inputs: inputResults
// Resolve on click
if (button.resolvesPopup != false) {
buttonEl.addEventListener('click', () => {
const inputResults = getInputValues();
removePopup();
resolve({
buttonName: button.name,
inputs: inputResults
});
});
});
}
popupEl.appendChild(buttonEl);
}
// Add popup to the page
document.body.appendChild(popupEl);
// Close popup when x button or escape is pressed
popupEl.querySelector('a.popup-close-button').addEventListener('click', () => {
removePopup();
reject();
});

@@ -106,10 +112,7 @@ const escapePressHandler = (e) => {

removePopup();
reject();
}, disappearsAfterMs);
}
});
const notification = (title, body, disappearsAfterMs = 3000) => new Promise((resolve) => {
popup(title, body, [], [], disappearsAfterMs)
// Buttonless popup can only reject
.catch(resolve);
});
const notification = (title, body, disappearsAfterMs = 3000) => {
popup(title, body, [], [], disappearsAfterMs);
};

@@ -5,4 +5,5 @@ interface PopupButton {

on?: {
[key in keyof HTMLElementEventMap]?: Function
[key in keyof HTMLElementEventMap]?: (e: HTMLElementEventMap[key]) => any
}
resolvesPopup?: boolean
}

@@ -12,3 +13,3 @@

name: string
placeholder: string
placeholder?: string
value?: string

@@ -30,3 +31,3 @@ type: 'button' | 'checkbox' | 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'hidden' | 'image' | 'month' | 'number' | 'password' | 'radio' | 'range' | 'reset' | 'search' | 'submit' | 'tel' | 'text' | 'time' | 'url' | 'week'

disappearsAfterMs?: number
) => new Promise<PopupResult>((resolve, reject) => {
) => new Promise<PopupResult>(resolve => {
const popupEl = document.createElement('div')

@@ -42,2 +43,6 @@

// Add popup to the page
document.body.appendChild(popupEl)
const getInputValues = () => {

@@ -75,9 +80,10 @@ const inputResults = new Map<string, string>()

// Add it to the popup
popupEl.appendChild(inputEl)
inputEl.type = input.type
inputEl.placeholder = input.placeholder
// Todo: fix this bug: the value is not shown
if (input.value != undefined) {
inputEl.value = input.value
if (input.placeholder != undefined) {
inputEl.placeholder = input.placeholder
}

@@ -91,4 +97,11 @@

inputEl.setAttribute('data-id', randomId)
popupEl.appendChild(inputEl)
// Todo: fix this bug: the value is not shown
if (input.value != undefined) {
// html value="X" will set the default value, js el.value does not work
inputEl.setAttribute('value', input.value)
}
popupEl.innerHTML += /* html */ `

@@ -134,20 +147,21 @@ <br><br>

buttonEl.addEventListener('click', () => {
const inputResults = getInputValues()
// Resolve on click
removePopup()
resolve({
buttonName: button.name,
inputs: inputResults
if (button.resolvesPopup != false) {
buttonEl.addEventListener('click', () => {
const inputResults = getInputValues()
removePopup()
resolve({
buttonName: button.name,
inputs: inputResults
})
})
})
}
popupEl.appendChild(buttonEl)
}
// Add popup to the page
document.body.appendChild(popupEl)
// Close popup when x button or escape is pressed

@@ -157,3 +171,2 @@

removePopup()
reject()
})

@@ -173,3 +186,2 @@

removePopup()
reject()
}, disappearsAfterMs)

@@ -183,6 +195,4 @@ }

disappearsAfterMs: number = 3000
) => new Promise<undefined>((resolve) => {
) => {
popup(title, body, [], [], disappearsAfterMs)
// Buttonless popup can only reject
.catch(resolve)
})
}
const $ = (query) => document.querySelector(query);
const $a = (query) => Array.prototype.slice.call(document.querySelectorAll(query));
HTMLElement.prototype.$ = function (query) {
return this.querySelector(query);
};
HTMLElement.prototype.$a = function (query) {
return Array.prototype.slice.call(this.querySelectorAll(query));
};

@@ -7,2 +7,19 @@ const $ = <T = HTMLElement>(

query: string
) => Array.prototype.slice.call(document.querySelectorAll(query)) as unknown as T[]
) => Array.prototype.slice.call(document.querySelectorAll(query)) as unknown as T[]
interface HTMLElement {
$: <T = HTMLElement>(query: string) => T
$a: <T = HTMLElement>(query: string) => T[]
}
HTMLElement.prototype.$ = function <T = HTMLElement>(
query: string
) {
return this.querySelector(query) as T
}
HTMLElement.prototype.$a = function <T = HTMLElement>(
query: string
) {
return Array.prototype.slice.call(this.querySelectorAll(query)) as T[]
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc