code stringlengths 24 2.07M | docstring stringlengths 25 85.3k | func_name stringlengths 1 92 | language stringclasses 1
value | repo stringlengths 5 64 | path stringlengths 4 172 | url stringlengths 44 218 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
isSpawnedDaemonDead = (ipfsd) => {
if (typeof ipfsd.subprocess === 'undefined') throw new Error('undefined ipfsd.subprocess, unable to reason about startup errors')
if (ipfsd.subprocess === null) return false // not spawned yet or remote
if (ipfsd.subprocess?.failed) return true // explicit failure
// ... | Start IPFS, collects the logs, detects errors and migrations.
@param {import('ipfsd-ctl').Controller} ipfsd
@returns {Promise<IpfsLogs>} | isSpawnedDaemonDead | javascript | ipfs/ipfs-desktop | src/daemon/daemon.js | https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/daemon.js | MIT |
async function startDaemon (opts) {
const ipfsd = await getIpfsd(opts.flags, opts.path)
if (ipfsd === null) {
app.quit()
return { ipfsd: undefined, err: new Error('get ipfsd failed'), id: undefined, logs: '' }
}
let { err, logs, id } = await startIpfsWithLogs(ipfsd)
if (err) {
if (!err.message.in... | Start the IPFS daemon.
@param {any} opts
@returns {Promise<{ ipfsd: import('ipfsd-ctl').Controller|undefined } & IpfsLogs>} | startDaemon | javascript | ipfs/ipfs-desktop | src/daemon/daemon.js | https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/daemon.js | MIT |
function cannotConnectToApiDialog (addr) {
hideOtherWindows()
showDialog({
title: i18n.t('cannotConnectToApiDialog.title'),
message: i18n.t('cannotConnectToApiDialog.message', { addr }),
type: 'error',
buttons: [
i18n.t('quit')
]
})
} | Dialog to show when the daemon cannot connect to remote API.
@param {string} addr | cannotConnectToApiDialog | javascript | ipfs/ipfs-desktop | src/daemon/dialogs.js | https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/dialogs.js | MIT |
function multipleBusyPortsDialog () {
hideOtherWindows()
const opt = showDialog({
title: i18n.t('multipleBusyPortsDialog.title'),
message: i18n.t('multipleBusyPortsDialog.message'),
type: 'error',
buttons: [
i18n.t('multipleBusyPortsDialog.action'),
i18n.t('quit')
]
})
return op... | Dialog to show when there are multiple busy ports.
@returns {boolean} open the configuration file | multipleBusyPortsDialog | javascript | ipfs/ipfs-desktop | src/daemon/dialogs.js | https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/dialogs.js | MIT |
function busyPortDialog (port, alt) {
hideOtherWindows()
const opt = showDialog({
title: i18n.t('busyPortDialog.title'),
message: i18n.t('busyPortDialog.message', { port, alt }),
type: 'error',
buttons: [
i18n.t('busyPortDialog.action', { port, alt }),
i18n.t('quit')
]
})
return... | Dialog to show when there is a busy port and we offer an alternative.
@param {Number} port is the busy port
@param {Number} alt is the alternative free port
@returns {boolean} use the alternative port | busyPortDialog | javascript | ipfs/ipfs-desktop | src/daemon/dialogs.js | https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/dialogs.js | MIT |
function busyPortsDialog (port1, alt1, port2, alt2) {
hideOtherWindows()
const opt = showDialog({
title: i18n.t('busyPortsDialog.title'),
message: i18n.t('busyPortsDialog.message', { port1, alt1, port2, alt2 }),
type: 'error',
buttons: [
i18n.t('busyPortsDialog.action', { port1, alt1, port2, a... | Dialog to show when there are two busy ports and we offer an alternative.
@param {Number} port1 is the busy port 1
@param {Number} alt1 is the alternative free port 1
@param {Number} port2 is the busy port 2
@param {Number} alt2 is the alternative free port 2
@returns {boolean} use the alternative port | busyPortsDialog | javascript | ipfs/ipfs-desktop | src/daemon/dialogs.js | https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/dialogs.js | MIT |
function hideWindowsAndShowDialog (i18nKey, opts) {
hideOtherWindows()
showDialog({
title: i18n.t(`${i18nKey}.title`),
message: i18n.t(`${i18nKey}.message`, opts),
buttons: [i18n.t('quit')]
})
} | Show the dialog with the text from the i18nKey, using the
options opts.
@param {string} i18nKey
@param {any} opts | hideWindowsAndShowDialog | javascript | ipfs/ipfs-desktop | src/daemon/dialogs.js | https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/dialogs.js | MIT |
function repositoryIsPrivateDialog (path) {
hideWindowsAndShowDialog('privateNetworkDialog', { path })
} | Dialog to show when the repository is part of a private network.
@param {string} path | repositoryIsPrivateDialog | javascript | ipfs/ipfs-desktop | src/daemon/dialogs.js | https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/dialogs.js | MIT |
function repositoryMustBeDirectoryDialog (path) {
hideWindowsAndShowDialog('repositoryMustBeDirectoryDialog', { path })
} | Dialog to show when we detect that the repository is not a directory.
@param {string} path | repositoryMustBeDirectoryDialog | javascript | ipfs/ipfs-desktop | src/daemon/dialogs.js | https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/dialogs.js | MIT |
function repositoryConfigurationIsMissingDialog (path) {
hideWindowsAndShowDialog('repositoryConfigurationIsMissingDialog', { path })
} | Dialog to show when we detect that the configuration file is missing.
@param {string} path | repositoryConfigurationIsMissingDialog | javascript | ipfs/ipfs-desktop | src/daemon/dialogs.js | https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/dialogs.js | MIT |
function repositoryIsInvalidDialog (path) {
hideWindowsAndShowDialog('invalidRepositoryDialog', { path })
} | Dialog to show when we detect that the repository is invalid, but we
are not sure what the problem is.
@param {string} path | repositoryIsInvalidDialog | javascript | ipfs/ipfs-desktop | src/daemon/dialogs.js | https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/dialogs.js | MIT |
function showMigrationPrompt (logs, error = false, done = false) {
// Generate random id
const id = crypto.randomBytes(16).toString('hex')
const loadWindow = (logs, error = false, done = false) => {
if (!window) {
window = new BrowserWindow({
show: false,
width: 800,
height: 438... | Show migration prompt.
@param {string} logs
@param {boolean} error
@param {boolean} done
@returns {MigrationPrompt} | showMigrationPrompt | javascript | ipfs/ipfs-desktop | src/daemon/migration-prompt.js | https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/migration-prompt.js | MIT |
loadWindow = (logs, error = false, done = false) => {
if (!window) {
window = new BrowserWindow({
show: false,
width: 800,
height: 438,
useContentSize: true,
resizable: false,
autoHideMenuBar: true,
fullscreenable: false,
backgroundColor: getBack... | Show migration prompt.
@param {string} logs
@param {boolean} error
@param {boolean} done
@returns {MigrationPrompt} | loadWindow | javascript | ipfs/ipfs-desktop | src/daemon/migration-prompt.js | https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/migration-prompt.js | MIT |
loadWindow = (logs, error = false, done = false) => {
if (!window) {
window = new BrowserWindow({
show: false,
width: 800,
height: 438,
useContentSize: true,
resizable: false,
autoHideMenuBar: true,
fullscreenable: false,
backgroundColor: getBack... | Show migration prompt.
@param {string} logs
@param {boolean} error
@param {boolean} done
@returns {MigrationPrompt} | loadWindow | javascript | ipfs/ipfs-desktop | src/daemon/migration-prompt.js | https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/migration-prompt.js | MIT |
function criticalErrorDialog (e) {
if (hasErrored) return
hasErrored = true
const option = dialog({
title: i18n.t('ipfsDesktopHasShutdownDialog.title'),
message: i18n.t('ipfsDesktopHasShutdownDialog.message'),
type: 'error',
buttons: [
i18n.t('restartIpfsDesktop'),
i18n.t('close'),
... | This will fail and throw another application error if electron hasn't booted up properly.
@param {Error} e
@returns | criticalErrorDialog | javascript | ipfs/ipfs-desktop | src/dialogs/errors.js | https://github.com/ipfs/ipfs-desktop/blob/master/src/dialogs/errors.js | MIT |
function recoverableErrorDialog (e, options) {
const cfg = {
title: i18n.t('recoverableErrorDialog.title'),
message: i18n.t('recoverableErrorDialog.message'),
type: 'error',
buttons: [
i18n.t('close'),
i18n.t('reportTheError'),
i18n.t('openLogs')
]
}
if (options) {
if (o... | This will fail and throw another application error if electron hasn't booted up properly.
@param {Error} e
@returns | recoverableErrorDialog | javascript | ipfs/ipfs-desktop | src/dialogs/errors.js | https://github.com/ipfs/ipfs-desktop/blob/master/src/dialogs/errors.js | MIT |
async function startApp ({ repoPath } = {}) {
const home = tmp.dirSync({ prefix: 'tmp_home_', unsafeCleanup: true }).name
if (!repoPath) {
repoPath = path.join(home, '.ipfs')
}
app = await electron.launch({
args: [path.join(__dirname, '../../src/index.js')],
env: Object.assign({}, proc... | @param {Object} [param0]
@param {string} param0.repoPath
@returns {Promise<{ app: Awaited<ReturnType<import('playwright')._electron['launch']>>, repoPath: string, home: string }> | startApp | javascript | ipfs/ipfs-desktop | test/e2e/launch.e2e.test.js | https://github.com/ipfs/ipfs-desktop/blob/master/test/e2e/launch.e2e.test.js | MIT |
async function daemonReady (app) {
const peerId = await app.evaluate(async ({ ipcMain }) => new Promise((resolve, reject) => {
ipcMain.on('ipfsd', (status, peerId) => {
switch (status) {
// NOTE: this code runs inside the main process of electron, so we cannot use
// things we've i... | @param {Awaited<ReturnType<import('playwright')._electron['launch']>>} app
@returns {Promise<{ peerId: string }> | daemonReady | javascript | ipfs/ipfs-desktop | test/e2e/launch.e2e.test.js | https://github.com/ipfs/ipfs-desktop/blob/master/test/e2e/launch.e2e.test.js | MIT |
function flattenTree({ tree, simple, radio, showPartialState, hierarchical, rootPrefixId }) {
const forest = Array.isArray(tree) ? tree : [tree]
// eslint-disable-next-line no-use-before-define
return walkNodes({
nodes: forest,
simple,
radio,
showPartialState,
hierarchical,
rootPrefixId,
... | Converts a nested node into an associative array with pointers to child and parent nodes
Given:
```
const tree = [
{
label: 'item1',
value: 'value1',
children: [
{
label: 'item1-1',
value: 'value1-1',
children: [
{
label: 'item1-1-1',
value: ... | flattenTree | javascript | dowjones/react-dropdown-tree-select | src/tree-manager/flatten-tree.js | https://github.com/dowjones/react-dropdown-tree-select/blob/master/src/tree-manager/flatten-tree.js | MIT |
function setInitialStateProps(node, parent = {}, inheritChecked = true) {
const stateProps = inheritChecked ? ['checked', 'disabled'] : ['disabled']
for (let index = 0; index < stateProps.length; index++) {
const prop = stateProps[index]
// if and only if, node doesn't explicitly define a prop, grab it fro... | If the node didn't specify anything on its own
figure out the initial state based on parent
@param {object} node [current node]
@param {object} parent [node's immediate parent]
@param {bool} inheritChecked [if checked should be inherited] | setInitialStateProps | javascript | dowjones/react-dropdown-tree-select | src/tree-manager/flatten-tree.js | https://github.com/dowjones/react-dropdown-tree-select/blob/master/src/tree-manager/flatten-tree.js | MIT |
function walkNodes({
nodes,
parent,
depth = 0,
simple,
radio,
showPartialState,
hierarchical,
rootPrefixId,
_rv = { list: new Map(), defaultValues: [], singleSelectedNode: null },
}) {
const single = simple || radio
nodes.forEach((node, i) => {
node._depth = depth
if (parent) {
node... | If the node didn't specify anything on its own
figure out the initial state based on parent
@param {object} node [current node]
@param {object} parent [node's immediate parent]
@param {bool} inheritChecked [if checked should be inherited] | walkNodes | javascript | dowjones/react-dropdown-tree-select | src/tree-manager/flatten-tree.js | https://github.com/dowjones/react-dropdown-tree-select/blob/master/src/tree-manager/flatten-tree.js | MIT |
unCheckParents(node) {
let parent = node._parent
while (parent) {
const next = this.getNodeById(parent)
next.checked = false
next.partial = getPartialState(next, '_children', this.getNodeById.bind(this))
parent = next._parent
}
} | Walks up the tree unchecking parent nodes
@param {[type]} node [description]
@return {[type]} [description] | unCheckParents | javascript | dowjones/react-dropdown-tree-select | src/tree-manager/index.js | https://github.com/dowjones/react-dropdown-tree-select/blob/master/src/tree-manager/index.js | MIT |
partialCheckParents(node) {
let parent = node._parent
while (parent) {
const next = this.getNodeById(parent)
next.checked = next._children.every(c => this.getNodeById(c).checked)
next.partial = getPartialState(next, '_children', this.getNodeById.bind(this))
parent = next._parent
}
... | Walks up the tree setting partial state on parent nodes
@param {[type]} node [description]
@return {[type]} [description] | partialCheckParents | javascript | dowjones/react-dropdown-tree-select | src/tree-manager/index.js | https://github.com/dowjones/react-dropdown-tree-select/blob/master/src/tree-manager/index.js | MIT |
toggleChildren(id, state) {
const node = this.getNodeById(id)
node.checked = state
if (this.showPartialState) {
node.partial = false
}
if (!isEmpty(node._children)) {
node._children.forEach(id => this.toggleChildren(id, state))
}
} | Walks up the tree setting partial state on parent nodes
@param {[type]} node [description]
@return {[type]} [description] | toggleChildren | javascript | dowjones/react-dropdown-tree-select | src/tree-manager/index.js | https://github.com/dowjones/react-dropdown-tree-select/blob/master/src/tree-manager/index.js | MIT |
toggleNodeExpandState(id) {
const node = this.getNodeById(id)
node.expanded = !node.expanded
if (!node.expanded) this.collapseChildren(node)
return this.tree
} | Walks up the tree setting partial state on parent nodes
@param {[type]} node [description]
@return {[type]} [description] | toggleNodeExpandState | javascript | dowjones/react-dropdown-tree-select | src/tree-manager/index.js | https://github.com/dowjones/react-dropdown-tree-select/blob/master/src/tree-manager/index.js | MIT |
collapseChildren(node) {
node.expanded = false
if (!isEmpty(node._children)) {
node._children.forEach(c => this.collapseChildren(this.getNodeById(c)))
}
} | Walks up the tree setting partial state on parent nodes
@param {[type]} node [description]
@return {[type]} [description] | collapseChildren | javascript | dowjones/react-dropdown-tree-select | src/tree-manager/index.js | https://github.com/dowjones/react-dropdown-tree-select/blob/master/src/tree-manager/index.js | MIT |
get tags() {
if (this.radioSelect || this.simpleSelect) {
if (this.currentChecked) {
return [this.getNodeById(this.currentChecked)]
}
return []
}
return nodeVisitor.getNodesMatching(this.tree, (node, key, visited) => {
if (node.checked && !this.hierarchical) {
// Par... | Walks up the tree setting partial state on parent nodes
@param {[type]} node [description]
@return {[type]} [description] | tags | javascript | dowjones/react-dropdown-tree-select | src/tree-manager/index.js | https://github.com/dowjones/react-dropdown-tree-select/blob/master/src/tree-manager/index.js | MIT |
getTreeAndTags() {
return { tree: this.tree, tags: this.tags }
} | Walks up the tree setting partial state on parent nodes
@param {[type]} node [description]
@return {[type]} [description] | getTreeAndTags | javascript | dowjones/react-dropdown-tree-select | src/tree-manager/index.js | https://github.com/dowjones/react-dropdown-tree-select/blob/master/src/tree-manager/index.js | MIT |
handleNavigationKey(currentFocus, tree, key, readOnly, markSubTreeOnNonExpanded, onToggleChecked, onToggleExpanded) {
const prevFocus = currentFocus && this.getNodeById(currentFocus)
const getNodeById = id => this.getNodeById(id)
const action = keyboardNavigation.getAction(prevFocus, key)
if (FocusActi... | Walks up the tree setting partial state on parent nodes
@param {[type]} node [description]
@return {[type]} [description] | handleNavigationKey | javascript | dowjones/react-dropdown-tree-select | src/tree-manager/index.js | https://github.com/dowjones/react-dropdown-tree-select/blob/master/src/tree-manager/index.js | MIT |
_getAddOnMatch(matches, searchTerm) {
let isMatch = (node, term) => node.label.toLowerCase().indexOf(term) >= 0
if (typeof this.searchPredicate === 'function') {
isMatch = this.searchPredicate
}
return node => {
if (isMatch(node, searchTerm)) {
matches.push(node._id)
}
}
... | Walks up the tree setting partial state on parent nodes
@param {[type]} node [description]
@return {[type]} [description] | _getAddOnMatch | javascript | dowjones/react-dropdown-tree-select | src/tree-manager/index.js | https://github.com/dowjones/react-dropdown-tree-select/blob/master/src/tree-manager/index.js | MIT |
later = () => {
timeout = null
func(...args)
} | Modified debounce that always invokes on leading edge
See unmodified: https://gist.github.com/mrchief/a7e8938ee96774f05644905b37f09536 | later | javascript | dowjones/react-dropdown-tree-select | src/utils/debounce.js | https://github.com/dowjones/react-dropdown-tree-select/blob/master/src/utils/debounce.js | MIT |
later = () => {
timeout = null
func(...args)
} | Modified debounce that always invokes on leading edge
See unmodified: https://gist.github.com/mrchief/a7e8938ee96774f05644905b37f09536 | later | javascript | dowjones/react-dropdown-tree-select | src/utils/debounce.js | https://github.com/dowjones/react-dropdown-tree-select/blob/master/src/utils/debounce.js | MIT |
function timeout(ms) {
return new Promise((resolve, reject) => {
setTimeout(resolve, ms, 'done');
});
} | Tiemout
@param int ms
@return Promise<any> | timeout | javascript | unruledboy/WebFrontEndStack | index.js | https://github.com/unruledboy/WebFrontEndStack/blob/master/index.js | Apache-2.0 |
function buildReadme(object, language, deep) {
let deeper = deep + 1;
let deepString = new Array(deeper).join("\t") + "- ";
let ret = [];
let lang = "";
if (object.languages) {
lang = object.languages[language];
}
lang = lang || object.name;
ret.push((function (deepString, name, url, github) {
le... | Recursion to generate readme
@param object object
@param string language
@param int deep
@return string | buildReadme | javascript | unruledboy/WebFrontEndStack | index.js | https://github.com/unruledboy/WebFrontEndStack/blob/master/index.js | Apache-2.0 |
function phantomjs(language) {
let displayLanguage = language === "" ? "en" : language;
let promise = new Promise((resolve, reject) => {
return phantom.createAsync().then((phantom) => {
return phantom.createPageAsync();
}).then((objects) => {
console.log("Setting viewportSize..");
return objects.p... | For running phantomjs to take a screenshot for the webpage
@return Promise<any> | phantomjs | javascript | unruledboy/WebFrontEndStack | index.js | https://github.com/unruledboy/WebFrontEndStack/blob/master/index.js | Apache-2.0 |
function readme(language) {
let extension = (language === "" ? "" : ".") + language;
let promise = new Promise((resolve, reject) => {
fs.readFile('./README' + extension + '.md', "utf-8", (err, content) => {
if (err) return reject(err);
resolve(content);
});
});
return promise.then((fileContent) =>... | To rebuild the README.md
@return Promise<any> | readme | javascript | unruledboy/WebFrontEndStack | index.js | https://github.com/unruledboy/WebFrontEndStack/blob/master/index.js | Apache-2.0 |
function server() {
return new Promise((resolve, reject) => {
return app
.set('port', options.port)
.set('view engine', 'html')
.use(Express.static(path.join(__dirname, '/ux')))
.use('/', function (req, res) {
res.redirect('/WebFrontEndStack.htm?locale=' + req.query.locale);
})
.listen... | To start an express server
@return Promise<any> | server | javascript | unruledboy/WebFrontEndStack | index.js | https://github.com/unruledboy/WebFrontEndStack/blob/master/index.js | Apache-2.0 |
async function up(knex) {
const hasRole = await knex.schema.hasColumn("users", "role");
if (!hasRole) {
await knex.transaction(async function(trx) {
await trx.schema.alterTable("users", table => {
table
.enu("role", [ROLES.USER, ROLES.ADMIN])
.notNullable()
.defaultTo... | @param { import("knex").Knex } knex
@returns { Promise<void> } | up | javascript | thedevs-network/kutt | server/migrations/20241103083933_user-roles.js | https://github.com/thedevs-network/kutt/blob/master/server/migrations/20241103083933_user-roles.js | MIT |
async function up(knex) {
// make apikey unique
await knex.schema.alterTable("users", function(table) {
table.unique("apikey");
});
// IF NOT EXISTS is not available on MySQL So if you're
// using MySQL you should make sure you don't have these indexes already
const ifNotExists = isMySQL ? "" : "IF ... | @param { import("knex").Knex } knex
@returns { Promise<void> } | up | javascript | thedevs-network/kutt | server/migrations/20241223062111_indexes.js | https://github.com/thedevs-network/kutt/blob/master/server/migrations/20241223062111_indexes.js | MIT |
async function down(knex) {
await knex.schema.alterTable("users", function(table) {
table.dropUnique(["apikey"]);
});
await Promise.all([
knex.raw(`DROP INDEX links_domain_id_index;`),
knex.raw(`DROP INDEX links_user_id_index;`),
knex.raw(`DROP INDEX links_address_index;`),
knex.raw(`DROP IND... | @param { import("knex").Knex } knex
@returns { Promise<void> } | down | javascript | thedevs-network/kutt | server/migrations/20241223062111_indexes.js | https://github.com/thedevs-network/kutt/blob/master/server/migrations/20241223062111_indexes.js | MIT |
async function up(knex) {
const hasUserIDColumn = await knex.schema.hasColumn("visits", "user_id");
if (hasUserIDColumn) return;
await knex.schema.alterTable("visits", function(table) {
table
.integer("user_id")
.unsigned();
table
.foreign("user_id")
.references("id")
.inTa... | @param { import("knex").Knex } knex
@returns { Promise<void> } | up | javascript | thedevs-network/kutt | server/migrations/20241223103044_visits_user_id.js | https://github.com/thedevs-network/kutt/blob/master/server/migrations/20241223103044_visits_user_id.js | MIT |
async function up(knex) {
// IF NOT EXISTS is not available on MySQL So if you're
// using MySQL you should make sure you don't have these indexes already
const ifNotExists = isMySQL ? "" : "IF NOT EXISTS";
await knex.raw(`
CREATE INDEX ${ifNotExists} visits_user_id_index ON visits (user_id);
`);
} | @param { import("knex").Knex } knex
@returns { Promise<void> } | up | javascript | thedevs-network/kutt | server/migrations/20241223155527_visits_user_id_index.js | https://github.com/thedevs-network/kutt/blob/master/server/migrations/20241223155527_visits_user_id_index.js | MIT |
async function down(knex) {
await knex.raw(`
DROP INDEX visits_user_id_index;
`);
} | @param { import("knex").Knex } knex
@returns { Promise<void> } | down | javascript | thedevs-network/kutt | server/migrations/20241223155527_visits_user_id_index.js | https://github.com/thedevs-network/kutt/blob/master/server/migrations/20241223155527_visits_user_id_index.js | MIT |
populate_bounce_message_with_headers (from, to, reason, header, cb) {
const CRLF = '\r\n';
const originalMessageId = header.get('Message-Id');
const bounce_msg_ = config.get('outbound.bounce_message', 'data');
const bounce_msg_html_ = config.get('outbound.bounce_message_html', 'data');... | Generates a bounce message
hmail.todo.rcpt_to objects should be extended as follows:
- dsn_action
- dsn_status
- dsn_code
- dsn_msg
- dsn_remote_mta
Upstream code/message goes here:
- dsn_smtp_code
- dsn_smtp_extc
- dsn_smtp_response
@param from
@param to
@param reason
@param header
@param cb - a callback for fn(er... | populate_bounce_message_with_headers | javascript | haraka/Haraka | outbound/hmail.js | https://github.com/haraka/Haraka/blob/master/outbound/hmail.js | MIT |
bounce (err, opts) {
this.loginfo(`bouncing mail: ${err}`);
if (!this.todo) {
this.once('ready', () => { this._bounce(err, opts); });
return;
}
this._bounce(err, opts);
} | Generates a bounce message
hmail.todo.rcpt_to objects should be extended as follows:
- dsn_action
- dsn_status
- dsn_code
- dsn_msg
- dsn_remote_mta
Upstream code/message goes here:
- dsn_smtp_code
- dsn_smtp_extc
- dsn_smtp_response
@param from
@param to
@param reason
@param header
@param cb - a callback for fn(er... | bounce | javascript | haraka/Haraka | outbound/hmail.js | https://github.com/haraka/Haraka/blob/master/outbound/hmail.js | MIT |
_bounce (err, opts) {
err = new Error(err);
if (opts) {
err.mx = opts.mx;
err.deferred_rcpt = opts.fail_recips;
err.bounced_rcpt = opts.bounce_recips;
}
this.bounce_error = err;
plugins.run_hooks("bounce", this, err);
} | Generates a bounce message
hmail.todo.rcpt_to objects should be extended as follows:
- dsn_action
- dsn_status
- dsn_code
- dsn_msg
- dsn_remote_mta
Upstream code/message goes here:
- dsn_smtp_code
- dsn_smtp_extc
- dsn_smtp_response
@param from
@param to
@param reason
@param header
@param cb - a callback for fn(er... | _bounce | javascript | haraka/Haraka | outbound/hmail.js | https://github.com/haraka/Haraka/blob/master/outbound/hmail.js | MIT |
bounce_respond (retval, msg) {
if (retval !== constants.cont) {
this.loginfo(`Plugin responded with: ${retval}. Not sending bounce.`);
return this.discard(); // calls next_cb
}
const self = this;
const err = this.bounce_error;
if (!this.todo.mail_from.u... | Generates a bounce message
hmail.todo.rcpt_to objects should be extended as follows:
- dsn_action
- dsn_status
- dsn_code
- dsn_msg
- dsn_remote_mta
Upstream code/message goes here:
- dsn_smtp_code
- dsn_smtp_extc
- dsn_smtp_response
@param from
@param to
@param reason
@param header
@param cb - a callback for fn(er... | bounce_respond | javascript | haraka/Haraka | outbound/hmail.js | https://github.com/haraka/Haraka/blob/master/outbound/hmail.js | MIT |
double_bounce (err) {
this.lognotice(`Double bounce: ${err}`);
fs.unlink(this.path, () => {});
this.next_cb();
// TODO: fill this in... ?
// One strategy is perhaps log to an mbox file. What do other servers do?
// Another strategy might be delivery "plugins" to cope with... | Generates a bounce message
hmail.todo.rcpt_to objects should be extended as follows:
- dsn_action
- dsn_status
- dsn_code
- dsn_msg
- dsn_remote_mta
Upstream code/message goes here:
- dsn_smtp_code
- dsn_smtp_extc
- dsn_smtp_response
@param from
@param to
@param reason
@param header
@param cb - a callback for fn(er... | double_bounce | javascript | haraka/Haraka | outbound/hmail.js | https://github.com/haraka/Haraka/blob/master/outbound/hmail.js | MIT |
delivered (ip, port, mode, host, response, ok_recips, fail_recips, bounce_recips, secured, authenticated) {
const delay = (Date.now() - this.todo.queue_time)/1000;
this.lognotice({
'delivered file': this.filename,
'domain': this.todo.domain,
host,
ip,
... | Generates a bounce message
hmail.todo.rcpt_to objects should be extended as follows:
- dsn_action
- dsn_status
- dsn_code
- dsn_msg
- dsn_remote_mta
Upstream code/message goes here:
- dsn_smtp_code
- dsn_smtp_extc
- dsn_smtp_response
@param from
@param to
@param reason
@param header
@param cb - a callback for fn(er... | delivered | javascript | haraka/Haraka | outbound/hmail.js | https://github.com/haraka/Haraka/blob/master/outbound/hmail.js | MIT |
discard () {
this.refcount--;
if (this.refcount === 0) {
// Remove the file.
fs.unlink(this.path, () => {});
this.next_cb();
}
} | Generates a bounce message
hmail.todo.rcpt_to objects should be extended as follows:
- dsn_action
- dsn_status
- dsn_code
- dsn_msg
- dsn_remote_mta
Upstream code/message goes here:
- dsn_smtp_code
- dsn_smtp_extc
- dsn_smtp_response
@param from
@param to
@param reason
@param header
@param cb - a callback for fn(er... | discard | javascript | haraka/Haraka | outbound/hmail.js | https://github.com/haraka/Haraka/blob/master/outbound/hmail.js | MIT |
convert_temp_failed_to_bounce (err, extra) {
this.todo.rcpt_to.forEach(rcpt_to => {
rcpt_to.dsn_action = 'failed';
if (rcpt_to.dsn_status) {
rcpt_to.dsn_status = (`${rcpt_to.dsn_status}`).replace(/^4/, '5');
}
});
return this.bounce(err, extra)... | Generates a bounce message
hmail.todo.rcpt_to objects should be extended as follows:
- dsn_action
- dsn_status
- dsn_code
- dsn_msg
- dsn_remote_mta
Upstream code/message goes here:
- dsn_smtp_code
- dsn_smtp_extc
- dsn_smtp_response
@param from
@param to
@param reason
@param header
@param cb - a callback for fn(er... | convert_temp_failed_to_bounce | javascript | haraka/Haraka | outbound/hmail.js | https://github.com/haraka/Haraka/blob/master/outbound/hmail.js | MIT |
temp_fail (err, extra) {
logger.debug(this, `Temp fail for: ${err}`);
this.num_failures++;
// Test for max failures which is configurable.
if (this.num_failures > (obc.cfg.temp_fail_intervals.length)) {
return this.convert_temp_failed_to_bounce(`Too many failures (${err})`, ... | Generates a bounce message
hmail.todo.rcpt_to objects should be extended as follows:
- dsn_action
- dsn_status
- dsn_code
- dsn_msg
- dsn_remote_mta
Upstream code/message goes here:
- dsn_smtp_code
- dsn_smtp_extc
- dsn_smtp_response
@param from
@param to
@param reason
@param header
@param cb - a callback for fn(er... | temp_fail | javascript | haraka/Haraka | outbound/hmail.js | https://github.com/haraka/Haraka/blob/master/outbound/hmail.js | MIT |
deferred_respond (retval, msg, params) {
if (retval !== constants.cont && retval !== constants.denysoft) {
this.loginfo(`plugin responded with: ${retval}. Not deferring. Deleting mail.`);
return this.discard(); // calls next_cb
}
let delay = params.delay * 1000;
... | Generates a bounce message
hmail.todo.rcpt_to objects should be extended as follows:
- dsn_action
- dsn_status
- dsn_code
- dsn_msg
- dsn_remote_mta
Upstream code/message goes here:
- dsn_smtp_code
- dsn_smtp_extc
- dsn_smtp_response
@param from
@param to
@param reason
@param header
@param cb - a callback for fn(er... | deferred_respond | javascript | haraka/Haraka | outbound/hmail.js | https://github.com/haraka/Haraka/blob/master/outbound/hmail.js | MIT |
delivered_respond (retval, msg) {
if (retval !== constants.cont && retval !== constants.ok) {
this.logwarn(
"delivered plugin responded",
{ retval, msg }
);
}
this.discard();
} | Generates a bounce message
hmail.todo.rcpt_to objects should be extended as follows:
- dsn_action
- dsn_status
- dsn_code
- dsn_msg
- dsn_remote_mta
Upstream code/message goes here:
- dsn_smtp_code
- dsn_smtp_extc
- dsn_smtp_response
@param from
@param to
@param reason
@param header
@param cb - a callback for fn(er... | delivered_respond | javascript | haraka/Haraka | outbound/hmail.js | https://github.com/haraka/Haraka/blob/master/outbound/hmail.js | MIT |
get_force_tls (mx) {
if (!mx.exchange) return false
if (!obtls.cfg.force_tls_hosts) return false
if (net_utils.ip_in_list(obtls.cfg.force_tls_hosts, mx.exchange)) {
this.logdebug(`Forcing TLS for host ${mx.exchange}`);
return true;
}
if (mx.from_dns) {
... | Generates a bounce message
hmail.todo.rcpt_to objects should be extended as follows:
- dsn_action
- dsn_status
- dsn_code
- dsn_msg
- dsn_remote_mta
Upstream code/message goes here:
- dsn_smtp_code
- dsn_smtp_extc
- dsn_smtp_response
@param from
@param to
@param reason
@param header
@param cb - a callback for fn(er... | get_force_tls | javascript | haraka/Haraka | outbound/hmail.js | https://github.com/haraka/Haraka/blob/master/outbound/hmail.js | MIT |
sort_mx (mx_list) {
// MXs must be sorted by priority.
const sorted = mx_list.sort((a,b) => a.priority - b.priority);
// Matched priorities must be randomly shuffled.
// This isn't a very good shuffle but it'll do for now.
for (let i=0,l=sorted.length-1; i<l; i++) {
... | Generates a bounce message
hmail.todo.rcpt_to objects should be extended as follows:
- dsn_action
- dsn_status
- dsn_code
- dsn_msg
- dsn_remote_mta
Upstream code/message goes here:
- dsn_smtp_code
- dsn_smtp_extc
- dsn_smtp_response
@param from
@param to
@param reason
@param header
@param cb - a callback for fn(er... | sort_mx | javascript | haraka/Haraka | outbound/hmail.js | https://github.com/haraka/Haraka/blob/master/outbound/hmail.js | MIT |
split_to_new_recipients (recipients, response, cb) {
const hmail = this;
if (recipients.length === hmail.todo.rcpt_to.length) {
// Split to new for no reason - increase refcount and return self
hmail.refcount++;
return cb(hmail);
}
const fname = _qfile... | Generates a bounce message
hmail.todo.rcpt_to objects should be extended as follows:
- dsn_action
- dsn_status
- dsn_code
- dsn_msg
- dsn_remote_mta
Upstream code/message goes here:
- dsn_smtp_code
- dsn_smtp_extc
- dsn_smtp_response
@param from
@param to
@param reason
@param header
@param cb - a callback for fn(er... | split_to_new_recipients | javascript | haraka/Haraka | outbound/hmail.js | https://github.com/haraka/Haraka/blob/master/outbound/hmail.js | MIT |
function err_handler (err, location) {
logger.error(this, `Error while splitting to new recipients (${location}): ${err}`);
hmail.todo.rcpt_to.forEach(rcpt => {
hmail.extend_rcpt_with_dsn(rcpt, DSN.sys_unspecified(`Error splitting to new recipients: ${err}`));
});
... | Generates a bounce message
hmail.todo.rcpt_to objects should be extended as follows:
- dsn_action
- dsn_status
- dsn_code
- dsn_msg
- dsn_remote_mta
Upstream code/message goes here:
- dsn_smtp_code
- dsn_smtp_extc
- dsn_smtp_response
@param from
@param to
@param reason
@param header
@param cb - a callback for fn(er... | err_handler | javascript | haraka/Haraka | outbound/hmail.js | https://github.com/haraka/Haraka/blob/master/outbound/hmail.js | MIT |
function write_more () {
if (writing) return;
writing = true;
const rs = hmail.data_stream();
rs.pipe(ws, {end: false});
rs.on('error', err => {
err_handler(err, "hmail.data_stream reader");
});
rs.on('end', () => {
... | Generates a bounce message
hmail.todo.rcpt_to objects should be extended as follows:
- dsn_action
- dsn_status
- dsn_code
- dsn_msg
- dsn_remote_mta
Upstream code/message goes here:
- dsn_smtp_code
- dsn_smtp_extc
- dsn_smtp_response
@param from
@param to
@param reason
@param header
@param cb - a callback for fn(er... | write_more | javascript | haraka/Haraka | outbound/hmail.js | https://github.com/haraka/Haraka/blob/master/outbound/hmail.js | MIT |
function cram_md5_response (username, password, challenge) {
const crypto = require('crypto');
const c = utils.unbase64(challenge);
const hmac = crypto.createHmac('md5', password);
hmac.update(c);
const digest = hmac.digest('hex');
return utils.base64(`${username} ${digest}`);
} | Generates a bounce message
hmail.todo.rcpt_to objects should be extended as follows:
- dsn_action
- dsn_status
- dsn_code
- dsn_msg
- dsn_remote_mta
Upstream code/message goes here:
- dsn_smtp_code
- dsn_smtp_extc
- dsn_smtp_response
@param from
@param to
@param reason
@param header
@param cb - a callback for fn(er... | cram_md5_response | javascript | haraka/Haraka | outbound/hmail.js | https://github.com/haraka/Haraka/blob/master/outbound/hmail.js | MIT |
function getNextEntryFromPlaybook (ofType, playbook) {
if (playbook.length == 0) {
return false;
}
if (playbook[0].from == ofType) {
return playbook.shift();
}
return false;
} | runs a socket.write
@param socket
@param test
@param playbook | getNextEntryFromPlaybook | javascript | haraka/Haraka | test/fixtures/util_hmailitem.js | https://github.com/haraka/Haraka/blob/master/test/fixtures/util_hmailitem.js | MIT |
function getGlobal() {
return this;
} | Default timeout interval in milliseconds for waitsFor() blocks. | getGlobal | javascript | PaulKinlan/WebIntents | lib/jasmine/jasmine.js | https://github.com/PaulKinlan/WebIntents/blob/master/lib/jasmine/jasmine.js | Apache-2.0 |
spyObj = function() {
spyObj.wasCalled = true;
spyObj.callCount++;
var args = jasmine.util.argsToArray(arguments);
spyObj.mostRecentCall.object = this;
spyObj.mostRecentCall.args = args;
spyObj.argsForCall.push(args);
spyObj.calls.push({object: this, args: args});
return spyObj.plan.appl... | Resets all of a spy's the tracking variables so that it can be used again.
@example
spyOn(foo, 'bar');
foo.bar();
expect(foo.bar.callCount).toEqual(1);
foo.bar.reset();
expect(foo.bar.callCount).toEqual(0); | spyObj | javascript | PaulKinlan/WebIntents | lib/jasmine/jasmine.js | https://github.com/PaulKinlan/WebIntents/blob/master/lib/jasmine/jasmine.js | Apache-2.0 |
spyOn = function(obj, methodName) {
return jasmine.getEnv().currentSpec.spyOn(obj, methodName);
} | Function that installs a spy on an existing object's method name. Used within a Spec to create a spy.
@example
// spy example
var foo = {
not: function(bool) { return !bool; }
}
spyOn(foo, 'not'); // actual foo.not will not be called, execution stops
@see jasmine.createSpy
@param obj
@param methodName
@returns a J... | spyOn | javascript | PaulKinlan/WebIntents | lib/jasmine/jasmine.js | https://github.com/PaulKinlan/WebIntents/blob/master/lib/jasmine/jasmine.js | Apache-2.0 |
it = function(desc, func) {
return jasmine.getEnv().it(desc, func);
} | Creates a Jasmine spec that will be added to the current suite.
// TODO: pending tests
@example
it('should be true', function() {
expect(true).toEqual(true);
});
@param {String} desc description of this specification
@param {Function} func defines the preconditions and expectations of the spec | it | javascript | PaulKinlan/WebIntents | lib/jasmine/jasmine.js | https://github.com/PaulKinlan/WebIntents/blob/master/lib/jasmine/jasmine.js | Apache-2.0 |
xit = function(desc, func) {
return jasmine.getEnv().xit(desc, func);
} | Creates a <em>disabled</em> Jasmine spec.
A convenience method that allows existing specs to be disabled temporarily during development.
@param {String} desc description of this specification
@param {Function} func defines the preconditions and expectations of the spec | xit | javascript | PaulKinlan/WebIntents | lib/jasmine/jasmine.js | https://github.com/PaulKinlan/WebIntents/blob/master/lib/jasmine/jasmine.js | Apache-2.0 |
expect = function(actual) {
return jasmine.getEnv().currentSpec.expect(actual);
} | Starts a chain for a Jasmine expectation.
It is passed an Object that is the actual value and should chain to one of the many
jasmine.Matchers functions.
@param {Object} actual Actual value to test against and expected value | expect | javascript | PaulKinlan/WebIntents | lib/jasmine/jasmine.js | https://github.com/PaulKinlan/WebIntents/blob/master/lib/jasmine/jasmine.js | Apache-2.0 |
waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments);
} | Waits for the latchFunction to return true before proceeding to the next block.
@param {Function} latchFunction
@param {String} optional_timeoutMessage
@param {Number} optional_timeout | waitsFor | javascript | PaulKinlan/WebIntents | lib/jasmine/jasmine.js | https://github.com/PaulKinlan/WebIntents/blob/master/lib/jasmine/jasmine.js | Apache-2.0 |
describe = function(description, specDefinitions) {
return jasmine.getEnv().describe(description, specDefinitions);
} | Defines a suite of specifications.
Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared
are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization
of setup in some tests.
@example
// TODO: a simple s... | describe | javascript | PaulKinlan/WebIntents | lib/jasmine/jasmine.js | https://github.com/PaulKinlan/WebIntents/blob/master/lib/jasmine/jasmine.js | Apache-2.0 |
xdescribe = function(description, specDefinitions) {
return jasmine.getEnv().xdescribe(description, specDefinitions);
} | Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development.
@param {String} description A string, usually the class under test.
@param {Function} specDefinitions function that defines several specs. | xdescribe | javascript | PaulKinlan/WebIntents | lib/jasmine/jasmine.js | https://github.com/PaulKinlan/WebIntents/blob/master/lib/jasmine/jasmine.js | Apache-2.0 |
function tryIt(f) {
try {
return f();
} catch(e) {
}
return null;
} | Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development.
@param {String} description A string, usually the class under test.
@param {Function} specDefinitions function that defines several specs. | tryIt | javascript | PaulKinlan/WebIntents | lib/jasmine/jasmine.js | https://github.com/PaulKinlan/WebIntents/blob/master/lib/jasmine/jasmine.js | Apache-2.0 |
hasKey = function(obj, keyName) {
return obj !== null && obj[keyName] !== jasmine.undefined;
} | Register a reporter to receive status updates from Jasmine.
@param {jasmine.Reporter} reporter An object which will receive status updates. | hasKey | javascript | PaulKinlan/WebIntents | lib/jasmine/jasmine.js | https://github.com/PaulKinlan/WebIntents/blob/master/lib/jasmine/jasmine.js | Apache-2.0 |
onComplete = function () {
if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) {
completedSynchronously = true;
return;
}
if (self.blocks[self.index].abort) {
self.abort = true;
}
self.offset = 0;
self.index++;
var now = ne... | Formats a value in a nice, human-readable string.
@param value | onComplete | javascript | PaulKinlan/WebIntents | lib/jasmine/jasmine.js | https://github.com/PaulKinlan/WebIntents/blob/master/lib/jasmine/jasmine.js | Apache-2.0 |
newMatchersClass = function() {
parent.apply(this, arguments);
} | Waits for the latchFunction to return true before proceeding to the next block.
@param {Function} latchFunction
@param {String} optional_timeoutMessage
@param {Number} optional_timeout | newMatchersClass | javascript | PaulKinlan/WebIntents | lib/jasmine/jasmine.js | https://github.com/PaulKinlan/WebIntents/blob/master/lib/jasmine/jasmine.js | Apache-2.0 |
constructor() {
super();
// this.attachShadow({mode: "open"});
// this.shadowRoot.innerHTML = `:host { display: none }`;
} | Special type of delayed element that actually triggers an action when it's current | constructor | javascript | LeaVerou/inspire.js | plugins/delayed-actions/plugin.js | https://github.com/LeaVerou/inspire.js/blob/master/plugins/delayed-actions/plugin.js | MIT |
static get observedAttributes() {
return ["type", "target", "class"];
} | Special type of delayed element that actually triggers an action when it's current | observedAttributes | javascript | LeaVerou/inspire.js | plugins/delayed-actions/plugin.js | https://github.com/LeaVerou/inspire.js/blob/master/plugins/delayed-actions/plugin.js | MIT |
get type() {
return this.getAttribute("type");
} | Special type of delayed element that actually triggers an action when it's current | type | javascript | LeaVerou/inspire.js | plugins/delayed-actions/plugin.js | https://github.com/LeaVerou/inspire.js/blob/master/plugins/delayed-actions/plugin.js | MIT |
set type(type) {
this.setAttribute("type", type);
} | Special type of delayed element that actually triggers an action when it's current | type | javascript | LeaVerou/inspire.js | plugins/delayed-actions/plugin.js | https://github.com/LeaVerou/inspire.js/blob/master/plugins/delayed-actions/plugin.js | MIT |
get target() {
return this.getAttribute("target");
} | Special type of delayed element that actually triggers an action when it's current | target | javascript | LeaVerou/inspire.js | plugins/delayed-actions/plugin.js | https://github.com/LeaVerou/inspire.js/blob/master/plugins/delayed-actions/plugin.js | MIT |
set target(target) {
this.setAttribute("target", target);
} | Special type of delayed element that actually triggers an action when it's current | target | javascript | LeaVerou/inspire.js | plugins/delayed-actions/plugin.js | https://github.com/LeaVerou/inspire.js/blob/master/plugins/delayed-actions/plugin.js | MIT |
trigger() {
if (this.#triggered > 0 && this.hasAttribute("once")) {
return;
}
this.#triggered++;
let type = this.type || "click";
let slide = this.closest(".slide");
let targetSelector = this.target;
if (!targetSelector) {
throw new InvalidStateError("No target specified");
}
let target = sl... | Special type of delayed element that actually triggers an action when it's current | trigger | javascript | LeaVerou/inspire.js | plugins/delayed-actions/plugin.js | https://github.com/LeaVerou/inspire.js/blob/master/plugins/delayed-actions/plugin.js | MIT |
connectedCallback() {
this.classList.add("delayed");
this.innerHTML = `<slot></slot>`;
} | Special type of delayed element that actually triggers an action when it's current | connectedCallback | javascript | LeaVerou/inspire.js | plugins/delayed-actions/plugin.js | https://github.com/LeaVerou/inspire.js/blob/master/plugins/delayed-actions/plugin.js | MIT |
attributeChangedCallback(name, oldValue, newValue) {
if (name === "class") {
if (this.classList.contains("current")) {
this.trigger();
}
}
} | Special type of delayed element that actually triggers an action when it's current | attributeChangedCallback | javascript | LeaVerou/inspire.js | plugins/delayed-actions/plugin.js | https://github.com/LeaVerou/inspire.js/blob/master/plugins/delayed-actions/plugin.js | MIT |
static init (container) {
if (!container.demo) {
container.demo = new LiveDemo(container);
}
return container.demo;
} | /";
}
if (this.style.sheet) {
let scope = this.editors.css.textarea.getAttribute("data-scope") || `#${this.container.id} .demo-target `;
for (let rule of this.style.sheet.cssRules) {
LiveDemo.scopeRule(rule, this.container, scope);
}
}
else {
console.log("FAIL on", this.conta... | init | javascript | LeaVerou/inspire.js | plugins/live-demo/live-demo.js | https://github.com/LeaVerou/inspire.js/blob/master/plugins/live-demo/live-demo.js | MIT |
hashchange(evt) {
_.goto(location.hash.substr(1) || 0);
} | Keyboard navigation
Home : First slide
End : Last slide
Space/Up/Right arrow : Next item/slide
Ctrl + Space/Up/Right arrow : Next slide
Down/Left arrow : Previous item/slide
Ctrl + Down/Left arrow : Previous slide
(Shift instead of Ctrl works too) | hashchange | javascript | LeaVerou/inspire.js | src/inspire.js | https://github.com/LeaVerou/inspire.js/blob/master/src/inspire.js | MIT |
end() {
_.goto(_.slides.length - 1);
} | Keyboard navigation
Home : First slide
End : Last slide
Space/Up/Right arrow : Next item/slide
Ctrl + Space/Up/Right arrow : Next slide
Down/Left arrow : Previous item/slide
Ctrl + Down/Left arrow : Previous slide
(Shift instead of Ctrl works too) | end | javascript | LeaVerou/inspire.js | src/inspire.js | https://github.com/LeaVerou/inspire.js/blob/master/src/inspire.js | MIT |
next (hard) {
if (!hard && _.items.length) {
_.nextItem();
}
else {
_.goto(_.index + 1);
_.item = 0;
// Mark all items as not displayed, if there are any
_.items.forEach(item => item.classList.remove("displayed", "current"));
}
} | @param hard {Boolean} Whether to advance to the next slide (true) or
just the next step (which could very well be showing a list item) | next | javascript | LeaVerou/inspire.js | src/inspire.js | https://github.com/LeaVerou/inspire.js/blob/master/src/inspire.js | MIT |
nextItem() {
this.delayedLast = this.currentSlide.matches(".delayed-last, .delayed-last *");
if (_.item < _.items.length || this.delayedLast && _.item === _.items.length) {
_.gotoItem(++_.item);
}
else {
// Finished all slide items, go to next slide
_.item = 0;
_.next(true);
}
} | @param hard {Boolean} Whether to advance to the next slide (true) or
just the next step (which could very well be showing a list item) | nextItem | javascript | LeaVerou/inspire.js | src/inspire.js | https://github.com/LeaVerou/inspire.js/blob/master/src/inspire.js | MIT |
previous (hard) {
if (!hard && _.item > 0) {
_.previousItem();
}
else {
_.goto(_.index - 1);
_.item = _.items.length;
// Mark all items as displayed, if there are any
if (_.items.length) {
_.items.forEach(item => item.classList.add("displayed"));
_.items.forEach(item => item.classList.rem... | @param hard {Boolean} Whether to advance to the next slide (true) or
just the next step (which could very well be showing a list item) | previous | javascript | LeaVerou/inspire.js | src/inspire.js | https://github.com/LeaVerou/inspire.js/blob/master/src/inspire.js | MIT |
async on (ref) {
if (/^[\w-]+$/.test(ref)) {
console.warn("Inspire.on() expects a selector now, not an id");
ref = "#" + ref;
}
if (_.currentSlide === ref || _.currentSlide?.matches(ref)) {
return _.currentSlide;
}
return new Promise(resolve => {
let callback = evt => {
if (ref === evt.targe... | Run code once on a slide when the slide is active
@param {String | HTMLElement} ref CSS selector or slide element
@returns {Promise<HTMLElement>} The slide that was activated | on | javascript | LeaVerou/inspire.js | src/inspire.js | https://github.com/LeaVerou/inspire.js/blob/master/src/inspire.js | MIT |
callback = evt => {
if (ref === evt.target || typeof ref === "string" && evt.target.matches(ref)) {
resolve(evt.target);
evt.target.removeEventListener("slidechange", callback);
}
} | Run code once on a slide when the slide is active
@param {String | HTMLElement} ref CSS selector or slide element
@returns {Promise<HTMLElement>} The slide that was activated | callback | javascript | LeaVerou/inspire.js | src/inspire.js | https://github.com/LeaVerou/inspire.js/blob/master/src/inspire.js | MIT |
callback = evt => {
if (ref === evt.target || typeof ref === "string" && evt.target.matches(ref)) {
resolve(evt.target);
evt.target.removeEventListener("slidechange", callback);
}
} | Run code once on a slide when the slide is active
@param {String | HTMLElement} ref CSS selector or slide element
@returns {Promise<HTMLElement>} The slide that was activated | callback | javascript | LeaVerou/inspire.js | src/inspire.js | https://github.com/LeaVerou/inspire.js/blob/master/src/inspire.js | MIT |
for (selector, callback) {
let slides = $$(`.slide:has(${ selector})`);
for (let slide of slides) {
_.on(slide).then(slide => {
for (let element of $$(selector, slide)) {
callback(element);
}
});
}
return slides;
} | Run code for specific elements, once, only when the slide they appear in becomes active
@param {string} selector
@param {function} callback
@returns {HTMLElement[]} The slides that contain elements matching the selector | for | javascript | LeaVerou/inspire.js | src/inspire.js | https://github.com/LeaVerou/inspire.js/blob/master/src/inspire.js | MIT |
updateItems () {
_.items = $$(".delayed, .delayed-children > *", _.currentSlide);
_.items = _.items.sort((a, b) => {
return (a.getAttribute("data-index") || 0) - (b.getAttribute("data-index") || 0);
});
document.documentElement.style.setProperty("--total-items", _.items.length);
document.documentElement.cl... | Run code for specific elements, once, only when the slide they appear in becomes active
@param {string} selector
@param {function} callback
@returns {HTMLElement[]} The slides that contain elements matching the selector | updateItems | javascript | LeaVerou/inspire.js | src/inspire.js | https://github.com/LeaVerou/inspire.js/blob/master/src/inspire.js | MIT |
adjustFontSize() {
let slide = _.currentSlide;
if (!slide || document.body.matches(".show-thumbnails") || slide.matches(".dont-resize")) {
return;
}
let cs = getComputedStyle(slide);
if (cs.getPropertyValue("--dont-resize") || cs.getPropertyValue("--font-sizing")?.trim() === "fixed" || cs.overflow === "... | Go to a specific item in the current slide
@param {number} which 1-based index of the item to go to (0 means no items are current, just the slide itself) | adjustFontSize | javascript | LeaVerou/inspire.js | src/inspire.js | https://github.com/LeaVerou/inspire.js/blob/master/src/inspire.js | MIT |
get currentSlide() {
return _.slides?.[_.slide];
} | Go to a specific item in the current slide
@param {number} which 1-based index of the item to go to (0 means no items are current, just the slide itself) | currentSlide | javascript | LeaVerou/inspire.js | src/inspire.js | https://github.com/LeaVerou/inspire.js/blob/master/src/inspire.js | MIT |
getSlideById(id) {
id = id[0] === "#"? id : "#" + id;
return $(".slide" + id);
} | Go to a specific item in the current slide
@param {number} which 1-based index of the item to go to (0 means no items are current, just the slide itself) | getSlideById | javascript | LeaVerou/inspire.js | src/inspire.js | https://github.com/LeaVerou/inspire.js/blob/master/src/inspire.js | MIT |
getSlide(element) {
return element.closest(".slide");
} | Go to a specific item in the current slide
@param {number} which 1-based index of the item to go to (0 means no items are current, just the slide itself) | getSlide | javascript | LeaVerou/inspire.js | src/inspire.js | https://github.com/LeaVerou/inspire.js/blob/master/src/inspire.js | MIT |
function processAutoplayVideos (root) {
// Are there any autoplay videos?
let videos = root.matches("video[autoplay]") ? [root] : $$("video[autoplay]", root);
for (let video of videos) {
let delayed = video.closest(".delayed, .delayed-children > *");
if (delayed?.classList.contains("future")) {
// Video is i... | Go to a specific item in the current slide
@param {number} which 1-based index of the item to go to (0 means no items are current, just the slide itself) | processAutoplayVideos | javascript | LeaVerou/inspire.js | src/inspire.js | https://github.com/LeaVerou/inspire.js/blob/master/src/inspire.js | MIT |
function selectCipherStrategy(key) {
if (typeof key == 'string') {
return PasswordBasedCipher;
} else {
return SerializableCipher;
}
} | Creates shortcut functions to a cipher's object interface.
@param {Cipher} cipher The cipher to create a helper for.
@return {Object} An object with encrypt and decrypt shortcut functions.
@static
@example
var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES); | selectCipherStrategy | javascript | tangyoha/telegram_media_downloader | module/static/aes/crypto-js-master/cipher-core.js | https://github.com/tangyoha/telegram_media_downloader/blob/master/module/static/aes/crypto-js-master/cipher-core.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.