repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
list | docstring
stringlengths 4
11.8k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 86
226
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
codekirei/columnize-array | lib/columns.js | Columns | function Columns(props) {
// require and bind methods
//----------------------------------------------------------
[ 'bindState'
, 'solve'
].forEach(method =>
this.constructor.prototype[method] = require(`./methods/${method}`)
)
// bind props (immutable) and state (mutable)
//----------------------------------------------------------
this.props = props
this.bindState(1)
// find solution state
//----------------------------------------------------------
this.solve()
} | javascript | function Columns(props) {
// require and bind methods
//----------------------------------------------------------
[ 'bindState'
, 'solve'
].forEach(method =>
this.constructor.prototype[method] = require(`./methods/${method}`)
)
// bind props (immutable) and state (mutable)
//----------------------------------------------------------
this.props = props
this.bindState(1)
// find solution state
//----------------------------------------------------------
this.solve()
} | [
"function",
"Columns",
"(",
"props",
")",
"{",
"[",
"'bindState'",
",",
"'solve'",
"]",
".",
"forEach",
"(",
"method",
"=>",
"this",
".",
"constructor",
".",
"prototype",
"[",
"method",
"]",
"=",
"require",
"(",
"`",
"${",
"method",
"}",
"`",
")",
")",
"this",
".",
"props",
"=",
"props",
"this",
".",
"bindState",
"(",
"1",
")",
"this",
".",
"solve",
"(",
")",
"}"
]
| Constructor with columnization logic.
@param {Object} props - immutable properties that dictate columnization
@returns {Object} instance of self | [
"Constructor",
"with",
"columnization",
"logic",
"."
]
| ba100d1d9cf707fa249a58fa177d6b26ec131278 | https://github.com/codekirei/columnize-array/blob/ba100d1d9cf707fa249a58fa177d6b26ec131278/lib/columns.js#L9-L27 | train |
juttle/juttle-viz | src/lib/utils/string-utils.js | function(str, maxLength, where) {
if (!_.isString(str)) {
return str;
}
var strLength = str.length;
if (strLength <= maxLength) {
return str;
}
// limit the length of the series name by dropping characters and inserting an ELLIPSIS where specified
switch(where) {
case 'start':
str = ELLIPSIS + str.substr(strLength - maxLength - 1);
break;
case 'end':
str = str.substr(0, Math.floor(maxLength) - 1) + ELLIPSIS;
break;
default:
str = str.substr(0, Math.floor(maxLength/2) - 1) + ELLIPSIS + str.substr(-1 * (Math.floor(maxLength/2) + 1));
}
return str;
} | javascript | function(str, maxLength, where) {
if (!_.isString(str)) {
return str;
}
var strLength = str.length;
if (strLength <= maxLength) {
return str;
}
// limit the length of the series name by dropping characters and inserting an ELLIPSIS where specified
switch(where) {
case 'start':
str = ELLIPSIS + str.substr(strLength - maxLength - 1);
break;
case 'end':
str = str.substr(0, Math.floor(maxLength) - 1) + ELLIPSIS;
break;
default:
str = str.substr(0, Math.floor(maxLength/2) - 1) + ELLIPSIS + str.substr(-1 * (Math.floor(maxLength/2) + 1));
}
return str;
} | [
"function",
"(",
"str",
",",
"maxLength",
",",
"where",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"str",
")",
")",
"{",
"return",
"str",
";",
"}",
"var",
"strLength",
"=",
"str",
".",
"length",
";",
"if",
"(",
"strLength",
"<=",
"maxLength",
")",
"{",
"return",
"str",
";",
"}",
"switch",
"(",
"where",
")",
"{",
"case",
"'start'",
":",
"str",
"=",
"ELLIPSIS",
"+",
"str",
".",
"substr",
"(",
"strLength",
"-",
"maxLength",
"-",
"1",
")",
";",
"break",
";",
"case",
"'end'",
":",
"str",
"=",
"str",
".",
"substr",
"(",
"0",
",",
"Math",
".",
"floor",
"(",
"maxLength",
")",
"-",
"1",
")",
"+",
"ELLIPSIS",
";",
"break",
";",
"default",
":",
"str",
"=",
"str",
".",
"substr",
"(",
"0",
",",
"Math",
".",
"floor",
"(",
"maxLength",
"/",
"2",
")",
"-",
"1",
")",
"+",
"ELLIPSIS",
"+",
"str",
".",
"substr",
"(",
"-",
"1",
"*",
"(",
"Math",
".",
"floor",
"(",
"maxLength",
"/",
"2",
")",
"+",
"1",
")",
")",
";",
"}",
"return",
"str",
";",
"}"
]
| Truncate string to a maxLength
@param {[type]} str [description]
@param {[type]} maxLength [description]
@param {[type]} where where to truncate and put the ellipsis (start, middle, or end). defaults to middle.
@return {[type]} [description] | [
"Truncate",
"string",
"to",
"a",
"maxLength"
]
| 834d13a66256d9c9177f46968b0ef05b8143e762 | https://github.com/juttle/juttle-viz/blob/834d13a66256d9c9177f46968b0ef05b8143e762/src/lib/utils/string-utils.js#L12-L36 | train |
|
logikum/md-site-engine | source/readers/process-contents.js | processContents | function processContents(
contentDir, contentRoot,
submenuFile, contentStock, menuStock,
references, language, renderer
) {
var typeName = 'Content';
// Read directory items.
var items = fs.readdirSync( path.join( process.cwd(), contentDir ) );
items.forEach( function ( item ) {
// Get full path of item.
var itemPath = path.join( contentDir, item );
// Get item info.
var stats = fs.statSync( path.join( process.cwd(), itemPath ) );
if (stats.isDirectory()) {
// Determine content path.
var directoryPath = contentRoot + '/' + item;
// Create menu item.
var directoryNode = MenuBuilder.buildSubMenu(
menuStock, path.join( itemPath, submenuFile ), directoryPath
);
// Read subdirectory.
processContents(
itemPath,
directoryPath,
submenuFile,
contentStock,
directoryNode ? directoryNode.children : menuStock,
references,
language,
renderer
);
}
else if (stats.isFile()) {
var ext = path.extname( item );
var basename = path.basename( item, ext );
var isMarkdown = true;
switch (ext) {
case '.html':
isMarkdown = false;
case '.md':
// Read the content file.
var content = getContent( itemPath, isMarkdown ? "markdown" : 'html' );
// Set content path.
content.path = contentRoot + '/' + basename;
// Read content definition.
var definition = getDefinition( content );
// Contains menu info?
if (definition.order || definition.text)
// Create menu item.
MenuBuilder.createMenuItem( menuStock, definition, content.path, false );
// Generate HTML from markdown text.
if (isMarkdown)
content.html = marked(
content.html + '\n' + references.get( language ),
{ renderer: renderer }
);
// Omit menu separator.
if (definition.text !== '---')
// Store content.
contentStock.add( content, definition );
logger.fileProcessed( typeName, itemPath );
break;
default:
if (item !== submenuFile)
logger.fileSkipped( typeName, itemPath );
break;
}
}
} );
} | javascript | function processContents(
contentDir, contentRoot,
submenuFile, contentStock, menuStock,
references, language, renderer
) {
var typeName = 'Content';
// Read directory items.
var items = fs.readdirSync( path.join( process.cwd(), contentDir ) );
items.forEach( function ( item ) {
// Get full path of item.
var itemPath = path.join( contentDir, item );
// Get item info.
var stats = fs.statSync( path.join( process.cwd(), itemPath ) );
if (stats.isDirectory()) {
// Determine content path.
var directoryPath = contentRoot + '/' + item;
// Create menu item.
var directoryNode = MenuBuilder.buildSubMenu(
menuStock, path.join( itemPath, submenuFile ), directoryPath
);
// Read subdirectory.
processContents(
itemPath,
directoryPath,
submenuFile,
contentStock,
directoryNode ? directoryNode.children : menuStock,
references,
language,
renderer
);
}
else if (stats.isFile()) {
var ext = path.extname( item );
var basename = path.basename( item, ext );
var isMarkdown = true;
switch (ext) {
case '.html':
isMarkdown = false;
case '.md':
// Read the content file.
var content = getContent( itemPath, isMarkdown ? "markdown" : 'html' );
// Set content path.
content.path = contentRoot + '/' + basename;
// Read content definition.
var definition = getDefinition( content );
// Contains menu info?
if (definition.order || definition.text)
// Create menu item.
MenuBuilder.createMenuItem( menuStock, definition, content.path, false );
// Generate HTML from markdown text.
if (isMarkdown)
content.html = marked(
content.html + '\n' + references.get( language ),
{ renderer: renderer }
);
// Omit menu separator.
if (definition.text !== '---')
// Store content.
contentStock.add( content, definition );
logger.fileProcessed( typeName, itemPath );
break;
default:
if (item !== submenuFile)
logger.fileSkipped( typeName, itemPath );
break;
}
}
} );
} | [
"function",
"processContents",
"(",
"contentDir",
",",
"contentRoot",
",",
"submenuFile",
",",
"contentStock",
",",
"menuStock",
",",
"references",
",",
"language",
",",
"renderer",
")",
"{",
"var",
"typeName",
"=",
"'Content'",
";",
"var",
"items",
"=",
"fs",
".",
"readdirSync",
"(",
"path",
".",
"join",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"contentDir",
")",
")",
";",
"items",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"var",
"itemPath",
"=",
"path",
".",
"join",
"(",
"contentDir",
",",
"item",
")",
";",
"var",
"stats",
"=",
"fs",
".",
"statSync",
"(",
"path",
".",
"join",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"itemPath",
")",
")",
";",
"if",
"(",
"stats",
".",
"isDirectory",
"(",
")",
")",
"{",
"var",
"directoryPath",
"=",
"contentRoot",
"+",
"'/'",
"+",
"item",
";",
"var",
"directoryNode",
"=",
"MenuBuilder",
".",
"buildSubMenu",
"(",
"menuStock",
",",
"path",
".",
"join",
"(",
"itemPath",
",",
"submenuFile",
")",
",",
"directoryPath",
")",
";",
"processContents",
"(",
"itemPath",
",",
"directoryPath",
",",
"submenuFile",
",",
"contentStock",
",",
"directoryNode",
"?",
"directoryNode",
".",
"children",
":",
"menuStock",
",",
"references",
",",
"language",
",",
"renderer",
")",
";",
"}",
"else",
"if",
"(",
"stats",
".",
"isFile",
"(",
")",
")",
"{",
"var",
"ext",
"=",
"path",
".",
"extname",
"(",
"item",
")",
";",
"var",
"basename",
"=",
"path",
".",
"basename",
"(",
"item",
",",
"ext",
")",
";",
"var",
"isMarkdown",
"=",
"true",
";",
"switch",
"(",
"ext",
")",
"{",
"case",
"'.html'",
":",
"isMarkdown",
"=",
"false",
";",
"case",
"'.md'",
":",
"var",
"content",
"=",
"getContent",
"(",
"itemPath",
",",
"isMarkdown",
"?",
"\"markdown\"",
":",
"'html'",
")",
";",
"content",
".",
"path",
"=",
"contentRoot",
"+",
"'/'",
"+",
"basename",
";",
"var",
"definition",
"=",
"getDefinition",
"(",
"content",
")",
";",
"if",
"(",
"definition",
".",
"order",
"||",
"definition",
".",
"text",
")",
"MenuBuilder",
".",
"createMenuItem",
"(",
"menuStock",
",",
"definition",
",",
"content",
".",
"path",
",",
"false",
")",
";",
"if",
"(",
"isMarkdown",
")",
"content",
".",
"html",
"=",
"marked",
"(",
"content",
".",
"html",
"+",
"'\\n'",
"+",
"\\n",
",",
"references",
".",
"get",
"(",
"language",
")",
")",
";",
"{",
"renderer",
":",
"renderer",
"}",
"if",
"(",
"definition",
".",
"text",
"!==",
"'---'",
")",
"contentStock",
".",
"add",
"(",
"content",
",",
"definition",
")",
";",
"logger",
".",
"fileProcessed",
"(",
"typeName",
",",
"itemPath",
")",
";",
"break",
";",
"}",
"}",
"}",
")",
";",
"}"
]
| Processes the items of a content sub-directory.
@param {string} contentDir - The path of the content sub-directory.
@param {string} contentRoot - The base URL of the content sub-directory.
@param {string} submenuFile - The path of the menu level file (__submenu.txt).
@param {ContentStock} contentStock - The content storage of the language.
@param {MenuStock} menuStock - The current menu node (a menu level storage).
@param {ReferenceDrawer} references - The reference storage.
@param {string} language - The language of the content sub-directory.
@param {marked.Renderer} renderer - The custom markdown renderer. | [
"Processes",
"the",
"items",
"of",
"a",
"content",
"sub",
"-",
"directory",
"."
]
| 1abb0d9d6ea2c84690b9ffdde6b7ff7d49288784 | https://github.com/logikum/md-site-engine/blob/1abb0d9d6ea2c84690b9ffdde6b7ff7d49288784/source/readers/process-contents.js#L22-L106 | train |
oramics/synth-kit | lib/instruments/tonewheel.js | toState | function toState (preset) {
if (preset) {
const norm = (preset.replace(/[^012345678]/g, "") + "000000000").slice(0, 9)
const gains = norm.split("").map((n) => Math.abs(+n / 8))
return {
bank: { gains }
}
}
} | javascript | function toState (preset) {
if (preset) {
const norm = (preset.replace(/[^012345678]/g, "") + "000000000").slice(0, 9)
const gains = norm.split("").map((n) => Math.abs(+n / 8))
return {
bank: { gains }
}
}
} | [
"function",
"toState",
"(",
"preset",
")",
"{",
"if",
"(",
"preset",
")",
"{",
"const",
"norm",
"=",
"(",
"preset",
".",
"replace",
"(",
"/",
"[^012345678]",
"/",
"g",
",",
"\"\"",
")",
"+",
"\"000000000\"",
")",
".",
"slice",
"(",
"0",
",",
"9",
")",
"const",
"gains",
"=",
"norm",
".",
"split",
"(",
"\"\"",
")",
".",
"map",
"(",
"(",
"n",
")",
"=>",
"Math",
".",
"abs",
"(",
"+",
"n",
"/",
"8",
")",
")",
"return",
"{",
"bank",
":",
"{",
"gains",
"}",
"}",
"}",
"}"
]
| Given a preset, return a state fragment | [
"Given",
"a",
"preset",
"return",
"a",
"state",
"fragment"
]
| 38de28d945241507e2bb195eb551aaff7c1c55d5 | https://github.com/oramics/synth-kit/blob/38de28d945241507e2bb195eb551aaff7c1c55d5/lib/instruments/tonewheel.js#L45-L53 | train |
express-bem/express-bem | lib/engines.js | function (name, extension, engine) {
// add to storage
this[name] = engine.render || engine;
enginesByExtension[extension] = engine;
return this;
} | javascript | function (name, extension, engine) {
// add to storage
this[name] = engine.render || engine;
enginesByExtension[extension] = engine;
return this;
} | [
"function",
"(",
"name",
",",
"extension",
",",
"engine",
")",
"{",
"this",
"[",
"name",
"]",
"=",
"engine",
".",
"render",
"||",
"engine",
";",
"enginesByExtension",
"[",
"extension",
"]",
"=",
"engine",
";",
"return",
"this",
";",
"}"
]
| add bem engine
@param {String} [name]
@param {String} [extension]
@param {Function|Object} engine
@returns {Engines} | [
"add",
"bem",
"engine"
]
| 6ea49e5ecdd8e949dd5051ecc5762e40cbcead9c | https://github.com/express-bem/express-bem/blob/6ea49e5ecdd8e949dd5051ecc5762e40cbcead9c/lib/engines.js#L22-L28 | train |
|
express-bem/express-bem | lib/engines.js | function (name, options, cb) {
var engine = enginesByExtension[this.ext],
that = this,
// queue
stack = [],
ctx = {
name : name,
options : options,
cb : cb
};
this.engines = engines;
this.thru = function (name, _name, _options, _cb) {
var engine = engines[name];
if (!engine) {
return cb(Error('Unknown engine ' + name));
}
this.ext = engine.extension;
engine.call(this, _name || ctx.name, _options || ctx.options, _cb || ctx.cb);
};
options.forceLoad = options.hasOwnProperty('forceLoad') ? options.forceLoad : !expressBem.envLoadCache;
options.forceExec = options.hasOwnProperty('forceExec') ? options.forceExec : !expressBem.envExecCache;
if (!middlewares.length) {
return engine.call(this, ctx.name, ctx.options, ctx.cb);
}
// async fn queue
middlewares.forEach(function (mw) {
if (!mw.engine /* || shouldUseMiddlewareFor(mw.engine)*/) {
stack.push(mw.fn);
}
});
// put engine as last call
stack.push(function (ctx) {
engine.call(this, ctx.name, ctx.options, ctx.cb);
});
function next () {
var fn = stack.shift();
fn.call(that, ctx, next);
}
process.nextTick(next);
return this;
} | javascript | function (name, options, cb) {
var engine = enginesByExtension[this.ext],
that = this,
// queue
stack = [],
ctx = {
name : name,
options : options,
cb : cb
};
this.engines = engines;
this.thru = function (name, _name, _options, _cb) {
var engine = engines[name];
if (!engine) {
return cb(Error('Unknown engine ' + name));
}
this.ext = engine.extension;
engine.call(this, _name || ctx.name, _options || ctx.options, _cb || ctx.cb);
};
options.forceLoad = options.hasOwnProperty('forceLoad') ? options.forceLoad : !expressBem.envLoadCache;
options.forceExec = options.hasOwnProperty('forceExec') ? options.forceExec : !expressBem.envExecCache;
if (!middlewares.length) {
return engine.call(this, ctx.name, ctx.options, ctx.cb);
}
// async fn queue
middlewares.forEach(function (mw) {
if (!mw.engine /* || shouldUseMiddlewareFor(mw.engine)*/) {
stack.push(mw.fn);
}
});
// put engine as last call
stack.push(function (ctx) {
engine.call(this, ctx.name, ctx.options, ctx.cb);
});
function next () {
var fn = stack.shift();
fn.call(that, ctx, next);
}
process.nextTick(next);
return this;
} | [
"function",
"(",
"name",
",",
"options",
",",
"cb",
")",
"{",
"var",
"engine",
"=",
"enginesByExtension",
"[",
"this",
".",
"ext",
"]",
",",
"that",
"=",
"this",
",",
"stack",
"=",
"[",
"]",
",",
"ctx",
"=",
"{",
"name",
":",
"name",
",",
"options",
":",
"options",
",",
"cb",
":",
"cb",
"}",
";",
"this",
".",
"engines",
"=",
"engines",
";",
"this",
".",
"thru",
"=",
"function",
"(",
"name",
",",
"_name",
",",
"_options",
",",
"_cb",
")",
"{",
"var",
"engine",
"=",
"engines",
"[",
"name",
"]",
";",
"if",
"(",
"!",
"engine",
")",
"{",
"return",
"cb",
"(",
"Error",
"(",
"'Unknown engine '",
"+",
"name",
")",
")",
";",
"}",
"this",
".",
"ext",
"=",
"engine",
".",
"extension",
";",
"engine",
".",
"call",
"(",
"this",
",",
"_name",
"||",
"ctx",
".",
"name",
",",
"_options",
"||",
"ctx",
".",
"options",
",",
"_cb",
"||",
"ctx",
".",
"cb",
")",
";",
"}",
";",
"options",
".",
"forceLoad",
"=",
"options",
".",
"hasOwnProperty",
"(",
"'forceLoad'",
")",
"?",
"options",
".",
"forceLoad",
":",
"!",
"expressBem",
".",
"envLoadCache",
";",
"options",
".",
"forceExec",
"=",
"options",
".",
"hasOwnProperty",
"(",
"'forceExec'",
")",
"?",
"options",
".",
"forceExec",
":",
"!",
"expressBem",
".",
"envExecCache",
";",
"if",
"(",
"!",
"middlewares",
".",
"length",
")",
"{",
"return",
"engine",
".",
"call",
"(",
"this",
",",
"ctx",
".",
"name",
",",
"ctx",
".",
"options",
",",
"ctx",
".",
"cb",
")",
";",
"}",
"middlewares",
".",
"forEach",
"(",
"function",
"(",
"mw",
")",
"{",
"if",
"(",
"!",
"mw",
".",
"engine",
")",
"{",
"stack",
".",
"push",
"(",
"mw",
".",
"fn",
")",
";",
"}",
"}",
")",
";",
"stack",
".",
"push",
"(",
"function",
"(",
"ctx",
")",
"{",
"engine",
".",
"call",
"(",
"this",
",",
"ctx",
".",
"name",
",",
"ctx",
".",
"options",
",",
"ctx",
".",
"cb",
")",
";",
"}",
")",
";",
"function",
"next",
"(",
")",
"{",
"var",
"fn",
"=",
"stack",
".",
"shift",
"(",
")",
";",
"fn",
".",
"call",
"(",
"that",
",",
"ctx",
",",
"next",
")",
";",
"}",
"process",
".",
"nextTick",
"(",
"next",
")",
";",
"return",
"this",
";",
"}"
]
| all engines will pass through it | [
"all",
"engines",
"will",
"pass",
"through",
"it"
]
| 6ea49e5ecdd8e949dd5051ecc5762e40cbcead9c | https://github.com/express-bem/express-bem/blob/6ea49e5ecdd8e949dd5051ecc5762e40cbcead9c/lib/engines.js#L75-L123 | train |
|
chrisJohn404/ljswitchboard-ljm_device_curator | lib/dashboard/dashboard_operations.js | addListener | function addListener(uid) {
var addedListener = false;
if(typeof(dashboardListeners[uid]) === 'undefined') {
dashboardListeners[uid] = {
'startTime': new Date(),
'numIterations': 0,
'uid': uid,
'numStarts': 1,
};
addedListener = true;
} else {
// Don't add the listener.
dashboardListeners[uid].numStarts += 1;
}
return addedListener;
} | javascript | function addListener(uid) {
var addedListener = false;
if(typeof(dashboardListeners[uid]) === 'undefined') {
dashboardListeners[uid] = {
'startTime': new Date(),
'numIterations': 0,
'uid': uid,
'numStarts': 1,
};
addedListener = true;
} else {
// Don't add the listener.
dashboardListeners[uid].numStarts += 1;
}
return addedListener;
} | [
"function",
"addListener",
"(",
"uid",
")",
"{",
"var",
"addedListener",
"=",
"false",
";",
"if",
"(",
"typeof",
"(",
"dashboardListeners",
"[",
"uid",
"]",
")",
"===",
"'undefined'",
")",
"{",
"dashboardListeners",
"[",
"uid",
"]",
"=",
"{",
"'startTime'",
":",
"new",
"Date",
"(",
")",
",",
"'numIterations'",
":",
"0",
",",
"'uid'",
":",
"uid",
",",
"'numStarts'",
":",
"1",
",",
"}",
";",
"addedListener",
"=",
"true",
";",
"}",
"else",
"{",
"dashboardListeners",
"[",
"uid",
"]",
".",
"numStarts",
"+=",
"1",
";",
"}",
"return",
"addedListener",
";",
"}"
]
| Function that adds a data listener. | [
"Function",
"that",
"adds",
"a",
"data",
"listener",
"."
]
| 36cb25645dfa0a68e906d5ec43e5514391947257 | https://github.com/chrisJohn404/ljswitchboard-ljm_device_curator/blob/36cb25645dfa0a68e906d5ec43e5514391947257/lib/dashboard/dashboard_operations.js#L85-L100 | train |
chrisJohn404/ljswitchboard-ljm_device_curator | lib/dashboard/dashboard_operations.js | removeListener | function removeListener(uid) {
var removedListener = false;
if(typeof(dashboardListeners[uid]) !== 'undefined') {
dashboardListeners[uid] = undefined;
delete dashboardListeners[uid];
removedListener = true;
}
return removedListener;
} | javascript | function removeListener(uid) {
var removedListener = false;
if(typeof(dashboardListeners[uid]) !== 'undefined') {
dashboardListeners[uid] = undefined;
delete dashboardListeners[uid];
removedListener = true;
}
return removedListener;
} | [
"function",
"removeListener",
"(",
"uid",
")",
"{",
"var",
"removedListener",
"=",
"false",
";",
"if",
"(",
"typeof",
"(",
"dashboardListeners",
"[",
"uid",
"]",
")",
"!==",
"'undefined'",
")",
"{",
"dashboardListeners",
"[",
"uid",
"]",
"=",
"undefined",
";",
"delete",
"dashboardListeners",
"[",
"uid",
"]",
";",
"removedListener",
"=",
"true",
";",
"}",
"return",
"removedListener",
";",
"}"
]
| Function that removes a data listener. | [
"Function",
"that",
"removes",
"a",
"data",
"listener",
"."
]
| 36cb25645dfa0a68e906d5ec43e5514391947257 | https://github.com/chrisJohn404/ljswitchboard-ljm_device_curator/blob/36cb25645dfa0a68e906d5ec43e5514391947257/lib/dashboard/dashboard_operations.js#L103-L111 | train |
chrisJohn404/ljswitchboard-ljm_device_curator | lib/dashboard/dashboard_operations.js | dataCollectorHandler | function dataCollectorHandler(data) {
// debugDDC('New data', data['FIO0']);
var diffObj = _.diff(data, self.dataCache);
// console.log('Data Difference - diff', diffObj);
// Clean the object to get rid of empty results.
diffObj = _.pickBy(diffObj, function(value, key) {
return Object.keys(value).length > 0;
});
var numKeys = Object.keys(data);
var numNewKeys = Object.keys(diffObj);
// console.log('Num Keys for new data', numKeys, numNewKeys);
// console.log('Data Difference - pickBy', diffObj);
self.dataCache = data;
self.emit(device_events.DASHBOARD_DATA_UPDATE, diffObj);
} | javascript | function dataCollectorHandler(data) {
// debugDDC('New data', data['FIO0']);
var diffObj = _.diff(data, self.dataCache);
// console.log('Data Difference - diff', diffObj);
// Clean the object to get rid of empty results.
diffObj = _.pickBy(diffObj, function(value, key) {
return Object.keys(value).length > 0;
});
var numKeys = Object.keys(data);
var numNewKeys = Object.keys(diffObj);
// console.log('Num Keys for new data', numKeys, numNewKeys);
// console.log('Data Difference - pickBy', diffObj);
self.dataCache = data;
self.emit(device_events.DASHBOARD_DATA_UPDATE, diffObj);
} | [
"function",
"dataCollectorHandler",
"(",
"data",
")",
"{",
"var",
"diffObj",
"=",
"_",
".",
"diff",
"(",
"data",
",",
"self",
".",
"dataCache",
")",
";",
"diffObj",
"=",
"_",
".",
"pickBy",
"(",
"diffObj",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"value",
")",
".",
"length",
">",
"0",
";",
"}",
")",
";",
"var",
"numKeys",
"=",
"Object",
".",
"keys",
"(",
"data",
")",
";",
"var",
"numNewKeys",
"=",
"Object",
".",
"keys",
"(",
"diffObj",
")",
";",
"self",
".",
"dataCache",
"=",
"data",
";",
"self",
".",
"emit",
"(",
"device_events",
".",
"DASHBOARD_DATA_UPDATE",
",",
"diffObj",
")",
";",
"}"
]
| Function that handles the data collection "data" events. This data is the data returned by the read-commands that are performed. This data still needs to be interpreted saved, cached, and organized into "channels". Maybe?? The dashboard_data_collector has logic for each of the devices. This logic should probably be put there? | [
"Function",
"that",
"handles",
"the",
"data",
"collection",
"data",
"events",
".",
"This",
"data",
"is",
"the",
"data",
"returned",
"by",
"the",
"read",
"-",
"commands",
"that",
"are",
"performed",
".",
"This",
"data",
"still",
"needs",
"to",
"be",
"interpreted",
"saved",
"cached",
"and",
"organized",
"into",
"channels",
".",
"Maybe??",
"The",
"dashboard_data_collector",
"has",
"logic",
"for",
"each",
"of",
"the",
"devices",
".",
"This",
"logic",
"should",
"probably",
"be",
"put",
"there?"
]
| 36cb25645dfa0a68e906d5ec43e5514391947257 | https://github.com/chrisJohn404/ljswitchboard-ljm_device_curator/blob/36cb25645dfa0a68e906d5ec43e5514391947257/lib/dashboard/dashboard_operations.js#L143-L160 | train |
chrisJohn404/ljswitchboard-ljm_device_curator | lib/dashboard/dashboard_operations.js | innerStart | function innerStart (bundle) {
var defered = q.defer();
// Device Type is either T4, T5, or T7
var deviceType = self.savedAttributes.deviceTypeName;
// Save the created data collector object
dataCollector = new dashboard_data_collector.create(deviceType);
// Listen to only the next 'data' event emitted by the dataCollector.
dataCollector.once('data', function(data) {
debugDStart('dev_cur-dash_ops: First bit of data!');
// Listen to future data.
dataCollector.on('data', dataCollectorHandler);
// Save the data to the data cache.
self.dataCache = data;
bundle.data = data;
// Declare the innerStart function to be finished.
defered.resolve(bundle);
});
// Start the data collector.
dataCollector.start(self);
return defered.promise;
} | javascript | function innerStart (bundle) {
var defered = q.defer();
// Device Type is either T4, T5, or T7
var deviceType = self.savedAttributes.deviceTypeName;
// Save the created data collector object
dataCollector = new dashboard_data_collector.create(deviceType);
// Listen to only the next 'data' event emitted by the dataCollector.
dataCollector.once('data', function(data) {
debugDStart('dev_cur-dash_ops: First bit of data!');
// Listen to future data.
dataCollector.on('data', dataCollectorHandler);
// Save the data to the data cache.
self.dataCache = data;
bundle.data = data;
// Declare the innerStart function to be finished.
defered.resolve(bundle);
});
// Start the data collector.
dataCollector.start(self);
return defered.promise;
} | [
"function",
"innerStart",
"(",
"bundle",
")",
"{",
"var",
"defered",
"=",
"q",
".",
"defer",
"(",
")",
";",
"var",
"deviceType",
"=",
"self",
".",
"savedAttributes",
".",
"deviceTypeName",
";",
"dataCollector",
"=",
"new",
"dashboard_data_collector",
".",
"create",
"(",
"deviceType",
")",
";",
"dataCollector",
".",
"once",
"(",
"'data'",
",",
"function",
"(",
"data",
")",
"{",
"debugDStart",
"(",
"'dev_cur-dash_ops: First bit of data!'",
")",
";",
"dataCollector",
".",
"on",
"(",
"'data'",
",",
"dataCollectorHandler",
")",
";",
"self",
".",
"dataCache",
"=",
"data",
";",
"bundle",
".",
"data",
"=",
"data",
";",
"defered",
".",
"resolve",
"(",
"bundle",
")",
";",
"}",
")",
";",
"dataCollector",
".",
"start",
"(",
"self",
")",
";",
"return",
"defered",
".",
"promise",
";",
"}"
]
| This function starts the data collector and registers event listeners. | [
"This",
"function",
"starts",
"the",
"data",
"collector",
"and",
"registers",
"event",
"listeners",
"."
]
| 36cb25645dfa0a68e906d5ec43e5514391947257 | https://github.com/chrisJohn404/ljswitchboard-ljm_device_curator/blob/36cb25645dfa0a68e906d5ec43e5514391947257/lib/dashboard/dashboard_operations.js#L173-L201 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | function(k, i) {
var rval;
if(typeof(k) === 'undefined') {
rval = frag.query;
} else {
rval = frag.query[k];
if(rval && typeof(i) !== 'undefined') {
rval = rval[i];
}
}
return rval;
} | javascript | function(k, i) {
var rval;
if(typeof(k) === 'undefined') {
rval = frag.query;
} else {
rval = frag.query[k];
if(rval && typeof(i) !== 'undefined') {
rval = rval[i];
}
}
return rval;
} | [
"function",
"(",
"k",
",",
"i",
")",
"{",
"var",
"rval",
";",
"if",
"(",
"typeof",
"(",
"k",
")",
"===",
"'undefined'",
")",
"{",
"rval",
"=",
"frag",
".",
"query",
";",
"}",
"else",
"{",
"rval",
"=",
"frag",
".",
"query",
"[",
"k",
"]",
";",
"if",
"(",
"rval",
"&&",
"typeof",
"(",
"i",
")",
"!==",
"'undefined'",
")",
"{",
"rval",
"=",
"rval",
"[",
"i",
"]",
";",
"}",
"}",
"return",
"rval",
";",
"}"
]
| Get query, values for a key, or value for a key index.
@param k optional query key.
@param i optional query key index.
@return query, values for a key, or value for a key index. | [
"Get",
"query",
"values",
"for",
"a",
"key",
"or",
"value",
"for",
"a",
"key",
"index",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L2833-L2844 | train |
|
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | _expandKey | function _expandKey(key, decrypt) {
// copy the key's words to initialize the key schedule
var w = key.slice(0);
/* RotWord() will rotate a word, moving the first byte to the last
byte's position (shifting the other bytes left).
We will be getting the value of Rcon at i / Nk. 'i' will iterate
from Nk to (Nb * Nr+1). Nk = 4 (4 byte key), Nb = 4 (4 words in
a block), Nr = Nk + 6 (10). Therefore 'i' will iterate from
4 to 44 (exclusive). Each time we iterate 4 times, i / Nk will
increase by 1. We use a counter iNk to keep track of this.
*/
// go through the rounds expanding the key
var temp, iNk = 1;
var Nk = w.length;
var Nr1 = Nk + 6 + 1;
var end = Nb * Nr1;
for(var i = Nk; i < end; ++i) {
temp = w[i - 1];
if(i % Nk === 0) {
// temp = SubWord(RotWord(temp)) ^ Rcon[i / Nk]
temp =
sbox[temp >>> 16 & 255] << 24 ^
sbox[temp >>> 8 & 255] << 16 ^
sbox[temp & 255] << 8 ^
sbox[temp >>> 24] ^ (rcon[iNk] << 24);
iNk++;
} else if(Nk > 6 && (i % Nk === 4)) {
// temp = SubWord(temp)
temp =
sbox[temp >>> 24] << 24 ^
sbox[temp >>> 16 & 255] << 16 ^
sbox[temp >>> 8 & 255] << 8 ^
sbox[temp & 255];
}
w[i] = w[i - Nk] ^ temp;
}
/* When we are updating a cipher block we always use the code path for
encryption whether we are decrypting or not (to shorten code and
simplify the generation of look up tables). However, because there
are differences in the decryption algorithm, other than just swapping
in different look up tables, we must transform our key schedule to
account for these changes:
1. The decryption algorithm gets its key rounds in reverse order.
2. The decryption algorithm adds the round key before mixing columns
instead of afterwards.
We don't need to modify our key schedule to handle the first case,
we can just traverse the key schedule in reverse order when decrypting.
The second case requires a little work.
The tables we built for performing rounds will take an input and then
perform SubBytes() and MixColumns() or, for the decrypt version,
InvSubBytes() and InvMixColumns(). But the decrypt algorithm requires
us to AddRoundKey() before InvMixColumns(). This means we'll need to
apply some transformations to the round key to inverse-mix its columns
so they'll be correct for moving AddRoundKey() to after the state has
had its columns inverse-mixed.
To inverse-mix the columns of the state when we're decrypting we use a
lookup table that will apply InvSubBytes() and InvMixColumns() at the
same time. However, the round key's bytes are not inverse-substituted
in the decryption algorithm. To get around this problem, we can first
substitute the bytes in the round key so that when we apply the
transformation via the InvSubBytes()+InvMixColumns() table, it will
undo our substitution leaving us with the original value that we
want -- and then inverse-mix that value.
This change will correctly alter our key schedule so that we can XOR
each round key with our already transformed decryption state. This
allows us to use the same code path as the encryption algorithm.
We make one more change to the decryption key. Since the decryption
algorithm runs in reverse from the encryption algorithm, we reverse
the order of the round keys to avoid having to iterate over the key
schedule backwards when running the encryption algorithm later in
decryption mode. In addition to reversing the order of the round keys,
we also swap each round key's 2nd and 4th rows. See the comments
section where rounds are performed for more details about why this is
done. These changes are done inline with the other substitution
described above.
*/
if(decrypt) {
var tmp;
var m0 = imix[0];
var m1 = imix[1];
var m2 = imix[2];
var m3 = imix[3];
var wnew = w.slice(0);
end = w.length;
for(var i = 0, wi = end - Nb; i < end; i += Nb, wi -= Nb) {
// do not sub the first or last round key (round keys are Nb
// words) as no column mixing is performed before they are added,
// but do change the key order
if(i === 0 || i === (end - Nb)) {
wnew[i] = w[wi];
wnew[i + 1] = w[wi + 3];
wnew[i + 2] = w[wi + 2];
wnew[i + 3] = w[wi + 1];
} else {
// substitute each round key byte because the inverse-mix
// table will inverse-substitute it (effectively cancel the
// substitution because round key bytes aren't sub'd in
// decryption mode) and swap indexes 3 and 1
for(var n = 0; n < Nb; ++n) {
tmp = w[wi + n];
wnew[i + (3&-n)] =
m0[sbox[tmp >>> 24]] ^
m1[sbox[tmp >>> 16 & 255]] ^
m2[sbox[tmp >>> 8 & 255]] ^
m3[sbox[tmp & 255]];
}
}
}
w = wnew;
}
return w;
} | javascript | function _expandKey(key, decrypt) {
// copy the key's words to initialize the key schedule
var w = key.slice(0);
/* RotWord() will rotate a word, moving the first byte to the last
byte's position (shifting the other bytes left).
We will be getting the value of Rcon at i / Nk. 'i' will iterate
from Nk to (Nb * Nr+1). Nk = 4 (4 byte key), Nb = 4 (4 words in
a block), Nr = Nk + 6 (10). Therefore 'i' will iterate from
4 to 44 (exclusive). Each time we iterate 4 times, i / Nk will
increase by 1. We use a counter iNk to keep track of this.
*/
// go through the rounds expanding the key
var temp, iNk = 1;
var Nk = w.length;
var Nr1 = Nk + 6 + 1;
var end = Nb * Nr1;
for(var i = Nk; i < end; ++i) {
temp = w[i - 1];
if(i % Nk === 0) {
// temp = SubWord(RotWord(temp)) ^ Rcon[i / Nk]
temp =
sbox[temp >>> 16 & 255] << 24 ^
sbox[temp >>> 8 & 255] << 16 ^
sbox[temp & 255] << 8 ^
sbox[temp >>> 24] ^ (rcon[iNk] << 24);
iNk++;
} else if(Nk > 6 && (i % Nk === 4)) {
// temp = SubWord(temp)
temp =
sbox[temp >>> 24] << 24 ^
sbox[temp >>> 16 & 255] << 16 ^
sbox[temp >>> 8 & 255] << 8 ^
sbox[temp & 255];
}
w[i] = w[i - Nk] ^ temp;
}
/* When we are updating a cipher block we always use the code path for
encryption whether we are decrypting or not (to shorten code and
simplify the generation of look up tables). However, because there
are differences in the decryption algorithm, other than just swapping
in different look up tables, we must transform our key schedule to
account for these changes:
1. The decryption algorithm gets its key rounds in reverse order.
2. The decryption algorithm adds the round key before mixing columns
instead of afterwards.
We don't need to modify our key schedule to handle the first case,
we can just traverse the key schedule in reverse order when decrypting.
The second case requires a little work.
The tables we built for performing rounds will take an input and then
perform SubBytes() and MixColumns() or, for the decrypt version,
InvSubBytes() and InvMixColumns(). But the decrypt algorithm requires
us to AddRoundKey() before InvMixColumns(). This means we'll need to
apply some transformations to the round key to inverse-mix its columns
so they'll be correct for moving AddRoundKey() to after the state has
had its columns inverse-mixed.
To inverse-mix the columns of the state when we're decrypting we use a
lookup table that will apply InvSubBytes() and InvMixColumns() at the
same time. However, the round key's bytes are not inverse-substituted
in the decryption algorithm. To get around this problem, we can first
substitute the bytes in the round key so that when we apply the
transformation via the InvSubBytes()+InvMixColumns() table, it will
undo our substitution leaving us with the original value that we
want -- and then inverse-mix that value.
This change will correctly alter our key schedule so that we can XOR
each round key with our already transformed decryption state. This
allows us to use the same code path as the encryption algorithm.
We make one more change to the decryption key. Since the decryption
algorithm runs in reverse from the encryption algorithm, we reverse
the order of the round keys to avoid having to iterate over the key
schedule backwards when running the encryption algorithm later in
decryption mode. In addition to reversing the order of the round keys,
we also swap each round key's 2nd and 4th rows. See the comments
section where rounds are performed for more details about why this is
done. These changes are done inline with the other substitution
described above.
*/
if(decrypt) {
var tmp;
var m0 = imix[0];
var m1 = imix[1];
var m2 = imix[2];
var m3 = imix[3];
var wnew = w.slice(0);
end = w.length;
for(var i = 0, wi = end - Nb; i < end; i += Nb, wi -= Nb) {
// do not sub the first or last round key (round keys are Nb
// words) as no column mixing is performed before they are added,
// but do change the key order
if(i === 0 || i === (end - Nb)) {
wnew[i] = w[wi];
wnew[i + 1] = w[wi + 3];
wnew[i + 2] = w[wi + 2];
wnew[i + 3] = w[wi + 1];
} else {
// substitute each round key byte because the inverse-mix
// table will inverse-substitute it (effectively cancel the
// substitution because round key bytes aren't sub'd in
// decryption mode) and swap indexes 3 and 1
for(var n = 0; n < Nb; ++n) {
tmp = w[wi + n];
wnew[i + (3&-n)] =
m0[sbox[tmp >>> 24]] ^
m1[sbox[tmp >>> 16 & 255]] ^
m2[sbox[tmp >>> 8 & 255]] ^
m3[sbox[tmp & 255]];
}
}
}
w = wnew;
}
return w;
} | [
"function",
"_expandKey",
"(",
"key",
",",
"decrypt",
")",
"{",
"var",
"w",
"=",
"key",
".",
"slice",
"(",
"0",
")",
";",
"var",
"temp",
",",
"iNk",
"=",
"1",
";",
"var",
"Nk",
"=",
"w",
".",
"length",
";",
"var",
"Nr1",
"=",
"Nk",
"+",
"6",
"+",
"1",
";",
"var",
"end",
"=",
"Nb",
"*",
"Nr1",
";",
"for",
"(",
"var",
"i",
"=",
"Nk",
";",
"i",
"<",
"end",
";",
"++",
"i",
")",
"{",
"temp",
"=",
"w",
"[",
"i",
"-",
"1",
"]",
";",
"if",
"(",
"i",
"%",
"Nk",
"===",
"0",
")",
"{",
"temp",
"=",
"sbox",
"[",
"temp",
">>>",
"16",
"&",
"255",
"]",
"<<",
"24",
"^",
"sbox",
"[",
"temp",
">>>",
"8",
"&",
"255",
"]",
"<<",
"16",
"^",
"sbox",
"[",
"temp",
"&",
"255",
"]",
"<<",
"8",
"^",
"sbox",
"[",
"temp",
">>>",
"24",
"]",
"^",
"(",
"rcon",
"[",
"iNk",
"]",
"<<",
"24",
")",
";",
"iNk",
"++",
";",
"}",
"else",
"if",
"(",
"Nk",
">",
"6",
"&&",
"(",
"i",
"%",
"Nk",
"===",
"4",
")",
")",
"{",
"temp",
"=",
"sbox",
"[",
"temp",
">>>",
"24",
"]",
"<<",
"24",
"^",
"sbox",
"[",
"temp",
">>>",
"16",
"&",
"255",
"]",
"<<",
"16",
"^",
"sbox",
"[",
"temp",
">>>",
"8",
"&",
"255",
"]",
"<<",
"8",
"^",
"sbox",
"[",
"temp",
"&",
"255",
"]",
";",
"}",
"w",
"[",
"i",
"]",
"=",
"w",
"[",
"i",
"-",
"Nk",
"]",
"^",
"temp",
";",
"}",
"if",
"(",
"decrypt",
")",
"{",
"var",
"tmp",
";",
"var",
"m0",
"=",
"imix",
"[",
"0",
"]",
";",
"var",
"m1",
"=",
"imix",
"[",
"1",
"]",
";",
"var",
"m2",
"=",
"imix",
"[",
"2",
"]",
";",
"var",
"m3",
"=",
"imix",
"[",
"3",
"]",
";",
"var",
"wnew",
"=",
"w",
".",
"slice",
"(",
"0",
")",
";",
"end",
"=",
"w",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"wi",
"=",
"end",
"-",
"Nb",
";",
"i",
"<",
"end",
";",
"i",
"+=",
"Nb",
",",
"wi",
"-=",
"Nb",
")",
"{",
"if",
"(",
"i",
"===",
"0",
"||",
"i",
"===",
"(",
"end",
"-",
"Nb",
")",
")",
"{",
"wnew",
"[",
"i",
"]",
"=",
"w",
"[",
"wi",
"]",
";",
"wnew",
"[",
"i",
"+",
"1",
"]",
"=",
"w",
"[",
"wi",
"+",
"3",
"]",
";",
"wnew",
"[",
"i",
"+",
"2",
"]",
"=",
"w",
"[",
"wi",
"+",
"2",
"]",
";",
"wnew",
"[",
"i",
"+",
"3",
"]",
"=",
"w",
"[",
"wi",
"+",
"1",
"]",
";",
"}",
"else",
"{",
"for",
"(",
"var",
"n",
"=",
"0",
";",
"n",
"<",
"Nb",
";",
"++",
"n",
")",
"{",
"tmp",
"=",
"w",
"[",
"wi",
"+",
"n",
"]",
";",
"wnew",
"[",
"i",
"+",
"(",
"3",
"&",
"-",
"n",
")",
"]",
"=",
"m0",
"[",
"sbox",
"[",
"tmp",
">>>",
"24",
"]",
"]",
"^",
"m1",
"[",
"sbox",
"[",
"tmp",
">>>",
"16",
"&",
"255",
"]",
"]",
"^",
"m2",
"[",
"sbox",
"[",
"tmp",
">>>",
"8",
"&",
"255",
"]",
"]",
"^",
"m3",
"[",
"sbox",
"[",
"tmp",
"&",
"255",
"]",
"]",
";",
"}",
"}",
"}",
"w",
"=",
"wnew",
";",
"}",
"return",
"w",
";",
"}"
]
| Generates a key schedule using the AES key expansion algorithm.
The AES algorithm takes the Cipher Key, K, and performs a Key Expansion
routine to generate a key schedule. The Key Expansion generates a total
of Nb*(Nr + 1) words: the algorithm requires an initial set of Nb words,
and each of the Nr rounds requires Nb words of key data. The resulting
key schedule consists of a linear array of 4-byte words, denoted [wi ],
with i in the range 0 ≤ i < Nb(Nr + 1).
KeyExpansion(byte key[4*Nk], word w[Nb*(Nr+1)], Nk)
AES-128 (Nb=4, Nk=4, Nr=10)
AES-192 (Nb=4, Nk=6, Nr=12)
AES-256 (Nb=4, Nk=8, Nr=14)
Note: Nr=Nk+6.
Nb is the number of columns (32-bit words) comprising the State (or
number of bytes in a block). For AES, Nb=4.
@param key the key to schedule (as an array of 32-bit words).
@param decrypt true to modify the key schedule to decrypt, false not to.
@return the generated key schedule. | [
"Generates",
"a",
"key",
"schedule",
"using",
"the",
"AES",
"key",
"expansion",
"algorithm",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L5425-L5548 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | _update | function _update(s, w, bytes) {
// consume 512 bit (64 byte) chunks
var t, a, b, c, d, f, r, i;
var len = bytes.length();
while(len >= 64) {
// initialize hash value for this chunk
a = s.h0;
b = s.h1;
c = s.h2;
d = s.h3;
// round 1
for(i = 0; i < 16; ++i) {
w[i] = bytes.getInt32Le();
f = d ^ (b & (c ^ d));
t = (a + f + _k[i] + w[i]);
r = _r[i];
a = d;
d = c;
c = b;
b += (t << r) | (t >>> (32 - r));
}
// round 2
for(; i < 32; ++i) {
f = c ^ (d & (b ^ c));
t = (a + f + _k[i] + w[_g[i]]);
r = _r[i];
a = d;
d = c;
c = b;
b += (t << r) | (t >>> (32 - r));
}
// round 3
for(; i < 48; ++i) {
f = b ^ c ^ d;
t = (a + f + _k[i] + w[_g[i]]);
r = _r[i];
a = d;
d = c;
c = b;
b += (t << r) | (t >>> (32 - r));
}
// round 4
for(; i < 64; ++i) {
f = c ^ (b | ~d);
t = (a + f + _k[i] + w[_g[i]]);
r = _r[i];
a = d;
d = c;
c = b;
b += (t << r) | (t >>> (32 - r));
}
// update hash state
s.h0 = (s.h0 + a) | 0;
s.h1 = (s.h1 + b) | 0;
s.h2 = (s.h2 + c) | 0;
s.h3 = (s.h3 + d) | 0;
len -= 64;
}
} | javascript | function _update(s, w, bytes) {
// consume 512 bit (64 byte) chunks
var t, a, b, c, d, f, r, i;
var len = bytes.length();
while(len >= 64) {
// initialize hash value for this chunk
a = s.h0;
b = s.h1;
c = s.h2;
d = s.h3;
// round 1
for(i = 0; i < 16; ++i) {
w[i] = bytes.getInt32Le();
f = d ^ (b & (c ^ d));
t = (a + f + _k[i] + w[i]);
r = _r[i];
a = d;
d = c;
c = b;
b += (t << r) | (t >>> (32 - r));
}
// round 2
for(; i < 32; ++i) {
f = c ^ (d & (b ^ c));
t = (a + f + _k[i] + w[_g[i]]);
r = _r[i];
a = d;
d = c;
c = b;
b += (t << r) | (t >>> (32 - r));
}
// round 3
for(; i < 48; ++i) {
f = b ^ c ^ d;
t = (a + f + _k[i] + w[_g[i]]);
r = _r[i];
a = d;
d = c;
c = b;
b += (t << r) | (t >>> (32 - r));
}
// round 4
for(; i < 64; ++i) {
f = c ^ (b | ~d);
t = (a + f + _k[i] + w[_g[i]]);
r = _r[i];
a = d;
d = c;
c = b;
b += (t << r) | (t >>> (32 - r));
}
// update hash state
s.h0 = (s.h0 + a) | 0;
s.h1 = (s.h1 + b) | 0;
s.h2 = (s.h2 + c) | 0;
s.h3 = (s.h3 + d) | 0;
len -= 64;
}
} | [
"function",
"_update",
"(",
"s",
",",
"w",
",",
"bytes",
")",
"{",
"var",
"t",
",",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"f",
",",
"r",
",",
"i",
";",
"var",
"len",
"=",
"bytes",
".",
"length",
"(",
")",
";",
"while",
"(",
"len",
">=",
"64",
")",
"{",
"a",
"=",
"s",
".",
"h0",
";",
"b",
"=",
"s",
".",
"h1",
";",
"c",
"=",
"s",
".",
"h2",
";",
"d",
"=",
"s",
".",
"h3",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"16",
";",
"++",
"i",
")",
"{",
"w",
"[",
"i",
"]",
"=",
"bytes",
".",
"getInt32Le",
"(",
")",
";",
"f",
"=",
"d",
"^",
"(",
"b",
"&",
"(",
"c",
"^",
"d",
")",
")",
";",
"t",
"=",
"(",
"a",
"+",
"f",
"+",
"_k",
"[",
"i",
"]",
"+",
"w",
"[",
"i",
"]",
")",
";",
"r",
"=",
"_r",
"[",
"i",
"]",
";",
"a",
"=",
"d",
";",
"d",
"=",
"c",
";",
"c",
"=",
"b",
";",
"b",
"+=",
"(",
"t",
"<<",
"r",
")",
"|",
"(",
"t",
">>>",
"(",
"32",
"-",
"r",
")",
")",
";",
"}",
"for",
"(",
";",
"i",
"<",
"32",
";",
"++",
"i",
")",
"{",
"f",
"=",
"c",
"^",
"(",
"d",
"&",
"(",
"b",
"^",
"c",
")",
")",
";",
"t",
"=",
"(",
"a",
"+",
"f",
"+",
"_k",
"[",
"i",
"]",
"+",
"w",
"[",
"_g",
"[",
"i",
"]",
"]",
")",
";",
"r",
"=",
"_r",
"[",
"i",
"]",
";",
"a",
"=",
"d",
";",
"d",
"=",
"c",
";",
"c",
"=",
"b",
";",
"b",
"+=",
"(",
"t",
"<<",
"r",
")",
"|",
"(",
"t",
">>>",
"(",
"32",
"-",
"r",
")",
")",
";",
"}",
"for",
"(",
";",
"i",
"<",
"48",
";",
"++",
"i",
")",
"{",
"f",
"=",
"b",
"^",
"c",
"^",
"d",
";",
"t",
"=",
"(",
"a",
"+",
"f",
"+",
"_k",
"[",
"i",
"]",
"+",
"w",
"[",
"_g",
"[",
"i",
"]",
"]",
")",
";",
"r",
"=",
"_r",
"[",
"i",
"]",
";",
"a",
"=",
"d",
";",
"d",
"=",
"c",
";",
"c",
"=",
"b",
";",
"b",
"+=",
"(",
"t",
"<<",
"r",
")",
"|",
"(",
"t",
">>>",
"(",
"32",
"-",
"r",
")",
")",
";",
"}",
"for",
"(",
";",
"i",
"<",
"64",
";",
"++",
"i",
")",
"{",
"f",
"=",
"c",
"^",
"(",
"b",
"|",
"~",
"d",
")",
";",
"t",
"=",
"(",
"a",
"+",
"f",
"+",
"_k",
"[",
"i",
"]",
"+",
"w",
"[",
"_g",
"[",
"i",
"]",
"]",
")",
";",
"r",
"=",
"_r",
"[",
"i",
"]",
";",
"a",
"=",
"d",
";",
"d",
"=",
"c",
";",
"c",
"=",
"b",
";",
"b",
"+=",
"(",
"t",
"<<",
"r",
")",
"|",
"(",
"t",
">>>",
"(",
"32",
"-",
"r",
")",
")",
";",
"}",
"s",
".",
"h0",
"=",
"(",
"s",
".",
"h0",
"+",
"a",
")",
"|",
"0",
";",
"s",
".",
"h1",
"=",
"(",
"s",
".",
"h1",
"+",
"b",
")",
"|",
"0",
";",
"s",
".",
"h2",
"=",
"(",
"s",
".",
"h2",
"+",
"c",
")",
"|",
"0",
";",
"s",
".",
"h3",
"=",
"(",
"s",
".",
"h3",
"+",
"d",
")",
"|",
"0",
";",
"len",
"-=",
"64",
";",
"}",
"}"
]
| Updates an MD5 state with the given byte buffer.
@param s the MD5 state to update.
@param w the array to use to store words.
@param bytes the byte buffer to update with. | [
"Updates",
"an",
"MD5",
"state",
"with",
"the",
"given",
"byte",
"buffer",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L7563-L7624 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | _reseed | function _reseed(callback) {
if(ctx.pools[0].messageLength >= 32) {
_seed();
return callback();
}
// not enough seed data...
var needed = (32 - ctx.pools[0].messageLength) << 5;
ctx.seedFile(needed, function(err, bytes) {
if(err) {
return callback(err);
}
ctx.collect(bytes);
_seed();
callback();
});
} | javascript | function _reseed(callback) {
if(ctx.pools[0].messageLength >= 32) {
_seed();
return callback();
}
// not enough seed data...
var needed = (32 - ctx.pools[0].messageLength) << 5;
ctx.seedFile(needed, function(err, bytes) {
if(err) {
return callback(err);
}
ctx.collect(bytes);
_seed();
callback();
});
} | [
"function",
"_reseed",
"(",
"callback",
")",
"{",
"if",
"(",
"ctx",
".",
"pools",
"[",
"0",
"]",
".",
"messageLength",
">=",
"32",
")",
"{",
"_seed",
"(",
")",
";",
"return",
"callback",
"(",
")",
";",
"}",
"var",
"needed",
"=",
"(",
"32",
"-",
"ctx",
".",
"pools",
"[",
"0",
"]",
".",
"messageLength",
")",
"<<",
"5",
";",
"ctx",
".",
"seedFile",
"(",
"needed",
",",
"function",
"(",
"err",
",",
"bytes",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"callback",
"(",
"err",
")",
";",
"}",
"ctx",
".",
"collect",
"(",
"bytes",
")",
";",
"_seed",
"(",
")",
";",
"callback",
"(",
")",
";",
"}",
")",
";",
"}"
]
| Private function that asynchronously reseeds a generator.
@param callback(err) called once the operation completes. | [
"Private",
"function",
"that",
"asynchronously",
"reseeds",
"a",
"generator",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L10590-L10605 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | function(e) {
var data = e.data;
if(data.forge && data.forge.prng) {
ctx.seedFile(data.forge.prng.needed, function(err, bytes) {
worker.postMessage({forge: {prng: {err: err, bytes: bytes}}});
});
}
} | javascript | function(e) {
var data = e.data;
if(data.forge && data.forge.prng) {
ctx.seedFile(data.forge.prng.needed, function(err, bytes) {
worker.postMessage({forge: {prng: {err: err, bytes: bytes}}});
});
}
} | [
"function",
"(",
"e",
")",
"{",
"var",
"data",
"=",
"e",
".",
"data",
";",
"if",
"(",
"data",
".",
"forge",
"&&",
"data",
".",
"forge",
".",
"prng",
")",
"{",
"ctx",
".",
"seedFile",
"(",
"data",
".",
"forge",
".",
"prng",
".",
"needed",
",",
"function",
"(",
"err",
",",
"bytes",
")",
"{",
"worker",
".",
"postMessage",
"(",
"{",
"forge",
":",
"{",
"prng",
":",
"{",
"err",
":",
"err",
",",
"bytes",
":",
"bytes",
"}",
"}",
"}",
")",
";",
"}",
")",
";",
"}",
"}"
]
| main thread sends random bytes upon request | [
"main",
"thread",
"sends",
"random",
"bytes",
"upon",
"request"
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L10803-L10810 | train |
|
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | function(iv, output) {
if(iv) {
/* CBC mode */
if(typeof iv === 'string') {
iv = forge.util.createBuffer(iv);
}
}
_finish = false;
_input = forge.util.createBuffer();
_output = output || new forge.util.createBuffer();
_iv = iv;
cipher.output = _output;
} | javascript | function(iv, output) {
if(iv) {
/* CBC mode */
if(typeof iv === 'string') {
iv = forge.util.createBuffer(iv);
}
}
_finish = false;
_input = forge.util.createBuffer();
_output = output || new forge.util.createBuffer();
_iv = iv;
cipher.output = _output;
} | [
"function",
"(",
"iv",
",",
"output",
")",
"{",
"if",
"(",
"iv",
")",
"{",
"if",
"(",
"typeof",
"iv",
"===",
"'string'",
")",
"{",
"iv",
"=",
"forge",
".",
"util",
".",
"createBuffer",
"(",
"iv",
")",
";",
"}",
"}",
"_finish",
"=",
"false",
";",
"_input",
"=",
"forge",
".",
"util",
".",
"createBuffer",
"(",
")",
";",
"_output",
"=",
"output",
"||",
"new",
"forge",
".",
"util",
".",
"createBuffer",
"(",
")",
";",
"_iv",
"=",
"iv",
";",
"cipher",
".",
"output",
"=",
"_output",
";",
"}"
]
| Starts or restarts the encryption or decryption process, whichever
was previously configured.
To use the cipher in CBC mode, iv may be given either as a string
of bytes, or as a byte buffer. For ECB mode, give null as iv.
@param iv the initialization vector to use, null for ECB mode.
@param output the output the buffer to write to, null to create one. | [
"Starts",
"or",
"restarts",
"the",
"encryption",
"or",
"decryption",
"process",
"whichever",
"was",
"previously",
"configured",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L11360-L11374 | train |
|
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | generateRandom | function generateRandom(bits, rng) {
var num = new BigInteger(bits, rng);
// force MSB set
var bits1 = bits - 1;
if(!num.testBit(bits1)) {
num.bitwiseTo(BigInteger.ONE.shiftLeft(bits1), op_or, num);
}
// align number on 30k+1 boundary
num.dAddOffset(31 - num.mod(THIRTY).byteValue(), 0);
return num;
} | javascript | function generateRandom(bits, rng) {
var num = new BigInteger(bits, rng);
// force MSB set
var bits1 = bits - 1;
if(!num.testBit(bits1)) {
num.bitwiseTo(BigInteger.ONE.shiftLeft(bits1), op_or, num);
}
// align number on 30k+1 boundary
num.dAddOffset(31 - num.mod(THIRTY).byteValue(), 0);
return num;
} | [
"function",
"generateRandom",
"(",
"bits",
",",
"rng",
")",
"{",
"var",
"num",
"=",
"new",
"BigInteger",
"(",
"bits",
",",
"rng",
")",
";",
"var",
"bits1",
"=",
"bits",
"-",
"1",
";",
"if",
"(",
"!",
"num",
".",
"testBit",
"(",
"bits1",
")",
")",
"{",
"num",
".",
"bitwiseTo",
"(",
"BigInteger",
".",
"ONE",
".",
"shiftLeft",
"(",
"bits1",
")",
",",
"op_or",
",",
"num",
")",
";",
"}",
"num",
".",
"dAddOffset",
"(",
"31",
"-",
"num",
".",
"mod",
"(",
"THIRTY",
")",
".",
"byteValue",
"(",
")",
",",
"0",
")",
";",
"return",
"num",
";",
"}"
]
| Generates a random number using the given number of bits and RNG.
@param bits the number of bits for the number.
@param rng the random number generator to use.
@return the random number. | [
"Generates",
"a",
"random",
"number",
"using",
"the",
"given",
"number",
"of",
"bits",
"and",
"RNG",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L13481-L13491 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | function(md) {
// get the oid for the algorithm
var oid;
if(md.algorithm in pki.oids) {
oid = pki.oids[md.algorithm];
} else {
var error = new Error('Unknown message digest algorithm.');
error.algorithm = md.algorithm;
throw error;
}
var oidBytes = asn1.oidToDer(oid).getBytes();
// create the digest info
var digestInfo = asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
var digestAlgorithm = asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
digestAlgorithm.value.push(asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.OID, false, oidBytes));
digestAlgorithm.value.push(asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.NULL, false, ''));
var digest = asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING,
false, md.digest().getBytes());
digestInfo.value.push(digestAlgorithm);
digestInfo.value.push(digest);
// encode digest info
return asn1.toDer(digestInfo).getBytes();
} | javascript | function(md) {
// get the oid for the algorithm
var oid;
if(md.algorithm in pki.oids) {
oid = pki.oids[md.algorithm];
} else {
var error = new Error('Unknown message digest algorithm.');
error.algorithm = md.algorithm;
throw error;
}
var oidBytes = asn1.oidToDer(oid).getBytes();
// create the digest info
var digestInfo = asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
var digestAlgorithm = asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
digestAlgorithm.value.push(asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.OID, false, oidBytes));
digestAlgorithm.value.push(asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.NULL, false, ''));
var digest = asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING,
false, md.digest().getBytes());
digestInfo.value.push(digestAlgorithm);
digestInfo.value.push(digest);
// encode digest info
return asn1.toDer(digestInfo).getBytes();
} | [
"function",
"(",
"md",
")",
"{",
"var",
"oid",
";",
"if",
"(",
"md",
".",
"algorithm",
"in",
"pki",
".",
"oids",
")",
"{",
"oid",
"=",
"pki",
".",
"oids",
"[",
"md",
".",
"algorithm",
"]",
";",
"}",
"else",
"{",
"var",
"error",
"=",
"new",
"Error",
"(",
"'Unknown message digest algorithm.'",
")",
";",
"error",
".",
"algorithm",
"=",
"md",
".",
"algorithm",
";",
"throw",
"error",
";",
"}",
"var",
"oidBytes",
"=",
"asn1",
".",
"oidToDer",
"(",
"oid",
")",
".",
"getBytes",
"(",
")",
";",
"var",
"digestInfo",
"=",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SEQUENCE",
",",
"true",
",",
"[",
"]",
")",
";",
"var",
"digestAlgorithm",
"=",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SEQUENCE",
",",
"true",
",",
"[",
"]",
")",
";",
"digestAlgorithm",
".",
"value",
".",
"push",
"(",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OID",
",",
"false",
",",
"oidBytes",
")",
")",
";",
"digestAlgorithm",
".",
"value",
".",
"push",
"(",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"NULL",
",",
"false",
",",
"''",
")",
")",
";",
"var",
"digest",
"=",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OCTETSTRING",
",",
"false",
",",
"md",
".",
"digest",
"(",
")",
".",
"getBytes",
"(",
")",
")",
";",
"digestInfo",
".",
"value",
".",
"push",
"(",
"digestAlgorithm",
")",
";",
"digestInfo",
".",
"value",
".",
"push",
"(",
"digest",
")",
";",
"return",
"asn1",
".",
"toDer",
"(",
"digestInfo",
")",
".",
"getBytes",
"(",
")",
";",
"}"
]
| Wrap digest in DigestInfo object.
This function implements EMSA-PKCS1-v1_5-ENCODE as per RFC 3447.
DigestInfo ::= SEQUENCE {
digestAlgorithm DigestAlgorithmIdentifier,
digest Digest
}
DigestAlgorithmIdentifier ::= AlgorithmIdentifier
Digest ::= OCTET STRING
@param md the message digest object with the hash to sign.
@return the encoded message (ready for RSA encrytion) | [
"Wrap",
"digest",
"in",
"DigestInfo",
"object",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L13846-L13875 | train |
|
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | _getAttribute | function _getAttribute(obj, options) {
if(typeof options === 'string') {
options = {shortName: options};
}
var rval = null;
var attr;
for(var i = 0; rval === null && i < obj.attributes.length; ++i) {
attr = obj.attributes[i];
if(options.type && options.type === attr.type) {
rval = attr;
} else if(options.name && options.name === attr.name) {
rval = attr;
} else if(options.shortName && options.shortName === attr.shortName) {
rval = attr;
}
}
return rval;
} | javascript | function _getAttribute(obj, options) {
if(typeof options === 'string') {
options = {shortName: options};
}
var rval = null;
var attr;
for(var i = 0; rval === null && i < obj.attributes.length; ++i) {
attr = obj.attributes[i];
if(options.type && options.type === attr.type) {
rval = attr;
} else if(options.name && options.name === attr.name) {
rval = attr;
} else if(options.shortName && options.shortName === attr.shortName) {
rval = attr;
}
}
return rval;
} | [
"function",
"_getAttribute",
"(",
"obj",
",",
"options",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'string'",
")",
"{",
"options",
"=",
"{",
"shortName",
":",
"options",
"}",
";",
"}",
"var",
"rval",
"=",
"null",
";",
"var",
"attr",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"rval",
"===",
"null",
"&&",
"i",
"<",
"obj",
".",
"attributes",
".",
"length",
";",
"++",
"i",
")",
"{",
"attr",
"=",
"obj",
".",
"attributes",
"[",
"i",
"]",
";",
"if",
"(",
"options",
".",
"type",
"&&",
"options",
".",
"type",
"===",
"attr",
".",
"type",
")",
"{",
"rval",
"=",
"attr",
";",
"}",
"else",
"if",
"(",
"options",
".",
"name",
"&&",
"options",
".",
"name",
"===",
"attr",
".",
"name",
")",
"{",
"rval",
"=",
"attr",
";",
"}",
"else",
"if",
"(",
"options",
".",
"shortName",
"&&",
"options",
".",
"shortName",
"===",
"attr",
".",
"shortName",
")",
"{",
"rval",
"=",
"attr",
";",
"}",
"}",
"return",
"rval",
";",
"}"
]
| Gets an issuer or subject attribute from its name, type, or short name.
@param obj the issuer or subject object.
@param options a short name string or an object with:
shortName the short name for the attribute.
name the name for the attribute.
type the type for the attribute.
@return the attribute. | [
"Gets",
"an",
"issuer",
"or",
"subject",
"attribute",
"from",
"its",
"name",
"type",
"or",
"short",
"name",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L17787-L17805 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | function(oid, obj, fillDefaults) {
var params = {};
if(oid !== oids['RSASSA-PSS']) {
return params;
}
if(fillDefaults) {
params = {
hash: {
algorithmOid: oids['sha1']
},
mgf: {
algorithmOid: oids['mgf1'],
hash: {
algorithmOid: oids['sha1']
}
},
saltLength: 20
};
}
var capture = {};
var errors = [];
if(!asn1.validate(obj, rsassaPssParameterValidator, capture, errors)) {
var error = new Error('Cannot read RSASSA-PSS parameter block.');
error.errors = errors;
throw error;
}
if(capture.hashOid !== undefined) {
params.hash = params.hash || {};
params.hash.algorithmOid = asn1.derToOid(capture.hashOid);
}
if(capture.maskGenOid !== undefined) {
params.mgf = params.mgf || {};
params.mgf.algorithmOid = asn1.derToOid(capture.maskGenOid);
params.mgf.hash = params.mgf.hash || {};
params.mgf.hash.algorithmOid = asn1.derToOid(capture.maskGenHashOid);
}
if(capture.saltLength !== undefined) {
params.saltLength = capture.saltLength.charCodeAt(0);
}
return params;
} | javascript | function(oid, obj, fillDefaults) {
var params = {};
if(oid !== oids['RSASSA-PSS']) {
return params;
}
if(fillDefaults) {
params = {
hash: {
algorithmOid: oids['sha1']
},
mgf: {
algorithmOid: oids['mgf1'],
hash: {
algorithmOid: oids['sha1']
}
},
saltLength: 20
};
}
var capture = {};
var errors = [];
if(!asn1.validate(obj, rsassaPssParameterValidator, capture, errors)) {
var error = new Error('Cannot read RSASSA-PSS parameter block.');
error.errors = errors;
throw error;
}
if(capture.hashOid !== undefined) {
params.hash = params.hash || {};
params.hash.algorithmOid = asn1.derToOid(capture.hashOid);
}
if(capture.maskGenOid !== undefined) {
params.mgf = params.mgf || {};
params.mgf.algorithmOid = asn1.derToOid(capture.maskGenOid);
params.mgf.hash = params.mgf.hash || {};
params.mgf.hash.algorithmOid = asn1.derToOid(capture.maskGenHashOid);
}
if(capture.saltLength !== undefined) {
params.saltLength = capture.saltLength.charCodeAt(0);
}
return params;
} | [
"function",
"(",
"oid",
",",
"obj",
",",
"fillDefaults",
")",
"{",
"var",
"params",
"=",
"{",
"}",
";",
"if",
"(",
"oid",
"!==",
"oids",
"[",
"'RSASSA-PSS'",
"]",
")",
"{",
"return",
"params",
";",
"}",
"if",
"(",
"fillDefaults",
")",
"{",
"params",
"=",
"{",
"hash",
":",
"{",
"algorithmOid",
":",
"oids",
"[",
"'sha1'",
"]",
"}",
",",
"mgf",
":",
"{",
"algorithmOid",
":",
"oids",
"[",
"'mgf1'",
"]",
",",
"hash",
":",
"{",
"algorithmOid",
":",
"oids",
"[",
"'sha1'",
"]",
"}",
"}",
",",
"saltLength",
":",
"20",
"}",
";",
"}",
"var",
"capture",
"=",
"{",
"}",
";",
"var",
"errors",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"asn1",
".",
"validate",
"(",
"obj",
",",
"rsassaPssParameterValidator",
",",
"capture",
",",
"errors",
")",
")",
"{",
"var",
"error",
"=",
"new",
"Error",
"(",
"'Cannot read RSASSA-PSS parameter block.'",
")",
";",
"error",
".",
"errors",
"=",
"errors",
";",
"throw",
"error",
";",
"}",
"if",
"(",
"capture",
".",
"hashOid",
"!==",
"undefined",
")",
"{",
"params",
".",
"hash",
"=",
"params",
".",
"hash",
"||",
"{",
"}",
";",
"params",
".",
"hash",
".",
"algorithmOid",
"=",
"asn1",
".",
"derToOid",
"(",
"capture",
".",
"hashOid",
")",
";",
"}",
"if",
"(",
"capture",
".",
"maskGenOid",
"!==",
"undefined",
")",
"{",
"params",
".",
"mgf",
"=",
"params",
".",
"mgf",
"||",
"{",
"}",
";",
"params",
".",
"mgf",
".",
"algorithmOid",
"=",
"asn1",
".",
"derToOid",
"(",
"capture",
".",
"maskGenOid",
")",
";",
"params",
".",
"mgf",
".",
"hash",
"=",
"params",
".",
"mgf",
".",
"hash",
"||",
"{",
"}",
";",
"params",
".",
"mgf",
".",
"hash",
".",
"algorithmOid",
"=",
"asn1",
".",
"derToOid",
"(",
"capture",
".",
"maskGenHashOid",
")",
";",
"}",
"if",
"(",
"capture",
".",
"saltLength",
"!==",
"undefined",
")",
"{",
"params",
".",
"saltLength",
"=",
"capture",
".",
"saltLength",
".",
"charCodeAt",
"(",
"0",
")",
";",
"}",
"return",
"params",
";",
"}"
]
| Converts signature parameters from ASN.1 structure.
Currently only RSASSA-PSS supported. The PKCS#1 v1.5 signature scheme had
no parameters.
RSASSA-PSS-params ::= SEQUENCE {
hashAlgorithm [0] HashAlgorithm DEFAULT
sha1Identifier,
maskGenAlgorithm [1] MaskGenAlgorithm DEFAULT
mgf1SHA1Identifier,
saltLength [2] INTEGER DEFAULT 20,
trailerField [3] INTEGER DEFAULT 1
}
HashAlgorithm ::= AlgorithmIdentifier
MaskGenAlgorithm ::= AlgorithmIdentifier
AlgorithmIdentifer ::= SEQUENCE {
algorithm OBJECT IDENTIFIER,
parameters ANY DEFINED BY algorithm OPTIONAL
}
@param oid The OID specifying the signature algorithm
@param obj The ASN.1 structure holding the parameters
@param fillDefaults Whether to use return default values where omitted
@return signature parameter object | [
"Converts",
"signature",
"parameters",
"from",
"ASN",
".",
"1",
"structure",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L17836-L17883 | train |
|
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | _dnToAsn1 | function _dnToAsn1(obj) {
// create an empty RDNSequence
var rval = asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
// iterate over attributes
var attr, set;
var attrs = obj.attributes;
for(var i = 0; i < attrs.length; ++i) {
attr = attrs[i];
var value = attr.value;
// reuse tag class for attribute value if available
var valueTagClass = asn1.Type.PRINTABLESTRING;
if('valueTagClass' in attr) {
valueTagClass = attr.valueTagClass;
if(valueTagClass === asn1.Type.UTF8) {
value = forge.util.encodeUtf8(value);
}
// FIXME: handle more encodings
}
// create a RelativeDistinguishedName set
// each value in the set is an AttributeTypeAndValue first
// containing the type (an OID) and second the value
set = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// AttributeType
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(attr.type).getBytes()),
// AttributeValue
asn1.create(asn1.Class.UNIVERSAL, valueTagClass, false, value)
])
]);
rval.value.push(set);
}
return rval;
} | javascript | function _dnToAsn1(obj) {
// create an empty RDNSequence
var rval = asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
// iterate over attributes
var attr, set;
var attrs = obj.attributes;
for(var i = 0; i < attrs.length; ++i) {
attr = attrs[i];
var value = attr.value;
// reuse tag class for attribute value if available
var valueTagClass = asn1.Type.PRINTABLESTRING;
if('valueTagClass' in attr) {
valueTagClass = attr.valueTagClass;
if(valueTagClass === asn1.Type.UTF8) {
value = forge.util.encodeUtf8(value);
}
// FIXME: handle more encodings
}
// create a RelativeDistinguishedName set
// each value in the set is an AttributeTypeAndValue first
// containing the type (an OID) and second the value
set = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// AttributeType
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(attr.type).getBytes()),
// AttributeValue
asn1.create(asn1.Class.UNIVERSAL, valueTagClass, false, value)
])
]);
rval.value.push(set);
}
return rval;
} | [
"function",
"_dnToAsn1",
"(",
"obj",
")",
"{",
"var",
"rval",
"=",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SEQUENCE",
",",
"true",
",",
"[",
"]",
")",
";",
"var",
"attr",
",",
"set",
";",
"var",
"attrs",
"=",
"obj",
".",
"attributes",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"attrs",
".",
"length",
";",
"++",
"i",
")",
"{",
"attr",
"=",
"attrs",
"[",
"i",
"]",
";",
"var",
"value",
"=",
"attr",
".",
"value",
";",
"var",
"valueTagClass",
"=",
"asn1",
".",
"Type",
".",
"PRINTABLESTRING",
";",
"if",
"(",
"'valueTagClass'",
"in",
"attr",
")",
"{",
"valueTagClass",
"=",
"attr",
".",
"valueTagClass",
";",
"if",
"(",
"valueTagClass",
"===",
"asn1",
".",
"Type",
".",
"UTF8",
")",
"{",
"value",
"=",
"forge",
".",
"util",
".",
"encodeUtf8",
"(",
"value",
")",
";",
"}",
"}",
"set",
"=",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SET",
",",
"true",
",",
"[",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SEQUENCE",
",",
"true",
",",
"[",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OID",
",",
"false",
",",
"asn1",
".",
"oidToDer",
"(",
"attr",
".",
"type",
")",
".",
"getBytes",
"(",
")",
")",
",",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"valueTagClass",
",",
"false",
",",
"value",
")",
"]",
")",
"]",
")",
";",
"rval",
".",
"value",
".",
"push",
"(",
"set",
")",
";",
"}",
"return",
"rval",
";",
"}"
]
| Converts an X.509 subject or issuer to an ASN.1 RDNSequence.
@param obj the subject or issuer (distinguished name).
@return the ASN.1 RDNSequence. | [
"Converts",
"an",
"X",
".",
"509",
"subject",
"or",
"issuer",
"to",
"an",
"ASN",
".",
"1",
"RDNSequence",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L19150-L19189 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | _signatureParametersToAsn1 | function _signatureParametersToAsn1(oid, params) {
switch(oid) {
case oids['RSASSA-PSS']:
var parts = [];
if(params.hash.algorithmOid !== undefined) {
parts.push(asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(params.hash.algorithmOid).getBytes()),
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
])
]));
}
if(params.mgf.algorithmOid !== undefined) {
parts.push(asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, [
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(params.mgf.algorithmOid).getBytes()),
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(params.mgf.hash.algorithmOid).getBytes()),
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
])
])
]));
}
if(params.saltLength !== undefined) {
parts.push(asn1.create(asn1.Class.CONTEXT_SPECIFIC, 2, true, [
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
asn1.integerToDer(params.saltLength).getBytes())
]));
}
return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, parts);
default:
return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '');
}
} | javascript | function _signatureParametersToAsn1(oid, params) {
switch(oid) {
case oids['RSASSA-PSS']:
var parts = [];
if(params.hash.algorithmOid !== undefined) {
parts.push(asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(params.hash.algorithmOid).getBytes()),
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
])
]));
}
if(params.mgf.algorithmOid !== undefined) {
parts.push(asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, [
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(params.mgf.algorithmOid).getBytes()),
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(params.mgf.hash.algorithmOid).getBytes()),
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
])
])
]));
}
if(params.saltLength !== undefined) {
parts.push(asn1.create(asn1.Class.CONTEXT_SPECIFIC, 2, true, [
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
asn1.integerToDer(params.saltLength).getBytes())
]));
}
return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, parts);
default:
return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '');
}
} | [
"function",
"_signatureParametersToAsn1",
"(",
"oid",
",",
"params",
")",
"{",
"switch",
"(",
"oid",
")",
"{",
"case",
"oids",
"[",
"'RSASSA-PSS'",
"]",
":",
"var",
"parts",
"=",
"[",
"]",
";",
"if",
"(",
"params",
".",
"hash",
".",
"algorithmOid",
"!==",
"undefined",
")",
"{",
"parts",
".",
"push",
"(",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"CONTEXT_SPECIFIC",
",",
"0",
",",
"true",
",",
"[",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SEQUENCE",
",",
"true",
",",
"[",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OID",
",",
"false",
",",
"asn1",
".",
"oidToDer",
"(",
"params",
".",
"hash",
".",
"algorithmOid",
")",
".",
"getBytes",
"(",
")",
")",
",",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"NULL",
",",
"false",
",",
"''",
")",
"]",
")",
"]",
")",
")",
";",
"}",
"if",
"(",
"params",
".",
"mgf",
".",
"algorithmOid",
"!==",
"undefined",
")",
"{",
"parts",
".",
"push",
"(",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"CONTEXT_SPECIFIC",
",",
"1",
",",
"true",
",",
"[",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SEQUENCE",
",",
"true",
",",
"[",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OID",
",",
"false",
",",
"asn1",
".",
"oidToDer",
"(",
"params",
".",
"mgf",
".",
"algorithmOid",
")",
".",
"getBytes",
"(",
")",
")",
",",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SEQUENCE",
",",
"true",
",",
"[",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OID",
",",
"false",
",",
"asn1",
".",
"oidToDer",
"(",
"params",
".",
"mgf",
".",
"hash",
".",
"algorithmOid",
")",
".",
"getBytes",
"(",
")",
")",
",",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"NULL",
",",
"false",
",",
"''",
")",
"]",
")",
"]",
")",
"]",
")",
")",
";",
"}",
"if",
"(",
"params",
".",
"saltLength",
"!==",
"undefined",
")",
"{",
"parts",
".",
"push",
"(",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"CONTEXT_SPECIFIC",
",",
"2",
",",
"true",
",",
"[",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"INTEGER",
",",
"false",
",",
"asn1",
".",
"integerToDer",
"(",
"params",
".",
"saltLength",
")",
".",
"getBytes",
"(",
")",
")",
"]",
")",
")",
";",
"}",
"return",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SEQUENCE",
",",
"true",
",",
"parts",
")",
";",
"default",
":",
"return",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"NULL",
",",
"false",
",",
"''",
")",
";",
"}",
"}"
]
| Convert signature parameters object to ASN.1
@param {String} oid Signature algorithm OID
@param params The signature parametrs object
@return ASN.1 object representing signature parameters | [
"Convert",
"signature",
"parameters",
"object",
"to",
"ASN",
".",
"1"
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L19504-L19545 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | _getBagsByAttribute | function _getBagsByAttribute(safeContents, attrName, attrValue, bagType) {
var result = [];
for(var i = 0; i < safeContents.length; i ++) {
for(var j = 0; j < safeContents[i].safeBags.length; j ++) {
var bag = safeContents[i].safeBags[j];
if(bagType !== undefined && bag.type !== bagType) {
continue;
}
// only filter by bag type, no attribute specified
if(attrName === null) {
result.push(bag);
continue;
}
if(bag.attributes[attrName] !== undefined &&
bag.attributes[attrName].indexOf(attrValue) >= 0) {
result.push(bag);
}
}
}
return result;
} | javascript | function _getBagsByAttribute(safeContents, attrName, attrValue, bagType) {
var result = [];
for(var i = 0; i < safeContents.length; i ++) {
for(var j = 0; j < safeContents[i].safeBags.length; j ++) {
var bag = safeContents[i].safeBags[j];
if(bagType !== undefined && bag.type !== bagType) {
continue;
}
// only filter by bag type, no attribute specified
if(attrName === null) {
result.push(bag);
continue;
}
if(bag.attributes[attrName] !== undefined &&
bag.attributes[attrName].indexOf(attrValue) >= 0) {
result.push(bag);
}
}
}
return result;
} | [
"function",
"_getBagsByAttribute",
"(",
"safeContents",
",",
"attrName",
",",
"attrValue",
",",
"bagType",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"safeContents",
".",
"length",
";",
"i",
"++",
")",
"{",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"safeContents",
"[",
"i",
"]",
".",
"safeBags",
".",
"length",
";",
"j",
"++",
")",
"{",
"var",
"bag",
"=",
"safeContents",
"[",
"i",
"]",
".",
"safeBags",
"[",
"j",
"]",
";",
"if",
"(",
"bagType",
"!==",
"undefined",
"&&",
"bag",
".",
"type",
"!==",
"bagType",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"attrName",
"===",
"null",
")",
"{",
"result",
".",
"push",
"(",
"bag",
")",
";",
"continue",
";",
"}",
"if",
"(",
"bag",
".",
"attributes",
"[",
"attrName",
"]",
"!==",
"undefined",
"&&",
"bag",
".",
"attributes",
"[",
"attrName",
"]",
".",
"indexOf",
"(",
"attrValue",
")",
">=",
"0",
")",
"{",
"result",
".",
"push",
"(",
"bag",
")",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
]
| Search SafeContents structure for bags with matching attributes.
The search can optionally be narrowed by a certain bag type.
@param safeContents the SafeContents structure to search in.
@param attrName the name of the attribute to compare against.
@param attrValue the attribute value to search for.
@param [bagType] bag type to narrow search by.
@return an array of matching bags. | [
"Search",
"SafeContents",
"structure",
"for",
"bags",
"with",
"matching",
"attributes",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L20671-L20693 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | function(c, record, s) {
var rval = false;
try {
var bytes = c.inflate(record.fragment.getBytes());
record.fragment = forge.util.createBuffer(bytes);
record.length = bytes.length;
rval = true;
} catch(ex) {
// inflate error, fail out
}
return rval;
} | javascript | function(c, record, s) {
var rval = false;
try {
var bytes = c.inflate(record.fragment.getBytes());
record.fragment = forge.util.createBuffer(bytes);
record.length = bytes.length;
rval = true;
} catch(ex) {
// inflate error, fail out
}
return rval;
} | [
"function",
"(",
"c",
",",
"record",
",",
"s",
")",
"{",
"var",
"rval",
"=",
"false",
";",
"try",
"{",
"var",
"bytes",
"=",
"c",
".",
"inflate",
"(",
"record",
".",
"fragment",
".",
"getBytes",
"(",
")",
")",
";",
"record",
".",
"fragment",
"=",
"forge",
".",
"util",
".",
"createBuffer",
"(",
"bytes",
")",
";",
"record",
".",
"length",
"=",
"bytes",
".",
"length",
";",
"rval",
"=",
"true",
";",
"}",
"catch",
"(",
"ex",
")",
"{",
"}",
"return",
"rval",
";",
"}"
]
| Decompresses the TLSCompressed record into a TLSPlaintext record using the
deflate algorithm.
@param c the TLS connection.
@param record the TLSCompressed record to decompress.
@param s the ConnectionState to use.
@return true on success, false on failure. | [
"Decompresses",
"the",
"TLSCompressed",
"record",
"into",
"a",
"TLSPlaintext",
"record",
"using",
"the",
"deflate",
"algorithm",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L22117-L22130 | train |
|
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | function(b, lenBytes) {
var len = 0;
switch(lenBytes) {
case 1:
len = b.getByte();
break;
case 2:
len = b.getInt16();
break;
case 3:
len = b.getInt24();
break;
case 4:
len = b.getInt32();
break;
}
// read vector bytes into a new buffer
return forge.util.createBuffer(b.getBytes(len));
} | javascript | function(b, lenBytes) {
var len = 0;
switch(lenBytes) {
case 1:
len = b.getByte();
break;
case 2:
len = b.getInt16();
break;
case 3:
len = b.getInt24();
break;
case 4:
len = b.getInt32();
break;
}
// read vector bytes into a new buffer
return forge.util.createBuffer(b.getBytes(len));
} | [
"function",
"(",
"b",
",",
"lenBytes",
")",
"{",
"var",
"len",
"=",
"0",
";",
"switch",
"(",
"lenBytes",
")",
"{",
"case",
"1",
":",
"len",
"=",
"b",
".",
"getByte",
"(",
")",
";",
"break",
";",
"case",
"2",
":",
"len",
"=",
"b",
".",
"getInt16",
"(",
")",
";",
"break",
";",
"case",
"3",
":",
"len",
"=",
"b",
".",
"getInt24",
"(",
")",
";",
"break",
";",
"case",
"4",
":",
"len",
"=",
"b",
".",
"getInt32",
"(",
")",
";",
"break",
";",
"}",
"return",
"forge",
".",
"util",
".",
"createBuffer",
"(",
"b",
".",
"getBytes",
"(",
"len",
")",
")",
";",
"}"
]
| Reads a TLS variable-length vector from a byte buffer.
Variable-length vectors are defined by specifying a subrange of legal
lengths, inclusively, using the notation <floor..ceiling>. When these are
encoded, the actual length precedes the vector's contents in the byte
stream. The length will be in the form of a number consuming as many bytes
as required to hold the vector's specified maximum (ceiling) length. A
variable-length vector with an actual length field of zero is referred to
as an empty vector.
@param b the byte buffer.
@param lenBytes the number of bytes required to store the length.
@return the resulting byte buffer. | [
"Reads",
"a",
"TLS",
"variable",
"-",
"length",
"vector",
"from",
"a",
"byte",
"buffer",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L22148-L22167 | train |
|
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | function(b, lenBytes, v) {
// encode length at the start of the vector, where the number of bytes for
// the length is the maximum number of bytes it would take to encode the
// vector's ceiling
b.putInt(v.length(), lenBytes << 3);
b.putBuffer(v);
} | javascript | function(b, lenBytes, v) {
// encode length at the start of the vector, where the number of bytes for
// the length is the maximum number of bytes it would take to encode the
// vector's ceiling
b.putInt(v.length(), lenBytes << 3);
b.putBuffer(v);
} | [
"function",
"(",
"b",
",",
"lenBytes",
",",
"v",
")",
"{",
"b",
".",
"putInt",
"(",
"v",
".",
"length",
"(",
")",
",",
"lenBytes",
"<<",
"3",
")",
";",
"b",
".",
"putBuffer",
"(",
"v",
")",
";",
"}"
]
| Writes a TLS variable-length vector to a byte buffer.
@param b the byte buffer.
@param lenBytes the number of bytes required to store the length.
@param v the byte buffer vector. | [
"Writes",
"a",
"TLS",
"variable",
"-",
"length",
"vector",
"to",
"a",
"byte",
"buffer",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L22176-L22182 | train |
|
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | function(desc) {
switch(desc) {
case true:
return true;
case tls.Alert.Description.bad_certificate:
return forge.pki.certificateError.bad_certificate;
case tls.Alert.Description.unsupported_certificate:
return forge.pki.certificateError.unsupported_certificate;
case tls.Alert.Description.certificate_revoked:
return forge.pki.certificateError.certificate_revoked;
case tls.Alert.Description.certificate_expired:
return forge.pki.certificateError.certificate_expired;
case tls.Alert.Description.certificate_unknown:
return forge.pki.certificateError.certificate_unknown;
case tls.Alert.Description.unknown_ca:
return forge.pki.certificateError.unknown_ca;
default:
return forge.pki.certificateError.bad_certificate;
}
} | javascript | function(desc) {
switch(desc) {
case true:
return true;
case tls.Alert.Description.bad_certificate:
return forge.pki.certificateError.bad_certificate;
case tls.Alert.Description.unsupported_certificate:
return forge.pki.certificateError.unsupported_certificate;
case tls.Alert.Description.certificate_revoked:
return forge.pki.certificateError.certificate_revoked;
case tls.Alert.Description.certificate_expired:
return forge.pki.certificateError.certificate_expired;
case tls.Alert.Description.certificate_unknown:
return forge.pki.certificateError.certificate_unknown;
case tls.Alert.Description.unknown_ca:
return forge.pki.certificateError.unknown_ca;
default:
return forge.pki.certificateError.bad_certificate;
}
} | [
"function",
"(",
"desc",
")",
"{",
"switch",
"(",
"desc",
")",
"{",
"case",
"true",
":",
"return",
"true",
";",
"case",
"tls",
".",
"Alert",
".",
"Description",
".",
"bad_certificate",
":",
"return",
"forge",
".",
"pki",
".",
"certificateError",
".",
"bad_certificate",
";",
"case",
"tls",
".",
"Alert",
".",
"Description",
".",
"unsupported_certificate",
":",
"return",
"forge",
".",
"pki",
".",
"certificateError",
".",
"unsupported_certificate",
";",
"case",
"tls",
".",
"Alert",
".",
"Description",
".",
"certificate_revoked",
":",
"return",
"forge",
".",
"pki",
".",
"certificateError",
".",
"certificate_revoked",
";",
"case",
"tls",
".",
"Alert",
".",
"Description",
".",
"certificate_expired",
":",
"return",
"forge",
".",
"pki",
".",
"certificateError",
".",
"certificate_expired",
";",
"case",
"tls",
".",
"Alert",
".",
"Description",
".",
"certificate_unknown",
":",
"return",
"forge",
".",
"pki",
".",
"certificateError",
".",
"certificate_unknown",
";",
"case",
"tls",
".",
"Alert",
".",
"Description",
".",
"unknown_ca",
":",
"return",
"forge",
".",
"pki",
".",
"certificateError",
".",
"unknown_ca",
";",
"default",
":",
"return",
"forge",
".",
"pki",
".",
"certificateError",
".",
"bad_certificate",
";",
"}",
"}"
]
| Maps a tls.Alert.Description to a pki.certificateError.
@param desc the alert description.
@return the certificate error. | [
"Maps",
"a",
"tls",
".",
"Alert",
".",
"Description",
"to",
"a",
"pki",
".",
"certificateError",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L25174-L25193 | train |
|
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | function(c, record) {
// get record handler (align type in table by subtracting lowest)
var aligned = record.type - tls.ContentType.change_cipher_spec;
var handlers = ctTable[c.entity][c.expect];
if(aligned in handlers) {
handlers[aligned](c, record);
} else {
// unexpected record
tls.handleUnexpected(c, record);
}
} | javascript | function(c, record) {
// get record handler (align type in table by subtracting lowest)
var aligned = record.type - tls.ContentType.change_cipher_spec;
var handlers = ctTable[c.entity][c.expect];
if(aligned in handlers) {
handlers[aligned](c, record);
} else {
// unexpected record
tls.handleUnexpected(c, record);
}
} | [
"function",
"(",
"c",
",",
"record",
")",
"{",
"var",
"aligned",
"=",
"record",
".",
"type",
"-",
"tls",
".",
"ContentType",
".",
"change_cipher_spec",
";",
"var",
"handlers",
"=",
"ctTable",
"[",
"c",
".",
"entity",
"]",
"[",
"c",
".",
"expect",
"]",
";",
"if",
"(",
"aligned",
"in",
"handlers",
")",
"{",
"handlers",
"[",
"aligned",
"]",
"(",
"c",
",",
"record",
")",
";",
"}",
"else",
"{",
"tls",
".",
"handleUnexpected",
"(",
"c",
",",
"record",
")",
";",
"}",
"}"
]
| Updates the current TLS engine state based on the given record.
@param c the TLS connection.
@param record the TLS record to act on. | [
"Updates",
"the",
"current",
"TLS",
"engine",
"state",
"based",
"on",
"the",
"given",
"record",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L25474-L25484 | train |
|
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | function(c) {
var rval = 0;
// get input buffer and its length
var b = c.input;
var len = b.length();
// need at least 5 bytes to initialize a record
if(len < 5) {
rval = 5 - len;
} else {
// enough bytes for header
// initialize record
c.record = {
type: b.getByte(),
version: {
major: b.getByte(),
minor: b.getByte()
},
length: b.getInt16(),
fragment: forge.util.createBuffer(),
ready: false
};
// check record version
var compatibleVersion = (c.record.version.major === c.version.major);
if(compatibleVersion && c.session && c.session.version) {
// session version already set, require same minor version
compatibleVersion = (c.record.version.minor === c.version.minor);
}
if(!compatibleVersion) {
c.error(c, {
message: 'Incompatible TLS version.',
send: true,
alert: {
level: tls.Alert.Level.fatal,
description: tls.Alert.Description.protocol_version
}
});
}
}
return rval;
} | javascript | function(c) {
var rval = 0;
// get input buffer and its length
var b = c.input;
var len = b.length();
// need at least 5 bytes to initialize a record
if(len < 5) {
rval = 5 - len;
} else {
// enough bytes for header
// initialize record
c.record = {
type: b.getByte(),
version: {
major: b.getByte(),
minor: b.getByte()
},
length: b.getInt16(),
fragment: forge.util.createBuffer(),
ready: false
};
// check record version
var compatibleVersion = (c.record.version.major === c.version.major);
if(compatibleVersion && c.session && c.session.version) {
// session version already set, require same minor version
compatibleVersion = (c.record.version.minor === c.version.minor);
}
if(!compatibleVersion) {
c.error(c, {
message: 'Incompatible TLS version.',
send: true,
alert: {
level: tls.Alert.Level.fatal,
description: tls.Alert.Description.protocol_version
}
});
}
}
return rval;
} | [
"function",
"(",
"c",
")",
"{",
"var",
"rval",
"=",
"0",
";",
"var",
"b",
"=",
"c",
".",
"input",
";",
"var",
"len",
"=",
"b",
".",
"length",
"(",
")",
";",
"if",
"(",
"len",
"<",
"5",
")",
"{",
"rval",
"=",
"5",
"-",
"len",
";",
"}",
"else",
"{",
"c",
".",
"record",
"=",
"{",
"type",
":",
"b",
".",
"getByte",
"(",
")",
",",
"version",
":",
"{",
"major",
":",
"b",
".",
"getByte",
"(",
")",
",",
"minor",
":",
"b",
".",
"getByte",
"(",
")",
"}",
",",
"length",
":",
"b",
".",
"getInt16",
"(",
")",
",",
"fragment",
":",
"forge",
".",
"util",
".",
"createBuffer",
"(",
")",
",",
"ready",
":",
"false",
"}",
";",
"var",
"compatibleVersion",
"=",
"(",
"c",
".",
"record",
".",
"version",
".",
"major",
"===",
"c",
".",
"version",
".",
"major",
")",
";",
"if",
"(",
"compatibleVersion",
"&&",
"c",
".",
"session",
"&&",
"c",
".",
"session",
".",
"version",
")",
"{",
"compatibleVersion",
"=",
"(",
"c",
".",
"record",
".",
"version",
".",
"minor",
"===",
"c",
".",
"version",
".",
"minor",
")",
";",
"}",
"if",
"(",
"!",
"compatibleVersion",
")",
"{",
"c",
".",
"error",
"(",
"c",
",",
"{",
"message",
":",
"'Incompatible TLS version.'",
",",
"send",
":",
"true",
",",
"alert",
":",
"{",
"level",
":",
"tls",
".",
"Alert",
".",
"Level",
".",
"fatal",
",",
"description",
":",
"tls",
".",
"Alert",
".",
"Description",
".",
"protocol_version",
"}",
"}",
")",
";",
"}",
"}",
"return",
"rval",
";",
"}"
]
| Reads the record header and initializes the next record on the given
connection.
@param c the TLS connection with the next record.
@return 0 if the input data could be processed, otherwise the
number of bytes required for data to be processed. | [
"Reads",
"the",
"record",
"header",
"and",
"initializes",
"the",
"next",
"record",
"on",
"the",
"given",
"connection",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L25495-L25538 | train |
|
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | function(c) {
var rval = 0;
// ensure there is enough input data to get the entire record
var b = c.input;
var len = b.length();
if(len < c.record.length) {
// not enough data yet, return how much is required
rval = c.record.length - len;
} else {
// there is enough data to parse the pending record
// fill record fragment and compact input buffer
c.record.fragment.putBytes(b.getBytes(c.record.length));
b.compact();
// update record using current read state
var s = c.state.current.read;
if(s.update(c, c.record)) {
// see if there is a previously fragmented message that the
// new record's message fragment should be appended to
if(c.fragmented !== null) {
// if the record type matches a previously fragmented
// record, append the record fragment to it
if(c.fragmented.type === c.record.type) {
// concatenate record fragments
c.fragmented.fragment.putBuffer(c.record.fragment);
c.record = c.fragmented;
} else {
// error, invalid fragmented record
c.error(c, {
message: 'Invalid fragmented record.',
send: true,
alert: {
level: tls.Alert.Level.fatal,
description:
tls.Alert.Description.unexpected_message
}
});
}
}
// record is now ready
c.record.ready = true;
}
}
return rval;
} | javascript | function(c) {
var rval = 0;
// ensure there is enough input data to get the entire record
var b = c.input;
var len = b.length();
if(len < c.record.length) {
// not enough data yet, return how much is required
rval = c.record.length - len;
} else {
// there is enough data to parse the pending record
// fill record fragment and compact input buffer
c.record.fragment.putBytes(b.getBytes(c.record.length));
b.compact();
// update record using current read state
var s = c.state.current.read;
if(s.update(c, c.record)) {
// see if there is a previously fragmented message that the
// new record's message fragment should be appended to
if(c.fragmented !== null) {
// if the record type matches a previously fragmented
// record, append the record fragment to it
if(c.fragmented.type === c.record.type) {
// concatenate record fragments
c.fragmented.fragment.putBuffer(c.record.fragment);
c.record = c.fragmented;
} else {
// error, invalid fragmented record
c.error(c, {
message: 'Invalid fragmented record.',
send: true,
alert: {
level: tls.Alert.Level.fatal,
description:
tls.Alert.Description.unexpected_message
}
});
}
}
// record is now ready
c.record.ready = true;
}
}
return rval;
} | [
"function",
"(",
"c",
")",
"{",
"var",
"rval",
"=",
"0",
";",
"var",
"b",
"=",
"c",
".",
"input",
";",
"var",
"len",
"=",
"b",
".",
"length",
"(",
")",
";",
"if",
"(",
"len",
"<",
"c",
".",
"record",
".",
"length",
")",
"{",
"rval",
"=",
"c",
".",
"record",
".",
"length",
"-",
"len",
";",
"}",
"else",
"{",
"c",
".",
"record",
".",
"fragment",
".",
"putBytes",
"(",
"b",
".",
"getBytes",
"(",
"c",
".",
"record",
".",
"length",
")",
")",
";",
"b",
".",
"compact",
"(",
")",
";",
"var",
"s",
"=",
"c",
".",
"state",
".",
"current",
".",
"read",
";",
"if",
"(",
"s",
".",
"update",
"(",
"c",
",",
"c",
".",
"record",
")",
")",
"{",
"if",
"(",
"c",
".",
"fragmented",
"!==",
"null",
")",
"{",
"if",
"(",
"c",
".",
"fragmented",
".",
"type",
"===",
"c",
".",
"record",
".",
"type",
")",
"{",
"c",
".",
"fragmented",
".",
"fragment",
".",
"putBuffer",
"(",
"c",
".",
"record",
".",
"fragment",
")",
";",
"c",
".",
"record",
"=",
"c",
".",
"fragmented",
";",
"}",
"else",
"{",
"c",
".",
"error",
"(",
"c",
",",
"{",
"message",
":",
"'Invalid fragmented record.'",
",",
"send",
":",
"true",
",",
"alert",
":",
"{",
"level",
":",
"tls",
".",
"Alert",
".",
"Level",
".",
"fatal",
",",
"description",
":",
"tls",
".",
"Alert",
".",
"Description",
".",
"unexpected_message",
"}",
"}",
")",
";",
"}",
"}",
"c",
".",
"record",
".",
"ready",
"=",
"true",
";",
"}",
"}",
"return",
"rval",
";",
"}"
]
| Reads the next record's contents and appends its message to any
previously fragmented message.
@param c the TLS connection with the next record.
@return 0 if the input data could be processed, otherwise the
number of bytes required for data to be processed. | [
"Reads",
"the",
"next",
"record",
"s",
"contents",
"and",
"appends",
"its",
"message",
"to",
"any",
"previously",
"fragmented",
"message",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L25549-L25596 | train |
|
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | encrypt_aes_cbc_sha1_padding | function encrypt_aes_cbc_sha1_padding(blockSize, input, decrypt) {
/* The encrypted data length (TLSCiphertext.length) is one more than the sum
of SecurityParameters.block_length, TLSCompressed.length,
SecurityParameters.mac_length, and padding_length.
The padding may be any length up to 255 bytes long, as long as it results in
the TLSCiphertext.length being an integral multiple of the block length.
Lengths longer than necessary might be desirable to frustrate attacks on a
protocol based on analysis of the lengths of exchanged messages. Each uint8
in the padding data vector must be filled with the padding length value.
The padding length should be such that the total size of the
GenericBlockCipher structure is a multiple of the cipher's block length.
Legal values range from zero to 255, inclusive. This length specifies the
length of the padding field exclusive of the padding_length field itself.
This is slightly different from PKCS#7 because the padding value is 1
less than the actual number of padding bytes if you include the
padding_length uint8 itself as a padding byte. */
if(!decrypt) {
// get the number of padding bytes required to reach the blockSize and
// subtract 1 for the padding value (to make room for the padding_length
// uint8)
var padding = blockSize - (input.length() % blockSize);
input.fillWithByte(padding - 1, padding);
}
return true;
} | javascript | function encrypt_aes_cbc_sha1_padding(blockSize, input, decrypt) {
/* The encrypted data length (TLSCiphertext.length) is one more than the sum
of SecurityParameters.block_length, TLSCompressed.length,
SecurityParameters.mac_length, and padding_length.
The padding may be any length up to 255 bytes long, as long as it results in
the TLSCiphertext.length being an integral multiple of the block length.
Lengths longer than necessary might be desirable to frustrate attacks on a
protocol based on analysis of the lengths of exchanged messages. Each uint8
in the padding data vector must be filled with the padding length value.
The padding length should be such that the total size of the
GenericBlockCipher structure is a multiple of the cipher's block length.
Legal values range from zero to 255, inclusive. This length specifies the
length of the padding field exclusive of the padding_length field itself.
This is slightly different from PKCS#7 because the padding value is 1
less than the actual number of padding bytes if you include the
padding_length uint8 itself as a padding byte. */
if(!decrypt) {
// get the number of padding bytes required to reach the blockSize and
// subtract 1 for the padding value (to make room for the padding_length
// uint8)
var padding = blockSize - (input.length() % blockSize);
input.fillWithByte(padding - 1, padding);
}
return true;
} | [
"function",
"encrypt_aes_cbc_sha1_padding",
"(",
"blockSize",
",",
"input",
",",
"decrypt",
")",
"{",
"if",
"(",
"!",
"decrypt",
")",
"{",
"var",
"padding",
"=",
"blockSize",
"-",
"(",
"input",
".",
"length",
"(",
")",
"%",
"blockSize",
")",
";",
"input",
".",
"fillWithByte",
"(",
"padding",
"-",
"1",
",",
"padding",
")",
";",
"}",
"return",
"true",
";",
"}"
]
| Handles padding for aes_cbc_sha1 in encrypt mode.
@param blockSize the block size.
@param input the input buffer.
@param decrypt true in decrypt mode, false in encrypt mode.
@return true on success, false on failure. | [
"Handles",
"padding",
"for",
"aes_cbc_sha1",
"in",
"encrypt",
"mode",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L26143-L26170 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | compareMacs | function compareMacs(key, mac1, mac2) {
var hmac = forge.hmac.create();
hmac.start('SHA1', key);
hmac.update(mac1);
mac1 = hmac.digest().getBytes();
hmac.start(null, null);
hmac.update(mac2);
mac2 = hmac.digest().getBytes();
return mac1 === mac2;
} | javascript | function compareMacs(key, mac1, mac2) {
var hmac = forge.hmac.create();
hmac.start('SHA1', key);
hmac.update(mac1);
mac1 = hmac.digest().getBytes();
hmac.start(null, null);
hmac.update(mac2);
mac2 = hmac.digest().getBytes();
return mac1 === mac2;
} | [
"function",
"compareMacs",
"(",
"key",
",",
"mac1",
",",
"mac2",
")",
"{",
"var",
"hmac",
"=",
"forge",
".",
"hmac",
".",
"create",
"(",
")",
";",
"hmac",
".",
"start",
"(",
"'SHA1'",
",",
"key",
")",
";",
"hmac",
".",
"update",
"(",
"mac1",
")",
";",
"mac1",
"=",
"hmac",
".",
"digest",
"(",
")",
".",
"getBytes",
"(",
")",
";",
"hmac",
".",
"start",
"(",
"null",
",",
"null",
")",
";",
"hmac",
".",
"update",
"(",
"mac2",
")",
";",
"mac2",
"=",
"hmac",
".",
"digest",
"(",
")",
".",
"getBytes",
"(",
")",
";",
"return",
"mac1",
"===",
"mac2",
";",
"}"
]
| Safely compare two MACs. This function will compare two MACs in a way
that protects against timing attacks.
TODO: Expose elsewhere as a utility API.
See: https://www.nccgroup.trust/us/about-us/newsroom-and-events/blog/2011/february/double-hmac-verification/
@param key the MAC key to use.
@param mac1 as a binary-encoded string of bytes.
@param mac2 as a binary-encoded string of bytes.
@return true if the MACs are the same, false if not. | [
"Safely",
"compare",
"two",
"MACs",
".",
"This",
"function",
"will",
"compare",
"two",
"MACs",
"in",
"a",
"way",
"that",
"protects",
"against",
"timing",
"attacks",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L26281-L26293 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | _createKDF | function _createKDF(kdf, md, counterStart, digestLength) {
/**
* Generate a key of the specified length.
*
* @param x the binary-encoded byte string to generate a key from.
* @param length the number of bytes to generate (the size of the key).
*
* @return the key as a binary-encoded string.
*/
kdf.generate = function(x, length) {
var key = new forge.util.ByteBuffer();
// run counter from counterStart to ceil(length / Hash.len)
var k = Math.ceil(length / digestLength) + counterStart;
var c = new forge.util.ByteBuffer();
for(var i = counterStart; i < k; ++i) {
// I2OSP(i, 4): convert counter to an octet string of 4 octets
c.putInt32(i);
// digest 'x' and the counter and add the result to the key
md.start();
md.update(x + c.getBytes());
var hash = md.digest();
key.putBytes(hash.getBytes(digestLength));
}
// truncate to the correct key length
key.truncate(key.length() - length);
return key.getBytes();
};
} | javascript | function _createKDF(kdf, md, counterStart, digestLength) {
/**
* Generate a key of the specified length.
*
* @param x the binary-encoded byte string to generate a key from.
* @param length the number of bytes to generate (the size of the key).
*
* @return the key as a binary-encoded string.
*/
kdf.generate = function(x, length) {
var key = new forge.util.ByteBuffer();
// run counter from counterStart to ceil(length / Hash.len)
var k = Math.ceil(length / digestLength) + counterStart;
var c = new forge.util.ByteBuffer();
for(var i = counterStart; i < k; ++i) {
// I2OSP(i, 4): convert counter to an octet string of 4 octets
c.putInt32(i);
// digest 'x' and the counter and add the result to the key
md.start();
md.update(x + c.getBytes());
var hash = md.digest();
key.putBytes(hash.getBytes(digestLength));
}
// truncate to the correct key length
key.truncate(key.length() - length);
return key.getBytes();
};
} | [
"function",
"_createKDF",
"(",
"kdf",
",",
"md",
",",
"counterStart",
",",
"digestLength",
")",
"{",
"kdf",
".",
"generate",
"=",
"function",
"(",
"x",
",",
"length",
")",
"{",
"var",
"key",
"=",
"new",
"forge",
".",
"util",
".",
"ByteBuffer",
"(",
")",
";",
"var",
"k",
"=",
"Math",
".",
"ceil",
"(",
"length",
"/",
"digestLength",
")",
"+",
"counterStart",
";",
"var",
"c",
"=",
"new",
"forge",
".",
"util",
".",
"ByteBuffer",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"counterStart",
";",
"i",
"<",
"k",
";",
"++",
"i",
")",
"{",
"c",
".",
"putInt32",
"(",
"i",
")",
";",
"md",
".",
"start",
"(",
")",
";",
"md",
".",
"update",
"(",
"x",
"+",
"c",
".",
"getBytes",
"(",
")",
")",
";",
"var",
"hash",
"=",
"md",
".",
"digest",
"(",
")",
";",
"key",
".",
"putBytes",
"(",
"hash",
".",
"getBytes",
"(",
"digestLength",
")",
")",
";",
"}",
"key",
".",
"truncate",
"(",
"key",
".",
"length",
"(",
")",
"-",
"length",
")",
";",
"return",
"key",
".",
"getBytes",
"(",
")",
";",
"}",
";",
"}"
]
| Creates a KDF1 or KDF2 API object.
@param md the hash API to use.
@param counterStart the starting index for the counter.
@param digestLength the digest length to use.
@return the KDF API object. | [
"Creates",
"a",
"KDF1",
"or",
"KDF2",
"API",
"object",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L26619-L26650 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | function(logger, message) {
forge.log.prepareStandardFull(message);
console.log(message.standardFull);
} | javascript | function(logger, message) {
forge.log.prepareStandardFull(message);
console.log(message.standardFull);
} | [
"function",
"(",
"logger",
",",
"message",
")",
"{",
"forge",
".",
"log",
".",
"prepareStandardFull",
"(",
"message",
")",
";",
"console",
".",
"log",
"(",
"message",
".",
"standardFull",
")",
";",
"}"
]
| only appear to have basic console.log | [
"only",
"appear",
"to",
"have",
"basic",
"console",
".",
"log"
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L26977-L26980 | train |
|
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | function(cert) {
// convert from PEM
if(typeof cert === 'string') {
cert = forge.pki.certificateFromPem(cert);
}
msg.certificates.push(cert);
} | javascript | function(cert) {
// convert from PEM
if(typeof cert === 'string') {
cert = forge.pki.certificateFromPem(cert);
}
msg.certificates.push(cert);
} | [
"function",
"(",
"cert",
")",
"{",
"if",
"(",
"typeof",
"cert",
"===",
"'string'",
")",
"{",
"cert",
"=",
"forge",
".",
"pki",
".",
"certificateFromPem",
"(",
"cert",
")",
";",
"}",
"msg",
".",
"certificates",
".",
"push",
"(",
"cert",
")",
";",
"}"
]
| Add a certificate.
@param cert the certificate to add. | [
"Add",
"a",
"certificate",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L27452-L27458 | train |
|
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | function(cert) {
var sAttr = cert.issuer.attributes;
for(var i = 0; i < msg.recipients.length; ++i) {
var r = msg.recipients[i];
var rAttr = r.issuer;
if(r.serialNumber !== cert.serialNumber) {
continue;
}
if(rAttr.length !== sAttr.length) {
continue;
}
var match = true;
for(var j = 0; j < sAttr.length; ++j) {
if(rAttr[j].type !== sAttr[j].type ||
rAttr[j].value !== sAttr[j].value) {
match = false;
break;
}
}
if(match) {
return r;
}
}
return null;
} | javascript | function(cert) {
var sAttr = cert.issuer.attributes;
for(var i = 0; i < msg.recipients.length; ++i) {
var r = msg.recipients[i];
var rAttr = r.issuer;
if(r.serialNumber !== cert.serialNumber) {
continue;
}
if(rAttr.length !== sAttr.length) {
continue;
}
var match = true;
for(var j = 0; j < sAttr.length; ++j) {
if(rAttr[j].type !== sAttr[j].type ||
rAttr[j].value !== sAttr[j].value) {
match = false;
break;
}
}
if(match) {
return r;
}
}
return null;
} | [
"function",
"(",
"cert",
")",
"{",
"var",
"sAttr",
"=",
"cert",
".",
"issuer",
".",
"attributes",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"msg",
".",
"recipients",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"r",
"=",
"msg",
".",
"recipients",
"[",
"i",
"]",
";",
"var",
"rAttr",
"=",
"r",
".",
"issuer",
";",
"if",
"(",
"r",
".",
"serialNumber",
"!==",
"cert",
".",
"serialNumber",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"rAttr",
".",
"length",
"!==",
"sAttr",
".",
"length",
")",
"{",
"continue",
";",
"}",
"var",
"match",
"=",
"true",
";",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"sAttr",
".",
"length",
";",
"++",
"j",
")",
"{",
"if",
"(",
"rAttr",
"[",
"j",
"]",
".",
"type",
"!==",
"sAttr",
"[",
"j",
"]",
".",
"type",
"||",
"rAttr",
"[",
"j",
"]",
".",
"value",
"!==",
"sAttr",
"[",
"j",
"]",
".",
"value",
")",
"{",
"match",
"=",
"false",
";",
"break",
";",
"}",
"}",
"if",
"(",
"match",
")",
"{",
"return",
"r",
";",
"}",
"}",
"return",
"null",
";",
"}"
]
| Find recipient by X.509 certificate's issuer.
@param cert the certificate with the issuer to look for.
@return the recipient object. | [
"Find",
"recipient",
"by",
"X",
".",
"509",
"certificate",
"s",
"issuer",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L27693-L27723 | train |
|
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | function(recipient, privKey) {
if(msg.encryptedContent.key === undefined && recipient !== undefined &&
privKey !== undefined) {
switch(recipient.encryptedContent.algorithm) {
case forge.pki.oids.rsaEncryption:
case forge.pki.oids.desCBC:
var key = privKey.decrypt(recipient.encryptedContent.content);
msg.encryptedContent.key = forge.util.createBuffer(key);
break;
default:
throw new Error('Unsupported asymmetric cipher, ' +
'OID ' + recipient.encryptedContent.algorithm);
}
}
_decryptContent(msg);
} | javascript | function(recipient, privKey) {
if(msg.encryptedContent.key === undefined && recipient !== undefined &&
privKey !== undefined) {
switch(recipient.encryptedContent.algorithm) {
case forge.pki.oids.rsaEncryption:
case forge.pki.oids.desCBC:
var key = privKey.decrypt(recipient.encryptedContent.content);
msg.encryptedContent.key = forge.util.createBuffer(key);
break;
default:
throw new Error('Unsupported asymmetric cipher, ' +
'OID ' + recipient.encryptedContent.algorithm);
}
}
_decryptContent(msg);
} | [
"function",
"(",
"recipient",
",",
"privKey",
")",
"{",
"if",
"(",
"msg",
".",
"encryptedContent",
".",
"key",
"===",
"undefined",
"&&",
"recipient",
"!==",
"undefined",
"&&",
"privKey",
"!==",
"undefined",
")",
"{",
"switch",
"(",
"recipient",
".",
"encryptedContent",
".",
"algorithm",
")",
"{",
"case",
"forge",
".",
"pki",
".",
"oids",
".",
"rsaEncryption",
":",
"case",
"forge",
".",
"pki",
".",
"oids",
".",
"desCBC",
":",
"var",
"key",
"=",
"privKey",
".",
"decrypt",
"(",
"recipient",
".",
"encryptedContent",
".",
"content",
")",
";",
"msg",
".",
"encryptedContent",
".",
"key",
"=",
"forge",
".",
"util",
".",
"createBuffer",
"(",
"key",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Error",
"(",
"'Unsupported asymmetric cipher, '",
"+",
"'OID '",
"+",
"recipient",
".",
"encryptedContent",
".",
"algorithm",
")",
";",
"}",
"}",
"_decryptContent",
"(",
"msg",
")",
";",
"}"
]
| Decrypt enveloped content
@param recipient The recipient object related to the private key
@param privKey The (RSA) private key object | [
"Decrypt",
"enveloped",
"content"
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L27731-L27748 | train |
|
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | function(key, cipher) {
// Part 1: Symmetric encryption
if(msg.encryptedContent.content === undefined) {
cipher = cipher || msg.encryptedContent.algorithm;
key = key || msg.encryptedContent.key;
var keyLen, ivLen, ciphFn;
switch(cipher) {
case forge.pki.oids['aes128-CBC']:
keyLen = 16;
ivLen = 16;
ciphFn = forge.aes.createEncryptionCipher;
break;
case forge.pki.oids['aes192-CBC']:
keyLen = 24;
ivLen = 16;
ciphFn = forge.aes.createEncryptionCipher;
break;
case forge.pki.oids['aes256-CBC']:
keyLen = 32;
ivLen = 16;
ciphFn = forge.aes.createEncryptionCipher;
break;
case forge.pki.oids['des-EDE3-CBC']:
keyLen = 24;
ivLen = 8;
ciphFn = forge.des.createEncryptionCipher;
break;
default:
throw new Error('Unsupported symmetric cipher, OID ' + cipher);
}
if(key === undefined) {
key = forge.util.createBuffer(forge.random.getBytes(keyLen));
} else if(key.length() != keyLen) {
throw new Error('Symmetric key has wrong length; ' +
'got ' + key.length() + ' bytes, expected ' + keyLen + '.');
}
// Keep a copy of the key & IV in the object, so the caller can
// use it for whatever reason.
msg.encryptedContent.algorithm = cipher;
msg.encryptedContent.key = key;
msg.encryptedContent.parameter = forge.util.createBuffer(
forge.random.getBytes(ivLen));
var ciph = ciphFn(key);
ciph.start(msg.encryptedContent.parameter.copy());
ciph.update(msg.content);
// The finish function does PKCS#7 padding by default, therefore
// no action required by us.
if(!ciph.finish()) {
throw new Error('Symmetric encryption failed.');
}
msg.encryptedContent.content = ciph.output;
}
// Part 2: asymmetric encryption for each recipient
for(var i = 0; i < msg.recipients.length; ++i) {
var recipient = msg.recipients[i];
// Nothing to do, encryption already done.
if(recipient.encryptedContent.content !== undefined) {
continue;
}
switch(recipient.encryptedContent.algorithm) {
case forge.pki.oids.rsaEncryption:
recipient.encryptedContent.content =
recipient.encryptedContent.key.encrypt(
msg.encryptedContent.key.data);
break;
default:
throw new Error('Unsupported asymmetric cipher, OID ' +
recipient.encryptedContent.algorithm);
}
}
} | javascript | function(key, cipher) {
// Part 1: Symmetric encryption
if(msg.encryptedContent.content === undefined) {
cipher = cipher || msg.encryptedContent.algorithm;
key = key || msg.encryptedContent.key;
var keyLen, ivLen, ciphFn;
switch(cipher) {
case forge.pki.oids['aes128-CBC']:
keyLen = 16;
ivLen = 16;
ciphFn = forge.aes.createEncryptionCipher;
break;
case forge.pki.oids['aes192-CBC']:
keyLen = 24;
ivLen = 16;
ciphFn = forge.aes.createEncryptionCipher;
break;
case forge.pki.oids['aes256-CBC']:
keyLen = 32;
ivLen = 16;
ciphFn = forge.aes.createEncryptionCipher;
break;
case forge.pki.oids['des-EDE3-CBC']:
keyLen = 24;
ivLen = 8;
ciphFn = forge.des.createEncryptionCipher;
break;
default:
throw new Error('Unsupported symmetric cipher, OID ' + cipher);
}
if(key === undefined) {
key = forge.util.createBuffer(forge.random.getBytes(keyLen));
} else if(key.length() != keyLen) {
throw new Error('Symmetric key has wrong length; ' +
'got ' + key.length() + ' bytes, expected ' + keyLen + '.');
}
// Keep a copy of the key & IV in the object, so the caller can
// use it for whatever reason.
msg.encryptedContent.algorithm = cipher;
msg.encryptedContent.key = key;
msg.encryptedContent.parameter = forge.util.createBuffer(
forge.random.getBytes(ivLen));
var ciph = ciphFn(key);
ciph.start(msg.encryptedContent.parameter.copy());
ciph.update(msg.content);
// The finish function does PKCS#7 padding by default, therefore
// no action required by us.
if(!ciph.finish()) {
throw new Error('Symmetric encryption failed.');
}
msg.encryptedContent.content = ciph.output;
}
// Part 2: asymmetric encryption for each recipient
for(var i = 0; i < msg.recipients.length; ++i) {
var recipient = msg.recipients[i];
// Nothing to do, encryption already done.
if(recipient.encryptedContent.content !== undefined) {
continue;
}
switch(recipient.encryptedContent.algorithm) {
case forge.pki.oids.rsaEncryption:
recipient.encryptedContent.content =
recipient.encryptedContent.key.encrypt(
msg.encryptedContent.key.data);
break;
default:
throw new Error('Unsupported asymmetric cipher, OID ' +
recipient.encryptedContent.algorithm);
}
}
} | [
"function",
"(",
"key",
",",
"cipher",
")",
"{",
"if",
"(",
"msg",
".",
"encryptedContent",
".",
"content",
"===",
"undefined",
")",
"{",
"cipher",
"=",
"cipher",
"||",
"msg",
".",
"encryptedContent",
".",
"algorithm",
";",
"key",
"=",
"key",
"||",
"msg",
".",
"encryptedContent",
".",
"key",
";",
"var",
"keyLen",
",",
"ivLen",
",",
"ciphFn",
";",
"switch",
"(",
"cipher",
")",
"{",
"case",
"forge",
".",
"pki",
".",
"oids",
"[",
"'aes128-CBC'",
"]",
":",
"keyLen",
"=",
"16",
";",
"ivLen",
"=",
"16",
";",
"ciphFn",
"=",
"forge",
".",
"aes",
".",
"createEncryptionCipher",
";",
"break",
";",
"case",
"forge",
".",
"pki",
".",
"oids",
"[",
"'aes192-CBC'",
"]",
":",
"keyLen",
"=",
"24",
";",
"ivLen",
"=",
"16",
";",
"ciphFn",
"=",
"forge",
".",
"aes",
".",
"createEncryptionCipher",
";",
"break",
";",
"case",
"forge",
".",
"pki",
".",
"oids",
"[",
"'aes256-CBC'",
"]",
":",
"keyLen",
"=",
"32",
";",
"ivLen",
"=",
"16",
";",
"ciphFn",
"=",
"forge",
".",
"aes",
".",
"createEncryptionCipher",
";",
"break",
";",
"case",
"forge",
".",
"pki",
".",
"oids",
"[",
"'des-EDE3-CBC'",
"]",
":",
"keyLen",
"=",
"24",
";",
"ivLen",
"=",
"8",
";",
"ciphFn",
"=",
"forge",
".",
"des",
".",
"createEncryptionCipher",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Error",
"(",
"'Unsupported symmetric cipher, OID '",
"+",
"cipher",
")",
";",
"}",
"if",
"(",
"key",
"===",
"undefined",
")",
"{",
"key",
"=",
"forge",
".",
"util",
".",
"createBuffer",
"(",
"forge",
".",
"random",
".",
"getBytes",
"(",
"keyLen",
")",
")",
";",
"}",
"else",
"if",
"(",
"key",
".",
"length",
"(",
")",
"!=",
"keyLen",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Symmetric key has wrong length; '",
"+",
"'got '",
"+",
"key",
".",
"length",
"(",
")",
"+",
"' bytes, expected '",
"+",
"keyLen",
"+",
"'.'",
")",
";",
"}",
"msg",
".",
"encryptedContent",
".",
"algorithm",
"=",
"cipher",
";",
"msg",
".",
"encryptedContent",
".",
"key",
"=",
"key",
";",
"msg",
".",
"encryptedContent",
".",
"parameter",
"=",
"forge",
".",
"util",
".",
"createBuffer",
"(",
"forge",
".",
"random",
".",
"getBytes",
"(",
"ivLen",
")",
")",
";",
"var",
"ciph",
"=",
"ciphFn",
"(",
"key",
")",
";",
"ciph",
".",
"start",
"(",
"msg",
".",
"encryptedContent",
".",
"parameter",
".",
"copy",
"(",
")",
")",
";",
"ciph",
".",
"update",
"(",
"msg",
".",
"content",
")",
";",
"if",
"(",
"!",
"ciph",
".",
"finish",
"(",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Symmetric encryption failed.'",
")",
";",
"}",
"msg",
".",
"encryptedContent",
".",
"content",
"=",
"ciph",
".",
"output",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"msg",
".",
"recipients",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"recipient",
"=",
"msg",
".",
"recipients",
"[",
"i",
"]",
";",
"if",
"(",
"recipient",
".",
"encryptedContent",
".",
"content",
"!==",
"undefined",
")",
"{",
"continue",
";",
"}",
"switch",
"(",
"recipient",
".",
"encryptedContent",
".",
"algorithm",
")",
"{",
"case",
"forge",
".",
"pki",
".",
"oids",
".",
"rsaEncryption",
":",
"recipient",
".",
"encryptedContent",
".",
"content",
"=",
"recipient",
".",
"encryptedContent",
".",
"key",
".",
"encrypt",
"(",
"msg",
".",
"encryptedContent",
".",
"key",
".",
"data",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Error",
"(",
"'Unsupported asymmetric cipher, OID '",
"+",
"recipient",
".",
"encryptedContent",
".",
"algorithm",
")",
";",
"}",
"}",
"}"
]
| Encrypt enveloped content.
This function supports two optional arguments, cipher and key, which
can be used to influence symmetric encryption. Unless cipher is
provided, the cipher specified in encryptedContent.algorithm is used
(defaults to AES-256-CBC). If no key is provided, encryptedContent.key
is (re-)used. If that one's not set, a random key will be generated
automatically.
@param [key] The key to be used for symmetric encryption.
@param [cipher] The OID of the symmetric cipher to use. | [
"Encrypt",
"enveloped",
"content",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L27783-L27867 | train |
|
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | _recipientFromAsn1 | function _recipientFromAsn1(obj) {
// validate EnvelopedData content block and capture data
var capture = {};
var errors = [];
if(!asn1.validate(obj, p7.asn1.recipientInfoValidator, capture, errors)) {
var error = new Error('Cannot read PKCS#7 RecipientInfo. ' +
'ASN.1 object is not an PKCS#7 RecipientInfo.');
error.errors = errors;
throw error;
}
return {
version: capture.version.charCodeAt(0),
issuer: forge.pki.RDNAttributesAsArray(capture.issuer),
serialNumber: forge.util.createBuffer(capture.serial).toHex(),
encryptedContent: {
algorithm: asn1.derToOid(capture.encAlgorithm),
parameter: capture.encParameter.value,
content: capture.encKey
}
};
} | javascript | function _recipientFromAsn1(obj) {
// validate EnvelopedData content block and capture data
var capture = {};
var errors = [];
if(!asn1.validate(obj, p7.asn1.recipientInfoValidator, capture, errors)) {
var error = new Error('Cannot read PKCS#7 RecipientInfo. ' +
'ASN.1 object is not an PKCS#7 RecipientInfo.');
error.errors = errors;
throw error;
}
return {
version: capture.version.charCodeAt(0),
issuer: forge.pki.RDNAttributesAsArray(capture.issuer),
serialNumber: forge.util.createBuffer(capture.serial).toHex(),
encryptedContent: {
algorithm: asn1.derToOid(capture.encAlgorithm),
parameter: capture.encParameter.value,
content: capture.encKey
}
};
} | [
"function",
"_recipientFromAsn1",
"(",
"obj",
")",
"{",
"var",
"capture",
"=",
"{",
"}",
";",
"var",
"errors",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"asn1",
".",
"validate",
"(",
"obj",
",",
"p7",
".",
"asn1",
".",
"recipientInfoValidator",
",",
"capture",
",",
"errors",
")",
")",
"{",
"var",
"error",
"=",
"new",
"Error",
"(",
"'Cannot read PKCS#7 RecipientInfo. '",
"+",
"'ASN.1 object is not an PKCS#7 RecipientInfo.'",
")",
";",
"error",
".",
"errors",
"=",
"errors",
";",
"throw",
"error",
";",
"}",
"return",
"{",
"version",
":",
"capture",
".",
"version",
".",
"charCodeAt",
"(",
"0",
")",
",",
"issuer",
":",
"forge",
".",
"pki",
".",
"RDNAttributesAsArray",
"(",
"capture",
".",
"issuer",
")",
",",
"serialNumber",
":",
"forge",
".",
"util",
".",
"createBuffer",
"(",
"capture",
".",
"serial",
")",
".",
"toHex",
"(",
")",
",",
"encryptedContent",
":",
"{",
"algorithm",
":",
"asn1",
".",
"derToOid",
"(",
"capture",
".",
"encAlgorithm",
")",
",",
"parameter",
":",
"capture",
".",
"encParameter",
".",
"value",
",",
"content",
":",
"capture",
".",
"encKey",
"}",
"}",
";",
"}"
]
| Converts a single recipient from an ASN.1 object.
@param obj the ASN.1 RecipientInfo.
@return the recipient object. | [
"Converts",
"a",
"single",
"recipient",
"from",
"an",
"ASN",
".",
"1",
"object",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L27879-L27900 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | _recipientToAsn1 | function _recipientToAsn1(obj) {
return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// Version
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
asn1.integerToDer(obj.version).getBytes()),
// IssuerAndSerialNumber
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// Name
forge.pki.distinguishedNameToAsn1({attributes: obj.issuer}),
// Serial
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
forge.util.hexToBytes(obj.serialNumber))
]),
// KeyEncryptionAlgorithmIdentifier
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// Algorithm
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(obj.encryptedContent.algorithm).getBytes()),
// Parameter, force NULL, only RSA supported for now.
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
]),
// EncryptedKey
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
obj.encryptedContent.content)
]);
} | javascript | function _recipientToAsn1(obj) {
return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// Version
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
asn1.integerToDer(obj.version).getBytes()),
// IssuerAndSerialNumber
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// Name
forge.pki.distinguishedNameToAsn1({attributes: obj.issuer}),
// Serial
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
forge.util.hexToBytes(obj.serialNumber))
]),
// KeyEncryptionAlgorithmIdentifier
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// Algorithm
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(obj.encryptedContent.algorithm).getBytes()),
// Parameter, force NULL, only RSA supported for now.
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
]),
// EncryptedKey
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
obj.encryptedContent.content)
]);
} | [
"function",
"_recipientToAsn1",
"(",
"obj",
")",
"{",
"return",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SEQUENCE",
",",
"true",
",",
"[",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"INTEGER",
",",
"false",
",",
"asn1",
".",
"integerToDer",
"(",
"obj",
".",
"version",
")",
".",
"getBytes",
"(",
")",
")",
",",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SEQUENCE",
",",
"true",
",",
"[",
"forge",
".",
"pki",
".",
"distinguishedNameToAsn1",
"(",
"{",
"attributes",
":",
"obj",
".",
"issuer",
"}",
")",
",",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"INTEGER",
",",
"false",
",",
"forge",
".",
"util",
".",
"hexToBytes",
"(",
"obj",
".",
"serialNumber",
")",
")",
"]",
")",
",",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SEQUENCE",
",",
"true",
",",
"[",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OID",
",",
"false",
",",
"asn1",
".",
"oidToDer",
"(",
"obj",
".",
"encryptedContent",
".",
"algorithm",
")",
".",
"getBytes",
"(",
")",
")",
",",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"NULL",
",",
"false",
",",
"''",
")",
"]",
")",
",",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OCTETSTRING",
",",
"false",
",",
"obj",
".",
"encryptedContent",
".",
"content",
")",
"]",
")",
";",
"}"
]
| Converts a single recipient object to an ASN.1 object.
@param obj the recipient object.
@return the ASN.1 RecipientInfo. | [
"Converts",
"a",
"single",
"recipient",
"object",
"to",
"an",
"ASN",
".",
"1",
"object",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L27909-L27934 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | _recipientsFromAsn1 | function _recipientsFromAsn1(infos) {
var ret = [];
for(var i = 0; i < infos.length; ++i) {
ret.push(_recipientFromAsn1(infos[i]));
}
return ret;
} | javascript | function _recipientsFromAsn1(infos) {
var ret = [];
for(var i = 0; i < infos.length; ++i) {
ret.push(_recipientFromAsn1(infos[i]));
}
return ret;
} | [
"function",
"_recipientsFromAsn1",
"(",
"infos",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"infos",
".",
"length",
";",
"++",
"i",
")",
"{",
"ret",
".",
"push",
"(",
"_recipientFromAsn1",
"(",
"infos",
"[",
"i",
"]",
")",
")",
";",
"}",
"return",
"ret",
";",
"}"
]
| Map a set of RecipientInfo ASN.1 objects to recipient objects.
@param infos an array of ASN.1 representations RecipientInfo (i.e. SET OF).
@return an array of recipient objects. | [
"Map",
"a",
"set",
"of",
"RecipientInfo",
"ASN",
".",
"1",
"objects",
"to",
"recipient",
"objects",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L27943-L27949 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | _recipientsToAsn1 | function _recipientsToAsn1(recipients) {
var ret = [];
for(var i = 0; i < recipients.length; ++i) {
ret.push(_recipientToAsn1(recipients[i]));
}
return ret;
} | javascript | function _recipientsToAsn1(recipients) {
var ret = [];
for(var i = 0; i < recipients.length; ++i) {
ret.push(_recipientToAsn1(recipients[i]));
}
return ret;
} | [
"function",
"_recipientsToAsn1",
"(",
"recipients",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"recipients",
".",
"length",
";",
"++",
"i",
")",
"{",
"ret",
".",
"push",
"(",
"_recipientToAsn1",
"(",
"recipients",
"[",
"i",
"]",
")",
")",
";",
"}",
"return",
"ret",
";",
"}"
]
| Map an array of recipient objects to ASN.1 RecipientInfo objects.
@param recipients an array of recipientInfo objects.
@return an array of ASN.1 RecipientInfos. | [
"Map",
"an",
"array",
"of",
"recipient",
"objects",
"to",
"ASN",
".",
"1",
"RecipientInfo",
"objects",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L27958-L27964 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | _signerFromAsn1 | function _signerFromAsn1(obj) {
// validate EnvelopedData content block and capture data
var capture = {};
var errors = [];
if(!asn1.validate(obj, p7.asn1.signerInfoValidator, capture, errors)) {
var error = new Error('Cannot read PKCS#7 SignerInfo. ' +
'ASN.1 object is not an PKCS#7 SignerInfo.');
error.errors = errors;
throw error;
}
var rval = {
version: capture.version.charCodeAt(0),
issuer: forge.pki.RDNAttributesAsArray(capture.issuer),
serialNumber: forge.util.createBuffer(capture.serial).toHex(),
digestAlgorithm: asn1.derToOid(capture.digestAlgorithm),
signatureAlgorithm: asn1.derToOid(capture.signatureAlgorithm),
signature: capture.signature,
authenticatedAttributes: [],
unauthenticatedAttributes: []
};
// TODO: convert attributes
var authenticatedAttributes = capture.authenticatedAttributes || [];
var unauthenticatedAttributes = capture.unauthenticatedAttributes || [];
return rval;
} | javascript | function _signerFromAsn1(obj) {
// validate EnvelopedData content block and capture data
var capture = {};
var errors = [];
if(!asn1.validate(obj, p7.asn1.signerInfoValidator, capture, errors)) {
var error = new Error('Cannot read PKCS#7 SignerInfo. ' +
'ASN.1 object is not an PKCS#7 SignerInfo.');
error.errors = errors;
throw error;
}
var rval = {
version: capture.version.charCodeAt(0),
issuer: forge.pki.RDNAttributesAsArray(capture.issuer),
serialNumber: forge.util.createBuffer(capture.serial).toHex(),
digestAlgorithm: asn1.derToOid(capture.digestAlgorithm),
signatureAlgorithm: asn1.derToOid(capture.signatureAlgorithm),
signature: capture.signature,
authenticatedAttributes: [],
unauthenticatedAttributes: []
};
// TODO: convert attributes
var authenticatedAttributes = capture.authenticatedAttributes || [];
var unauthenticatedAttributes = capture.unauthenticatedAttributes || [];
return rval;
} | [
"function",
"_signerFromAsn1",
"(",
"obj",
")",
"{",
"var",
"capture",
"=",
"{",
"}",
";",
"var",
"errors",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"asn1",
".",
"validate",
"(",
"obj",
",",
"p7",
".",
"asn1",
".",
"signerInfoValidator",
",",
"capture",
",",
"errors",
")",
")",
"{",
"var",
"error",
"=",
"new",
"Error",
"(",
"'Cannot read PKCS#7 SignerInfo. '",
"+",
"'ASN.1 object is not an PKCS#7 SignerInfo.'",
")",
";",
"error",
".",
"errors",
"=",
"errors",
";",
"throw",
"error",
";",
"}",
"var",
"rval",
"=",
"{",
"version",
":",
"capture",
".",
"version",
".",
"charCodeAt",
"(",
"0",
")",
",",
"issuer",
":",
"forge",
".",
"pki",
".",
"RDNAttributesAsArray",
"(",
"capture",
".",
"issuer",
")",
",",
"serialNumber",
":",
"forge",
".",
"util",
".",
"createBuffer",
"(",
"capture",
".",
"serial",
")",
".",
"toHex",
"(",
")",
",",
"digestAlgorithm",
":",
"asn1",
".",
"derToOid",
"(",
"capture",
".",
"digestAlgorithm",
")",
",",
"signatureAlgorithm",
":",
"asn1",
".",
"derToOid",
"(",
"capture",
".",
"signatureAlgorithm",
")",
",",
"signature",
":",
"capture",
".",
"signature",
",",
"authenticatedAttributes",
":",
"[",
"]",
",",
"unauthenticatedAttributes",
":",
"[",
"]",
"}",
";",
"var",
"authenticatedAttributes",
"=",
"capture",
".",
"authenticatedAttributes",
"||",
"[",
"]",
";",
"var",
"unauthenticatedAttributes",
"=",
"capture",
".",
"unauthenticatedAttributes",
"||",
"[",
"]",
";",
"return",
"rval",
";",
"}"
]
| Converts a single signer from an ASN.1 object.
@param obj the ASN.1 representation of a SignerInfo.
@return the signer object. | [
"Converts",
"a",
"single",
"signer",
"from",
"an",
"ASN",
".",
"1",
"object",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L27973-L28000 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | _signerToAsn1 | function _signerToAsn1(obj) {
// SignerInfo
var rval = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// version
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
asn1.integerToDer(obj.version).getBytes()),
// issuerAndSerialNumber
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// name
forge.pki.distinguishedNameToAsn1({attributes: obj.issuer}),
// serial
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
forge.util.hexToBytes(obj.serialNumber))
]),
// digestAlgorithm
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// algorithm
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(obj.digestAlgorithm).getBytes()),
// parameters (null)
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
])
]);
// authenticatedAttributes (OPTIONAL)
if(obj.authenticatedAttributesAsn1) {
// add ASN.1 previously generated during signing
rval.value.push(obj.authenticatedAttributesAsn1);
}
// digestEncryptionAlgorithm
rval.value.push(asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// algorithm
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(obj.signatureAlgorithm).getBytes()),
// parameters (null)
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
]));
// encryptedDigest
rval.value.push(asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, obj.signature));
// unauthenticatedAttributes (OPTIONAL)
if(obj.unauthenticatedAttributes.length > 0) {
// [1] IMPLICIT
var attrsAsn1 = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, []);
for(var i = 0; i < obj.unauthenticatedAttributes.length; ++i) {
var attr = obj.unauthenticatedAttributes[i];
attrsAsn1.values.push(_attributeToAsn1(attr));
}
rval.value.push(attrsAsn1);
}
return rval;
} | javascript | function _signerToAsn1(obj) {
// SignerInfo
var rval = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// version
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
asn1.integerToDer(obj.version).getBytes()),
// issuerAndSerialNumber
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// name
forge.pki.distinguishedNameToAsn1({attributes: obj.issuer}),
// serial
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
forge.util.hexToBytes(obj.serialNumber))
]),
// digestAlgorithm
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// algorithm
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(obj.digestAlgorithm).getBytes()),
// parameters (null)
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
])
]);
// authenticatedAttributes (OPTIONAL)
if(obj.authenticatedAttributesAsn1) {
// add ASN.1 previously generated during signing
rval.value.push(obj.authenticatedAttributesAsn1);
}
// digestEncryptionAlgorithm
rval.value.push(asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// algorithm
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(obj.signatureAlgorithm).getBytes()),
// parameters (null)
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
]));
// encryptedDigest
rval.value.push(asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, obj.signature));
// unauthenticatedAttributes (OPTIONAL)
if(obj.unauthenticatedAttributes.length > 0) {
// [1] IMPLICIT
var attrsAsn1 = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, []);
for(var i = 0; i < obj.unauthenticatedAttributes.length; ++i) {
var attr = obj.unauthenticatedAttributes[i];
attrsAsn1.values.push(_attributeToAsn1(attr));
}
rval.value.push(attrsAsn1);
}
return rval;
} | [
"function",
"_signerToAsn1",
"(",
"obj",
")",
"{",
"var",
"rval",
"=",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SEQUENCE",
",",
"true",
",",
"[",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"INTEGER",
",",
"false",
",",
"asn1",
".",
"integerToDer",
"(",
"obj",
".",
"version",
")",
".",
"getBytes",
"(",
")",
")",
",",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SEQUENCE",
",",
"true",
",",
"[",
"forge",
".",
"pki",
".",
"distinguishedNameToAsn1",
"(",
"{",
"attributes",
":",
"obj",
".",
"issuer",
"}",
")",
",",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"INTEGER",
",",
"false",
",",
"forge",
".",
"util",
".",
"hexToBytes",
"(",
"obj",
".",
"serialNumber",
")",
")",
"]",
")",
",",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SEQUENCE",
",",
"true",
",",
"[",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OID",
",",
"false",
",",
"asn1",
".",
"oidToDer",
"(",
"obj",
".",
"digestAlgorithm",
")",
".",
"getBytes",
"(",
")",
")",
",",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"NULL",
",",
"false",
",",
"''",
")",
"]",
")",
"]",
")",
";",
"if",
"(",
"obj",
".",
"authenticatedAttributesAsn1",
")",
"{",
"rval",
".",
"value",
".",
"push",
"(",
"obj",
".",
"authenticatedAttributesAsn1",
")",
";",
"}",
"rval",
".",
"value",
".",
"push",
"(",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SEQUENCE",
",",
"true",
",",
"[",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OID",
",",
"false",
",",
"asn1",
".",
"oidToDer",
"(",
"obj",
".",
"signatureAlgorithm",
")",
".",
"getBytes",
"(",
")",
")",
",",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"NULL",
",",
"false",
",",
"''",
")",
"]",
")",
")",
";",
"rval",
".",
"value",
".",
"push",
"(",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OCTETSTRING",
",",
"false",
",",
"obj",
".",
"signature",
")",
")",
";",
"if",
"(",
"obj",
".",
"unauthenticatedAttributes",
".",
"length",
">",
"0",
")",
"{",
"var",
"attrsAsn1",
"=",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"CONTEXT_SPECIFIC",
",",
"1",
",",
"true",
",",
"[",
"]",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"obj",
".",
"unauthenticatedAttributes",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"attr",
"=",
"obj",
".",
"unauthenticatedAttributes",
"[",
"i",
"]",
";",
"attrsAsn1",
".",
"values",
".",
"push",
"(",
"_attributeToAsn1",
"(",
"attr",
")",
")",
";",
"}",
"rval",
".",
"value",
".",
"push",
"(",
"attrsAsn1",
")",
";",
"}",
"return",
"rval",
";",
"}"
]
| Converts a single signerInfo object to an ASN.1 object.
@param obj the signerInfo object.
@return the ASN.1 representation of a SignerInfo. | [
"Converts",
"a",
"single",
"signerInfo",
"object",
"to",
"an",
"ASN",
".",
"1",
"object",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L28009-L28064 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | _signersFromAsn1 | function _signersFromAsn1(signerInfoAsn1s) {
var ret = [];
for(var i = 0; i < signerInfoAsn1s.length; ++i) {
ret.push(_signerFromAsn1(signerInfoAsn1s[i]));
}
return ret;
} | javascript | function _signersFromAsn1(signerInfoAsn1s) {
var ret = [];
for(var i = 0; i < signerInfoAsn1s.length; ++i) {
ret.push(_signerFromAsn1(signerInfoAsn1s[i]));
}
return ret;
} | [
"function",
"_signersFromAsn1",
"(",
"signerInfoAsn1s",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"signerInfoAsn1s",
".",
"length",
";",
"++",
"i",
")",
"{",
"ret",
".",
"push",
"(",
"_signerFromAsn1",
"(",
"signerInfoAsn1s",
"[",
"i",
"]",
")",
")",
";",
"}",
"return",
"ret",
";",
"}"
]
| Map a set of SignerInfo ASN.1 objects to an array of signer objects.
@param signerInfoAsn1s an array of ASN.1 SignerInfos (i.e. SET OF).
@return an array of signers objects. | [
"Map",
"a",
"set",
"of",
"SignerInfo",
"ASN",
".",
"1",
"objects",
"to",
"an",
"array",
"of",
"signer",
"objects",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L28073-L28079 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | _signersToAsn1 | function _signersToAsn1(signers) {
var ret = [];
for(var i = 0; i < signers.length; ++i) {
ret.push(_signerToAsn1(signers[i]));
}
return ret;
} | javascript | function _signersToAsn1(signers) {
var ret = [];
for(var i = 0; i < signers.length; ++i) {
ret.push(_signerToAsn1(signers[i]));
}
return ret;
} | [
"function",
"_signersToAsn1",
"(",
"signers",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"signers",
".",
"length",
";",
"++",
"i",
")",
"{",
"ret",
".",
"push",
"(",
"_signerToAsn1",
"(",
"signers",
"[",
"i",
"]",
")",
")",
";",
"}",
"return",
"ret",
";",
"}"
]
| Map an array of signer objects to ASN.1 objects.
@param signers an array of signer objects.
@return an array of ASN.1 SignerInfos. | [
"Map",
"an",
"array",
"of",
"signer",
"objects",
"to",
"ASN",
".",
"1",
"objects",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L28088-L28094 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | _attributeToAsn1 | function _attributeToAsn1(attr) {
var value;
// TODO: generalize to support more attributes
if(attr.type === forge.pki.oids.contentType) {
value = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(attr.value).getBytes());
} else if(attr.type === forge.pki.oids.messageDigest) {
value = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
attr.value.bytes());
} else if(attr.type === forge.pki.oids.signingTime) {
/* Note per RFC 2985: Dates between 1 January 1950 and 31 December 2049
(inclusive) MUST be encoded as UTCTime. Any dates with year values
before 1950 or after 2049 MUST be encoded as GeneralizedTime. [Further,]
UTCTime values MUST be expressed in Greenwich Mean Time (Zulu) and MUST
include seconds (i.e., times are YYMMDDHHMMSSZ), even where the
number of seconds is zero. Midnight (GMT) must be represented as
"YYMMDD000000Z". */
// TODO: make these module-level constants
var jan_1_1950 = new Date('Jan 1, 1950 00:00:00Z');
var jan_1_2050 = new Date('Jan 1, 2050 00:00:00Z');
var date = attr.value;
if(typeof date === 'string') {
// try to parse date
var timestamp = Date.parse(date);
if(!isNaN(timestamp)) {
date = new Date(timestamp);
} else if(date.length === 13) {
// YYMMDDHHMMSSZ (13 chars for UTCTime)
date = asn1.utcTimeToDate(date);
} else {
// assume generalized time
date = asn1.generalizedTimeToDate(date);
}
}
if(date >= jan_1_1950 && date < jan_1_2050) {
value = asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.UTCTIME, false,
asn1.dateToUtcTime(date));
} else {
value = asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.GENERALIZEDTIME, false,
asn1.dateToGeneralizedTime(date));
}
}
// TODO: expose as common API call
// create a RelativeDistinguishedName set
// each value in the set is an AttributeTypeAndValue first
// containing the type (an OID) and second the value
return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// AttributeType
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(attr.type).getBytes()),
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [
// AttributeValue
value
])
]);
} | javascript | function _attributeToAsn1(attr) {
var value;
// TODO: generalize to support more attributes
if(attr.type === forge.pki.oids.contentType) {
value = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(attr.value).getBytes());
} else if(attr.type === forge.pki.oids.messageDigest) {
value = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
attr.value.bytes());
} else if(attr.type === forge.pki.oids.signingTime) {
/* Note per RFC 2985: Dates between 1 January 1950 and 31 December 2049
(inclusive) MUST be encoded as UTCTime. Any dates with year values
before 1950 or after 2049 MUST be encoded as GeneralizedTime. [Further,]
UTCTime values MUST be expressed in Greenwich Mean Time (Zulu) and MUST
include seconds (i.e., times are YYMMDDHHMMSSZ), even where the
number of seconds is zero. Midnight (GMT) must be represented as
"YYMMDD000000Z". */
// TODO: make these module-level constants
var jan_1_1950 = new Date('Jan 1, 1950 00:00:00Z');
var jan_1_2050 = new Date('Jan 1, 2050 00:00:00Z');
var date = attr.value;
if(typeof date === 'string') {
// try to parse date
var timestamp = Date.parse(date);
if(!isNaN(timestamp)) {
date = new Date(timestamp);
} else if(date.length === 13) {
// YYMMDDHHMMSSZ (13 chars for UTCTime)
date = asn1.utcTimeToDate(date);
} else {
// assume generalized time
date = asn1.generalizedTimeToDate(date);
}
}
if(date >= jan_1_1950 && date < jan_1_2050) {
value = asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.UTCTIME, false,
asn1.dateToUtcTime(date));
} else {
value = asn1.create(
asn1.Class.UNIVERSAL, asn1.Type.GENERALIZEDTIME, false,
asn1.dateToGeneralizedTime(date));
}
}
// TODO: expose as common API call
// create a RelativeDistinguishedName set
// each value in the set is an AttributeTypeAndValue first
// containing the type (an OID) and second the value
return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// AttributeType
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(attr.type).getBytes()),
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [
// AttributeValue
value
])
]);
} | [
"function",
"_attributeToAsn1",
"(",
"attr",
")",
"{",
"var",
"value",
";",
"if",
"(",
"attr",
".",
"type",
"===",
"forge",
".",
"pki",
".",
"oids",
".",
"contentType",
")",
"{",
"value",
"=",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OID",
",",
"false",
",",
"asn1",
".",
"oidToDer",
"(",
"attr",
".",
"value",
")",
".",
"getBytes",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"attr",
".",
"type",
"===",
"forge",
".",
"pki",
".",
"oids",
".",
"messageDigest",
")",
"{",
"value",
"=",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OCTETSTRING",
",",
"false",
",",
"attr",
".",
"value",
".",
"bytes",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"attr",
".",
"type",
"===",
"forge",
".",
"pki",
".",
"oids",
".",
"signingTime",
")",
"{",
"var",
"jan_1_1950",
"=",
"new",
"Date",
"(",
"'Jan 1, 1950 00:00:00Z'",
")",
";",
"var",
"jan_1_2050",
"=",
"new",
"Date",
"(",
"'Jan 1, 2050 00:00:00Z'",
")",
";",
"var",
"date",
"=",
"attr",
".",
"value",
";",
"if",
"(",
"typeof",
"date",
"===",
"'string'",
")",
"{",
"var",
"timestamp",
"=",
"Date",
".",
"parse",
"(",
"date",
")",
";",
"if",
"(",
"!",
"isNaN",
"(",
"timestamp",
")",
")",
"{",
"date",
"=",
"new",
"Date",
"(",
"timestamp",
")",
";",
"}",
"else",
"if",
"(",
"date",
".",
"length",
"===",
"13",
")",
"{",
"date",
"=",
"asn1",
".",
"utcTimeToDate",
"(",
"date",
")",
";",
"}",
"else",
"{",
"date",
"=",
"asn1",
".",
"generalizedTimeToDate",
"(",
"date",
")",
";",
"}",
"}",
"if",
"(",
"date",
">=",
"jan_1_1950",
"&&",
"date",
"<",
"jan_1_2050",
")",
"{",
"value",
"=",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"UTCTIME",
",",
"false",
",",
"asn1",
".",
"dateToUtcTime",
"(",
"date",
")",
")",
";",
"}",
"else",
"{",
"value",
"=",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"GENERALIZEDTIME",
",",
"false",
",",
"asn1",
".",
"dateToGeneralizedTime",
"(",
"date",
")",
")",
";",
"}",
"}",
"return",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SEQUENCE",
",",
"true",
",",
"[",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OID",
",",
"false",
",",
"asn1",
".",
"oidToDer",
"(",
"attr",
".",
"type",
")",
".",
"getBytes",
"(",
")",
")",
",",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SET",
",",
"true",
",",
"[",
"value",
"]",
")",
"]",
")",
";",
"}"
]
| Convert an attribute object to an ASN.1 Attribute.
@param attr the attribute object.
@return the ASN.1 Attribute. | [
"Convert",
"an",
"attribute",
"object",
"to",
"an",
"ASN",
".",
"1",
"Attribute",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L28103-L28163 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | _encryptedContentToAsn1 | function _encryptedContentToAsn1(ec) {
return [
// ContentType, always Data for the moment
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(forge.pki.oids.data).getBytes()),
// ContentEncryptionAlgorithmIdentifier
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// Algorithm
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(ec.algorithm).getBytes()),
// Parameters (IV)
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
ec.parameter.getBytes())
]),
// [0] EncryptedContent
asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
ec.content.getBytes())
])
];
} | javascript | function _encryptedContentToAsn1(ec) {
return [
// ContentType, always Data for the moment
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(forge.pki.oids.data).getBytes()),
// ContentEncryptionAlgorithmIdentifier
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
// Algorithm
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
asn1.oidToDer(ec.algorithm).getBytes()),
// Parameters (IV)
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
ec.parameter.getBytes())
]),
// [0] EncryptedContent
asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [
asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
ec.content.getBytes())
])
];
} | [
"function",
"_encryptedContentToAsn1",
"(",
"ec",
")",
"{",
"return",
"[",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OID",
",",
"false",
",",
"asn1",
".",
"oidToDer",
"(",
"forge",
".",
"pki",
".",
"oids",
".",
"data",
")",
".",
"getBytes",
"(",
")",
")",
",",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"SEQUENCE",
",",
"true",
",",
"[",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OID",
",",
"false",
",",
"asn1",
".",
"oidToDer",
"(",
"ec",
".",
"algorithm",
")",
".",
"getBytes",
"(",
")",
")",
",",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OCTETSTRING",
",",
"false",
",",
"ec",
".",
"parameter",
".",
"getBytes",
"(",
")",
")",
"]",
")",
",",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"CONTEXT_SPECIFIC",
",",
"0",
",",
"true",
",",
"[",
"asn1",
".",
"create",
"(",
"asn1",
".",
"Class",
".",
"UNIVERSAL",
",",
"asn1",
".",
"Type",
".",
"OCTETSTRING",
",",
"false",
",",
"ec",
".",
"content",
".",
"getBytes",
"(",
")",
")",
"]",
")",
"]",
";",
"}"
]
| Map messages encrypted content to ASN.1 objects.
@param ec The encryptedContent object of the message.
@return ASN.1 representation of the encryptedContent object (SEQUENCE). | [
"Map",
"messages",
"encrypted",
"content",
"to",
"ASN",
".",
"1",
"objects",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L28172-L28192 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | _sha1 | function _sha1() {
var sha = forge.md.sha1.create();
var num = arguments.length;
for (var i = 0; i < num; ++i) {
sha.update(arguments[i]);
}
return sha.digest();
} | javascript | function _sha1() {
var sha = forge.md.sha1.create();
var num = arguments.length;
for (var i = 0; i < num; ++i) {
sha.update(arguments[i]);
}
return sha.digest();
} | [
"function",
"_sha1",
"(",
")",
"{",
"var",
"sha",
"=",
"forge",
".",
"md",
".",
"sha1",
".",
"create",
"(",
")",
";",
"var",
"num",
"=",
"arguments",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"num",
";",
"++",
"i",
")",
"{",
"sha",
".",
"update",
"(",
"arguments",
"[",
"i",
"]",
")",
";",
"}",
"return",
"sha",
".",
"digest",
"(",
")",
";",
"}"
]
| Hashes the arguments into one value using SHA-1.
@return the sha1 hash of the provided arguments. | [
"Hashes",
"the",
"arguments",
"into",
"one",
"value",
"using",
"SHA",
"-",
"1",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L28606-L28613 | train |
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | function(options) {
// task id
this.id = -1;
// task name
this.name = options.name || sNoTaskName;
// task has no parent
this.parent = options.parent || null;
// save run function
this.run = options.run;
// create a queue of subtasks to run
this.subtasks = [];
// error flag
this.error = false;
// state of the task
this.state = READY;
// number of times the task has been blocked (also the number
// of permits needed to be released to continue running)
this.blocks = 0;
// timeout id when sleeping
this.timeoutId = null;
// no swap time yet
this.swapTime = null;
// no user data
this.userData = null;
// initialize task
// FIXME: deal with overflow
this.id = sNextTaskId++;
sTasks[this.id] = this;
if(sVL >= 1) {
forge.log.verbose(cat, '[%s][%s] init', this.id, this.name, this);
}
} | javascript | function(options) {
// task id
this.id = -1;
// task name
this.name = options.name || sNoTaskName;
// task has no parent
this.parent = options.parent || null;
// save run function
this.run = options.run;
// create a queue of subtasks to run
this.subtasks = [];
// error flag
this.error = false;
// state of the task
this.state = READY;
// number of times the task has been blocked (also the number
// of permits needed to be released to continue running)
this.blocks = 0;
// timeout id when sleeping
this.timeoutId = null;
// no swap time yet
this.swapTime = null;
// no user data
this.userData = null;
// initialize task
// FIXME: deal with overflow
this.id = sNextTaskId++;
sTasks[this.id] = this;
if(sVL >= 1) {
forge.log.verbose(cat, '[%s][%s] init', this.id, this.name, this);
}
} | [
"function",
"(",
"options",
")",
"{",
"this",
".",
"id",
"=",
"-",
"1",
";",
"this",
".",
"name",
"=",
"options",
".",
"name",
"||",
"sNoTaskName",
";",
"this",
".",
"parent",
"=",
"options",
".",
"parent",
"||",
"null",
";",
"this",
".",
"run",
"=",
"options",
".",
"run",
";",
"this",
".",
"subtasks",
"=",
"[",
"]",
";",
"this",
".",
"error",
"=",
"false",
";",
"this",
".",
"state",
"=",
"READY",
";",
"this",
".",
"blocks",
"=",
"0",
";",
"this",
".",
"timeoutId",
"=",
"null",
";",
"this",
".",
"swapTime",
"=",
"null",
";",
"this",
".",
"userData",
"=",
"null",
";",
"this",
".",
"id",
"=",
"sNextTaskId",
"++",
";",
"sTasks",
"[",
"this",
".",
"id",
"]",
"=",
"this",
";",
"if",
"(",
"sVL",
">=",
"1",
")",
"{",
"forge",
".",
"log",
".",
"verbose",
"(",
"cat",
",",
"'[%s][%s] init'",
",",
"this",
".",
"id",
",",
"this",
".",
"name",
",",
"this",
")",
";",
"}",
"}"
]
| Creates a new task.
@param options options for this task
run: the run function for the task (required)
name: the run function for the task (optional)
parent: parent of this task (optional)
@return the empty task. | [
"Creates",
"a",
"new",
"task",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L28835-L28877 | train |
|
FelixMcFelix/conductor-chord | web_modules/forge.bundle.js | function(task) {
task.error = false;
task.state = sStateTable[task.state][START];
setTimeout(function() {
if(task.state === RUNNING) {
task.swapTime = +new Date();
task.run(task);
runNext(task, 0);
}
}, 0);
} | javascript | function(task) {
task.error = false;
task.state = sStateTable[task.state][START];
setTimeout(function() {
if(task.state === RUNNING) {
task.swapTime = +new Date();
task.run(task);
runNext(task, 0);
}
}, 0);
} | [
"function",
"(",
"task",
")",
"{",
"task",
".",
"error",
"=",
"false",
";",
"task",
".",
"state",
"=",
"sStateTable",
"[",
"task",
".",
"state",
"]",
"[",
"START",
"]",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"task",
".",
"state",
"===",
"RUNNING",
")",
"{",
"task",
".",
"swapTime",
"=",
"+",
"new",
"Date",
"(",
")",
";",
"task",
".",
"run",
"(",
"task",
")",
";",
"runNext",
"(",
"task",
",",
"0",
")",
";",
"}",
"}",
",",
"0",
")",
";",
"}"
]
| Asynchronously start a task.
@param task the task to start. | [
"Asynchronously",
"start",
"a",
"task",
"."
]
| f5326861a0754a0f43f4e8585275de271a969c4c | https://github.com/FelixMcFelix/conductor-chord/blob/f5326861a0754a0f43f4e8585275de271a969c4c/web_modules/forge.bundle.js#L29153-L29163 | train |
|
eface2face/jquery-meteor-blaze | gulpfile.js | bundle | function bundle() {
return browserify( config.inputDir + config.inputFile ).bundle()
.pipe(
source( config.outputFile )
)
.pipe(
rename( config.outputFile )
)
.pipe(
gulp.dest( config.outputDir ) // Create the .devel.js
)
.pipe(
streamify( jsmin() )
)
.pipe(
rename( config.outputFileMin )
)
.pipe(
gulp.dest( config.outputDir ) // Create the .min.js
)
.pipe(
streamify( gzip() )
)
.pipe(
rename( config.outputFileMinGz )
)
.pipe(
gulp.dest( config.outputDir ) // Create the .min.gz
);
} | javascript | function bundle() {
return browserify( config.inputDir + config.inputFile ).bundle()
.pipe(
source( config.outputFile )
)
.pipe(
rename( config.outputFile )
)
.pipe(
gulp.dest( config.outputDir ) // Create the .devel.js
)
.pipe(
streamify( jsmin() )
)
.pipe(
rename( config.outputFileMin )
)
.pipe(
gulp.dest( config.outputDir ) // Create the .min.js
)
.pipe(
streamify( gzip() )
)
.pipe(
rename( config.outputFileMinGz )
)
.pipe(
gulp.dest( config.outputDir ) // Create the .min.gz
);
} | [
"function",
"bundle",
"(",
")",
"{",
"return",
"browserify",
"(",
"config",
".",
"inputDir",
"+",
"config",
".",
"inputFile",
")",
".",
"bundle",
"(",
")",
".",
"pipe",
"(",
"source",
"(",
"config",
".",
"outputFile",
")",
")",
".",
"pipe",
"(",
"rename",
"(",
"config",
".",
"outputFile",
")",
")",
".",
"pipe",
"(",
"gulp",
".",
"dest",
"(",
"config",
".",
"outputDir",
")",
")",
".",
"pipe",
"(",
"streamify",
"(",
"jsmin",
"(",
")",
")",
")",
".",
"pipe",
"(",
"rename",
"(",
"config",
".",
"outputFileMin",
")",
")",
".",
"pipe",
"(",
"gulp",
".",
"dest",
"(",
"config",
".",
"outputDir",
")",
")",
".",
"pipe",
"(",
"streamify",
"(",
"gzip",
"(",
")",
")",
")",
".",
"pipe",
"(",
"rename",
"(",
"config",
".",
"outputFileMinGz",
")",
")",
".",
"pipe",
"(",
"gulp",
".",
"dest",
"(",
"config",
".",
"outputDir",
")",
")",
";",
"}"
]
| Produce outfile, min, and gzip versions | [
"Produce",
"outfile",
"min",
"and",
"gzip",
"versions"
]
| 5d8776cf8915622905d3c5ff1da1c3259e7eee24 | https://github.com/eface2face/jquery-meteor-blaze/blob/5d8776cf8915622905d3c5ff1da1c3259e7eee24/gulpfile.js#L31-L60 | train |
IonicaBizau/node-gh-polyglot | lib/index.js | GhPolyglot | function GhPolyglot (input, token, host) {
var splits = input.split("/");
this.user = splits[0];
this.repo = splits[1];
this.full_name = input;
this.gh = new GitHub({ token: token, host: host });
} | javascript | function GhPolyglot (input, token, host) {
var splits = input.split("/");
this.user = splits[0];
this.repo = splits[1];
this.full_name = input;
this.gh = new GitHub({ token: token, host: host });
} | [
"function",
"GhPolyglot",
"(",
"input",
",",
"token",
",",
"host",
")",
"{",
"var",
"splits",
"=",
"input",
".",
"split",
"(",
"\"/\"",
")",
";",
"this",
".",
"user",
"=",
"splits",
"[",
"0",
"]",
";",
"this",
".",
"repo",
"=",
"splits",
"[",
"1",
"]",
";",
"this",
".",
"full_name",
"=",
"input",
";",
"this",
".",
"gh",
"=",
"new",
"GitHub",
"(",
"{",
"token",
":",
"token",
",",
"host",
":",
"host",
"}",
")",
";",
"}"
]
| GhPolyglot
Creates a new instance of `GhPolyglot`.
@name GhPolyglot
@function
@param {String} input The repository full name
(e.g. `"IonicaBizau/gh-polyglot"`) or the username (e.g. `"IonicaBizau"`).
@param {String} token An optional GitHub token used for making
authenticated requests.
@param {String} host An optional alternative Github FQDN (e.g. `"https://github.myenterprise.com/api/v3/"`)
@return {GhPolyglot} The `GhPolyglot` instance. | [
"GhPolyglot",
"Creates",
"a",
"new",
"instance",
"of",
"GhPolyglot",
"."
]
| 1656b7a056bc57d6ab4c18cce68672dfb79baf8a | https://github.com/IonicaBizau/node-gh-polyglot/blob/1656b7a056bc57d6ab4c18cce68672dfb79baf8a/lib/index.js#L19-L25 | train |
hhdevelopment/boxes-scroll | src/boxesscroll.js | getInnerLimit | function getInnerLimit() {
var items = getItems();
var notInDeck = 0;
if (items.length) {
do {
notInDeck = notInDeck + 1;
var cont = false;
var item = items[items.length - notInDeck];
if (item) {
var area = getArea(item);
if (ctrl.horizontal) {
cont = area.right > getEltArea().right;
} else {
cont = area.bottom > getEltArea().bottom;
}
if (!cont) {
notInDeck--;
}
}
} while (cont);
} else {
notInDeck = 1;
}
var fix = ($scope.ngLimit - items.length) + notInDeck;
return $scope.max ? $scope.ngLimit : $scope.ngLimit - fix;
} | javascript | function getInnerLimit() {
var items = getItems();
var notInDeck = 0;
if (items.length) {
do {
notInDeck = notInDeck + 1;
var cont = false;
var item = items[items.length - notInDeck];
if (item) {
var area = getArea(item);
if (ctrl.horizontal) {
cont = area.right > getEltArea().right;
} else {
cont = area.bottom > getEltArea().bottom;
}
if (!cont) {
notInDeck--;
}
}
} while (cont);
} else {
notInDeck = 1;
}
var fix = ($scope.ngLimit - items.length) + notInDeck;
return $scope.max ? $scope.ngLimit : $scope.ngLimit - fix;
} | [
"function",
"getInnerLimit",
"(",
")",
"{",
"var",
"items",
"=",
"getItems",
"(",
")",
";",
"var",
"notInDeck",
"=",
"0",
";",
"if",
"(",
"items",
".",
"length",
")",
"{",
"do",
"{",
"notInDeck",
"=",
"notInDeck",
"+",
"1",
";",
"var",
"cont",
"=",
"false",
";",
"var",
"item",
"=",
"items",
"[",
"items",
".",
"length",
"-",
"notInDeck",
"]",
";",
"if",
"(",
"item",
")",
"{",
"var",
"area",
"=",
"getArea",
"(",
"item",
")",
";",
"if",
"(",
"ctrl",
".",
"horizontal",
")",
"{",
"cont",
"=",
"area",
".",
"right",
">",
"getEltArea",
"(",
")",
".",
"right",
";",
"}",
"else",
"{",
"cont",
"=",
"area",
".",
"bottom",
">",
"getEltArea",
"(",
")",
".",
"bottom",
";",
"}",
"if",
"(",
"!",
"cont",
")",
"{",
"notInDeck",
"--",
";",
"}",
"}",
"}",
"while",
"(",
"cont",
")",
";",
"}",
"else",
"{",
"notInDeck",
"=",
"1",
";",
"}",
"var",
"fix",
"=",
"(",
"$scope",
".",
"ngLimit",
"-",
"items",
".",
"length",
")",
"+",
"notInDeck",
";",
"return",
"$scope",
".",
"max",
"?",
"$scope",
".",
"ngLimit",
":",
"$scope",
".",
"ngLimit",
"-",
"fix",
";",
"}"
]
| Retourne la limit pour les calcul interne, cad le nombre d'items vraiment visible
@returns {Number|type.ngLimit|boxesscrollL#1.BoxScrollCtrl.$scope.ngLimit} | [
"Retourne",
"la",
"limit",
"pour",
"les",
"calcul",
"interne",
"cad",
"le",
"nombre",
"d",
"items",
"vraiment",
"visible"
]
| 1d707715cbc25c35d9f30baaa95885cd36e0fec5 | https://github.com/hhdevelopment/boxes-scroll/blob/1d707715cbc25c35d9f30baaa95885cd36e0fec5/src/boxesscroll.js#L89-L114 | train |
hhdevelopment/boxes-scroll | src/boxesscroll.js | addEventListeners | function addEventListeners() {
ctrl.ngelt.on('wheel', wheelOnElt);
ctrl.ngelt.on('computegrabbersizes', ctrl.updateSize);
// ctrl.elt.addEventListener("wheel", function (event) {
// boxesScrollServices.execAndApplyIfScrollable($scope, this, wheel, [event]);
// }, {passive: true, capture: true});
ctrl.ngsb.on("mouseout", mouseoutOnSb);
ctrl.ngsb.on("mousedown", mousedownOnSb); // sur le mousedown, si dans le grabber, on init le mode drag, sinon on inc/dec les pages tant que l'on est appuyé
ctrl.ngsb.on("mouseup", mouseup); // on stop l'inc/dec des pages
ctrl.ngsb.on("click", boxesScrollServices.stopEvent); // desactive la propagation entre autrepour eviter la fermeture des popup
ctrl.ngelt.on("mousemove", mousemoveOnElt); // on définit la couleur du grabber
if (!ctrl.ngelt.css('display') !== 'none') { // si c'est une popup, le resize de l'ecran ne joue pas
ng.element($window).on("resize", updateSize);
}
$document.on("mousedown", mousedownOnDoc);
$document.on("keydown", keydownOnOnDoc);
$document.on("scroll", invalidSizes);
} | javascript | function addEventListeners() {
ctrl.ngelt.on('wheel', wheelOnElt);
ctrl.ngelt.on('computegrabbersizes', ctrl.updateSize);
// ctrl.elt.addEventListener("wheel", function (event) {
// boxesScrollServices.execAndApplyIfScrollable($scope, this, wheel, [event]);
// }, {passive: true, capture: true});
ctrl.ngsb.on("mouseout", mouseoutOnSb);
ctrl.ngsb.on("mousedown", mousedownOnSb); // sur le mousedown, si dans le grabber, on init le mode drag, sinon on inc/dec les pages tant que l'on est appuyé
ctrl.ngsb.on("mouseup", mouseup); // on stop l'inc/dec des pages
ctrl.ngsb.on("click", boxesScrollServices.stopEvent); // desactive la propagation entre autrepour eviter la fermeture des popup
ctrl.ngelt.on("mousemove", mousemoveOnElt); // on définit la couleur du grabber
if (!ctrl.ngelt.css('display') !== 'none') { // si c'est une popup, le resize de l'ecran ne joue pas
ng.element($window).on("resize", updateSize);
}
$document.on("mousedown", mousedownOnDoc);
$document.on("keydown", keydownOnOnDoc);
$document.on("scroll", invalidSizes);
} | [
"function",
"addEventListeners",
"(",
")",
"{",
"ctrl",
".",
"ngelt",
".",
"on",
"(",
"'wheel'",
",",
"wheelOnElt",
")",
";",
"ctrl",
".",
"ngelt",
".",
"on",
"(",
"'computegrabbersizes'",
",",
"ctrl",
".",
"updateSize",
")",
";",
"ctrl",
".",
"ngsb",
".",
"on",
"(",
"\"mouseout\"",
",",
"mouseoutOnSb",
")",
";",
"ctrl",
".",
"ngsb",
".",
"on",
"(",
"\"mousedown\"",
",",
"mousedownOnSb",
")",
";",
"ctrl",
".",
"ngsb",
".",
"on",
"(",
"\"mouseup\"",
",",
"mouseup",
")",
";",
"ctrl",
".",
"ngsb",
".",
"on",
"(",
"\"click\"",
",",
"boxesScrollServices",
".",
"stopEvent",
")",
";",
"ctrl",
".",
"ngelt",
".",
"on",
"(",
"\"mousemove\"",
",",
"mousemoveOnElt",
")",
";",
"if",
"(",
"!",
"ctrl",
".",
"ngelt",
".",
"css",
"(",
"'display'",
")",
"!==",
"'none'",
")",
"{",
"ng",
".",
"element",
"(",
"$window",
")",
".",
"on",
"(",
"\"resize\"",
",",
"updateSize",
")",
";",
"}",
"$document",
".",
"on",
"(",
"\"mousedown\"",
",",
"mousedownOnDoc",
")",
";",
"$document",
".",
"on",
"(",
"\"keydown\"",
",",
"keydownOnOnDoc",
")",
";",
"$document",
".",
"on",
"(",
"\"scroll\"",
",",
"invalidSizes",
")",
";",
"}"
]
| Ajoute et Supprime tous les handlers | [
"Ajoute",
"et",
"Supprime",
"tous",
"les",
"handlers"
]
| 1d707715cbc25c35d9f30baaa95885cd36e0fec5 | https://github.com/hhdevelopment/boxes-scroll/blob/1d707715cbc25c35d9f30baaa95885cd36e0fec5/src/boxesscroll.js#L119-L136 | train |
hhdevelopment/boxes-scroll | src/boxesscroll.js | keydown | function keydown(event) {
var inc = 0;
if (ctrl.horizontal) {
if (event.which === 37) { // LEFT
inc = -1;
} else if (event.which === 39) { // RIGHT
inc = 1;
}
} else {
var innerLimit = ctrl.getInnerLimit();
if (event.which === 38) { // UP
inc = -1;
} else if (event.which === 40) { // DOWN
inc = 1;
} else if (event.which === 33) { // PAGEUP
inc = -innerLimit;
} else if (event.which === 34) { // PAGEDOWN
inc = innerLimit;
} else if (event.which === 35) { // END
inc = $scope.total - $scope.ngBegin - innerLimit;
} else if (event.which === 36) { // HOME
inc = -$scope.ngBegin;
}
}
if (inc !== 0) {
boxesScrollServices.stopEvent(event);
$scope.ngBegin = $scope.ngBegin + inc;
}
} | javascript | function keydown(event) {
var inc = 0;
if (ctrl.horizontal) {
if (event.which === 37) { // LEFT
inc = -1;
} else if (event.which === 39) { // RIGHT
inc = 1;
}
} else {
var innerLimit = ctrl.getInnerLimit();
if (event.which === 38) { // UP
inc = -1;
} else if (event.which === 40) { // DOWN
inc = 1;
} else if (event.which === 33) { // PAGEUP
inc = -innerLimit;
} else if (event.which === 34) { // PAGEDOWN
inc = innerLimit;
} else if (event.which === 35) { // END
inc = $scope.total - $scope.ngBegin - innerLimit;
} else if (event.which === 36) { // HOME
inc = -$scope.ngBegin;
}
}
if (inc !== 0) {
boxesScrollServices.stopEvent(event);
$scope.ngBegin = $scope.ngBegin + inc;
}
} | [
"function",
"keydown",
"(",
"event",
")",
"{",
"var",
"inc",
"=",
"0",
";",
"if",
"(",
"ctrl",
".",
"horizontal",
")",
"{",
"if",
"(",
"event",
".",
"which",
"===",
"37",
")",
"{",
"inc",
"=",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"event",
".",
"which",
"===",
"39",
")",
"{",
"inc",
"=",
"1",
";",
"}",
"}",
"else",
"{",
"var",
"innerLimit",
"=",
"ctrl",
".",
"getInnerLimit",
"(",
")",
";",
"if",
"(",
"event",
".",
"which",
"===",
"38",
")",
"{",
"inc",
"=",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"event",
".",
"which",
"===",
"40",
")",
"{",
"inc",
"=",
"1",
";",
"}",
"else",
"if",
"(",
"event",
".",
"which",
"===",
"33",
")",
"{",
"inc",
"=",
"-",
"innerLimit",
";",
"}",
"else",
"if",
"(",
"event",
".",
"which",
"===",
"34",
")",
"{",
"inc",
"=",
"innerLimit",
";",
"}",
"else",
"if",
"(",
"event",
".",
"which",
"===",
"35",
")",
"{",
"inc",
"=",
"$scope",
".",
"total",
"-",
"$scope",
".",
"ngBegin",
"-",
"innerLimit",
";",
"}",
"else",
"if",
"(",
"event",
".",
"which",
"===",
"36",
")",
"{",
"inc",
"=",
"-",
"$scope",
".",
"ngBegin",
";",
"}",
"}",
"if",
"(",
"inc",
"!==",
"0",
")",
"{",
"boxesScrollServices",
".",
"stopEvent",
"(",
"event",
")",
";",
"$scope",
".",
"ngBegin",
"=",
"$scope",
".",
"ngBegin",
"+",
"inc",
";",
"}",
"}"
]
| Gere la navigation clavier
@param {type} event | [
"Gere",
"la",
"navigation",
"clavier"
]
| 1d707715cbc25c35d9f30baaa95885cd36e0fec5 | https://github.com/hhdevelopment/boxes-scroll/blob/1d707715cbc25c35d9f30baaa95885cd36e0fec5/src/boxesscroll.js#L274-L302 | train |
hhdevelopment/boxes-scroll | src/boxesscroll.js | isScrollbarOver | function isScrollbarOver(m) {
return document.elementFromPoint(m.x, m.y) === ctrl.sb;
} | javascript | function isScrollbarOver(m) {
return document.elementFromPoint(m.x, m.y) === ctrl.sb;
} | [
"function",
"isScrollbarOver",
"(",
"m",
")",
"{",
"return",
"document",
".",
"elementFromPoint",
"(",
"m",
".",
"x",
",",
"m",
".",
"y",
")",
"===",
"ctrl",
".",
"sb",
";",
"}"
]
| La souris est elle au dessus de la scrollbar
@param {MouseCoordonates} m
@returns {Boolean} | [
"La",
"souris",
"est",
"elle",
"au",
"dessus",
"de",
"la",
"scrollbar"
]
| 1d707715cbc25c35d9f30baaa95885cd36e0fec5 | https://github.com/hhdevelopment/boxes-scroll/blob/1d707715cbc25c35d9f30baaa95885cd36e0fec5/src/boxesscroll.js#L436-L438 | train |
hhdevelopment/boxes-scroll | src/boxesscroll.js | updateGrabberSizes | function updateGrabberSizes() {
if (ctrl.horizontal !== undefined) {
var bgSizeElt = ctrl.ngelt.css('background-size');
var bgSizeSb = ctrl.ngsb.css('background-size');
var grabbersizePixel = '100%';
if(getInnerLimit() !== $scope.total) {
grabbersizePixel = getGrabberSizePixelFromPercent(getGrabberSizePercentFromScopeValues())+'px';
}
if (ctrl.horizontal) {
bgSizeElt = bgSizeElt.replace(/.*\s+/, grabbersizePixel + ' ');
bgSizeSb = bgSizeSb.replace(/.*\s+/, grabbersizePixel + ' ');
} else {
bgSizeElt = bgSizeElt.replace(/px\s+\d+(\.\d+)*.*/, 'px ' + grabbersizePixel);
bgSizeSb = bgSizeSb.replace(/px\s+\d+(\.\d+)*.*/, 'px ' + grabbersizePixel);
}
ctrl.ngelt.css({'background-size': bgSizeElt});
ctrl.ngsb.css({'background-size': bgSizeSb});
}
} | javascript | function updateGrabberSizes() {
if (ctrl.horizontal !== undefined) {
var bgSizeElt = ctrl.ngelt.css('background-size');
var bgSizeSb = ctrl.ngsb.css('background-size');
var grabbersizePixel = '100%';
if(getInnerLimit() !== $scope.total) {
grabbersizePixel = getGrabberSizePixelFromPercent(getGrabberSizePercentFromScopeValues())+'px';
}
if (ctrl.horizontal) {
bgSizeElt = bgSizeElt.replace(/.*\s+/, grabbersizePixel + ' ');
bgSizeSb = bgSizeSb.replace(/.*\s+/, grabbersizePixel + ' ');
} else {
bgSizeElt = bgSizeElt.replace(/px\s+\d+(\.\d+)*.*/, 'px ' + grabbersizePixel);
bgSizeSb = bgSizeSb.replace(/px\s+\d+(\.\d+)*.*/, 'px ' + grabbersizePixel);
}
ctrl.ngelt.css({'background-size': bgSizeElt});
ctrl.ngsb.css({'background-size': bgSizeSb});
}
} | [
"function",
"updateGrabberSizes",
"(",
")",
"{",
"if",
"(",
"ctrl",
".",
"horizontal",
"!==",
"undefined",
")",
"{",
"var",
"bgSizeElt",
"=",
"ctrl",
".",
"ngelt",
".",
"css",
"(",
"'background-size'",
")",
";",
"var",
"bgSizeSb",
"=",
"ctrl",
".",
"ngsb",
".",
"css",
"(",
"'background-size'",
")",
";",
"var",
"grabbersizePixel",
"=",
"'100%'",
";",
"if",
"(",
"getInnerLimit",
"(",
")",
"!==",
"$scope",
".",
"total",
")",
"{",
"grabbersizePixel",
"=",
"getGrabberSizePixelFromPercent",
"(",
"getGrabberSizePercentFromScopeValues",
"(",
")",
")",
"+",
"'px'",
";",
"}",
"if",
"(",
"ctrl",
".",
"horizontal",
")",
"{",
"bgSizeElt",
"=",
"bgSizeElt",
".",
"replace",
"(",
"/",
".*\\s+",
"/",
",",
"grabbersizePixel",
"+",
"' '",
")",
";",
"bgSizeSb",
"=",
"bgSizeSb",
".",
"replace",
"(",
"/",
".*\\s+",
"/",
",",
"grabbersizePixel",
"+",
"' '",
")",
";",
"}",
"else",
"{",
"bgSizeElt",
"=",
"bgSizeElt",
".",
"replace",
"(",
"/",
"px\\s+\\d+(\\.\\d+)*.*",
"/",
",",
"'px '",
"+",
"grabbersizePixel",
")",
";",
"bgSizeSb",
"=",
"bgSizeSb",
".",
"replace",
"(",
"/",
"px\\s+\\d+(\\.\\d+)*.*",
"/",
",",
"'px '",
"+",
"grabbersizePixel",
")",
";",
"}",
"ctrl",
".",
"ngelt",
".",
"css",
"(",
"{",
"'background-size'",
":",
"bgSizeElt",
"}",
")",
";",
"ctrl",
".",
"ngsb",
".",
"css",
"(",
"{",
"'background-size'",
":",
"bgSizeSb",
"}",
")",
";",
"}",
"}"
]
| Calcul la taille des grabbers | [
"Calcul",
"la",
"taille",
"des",
"grabbers"
]
| 1d707715cbc25c35d9f30baaa95885cd36e0fec5 | https://github.com/hhdevelopment/boxes-scroll/blob/1d707715cbc25c35d9f30baaa95885cd36e0fec5/src/boxesscroll.js#L564-L584 | train |
hhdevelopment/boxes-scroll | src/boxesscroll.js | getGrabberOffsetPixelFromPercent | function getGrabberOffsetPixelFromPercent(percentOffset) {
var sbLenght = getHeightArea(); // Longueur de la scrollbar
var grabberOffsetPixel = sbLenght * percentOffset / 100;
return Math.max(grabberOffsetPixel, 0);
} | javascript | function getGrabberOffsetPixelFromPercent(percentOffset) {
var sbLenght = getHeightArea(); // Longueur de la scrollbar
var grabberOffsetPixel = sbLenght * percentOffset / 100;
return Math.max(grabberOffsetPixel, 0);
} | [
"function",
"getGrabberOffsetPixelFromPercent",
"(",
"percentOffset",
")",
"{",
"var",
"sbLenght",
"=",
"getHeightArea",
"(",
")",
";",
"var",
"grabberOffsetPixel",
"=",
"sbLenght",
"*",
"percentOffset",
"/",
"100",
";",
"return",
"Math",
".",
"max",
"(",
"grabberOffsetPixel",
",",
"0",
")",
";",
"}"
]
| Calcul la position du curseur en px
@param {type} percentOffset
@returns {Number} | [
"Calcul",
"la",
"position",
"du",
"curseur",
"en",
"px"
]
| 1d707715cbc25c35d9f30baaa95885cd36e0fec5 | https://github.com/hhdevelopment/boxes-scroll/blob/1d707715cbc25c35d9f30baaa95885cd36e0fec5/src/boxesscroll.js#L620-L624 | train |
hhdevelopment/boxes-scroll | src/boxesscroll.js | getOffsetPixelContainerBeforeItem | function getOffsetPixelContainerBeforeItem(item) {
if (ctrl.horizontal) {
return getArea(item).left - getEltArea().left;
} else {
return getArea(item).top - getEltArea().top;
}
} | javascript | function getOffsetPixelContainerBeforeItem(item) {
if (ctrl.horizontal) {
return getArea(item).left - getEltArea().left;
} else {
return getArea(item).top - getEltArea().top;
}
} | [
"function",
"getOffsetPixelContainerBeforeItem",
"(",
"item",
")",
"{",
"if",
"(",
"ctrl",
".",
"horizontal",
")",
"{",
"return",
"getArea",
"(",
"item",
")",
".",
"left",
"-",
"getEltArea",
"(",
")",
".",
"left",
";",
"}",
"else",
"{",
"return",
"getArea",
"(",
"item",
")",
".",
"top",
"-",
"getEltArea",
"(",
")",
".",
"top",
";",
"}",
"}"
]
| Retourne l'offset en pixel avant l'item
Typiquement la taille du header dans un tableau
@param {HtmlElement} item
@returns {number} | [
"Retourne",
"l",
"offset",
"en",
"pixel",
"avant",
"l",
"item",
"Typiquement",
"la",
"taille",
"du",
"header",
"dans",
"un",
"tableau"
]
| 1d707715cbc25c35d9f30baaa95885cd36e0fec5 | https://github.com/hhdevelopment/boxes-scroll/blob/1d707715cbc25c35d9f30baaa95885cd36e0fec5/src/boxesscroll.js#L649-L655 | train |
mattidupre/gulp-retinize | retinize.js | function(file, enc, cb) {
if (
!file.isNull() &&
!file.isDirectory() &&
options.extensions.some(function(ext) {
return path.extname(file.path).substr(1).toLowerCase() === ext;
})
) {
file = retina.tapFile(file, cb);
} else {
cb();
}
// Push only if file is returned by retina (otherwise it is dropped from stream)
if (file) this.push(file);
} | javascript | function(file, enc, cb) {
if (
!file.isNull() &&
!file.isDirectory() &&
options.extensions.some(function(ext) {
return path.extname(file.path).substr(1).toLowerCase() === ext;
})
) {
file = retina.tapFile(file, cb);
} else {
cb();
}
// Push only if file is returned by retina (otherwise it is dropped from stream)
if (file) this.push(file);
} | [
"function",
"(",
"file",
",",
"enc",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"file",
".",
"isNull",
"(",
")",
"&&",
"!",
"file",
".",
"isDirectory",
"(",
")",
"&&",
"options",
".",
"extensions",
".",
"some",
"(",
"function",
"(",
"ext",
")",
"{",
"return",
"path",
".",
"extname",
"(",
"file",
".",
"path",
")",
".",
"substr",
"(",
"1",
")",
".",
"toLowerCase",
"(",
")",
"===",
"ext",
";",
"}",
")",
")",
"{",
"file",
"=",
"retina",
".",
"tapFile",
"(",
"file",
",",
"cb",
")",
";",
"}",
"else",
"{",
"cb",
"(",
")",
";",
"}",
"if",
"(",
"file",
")",
"this",
".",
"push",
"(",
"file",
")",
";",
"}"
]
| Transform function filters image files | [
"Transform",
"function",
"filters",
"image",
"files"
]
| f804f01d80d8f240dc41fc6c656e2bca09b1fb46 | https://github.com/mattidupre/gulp-retinize/blob/f804f01d80d8f240dc41fc6c656e2bca09b1fb46/retinize.js#L37-L51 | train |
|
amritk/gulp-angular2-embed-sass | index.js | joinParts | function joinParts(entrances) {
var parts = [];
parts.push(Buffer(content.substring(0, matches.index)));
parts.push(Buffer('styles: [`'));
for (var i=0; i<entrances.length; i++) {
parts.push(Buffer(entrances[i].replace(/\n/g, '')));
if (i < entrances.length - 1) {
parts.push(Buffer('`, `'));
}
}
parts.push(Buffer('`]'));
parts.push(Buffer(content.substr(matches.index + matches[0].length)));
return Buffer.concat(parts);
} | javascript | function joinParts(entrances) {
var parts = [];
parts.push(Buffer(content.substring(0, matches.index)));
parts.push(Buffer('styles: [`'));
for (var i=0; i<entrances.length; i++) {
parts.push(Buffer(entrances[i].replace(/\n/g, '')));
if (i < entrances.length - 1) {
parts.push(Buffer('`, `'));
}
}
parts.push(Buffer('`]'));
parts.push(Buffer(content.substr(matches.index + matches[0].length)));
return Buffer.concat(parts);
} | [
"function",
"joinParts",
"(",
"entrances",
")",
"{",
"var",
"parts",
"=",
"[",
"]",
";",
"parts",
".",
"push",
"(",
"Buffer",
"(",
"content",
".",
"substring",
"(",
"0",
",",
"matches",
".",
"index",
")",
")",
")",
";",
"parts",
".",
"push",
"(",
"Buffer",
"(",
"'styles: [`'",
")",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"entrances",
".",
"length",
";",
"i",
"++",
")",
"{",
"parts",
".",
"push",
"(",
"Buffer",
"(",
"entrances",
"[",
"i",
"]",
".",
"replace",
"(",
"/",
"\\n",
"/",
"g",
",",
"''",
")",
")",
")",
";",
"if",
"(",
"i",
"<",
"entrances",
".",
"length",
"-",
"1",
")",
"{",
"parts",
".",
"push",
"(",
"Buffer",
"(",
"'`, `'",
")",
")",
";",
"}",
"}",
"parts",
".",
"push",
"(",
"Buffer",
"(",
"'`]'",
")",
")",
";",
"parts",
".",
"push",
"(",
"Buffer",
"(",
"content",
".",
"substr",
"(",
"matches",
".",
"index",
"+",
"matches",
"[",
"0",
"]",
".",
"length",
")",
")",
")",
";",
"return",
"Buffer",
".",
"concat",
"(",
"parts",
")",
";",
"}"
]
| Writes the new css strings to the file buffer | [
"Writes",
"the",
"new",
"css",
"strings",
"to",
"the",
"file",
"buffer"
]
| 4e50499ea49b4a6178c1e87535c9f006877a7a65 | https://github.com/amritk/gulp-angular2-embed-sass/blob/4e50499ea49b4a6178c1e87535c9f006877a7a65/index.js#L110-L125 | train |
solid/contacts-pane | contactsPane.js | function (subject) {
var t = kb.findTypeURIs(subject)
if (t[ns.vcard('Individual').uri]) return 'Contact'
if (t[ns.vcard('Organization').uri]) return 'contact'
if (t[ns.foaf('Person').uri]) return 'Person'
if (t[ns.schema('Person').uri]) return 'Person'
if (t[ns.vcard('Group').uri]) return 'Group'
if (t[ns.vcard('AddressBook').uri]) return 'Address book'
return null // No under other circumstances
} | javascript | function (subject) {
var t = kb.findTypeURIs(subject)
if (t[ns.vcard('Individual').uri]) return 'Contact'
if (t[ns.vcard('Organization').uri]) return 'contact'
if (t[ns.foaf('Person').uri]) return 'Person'
if (t[ns.schema('Person').uri]) return 'Person'
if (t[ns.vcard('Group').uri]) return 'Group'
if (t[ns.vcard('AddressBook').uri]) return 'Address book'
return null // No under other circumstances
} | [
"function",
"(",
"subject",
")",
"{",
"var",
"t",
"=",
"kb",
".",
"findTypeURIs",
"(",
"subject",
")",
"if",
"(",
"t",
"[",
"ns",
".",
"vcard",
"(",
"'Individual'",
")",
".",
"uri",
"]",
")",
"return",
"'Contact'",
"if",
"(",
"t",
"[",
"ns",
".",
"vcard",
"(",
"'Organization'",
")",
".",
"uri",
"]",
")",
"return",
"'contact'",
"if",
"(",
"t",
"[",
"ns",
".",
"foaf",
"(",
"'Person'",
")",
".",
"uri",
"]",
")",
"return",
"'Person'",
"if",
"(",
"t",
"[",
"ns",
".",
"schema",
"(",
"'Person'",
")",
".",
"uri",
"]",
")",
"return",
"'Person'",
"if",
"(",
"t",
"[",
"ns",
".",
"vcard",
"(",
"'Group'",
")",
".",
"uri",
"]",
")",
"return",
"'Group'",
"if",
"(",
"t",
"[",
"ns",
".",
"vcard",
"(",
"'AddressBook'",
")",
".",
"uri",
"]",
")",
"return",
"'Address book'",
"return",
"null",
"}"
]
| Does the subject deserve an contact pane? | [
"Does",
"the",
"subject",
"deserve",
"an",
"contact",
"pane?"
]
| 373c55fc6e2c584603741ee972d036fcb1e2f4b8 | https://github.com/solid/contacts-pane/blob/373c55fc6e2c584603741ee972d036fcb1e2f4b8/contactsPane.js#L34-L43 | train |
|
solid/contacts-pane | contactsPane.js | function (books, context, options) {
kb.fetcher.load(books).then(function (xhr) {
renderThreeColumnBrowser2(books, context, options)
}).catch(function (err) { complain(err) })
} | javascript | function (books, context, options) {
kb.fetcher.load(books).then(function (xhr) {
renderThreeColumnBrowser2(books, context, options)
}).catch(function (err) { complain(err) })
} | [
"function",
"(",
"books",
",",
"context",
",",
"options",
")",
"{",
"kb",
".",
"fetcher",
".",
"load",
"(",
"books",
")",
".",
"then",
"(",
"function",
"(",
"xhr",
")",
"{",
"renderThreeColumnBrowser2",
"(",
"books",
",",
"context",
",",
"options",
")",
"}",
")",
".",
"catch",
"(",
"function",
"(",
"err",
")",
"{",
"complain",
"(",
"err",
")",
"}",
")",
"}"
]
| Render a 3-column browser for an address book or a group | [
"Render",
"a",
"3",
"-",
"column",
"browser",
"for",
"an",
"address",
"book",
"or",
"a",
"group"
]
| 373c55fc6e2c584603741ee972d036fcb1e2f4b8 | https://github.com/solid/contacts-pane/blob/373c55fc6e2c584603741ee972d036fcb1e2f4b8/contactsPane.js#L227-L231 | train |
|
solid/contacts-pane | contactsPane.js | findBookFromGroups | function findBookFromGroups (book) {
if (book) {
return book
}
var g
for (let gu in selectedGroups) {
g = kb.sym(gu)
let b = kb.any(undefined, ns.vcard('includesGroup'), g)
if (b) return b
}
throw new Error('findBookFromGroups: Cant find address book which this group is part of')
} | javascript | function findBookFromGroups (book) {
if (book) {
return book
}
var g
for (let gu in selectedGroups) {
g = kb.sym(gu)
let b = kb.any(undefined, ns.vcard('includesGroup'), g)
if (b) return b
}
throw new Error('findBookFromGroups: Cant find address book which this group is part of')
} | [
"function",
"findBookFromGroups",
"(",
"book",
")",
"{",
"if",
"(",
"book",
")",
"{",
"return",
"book",
"}",
"var",
"g",
"for",
"(",
"let",
"gu",
"in",
"selectedGroups",
")",
"{",
"g",
"=",
"kb",
".",
"sym",
"(",
"gu",
")",
"let",
"b",
"=",
"kb",
".",
"any",
"(",
"undefined",
",",
"ns",
".",
"vcard",
"(",
"'includesGroup'",
")",
",",
"g",
")",
"if",
"(",
"b",
")",
"return",
"b",
"}",
"throw",
"new",
"Error",
"(",
"'findBookFromGroups: Cant find address book which this group is part of'",
")",
"}"
]
| The book could be the main subject, or linked from a group we are dealing with | [
"The",
"book",
"could",
"be",
"the",
"main",
"subject",
"or",
"linked",
"from",
"a",
"group",
"we",
"are",
"dealing",
"with"
]
| 373c55fc6e2c584603741ee972d036fcb1e2f4b8 | https://github.com/solid/contacts-pane/blob/373c55fc6e2c584603741ee972d036fcb1e2f4b8/contactsPane.js#L250-L261 | train |
solid/contacts-pane | contactsPane.js | function (book, name, selectedGroups, callbackFunction) {
book = findBookFromGroups(book)
var nameEmailIndex = kb.any(book, ns.vcard('nameEmailIndex'))
var uuid = UI.utils.genUuid()
var person = kb.sym(book.dir().uri + 'Person/' + uuid + '/index.ttl#this')
var doc = person.doc()
// Sets of statements to different files
var agenda = [ // Patch the main index to add the person
[ $rdf.st(person, ns.vcard('inAddressBook'), book, nameEmailIndex), // The people index
$rdf.st(person, ns.vcard('fn'), name, nameEmailIndex) ]
]
// @@ May be missing email - sync that differently
// sts.push(new $rdf.Statement(person, DCT('created'), new Date(), doc)); ??? include this?
for (var gu in selectedGroups) {
var g = kb.sym(gu)
var gd = g.doc()
agenda.push([ $rdf.st(g, ns.vcard('hasMember'), person, gd),
$rdf.st(person, ns.vcard('fn'), name, gd)
])
}
var updateCallback = function (uri, success, body) {
if (!success) {
console.log("Error: can't update " + uri + ' for new contact:' + body + '\n')
callbackFunction(false, "Error: can't update " + uri + ' for new contact:' + body)
} else {
if (agenda.length > 0) {
console.log('Patching ' + agenda[0] + '\n')
updater.update([], agenda.shift(), updateCallback)
} else { // done!
console.log('Done patching. Now reading back in.\n')
UI.store.fetcher.nowOrWhenFetched(doc, undefined, function (ok, body) {
if (ok) {
console.log('Read back in OK.\n')
callbackFunction(true, person)
} else {
console.log('Read back in FAILED: ' + body + '\n')
callbackFunction(false, body)
}
})
}
}
}
UI.store.fetcher.nowOrWhenFetched(nameEmailIndex, undefined, function (ok, message) {
if (ok) {
console.log(' People index must be loaded\n')
updater.put(doc, [
$rdf.st(person, ns.vcard('fn'), name, doc),
$rdf.st(person, ns.rdf('type'), ns.vcard('Individual'), doc) ],
'text/turtle', updateCallback)
} else {
console.log('Error loading people index!' + nameEmailIndex.uri + ': ' + message)
callbackFunction(false, 'Error loading people index!' + nameEmailIndex.uri + ': ' + message + '\n')
}
})
} | javascript | function (book, name, selectedGroups, callbackFunction) {
book = findBookFromGroups(book)
var nameEmailIndex = kb.any(book, ns.vcard('nameEmailIndex'))
var uuid = UI.utils.genUuid()
var person = kb.sym(book.dir().uri + 'Person/' + uuid + '/index.ttl#this')
var doc = person.doc()
// Sets of statements to different files
var agenda = [ // Patch the main index to add the person
[ $rdf.st(person, ns.vcard('inAddressBook'), book, nameEmailIndex), // The people index
$rdf.st(person, ns.vcard('fn'), name, nameEmailIndex) ]
]
// @@ May be missing email - sync that differently
// sts.push(new $rdf.Statement(person, DCT('created'), new Date(), doc)); ??? include this?
for (var gu in selectedGroups) {
var g = kb.sym(gu)
var gd = g.doc()
agenda.push([ $rdf.st(g, ns.vcard('hasMember'), person, gd),
$rdf.st(person, ns.vcard('fn'), name, gd)
])
}
var updateCallback = function (uri, success, body) {
if (!success) {
console.log("Error: can't update " + uri + ' for new contact:' + body + '\n')
callbackFunction(false, "Error: can't update " + uri + ' for new contact:' + body)
} else {
if (agenda.length > 0) {
console.log('Patching ' + agenda[0] + '\n')
updater.update([], agenda.shift(), updateCallback)
} else { // done!
console.log('Done patching. Now reading back in.\n')
UI.store.fetcher.nowOrWhenFetched(doc, undefined, function (ok, body) {
if (ok) {
console.log('Read back in OK.\n')
callbackFunction(true, person)
} else {
console.log('Read back in FAILED: ' + body + '\n')
callbackFunction(false, body)
}
})
}
}
}
UI.store.fetcher.nowOrWhenFetched(nameEmailIndex, undefined, function (ok, message) {
if (ok) {
console.log(' People index must be loaded\n')
updater.put(doc, [
$rdf.st(person, ns.vcard('fn'), name, doc),
$rdf.st(person, ns.rdf('type'), ns.vcard('Individual'), doc) ],
'text/turtle', updateCallback)
} else {
console.log('Error loading people index!' + nameEmailIndex.uri + ': ' + message)
callbackFunction(false, 'Error loading people index!' + nameEmailIndex.uri + ': ' + message + '\n')
}
})
} | [
"function",
"(",
"book",
",",
"name",
",",
"selectedGroups",
",",
"callbackFunction",
")",
"{",
"book",
"=",
"findBookFromGroups",
"(",
"book",
")",
"var",
"nameEmailIndex",
"=",
"kb",
".",
"any",
"(",
"book",
",",
"ns",
".",
"vcard",
"(",
"'nameEmailIndex'",
")",
")",
"var",
"uuid",
"=",
"UI",
".",
"utils",
".",
"genUuid",
"(",
")",
"var",
"person",
"=",
"kb",
".",
"sym",
"(",
"book",
".",
"dir",
"(",
")",
".",
"uri",
"+",
"'Person/'",
"+",
"uuid",
"+",
"'/index.ttl#this'",
")",
"var",
"doc",
"=",
"person",
".",
"doc",
"(",
")",
"var",
"agenda",
"=",
"[",
"[",
"$rdf",
".",
"st",
"(",
"person",
",",
"ns",
".",
"vcard",
"(",
"'inAddressBook'",
")",
",",
"book",
",",
"nameEmailIndex",
")",
",",
"$rdf",
".",
"st",
"(",
"person",
",",
"ns",
".",
"vcard",
"(",
"'fn'",
")",
",",
"name",
",",
"nameEmailIndex",
")",
"]",
"]",
"for",
"(",
"var",
"gu",
"in",
"selectedGroups",
")",
"{",
"var",
"g",
"=",
"kb",
".",
"sym",
"(",
"gu",
")",
"var",
"gd",
"=",
"g",
".",
"doc",
"(",
")",
"agenda",
".",
"push",
"(",
"[",
"$rdf",
".",
"st",
"(",
"g",
",",
"ns",
".",
"vcard",
"(",
"'hasMember'",
")",
",",
"person",
",",
"gd",
")",
",",
"$rdf",
".",
"st",
"(",
"person",
",",
"ns",
".",
"vcard",
"(",
"'fn'",
")",
",",
"name",
",",
"gd",
")",
"]",
")",
"}",
"var",
"updateCallback",
"=",
"function",
"(",
"uri",
",",
"success",
",",
"body",
")",
"{",
"if",
"(",
"!",
"success",
")",
"{",
"console",
".",
"log",
"(",
"\"Error: can't update \"",
"+",
"uri",
"+",
"' for new contact:'",
"+",
"body",
"+",
"'\\n'",
")",
"\\n",
"}",
"else",
"callbackFunction",
"(",
"false",
",",
"\"Error: can't update \"",
"+",
"uri",
"+",
"' for new contact:'",
"+",
"body",
")",
"}",
"{",
"if",
"(",
"agenda",
".",
"length",
">",
"0",
")",
"{",
"console",
".",
"log",
"(",
"'Patching '",
"+",
"agenda",
"[",
"0",
"]",
"+",
"'\\n'",
")",
"\\n",
"}",
"else",
"updater",
".",
"update",
"(",
"[",
"]",
",",
"agenda",
".",
"shift",
"(",
")",
",",
"updateCallback",
")",
"}",
"}"
]
| Write a new contact to the web | [
"Write",
"a",
"new",
"contact",
"to",
"the",
"web"
]
| 373c55fc6e2c584603741ee972d036fcb1e2f4b8 | https://github.com/solid/contacts-pane/blob/373c55fc6e2c584603741ee972d036fcb1e2f4b8/contactsPane.js#L264-L324 | train |
|
solid/contacts-pane | contactsPane.js | function (book, name, callbackFunction) {
var gix = kb.any(book, ns.vcard('groupIndex'))
var x = book.uri.split('#')[0]
var gname = name.replace(' ', '_')
var doc = kb.sym(x.slice(0, x.lastIndexOf('/') + 1) + 'Group/' + gname + '.ttl')
var group = kb.sym(doc.uri + '#this')
console.log(' New group will be: ' + group + '\n')
UI.store.fetcher.nowOrWhenFetched(gix, function (ok, message) {
if (ok) {
console.log(' Group index must be loaded\n')
var insertTriples = [
$rdf.st(book, ns.vcard('includesGroup'), group, gix),
$rdf.st(group, ns.rdf('type'), ns.vcard('Group'), gix),
$rdf.st(group, ns.vcard('fn'), name, gix)
]
updater.update([], insertTriples, function (uri, success, body) {
if (ok) {
var triples = [
$rdf.st(book, ns.vcard('includesGroup'), group, gix), // Pointer back to book
$rdf.st(group, ns.rdf('type'), ns.vcard('Group'), doc),
$rdf.st(group, ns.vcard('fn'), name, doc)
]
updater.put(doc, triples, 'text/turtle', function (uri, ok, body) {
callbackFunction(ok, ok ? group : "Can't save new group file " + doc + body)
})
} else {
callbackFunction(ok, 'Could not update group index ' + body) // fail
}
})
} else {
console.log('Error loading people index!' + gix.uri + ': ' + message)
callbackFunction(false, 'Error loading people index!' + gix.uri + ': ' + message + '\n')
}
})
} | javascript | function (book, name, callbackFunction) {
var gix = kb.any(book, ns.vcard('groupIndex'))
var x = book.uri.split('#')[0]
var gname = name.replace(' ', '_')
var doc = kb.sym(x.slice(0, x.lastIndexOf('/') + 1) + 'Group/' + gname + '.ttl')
var group = kb.sym(doc.uri + '#this')
console.log(' New group will be: ' + group + '\n')
UI.store.fetcher.nowOrWhenFetched(gix, function (ok, message) {
if (ok) {
console.log(' Group index must be loaded\n')
var insertTriples = [
$rdf.st(book, ns.vcard('includesGroup'), group, gix),
$rdf.st(group, ns.rdf('type'), ns.vcard('Group'), gix),
$rdf.st(group, ns.vcard('fn'), name, gix)
]
updater.update([], insertTriples, function (uri, success, body) {
if (ok) {
var triples = [
$rdf.st(book, ns.vcard('includesGroup'), group, gix), // Pointer back to book
$rdf.st(group, ns.rdf('type'), ns.vcard('Group'), doc),
$rdf.st(group, ns.vcard('fn'), name, doc)
]
updater.put(doc, triples, 'text/turtle', function (uri, ok, body) {
callbackFunction(ok, ok ? group : "Can't save new group file " + doc + body)
})
} else {
callbackFunction(ok, 'Could not update group index ' + body) // fail
}
})
} else {
console.log('Error loading people index!' + gix.uri + ': ' + message)
callbackFunction(false, 'Error loading people index!' + gix.uri + ': ' + message + '\n')
}
})
} | [
"function",
"(",
"book",
",",
"name",
",",
"callbackFunction",
")",
"{",
"var",
"gix",
"=",
"kb",
".",
"any",
"(",
"book",
",",
"ns",
".",
"vcard",
"(",
"'groupIndex'",
")",
")",
"var",
"x",
"=",
"book",
".",
"uri",
".",
"split",
"(",
"'#'",
")",
"[",
"0",
"]",
"var",
"gname",
"=",
"name",
".",
"replace",
"(",
"' '",
",",
"'_'",
")",
"var",
"doc",
"=",
"kb",
".",
"sym",
"(",
"x",
".",
"slice",
"(",
"0",
",",
"x",
".",
"lastIndexOf",
"(",
"'/'",
")",
"+",
"1",
")",
"+",
"'Group/'",
"+",
"gname",
"+",
"'.ttl'",
")",
"var",
"group",
"=",
"kb",
".",
"sym",
"(",
"doc",
".",
"uri",
"+",
"'#this'",
")",
"console",
".",
"log",
"(",
"' New group will be: '",
"+",
"group",
"+",
"'\\n'",
")",
"\\n",
"}"
]
| Write new group to web Creates an empty new group file and adds it to the index | [
"Write",
"new",
"group",
"to",
"web",
"Creates",
"an",
"empty",
"new",
"group",
"file",
"and",
"adds",
"it",
"to",
"the",
"index"
]
| 373c55fc6e2c584603741ee972d036fcb1e2f4b8 | https://github.com/solid/contacts-pane/blob/373c55fc6e2c584603741ee972d036fcb1e2f4b8/contactsPane.js#L329-L366 | train |
|
solid/contacts-pane | contactsPane.js | function (x) {
var name = kb.any(x, ns.vcard('fn')) ||
kb.any(x, ns.foaf('name')) || kb.any(x, ns.vcard('organization-name'))
return name ? name.value : '???'
} | javascript | function (x) {
var name = kb.any(x, ns.vcard('fn')) ||
kb.any(x, ns.foaf('name')) || kb.any(x, ns.vcard('organization-name'))
return name ? name.value : '???'
} | [
"function",
"(",
"x",
")",
"{",
"var",
"name",
"=",
"kb",
".",
"any",
"(",
"x",
",",
"ns",
".",
"vcard",
"(",
"'fn'",
")",
")",
"||",
"kb",
".",
"any",
"(",
"x",
",",
"ns",
".",
"foaf",
"(",
"'name'",
")",
")",
"||",
"kb",
".",
"any",
"(",
"x",
",",
"ns",
".",
"vcard",
"(",
"'organization-name'",
")",
")",
"return",
"name",
"?",
"name",
".",
"value",
":",
"'???'",
"}"
]
| organization-name is a hack for Mac records with no FN which is mandatory. | [
"organization",
"-",
"name",
"is",
"a",
"hack",
"for",
"Mac",
"records",
"with",
"no",
"FN",
"which",
"is",
"mandatory",
"."
]
| 373c55fc6e2c584603741ee972d036fcb1e2f4b8 | https://github.com/solid/contacts-pane/blob/373c55fc6e2c584603741ee972d036fcb1e2f4b8/contactsPane.js#L369-L373 | train |
|
solid/contacts-pane | contactsPane.js | deleteThing | function deleteThing (x) {
console.log('deleteThing: ' + x)
var ds = kb.statementsMatching(x).concat(kb.statementsMatching(undefined, undefined, x))
var targets = {}
ds.map(function (st) { targets[st.why.uri] = st })
var agenda = [] // sets of statements of same dcoument to delete
for (var target in targets) {
agenda.push(ds.filter(function (st) { return st.why.uri === target }))
console.log(' Deleting ' + agenda[agenda.length - 1].length + ' triples from ' + target)
}
function nextOne () {
if (agenda.length > 0) {
updater.update(agenda.shift(), [], function (uri, ok, body) {
if (!ok) {
complain('Error deleting all trace of: ' + x + ': ' + body)
return
}
nextOne()
})
} else {
console.log('Deleting resoure ' + x.doc())
kb.fetcher.delete(x.doc())
.then(function () {
console.log('Delete thing ' + x + ': complete.')
})
.catch(function (e) {
complain('Error deleting thing ' + x + ': ' + e)
})
}
}
nextOne()
} | javascript | function deleteThing (x) {
console.log('deleteThing: ' + x)
var ds = kb.statementsMatching(x).concat(kb.statementsMatching(undefined, undefined, x))
var targets = {}
ds.map(function (st) { targets[st.why.uri] = st })
var agenda = [] // sets of statements of same dcoument to delete
for (var target in targets) {
agenda.push(ds.filter(function (st) { return st.why.uri === target }))
console.log(' Deleting ' + agenda[agenda.length - 1].length + ' triples from ' + target)
}
function nextOne () {
if (agenda.length > 0) {
updater.update(agenda.shift(), [], function (uri, ok, body) {
if (!ok) {
complain('Error deleting all trace of: ' + x + ': ' + body)
return
}
nextOne()
})
} else {
console.log('Deleting resoure ' + x.doc())
kb.fetcher.delete(x.doc())
.then(function () {
console.log('Delete thing ' + x + ': complete.')
})
.catch(function (e) {
complain('Error deleting thing ' + x + ': ' + e)
})
}
}
nextOne()
} | [
"function",
"deleteThing",
"(",
"x",
")",
"{",
"console",
".",
"log",
"(",
"'deleteThing: '",
"+",
"x",
")",
"var",
"ds",
"=",
"kb",
".",
"statementsMatching",
"(",
"x",
")",
".",
"concat",
"(",
"kb",
".",
"statementsMatching",
"(",
"undefined",
",",
"undefined",
",",
"x",
")",
")",
"var",
"targets",
"=",
"{",
"}",
"ds",
".",
"map",
"(",
"function",
"(",
"st",
")",
"{",
"targets",
"[",
"st",
".",
"why",
".",
"uri",
"]",
"=",
"st",
"}",
")",
"var",
"agenda",
"=",
"[",
"]",
"for",
"(",
"var",
"target",
"in",
"targets",
")",
"{",
"agenda",
".",
"push",
"(",
"ds",
".",
"filter",
"(",
"function",
"(",
"st",
")",
"{",
"return",
"st",
".",
"why",
".",
"uri",
"===",
"target",
"}",
")",
")",
"console",
".",
"log",
"(",
"' Deleting '",
"+",
"agenda",
"[",
"agenda",
".",
"length",
"-",
"1",
"]",
".",
"length",
"+",
"' triples from '",
"+",
"target",
")",
"}",
"function",
"nextOne",
"(",
")",
"{",
"if",
"(",
"agenda",
".",
"length",
">",
"0",
")",
"{",
"updater",
".",
"update",
"(",
"agenda",
".",
"shift",
"(",
")",
",",
"[",
"]",
",",
"function",
"(",
"uri",
",",
"ok",
",",
"body",
")",
"{",
"if",
"(",
"!",
"ok",
")",
"{",
"complain",
"(",
"'Error deleting all trace of: '",
"+",
"x",
"+",
"': '",
"+",
"body",
")",
"return",
"}",
"nextOne",
"(",
")",
"}",
")",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"'Deleting resoure '",
"+",
"x",
".",
"doc",
"(",
")",
")",
"kb",
".",
"fetcher",
".",
"delete",
"(",
"x",
".",
"doc",
"(",
")",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"console",
".",
"log",
"(",
"'Delete thing '",
"+",
"x",
"+",
"': complete.'",
")",
"}",
")",
".",
"catch",
"(",
"function",
"(",
"e",
")",
"{",
"complain",
"(",
"'Error deleting thing '",
"+",
"x",
"+",
"': '",
"+",
"e",
")",
"}",
")",
"}",
"}",
"nextOne",
"(",
")",
"}"
]
| In a LDP work, deletes the whole document describing a thing plus patch out ALL mentiosn of it! Use with care! beware of other dta picked up from other places being smushed together and then deleted. | [
"In",
"a",
"LDP",
"work",
"deletes",
"the",
"whole",
"document",
"describing",
"a",
"thing",
"plus",
"patch",
"out",
"ALL",
"mentiosn",
"of",
"it!",
"Use",
"with",
"care!",
"beware",
"of",
"other",
"dta",
"picked",
"up",
"from",
"other",
"places",
"being",
"smushed",
"together",
"and",
"then",
"deleted",
"."
]
| 373c55fc6e2c584603741ee972d036fcb1e2f4b8 | https://github.com/solid/contacts-pane/blob/373c55fc6e2c584603741ee972d036fcb1e2f4b8/contactsPane.js#L517-L548 | train |
solid/contacts-pane | contactsPane.js | deleteRecursive | function deleteRecursive (kb, folder) {
return new Promise(function (resolve, reject) {
kb.fetcher.load(folder).then(function () {
let promises = kb.each(folder, ns.ldp('contains')).map(file => {
if (kb.holds(file, ns.rdf('type'), ns.ldp('BasicContainer'))) {
return deleteRecursive(kb, file)
} else {
console.log('deleteRecirsive file: ' + file)
if (!confirm(' Really DELETE File ' + file)) {
throw new Error('User aborted delete file')
}
return kb.fetcher.webOperation('DELETE', file.uri)
}
})
console.log('deleteRecirsive folder: ' + folder)
if (!confirm(' Really DELETE folder ' + folder)) {
throw new Error('User aborted delete file')
}
promises.push(kb.fetcher.webOperation('DELETE', folder.uri))
Promise.all(promises).then(res => { resolve() })
})
})
} | javascript | function deleteRecursive (kb, folder) {
return new Promise(function (resolve, reject) {
kb.fetcher.load(folder).then(function () {
let promises = kb.each(folder, ns.ldp('contains')).map(file => {
if (kb.holds(file, ns.rdf('type'), ns.ldp('BasicContainer'))) {
return deleteRecursive(kb, file)
} else {
console.log('deleteRecirsive file: ' + file)
if (!confirm(' Really DELETE File ' + file)) {
throw new Error('User aborted delete file')
}
return kb.fetcher.webOperation('DELETE', file.uri)
}
})
console.log('deleteRecirsive folder: ' + folder)
if (!confirm(' Really DELETE folder ' + folder)) {
throw new Error('User aborted delete file')
}
promises.push(kb.fetcher.webOperation('DELETE', folder.uri))
Promise.all(promises).then(res => { resolve() })
})
})
} | [
"function",
"deleteRecursive",
"(",
"kb",
",",
"folder",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"kb",
".",
"fetcher",
".",
"load",
"(",
"folder",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"let",
"promises",
"=",
"kb",
".",
"each",
"(",
"folder",
",",
"ns",
".",
"ldp",
"(",
"'contains'",
")",
")",
".",
"map",
"(",
"file",
"=>",
"{",
"if",
"(",
"kb",
".",
"holds",
"(",
"file",
",",
"ns",
".",
"rdf",
"(",
"'type'",
")",
",",
"ns",
".",
"ldp",
"(",
"'BasicContainer'",
")",
")",
")",
"{",
"return",
"deleteRecursive",
"(",
"kb",
",",
"file",
")",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"'deleteRecirsive file: '",
"+",
"file",
")",
"if",
"(",
"!",
"confirm",
"(",
"' Really DELETE File '",
"+",
"file",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'User aborted delete file'",
")",
"}",
"return",
"kb",
".",
"fetcher",
".",
"webOperation",
"(",
"'DELETE'",
",",
"file",
".",
"uri",
")",
"}",
"}",
")",
"console",
".",
"log",
"(",
"'deleteRecirsive folder: '",
"+",
"folder",
")",
"if",
"(",
"!",
"confirm",
"(",
"' Really DELETE folder '",
"+",
"folder",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'User aborted delete file'",
")",
"}",
"promises",
".",
"push",
"(",
"kb",
".",
"fetcher",
".",
"webOperation",
"(",
"'DELETE'",
",",
"folder",
".",
"uri",
")",
")",
"Promise",
".",
"all",
"(",
"promises",
")",
".",
"then",
"(",
"res",
"=>",
"{",
"resolve",
"(",
")",
"}",
")",
"}",
")",
"}",
")",
"}"
]
| For deleting an addressbook sub-folder eg person - use with care! | [
"For",
"deleting",
"an",
"addressbook",
"sub",
"-",
"folder",
"eg",
"person",
"-",
"use",
"with",
"care!"
]
| 373c55fc6e2c584603741ee972d036fcb1e2f4b8 | https://github.com/solid/contacts-pane/blob/373c55fc6e2c584603741ee972d036fcb1e2f4b8/contactsPane.js#L552-L574 | train |
solid/contacts-pane | contactsPane.js | function (uris) {
uris.forEach(function (u) {
console.log('Dropped on group: ' + u)
var thing = kb.sym(u)
var toBeFetched = [thing.doc(), group.doc()]
kb.fetcher.load(toBeFetched).then(function (xhrs) {
var types = kb.findTypeURIs(thing)
for (var ty in types) {
console.log(' drop object type includes: ' + ty) // @@ Allow email addresses and phone numbers to be dropped?
}
if (ns.vcard('Individual').uri in types || ns.vcard('Organization').uri in types) {
var pname = kb.any(thing, ns.vcard('fn'))
if (!pname) return alert('No vcard name known for ' + thing)
var already = kb.holds(group, ns.vcard('hasMember'), thing, group.doc())
if (already) return alert('ALREADY added ' + pname + ' to group ' + name)
var message = 'Add ' + pname + ' to group ' + name + '?'
if (confirm(message)) {
var ins = [ $rdf.st(group, ns.vcard('hasMember'), thing, group.doc()),
$rdf.st(thing, ns.vcard('fn'), pname, group.doc())]
kb.updater.update([], ins, function (uri, ok, err) {
if (!ok) return complain('Error adding member to group ' + group + ': ' + err)
console.log('Added ' + pname + ' to group ' + name)
// @@ refresh UI
})
}
}
}).catch(function (e) {
complain('Error looking up dropped thing ' + thing + ' and group: ' + e)
})
})
} | javascript | function (uris) {
uris.forEach(function (u) {
console.log('Dropped on group: ' + u)
var thing = kb.sym(u)
var toBeFetched = [thing.doc(), group.doc()]
kb.fetcher.load(toBeFetched).then(function (xhrs) {
var types = kb.findTypeURIs(thing)
for (var ty in types) {
console.log(' drop object type includes: ' + ty) // @@ Allow email addresses and phone numbers to be dropped?
}
if (ns.vcard('Individual').uri in types || ns.vcard('Organization').uri in types) {
var pname = kb.any(thing, ns.vcard('fn'))
if (!pname) return alert('No vcard name known for ' + thing)
var already = kb.holds(group, ns.vcard('hasMember'), thing, group.doc())
if (already) return alert('ALREADY added ' + pname + ' to group ' + name)
var message = 'Add ' + pname + ' to group ' + name + '?'
if (confirm(message)) {
var ins = [ $rdf.st(group, ns.vcard('hasMember'), thing, group.doc()),
$rdf.st(thing, ns.vcard('fn'), pname, group.doc())]
kb.updater.update([], ins, function (uri, ok, err) {
if (!ok) return complain('Error adding member to group ' + group + ': ' + err)
console.log('Added ' + pname + ' to group ' + name)
// @@ refresh UI
})
}
}
}).catch(function (e) {
complain('Error looking up dropped thing ' + thing + ' and group: ' + e)
})
})
} | [
"function",
"(",
"uris",
")",
"{",
"uris",
".",
"forEach",
"(",
"function",
"(",
"u",
")",
"{",
"console",
".",
"log",
"(",
"'Dropped on group: '",
"+",
"u",
")",
"var",
"thing",
"=",
"kb",
".",
"sym",
"(",
"u",
")",
"var",
"toBeFetched",
"=",
"[",
"thing",
".",
"doc",
"(",
")",
",",
"group",
".",
"doc",
"(",
")",
"]",
"kb",
".",
"fetcher",
".",
"load",
"(",
"toBeFetched",
")",
".",
"then",
"(",
"function",
"(",
"xhrs",
")",
"{",
"var",
"types",
"=",
"kb",
".",
"findTypeURIs",
"(",
"thing",
")",
"for",
"(",
"var",
"ty",
"in",
"types",
")",
"{",
"console",
".",
"log",
"(",
"' drop object type includes: '",
"+",
"ty",
")",
"}",
"if",
"(",
"ns",
".",
"vcard",
"(",
"'Individual'",
")",
".",
"uri",
"in",
"types",
"||",
"ns",
".",
"vcard",
"(",
"'Organization'",
")",
".",
"uri",
"in",
"types",
")",
"{",
"var",
"pname",
"=",
"kb",
".",
"any",
"(",
"thing",
",",
"ns",
".",
"vcard",
"(",
"'fn'",
")",
")",
"if",
"(",
"!",
"pname",
")",
"return",
"alert",
"(",
"'No vcard name known for '",
"+",
"thing",
")",
"var",
"already",
"=",
"kb",
".",
"holds",
"(",
"group",
",",
"ns",
".",
"vcard",
"(",
"'hasMember'",
")",
",",
"thing",
",",
"group",
".",
"doc",
"(",
")",
")",
"if",
"(",
"already",
")",
"return",
"alert",
"(",
"'ALREADY added '",
"+",
"pname",
"+",
"' to group '",
"+",
"name",
")",
"var",
"message",
"=",
"'Add '",
"+",
"pname",
"+",
"' to group '",
"+",
"name",
"+",
"'?'",
"if",
"(",
"confirm",
"(",
"message",
")",
")",
"{",
"var",
"ins",
"=",
"[",
"$rdf",
".",
"st",
"(",
"group",
",",
"ns",
".",
"vcard",
"(",
"'hasMember'",
")",
",",
"thing",
",",
"group",
".",
"doc",
"(",
")",
")",
",",
"$rdf",
".",
"st",
"(",
"thing",
",",
"ns",
".",
"vcard",
"(",
"'fn'",
")",
",",
"pname",
",",
"group",
".",
"doc",
"(",
")",
")",
"]",
"kb",
".",
"updater",
".",
"update",
"(",
"[",
"]",
",",
"ins",
",",
"function",
"(",
"uri",
",",
"ok",
",",
"err",
")",
"{",
"if",
"(",
"!",
"ok",
")",
"return",
"complain",
"(",
"'Error adding member to group '",
"+",
"group",
"+",
"': '",
"+",
"err",
")",
"console",
".",
"log",
"(",
"'Added '",
"+",
"pname",
"+",
"' to group '",
"+",
"name",
")",
"}",
")",
"}",
"}",
"}",
")",
".",
"catch",
"(",
"function",
"(",
"e",
")",
"{",
"complain",
"(",
"'Error looking up dropped thing '",
"+",
"thing",
"+",
"' and group: '",
"+",
"e",
")",
"}",
")",
"}",
")",
"}"
]
| Is something is dropped on a group, add people to group | [
"Is",
"something",
"is",
"dropped",
"on",
"a",
"group",
"add",
"people",
"to",
"group"
]
| 373c55fc6e2c584603741ee972d036fcb1e2f4b8 | https://github.com/solid/contacts-pane/blob/373c55fc6e2c584603741ee972d036fcb1e2f4b8/contactsPane.js#L688-L719 | train |
|
solid/contacts-pane | contactsPane.js | function (uris) {
uris.map(function (u) {
var thing = $rdf.sym(u) // Attachment needs text label to disinguish I think not icon.
console.log('Dropped on mugshot thing ' + thing) // icon was: UI.icons.iconBase + 'noun_25830.svg'
if (u.startsWith('http') && u.indexOf('#') < 0) { // Plain document
// Take a copy of a photo on the web:
kb.fetcher.webOperation('GET', thing.uri).then(result => {
let contentType = result.headers.get('Content-Type')
// let data = result.responseText
let pathEnd = thing.uri.split('/').slice(-1)[0] // last segment as putative filename
pathEnd = pathEnd.split('?')[0] // chop off any query params
result.arrayBuffer().then(function (data) { // read text stream
if (!result.ok) {
complain('Error downloading ' + thing + ':' + result.status)
return
}
uploadFileToContact(pathEnd, contentType, data)
})
})
return
} else {
console.log('Not a web document URI, cannot copy as picture: ' + thing)
}
handleDroppedThing(thing)
})
} | javascript | function (uris) {
uris.map(function (u) {
var thing = $rdf.sym(u) // Attachment needs text label to disinguish I think not icon.
console.log('Dropped on mugshot thing ' + thing) // icon was: UI.icons.iconBase + 'noun_25830.svg'
if (u.startsWith('http') && u.indexOf('#') < 0) { // Plain document
// Take a copy of a photo on the web:
kb.fetcher.webOperation('GET', thing.uri).then(result => {
let contentType = result.headers.get('Content-Type')
// let data = result.responseText
let pathEnd = thing.uri.split('/').slice(-1)[0] // last segment as putative filename
pathEnd = pathEnd.split('?')[0] // chop off any query params
result.arrayBuffer().then(function (data) { // read text stream
if (!result.ok) {
complain('Error downloading ' + thing + ':' + result.status)
return
}
uploadFileToContact(pathEnd, contentType, data)
})
})
return
} else {
console.log('Not a web document URI, cannot copy as picture: ' + thing)
}
handleDroppedThing(thing)
})
} | [
"function",
"(",
"uris",
")",
"{",
"uris",
".",
"map",
"(",
"function",
"(",
"u",
")",
"{",
"var",
"thing",
"=",
"$rdf",
".",
"sym",
"(",
"u",
")",
"console",
".",
"log",
"(",
"'Dropped on mugshot thing '",
"+",
"thing",
")",
"if",
"(",
"u",
".",
"startsWith",
"(",
"'http'",
")",
"&&",
"u",
".",
"indexOf",
"(",
"'#'",
")",
"<",
"0",
")",
"{",
"kb",
".",
"fetcher",
".",
"webOperation",
"(",
"'GET'",
",",
"thing",
".",
"uri",
")",
".",
"then",
"(",
"result",
"=>",
"{",
"let",
"contentType",
"=",
"result",
".",
"headers",
".",
"get",
"(",
"'Content-Type'",
")",
"let",
"pathEnd",
"=",
"thing",
".",
"uri",
".",
"split",
"(",
"'/'",
")",
".",
"slice",
"(",
"-",
"1",
")",
"[",
"0",
"]",
"pathEnd",
"=",
"pathEnd",
".",
"split",
"(",
"'?'",
")",
"[",
"0",
"]",
"result",
".",
"arrayBuffer",
"(",
")",
".",
"then",
"(",
"function",
"(",
"data",
")",
"{",
"if",
"(",
"!",
"result",
".",
"ok",
")",
"{",
"complain",
"(",
"'Error downloading '",
"+",
"thing",
"+",
"':'",
"+",
"result",
".",
"status",
")",
"return",
"}",
"uploadFileToContact",
"(",
"pathEnd",
",",
"contentType",
",",
"data",
")",
"}",
")",
"}",
")",
"return",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"'Not a web document URI, cannot copy as picture: '",
"+",
"thing",
")",
"}",
"handleDroppedThing",
"(",
"thing",
")",
"}",
")",
"}"
]
| When a set of URIs are dropped on | [
"When",
"a",
"set",
"of",
"URIs",
"are",
"dropped",
"on"
]
| 373c55fc6e2c584603741ee972d036fcb1e2f4b8 | https://github.com/solid/contacts-pane/blob/373c55fc6e2c584603741ee972d036fcb1e2f4b8/contactsPane.js#L1050-L1075 | train |
|
solid/contacts-pane | contactsPane.js | function (files) {
for (var i = 0; i < files.length; i++) {
let f = files[i]
console.log(' meeting: Filename: ' + f.name + ', type: ' + (f.type || 'n/a') +
' size: ' + f.size + ' bytes, last modified: ' +
(f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a')
) // See e.g. https://www.html5rocks.com/en/tutorials/file/dndfiles/
// @@ Add: progress bar(s)
var reader = new FileReader()
reader.onload = (function (theFile) {
return function (e) {
var data = e.target.result
console.log(' File read byteLength : ' + data.byteLength)
var filename = encodeURIComponent(theFile.name)
var contentType = theFile.type
uploadFileToContact(filename, contentType, data)
}
})(f)
reader.readAsArrayBuffer(f)
}
} | javascript | function (files) {
for (var i = 0; i < files.length; i++) {
let f = files[i]
console.log(' meeting: Filename: ' + f.name + ', type: ' + (f.type || 'n/a') +
' size: ' + f.size + ' bytes, last modified: ' +
(f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a')
) // See e.g. https://www.html5rocks.com/en/tutorials/file/dndfiles/
// @@ Add: progress bar(s)
var reader = new FileReader()
reader.onload = (function (theFile) {
return function (e) {
var data = e.target.result
console.log(' File read byteLength : ' + data.byteLength)
var filename = encodeURIComponent(theFile.name)
var contentType = theFile.type
uploadFileToContact(filename, contentType, data)
}
})(f)
reader.readAsArrayBuffer(f)
}
} | [
"function",
"(",
"files",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"files",
".",
"length",
";",
"i",
"++",
")",
"{",
"let",
"f",
"=",
"files",
"[",
"i",
"]",
"console",
".",
"log",
"(",
"' meeting: Filename: '",
"+",
"f",
".",
"name",
"+",
"', type: '",
"+",
"(",
"f",
".",
"type",
"||",
"'n/a'",
")",
"+",
"' size: '",
"+",
"f",
".",
"size",
"+",
"' bytes, last modified: '",
"+",
"(",
"f",
".",
"lastModifiedDate",
"?",
"f",
".",
"lastModifiedDate",
".",
"toLocaleDateString",
"(",
")",
":",
"'n/a'",
")",
")",
"var",
"reader",
"=",
"new",
"FileReader",
"(",
")",
"reader",
".",
"onload",
"=",
"(",
"function",
"(",
"theFile",
")",
"{",
"return",
"function",
"(",
"e",
")",
"{",
"var",
"data",
"=",
"e",
".",
"target",
".",
"result",
"console",
".",
"log",
"(",
"' File read byteLength : '",
"+",
"data",
".",
"byteLength",
")",
"var",
"filename",
"=",
"encodeURIComponent",
"(",
"theFile",
".",
"name",
")",
"var",
"contentType",
"=",
"theFile",
".",
"type",
"uploadFileToContact",
"(",
"filename",
",",
"contentType",
",",
"data",
")",
"}",
"}",
")",
"(",
"f",
")",
"reader",
".",
"readAsArrayBuffer",
"(",
"f",
")",
"}",
"}"
]
| Drop an image file to set up the mugshot | [
"Drop",
"an",
"image",
"file",
"to",
"set",
"up",
"the",
"mugshot"
]
| 373c55fc6e2c584603741ee972d036fcb1e2f4b8 | https://github.com/solid/contacts-pane/blob/373c55fc6e2c584603741ee972d036fcb1e2f4b8/contactsPane.js#L1078-L1099 | train |
|
solid/contacts-pane | contactsPane.js | function (thing, group) {
var pname = kb.any(thing, ns.vcard('fn'))
var gname = kb.any(group, ns.vcard('fn'))
var groups = kb.each(null, ns.vcard('hasMember'), thing)
if (groups.length < 2) {
alert('Must be a member of at least one group. Add to another group first.')
return
}
var message = 'Remove ' + pname + ' from group ' + gname + '?'
if (confirm(message)) {
var del = [ $rdf.st(group, ns.vcard('hasMember'), thing, group.doc()),
$rdf.st(thing, ns.vcard('fn'), pname, group.doc())]
kb.updater.update(del, [], function (uri, ok, err) {
if (!ok) return complain('Error removing member from group ' + group + ': ' + err)
console.log('Removed ' + pname + ' from group ' + gname)
syncGroupList()
})
}
} | javascript | function (thing, group) {
var pname = kb.any(thing, ns.vcard('fn'))
var gname = kb.any(group, ns.vcard('fn'))
var groups = kb.each(null, ns.vcard('hasMember'), thing)
if (groups.length < 2) {
alert('Must be a member of at least one group. Add to another group first.')
return
}
var message = 'Remove ' + pname + ' from group ' + gname + '?'
if (confirm(message)) {
var del = [ $rdf.st(group, ns.vcard('hasMember'), thing, group.doc()),
$rdf.st(thing, ns.vcard('fn'), pname, group.doc())]
kb.updater.update(del, [], function (uri, ok, err) {
if (!ok) return complain('Error removing member from group ' + group + ': ' + err)
console.log('Removed ' + pname + ' from group ' + gname)
syncGroupList()
})
}
} | [
"function",
"(",
"thing",
",",
"group",
")",
"{",
"var",
"pname",
"=",
"kb",
".",
"any",
"(",
"thing",
",",
"ns",
".",
"vcard",
"(",
"'fn'",
")",
")",
"var",
"gname",
"=",
"kb",
".",
"any",
"(",
"group",
",",
"ns",
".",
"vcard",
"(",
"'fn'",
")",
")",
"var",
"groups",
"=",
"kb",
".",
"each",
"(",
"null",
",",
"ns",
".",
"vcard",
"(",
"'hasMember'",
")",
",",
"thing",
")",
"if",
"(",
"groups",
".",
"length",
"<",
"2",
")",
"{",
"alert",
"(",
"'Must be a member of at least one group. Add to another group first.'",
")",
"return",
"}",
"var",
"message",
"=",
"'Remove '",
"+",
"pname",
"+",
"' from group '",
"+",
"gname",
"+",
"'?'",
"if",
"(",
"confirm",
"(",
"message",
")",
")",
"{",
"var",
"del",
"=",
"[",
"$rdf",
".",
"st",
"(",
"group",
",",
"ns",
".",
"vcard",
"(",
"'hasMember'",
")",
",",
"thing",
",",
"group",
".",
"doc",
"(",
")",
")",
",",
"$rdf",
".",
"st",
"(",
"thing",
",",
"ns",
".",
"vcard",
"(",
"'fn'",
")",
",",
"pname",
",",
"group",
".",
"doc",
"(",
")",
")",
"]",
"kb",
".",
"updater",
".",
"update",
"(",
"del",
",",
"[",
"]",
",",
"function",
"(",
"uri",
",",
"ok",
",",
"err",
")",
"{",
"if",
"(",
"!",
"ok",
")",
"return",
"complain",
"(",
"'Error removing member from group '",
"+",
"group",
"+",
"': '",
"+",
"err",
")",
"console",
".",
"log",
"(",
"'Removed '",
"+",
"pname",
"+",
"' from group '",
"+",
"gname",
")",
"syncGroupList",
"(",
")",
"}",
")",
"}",
"}"
]
| Remove a person from a group | [
"Remove",
"a",
"person",
"from",
"a",
"group"
]
| 373c55fc6e2c584603741ee972d036fcb1e2f4b8 | https://github.com/solid/contacts-pane/blob/373c55fc6e2c584603741ee972d036fcb1e2f4b8/contactsPane.js#L1241-L1259 | train |
|
quase/quasejs | packages/unit/src/core/global-env.js | diff | function diff( a, b ) {
let i, j, found = false, result = [];
for ( i = 0; i < a.length; i++ ) {
found = false;
for ( j = 0; j < b.length; j++ ) {
if ( a[ i ] === b[ j ] ) {
found = true;
break;
}
}
if ( !found ) {
result.push( a[ i ] );
}
}
return result;
} | javascript | function diff( a, b ) {
let i, j, found = false, result = [];
for ( i = 0; i < a.length; i++ ) {
found = false;
for ( j = 0; j < b.length; j++ ) {
if ( a[ i ] === b[ j ] ) {
found = true;
break;
}
}
if ( !found ) {
result.push( a[ i ] );
}
}
return result;
} | [
"function",
"diff",
"(",
"a",
",",
"b",
")",
"{",
"let",
"i",
",",
"j",
",",
"found",
"=",
"false",
",",
"result",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"a",
".",
"length",
";",
"i",
"++",
")",
"{",
"found",
"=",
"false",
";",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"b",
".",
"length",
";",
"j",
"++",
")",
"{",
"if",
"(",
"a",
"[",
"i",
"]",
"===",
"b",
"[",
"j",
"]",
")",
"{",
"found",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"found",
")",
"{",
"result",
".",
"push",
"(",
"a",
"[",
"i",
"]",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
]
| Returns a new Array with the elements that are in a but not in b | [
"Returns",
"a",
"new",
"Array",
"with",
"the",
"elements",
"that",
"are",
"in",
"a",
"but",
"not",
"in",
"b"
]
| a8f46d6648db13abf30bbb4800fe63b25e49e1b3 | https://github.com/quase/quasejs/blob/a8f46d6648db13abf30bbb4800fe63b25e49e1b3/packages/unit/src/core/global-env.js#L8-L25 | train |
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function(thingy) {
// simple DOM lookup utility function
if (typeof(thingy) == 'string') {
thingy = document.getElementById(thingy);
}
if (!thingy.addClass) {
// extend element with a few useful methods
thingy.hide = function() { this.style.display = 'none'; };
thingy.show = function() { this.style.display = ''; };
thingy.addClass = function(name) { this.removeClass(name); this.className += ' ' + name; };
thingy.removeClass = function(name) {
this.className = this.className.replace( new RegExp("\\s*" + name + "\\s*"), " ").replace(/^\s+/, '').replace(/\s+$/, '');
};
thingy.hasClass = function(name) {
return !!this.className.match( new RegExp("\\s*" + name + "\\s*") );
};
}
return thingy;
} | javascript | function(thingy) {
// simple DOM lookup utility function
if (typeof(thingy) == 'string') {
thingy = document.getElementById(thingy);
}
if (!thingy.addClass) {
// extend element with a few useful methods
thingy.hide = function() { this.style.display = 'none'; };
thingy.show = function() { this.style.display = ''; };
thingy.addClass = function(name) { this.removeClass(name); this.className += ' ' + name; };
thingy.removeClass = function(name) {
this.className = this.className.replace( new RegExp("\\s*" + name + "\\s*"), " ").replace(/^\s+/, '').replace(/\s+$/, '');
};
thingy.hasClass = function(name) {
return !!this.className.match( new RegExp("\\s*" + name + "\\s*") );
};
}
return thingy;
} | [
"function",
"(",
"thingy",
")",
"{",
"if",
"(",
"typeof",
"(",
"thingy",
")",
"==",
"'string'",
")",
"{",
"thingy",
"=",
"document",
".",
"getElementById",
"(",
"thingy",
")",
";",
"}",
"if",
"(",
"!",
"thingy",
".",
"addClass",
")",
"{",
"thingy",
".",
"hide",
"=",
"function",
"(",
")",
"{",
"this",
".",
"style",
".",
"display",
"=",
"'none'",
";",
"}",
";",
"thingy",
".",
"show",
"=",
"function",
"(",
")",
"{",
"this",
".",
"style",
".",
"display",
"=",
"''",
";",
"}",
";",
"thingy",
".",
"addClass",
"=",
"function",
"(",
"name",
")",
"{",
"this",
".",
"removeClass",
"(",
"name",
")",
";",
"this",
".",
"className",
"+=",
"' '",
"+",
"name",
";",
"}",
";",
"thingy",
".",
"removeClass",
"=",
"function",
"(",
"name",
")",
"{",
"this",
".",
"className",
"=",
"this",
".",
"className",
".",
"replace",
"(",
"new",
"RegExp",
"(",
"\"\\\\s*\"",
"+",
"\\\\",
"+",
"name",
")",
",",
"\"\\\\s*\"",
")",
".",
"\\\\",
"\" \"",
".",
"replace",
"(",
"/",
"^\\s+",
"/",
",",
"''",
")",
";",
"}",
";",
"replace",
"}",
"(",
"/",
"\\s+$",
"/",
",",
"''",
")",
"}"
]
| ID of next movie | [
"ID",
"of",
"next",
"movie"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L52-L70 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ( filtered )
{
var
out = [],
data = this.s.dt.aoData,
displayed = this.s.dt.aiDisplay,
i, iLen;
if ( filtered )
{
// Only consider filtered rows
for ( i=0, iLen=displayed.length ; i<iLen ; i++ )
{
if ( data[ displayed[i] ]._DTTT_selected )
{
out.push( displayed[i] );
}
}
}
else
{
// Use all rows
for ( i=0, iLen=data.length ; i<iLen ; i++ )
{
if ( data[i]._DTTT_selected )
{
out.push( i );
}
}
}
return out;
} | javascript | function ( filtered )
{
var
out = [],
data = this.s.dt.aoData,
displayed = this.s.dt.aiDisplay,
i, iLen;
if ( filtered )
{
// Only consider filtered rows
for ( i=0, iLen=displayed.length ; i<iLen ; i++ )
{
if ( data[ displayed[i] ]._DTTT_selected )
{
out.push( displayed[i] );
}
}
}
else
{
// Use all rows
for ( i=0, iLen=data.length ; i<iLen ; i++ )
{
if ( data[i]._DTTT_selected )
{
out.push( i );
}
}
}
return out;
} | [
"function",
"(",
"filtered",
")",
"{",
"var",
"out",
"=",
"[",
"]",
",",
"data",
"=",
"this",
".",
"s",
".",
"dt",
".",
"aoData",
",",
"displayed",
"=",
"this",
".",
"s",
".",
"dt",
".",
"aiDisplay",
",",
"i",
",",
"iLen",
";",
"if",
"(",
"filtered",
")",
"{",
"for",
"(",
"i",
"=",
"0",
",",
"iLen",
"=",
"displayed",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"if",
"(",
"data",
"[",
"displayed",
"[",
"i",
"]",
"]",
".",
"_DTTT_selected",
")",
"{",
"out",
".",
"push",
"(",
"displayed",
"[",
"i",
"]",
")",
";",
"}",
"}",
"}",
"else",
"{",
"for",
"(",
"i",
"=",
"0",
",",
"iLen",
"=",
"data",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"if",
"(",
"data",
"[",
"i",
"]",
".",
"_DTTT_selected",
")",
"{",
"out",
".",
"push",
"(",
"i",
")",
";",
"}",
"}",
"}",
"return",
"out",
";",
"}"
]
| Get the indexes of the selected rows
@returns {array} List of row indexes
@param {boolean} [filtered=false] Get only selected rows which are
available given the filtering applied to the table. By default
this is false - i.e. all rows, regardless of filtering are
selected. | [
"Get",
"the",
"indexes",
"of",
"the",
"selected",
"rows"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L829-L861 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ( n )
{
var pos = this.s.dt.oInstance.fnGetPosition( n );
return (this.s.dt.aoData[pos]._DTTT_selected===true) ? true : false;
} | javascript | function ( n )
{
var pos = this.s.dt.oInstance.fnGetPosition( n );
return (this.s.dt.aoData[pos]._DTTT_selected===true) ? true : false;
} | [
"function",
"(",
"n",
")",
"{",
"var",
"pos",
"=",
"this",
".",
"s",
".",
"dt",
".",
"oInstance",
".",
"fnGetPosition",
"(",
"n",
")",
";",
"return",
"(",
"this",
".",
"s",
".",
"dt",
".",
"aoData",
"[",
"pos",
"]",
".",
"_DTTT_selected",
"===",
"true",
")",
"?",
"true",
":",
"false",
";",
"}"
]
| Check to see if a current row is selected or not
@param {Node} n TR node to check if it is currently selected or not
@returns {Boolean} true if select, false otherwise | [
"Check",
"to",
"see",
"if",
"a",
"current",
"row",
"is",
"selected",
"or",
"not"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L869-L873 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function( oConfig )
{
var sTitle = "";
if ( typeof oConfig.sTitle != 'undefined' && oConfig.sTitle !== "" ) {
sTitle = oConfig.sTitle;
} else {
var anTitle = document.getElementsByTagName('title');
if ( anTitle.length > 0 )
{
sTitle = anTitle[0].innerHTML;
}
}
/* Strip characters which the OS will object to - checking for UTF8 support in the scripting
* engine
*/
if ( "\u00A1".toString().length < 4 ) {
return sTitle.replace(/[^a-zA-Z0-9_\u00A1-\uFFFF\.,\-_ !\(\)]/g, "");
} else {
return sTitle.replace(/[^a-zA-Z0-9_\.,\-_ !\(\)]/g, "");
}
} | javascript | function( oConfig )
{
var sTitle = "";
if ( typeof oConfig.sTitle != 'undefined' && oConfig.sTitle !== "" ) {
sTitle = oConfig.sTitle;
} else {
var anTitle = document.getElementsByTagName('title');
if ( anTitle.length > 0 )
{
sTitle = anTitle[0].innerHTML;
}
}
/* Strip characters which the OS will object to - checking for UTF8 support in the scripting
* engine
*/
if ( "\u00A1".toString().length < 4 ) {
return sTitle.replace(/[^a-zA-Z0-9_\u00A1-\uFFFF\.,\-_ !\(\)]/g, "");
} else {
return sTitle.replace(/[^a-zA-Z0-9_\.,\-_ !\(\)]/g, "");
}
} | [
"function",
"(",
"oConfig",
")",
"{",
"var",
"sTitle",
"=",
"\"\"",
";",
"if",
"(",
"typeof",
"oConfig",
".",
"sTitle",
"!=",
"'undefined'",
"&&",
"oConfig",
".",
"sTitle",
"!==",
"\"\"",
")",
"{",
"sTitle",
"=",
"oConfig",
".",
"sTitle",
";",
"}",
"else",
"{",
"var",
"anTitle",
"=",
"document",
".",
"getElementsByTagName",
"(",
"'title'",
")",
";",
"if",
"(",
"anTitle",
".",
"length",
">",
"0",
")",
"{",
"sTitle",
"=",
"anTitle",
"[",
"0",
"]",
".",
"innerHTML",
";",
"}",
"}",
"if",
"(",
"\"\\u00A1\"",
".",
"\\u00A1",
"toString",
".",
"(",
")",
"<",
"length",
")",
"4",
"else",
"{",
"return",
"sTitle",
".",
"replace",
"(",
"/",
"[^a-zA-Z0-9_\\u00A1-\\uFFFF\\.,\\-_ !\\(\\)]",
"/",
"g",
",",
"\"\"",
")",
";",
"}",
"}"
]
| Get the title of the document - useful for file names. The title is retrieved from either
the configuration object's 'title' parameter, or the HTML document title
@param {Object} oConfig Button configuration object
@returns {String} Button title | [
"Get",
"the",
"title",
"of",
"the",
"document",
"-",
"useful",
"for",
"file",
"names",
".",
"The",
"title",
"is",
"retrieved",
"from",
"either",
"the",
"configuration",
"object",
"s",
"title",
"parameter",
"or",
"the",
"HTML",
"document",
"title"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L939-L960 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ( oConfig )
{
var
aoCols = this.s.dt.aoColumns,
aColumnsInc = this._fnColumnTargets( oConfig.mColumns ),
aColWidths = [],
iWidth = 0, iTotal = 0, i, iLen;
for ( i=0, iLen=aColumnsInc.length ; i<iLen ; i++ )
{
if ( aColumnsInc[i] )
{
iWidth = aoCols[i].nTh.offsetWidth;
iTotal += iWidth;
aColWidths.push( iWidth );
}
}
for ( i=0, iLen=aColWidths.length ; i<iLen ; i++ )
{
aColWidths[i] = aColWidths[i] / iTotal;
}
return aColWidths.join('\t');
} | javascript | function ( oConfig )
{
var
aoCols = this.s.dt.aoColumns,
aColumnsInc = this._fnColumnTargets( oConfig.mColumns ),
aColWidths = [],
iWidth = 0, iTotal = 0, i, iLen;
for ( i=0, iLen=aColumnsInc.length ; i<iLen ; i++ )
{
if ( aColumnsInc[i] )
{
iWidth = aoCols[i].nTh.offsetWidth;
iTotal += iWidth;
aColWidths.push( iWidth );
}
}
for ( i=0, iLen=aColWidths.length ; i<iLen ; i++ )
{
aColWidths[i] = aColWidths[i] / iTotal;
}
return aColWidths.join('\t');
} | [
"function",
"(",
"oConfig",
")",
"{",
"var",
"aoCols",
"=",
"this",
".",
"s",
".",
"dt",
".",
"aoColumns",
",",
"aColumnsInc",
"=",
"this",
".",
"_fnColumnTargets",
"(",
"oConfig",
".",
"mColumns",
")",
",",
"aColWidths",
"=",
"[",
"]",
",",
"iWidth",
"=",
"0",
",",
"iTotal",
"=",
"0",
",",
"i",
",",
"iLen",
";",
"for",
"(",
"i",
"=",
"0",
",",
"iLen",
"=",
"aColumnsInc",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"if",
"(",
"aColumnsInc",
"[",
"i",
"]",
")",
"{",
"iWidth",
"=",
"aoCols",
"[",
"i",
"]",
".",
"nTh",
".",
"offsetWidth",
";",
"iTotal",
"+=",
"iWidth",
";",
"aColWidths",
".",
"push",
"(",
"iWidth",
")",
";",
"}",
"}",
"for",
"(",
"i",
"=",
"0",
",",
"iLen",
"=",
"aColWidths",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"aColWidths",
"[",
"i",
"]",
"=",
"aColWidths",
"[",
"i",
"]",
"/",
"iTotal",
";",
"}",
"return",
"aColWidths",
".",
"join",
"(",
"'\\t'",
")",
";",
"}"
]
| Calculate a unity array with the column width by proportion for a set of columns to be
included for a button. This is particularly useful for PDF creation, where we can use the
column widths calculated by the browser to size the columns in the PDF.
@param {Object} oConfig Button configuration object
@returns {Array} Unity array of column ratios | [
"Calculate",
"a",
"unity",
"array",
"with",
"the",
"column",
"width",
"by",
"proportion",
"for",
"a",
"set",
"of",
"columns",
"to",
"be",
"included",
"for",
"a",
"button",
".",
"This",
"is",
"particularly",
"useful",
"for",
"PDF",
"creation",
"where",
"we",
"can",
"use",
"the",
"column",
"widths",
"calculated",
"by",
"the",
"browser",
"to",
"size",
"the",
"columns",
"in",
"the",
"PDF",
"."
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L970-L994 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ()
{
for ( var cli in ZeroClipboard_TableTools.clients )
{
if ( cli )
{
var client = ZeroClipboard_TableTools.clients[cli];
if ( typeof client.domElement != 'undefined' &&
client.domElement.parentNode == this.dom.container &&
client.sized === false )
{
return true;
}
}
}
return false;
} | javascript | function ()
{
for ( var cli in ZeroClipboard_TableTools.clients )
{
if ( cli )
{
var client = ZeroClipboard_TableTools.clients[cli];
if ( typeof client.domElement != 'undefined' &&
client.domElement.parentNode == this.dom.container &&
client.sized === false )
{
return true;
}
}
}
return false;
} | [
"function",
"(",
")",
"{",
"for",
"(",
"var",
"cli",
"in",
"ZeroClipboard_TableTools",
".",
"clients",
")",
"{",
"if",
"(",
"cli",
")",
"{",
"var",
"client",
"=",
"ZeroClipboard_TableTools",
".",
"clients",
"[",
"cli",
"]",
";",
"if",
"(",
"typeof",
"client",
".",
"domElement",
"!=",
"'undefined'",
"&&",
"client",
".",
"domElement",
".",
"parentNode",
"==",
"this",
".",
"dom",
".",
"container",
"&&",
"client",
".",
"sized",
"===",
"false",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
]
| Check to see if any of the ZeroClipboard client's attached need to be resized | [
"Check",
"to",
"see",
"if",
"any",
"of",
"the",
"ZeroClipboard",
"client",
"s",
"attached",
"need",
"to",
"be",
"resized"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L1048-L1064 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ( bView, oConfig )
{
if ( oConfig === undefined )
{
oConfig = {};
}
if ( bView === undefined || bView )
{
this._fnPrintStart( oConfig );
}
else
{
this._fnPrintEnd();
}
} | javascript | function ( bView, oConfig )
{
if ( oConfig === undefined )
{
oConfig = {};
}
if ( bView === undefined || bView )
{
this._fnPrintStart( oConfig );
}
else
{
this._fnPrintEnd();
}
} | [
"function",
"(",
"bView",
",",
"oConfig",
")",
"{",
"if",
"(",
"oConfig",
"===",
"undefined",
")",
"{",
"oConfig",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"bView",
"===",
"undefined",
"||",
"bView",
")",
"{",
"this",
".",
"_fnPrintStart",
"(",
"oConfig",
")",
";",
"}",
"else",
"{",
"this",
".",
"_fnPrintEnd",
"(",
")",
";",
"}",
"}"
]
| Programmatically enable or disable the print view
@param {boolean} [bView=true] Show the print view if true or not given. If false, then
terminate the print view and return to normal.
@param {object} [oConfig={}] Configuration for the print view
@param {boolean} [oConfig.bShowAll=false] Show all rows in the table if true
@param {string} [oConfig.sInfo] Information message, displayed as an overlay to the
user to let them know what the print view is.
@param {string} [oConfig.sMessage] HTML string to show at the top of the document - will
be included in the printed document. | [
"Programmatically",
"enable",
"or",
"disable",
"the",
"print",
"view"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L1078-L1093 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ( message, time ) {
var info = $('<div/>')
.addClass( this.classes.print.info )
.html( message )
.appendTo( 'body' );
setTimeout( function() {
info.fadeOut( "normal", function() {
info.remove();
} );
}, time );
} | javascript | function ( message, time ) {
var info = $('<div/>')
.addClass( this.classes.print.info )
.html( message )
.appendTo( 'body' );
setTimeout( function() {
info.fadeOut( "normal", function() {
info.remove();
} );
}, time );
} | [
"function",
"(",
"message",
",",
"time",
")",
"{",
"var",
"info",
"=",
"$",
"(",
"'<div/>'",
")",
".",
"addClass",
"(",
"this",
".",
"classes",
".",
"print",
".",
"info",
")",
".",
"html",
"(",
"message",
")",
".",
"appendTo",
"(",
"'body'",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"info",
".",
"fadeOut",
"(",
"\"normal\"",
",",
"function",
"(",
")",
"{",
"info",
".",
"remove",
"(",
")",
";",
"}",
")",
";",
"}",
",",
"time",
")",
";",
"}"
]
| Show a message to the end user which is nicely styled
@param {string} message The HTML string to show to the user
@param {int} time The duration the message is to be shown on screen for (mS) | [
"Show",
"a",
"message",
"to",
"the",
"end",
"user",
"which",
"is",
"nicely",
"styled"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L1101-L1112 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ( oOpts )
{
/* Is this the master control instance or not? */
if ( typeof this.s.dt._TableToolsInit == 'undefined' )
{
this.s.master = true;
this.s.dt._TableToolsInit = true;
}
/* We can use the table node from comparisons to group controls */
this.dom.table = this.s.dt.nTable;
/* Clone the defaults and then the user options */
this.s.custom = $.extend( {}, TableTools.DEFAULTS, oOpts );
/* Flash file location */
this.s.swfPath = this.s.custom.sSwfPath;
if ( typeof ZeroClipboard_TableTools != 'undefined' )
{
ZeroClipboard_TableTools.moviePath = this.s.swfPath;
}
/* Table row selecting */
this.s.select.type = this.s.custom.sRowSelect;
this.s.select.preRowSelect = this.s.custom.fnPreRowSelect;
this.s.select.postSelected = this.s.custom.fnRowSelected;
this.s.select.postDeselected = this.s.custom.fnRowDeselected;
// Backwards compatibility - allow the user to specify a custom class in the initialiser
if ( this.s.custom.sSelectedClass )
{
this.classes.select.row = this.s.custom.sSelectedClass;
}
this.s.tags = this.s.custom.oTags;
/* Button set */
this.s.buttonSet = this.s.custom.aButtons;
} | javascript | function ( oOpts )
{
/* Is this the master control instance or not? */
if ( typeof this.s.dt._TableToolsInit == 'undefined' )
{
this.s.master = true;
this.s.dt._TableToolsInit = true;
}
/* We can use the table node from comparisons to group controls */
this.dom.table = this.s.dt.nTable;
/* Clone the defaults and then the user options */
this.s.custom = $.extend( {}, TableTools.DEFAULTS, oOpts );
/* Flash file location */
this.s.swfPath = this.s.custom.sSwfPath;
if ( typeof ZeroClipboard_TableTools != 'undefined' )
{
ZeroClipboard_TableTools.moviePath = this.s.swfPath;
}
/* Table row selecting */
this.s.select.type = this.s.custom.sRowSelect;
this.s.select.preRowSelect = this.s.custom.fnPreRowSelect;
this.s.select.postSelected = this.s.custom.fnRowSelected;
this.s.select.postDeselected = this.s.custom.fnRowDeselected;
// Backwards compatibility - allow the user to specify a custom class in the initialiser
if ( this.s.custom.sSelectedClass )
{
this.classes.select.row = this.s.custom.sSelectedClass;
}
this.s.tags = this.s.custom.oTags;
/* Button set */
this.s.buttonSet = this.s.custom.aButtons;
} | [
"function",
"(",
"oOpts",
")",
"{",
"if",
"(",
"typeof",
"this",
".",
"s",
".",
"dt",
".",
"_TableToolsInit",
"==",
"'undefined'",
")",
"{",
"this",
".",
"s",
".",
"master",
"=",
"true",
";",
"this",
".",
"s",
".",
"dt",
".",
"_TableToolsInit",
"=",
"true",
";",
"}",
"this",
".",
"dom",
".",
"table",
"=",
"this",
".",
"s",
".",
"dt",
".",
"nTable",
";",
"this",
".",
"s",
".",
"custom",
"=",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"TableTools",
".",
"DEFAULTS",
",",
"oOpts",
")",
";",
"this",
".",
"s",
".",
"swfPath",
"=",
"this",
".",
"s",
".",
"custom",
".",
"sSwfPath",
";",
"if",
"(",
"typeof",
"ZeroClipboard_TableTools",
"!=",
"'undefined'",
")",
"{",
"ZeroClipboard_TableTools",
".",
"moviePath",
"=",
"this",
".",
"s",
".",
"swfPath",
";",
"}",
"this",
".",
"s",
".",
"select",
".",
"type",
"=",
"this",
".",
"s",
".",
"custom",
".",
"sRowSelect",
";",
"this",
".",
"s",
".",
"select",
".",
"preRowSelect",
"=",
"this",
".",
"s",
".",
"custom",
".",
"fnPreRowSelect",
";",
"this",
".",
"s",
".",
"select",
".",
"postSelected",
"=",
"this",
".",
"s",
".",
"custom",
".",
"fnRowSelected",
";",
"this",
".",
"s",
".",
"select",
".",
"postDeselected",
"=",
"this",
".",
"s",
".",
"custom",
".",
"fnRowDeselected",
";",
"if",
"(",
"this",
".",
"s",
".",
"custom",
".",
"sSelectedClass",
")",
"{",
"this",
".",
"classes",
".",
"select",
".",
"row",
"=",
"this",
".",
"s",
".",
"custom",
".",
"sSelectedClass",
";",
"}",
"this",
".",
"s",
".",
"tags",
"=",
"this",
".",
"s",
".",
"custom",
".",
"oTags",
";",
"this",
".",
"s",
".",
"buttonSet",
"=",
"this",
".",
"s",
".",
"custom",
".",
"aButtons",
";",
"}"
]
| Take the user defined settings and the default settings and combine them.
@method _fnCustomiseSettings
@param {Object} oOpts Same as TableTools constructor
@returns void
@private | [
"Take",
"the",
"user",
"defined",
"settings",
"and",
"the",
"default",
"settings",
"and",
"combine",
"them",
"."
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L1184-L1222 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ( buttonSet, wrapper )
{
var buttonDef;
for ( var i=0, iLen=buttonSet.length ; i<iLen ; i++ )
{
if ( typeof buttonSet[i] == "string" )
{
if ( typeof TableTools.BUTTONS[ buttonSet[i] ] == 'undefined' )
{
alert( "TableTools: Warning - unknown button type: "+buttonSet[i] );
continue;
}
buttonDef = $.extend( {}, TableTools.BUTTONS[ buttonSet[i] ], true );
}
else
{
if ( typeof TableTools.BUTTONS[ buttonSet[i].sExtends ] == 'undefined' )
{
alert( "TableTools: Warning - unknown button type: "+buttonSet[i].sExtends );
continue;
}
var o = $.extend( {}, TableTools.BUTTONS[ buttonSet[i].sExtends ], true );
buttonDef = $.extend( o, buttonSet[i], true );
}
var button = this._fnCreateButton(
buttonDef,
$(wrapper).hasClass(this.classes.collection.container)
);
if ( button ) {
wrapper.appendChild( button );
}
}
} | javascript | function ( buttonSet, wrapper )
{
var buttonDef;
for ( var i=0, iLen=buttonSet.length ; i<iLen ; i++ )
{
if ( typeof buttonSet[i] == "string" )
{
if ( typeof TableTools.BUTTONS[ buttonSet[i] ] == 'undefined' )
{
alert( "TableTools: Warning - unknown button type: "+buttonSet[i] );
continue;
}
buttonDef = $.extend( {}, TableTools.BUTTONS[ buttonSet[i] ], true );
}
else
{
if ( typeof TableTools.BUTTONS[ buttonSet[i].sExtends ] == 'undefined' )
{
alert( "TableTools: Warning - unknown button type: "+buttonSet[i].sExtends );
continue;
}
var o = $.extend( {}, TableTools.BUTTONS[ buttonSet[i].sExtends ], true );
buttonDef = $.extend( o, buttonSet[i], true );
}
var button = this._fnCreateButton(
buttonDef,
$(wrapper).hasClass(this.classes.collection.container)
);
if ( button ) {
wrapper.appendChild( button );
}
}
} | [
"function",
"(",
"buttonSet",
",",
"wrapper",
")",
"{",
"var",
"buttonDef",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"iLen",
"=",
"buttonSet",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"if",
"(",
"typeof",
"buttonSet",
"[",
"i",
"]",
"==",
"\"string\"",
")",
"{",
"if",
"(",
"typeof",
"TableTools",
".",
"BUTTONS",
"[",
"buttonSet",
"[",
"i",
"]",
"]",
"==",
"'undefined'",
")",
"{",
"alert",
"(",
"\"TableTools: Warning - unknown button type: \"",
"+",
"buttonSet",
"[",
"i",
"]",
")",
";",
"continue",
";",
"}",
"buttonDef",
"=",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"TableTools",
".",
"BUTTONS",
"[",
"buttonSet",
"[",
"i",
"]",
"]",
",",
"true",
")",
";",
"}",
"else",
"{",
"if",
"(",
"typeof",
"TableTools",
".",
"BUTTONS",
"[",
"buttonSet",
"[",
"i",
"]",
".",
"sExtends",
"]",
"==",
"'undefined'",
")",
"{",
"alert",
"(",
"\"TableTools: Warning - unknown button type: \"",
"+",
"buttonSet",
"[",
"i",
"]",
".",
"sExtends",
")",
";",
"continue",
";",
"}",
"var",
"o",
"=",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"TableTools",
".",
"BUTTONS",
"[",
"buttonSet",
"[",
"i",
"]",
".",
"sExtends",
"]",
",",
"true",
")",
";",
"buttonDef",
"=",
"$",
".",
"extend",
"(",
"o",
",",
"buttonSet",
"[",
"i",
"]",
",",
"true",
")",
";",
"}",
"var",
"button",
"=",
"this",
".",
"_fnCreateButton",
"(",
"buttonDef",
",",
"$",
"(",
"wrapper",
")",
".",
"hasClass",
"(",
"this",
".",
"classes",
".",
"collection",
".",
"container",
")",
")",
";",
"if",
"(",
"button",
")",
"{",
"wrapper",
".",
"appendChild",
"(",
"button",
")",
";",
"}",
"}",
"}"
]
| Take the user input arrays and expand them to be fully defined, and then add them to a given
DOM element
@method _fnButtonDefinations
@param {array} buttonSet Set of user defined buttons
@param {node} wrapper Node to add the created buttons to
@returns void
@private | [
"Take",
"the",
"user",
"input",
"arrays",
"and",
"expand",
"them",
"to",
"be",
"fully",
"defined",
"and",
"then",
"add",
"them",
"to",
"a",
"given",
"DOM",
"element"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L1234-L1269 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ( oConfig, bCollectionButton )
{
var nButton = this._fnButtonBase( oConfig, bCollectionButton );
if ( oConfig.sAction.match(/flash/) )
{
if ( ! this._fnHasFlash() ) {
return false;
}
this._fnFlashConfig( nButton, oConfig );
}
else if ( oConfig.sAction == "text" )
{
this._fnTextConfig( nButton, oConfig );
}
else if ( oConfig.sAction == "div" )
{
this._fnTextConfig( nButton, oConfig );
}
else if ( oConfig.sAction == "collection" )
{
this._fnTextConfig( nButton, oConfig );
this._fnCollectionConfig( nButton, oConfig );
}
if ( this.s.dt.iTabIndex !== -1 ) {
$(nButton)
.attr( 'tabindex', this.s.dt.iTabIndex )
.attr( 'aria-controls', this.s.dt.sTableId )
.on( 'keyup.DTTT', function (e) {
// Trigger the click event on return key when focused.
// Note that for Flash buttons this has no effect since we
// can't programmatically trigger the Flash export
if ( e.keyCode === 13 ) {
e.stopPropagation();
$(this).trigger( 'click' );
}
} )
.on( 'mousedown.DTTT', function (e) {
// On mousedown we want to stop the focus occurring on the
// button, focus is used only for the keyboard navigation.
// But using preventDefault for the flash buttons stops the
// flash action. However, it is not the button that gets
// focused but the flash element for flash buttons, so this
// works
if ( ! oConfig.sAction.match(/flash/) ) {
e.preventDefault();
}
} );
}
return nButton;
} | javascript | function ( oConfig, bCollectionButton )
{
var nButton = this._fnButtonBase( oConfig, bCollectionButton );
if ( oConfig.sAction.match(/flash/) )
{
if ( ! this._fnHasFlash() ) {
return false;
}
this._fnFlashConfig( nButton, oConfig );
}
else if ( oConfig.sAction == "text" )
{
this._fnTextConfig( nButton, oConfig );
}
else if ( oConfig.sAction == "div" )
{
this._fnTextConfig( nButton, oConfig );
}
else if ( oConfig.sAction == "collection" )
{
this._fnTextConfig( nButton, oConfig );
this._fnCollectionConfig( nButton, oConfig );
}
if ( this.s.dt.iTabIndex !== -1 ) {
$(nButton)
.attr( 'tabindex', this.s.dt.iTabIndex )
.attr( 'aria-controls', this.s.dt.sTableId )
.on( 'keyup.DTTT', function (e) {
// Trigger the click event on return key when focused.
// Note that for Flash buttons this has no effect since we
// can't programmatically trigger the Flash export
if ( e.keyCode === 13 ) {
e.stopPropagation();
$(this).trigger( 'click' );
}
} )
.on( 'mousedown.DTTT', function (e) {
// On mousedown we want to stop the focus occurring on the
// button, focus is used only for the keyboard navigation.
// But using preventDefault for the flash buttons stops the
// flash action. However, it is not the button that gets
// focused but the flash element for flash buttons, so this
// works
if ( ! oConfig.sAction.match(/flash/) ) {
e.preventDefault();
}
} );
}
return nButton;
} | [
"function",
"(",
"oConfig",
",",
"bCollectionButton",
")",
"{",
"var",
"nButton",
"=",
"this",
".",
"_fnButtonBase",
"(",
"oConfig",
",",
"bCollectionButton",
")",
";",
"if",
"(",
"oConfig",
".",
"sAction",
".",
"match",
"(",
"/",
"flash",
"/",
")",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_fnHasFlash",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"this",
".",
"_fnFlashConfig",
"(",
"nButton",
",",
"oConfig",
")",
";",
"}",
"else",
"if",
"(",
"oConfig",
".",
"sAction",
"==",
"\"text\"",
")",
"{",
"this",
".",
"_fnTextConfig",
"(",
"nButton",
",",
"oConfig",
")",
";",
"}",
"else",
"if",
"(",
"oConfig",
".",
"sAction",
"==",
"\"div\"",
")",
"{",
"this",
".",
"_fnTextConfig",
"(",
"nButton",
",",
"oConfig",
")",
";",
"}",
"else",
"if",
"(",
"oConfig",
".",
"sAction",
"==",
"\"collection\"",
")",
"{",
"this",
".",
"_fnTextConfig",
"(",
"nButton",
",",
"oConfig",
")",
";",
"this",
".",
"_fnCollectionConfig",
"(",
"nButton",
",",
"oConfig",
")",
";",
"}",
"if",
"(",
"this",
".",
"s",
".",
"dt",
".",
"iTabIndex",
"!==",
"-",
"1",
")",
"{",
"$",
"(",
"nButton",
")",
".",
"attr",
"(",
"'tabindex'",
",",
"this",
".",
"s",
".",
"dt",
".",
"iTabIndex",
")",
".",
"attr",
"(",
"'aria-controls'",
",",
"this",
".",
"s",
".",
"dt",
".",
"sTableId",
")",
".",
"on",
"(",
"'keyup.DTTT'",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"keyCode",
"===",
"13",
")",
"{",
"e",
".",
"stopPropagation",
"(",
")",
";",
"$",
"(",
"this",
")",
".",
"trigger",
"(",
"'click'",
")",
";",
"}",
"}",
")",
".",
"on",
"(",
"'mousedown.DTTT'",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"!",
"oConfig",
".",
"sAction",
".",
"match",
"(",
"/",
"flash",
"/",
")",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
"return",
"nButton",
";",
"}"
]
| Create and configure a TableTools button
@method _fnCreateButton
@param {Object} oConfig Button configuration object
@returns {Node} Button element
@private | [
"Create",
"and",
"configure",
"a",
"TableTools",
"button"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L1279-L1333 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ( o, bCollectionButton )
{
var sTag, sLiner, sClass;
if ( bCollectionButton )
{
sTag = o.sTag && o.sTag !== "default" ? o.sTag : this.s.tags.collection.button;
sLiner = o.sLinerTag && o.sLinerTag !== "default" ? o.sLiner : this.s.tags.collection.liner;
sClass = this.classes.collection.buttons.normal;
}
else
{
sTag = o.sTag && o.sTag !== "default" ? o.sTag : this.s.tags.button;
sLiner = o.sLinerTag && o.sLinerTag !== "default" ? o.sLiner : this.s.tags.liner;
sClass = this.classes.buttons.normal;
}
var
nButton = document.createElement( sTag ),
nSpan = document.createElement( sLiner ),
masterS = this._fnGetMasterSettings();
nButton.className = sClass+" "+o.sButtonClass;
nButton.setAttribute('id', "ToolTables_"+this.s.dt.sInstance+"_"+masterS.buttonCounter );
nButton.appendChild( nSpan );
nSpan.innerHTML = o.sButtonText;
masterS.buttonCounter++;
return nButton;
} | javascript | function ( o, bCollectionButton )
{
var sTag, sLiner, sClass;
if ( bCollectionButton )
{
sTag = o.sTag && o.sTag !== "default" ? o.sTag : this.s.tags.collection.button;
sLiner = o.sLinerTag && o.sLinerTag !== "default" ? o.sLiner : this.s.tags.collection.liner;
sClass = this.classes.collection.buttons.normal;
}
else
{
sTag = o.sTag && o.sTag !== "default" ? o.sTag : this.s.tags.button;
sLiner = o.sLinerTag && o.sLinerTag !== "default" ? o.sLiner : this.s.tags.liner;
sClass = this.classes.buttons.normal;
}
var
nButton = document.createElement( sTag ),
nSpan = document.createElement( sLiner ),
masterS = this._fnGetMasterSettings();
nButton.className = sClass+" "+o.sButtonClass;
nButton.setAttribute('id', "ToolTables_"+this.s.dt.sInstance+"_"+masterS.buttonCounter );
nButton.appendChild( nSpan );
nSpan.innerHTML = o.sButtonText;
masterS.buttonCounter++;
return nButton;
} | [
"function",
"(",
"o",
",",
"bCollectionButton",
")",
"{",
"var",
"sTag",
",",
"sLiner",
",",
"sClass",
";",
"if",
"(",
"bCollectionButton",
")",
"{",
"sTag",
"=",
"o",
".",
"sTag",
"&&",
"o",
".",
"sTag",
"!==",
"\"default\"",
"?",
"o",
".",
"sTag",
":",
"this",
".",
"s",
".",
"tags",
".",
"collection",
".",
"button",
";",
"sLiner",
"=",
"o",
".",
"sLinerTag",
"&&",
"o",
".",
"sLinerTag",
"!==",
"\"default\"",
"?",
"o",
".",
"sLiner",
":",
"this",
".",
"s",
".",
"tags",
".",
"collection",
".",
"liner",
";",
"sClass",
"=",
"this",
".",
"classes",
".",
"collection",
".",
"buttons",
".",
"normal",
";",
"}",
"else",
"{",
"sTag",
"=",
"o",
".",
"sTag",
"&&",
"o",
".",
"sTag",
"!==",
"\"default\"",
"?",
"o",
".",
"sTag",
":",
"this",
".",
"s",
".",
"tags",
".",
"button",
";",
"sLiner",
"=",
"o",
".",
"sLinerTag",
"&&",
"o",
".",
"sLinerTag",
"!==",
"\"default\"",
"?",
"o",
".",
"sLiner",
":",
"this",
".",
"s",
".",
"tags",
".",
"liner",
";",
"sClass",
"=",
"this",
".",
"classes",
".",
"buttons",
".",
"normal",
";",
"}",
"var",
"nButton",
"=",
"document",
".",
"createElement",
"(",
"sTag",
")",
",",
"nSpan",
"=",
"document",
".",
"createElement",
"(",
"sLiner",
")",
",",
"masterS",
"=",
"this",
".",
"_fnGetMasterSettings",
"(",
")",
";",
"nButton",
".",
"className",
"=",
"sClass",
"+",
"\" \"",
"+",
"o",
".",
"sButtonClass",
";",
"nButton",
".",
"setAttribute",
"(",
"'id'",
",",
"\"ToolTables_\"",
"+",
"this",
".",
"s",
".",
"dt",
".",
"sInstance",
"+",
"\"_\"",
"+",
"masterS",
".",
"buttonCounter",
")",
";",
"nButton",
".",
"appendChild",
"(",
"nSpan",
")",
";",
"nSpan",
".",
"innerHTML",
"=",
"o",
".",
"sButtonText",
";",
"masterS",
".",
"buttonCounter",
"++",
";",
"return",
"nButton",
";",
"}"
]
| Create the DOM needed for the button and apply some base properties. All buttons start here
@method _fnButtonBase
@param {o} oConfig Button configuration object
@returns {Node} DIV element for the button
@private | [
"Create",
"the",
"DOM",
"needed",
"for",
"the",
"button",
"and",
"apply",
"some",
"base",
"properties",
".",
"All",
"buttons",
"start",
"here"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L1343-L1373 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ( nButton, oConfig )
{
var
that = this,
oPos = $(nButton).offset(),
nHidden = oConfig._collection,
iDivX = oPos.left,
iDivY = oPos.top + $(nButton).outerHeight(),
iWinHeight = $(window).height(), iDocHeight = $(document).height(),
iWinWidth = $(window).width(), iDocWidth = $(document).width();
nHidden.style.position = "absolute";
nHidden.style.left = iDivX+"px";
nHidden.style.top = iDivY+"px";
nHidden.style.display = "block";
$(nHidden).css('opacity',0);
var nBackground = document.createElement('div');
nBackground.style.position = "absolute";
nBackground.style.left = "0px";
nBackground.style.top = "0px";
nBackground.style.height = ((iWinHeight>iDocHeight)? iWinHeight : iDocHeight) +"px";
nBackground.style.width = ((iWinWidth>iDocWidth)? iWinWidth : iDocWidth) +"px";
nBackground.className = this.classes.collection.background;
$(nBackground).css('opacity',0);
document.body.appendChild( nBackground );
document.body.appendChild( nHidden );
/* Visual corrections to try and keep the collection visible */
var iDivWidth = $(nHidden).outerWidth();
var iDivHeight = $(nHidden).outerHeight();
if ( iDivX + iDivWidth > iDocWidth )
{
nHidden.style.left = (iDocWidth-iDivWidth)+"px";
}
if ( iDivY + iDivHeight > iDocHeight )
{
nHidden.style.top = (iDivY-iDivHeight-$(nButton).outerHeight())+"px";
}
this.dom.collection.collection = nHidden;
this.dom.collection.background = nBackground;
/* This results in a very small delay for the end user but it allows the animation to be
* much smoother. If you don't want the animation, then the setTimeout can be removed
*/
setTimeout( function () {
$(nHidden).animate({"opacity": 1}, 500);
$(nBackground).animate({"opacity": 0.25}, 500);
}, 10 );
/* Resize the buttons to the Flash contents fit */
this.fnResizeButtons();
/* Event handler to remove the collection display */
$(nBackground).click( function () {
that._fnCollectionHide.call( that, null, null );
} );
} | javascript | function ( nButton, oConfig )
{
var
that = this,
oPos = $(nButton).offset(),
nHidden = oConfig._collection,
iDivX = oPos.left,
iDivY = oPos.top + $(nButton).outerHeight(),
iWinHeight = $(window).height(), iDocHeight = $(document).height(),
iWinWidth = $(window).width(), iDocWidth = $(document).width();
nHidden.style.position = "absolute";
nHidden.style.left = iDivX+"px";
nHidden.style.top = iDivY+"px";
nHidden.style.display = "block";
$(nHidden).css('opacity',0);
var nBackground = document.createElement('div');
nBackground.style.position = "absolute";
nBackground.style.left = "0px";
nBackground.style.top = "0px";
nBackground.style.height = ((iWinHeight>iDocHeight)? iWinHeight : iDocHeight) +"px";
nBackground.style.width = ((iWinWidth>iDocWidth)? iWinWidth : iDocWidth) +"px";
nBackground.className = this.classes.collection.background;
$(nBackground).css('opacity',0);
document.body.appendChild( nBackground );
document.body.appendChild( nHidden );
/* Visual corrections to try and keep the collection visible */
var iDivWidth = $(nHidden).outerWidth();
var iDivHeight = $(nHidden).outerHeight();
if ( iDivX + iDivWidth > iDocWidth )
{
nHidden.style.left = (iDocWidth-iDivWidth)+"px";
}
if ( iDivY + iDivHeight > iDocHeight )
{
nHidden.style.top = (iDivY-iDivHeight-$(nButton).outerHeight())+"px";
}
this.dom.collection.collection = nHidden;
this.dom.collection.background = nBackground;
/* This results in a very small delay for the end user but it allows the animation to be
* much smoother. If you don't want the animation, then the setTimeout can be removed
*/
setTimeout( function () {
$(nHidden).animate({"opacity": 1}, 500);
$(nBackground).animate({"opacity": 0.25}, 500);
}, 10 );
/* Resize the buttons to the Flash contents fit */
this.fnResizeButtons();
/* Event handler to remove the collection display */
$(nBackground).click( function () {
that._fnCollectionHide.call( that, null, null );
} );
} | [
"function",
"(",
"nButton",
",",
"oConfig",
")",
"{",
"var",
"that",
"=",
"this",
",",
"oPos",
"=",
"$",
"(",
"nButton",
")",
".",
"offset",
"(",
")",
",",
"nHidden",
"=",
"oConfig",
".",
"_collection",
",",
"iDivX",
"=",
"oPos",
".",
"left",
",",
"iDivY",
"=",
"oPos",
".",
"top",
"+",
"$",
"(",
"nButton",
")",
".",
"outerHeight",
"(",
")",
",",
"iWinHeight",
"=",
"$",
"(",
"window",
")",
".",
"height",
"(",
")",
",",
"iDocHeight",
"=",
"$",
"(",
"document",
")",
".",
"height",
"(",
")",
",",
"iWinWidth",
"=",
"$",
"(",
"window",
")",
".",
"width",
"(",
")",
",",
"iDocWidth",
"=",
"$",
"(",
"document",
")",
".",
"width",
"(",
")",
";",
"nHidden",
".",
"style",
".",
"position",
"=",
"\"absolute\"",
";",
"nHidden",
".",
"style",
".",
"left",
"=",
"iDivX",
"+",
"\"px\"",
";",
"nHidden",
".",
"style",
".",
"top",
"=",
"iDivY",
"+",
"\"px\"",
";",
"nHidden",
".",
"style",
".",
"display",
"=",
"\"block\"",
";",
"$",
"(",
"nHidden",
")",
".",
"css",
"(",
"'opacity'",
",",
"0",
")",
";",
"var",
"nBackground",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"nBackground",
".",
"style",
".",
"position",
"=",
"\"absolute\"",
";",
"nBackground",
".",
"style",
".",
"left",
"=",
"\"0px\"",
";",
"nBackground",
".",
"style",
".",
"top",
"=",
"\"0px\"",
";",
"nBackground",
".",
"style",
".",
"height",
"=",
"(",
"(",
"iWinHeight",
">",
"iDocHeight",
")",
"?",
"iWinHeight",
":",
"iDocHeight",
")",
"+",
"\"px\"",
";",
"nBackground",
".",
"style",
".",
"width",
"=",
"(",
"(",
"iWinWidth",
">",
"iDocWidth",
")",
"?",
"iWinWidth",
":",
"iDocWidth",
")",
"+",
"\"px\"",
";",
"nBackground",
".",
"className",
"=",
"this",
".",
"classes",
".",
"collection",
".",
"background",
";",
"$",
"(",
"nBackground",
")",
".",
"css",
"(",
"'opacity'",
",",
"0",
")",
";",
"document",
".",
"body",
".",
"appendChild",
"(",
"nBackground",
")",
";",
"document",
".",
"body",
".",
"appendChild",
"(",
"nHidden",
")",
";",
"var",
"iDivWidth",
"=",
"$",
"(",
"nHidden",
")",
".",
"outerWidth",
"(",
")",
";",
"var",
"iDivHeight",
"=",
"$",
"(",
"nHidden",
")",
".",
"outerHeight",
"(",
")",
";",
"if",
"(",
"iDivX",
"+",
"iDivWidth",
">",
"iDocWidth",
")",
"{",
"nHidden",
".",
"style",
".",
"left",
"=",
"(",
"iDocWidth",
"-",
"iDivWidth",
")",
"+",
"\"px\"",
";",
"}",
"if",
"(",
"iDivY",
"+",
"iDivHeight",
">",
"iDocHeight",
")",
"{",
"nHidden",
".",
"style",
".",
"top",
"=",
"(",
"iDivY",
"-",
"iDivHeight",
"-",
"$",
"(",
"nButton",
")",
".",
"outerHeight",
"(",
")",
")",
"+",
"\"px\"",
";",
"}",
"this",
".",
"dom",
".",
"collection",
".",
"collection",
"=",
"nHidden",
";",
"this",
".",
"dom",
".",
"collection",
".",
"background",
"=",
"nBackground",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"$",
"(",
"nHidden",
")",
".",
"animate",
"(",
"{",
"\"opacity\"",
":",
"1",
"}",
",",
"500",
")",
";",
"$",
"(",
"nBackground",
")",
".",
"animate",
"(",
"{",
"\"opacity\"",
":",
"0.25",
"}",
",",
"500",
")",
";",
"}",
",",
"10",
")",
";",
"this",
".",
"fnResizeButtons",
"(",
")",
";",
"$",
"(",
"nBackground",
")",
".",
"click",
"(",
"function",
"(",
")",
"{",
"that",
".",
"_fnCollectionHide",
".",
"call",
"(",
"that",
",",
"null",
",",
"null",
")",
";",
"}",
")",
";",
"}"
]
| Show a button collection
@param {Node} nButton Button to use for the collection
@param {Object} oConfig Button configuration object
@returns void
@private | [
"Show",
"a",
"button",
"collection"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L1436-L1497 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ( nButton, oConfig )
{
if ( oConfig !== null && oConfig.sExtends == 'collection' )
{
return;
}
if ( this.dom.collection.collection !== null )
{
$(this.dom.collection.collection).animate({"opacity": 0}, 500, function (e) {
this.style.display = "none";
} );
$(this.dom.collection.background).animate({"opacity": 0}, 500, function (e) {
this.parentNode.removeChild( this );
} );
this.dom.collection.collection = null;
this.dom.collection.background = null;
}
} | javascript | function ( nButton, oConfig )
{
if ( oConfig !== null && oConfig.sExtends == 'collection' )
{
return;
}
if ( this.dom.collection.collection !== null )
{
$(this.dom.collection.collection).animate({"opacity": 0}, 500, function (e) {
this.style.display = "none";
} );
$(this.dom.collection.background).animate({"opacity": 0}, 500, function (e) {
this.parentNode.removeChild( this );
} );
this.dom.collection.collection = null;
this.dom.collection.background = null;
}
} | [
"function",
"(",
"nButton",
",",
"oConfig",
")",
"{",
"if",
"(",
"oConfig",
"!==",
"null",
"&&",
"oConfig",
".",
"sExtends",
"==",
"'collection'",
")",
"{",
"return",
";",
"}",
"if",
"(",
"this",
".",
"dom",
".",
"collection",
".",
"collection",
"!==",
"null",
")",
"{",
"$",
"(",
"this",
".",
"dom",
".",
"collection",
".",
"collection",
")",
".",
"animate",
"(",
"{",
"\"opacity\"",
":",
"0",
"}",
",",
"500",
",",
"function",
"(",
"e",
")",
"{",
"this",
".",
"style",
".",
"display",
"=",
"\"none\"",
";",
"}",
")",
";",
"$",
"(",
"this",
".",
"dom",
".",
"collection",
".",
"background",
")",
".",
"animate",
"(",
"{",
"\"opacity\"",
":",
"0",
"}",
",",
"500",
",",
"function",
"(",
"e",
")",
"{",
"this",
".",
"parentNode",
".",
"removeChild",
"(",
"this",
")",
";",
"}",
")",
";",
"this",
".",
"dom",
".",
"collection",
".",
"collection",
"=",
"null",
";",
"this",
".",
"dom",
".",
"collection",
".",
"background",
"=",
"null",
";",
"}",
"}"
]
| Hide a button collection
@param {Node} nButton Button to use for the collection
@param {Object} oConfig Button configuration object
@returns void
@private | [
"Hide",
"a",
"button",
"collection"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L1507-L1527 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ( src )
{
var out = [], pos, i, iLen;
if ( src.nodeName )
{
// Single node
pos = this.s.dt.oInstance.fnGetPosition( src );
out.push( this.s.dt.aoData[pos] );
}
else if ( typeof src.length !== 'undefined' )
{
// jQuery object or an array of nodes, or aoData points
for ( i=0, iLen=src.length ; i<iLen ; i++ )
{
if ( src[i].nodeName )
{
pos = this.s.dt.oInstance.fnGetPosition( src[i] );
out.push( this.s.dt.aoData[pos] );
}
else if ( typeof src[i] === 'number' )
{
out.push( this.s.dt.aoData[ src[i] ] );
}
else
{
out.push( src[i] );
}
}
return out;
}
else if ( typeof src === 'number' )
{
out.push(this.s.dt.aoData[src]);
}
else
{
// A single aoData point
out.push( src );
}
return out;
} | javascript | function ( src )
{
var out = [], pos, i, iLen;
if ( src.nodeName )
{
// Single node
pos = this.s.dt.oInstance.fnGetPosition( src );
out.push( this.s.dt.aoData[pos] );
}
else if ( typeof src.length !== 'undefined' )
{
// jQuery object or an array of nodes, or aoData points
for ( i=0, iLen=src.length ; i<iLen ; i++ )
{
if ( src[i].nodeName )
{
pos = this.s.dt.oInstance.fnGetPosition( src[i] );
out.push( this.s.dt.aoData[pos] );
}
else if ( typeof src[i] === 'number' )
{
out.push( this.s.dt.aoData[ src[i] ] );
}
else
{
out.push( src[i] );
}
}
return out;
}
else if ( typeof src === 'number' )
{
out.push(this.s.dt.aoData[src]);
}
else
{
// A single aoData point
out.push( src );
}
return out;
} | [
"function",
"(",
"src",
")",
"{",
"var",
"out",
"=",
"[",
"]",
",",
"pos",
",",
"i",
",",
"iLen",
";",
"if",
"(",
"src",
".",
"nodeName",
")",
"{",
"pos",
"=",
"this",
".",
"s",
".",
"dt",
".",
"oInstance",
".",
"fnGetPosition",
"(",
"src",
")",
";",
"out",
".",
"push",
"(",
"this",
".",
"s",
".",
"dt",
".",
"aoData",
"[",
"pos",
"]",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"src",
".",
"length",
"!==",
"'undefined'",
")",
"{",
"for",
"(",
"i",
"=",
"0",
",",
"iLen",
"=",
"src",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"if",
"(",
"src",
"[",
"i",
"]",
".",
"nodeName",
")",
"{",
"pos",
"=",
"this",
".",
"s",
".",
"dt",
".",
"oInstance",
".",
"fnGetPosition",
"(",
"src",
"[",
"i",
"]",
")",
";",
"out",
".",
"push",
"(",
"this",
".",
"s",
".",
"dt",
".",
"aoData",
"[",
"pos",
"]",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"src",
"[",
"i",
"]",
"===",
"'number'",
")",
"{",
"out",
".",
"push",
"(",
"this",
".",
"s",
".",
"dt",
".",
"aoData",
"[",
"src",
"[",
"i",
"]",
"]",
")",
";",
"}",
"else",
"{",
"out",
".",
"push",
"(",
"src",
"[",
"i",
"]",
")",
";",
"}",
"}",
"return",
"out",
";",
"}",
"else",
"if",
"(",
"typeof",
"src",
"===",
"'number'",
")",
"{",
"out",
".",
"push",
"(",
"this",
".",
"s",
".",
"dt",
".",
"aoData",
"[",
"src",
"]",
")",
";",
"}",
"else",
"{",
"out",
".",
"push",
"(",
"src",
")",
";",
"}",
"return",
"out",
";",
"}"
]
| Take a data source for row selection and convert it into aoData points for the DT
@param {*} src Can be a single DOM TR node, an array of TR nodes (including a
a jQuery object), a single aoData point from DataTables, an array of aoData
points or an array of aoData indexes
@returns {array} An array of aoData points | [
"Take",
"a",
"data",
"source",
"for",
"row",
"selection",
"and",
"convert",
"it",
"into",
"aoData",
"points",
"for",
"the",
"DT"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L1780-L1823 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ( nButton, oConfig )
{
var that = this;
var flash = new ZeroClipboard_TableTools.Client();
if ( oConfig.fnInit !== null )
{
oConfig.fnInit.call( this, nButton, oConfig );
}
flash.setHandCursor( true );
if ( oConfig.sAction == "flash_save" )
{
flash.setAction( 'save' );
flash.setCharSet( (oConfig.sCharSet=="utf16le") ? 'UTF16LE' : 'UTF8' );
flash.setBomInc( oConfig.bBomInc );
flash.setFileName( oConfig.sFileName.replace('*', this.fnGetTitle(oConfig)) );
}
else if ( oConfig.sAction == "flash_pdf" )
{
flash.setAction( 'pdf' );
flash.setFileName( oConfig.sFileName.replace('*', this.fnGetTitle(oConfig)) );
}
else
{
flash.setAction( 'copy' );
}
flash.addEventListener('mouseOver', function(client) {
if ( oConfig.fnMouseover !== null )
{
oConfig.fnMouseover.call( that, nButton, oConfig, flash );
}
} );
flash.addEventListener('mouseOut', function(client) {
if ( oConfig.fnMouseout !== null )
{
oConfig.fnMouseout.call( that, nButton, oConfig, flash );
}
} );
flash.addEventListener('mouseDown', function(client) {
if ( oConfig.fnClick !== null )
{
oConfig.fnClick.call( that, nButton, oConfig, flash );
}
} );
flash.addEventListener('complete', function (client, text) {
if ( oConfig.fnComplete !== null )
{
oConfig.fnComplete.call( that, nButton, oConfig, flash, text );
}
that._fnCollectionHide( nButton, oConfig );
} );
if ( oConfig.fnSelect !== null )
{
TableTools._fnEventListen( this, 'select', function (n) {
oConfig.fnSelect.call( that, nButton, oConfig, n );
} );
}
this._fnFlashGlue( flash, nButton, oConfig.sToolTip );
} | javascript | function ( nButton, oConfig )
{
var that = this;
var flash = new ZeroClipboard_TableTools.Client();
if ( oConfig.fnInit !== null )
{
oConfig.fnInit.call( this, nButton, oConfig );
}
flash.setHandCursor( true );
if ( oConfig.sAction == "flash_save" )
{
flash.setAction( 'save' );
flash.setCharSet( (oConfig.sCharSet=="utf16le") ? 'UTF16LE' : 'UTF8' );
flash.setBomInc( oConfig.bBomInc );
flash.setFileName( oConfig.sFileName.replace('*', this.fnGetTitle(oConfig)) );
}
else if ( oConfig.sAction == "flash_pdf" )
{
flash.setAction( 'pdf' );
flash.setFileName( oConfig.sFileName.replace('*', this.fnGetTitle(oConfig)) );
}
else
{
flash.setAction( 'copy' );
}
flash.addEventListener('mouseOver', function(client) {
if ( oConfig.fnMouseover !== null )
{
oConfig.fnMouseover.call( that, nButton, oConfig, flash );
}
} );
flash.addEventListener('mouseOut', function(client) {
if ( oConfig.fnMouseout !== null )
{
oConfig.fnMouseout.call( that, nButton, oConfig, flash );
}
} );
flash.addEventListener('mouseDown', function(client) {
if ( oConfig.fnClick !== null )
{
oConfig.fnClick.call( that, nButton, oConfig, flash );
}
} );
flash.addEventListener('complete', function (client, text) {
if ( oConfig.fnComplete !== null )
{
oConfig.fnComplete.call( that, nButton, oConfig, flash, text );
}
that._fnCollectionHide( nButton, oConfig );
} );
if ( oConfig.fnSelect !== null )
{
TableTools._fnEventListen( this, 'select', function (n) {
oConfig.fnSelect.call( that, nButton, oConfig, n );
} );
}
this._fnFlashGlue( flash, nButton, oConfig.sToolTip );
} | [
"function",
"(",
"nButton",
",",
"oConfig",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"flash",
"=",
"new",
"ZeroClipboard_TableTools",
".",
"Client",
"(",
")",
";",
"if",
"(",
"oConfig",
".",
"fnInit",
"!==",
"null",
")",
"{",
"oConfig",
".",
"fnInit",
".",
"call",
"(",
"this",
",",
"nButton",
",",
"oConfig",
")",
";",
"}",
"flash",
".",
"setHandCursor",
"(",
"true",
")",
";",
"if",
"(",
"oConfig",
".",
"sAction",
"==",
"\"flash_save\"",
")",
"{",
"flash",
".",
"setAction",
"(",
"'save'",
")",
";",
"flash",
".",
"setCharSet",
"(",
"(",
"oConfig",
".",
"sCharSet",
"==",
"\"utf16le\"",
")",
"?",
"'UTF16LE'",
":",
"'UTF8'",
")",
";",
"flash",
".",
"setBomInc",
"(",
"oConfig",
".",
"bBomInc",
")",
";",
"flash",
".",
"setFileName",
"(",
"oConfig",
".",
"sFileName",
".",
"replace",
"(",
"'*'",
",",
"this",
".",
"fnGetTitle",
"(",
"oConfig",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"oConfig",
".",
"sAction",
"==",
"\"flash_pdf\"",
")",
"{",
"flash",
".",
"setAction",
"(",
"'pdf'",
")",
";",
"flash",
".",
"setFileName",
"(",
"oConfig",
".",
"sFileName",
".",
"replace",
"(",
"'*'",
",",
"this",
".",
"fnGetTitle",
"(",
"oConfig",
")",
")",
")",
";",
"}",
"else",
"{",
"flash",
".",
"setAction",
"(",
"'copy'",
")",
";",
"}",
"flash",
".",
"addEventListener",
"(",
"'mouseOver'",
",",
"function",
"(",
"client",
")",
"{",
"if",
"(",
"oConfig",
".",
"fnMouseover",
"!==",
"null",
")",
"{",
"oConfig",
".",
"fnMouseover",
".",
"call",
"(",
"that",
",",
"nButton",
",",
"oConfig",
",",
"flash",
")",
";",
"}",
"}",
")",
";",
"flash",
".",
"addEventListener",
"(",
"'mouseOut'",
",",
"function",
"(",
"client",
")",
"{",
"if",
"(",
"oConfig",
".",
"fnMouseout",
"!==",
"null",
")",
"{",
"oConfig",
".",
"fnMouseout",
".",
"call",
"(",
"that",
",",
"nButton",
",",
"oConfig",
",",
"flash",
")",
";",
"}",
"}",
")",
";",
"flash",
".",
"addEventListener",
"(",
"'mouseDown'",
",",
"function",
"(",
"client",
")",
"{",
"if",
"(",
"oConfig",
".",
"fnClick",
"!==",
"null",
")",
"{",
"oConfig",
".",
"fnClick",
".",
"call",
"(",
"that",
",",
"nButton",
",",
"oConfig",
",",
"flash",
")",
";",
"}",
"}",
")",
";",
"flash",
".",
"addEventListener",
"(",
"'complete'",
",",
"function",
"(",
"client",
",",
"text",
")",
"{",
"if",
"(",
"oConfig",
".",
"fnComplete",
"!==",
"null",
")",
"{",
"oConfig",
".",
"fnComplete",
".",
"call",
"(",
"that",
",",
"nButton",
",",
"oConfig",
",",
"flash",
",",
"text",
")",
";",
"}",
"that",
".",
"_fnCollectionHide",
"(",
"nButton",
",",
"oConfig",
")",
";",
"}",
")",
";",
"if",
"(",
"oConfig",
".",
"fnSelect",
"!==",
"null",
")",
"{",
"TableTools",
".",
"_fnEventListen",
"(",
"this",
",",
"'select'",
",",
"function",
"(",
"n",
")",
"{",
"oConfig",
".",
"fnSelect",
".",
"call",
"(",
"that",
",",
"nButton",
",",
"oConfig",
",",
"n",
")",
";",
"}",
")",
";",
"}",
"this",
".",
"_fnFlashGlue",
"(",
"flash",
",",
"nButton",
",",
"oConfig",
".",
"sToolTip",
")",
";",
"}"
]
| Configure a flash based button for interaction events
@method _fnFlashConfig
@param {Node} nButton Button element which is being considered
@param {o} oConfig Button configuration object
@returns void
@private | [
"Configure",
"a",
"flash",
"based",
"button",
"for",
"interaction",
"events"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L1931-L1997 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ( clip, sData )
{
var asData = this._fnChunkData( sData, 8192 );
clip.clearText();
for ( var i=0, iLen=asData.length ; i<iLen ; i++ )
{
clip.appendText( asData[i] );
}
} | javascript | function ( clip, sData )
{
var asData = this._fnChunkData( sData, 8192 );
clip.clearText();
for ( var i=0, iLen=asData.length ; i<iLen ; i++ )
{
clip.appendText( asData[i] );
}
} | [
"function",
"(",
"clip",
",",
"sData",
")",
"{",
"var",
"asData",
"=",
"this",
".",
"_fnChunkData",
"(",
"sData",
",",
"8192",
")",
";",
"clip",
".",
"clearText",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"iLen",
"=",
"asData",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"clip",
".",
"appendText",
"(",
"asData",
"[",
"i",
"]",
")",
";",
"}",
"}"
]
| Set the text for the flash clip to deal with
This function is required for large information sets. There is a limit on the
amount of data that can be transferred between Javascript and Flash in a single call, so
we use this method to build up the text in Flash by sending over chunks. It is estimated
that the data limit is around 64k, although it is undocumented, and appears to be different
between different flash versions. We chunk at 8KiB.
@method _fnFlashSetText
@param {Object} clip the ZeroClipboard object
@param {String} sData the data to be set
@returns void
@private | [
"Set",
"the",
"text",
"for",
"the",
"flash",
"clip",
"to",
"deal",
"with"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L2042-L2051 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ( sData, sBoundary, regex )
{
if ( sBoundary === "" )
{
return sData;
}
else
{
return sBoundary + sData.replace(regex, sBoundary+sBoundary) + sBoundary;
}
} | javascript | function ( sData, sBoundary, regex )
{
if ( sBoundary === "" )
{
return sData;
}
else
{
return sBoundary + sData.replace(regex, sBoundary+sBoundary) + sBoundary;
}
} | [
"function",
"(",
"sData",
",",
"sBoundary",
",",
"regex",
")",
"{",
"if",
"(",
"sBoundary",
"===",
"\"\"",
")",
"{",
"return",
"sData",
";",
"}",
"else",
"{",
"return",
"sBoundary",
"+",
"sData",
".",
"replace",
"(",
"regex",
",",
"sBoundary",
"+",
"sBoundary",
")",
"+",
"sBoundary",
";",
"}",
"}"
]
| Wrap data up with a boundary string
@method _fnBoundData
@param {String} sData data to bound
@param {String} sBoundary bounding char(s)
@param {RegExp} regex search for the bounding chars - constructed outside for efficiency
in the loop
@returns {String} bound data
@private | [
"Wrap",
"data",
"up",
"with",
"a",
"boundary",
"string"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L2316-L2326 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ( sData, iSize )
{
var asReturn = [];
var iStrlen = sData.length;
for ( var i=0 ; i<iStrlen ; i+=iSize )
{
if ( i+iSize < iStrlen )
{
asReturn.push( sData.substring( i, i+iSize ) );
}
else
{
asReturn.push( sData.substring( i, iStrlen ) );
}
}
return asReturn;
} | javascript | function ( sData, iSize )
{
var asReturn = [];
var iStrlen = sData.length;
for ( var i=0 ; i<iStrlen ; i+=iSize )
{
if ( i+iSize < iStrlen )
{
asReturn.push( sData.substring( i, i+iSize ) );
}
else
{
asReturn.push( sData.substring( i, iStrlen ) );
}
}
return asReturn;
} | [
"function",
"(",
"sData",
",",
"iSize",
")",
"{",
"var",
"asReturn",
"=",
"[",
"]",
";",
"var",
"iStrlen",
"=",
"sData",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"iStrlen",
";",
"i",
"+=",
"iSize",
")",
"{",
"if",
"(",
"i",
"+",
"iSize",
"<",
"iStrlen",
")",
"{",
"asReturn",
".",
"push",
"(",
"sData",
".",
"substring",
"(",
"i",
",",
"i",
"+",
"iSize",
")",
")",
";",
"}",
"else",
"{",
"asReturn",
".",
"push",
"(",
"sData",
".",
"substring",
"(",
"i",
",",
"iStrlen",
")",
")",
";",
"}",
"}",
"return",
"asReturn",
";",
"}"
]
| Break a string up into an array of smaller strings
@method _fnChunkData
@param {String} sData data to be broken up
@param {Int} iSize chunk size
@returns {Array} String array of broken up text
@private | [
"Break",
"a",
"string",
"up",
"into",
"an",
"array",
"of",
"smaller",
"strings"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L2337-L2355 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ( sData )
{
if ( sData.indexOf('&') === -1 )
{
return sData;
}
var n = document.createElement('div');
return sData.replace( /&([^\s]*?);/g, function( match, match2 ) {
if ( match.substr(1, 1) === '#' )
{
return String.fromCharCode( Number(match2.substr(1)) );
}
else
{
n.innerHTML = match;
return n.childNodes[0].nodeValue;
}
} );
} | javascript | function ( sData )
{
if ( sData.indexOf('&') === -1 )
{
return sData;
}
var n = document.createElement('div');
return sData.replace( /&([^\s]*?);/g, function( match, match2 ) {
if ( match.substr(1, 1) === '#' )
{
return String.fromCharCode( Number(match2.substr(1)) );
}
else
{
n.innerHTML = match;
return n.childNodes[0].nodeValue;
}
} );
} | [
"function",
"(",
"sData",
")",
"{",
"if",
"(",
"sData",
".",
"indexOf",
"(",
"'&'",
")",
"===",
"-",
"1",
")",
"{",
"return",
"sData",
";",
"}",
"var",
"n",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"return",
"sData",
".",
"replace",
"(",
"/",
"&([^\\s]*?);",
"/",
"g",
",",
"function",
"(",
"match",
",",
"match2",
")",
"{",
"if",
"(",
"match",
".",
"substr",
"(",
"1",
",",
"1",
")",
"===",
"'#'",
")",
"{",
"return",
"String",
".",
"fromCharCode",
"(",
"Number",
"(",
"match2",
".",
"substr",
"(",
"1",
")",
")",
")",
";",
"}",
"else",
"{",
"n",
".",
"innerHTML",
"=",
"match",
";",
"return",
"n",
".",
"childNodes",
"[",
"0",
"]",
".",
"nodeValue",
";",
"}",
"}",
")",
";",
"}"
]
| Decode HTML entities
@method _fnHtmlDecode
@param {String} sData encoded string
@returns {String} decoded string
@private | [
"Decode",
"HTML",
"entities"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L2365-L2385 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ( e )
{
var that = this;
var oSetDT = this.s.dt;
var oSetPrint = this.s.print;
var oDomPrint = this.dom.print;
/* Show all hidden nodes */
this._fnPrintShowNodes();
/* Restore DataTables' scrolling */
if ( oSetDT.oScroll.sX !== "" || oSetDT.oScroll.sY !== "" )
{
$(this.s.dt.nTable).unbind('draw.DTTT_Print');
this._fnPrintScrollEnd();
}
/* Restore the scroll */
window.scrollTo( 0, oSetPrint.saveScroll );
/* Drop the print message */
$('div.'+this.classes.print.message).remove();
/* Styling class */
$(document.body).removeClass( 'DTTT_Print' );
/* Restore the table length */
oSetDT._iDisplayStart = oSetPrint.saveStart;
oSetDT._iDisplayLength = oSetPrint.saveLength;
if ( oSetDT.oApi._fnCalculateEnd ) {
oSetDT.oApi._fnCalculateEnd( oSetDT );
}
oSetDT.oApi._fnDraw( oSetDT );
$(document).unbind( "keydown.DTTT" );
} | javascript | function ( e )
{
var that = this;
var oSetDT = this.s.dt;
var oSetPrint = this.s.print;
var oDomPrint = this.dom.print;
/* Show all hidden nodes */
this._fnPrintShowNodes();
/* Restore DataTables' scrolling */
if ( oSetDT.oScroll.sX !== "" || oSetDT.oScroll.sY !== "" )
{
$(this.s.dt.nTable).unbind('draw.DTTT_Print');
this._fnPrintScrollEnd();
}
/* Restore the scroll */
window.scrollTo( 0, oSetPrint.saveScroll );
/* Drop the print message */
$('div.'+this.classes.print.message).remove();
/* Styling class */
$(document.body).removeClass( 'DTTT_Print' );
/* Restore the table length */
oSetDT._iDisplayStart = oSetPrint.saveStart;
oSetDT._iDisplayLength = oSetPrint.saveLength;
if ( oSetDT.oApi._fnCalculateEnd ) {
oSetDT.oApi._fnCalculateEnd( oSetDT );
}
oSetDT.oApi._fnDraw( oSetDT );
$(document).unbind( "keydown.DTTT" );
} | [
"function",
"(",
"e",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"oSetDT",
"=",
"this",
".",
"s",
".",
"dt",
";",
"var",
"oSetPrint",
"=",
"this",
".",
"s",
".",
"print",
";",
"var",
"oDomPrint",
"=",
"this",
".",
"dom",
".",
"print",
";",
"this",
".",
"_fnPrintShowNodes",
"(",
")",
";",
"if",
"(",
"oSetDT",
".",
"oScroll",
".",
"sX",
"!==",
"\"\"",
"||",
"oSetDT",
".",
"oScroll",
".",
"sY",
"!==",
"\"\"",
")",
"{",
"$",
"(",
"this",
".",
"s",
".",
"dt",
".",
"nTable",
")",
".",
"unbind",
"(",
"'draw.DTTT_Print'",
")",
";",
"this",
".",
"_fnPrintScrollEnd",
"(",
")",
";",
"}",
"window",
".",
"scrollTo",
"(",
"0",
",",
"oSetPrint",
".",
"saveScroll",
")",
";",
"$",
"(",
"'div.'",
"+",
"this",
".",
"classes",
".",
"print",
".",
"message",
")",
".",
"remove",
"(",
")",
";",
"$",
"(",
"document",
".",
"body",
")",
".",
"removeClass",
"(",
"'DTTT_Print'",
")",
";",
"oSetDT",
".",
"_iDisplayStart",
"=",
"oSetPrint",
".",
"saveStart",
";",
"oSetDT",
".",
"_iDisplayLength",
"=",
"oSetPrint",
".",
"saveLength",
";",
"if",
"(",
"oSetDT",
".",
"oApi",
".",
"_fnCalculateEnd",
")",
"{",
"oSetDT",
".",
"oApi",
".",
"_fnCalculateEnd",
"(",
"oSetDT",
")",
";",
"}",
"oSetDT",
".",
"oApi",
".",
"_fnDraw",
"(",
"oSetDT",
")",
";",
"$",
"(",
"document",
")",
".",
"unbind",
"(",
"\"keydown.DTTT\"",
")",
";",
"}"
]
| Printing is finished, resume normal display
@method _fnPrintEnd
@param {Event} e Event object
@returns void
@private | [
"Printing",
"is",
"finished",
"resume",
"normal",
"display"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L2495-L2531 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ()
{
var
oSetDT = this.s.dt,
nScrollHeadInner = oSetDT.nScrollHead.getElementsByTagName('div')[0],
nScrollHeadTable = nScrollHeadInner.getElementsByTagName('table')[0],
nScrollBody = oSetDT.nTable.parentNode,
nTheadSize, nTfootSize;
/* Copy the header in the thead in the body table, this way we show one single table when
* in print view. Note that this section of code is more or less verbatim from DT 1.7.0
*/
nTheadSize = oSetDT.nTable.getElementsByTagName('thead');
if ( nTheadSize.length > 0 )
{
oSetDT.nTable.removeChild( nTheadSize[0] );
}
if ( oSetDT.nTFoot !== null )
{
nTfootSize = oSetDT.nTable.getElementsByTagName('tfoot');
if ( nTfootSize.length > 0 )
{
oSetDT.nTable.removeChild( nTfootSize[0] );
}
}
nTheadSize = oSetDT.nTHead.cloneNode(true);
oSetDT.nTable.insertBefore( nTheadSize, oSetDT.nTable.childNodes[0] );
if ( oSetDT.nTFoot !== null )
{
nTfootSize = oSetDT.nTFoot.cloneNode(true);
oSetDT.nTable.insertBefore( nTfootSize, oSetDT.nTable.childNodes[1] );
}
/* Now adjust the table's viewport so we can actually see it */
if ( oSetDT.oScroll.sX !== "" )
{
oSetDT.nTable.style.width = $(oSetDT.nTable).outerWidth()+"px";
nScrollBody.style.width = $(oSetDT.nTable).outerWidth()+"px";
nScrollBody.style.overflow = "visible";
}
if ( oSetDT.oScroll.sY !== "" )
{
nScrollBody.style.height = $(oSetDT.nTable).outerHeight()+"px";
nScrollBody.style.overflow = "visible";
}
} | javascript | function ()
{
var
oSetDT = this.s.dt,
nScrollHeadInner = oSetDT.nScrollHead.getElementsByTagName('div')[0],
nScrollHeadTable = nScrollHeadInner.getElementsByTagName('table')[0],
nScrollBody = oSetDT.nTable.parentNode,
nTheadSize, nTfootSize;
/* Copy the header in the thead in the body table, this way we show one single table when
* in print view. Note that this section of code is more or less verbatim from DT 1.7.0
*/
nTheadSize = oSetDT.nTable.getElementsByTagName('thead');
if ( nTheadSize.length > 0 )
{
oSetDT.nTable.removeChild( nTheadSize[0] );
}
if ( oSetDT.nTFoot !== null )
{
nTfootSize = oSetDT.nTable.getElementsByTagName('tfoot');
if ( nTfootSize.length > 0 )
{
oSetDT.nTable.removeChild( nTfootSize[0] );
}
}
nTheadSize = oSetDT.nTHead.cloneNode(true);
oSetDT.nTable.insertBefore( nTheadSize, oSetDT.nTable.childNodes[0] );
if ( oSetDT.nTFoot !== null )
{
nTfootSize = oSetDT.nTFoot.cloneNode(true);
oSetDT.nTable.insertBefore( nTfootSize, oSetDT.nTable.childNodes[1] );
}
/* Now adjust the table's viewport so we can actually see it */
if ( oSetDT.oScroll.sX !== "" )
{
oSetDT.nTable.style.width = $(oSetDT.nTable).outerWidth()+"px";
nScrollBody.style.width = $(oSetDT.nTable).outerWidth()+"px";
nScrollBody.style.overflow = "visible";
}
if ( oSetDT.oScroll.sY !== "" )
{
nScrollBody.style.height = $(oSetDT.nTable).outerHeight()+"px";
nScrollBody.style.overflow = "visible";
}
} | [
"function",
"(",
")",
"{",
"var",
"oSetDT",
"=",
"this",
".",
"s",
".",
"dt",
",",
"nScrollHeadInner",
"=",
"oSetDT",
".",
"nScrollHead",
".",
"getElementsByTagName",
"(",
"'div'",
")",
"[",
"0",
"]",
",",
"nScrollHeadTable",
"=",
"nScrollHeadInner",
".",
"getElementsByTagName",
"(",
"'table'",
")",
"[",
"0",
"]",
",",
"nScrollBody",
"=",
"oSetDT",
".",
"nTable",
".",
"parentNode",
",",
"nTheadSize",
",",
"nTfootSize",
";",
"nTheadSize",
"=",
"oSetDT",
".",
"nTable",
".",
"getElementsByTagName",
"(",
"'thead'",
")",
";",
"if",
"(",
"nTheadSize",
".",
"length",
">",
"0",
")",
"{",
"oSetDT",
".",
"nTable",
".",
"removeChild",
"(",
"nTheadSize",
"[",
"0",
"]",
")",
";",
"}",
"if",
"(",
"oSetDT",
".",
"nTFoot",
"!==",
"null",
")",
"{",
"nTfootSize",
"=",
"oSetDT",
".",
"nTable",
".",
"getElementsByTagName",
"(",
"'tfoot'",
")",
";",
"if",
"(",
"nTfootSize",
".",
"length",
">",
"0",
")",
"{",
"oSetDT",
".",
"nTable",
".",
"removeChild",
"(",
"nTfootSize",
"[",
"0",
"]",
")",
";",
"}",
"}",
"nTheadSize",
"=",
"oSetDT",
".",
"nTHead",
".",
"cloneNode",
"(",
"true",
")",
";",
"oSetDT",
".",
"nTable",
".",
"insertBefore",
"(",
"nTheadSize",
",",
"oSetDT",
".",
"nTable",
".",
"childNodes",
"[",
"0",
"]",
")",
";",
"if",
"(",
"oSetDT",
".",
"nTFoot",
"!==",
"null",
")",
"{",
"nTfootSize",
"=",
"oSetDT",
".",
"nTFoot",
".",
"cloneNode",
"(",
"true",
")",
";",
"oSetDT",
".",
"nTable",
".",
"insertBefore",
"(",
"nTfootSize",
",",
"oSetDT",
".",
"nTable",
".",
"childNodes",
"[",
"1",
"]",
")",
";",
"}",
"if",
"(",
"oSetDT",
".",
"oScroll",
".",
"sX",
"!==",
"\"\"",
")",
"{",
"oSetDT",
".",
"nTable",
".",
"style",
".",
"width",
"=",
"$",
"(",
"oSetDT",
".",
"nTable",
")",
".",
"outerWidth",
"(",
")",
"+",
"\"px\"",
";",
"nScrollBody",
".",
"style",
".",
"width",
"=",
"$",
"(",
"oSetDT",
".",
"nTable",
")",
".",
"outerWidth",
"(",
")",
"+",
"\"px\"",
";",
"nScrollBody",
".",
"style",
".",
"overflow",
"=",
"\"visible\"",
";",
"}",
"if",
"(",
"oSetDT",
".",
"oScroll",
".",
"sY",
"!==",
"\"\"",
")",
"{",
"nScrollBody",
".",
"style",
".",
"height",
"=",
"$",
"(",
"oSetDT",
".",
"nTable",
")",
".",
"outerHeight",
"(",
")",
"+",
"\"px\"",
";",
"nScrollBody",
".",
"style",
".",
"overflow",
"=",
"\"visible\"",
";",
"}",
"}"
]
| Take account of scrolling in DataTables by showing the full table
@returns void
@private | [
"Take",
"account",
"of",
"scrolling",
"in",
"DataTables",
"by",
"showing",
"the",
"full",
"table"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L2539-L2588 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ()
{
var
oSetDT = this.s.dt,
nScrollBody = oSetDT.nTable.parentNode;
if ( oSetDT.oScroll.sX !== "" )
{
nScrollBody.style.width = oSetDT.oApi._fnStringToCss( oSetDT.oScroll.sX );
nScrollBody.style.overflow = "auto";
}
if ( oSetDT.oScroll.sY !== "" )
{
nScrollBody.style.height = oSetDT.oApi._fnStringToCss( oSetDT.oScroll.sY );
nScrollBody.style.overflow = "auto";
}
} | javascript | function ()
{
var
oSetDT = this.s.dt,
nScrollBody = oSetDT.nTable.parentNode;
if ( oSetDT.oScroll.sX !== "" )
{
nScrollBody.style.width = oSetDT.oApi._fnStringToCss( oSetDT.oScroll.sX );
nScrollBody.style.overflow = "auto";
}
if ( oSetDT.oScroll.sY !== "" )
{
nScrollBody.style.height = oSetDT.oApi._fnStringToCss( oSetDT.oScroll.sY );
nScrollBody.style.overflow = "auto";
}
} | [
"function",
"(",
")",
"{",
"var",
"oSetDT",
"=",
"this",
".",
"s",
".",
"dt",
",",
"nScrollBody",
"=",
"oSetDT",
".",
"nTable",
".",
"parentNode",
";",
"if",
"(",
"oSetDT",
".",
"oScroll",
".",
"sX",
"!==",
"\"\"",
")",
"{",
"nScrollBody",
".",
"style",
".",
"width",
"=",
"oSetDT",
".",
"oApi",
".",
"_fnStringToCss",
"(",
"oSetDT",
".",
"oScroll",
".",
"sX",
")",
";",
"nScrollBody",
".",
"style",
".",
"overflow",
"=",
"\"auto\"",
";",
"}",
"if",
"(",
"oSetDT",
".",
"oScroll",
".",
"sY",
"!==",
"\"\"",
")",
"{",
"nScrollBody",
".",
"style",
".",
"height",
"=",
"oSetDT",
".",
"oApi",
".",
"_fnStringToCss",
"(",
"oSetDT",
".",
"oScroll",
".",
"sY",
")",
";",
"nScrollBody",
".",
"style",
".",
"overflow",
"=",
"\"auto\"",
";",
"}",
"}"
]
| Take account of scrolling in DataTables by showing the full table. Note that the redraw of
the DataTable that we do will actually deal with the majority of the hard work here
@returns void
@private | [
"Take",
"account",
"of",
"scrolling",
"in",
"DataTables",
"by",
"showing",
"the",
"full",
"table",
".",
"Note",
"that",
"the",
"redraw",
"of",
"the",
"DataTable",
"that",
"we",
"do",
"will",
"actually",
"deal",
"with",
"the",
"majority",
"of",
"the",
"hard",
"work",
"here"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L2597-L2614 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ( )
{
var anHidden = this.dom.print.hidden;
for ( var i=0, iLen=anHidden.length ; i<iLen ; i++ )
{
anHidden[i].node.style.display = anHidden[i].display;
}
anHidden.splice( 0, anHidden.length );
} | javascript | function ( )
{
var anHidden = this.dom.print.hidden;
for ( var i=0, iLen=anHidden.length ; i<iLen ; i++ )
{
anHidden[i].node.style.display = anHidden[i].display;
}
anHidden.splice( 0, anHidden.length );
} | [
"function",
"(",
")",
"{",
"var",
"anHidden",
"=",
"this",
".",
"dom",
".",
"print",
".",
"hidden",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"iLen",
"=",
"anHidden",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"anHidden",
"[",
"i",
"]",
".",
"node",
".",
"style",
".",
"display",
"=",
"anHidden",
"[",
"i",
"]",
".",
"display",
";",
"}",
"anHidden",
".",
"splice",
"(",
"0",
",",
"anHidden",
".",
"length",
")",
";",
"}"
]
| Resume the display of all TableTools hidden nodes
@method _fnPrintShowNodes
@returns void
@private | [
"Resume",
"the",
"display",
"of",
"all",
"TableTools",
"hidden",
"nodes"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L2623-L2632 | train |
|
S3bb1/ah-dashboard-plugin | public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js | function ( nNode )
{
var anHidden = this.dom.print.hidden;
var nParent = nNode.parentNode;
var nChildren = nParent.childNodes;
for ( var i=0, iLen=nChildren.length ; i<iLen ; i++ )
{
if ( nChildren[i] != nNode && nChildren[i].nodeType == 1 )
{
/* If our node is shown (don't want to show nodes which were previously hidden) */
var sDisplay = $(nChildren[i]).css("display");
if ( sDisplay != "none" )
{
/* Cache the node and it's previous state so we can restore it */
anHidden.push( {
"node": nChildren[i],
"display": sDisplay
} );
nChildren[i].style.display = "none";
}
}
}
if ( nParent.nodeName.toUpperCase() != "BODY" )
{
this._fnPrintHideNodes( nParent );
}
} | javascript | function ( nNode )
{
var anHidden = this.dom.print.hidden;
var nParent = nNode.parentNode;
var nChildren = nParent.childNodes;
for ( var i=0, iLen=nChildren.length ; i<iLen ; i++ )
{
if ( nChildren[i] != nNode && nChildren[i].nodeType == 1 )
{
/* If our node is shown (don't want to show nodes which were previously hidden) */
var sDisplay = $(nChildren[i]).css("display");
if ( sDisplay != "none" )
{
/* Cache the node and it's previous state so we can restore it */
anHidden.push( {
"node": nChildren[i],
"display": sDisplay
} );
nChildren[i].style.display = "none";
}
}
}
if ( nParent.nodeName.toUpperCase() != "BODY" )
{
this._fnPrintHideNodes( nParent );
}
} | [
"function",
"(",
"nNode",
")",
"{",
"var",
"anHidden",
"=",
"this",
".",
"dom",
".",
"print",
".",
"hidden",
";",
"var",
"nParent",
"=",
"nNode",
".",
"parentNode",
";",
"var",
"nChildren",
"=",
"nParent",
".",
"childNodes",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"iLen",
"=",
"nChildren",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"if",
"(",
"nChildren",
"[",
"i",
"]",
"!=",
"nNode",
"&&",
"nChildren",
"[",
"i",
"]",
".",
"nodeType",
"==",
"1",
")",
"{",
"var",
"sDisplay",
"=",
"$",
"(",
"nChildren",
"[",
"i",
"]",
")",
".",
"css",
"(",
"\"display\"",
")",
";",
"if",
"(",
"sDisplay",
"!=",
"\"none\"",
")",
"{",
"anHidden",
".",
"push",
"(",
"{",
"\"node\"",
":",
"nChildren",
"[",
"i",
"]",
",",
"\"display\"",
":",
"sDisplay",
"}",
")",
";",
"nChildren",
"[",
"i",
"]",
".",
"style",
".",
"display",
"=",
"\"none\"",
";",
"}",
"}",
"}",
"if",
"(",
"nParent",
".",
"nodeName",
".",
"toUpperCase",
"(",
")",
"!=",
"\"BODY\"",
")",
"{",
"this",
".",
"_fnPrintHideNodes",
"(",
"nParent",
")",
";",
"}",
"}"
]
| Hide nodes which are not needed in order to display the table. Note that this function is
recursive
@method _fnPrintHideNodes
@param {Node} nNode Element which should be showing in a 'print' display
@returns void
@private | [
"Hide",
"nodes",
"which",
"are",
"not",
"needed",
"in",
"order",
"to",
"display",
"the",
"table",
".",
"Note",
"that",
"this",
"function",
"is",
"recursive"
]
| c283370ec0f99a25db5bb7029a98b4febf8c5251 | https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L2643-L2671 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.