_id
stringlengths 2
6
| title
stringlengths 0
58
| partition
stringclasses 3
values | text
stringlengths 52
373k
| language
stringclasses 1
value | meta_information
dict |
|---|---|---|---|---|---|
q45400
|
gaussian
|
train
|
function gaussian(src, s, kernelSize) {
if (typeof s === 'undefined') s = 1;
if (typeof kernelSize === 'undefined') kernelSize = 7;
var kernel = gaussianKernel1D(s, kernelSize),
l = kernelSize || kernel.length,
kernelH = [kernel],
kernelV = new Array(l);
for (var i = 0; i < l; i++) {
kernelV[i] = [kernel[i]];
}
return convolve(convolve(src, kernelH), kernelV);
}
|
javascript
|
{
"resource": ""
}
|
q45401
|
train
|
function(SOAPEnvelope, siteDataOperation) {
var siteDataOp = siteDataOperation.substring(8);
SOAPEnvelope.opheader = SOAPEnvelope.opheader.replace(siteDataOperation, siteDataOp);
SOAPEnvelope.opfooter = SOAPEnvelope.opfooter.replace(siteDataOperation, siteDataOp);
return SOAPEnvelope;
}
|
javascript
|
{
"resource": ""
}
|
|
q45402
|
getScriptAttribute
|
train
|
function getScriptAttribute(source, attribute) {
var matches;
var regex = RegExp(attribute + "=(\"([^\"]*)\")|('([^']*)')", "gi");
if (matches = regex.exec(source)) {
return matches[2];
}
return null;
}
|
javascript
|
{
"resource": ""
}
|
q45403
|
showAttrs
|
train
|
function showAttrs(node) {
var i;
var out = "<table class='ms-vb' width='100%'>";
for (i = 0; i < node.attributes.length; i++) {
out += "<tr><td width='10px' style='font-weight:bold;'>" + i + "</td><td width='100px'>" +
node.attributes.item(i).nodeName + "</td><td>" + checkLink(node.attributes.item(i).nodeValue) + "</td></tr>";
}
out += "</table>";
return out;
}
|
javascript
|
{
"resource": ""
}
|
q45404
|
errBox
|
train
|
function errBox(func, param, msg) {
var errMsg = "<b>Error in function</b><br/>" + func + "<br/>" +
"<b>Parameter</b><br/>" + param + "<br/>" +
"<b>Message</b><br/>" + msg + "<br/><br/>" +
"<span onmouseover='this.style.cursor=\"hand\";' onmouseout='this.style.cursor=\"inherit\";' style='width=100%;text-align:right;'>Click to continue</span></div>";
modalBox(errMsg);
}
|
javascript
|
{
"resource": ""
}
|
q45405
|
modalBox
|
train
|
function modalBox(msg) {
var boxCSS = "position:absolute;width:300px;height:150px;padding:10px;background-color:#000000;color:#ffffff;z-index:30;font-family:'Arial';font-size:12px;display:none;";
$("#aspnetForm").parent().append("<div id='SPServices_msgBox' style=" + boxCSS + ">" + msg);
var msgBoxObj = $("#SPServices_msgBox");
var height = msgBoxObj.height();
var width = msgBoxObj.width();
var leftVal = ($(window).width() / 2) - (width / 2) + "px";
var topVal = ($(window).height() / 2) - (height / 2) - 100 + "px";
msgBoxObj.css({
border: '5px #C02000 solid',
left: leftVal,
top: topVal
}).show().fadeTo("slow", 0.75).click(function () {
$(this).fadeOut("3000", function () {
$(this).remove();
});
});
}
|
javascript
|
{
"resource": ""
}
|
q45406
|
genContainerId
|
train
|
function genContainerId(funcname, columnName, listName) {
var l = listName !== undefined ? listName : $().SPServices.SPListNameFromUrl();
return funcname + "_" + $().SPServices.SPGetStaticFromDisplay({
listName: l,
columnDisplayName: columnName
});
}
|
javascript
|
{
"resource": ""
}
|
q45407
|
getListFormUrl
|
train
|
function getListFormUrl(l, f) {
var u;
$().SPServices({
operation: "GetFormCollection",
async: false,
listName: l,
completefunc: function (xData) {
u = $(xData.responseXML).find("Form[Type='" + f + "']").attr("Url");
}
});
return u;
}
|
javascript
|
{
"resource": ""
}
|
q45408
|
checkLink
|
train
|
function checkLink(s) {
return ((s.indexOf("http") === 0) || (s.indexOf(SLASH) === 0)) ? "<a href='" + s + "'>" + s + "</a>" : s;
}
|
javascript
|
{
"resource": ""
}
|
q45409
|
coreScript
|
train
|
function coreScript(src) {
var coreScriptLocations = ["WebResource.axd", "_layouts"];
for (var i = 0; i < coreScriptLocations.length; i++) {
if (src.indexOf(coreScriptLocations[i]) > -1) {
return true;
}
}
return false;
}
|
javascript
|
{
"resource": ""
}
|
q45410
|
getSvgHeight
|
train
|
function getSvgHeight (svg, filename) {
const parseSvg = /<svg[^>]+height\s*=\s*["']?(\d+)\s*(pt|px|)["']?/i.exec(svg);
if (!parseSvg) {
throw new Error(`could not read height for '${filename}'.`);
}
return parseSvg[1];
}
|
javascript
|
{
"resource": ""
}
|
q45411
|
train
|
function (address, cb) {
setupMultiserver()
ms_client.client(coearseAddress(address), function (err, stream) {
return err ? cb(err) : cb(null, setupRPC(stream, null, true))
})
}
|
javascript
|
{
"resource": ""
}
|
|
q45412
|
train
|
function (done) {
fs.readdir(globalConfig.root, function (err, files) {
if (err) return callback(err)
async.map(files, function (f, next) {
if (f !== 'apps' && f !== 'repos') {
f = globalConfig.root + '/' + f
pruned.push(f)
removeFile(f, next)
} else {
next()
}
}, done)
})
}
|
javascript
|
{
"resource": ""
}
|
|
q45413
|
initialize
|
train
|
function initialize(success, error, opts) {
console.log("AudioInputCaptureProxy: initialize: " + JSON.stringify(opts));
onInitialized = success;
if (!intialized) {
sampleRate = opts[0] || sampleRate;
bufferSize = opts[1] || bufferSize;
channels = opts[2] || channels;
format = opts[3] || format;
audioSourceType = opts[4] || audioSourceType;
fileUrl = opts[5] || fileUrl;
if (fileUrl) {
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
if (window.webkitStorageInfo && window.webkitStorageInfo.requestQuota) {
// Chrome/Android requires calling requestQuota first
window.webkitStorageInfo.requestQuota(
/file:\/\/\/temporary.*/.test(fileUrl) ? window.TEMPORARY : window.PERSISTENT,
10 * 1024 * 1024,
function (grantedBytes) {
console.log("AudioInputCaptureProxy: Granted " + grantedBytes + " bytes storage");
window.requestFileSystem(
/file:\/\/\/temporary.*/.test(fileUrl) ? window.TEMPORARY : window.PERSISTENT,
10 * 1024 * 1024,
function (fs) {
console.log("AudioInputCaptureProxy: Got file system: " + fs.name);
fileSystem = fs;
intialized = true;
onInitialized();
}, error);
}, error);
}
else {
// Firefox and Safari/iOS require calling requestFileSystem directly
window.requestFileSystem(
/file:\/\/\/temporary.*/.test(fileUrl) ? window.TEMPORARY : window.PERSISTENT,
10 * 1024 * 1024,
function (fs) {
console.log("AudioInputCaptureProxy: Got file system: " + fs.name);
fileSystem = fs;
intialized = true;
onInitialized();
}, error);
}
return;
} // fileUrl set
intialized = true;
} // !initialized
onInitialized();
}
|
javascript
|
{
"resource": ""
}
|
q45414
|
gotBuffers
|
train
|
function gotBuffers(wav) {
if (channels == 1) {
audioRecorder.exportMonoWAV(doneEncoding, wav);
}
else {
audioRecorder.exportWAV(doneEncoding, wav);
}
}
|
javascript
|
{
"resource": ""
}
|
q45415
|
train
|
function () {
if (window.cordova && window.cordova.file && window.audioinput) {
initUIEvents();
consoleMessage("Use 'Start Capture' to begin...");
// Subscribe to audioinput events
//
window.addEventListener('audioinput', onAudioInputCapture, false);
window.addEventListener('audioinputerror', onAudioInputError, false);
}
else {
consoleMessage("Missing: cordova-plugin-file or cordova-plugin-audioinput!");
disableAllButtons();
}
}
|
javascript
|
{
"resource": ""
}
|
|
q45416
|
train
|
function (bufferSize, numberOfIterations) {
var bufSize = bufferSize || 16000,
iterations = numberOfIterations || 100;
for (var i = 0; i < iterations; i++) {
var data = [];
for (var k = 0; k < bufSize; k++) {
data.push((parseFloat(Math.random() * 1.0) - 0.5));
}
// Dispatch an event
var event = new CustomEvent('audioinput');
event.data = data;
window.dispatchEvent(event);
}
}
|
javascript
|
{
"resource": ""
}
|
|
q45417
|
train
|
function () {
var duration = 50;
// Check if there is any data in the queue
if (audioDataQueue.length > 0) {
// Concatenate up to concatenateMaxChunks data arrays from the queue
var concatenatedData = [];
for (var i = 0; i < concatenateMaxChunks; i++) {
if (audioDataQueue.length === 0) {
break;
}
concatenatedData = concatenatedData.concat(audioDataQueue.shift());
}
// Play the audio
duration = playAudio(concatenatedData) * 1000;
}
// Still capturing? Then call myself to continue consuming incoming data.
if (window.audioinput && audioinput.isCapturing()) {
timerGetNextAudio = setTimeout(getNextToPlay, duration);
}
}
|
javascript
|
{
"resource": ""
}
|
|
q45418
|
train
|
function (data) {
try {
// Create an audio buffer to hold the data
var audioBuffer = audioContext.createBuffer(captureCfg.channels, (data.length / captureCfg.channels),
captureCfg.sampleRate);
// Initialize the audio buffer with the data
if (captureCfg.channels > 1) {
// For multiple channels (stereo) we assume that the data is interleaved
for (var i = 0; i < captureCfg.channels; i++) {
var chdata = [],
index = 0;
while (index < data.length) {
chdata.push(data[index + i]);
index += parseInt(captureCfg.channels);
}
audioBuffer.getChannelData(i).set(chdata);
}
}
else {
// For just one channels (mono)
audioBuffer.getChannelData(0).set(data);
}
// Create a buffer source based on the audio buffer
var source = audioContext.createBufferSource();
source.buffer = audioBuffer;
// Connect the buffer source to the gain node
source.connect(micGainNode);
// Play the audio immediately
source.start(0);
// Increase the debug counter for played data
totalPlayedData += data.length;
// Return the duration of the sound so that we can play the next sound when ended.
return audioBuffer.duration;
}
catch(e) {
alert("playAudio exception: " + e);
return 100;
}
}
|
javascript
|
{
"resource": ""
}
|
|
q45419
|
train
|
function () {
try {
window.AudioContext = window.AudioContext || window.webkitAudioContext;
audioContext = new window.AudioContext();
consoleMessage("Web Audio Context is ready");
}
catch (e) {
consoleMessage('Web Audio API is not supported in this browser: ' + e);
return false;
}
// Create a gain node for volume control
micGainNode = audioContext.createGain();
// Connect the gain node to the speaker
micGainNode.connect(audioContext.destination);
return true;
}
|
javascript
|
{
"resource": ""
}
|
|
q45420
|
train
|
function(header,msg,opts){
opts = _setOpts(opts);
return $uibModal.open({
templateUrl : '/dialogs/notify.html',
controller : 'notifyDialogCtrl',
backdrop: opts.bd,
backdropClass: opts.bdc,
keyboard: opts.kb,
windowClass: opts.wc,
size: opts.ws,
animation: opts.anim,
resolve : {
data : function(){
return {
header : angular.copy(header),
msg : angular.copy(msg),
fa : _fa,
btnMessages: opts.btnMessages
};
}
}
}); // end modal.open
}
|
javascript
|
{
"resource": ""
}
|
|
q45421
|
train
|
function(url,ctrlr,data,opts,ctrlAs){
var copy = (opts && angular.isDefined(opts.copy)) ? opts.copy : _copy;
opts = _setOpts(opts);
return $uibModal.open({
templateUrl : url,
controller : ctrlr,
controllerAs : ctrlAs,
keyboard : opts.kb,
backdrop : opts.bd,
backdropClass: opts.bdc,
windowClass: opts.wc,
size: opts.ws,
animation: opts.anim,
resolve : {
data : function() {
if(copy)
return angular.copy(data);
else
return data;
}
}
}); // end modal.open
}
|
javascript
|
{
"resource": ""
}
|
|
q45422
|
train
|
function(component, data, opts) {
var copy = (opts && angular.isDefined(opts.copy)) ? opts.copy : _copy;
opts = _setOpts(opts);
return $uibModal.open({
component : component,
keyboard : opts.kb,
backdrop : opts.bd,
backdropClass: opts.bdc,
windowClass: opts.wc,
size: opts.ws,
animation: opts.anim,
resolve : {
data : function() {
if(copy)
return angular.copy(data);
else
return data;
}
}
}); // end modal.open
}
|
javascript
|
{
"resource": ""
}
|
|
q45423
|
pushToken
|
train
|
function pushToken(type, value, column) {
tokens.push({
tn: tn++,
ln: ln,
col: column,
type: type,
value: value
});
}
|
javascript
|
{
"resource": ""
}
|
q45424
|
parseMLComment
|
train
|
function parseMLComment(css) {
var start = pos;
// Read the string until we meet `*/`.
// Since we already know first 2 characters (`/*`), start reading
// from `pos + 2`:
for (pos += 2; pos < css.length; pos++) {
if (css.charAt(pos) === '*' && css.charAt(pos + 1) === '/') {
pos++;
break;
}
}
// Add full comment (including `/*` and `*/`) to the list of tokens:
var comment = css.substring(start, pos + 1);
pushToken(TokenType.CommentML, comment, col);
var newlines = comment.split('\n');
if (newlines.length > 1) {
ln += newlines.length - 1;
col = newlines[newlines.length - 1].length;
} else {
col += (pos - start);
}
}
|
javascript
|
{
"resource": ""
}
|
q45425
|
parseSLComment
|
train
|
function parseSLComment(css) {
var start = pos;
// Read the string until we meet line break.
// Since we already know first 2 characters (`//`), start reading
// from `pos + 2`:
for (pos += 2; pos < css.length; pos++) {
if (css.charAt(pos) === '\n' || css.charAt(pos) === '\r') {
break;
}
}
// Add comment (including `//` and line break) to the list of tokens:
pushToken(TokenType.CommentSL, css.substring(start, pos--), col);
col += pos - start;
}
|
javascript
|
{
"resource": ""
}
|
q45426
|
getTokens
|
train
|
function getTokens(css) {
// Parse string, character by character:
for (pos = 0; pos < css.length; col++, pos++) {
c = css.charAt(pos);
cn = css.charAt(pos + 1);
// If we meet `/*`, it's a start of a multiline comment.
// Parse following characters as a multiline comment:
if (c === '/' && cn === '*') {
parseMLComment(css);
}
// If we meet `//` and it is not a part of url:
else if (!urlMode && c === '/' && cn === '/') {
// If we're currently inside a block, treat `//` as a start
// of identifier. Else treat `//` as a start of a single-line
// comment:
parseSLComment(css);
}
// If current character is a double or single quote, it's a start
// of a string:
else if (c === '"' || c === "'") {
parseString(css, c);
}
// If current character is a space:
else if (c === ' ') {
parseSpaces(css);
}
// If current character is `=`, it must be combined with next `=`
else if (c === '=' && cn === '=') {
parseEquality(css);
}
// If we meet `!=`, this must be inequality
else if (c === '!' && cn === '=') {
parseInequality(css);
}
// If current character is a punctuation mark:
else if (c in Punctuation) {
// Check for CRLF here or just LF
if (c === '\r' && cn === '\n' || c === '\n') {
// If \r we know the next character is \n due to statement above
// so we push a CRLF token type to the token list and importantly
// skip the next character so as not to double count newlines or
// columns etc
if (c === '\r') {
pushToken(TokenType.Newline, '\r\n', col);
pos++; // If CRLF skip the next character and push crlf token
} else if (c === '\n') {
// If just a LF newline and not part of CRLF newline we can just
// push punctuation as usual
pushToken(Punctuation[c], c, col);
}
ln++; // Go to next line
col = 0; // Reset the column count
} else if (c !== '\r' && c !== '\n') {
// Handle all other punctuation and add to list of tokens
pushToken(Punctuation[c], c, col);
}// Go to next line
if (c === ')') urlMode = false; // Exit url mode
else if (c === '\t' && tabSize > 1) col += (tabSize - 1);
}
// If current character is a decimal digit:
else if (isDecimalDigit(c)) {
parseDecimalNumber(css);
}
// If current character is anything else:
else {
parseIdentifier(css);
}
}
return tokens;
}
|
javascript
|
{
"resource": ""
}
|
q45427
|
checkArgument
|
train
|
function checkArgument(i) {
let l;
if (l = checkBrackets(i)) tokens[i].argument_child = 1;
else if (l = checkParentheses(i)) tokens[i].argument_child = 2;
else if (l = checkSingleValueDeclaration(i)) tokens[i].argument_child = 3;
else if (l = checkFunctionsList(i)) tokens[i].argument_child = 4;
else if (l = checkFunction(i)) tokens[i].argument_child = 5;
else if (l = checkVariablesList(i)) tokens[i].argument_child = 6;
else if (l = checkVariable(i)) tokens[i].argument_child = 7;
else if (l = checkSC(i)) tokens[i].argument_child = 8;
else if (l = checkDelim(i)) tokens[i].argument_child = 9;
else if (l = checkDeclDelim(i)) tokens[i].argument_child = 10;
else if (l = checkString(i)) tokens[i].argument_child = 11;
else if (l = checkPercentage(i)) tokens[i].argument_child = 12;
else if (l = checkDimension(i)) tokens[i].argument_child = 13;
else if (l = checkNumber(i)) tokens[i].argument_child = 14;
else if (l = checkUri(i)) tokens[i].argument_child = 15;
else if (l = checkInterpolation(i)) tokens[i].argument_child = 16;
else if (l = checkIdent(i)) tokens[i].argument_child = 17;
else if (l = checkVhash(i)) tokens[i].argument_child = 18;
else if (l = checkCustomProperty(i)) tokens[i].argument_child = 19;
else if (l = checkOperator(i)) tokens[i].argument_child = 20;
else if (l = checkUnary(i)) tokens[i].argument_child = 21;
else if (l = checkParentSelector(i)) tokens[i].argument_child = 22;
else if (l = checkImportant(i)) tokens[i].argument_child = 23;
else if (l = checkGlobal(i)) tokens[i].argument_child = 24;
else if (l = checkDefault(i)) tokens[i].argument_child = 25;
else if (l = checkOptional(i)) tokens[i].argument_child = 26;
return l;
}
|
javascript
|
{
"resource": ""
}
|
q45428
|
getClass
|
train
|
function getClass() {
const type = NodeType.ClassType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const end = token.classEnd;
let content = [];
// Skip `.`
pos++;
while (pos < end) {
if (checkIdentOrInterpolation(pos)) {
content = content.concat(getIdentOrInterpolation());
} else break;
}
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45429
|
getCommentSL
|
train
|
function getCommentSL() {
const type = NodeType.CommentSLType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const content = tokens[pos++].value.substring(2);
const end = !content ? [line, column + 1]
: getLastPosition(content, line, column + 2);
return newNode(type, content, line, column, end);
}
|
javascript
|
{
"resource": ""
}
|
q45430
|
checkDeclDelim
|
train
|
function checkDeclDelim(i) {
if (i >= tokensLength) return 0;
return (tokens[i].type === TokenType.Newline ||
tokens[i].type === TokenType.Semicolon) ? 1 : 0;
}
|
javascript
|
{
"resource": ""
}
|
q45431
|
getDeclDelim
|
train
|
function getDeclDelim() {
const type = NodeType.DeclDelimType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const content = '\n';
pos++;
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45432
|
getDefault
|
train
|
function getDefault() {
const type = NodeType.DefaultType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const content = joinValues(pos, token.defaultEnd);
pos = token.defaultEnd + 1;
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45433
|
getDelim
|
train
|
function getDelim() {
const type = NodeType.DelimType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const content = ',';
pos++;
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45434
|
getDimension
|
train
|
function getDimension() {
const type = NodeType.DimensionType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const content = [
getNumber(),
getUnit()
];
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45435
|
getFunctionsList
|
train
|
function getFunctionsList() {
const type = NodeType.FunctionsListType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const content = [getFunction()];
const end = getLastPosition(content, line, column, 3);
// Skip `...`.
pos += 3;
return newNode(type, content, line, column, end);
}
|
javascript
|
{
"resource": ""
}
|
q45436
|
getIdent
|
train
|
function getIdent() {
const type = NodeType.IdentType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const content = joinValues(pos, tokens[pos].ident_last);
pos = tokens[pos].ident_last + 1;
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45437
|
checkImportant
|
train
|
function checkImportant(i) {
const start = i;
let l;
if (i >= tokensLength ||
tokens[i++].type !== TokenType.ExclamationMark) return 0;
if (l = checkSC(i)) i += l;
if (tokens[i].value === 'important') {
tokens[start].importantEnd = i;
return i - start + 1;
} else {
return 0;
}
}
|
javascript
|
{
"resource": ""
}
|
q45438
|
checkInclude
|
train
|
function checkInclude(i) {
let l;
if (i >= tokensLength) return 0;
if (l = checkIncludeWithKeyframes1(i)) tokens[i].include_type = 9;
else if (l = checkInclude1(i)) tokens[i].include_type = 1;
else if (l = checkInclude2(i)) tokens[i].include_type = 2;
else if (l = checkInclude3(i)) tokens[i].include_type = 3;
else if (l = checkInclude4(i)) tokens[i].include_type = 4;
else if (l = checkIncludeWithKeyframes2(i)) tokens[i].include_type = 10;
else if (l = checkInclude5(i)) tokens[i].include_type = 5;
else if (l = checkInclude6(i)) tokens[i].include_type = 6;
else if (l = checkInclude7(i)) tokens[i].include_type = 7;
else if (l = checkInclude8(i)) tokens[i].include_type = 8;
return l;
}
|
javascript
|
{
"resource": ""
}
|
q45439
|
getInterpolation
|
train
|
function getInterpolation() {
const type = NodeType.InterpolationType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
let content = [];
// Skip `#{`:
pos += 2;
while (pos < tokensLength &&
tokens[pos].type !== TokenType.RightCurlyBracket) {
const body = getArgument();
if (typeof body.content === 'string') content.push(body);
else content = content.concat(body);
}
const end = getLastPosition(content, line, column, 1);
// Skip `}`:
pos++;
return newNode(type, content, line, column, end);
}
|
javascript
|
{
"resource": ""
}
|
q45440
|
checkKeyframesRule
|
train
|
function checkKeyframesRule(i) {
const start = i;
let l;
if (i >= tokensLength) return 0;
if (l = checkAtkeyword(i)) i += l;
else return 0;
const atruleName = joinValues2(i - l, l);
if (atruleName.toLowerCase().indexOf('keyframes') === -1) return 0;
if (l = checkSC(i)) i += l;
else return 0;
if (l = checkIdentOrInterpolation(i) || checkPseudoc(i)) i += l;
else return 0;
if (l = checkSC(i)) i += l;
if (l = checkKeyframesBlocks(i)) i += l;
else return 0;
return i - start;
}
|
javascript
|
{
"resource": ""
}
|
q45441
|
checkKeyframesSelector
|
train
|
function checkKeyframesSelector(i) {
const start = i;
let l;
if (i >= tokensLength) return 0;
if (l = checkIdent(i)) {
// Valid selectors are only `from` and `to`.
const selector = joinValues2(i, l);
if (selector !== 'from' && selector !== 'to') return 0;
i += l;
tokens[start].keyframesSelectorType = 1;
} else if (l = checkPercentage(i)) {
i += l;
tokens[start].keyframesSelectorType = 2;
} else if (l = checkInterpolation(i)) {
i += l;
tokens[start].keyframesSelectorType = 3;
} else {
return 0;
}
return i - start;
}
|
javascript
|
{
"resource": ""
}
|
q45442
|
getLoop
|
train
|
function getLoop() {
const type = NodeType.LoopType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
let content = [];
content.push(getAtkeyword());
while (pos < tokensLength) {
if (checkBlock(pos)) {
content.push(getBlock());
break;
}
else if (checkVariable(pos)) content.push(getVariable());
else if (checkNumber(pos)) content.push(getNumber());
else if (checkInterpolation(pos)) content.push(getInterpolation());
else if (checkIdent(pos)) content.push(getIdent());
else if (checkOperator(pos)) content.push(getOperator());
else if (checkCombinator(pos)) content.push(getCombinator());
else if (checkSC(pos)) content = content.concat(getSC());
else if (checkString(pos)) content.push(getString());
}
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45443
|
getNamespace
|
train
|
function getNamespace() {
const type = NodeType.NamespaceType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const content = '|';
pos++;
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45444
|
checkNumber
|
train
|
function checkNumber(i) {
if (i >= tokensLength) return 0;
if (tokens[i].number_l) return tokens[i].number_l;
// `10`:
if (i < tokensLength && tokens[i].type === TokenType.DecimalNumber &&
(!tokens[i + 1] ||
(tokens[i + 1] && tokens[i + 1].type !== TokenType.FullStop))) {
tokens[i].number_l = 1;
return 1;
}
// `10.`:
if (i < tokensLength &&
tokens[i].type === TokenType.DecimalNumber &&
tokens[i + 1] && tokens[i + 1].type === TokenType.FullStop &&
(!tokens[i + 2] || (tokens[i + 2].type !== TokenType.DecimalNumber))) {
tokens[i].number_l = 2;
return 2;
}
// `.10`:
if (i < tokensLength &&
tokens[i].type === TokenType.FullStop &&
tokens[i + 1].type === TokenType.DecimalNumber) {
tokens[i].number_l = 2;
return 2;
}
// `10.10`:
if (i < tokensLength &&
tokens[i].type === TokenType.DecimalNumber &&
tokens[i + 1] && tokens[i + 1].type === TokenType.FullStop &&
tokens[i + 2] && tokens[i + 2].type === TokenType.DecimalNumber) {
tokens[i].number_l = 3;
return 3;
}
return 0;
}
|
javascript
|
{
"resource": ""
}
|
q45445
|
getNumber
|
train
|
function getNumber() {
const type = NodeType.NumberType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const l = tokens[pos].number_l;
let content = '';
for (let j = 0; j < l; j++) {
content += tokens[pos + j].value;
}
pos += l;
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45446
|
getOperator
|
train
|
function getOperator() {
const type = NodeType.OperatorType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const content = token.value;
pos++;
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45447
|
getParentSelector
|
train
|
function getParentSelector() {
const type = NodeType.ParentSelectorType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const content = '&';
pos++;
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45448
|
getPercentage
|
train
|
function getPercentage() {
const type = NodeType.PercentageType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const content = getNumberOrInterpolation();
const end = getLastPosition(content, line, column, 1);
// Skip `%`.
pos++;
return newNode(type, content, line, column, end);
}
|
javascript
|
{
"resource": ""
}
|
q45449
|
checkNumberOrInterpolation
|
train
|
function checkNumberOrInterpolation(i) {
const start = i;
let l;
while (i < tokensLength) {
if (l = checkInterpolation(i) || checkNumber(i)) i += l;
else break;
}
return i - start;
}
|
javascript
|
{
"resource": ""
}
|
q45450
|
getPlaceholder
|
train
|
function getPlaceholder() {
const type = NodeType.PlaceholderType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
let content = [];
// Skip `%`.
pos++;
content = content.concat(getIdentOrInterpolation());
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45451
|
checkCustomProperty
|
train
|
function checkCustomProperty(i) {
const start = i;
let l;
if (i >= tokensLength) return 0;
if (tokens[i].type !== TokenType.HyphenMinus ||
tokens[i + 1] && tokens[i + 1].type !== TokenType.HyphenMinus) return 0;
// Skip `--`
i += 2;
if (l = checkIdentOrInterpolation(i)) i += l;
else return 0;
return i - start;
}
|
javascript
|
{
"resource": ""
}
|
q45452
|
getCustomProperty
|
train
|
function getCustomProperty() {
const type = NodeType.CustomPropertyType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
// Skip `--`
pos += 2;
const content = getIdentOrInterpolation();
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45453
|
getPropertyDelim
|
train
|
function getPropertyDelim() {
const type = NodeType.PropertyDelimType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const content = ':';
// Skip `:`.
pos++;
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45454
|
getS
|
train
|
function getS() {
const type = NodeType.SType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const content = joinValues(pos, tokens[pos].ws_last);
pos = tokens[pos].ws_last + 1;
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45455
|
checkMultilineSC
|
train
|
function checkMultilineSC(i) {
if (!tokens[i]) return 0;
let l;
let lsc = 0;
while (i < tokensLength) {
if (!(l = checkS(i)) &&
!(l = checkCommentML(i)) &&
!(l = checkCommentSL(i))) break;
i += l;
lsc += l;
}
return lsc || 0;
}
|
javascript
|
{
"resource": ""
}
|
q45456
|
getString
|
train
|
function getString() {
const type = NodeType.StringType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const content = token.value;
pos++;
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45457
|
getUnicodeRange
|
train
|
function getUnicodeRange() {
const type = NodeType.UnicodeRangeType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
let content = [];
while (pos < tokensLength) {
if (checkSC(pos)) content = content.concat(getSC());
else if (checkDelim(pos)) content.push(getDelim());
else if (checkUrange(pos)) content.push(getUrange());
else break;
}
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45458
|
getUnit
|
train
|
function getUnit() {
const type = NodeType.IdentType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const content = token.value;
pos++;
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45459
|
_checkUnicodeWildcard
|
train
|
function _checkUnicodeWildcard(i) {
const start = i;
if (i >= tokensLength) return 0;
while (i < tokensLength) {
if (tokens[i].type === TokenType.QuestionMark) i += 1;
else break;
}
return i - start;
}
|
javascript
|
{
"resource": ""
}
|
q45460
|
getUri
|
train
|
function getUri() {
const startPos = pos;
const type = NodeType.UriType;
const token = tokens[startPos];
const line = token.ln;
const column = token.col;
let content = [];
let end;
const uriType = tokens[startPos].uriType;
// Skip `url` and `(`.
pos += 2;
if (uriType === 1) content = content.concat(getUri1());
else if (uriType === 2) content = content.concat(getUri2());
else end = getLastPosition(content, line, column, 4);
if (!end) end = getLastPosition(content, line, column, 1);
// Skip `)`.
pos++;
return newNode(type, content, line, column, end);
}
|
javascript
|
{
"resource": ""
}
|
q45461
|
checkUriRawCharacters
|
train
|
function checkUriRawCharacters(i) {
const start = i;
let l;
if (l = checkIdent(i)) i += l;
else if (l = checkNumber(i)) i += l;
else {
switch (tokens[i].type) {
case TokenType.ExclamationMark:
case TokenType.NumberSign:
case TokenType.DollarSign:
case TokenType.PercentSign:
case TokenType.Ampersand:
case TokenType.Asterisk:
case TokenType.PlusSign:
case TokenType.Comma:
case TokenType.HyphenMinus:
case TokenType.FullStop:
case TokenType.Solidus:
case TokenType.Colon:
case TokenType.Semicolon:
case TokenType.LessThanSign:
case TokenType.EqualsSign:
case TokenType.GreaterThanSign:
case TokenType.QuotationMark:
case TokenType.CommercialAt:
case TokenType.LeftSquareBracket:
case TokenType.RightSquareBracket:
case TokenType.CircumflexAccent:
case TokenType.LowLine:
case TokenType.LeftCurlyBracket:
case TokenType.VerticalLine:
case TokenType.RightCurlyBracket:
case TokenType.Tilde:
i += 1;
break;
default:
return 0;
}
}
return i - start;
}
|
javascript
|
{
"resource": ""
}
|
q45462
|
checkUriRaw
|
train
|
function checkUriRaw(i) {
const start = i;
let l;
while (i < tokensLength) {
if (checkInterpolation(i) || checkVariable(i)) break;
else if (l = checkUriRawCharacters(i)) i += l;
else break;
}
tokens[start].uri_raw_end = i;
return i - start;
}
|
javascript
|
{
"resource": ""
}
|
q45463
|
getUriRaw
|
train
|
function getUriRaw() {
const startPos = pos;
const type = NodeType.RawType;
const token = tokens[startPos];
const line = token.ln;
const column = token.col;
let content = [];
let l;
while (pos < tokens[startPos].uri_raw_end) {
if (checkInterpolation(pos) || checkVariable(pos)) break;
else if (l = checkUriRawCharacters(pos)) pos += l;
else break;
}
content = joinValues(startPos, pos - 1);
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45464
|
checkVariable
|
train
|
function checkVariable(i) {
const start = i;
let l;
if (i >= tokensLength) return 0;
// Skip `$`.
if (tokens[i].type === TokenType.DollarSign) i++;
else return 0;
if (l = checkIdent(i)) i += l;
else return 0;
return i - start;
}
|
javascript
|
{
"resource": ""
}
|
q45465
|
getVariablesList
|
train
|
function getVariablesList() {
const type = NodeType.VariablesListType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const content = [getVariable()];
const end = getLastPosition(content, line, column, 3);
// Skip `...`.
pos += 3;
return newNode(type, content, line, column, end);
}
|
javascript
|
{
"resource": ""
}
|
q45466
|
checkSelector1
|
train
|
function checkSelector1(i) {
if (i >= tokensLength) return 0;
const start = i;
let l;
if (l = checkCompoundSelector(i)) i += l;
else return 0;
while (i < tokensLength) {
let space = checkSC(i);
const comma = checkCombinator(i + space);
if (!space && !comma) break;
if (comma) {
i += space + comma;
space = checkSC(i);
}
if (l = checkCompoundSelector(i + space)) i += space + l;
else break;
}
tokens[start].selectorEnd = i;
return i - start;
}
|
javascript
|
{
"resource": ""
}
|
q45467
|
checkSelector2
|
train
|
function checkSelector2(i) {
if (i >= tokensLength) return 0;
const start = i;
let l;
if (l = checkCombinator(i)) i += l;
else return 0;
while (i < tokensLength) {
const spaceBefore = checkSC(i);
if (l = checkCompoundSelector(i + spaceBefore)) i += spaceBefore + l;
else break;
const spaceAfter = checkSC(i);
const comma = checkCombinator(i + spaceAfter);
if (!spaceAfter && !comma) break;
if (comma) {
i += spaceAfter + comma;
}
}
tokens[start].selectorEnd = i;
return i - start;
}
|
javascript
|
{
"resource": ""
}
|
q45468
|
checkTypeSelector
|
train
|
function checkTypeSelector(i) {
if (i >= tokensLength) return 0;
const start = i;
let l;
if (l = checkNamePrefix(i)) i += l;
if (l = checkIdentOrInterpolation(i)) i += l;
else return 0;
return i - start;
}
|
javascript
|
{
"resource": ""
}
|
q45469
|
getTypeSelector
|
train
|
function getTypeSelector() {
const type = NodeType.TypeSelectorType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
let content = [];
if (checkNamePrefix(pos)) content.push(getNamePrefix());
content = content.concat(getIdentOrInterpolation());
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45470
|
checkArgument
|
train
|
function checkArgument(i) {
let l;
if (l = checkEscapedString(i)) tokens[i].argument_child = 1;
else if (l = checkDeclaration(i)) tokens[i].argument_child = 2;
else if (l = checkVariablesList(i)) tokens[i].argument_child = 3;
else if (l = checkVariable(i)) tokens[i].argument_child = 4;
else if (l = checkSC(i)) tokens[i].argument_child = 5;
else if (l = checkUnary(i)) tokens[i].argument_child = 6;
else if (l = checkOperator(i)) tokens[i].argument_child = 7;
else if (l = checkDelim(i)) tokens[i].argument_child = 8;
else if (l = checkDeclDelim(i)) tokens[i].argument_child = 9;
else if (l = checkString(i)) tokens[i].argument_child = 10;
else if (l = checkPercentage(i)) tokens[i].argument_child = 11;
else if (l = checkDimension(i)) tokens[i].argument_child = 12;
else if (l = checkNumber(i)) tokens[i].argument_child = 13;
else if (l = checkUri(i)) tokens[i].argument_child = 14;
else if (l = checkFunction(i)) tokens[i].argument_child = 15;
else if (l = checkIdent(i)) tokens[i].argument_child = 16;
else if (l = checkVhash(i)) tokens[i].argument_child = 17;
else if (l = checkBlock(i)) tokens[i].argument_child = 18;
else if (l = checkParentheses(i)) tokens[i].argument_child = 19;
return l;
}
|
javascript
|
{
"resource": ""
}
|
q45471
|
checkAtrule
|
train
|
function checkAtrule(i) {
let l;
if (i >= tokensLength) return 0;
// If token already has a record of being part of an @-rule,
// return the @-rule's length:
if (tokens[i].atrule_l !== undefined) return tokens[i].atrule_l;
// If token is part of an @-rule, save the rule's type to token.
if (l = checkKeyframesRule(i)) tokens[i].atrule_type = 4;
// @-rule with ruleset:
else if (l = checkAtruler(i)) tokens[i].atrule_type = 1;
// Block @-rule:
else if (l = checkAtruleb(i)) tokens[i].atrule_type = 2;
// Single-line @-rule:
else if (l = checkAtrules(i)) tokens[i].atrule_type = 3;
else return 0;
// If token is part of an @-rule, save the rule's length to token:
tokens[i].atrule_l = l;
return l;
}
|
javascript
|
{
"resource": ""
}
|
q45472
|
checkAtruler
|
train
|
function checkAtruler(i) {
const start = i;
let l;
if (i >= tokensLength) return 0;
if (l = checkAtkeyword(i)) i += l;
else return 0;
if (l = checkTsets(i)) i += l;
if (i < tokensLength && tokens[i].type === TokenType.LeftCurlyBracket) i++;
else return 0;
if (l = checkAtrulers(i)) i += l;
if (i < tokensLength && tokens[i].type === TokenType.RightCurlyBracket) i++;
else return 0;
return i - start;
}
|
javascript
|
{
"resource": ""
}
|
q45473
|
getBlock
|
train
|
function getBlock() {
const type = NodeType.BlockType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const end = tokens[pos].right;
let content = [];
// Skip `{`.
pos++;
while (pos < end) {
if (checkBlockdecl(pos)) content = content.concat(getBlockdecl());
else throwError(pos);
}
const end_ = getLastPosition(content, line, column, 1);
pos = end + 1;
return newNode(type, content, line, column, end_);
}
|
javascript
|
{
"resource": ""
}
|
q45474
|
getCommentML
|
train
|
function getCommentML() {
const type = NodeType.CommentMLType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
let content = tokens[pos].value.substring(2);
const l = content.length;
if (content.charAt(l - 2) === '*' && content.charAt(l - 1) === '/')
content = content.substring(0, l - 2);
const end = getLastPosition(content, line, column, 2);
if (end[0] === line) end[1] += 2;
pos++;
return newNode(type, content, line, column, end);
}
|
javascript
|
{
"resource": ""
}
|
q45475
|
checkCondition
|
train
|
function checkCondition(i) {
const start = i;
let l;
if (i >= tokensLength) return 0;
if ((l = checkIdent(i)) && tokens[i].value === 'when') i += l;
else return 0;
while (i < tokensLength) {
if (l = checkBlock(i)) {
tokens[i].condition_child = 0;
break;
} else if (l = checkFunction(i)) tokens[i].condition_child = 1;
else if (l = checkBrackets(i)) tokens[i].condition_child = 2;
else if (l = checkParentheses(i)) tokens[i].condition_child = 3;
else if (l = checkVariable(i)) tokens[i].condition_child = 4;
else if (l = checkIdent(i)) tokens[i].condition_child = 5;
else if (l = checkNumber(i)) tokens[i].condition_child = 6;
else if (l = checkDelim(i)) tokens[i].condition_child = 7;
else if (l = checkOperator(i)) tokens[i].condition_child = 8;
else if (l = checkCombinator(i)) tokens[i].condition_child = 9;
else if (l = checkSC(i)) tokens[i].condition_child = 10;
else if (l = checkString(i)) tokens[i].condition_child = 11;
else return 0;
i += l;
}
return i - start;
}
|
javascript
|
{
"resource": ""
}
|
q45476
|
getEscapedString
|
train
|
function getEscapedString() {
const type = NodeType.EscapedStringType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
pos++;
const content = tokens[pos].value;
const end = getLastPosition(content, line, column + 1);
pos++;
return newNode(type, content, line, column, end);
}
|
javascript
|
{
"resource": ""
}
|
q45477
|
checkIdent
|
train
|
function checkIdent(i) {
const start = i;
if (i >= tokensLength) return 0;
if (tokens[i].type === TokenType.HyphenMinus) i++;
if (tokens[i].type === TokenType.LowLine ||
tokens[i].type === TokenType.Identifier) i++;
else return 0;
for (; i < tokensLength; i++) {
if (tokens[i].type !== TokenType.HyphenMinus &&
tokens[i].type !== TokenType.LowLine &&
tokens[i].type !== TokenType.Identifier &&
tokens[i].type !== TokenType.DecimalNumber) break;
}
tokens[start].ident_last = i - 1;
return i - start;
}
|
javascript
|
{
"resource": ""
}
|
q45478
|
checkInclude
|
train
|
function checkInclude(i) {
let l;
if (i >= tokensLength) return 0;
if (l = checkInclude1(i)) tokens[i].include_type = 1;
else if (l = checkInclude2(i)) tokens[i].include_type = 2;
return l;
}
|
javascript
|
{
"resource": ""
}
|
q45479
|
checkInterpolatedVariable
|
train
|
function checkInterpolatedVariable(i) {
const start = i;
let l;
if (i >= tokensLength) return 0;
if (tokens[i].type !== TokenType.CommercialAt ||
!tokens[i + 1] || tokens[i + 1].type !== TokenType.LeftCurlyBracket) {
return 0;
}
i += 2;
if (l = checkIdent(i)) i += l;
else return 0;
return tokens[i].type === TokenType.RightCurlyBracket ? i - start + 1 : 0;
}
|
javascript
|
{
"resource": ""
}
|
q45480
|
getInterpolatedVariable
|
train
|
function getInterpolatedVariable() {
const type = NodeType.InterpolatedVariableType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const content = [];
// Skip `@{`:
pos += 2;
content.push(getIdent());
const end = getLastPosition(content, line, column, 1);
// Skip `}`:
pos++;
return newNode(type, content, line, column, end);
}
|
javascript
|
{
"resource": ""
}
|
q45481
|
getUri
|
train
|
function getUri() {
const startPos = pos;
const uriExcluding = {};
let uri;
let token;
let l;
let raw;
pos += 2;
uriExcluding[TokenType.Space] = 1;
uriExcluding[TokenType.Tab] = 1;
uriExcluding[TokenType.Newline] = 1;
uriExcluding[TokenType.LeftParenthesis] = 1;
uriExcluding[TokenType.RightParenthesis] = 1;
if (checkUri1(pos)) {
uri = []
.concat(getSC())
.concat([getString()])
.concat(getSC());
} else {
uri = getSC();
l = checkExcluding(uriExcluding, pos);
token = tokens[pos];
raw = newNode(NodeType.RawType, joinValues(pos, pos + l), token.ln,
token.col);
uri.push(raw);
pos += l + 1;
uri = uri.concat(getSC());
}
token = tokens[startPos];
const line = token.ln;
const column = token.col;
const end = getLastPosition(uri, line, column, 1);
pos++;
return newNode(NodeType.UriType, uri, line, column, end);
}
|
javascript
|
{
"resource": ""
}
|
q45482
|
checkVariable
|
train
|
function checkVariable(i) {
let l;
if (i >= tokensLength || tokens[i].type !== TokenType.CommercialAt) return 0;
if (tokens[i - 1] &&
tokens[i - 1].type === TokenType.CommercialAt &&
tokens[i - 2] &&
tokens[i - 2].type === TokenType.CommercialAt) return 0;
return (l = checkVariable(i + 1) || checkIdent(i + 1)) ? l + 1 : 0;
}
|
javascript
|
{
"resource": ""
}
|
q45483
|
getVariable
|
train
|
function getVariable() {
const type = NodeType.VariableType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const content = [];
// Skip `$`.
pos++;
if (checkVariable(pos)) content.push(getVariable());
else content.push(getIdent());
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45484
|
checkInclude3
|
train
|
function checkInclude3(i) {
const start = i;
let l;
if (l = checkAtkeyword(i)) i += l;
else return 0;
if (tokens[start + 1].value !== 'include') return 0;
if (l = checkSC(i)) i += l;
else return 0;
if (l = checkIdentOrInterpolation(i)) i += l;
else return 0;
if (l = checkSC(i)) i += l;
if (l = checkArguments(i)) i += l;
else return 0;
return i - start;
}
|
javascript
|
{
"resource": ""
}
|
q45485
|
getInclude3
|
train
|
function getInclude3() {
const type = NodeType.IncludeType;
const token = tokens[pos];
const line = token.ln;
const column = token.col;
const content = [].concat(
getAtkeyword(),
getSC(),
getIdentOrInterpolation(),
getSC(),
getArguments()
);
return newNode(type, content, line, column);
}
|
javascript
|
{
"resource": ""
}
|
q45486
|
train
|
function () {
var bones = this.bones;
var updateCache = this.cache;
var ikConstraints = this.ikConstraints;
var transformConstraints = this.transformConstraints;
var ikConstraintsCount = ikConstraints.length;
var transformConstraintsCount = transformConstraints.length;
updateCache.length = 0;
for (var i = 0, n = bones.length; i < n; i++) {
var bone = bones[i];
updateCache[updateCache.length] = bone;
for (var ii = 0; ii < ikConstraintsCount; ii++) {
var ikConstraint = ikConstraints[ii];
if (bone == ikConstraint.bones[ikConstraint.bones.length - 1]) {
updateCache[updateCache.length] = ikConstraint;
break;
}
}
}
for (var i = 0; i < transformConstraintsCount; i++) {
var transformConstraint = transformConstraints[i];
for (var ii = updateCache.length - 1; ii >= 0; ii--) {
var object = updateCache[ii];
if (object == transformConstraint.bone || object == transformConstraint.target) {
updateCache.splice(ii + 1, 0, transformConstraint);
break;
}
}
}
}
|
javascript
|
{
"resource": ""
}
|
|
q45487
|
train
|
function () {
var updateCache = this.cache;
for (var i = 0, n = updateCache.length; i < n; i++)
updateCache[i].update();
}
|
javascript
|
{
"resource": ""
}
|
|
q45488
|
train
|
function () {
var bones = this.bones;
for (var i = 0, n = bones.length; i < n; i++)
bones[i].setToSetupPose();
var ikConstraints = this.ikConstraints;
for (var i = 0, n = ikConstraints.length; i < n; i++) {
var constraint = ikConstraints[i];
constraint.bendDirection = constraint.data.bendDirection;
constraint.mix = constraint.data.mix;
}
var transformConstraints = this.transformConstraints;
for (var i = 0, n = transformConstraints.length; i < n; i++) {
var constraint = transformConstraints[i];
constraint.translateMix = constraint.data.translateMix;
constraint.x = constraint.data.x;
constraint.y = constraint.data.y;
}
}
|
javascript
|
{
"resource": ""
}
|
|
q45489
|
train
|
function (trackIndex, animation, loop) {
var entry = new spine.TrackEntry();
entry.animation = animation;
entry.loop = loop;
entry.endTime = animation.duration;
this.setCurrent(trackIndex, entry);
return entry;
}
|
javascript
|
{
"resource": ""
}
|
|
q45490
|
train
|
function (x, y) {
return x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY;
}
|
javascript
|
{
"resource": ""
}
|
|
q45491
|
train
|
function (x1, y1, x2, y2) {
var minX = this.minX, minY = this.minY, maxX = this.maxX, maxY = this.maxY;
if ((x1 <= minX && x2 <= minX) || (y1 <= minY && y2 <= minY) || (x1 >= maxX && x2 >= maxX) || (y1 >= maxY && y2 >= maxY))
return false;
var m = (y2 - y1) / (x2 - x1);
var y = m * (minX - x1) + y1;
if (y > minY && y < maxY) return true;
y = m * (maxX - x1) + y1;
if (y > minY && y < maxY) return true;
var x = (minY - y1) / m + x1;
if (x > minX && x < maxX) return true;
x = (maxY - y1) / m + x1;
if (x > minX && x < maxX) return true;
return false;
}
|
javascript
|
{
"resource": ""
}
|
|
q45492
|
train
|
function (bounds) {
return this.minX < bounds.maxX && this.maxX > bounds.minX && this.minY < bounds.maxY && this.maxY > bounds.minY;
}
|
javascript
|
{
"resource": ""
}
|
|
q45493
|
train
|
function (polygon, x, y) {
var nn = polygon.length;
var prevIndex = nn - 2;
var inside = false;
for (var ii = 0; ii < nn; ii += 2) {
var vertexY = polygon[ii + 1];
var prevY = polygon[prevIndex + 1];
if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y)) {
var vertexX = polygon[ii];
if (vertexX + (y - vertexY) / (prevY - vertexY) * (polygon[prevIndex] - vertexX) < x) inside = !inside;
}
prevIndex = ii;
}
return inside;
}
|
javascript
|
{
"resource": ""
}
|
|
q45494
|
train
|
function (polygon, x1, y1, x2, y2) {
var nn = polygon.length;
var width12 = x1 - x2, height12 = y1 - y2;
var det1 = x1 * y2 - y1 * x2;
var x3 = polygon[nn - 2], y3 = polygon[nn - 1];
for (var ii = 0; ii < nn; ii += 2) {
var x4 = polygon[ii], y4 = polygon[ii + 1];
var det2 = x3 * y4 - y3 * x4;
var width34 = x3 - x4, height34 = y3 - y4;
var det3 = width12 * height34 - height12 * width34;
var x = (det1 * width34 - width12 * det2) / det3;
if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))) {
var y = (det1 * height34 - height12 * det2) / det3;
if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1))) return true;
}
x3 = x4;
y3 = y4;
}
return false;
}
|
javascript
|
{
"resource": ""
}
|
|
q45495
|
MultipleInput
|
train
|
function MultipleInput(options) {
Selectivity.call(
this,
assign(
{
// dropdowns for multiple-value inputs should open below the select box,
// unless there is not enough space below, but there is space enough above, then it should
// open upwards
positionDropdown: function(el, selectEl) {
var rect = selectEl.getBoundingClientRect();
var dropdownHeight = el.clientHeight;
var openUpwards =
rect.bottom + dropdownHeight > window.innerHeight &&
rect.top - dropdownHeight > 0;
assign(el.style, {
left: rect.left + 'px',
top: (openUpwards ? rect.top - dropdownHeight : rect.bottom) + 'px',
width: rect.width + 'px'
});
},
showSearchInputInDropdown: false
},
options
)
);
this._reset();
var events = {
change: this.rerenderSelection,
click: this._clicked,
'selectivity-selected': this._resultSelected
};
events['change ' + INPUT_SELECTOR] = stopPropagation;
events['click ' + SELECTED_ITEM_SELECTOR] = this._itemClicked;
events['click ' + SELECTED_ITEM_SELECTOR + '-remove'] = this._itemRemoveClicked;
events['keydown ' + INPUT_SELECTOR] = this._keyHeld;
events['keyup ' + INPUT_SELECTOR] = this._keyReleased;
events['paste ' + INPUT_SELECTOR] = this._onPaste;
this.events.on(events);
}
|
javascript
|
{
"resource": ""
}
|
q45496
|
train
|
function(el, selectEl) {
var rect = selectEl.getBoundingClientRect();
var dropdownHeight = el.clientHeight;
var openUpwards =
rect.bottom + dropdownHeight > window.innerHeight &&
rect.top - dropdownHeight > 0;
assign(el.style, {
left: rect.left + 'px',
top: (openUpwards ? rect.top - dropdownHeight : rect.bottom) + 'px',
width: rect.width + 'px'
});
}
|
javascript
|
{
"resource": ""
}
|
|
q45497
|
train
|
function(item) {
var itemIsId = Selectivity.isValidId(item);
var id = itemIsId ? item : this.validateItem(item) && item.id;
if (this.options.allowDuplicates || this._value.indexOf(id) === -1) {
this._value.push(id);
if (itemIsId && this.options.initSelection) {
this.options.initSelection(
[id],
function(data) {
if (this._value.indexOf(id) > -1) {
item = this.validateItem(data[0]);
this._data.push(item);
this.triggerChange({ added: item });
}
}.bind(this)
);
} else {
if (itemIsId) {
item = this.getItemForId(id);
}
this._data.push(item);
this.triggerChange({ added: item });
}
}
this.input.value = '';
this._updateInputWidth();
}
|
javascript
|
{
"resource": ""
}
|
|
q45498
|
train
|
function(item) {
var id = item.id || item;
var removedItem;
var index = Selectivity.findIndexById(this._data, id);
if (index > -1) {
removedItem = this._data[index];
this._data.splice(index, 1);
}
if (this._value[index] !== id) {
index = this._value.indexOf(id);
}
if (index > -1) {
this._value.splice(index, 1);
}
if (removedItem) {
this.triggerChange({ removed: removedItem });
}
if (id === this._highlightedItemId) {
this._highlightedItemId = null;
}
this._updateInputWidth();
}
|
javascript
|
{
"resource": ""
}
|
|
q45499
|
train
|
function(data) {
if (data === null) {
return [];
} else if (Array.isArray(data)) {
return data.map(this.validateItem, this);
} else {
throw new Error('Data for MultiSelectivity instance should be an array');
}
}
|
javascript
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.