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
sequence | docstring
stringlengths 4
11.8k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 86
226
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
Azure/azure-mobile-apps-js-client | sdk/src/sync/operations.js | getOperationForUpdatingLog | function getOperationForUpdatingLog(operationId, tableName, action, item) {
return api.getMetadata(tableName, action, item).then(function(metadata) {
return {
tableName: operationTableName,
action: 'upsert',
data: {
id: operationId,
action: action,
metadata: metadata
}
};
});
} | javascript | function getOperationForUpdatingLog(operationId, tableName, action, item) {
return api.getMetadata(tableName, action, item).then(function(metadata) {
return {
tableName: operationTableName,
action: 'upsert',
data: {
id: operationId,
action: action,
metadata: metadata
}
};
});
} | [
"function",
"getOperationForUpdatingLog",
"(",
"operationId",
",",
"tableName",
",",
"action",
",",
"item",
")",
"{",
"return",
"api",
".",
"getMetadata",
"(",
"tableName",
",",
"action",
",",
"item",
")",
".",
"then",
"(",
"function",
"(",
"metadata",
")",
"{",
"return",
"{",
"tableName",
":",
"operationTableName",
",",
"action",
":",
"'upsert'",
",",
"data",
":",
"{",
"id",
":",
"operationId",
",",
"action",
":",
"action",
",",
"metadata",
":",
"metadata",
"}",
"}",
";",
"}",
")",
";",
"}"
] | Gets the operation that will update an existing record in the operation table. | [
"Gets",
"the",
"operation",
"that",
"will",
"update",
"an",
"existing",
"record",
"in",
"the",
"operation",
"table",
"."
] | bd4f9ba795527fbb95eca0f4ab53eb798934beba | https://github.com/Azure/azure-mobile-apps-js-client/blob/bd4f9ba795527fbb95eca0f4ab53eb798934beba/sdk/src/sync/operations.js#L338-L350 | train |
Azure/azure-mobile-apps-js-client | sdk/src/sync/operations.js | getMetadata | function getMetadata(tableName, action, item) {
return Platform.async(function(callback) {
callback();
})().then(function() {
var metadata = {};
// If action is update and item defines version property OR if action is insert / update,
// define metadata.version to be the item's version property
if (action === 'upsert' ||
action === 'insert' ||
(action === 'update' && item.hasOwnProperty(versionColumnName))) {
metadata[versionColumnName] = item[versionColumnName];
return metadata;
} else if (action == 'update' || action === 'delete') { // Read item's version property from the table
return store.lookup(tableName, item[idPropertyName], true /* suppressRecordNotFoundError */).then(function(result) {
if (result) {
metadata[versionColumnName] = result[versionColumnName];
}
return metadata;
});
} else {
throw new Error('Invalid action ' + action);
}
});
} | javascript | function getMetadata(tableName, action, item) {
return Platform.async(function(callback) {
callback();
})().then(function() {
var metadata = {};
// If action is update and item defines version property OR if action is insert / update,
// define metadata.version to be the item's version property
if (action === 'upsert' ||
action === 'insert' ||
(action === 'update' && item.hasOwnProperty(versionColumnName))) {
metadata[versionColumnName] = item[versionColumnName];
return metadata;
} else if (action == 'update' || action === 'delete') { // Read item's version property from the table
return store.lookup(tableName, item[idPropertyName], true /* suppressRecordNotFoundError */).then(function(result) {
if (result) {
metadata[versionColumnName] = result[versionColumnName];
}
return metadata;
});
} else {
throw new Error('Invalid action ' + action);
}
});
} | [
"function",
"getMetadata",
"(",
"tableName",
",",
"action",
",",
"item",
")",
"{",
"return",
"Platform",
".",
"async",
"(",
"function",
"(",
"callback",
")",
"{",
"callback",
"(",
")",
";",
"}",
")",
"(",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"var",
"metadata",
"=",
"{",
"}",
";",
"if",
"(",
"action",
"===",
"'upsert'",
"||",
"action",
"===",
"'insert'",
"||",
"(",
"action",
"===",
"'update'",
"&&",
"item",
".",
"hasOwnProperty",
"(",
"versionColumnName",
")",
")",
")",
"{",
"metadata",
"[",
"versionColumnName",
"]",
"=",
"item",
"[",
"versionColumnName",
"]",
";",
"return",
"metadata",
";",
"}",
"else",
"if",
"(",
"action",
"==",
"'update'",
"||",
"action",
"===",
"'delete'",
")",
"{",
"return",
"store",
".",
"lookup",
"(",
"tableName",
",",
"item",
"[",
"idPropertyName",
"]",
",",
"true",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"if",
"(",
"result",
")",
"{",
"metadata",
"[",
"versionColumnName",
"]",
"=",
"result",
"[",
"versionColumnName",
"]",
";",
"}",
"return",
"metadata",
";",
"}",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"'Invalid action '",
"+",
"action",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets the metadata to associate with a log record in the operation table
@param action 'insert', 'update' and 'delete' correspond to the insert, update and delete operations.
'upsert' is a special action that is used only in the context of conflict handling. | [
"Gets",
"the",
"metadata",
"to",
"associate",
"with",
"a",
"log",
"record",
"in",
"the",
"operation",
"table"
] | bd4f9ba795527fbb95eca0f4ab53eb798934beba | https://github.com/Azure/azure-mobile-apps-js-client/blob/bd4f9ba795527fbb95eca0f4ab53eb798934beba/sdk/src/sync/operations.js#L369-L395 | train |
Azure/azure-mobile-apps-js-client | sdk/src/sync/operations.js | getMaxOperationId | function getMaxOperationId() {
var query = new Query(operationTableName);
return store.read(query.orderByDescending('id').take(1)).then(function(result) {
Validate.isArray(result);
if (result.length === 0) {
return 0;
} else if (result.length === 1) {
return result[0].id;
} else {
throw new Error('something is wrong!');
}
});
} | javascript | function getMaxOperationId() {
var query = new Query(operationTableName);
return store.read(query.orderByDescending('id').take(1)).then(function(result) {
Validate.isArray(result);
if (result.length === 0) {
return 0;
} else if (result.length === 1) {
return result[0].id;
} else {
throw new Error('something is wrong!');
}
});
} | [
"function",
"getMaxOperationId",
"(",
")",
"{",
"var",
"query",
"=",
"new",
"Query",
"(",
"operationTableName",
")",
";",
"return",
"store",
".",
"read",
"(",
"query",
".",
"orderByDescending",
"(",
"'id'",
")",
".",
"take",
"(",
"1",
")",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"Validate",
".",
"isArray",
"(",
"result",
")",
";",
"if",
"(",
"result",
".",
"length",
"===",
"0",
")",
"{",
"return",
"0",
";",
"}",
"else",
"if",
"(",
"result",
".",
"length",
"===",
"1",
")",
"{",
"return",
"result",
"[",
"0",
"]",
".",
"id",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"'something is wrong!'",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets the largest operation ID from the operation table
If there are no records in the operation table, returns 0. | [
"Gets",
"the",
"largest",
"operation",
"ID",
"from",
"the",
"operation",
"table",
"If",
"there",
"are",
"no",
"records",
"in",
"the",
"operation",
"table",
"returns",
"0",
"."
] | bd4f9ba795527fbb95eca0f4ab53eb798934beba | https://github.com/Azure/azure-mobile-apps-js-client/blob/bd4f9ba795527fbb95eca0f4ab53eb798934beba/sdk/src/sync/operations.js#L401-L414 | train |
Azure/azure-mobile-apps-js-client | sdk/src/sync/push.js | push | function push(handler) {
return pushTaskRunner.run(function() {
reset();
pushHandler = handler;
return pushAllOperations().then(function() {
return pushConflicts;
});
});
} | javascript | function push(handler) {
return pushTaskRunner.run(function() {
reset();
pushHandler = handler;
return pushAllOperations().then(function() {
return pushConflicts;
});
});
} | [
"function",
"push",
"(",
"handler",
")",
"{",
"return",
"pushTaskRunner",
".",
"run",
"(",
"function",
"(",
")",
"{",
"reset",
"(",
")",
";",
"pushHandler",
"=",
"handler",
";",
"return",
"pushAllOperations",
"(",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"pushConflicts",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | Pushes operations performed on the local store to the server tables.
@returns A promise that is fulfilled when all pending operations are pushed. Conflict errors won't fail the push operation.
All conflicts are collected and returned to the user at the completion of the push operation.
The promise is rejected if pushing any record fails for reasons other than conflict or is cancelled. | [
"Pushes",
"operations",
"performed",
"on",
"the",
"local",
"store",
"to",
"the",
"server",
"tables",
"."
] | bd4f9ba795527fbb95eca0f4ab53eb798934beba | https://github.com/Azure/azure-mobile-apps-js-client/blob/bd4f9ba795527fbb95eca0f4ab53eb798934beba/sdk/src/sync/push.js#L44-L52 | train |
Azure/azure-mobile-apps-js-client | sdk/src/sync/push.js | pushAllOperations | function pushAllOperations() {
var currentOperation,
pushError;
return readAndLockFirstPendingOperation().then(function(pendingOperation) {
if (!pendingOperation) {
return; // No more pending operations. Push is complete
}
var currentOperation = pendingOperation;
return pushOperation(currentOperation).then(function() {
return removeLockedOperation();
}, function(error) {
// failed to push
return unlockPendingOperation().then(function() {
pushError = createPushError(store, operationTableManager, storeTaskRunner, currentOperation, error);
//TODO: If the conflict isn't resolved but the error is marked as handled by the user,
//we can end up in an infinite loop. Guard against this by capping the max number of
//times handlePushError can be called for the same record.
// We want to reset the retryCount when we move on to the next record
if (lastFailedOperationId !== currentOperation.logRecord.id) {
lastFailedOperationId = currentOperation.logRecord.id;
retryCount = 0;
}
// Cap the number of times error handling logic is invoked for the same record
if (retryCount < maxRetryCount) {
++retryCount;
return handlePushError(pushError, pushHandler);
}
});
}).then(function() {
if (!pushError) { // no push error
lastProcessedOperationId = currentOperation.logRecord.id;
} else if (pushError && !pushError.isHandled) { // push failed and not handled
// For conflict errors, we add the error to the list of errors and continue pushing other records
// For other errors, we abort push.
if (pushError.isConflict()) {
lastProcessedOperationId = currentOperation.logRecord.id;
pushConflicts.push(pushError);
} else {
throw new verror.VError(pushError.getError(), 'Push failed while pushing operation for tableName : ' + currentOperation.logRecord.tableName +
', action: ' + currentOperation.logRecord.action +
', and record ID: ' + currentOperation.logRecord.itemId);
}
} else { // push error handled
// No action needed - We want the operation to be re-pushed.
// No special handling is needed even if the operation was cancelled by the user as part of error handling
}
}).then(function() {
return pushAllOperations(); // push remaining operations
});
});
} | javascript | function pushAllOperations() {
var currentOperation,
pushError;
return readAndLockFirstPendingOperation().then(function(pendingOperation) {
if (!pendingOperation) {
return; // No more pending operations. Push is complete
}
var currentOperation = pendingOperation;
return pushOperation(currentOperation).then(function() {
return removeLockedOperation();
}, function(error) {
// failed to push
return unlockPendingOperation().then(function() {
pushError = createPushError(store, operationTableManager, storeTaskRunner, currentOperation, error);
//TODO: If the conflict isn't resolved but the error is marked as handled by the user,
//we can end up in an infinite loop. Guard against this by capping the max number of
//times handlePushError can be called for the same record.
// We want to reset the retryCount when we move on to the next record
if (lastFailedOperationId !== currentOperation.logRecord.id) {
lastFailedOperationId = currentOperation.logRecord.id;
retryCount = 0;
}
// Cap the number of times error handling logic is invoked for the same record
if (retryCount < maxRetryCount) {
++retryCount;
return handlePushError(pushError, pushHandler);
}
});
}).then(function() {
if (!pushError) { // no push error
lastProcessedOperationId = currentOperation.logRecord.id;
} else if (pushError && !pushError.isHandled) { // push failed and not handled
// For conflict errors, we add the error to the list of errors and continue pushing other records
// For other errors, we abort push.
if (pushError.isConflict()) {
lastProcessedOperationId = currentOperation.logRecord.id;
pushConflicts.push(pushError);
} else {
throw new verror.VError(pushError.getError(), 'Push failed while pushing operation for tableName : ' + currentOperation.logRecord.tableName +
', action: ' + currentOperation.logRecord.action +
', and record ID: ' + currentOperation.logRecord.itemId);
}
} else { // push error handled
// No action needed - We want the operation to be re-pushed.
// No special handling is needed even if the operation was cancelled by the user as part of error handling
}
}).then(function() {
return pushAllOperations(); // push remaining operations
});
});
} | [
"function",
"pushAllOperations",
"(",
")",
"{",
"var",
"currentOperation",
",",
"pushError",
";",
"return",
"readAndLockFirstPendingOperation",
"(",
")",
".",
"then",
"(",
"function",
"(",
"pendingOperation",
")",
"{",
"if",
"(",
"!",
"pendingOperation",
")",
"{",
"return",
";",
"}",
"var",
"currentOperation",
"=",
"pendingOperation",
";",
"return",
"pushOperation",
"(",
"currentOperation",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"removeLockedOperation",
"(",
")",
";",
"}",
",",
"function",
"(",
"error",
")",
"{",
"return",
"unlockPendingOperation",
"(",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"pushError",
"=",
"createPushError",
"(",
"store",
",",
"operationTableManager",
",",
"storeTaskRunner",
",",
"currentOperation",
",",
"error",
")",
";",
"if",
"(",
"lastFailedOperationId",
"!==",
"currentOperation",
".",
"logRecord",
".",
"id",
")",
"{",
"lastFailedOperationId",
"=",
"currentOperation",
".",
"logRecord",
".",
"id",
";",
"retryCount",
"=",
"0",
";",
"}",
"if",
"(",
"retryCount",
"<",
"maxRetryCount",
")",
"{",
"++",
"retryCount",
";",
"return",
"handlePushError",
"(",
"pushError",
",",
"pushHandler",
")",
";",
"}",
"}",
")",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"pushError",
")",
"{",
"lastProcessedOperationId",
"=",
"currentOperation",
".",
"logRecord",
".",
"id",
";",
"}",
"else",
"if",
"(",
"pushError",
"&&",
"!",
"pushError",
".",
"isHandled",
")",
"{",
"if",
"(",
"pushError",
".",
"isConflict",
"(",
")",
")",
"{",
"lastProcessedOperationId",
"=",
"currentOperation",
".",
"logRecord",
".",
"id",
";",
"pushConflicts",
".",
"push",
"(",
"pushError",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"verror",
".",
"VError",
"(",
"pushError",
".",
"getError",
"(",
")",
",",
"'Push failed while pushing operation for tableName : '",
"+",
"currentOperation",
".",
"logRecord",
".",
"tableName",
"+",
"', action: '",
"+",
"currentOperation",
".",
"logRecord",
".",
"action",
"+",
"', and record ID: '",
"+",
"currentOperation",
".",
"logRecord",
".",
"itemId",
")",
";",
"}",
"}",
"else",
"{",
"}",
"}",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"pushAllOperations",
"(",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | Pushes all pending operations, one at a time. 1. Read the oldest pending operation 2. If 1 did not fetch any operation, go to 6. 3. Lock the operation obtained in step 1 and push it. 4. If 3 is successful, unlock and remove the locked operation from the operation table and go to 1 Else if 3 fails, unlock the operation. 5. If the error is a conflict, handle the conflict and go to 1. 6. Else, EXIT. | [
"Pushes",
"all",
"pending",
"operations",
"one",
"at",
"a",
"time",
".",
"1",
".",
"Read",
"the",
"oldest",
"pending",
"operation",
"2",
".",
"If",
"1",
"did",
"not",
"fetch",
"any",
"operation",
"go",
"to",
"6",
".",
"3",
".",
"Lock",
"the",
"operation",
"obtained",
"in",
"step",
"1",
"and",
"push",
"it",
".",
"4",
".",
"If",
"3",
"is",
"successful",
"unlock",
"and",
"remove",
"the",
"locked",
"operation",
"from",
"the",
"operation",
"table",
"and",
"go",
"to",
"1",
"Else",
"if",
"3",
"fails",
"unlock",
"the",
"operation",
".",
"5",
".",
"If",
"the",
"error",
"is",
"a",
"conflict",
"handle",
"the",
"conflict",
"and",
"go",
"to",
"1",
".",
"6",
".",
"Else",
"EXIT",
"."
] | bd4f9ba795527fbb95eca0f4ab53eb798934beba | https://github.com/Azure/azure-mobile-apps-js-client/blob/bd4f9ba795527fbb95eca0f4ab53eb798934beba/sdk/src/sync/push.js#L70-L125 | train |
Azure/azure-mobile-apps-js-client | sdk/src/Platform/web/index.js | function (err) {
if (_.isNull(err)) {
// Call complete with all the args except for err
complete.apply(null, Array.prototype.slice.call(arguments, 1));
} else {
error(err);
}
} | javascript | function (err) {
if (_.isNull(err)) {
// Call complete with all the args except for err
complete.apply(null, Array.prototype.slice.call(arguments, 1));
} else {
error(err);
}
} | [
"function",
"(",
"err",
")",
"{",
"if",
"(",
"_",
".",
"isNull",
"(",
"err",
")",
")",
"{",
"complete",
".",
"apply",
"(",
"null",
",",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
")",
";",
"}",
"else",
"{",
"error",
"(",
"err",
")",
";",
"}",
"}"
] | Add a callback to the args which will call the appropriate promise handlers | [
"Add",
"a",
"callback",
"to",
"the",
"args",
"which",
"will",
"call",
"the",
"appropriate",
"promise",
"handlers"
] | bd4f9ba795527fbb95eca0f4ab53eb798934beba | https://github.com/Azure/azure-mobile-apps-js-client/blob/bd4f9ba795527fbb95eca0f4ab53eb798934beba/sdk/src/Platform/web/index.js#L65-L72 | train |
|
Azure/azure-mobile-apps-js-client | sdk/src/sync/pushError.js | handlePushError | function handlePushError(pushError, pushHandler) {
return Platform.async(function(callback) {
callback();
})().then(function() {
if (pushError.isConflict()) {
if (pushHandler && pushHandler.onConflict) {
// NOTE: value of server record will not be available in case of 409.
return pushHandler.onConflict(pushError);
}
} else if (pushHandler && pushHandler.onError) {
return pushHandler.onError(pushError);
}
}).then(undefined, function(error) {
// Set isHandled to false even if the user has set it to handled if the onConflict / onError failed
pushError.isHandled = false;
});
} | javascript | function handlePushError(pushError, pushHandler) {
return Platform.async(function(callback) {
callback();
})().then(function() {
if (pushError.isConflict()) {
if (pushHandler && pushHandler.onConflict) {
// NOTE: value of server record will not be available in case of 409.
return pushHandler.onConflict(pushError);
}
} else if (pushHandler && pushHandler.onError) {
return pushHandler.onError(pushError);
}
}).then(undefined, function(error) {
// Set isHandled to false even if the user has set it to handled if the onConflict / onError failed
pushError.isHandled = false;
});
} | [
"function",
"handlePushError",
"(",
"pushError",
",",
"pushHandler",
")",
"{",
"return",
"Platform",
".",
"async",
"(",
"function",
"(",
"callback",
")",
"{",
"callback",
"(",
")",
";",
"}",
")",
"(",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"pushError",
".",
"isConflict",
"(",
")",
")",
"{",
"if",
"(",
"pushHandler",
"&&",
"pushHandler",
".",
"onConflict",
")",
"{",
"return",
"pushHandler",
".",
"onConflict",
"(",
"pushError",
")",
";",
"}",
"}",
"else",
"if",
"(",
"pushHandler",
"&&",
"pushHandler",
".",
"onError",
")",
"{",
"return",
"pushHandler",
".",
"onError",
"(",
"pushError",
")",
";",
"}",
"}",
")",
".",
"then",
"(",
"undefined",
",",
"function",
"(",
"error",
")",
"{",
"pushError",
".",
"isHandled",
"=",
"false",
";",
"}",
")",
";",
"}"
] | Attempts error handling by delegating it to the user, if a push handler is provided
@private | [
"Attempts",
"error",
"handling",
"by",
"delegating",
"it",
"to",
"the",
"user",
"if",
"a",
"push",
"handler",
"is",
"provided"
] | bd4f9ba795527fbb95eca0f4ab53eb798934beba | https://github.com/Azure/azure-mobile-apps-js-client/blob/bd4f9ba795527fbb95eca0f4ab53eb798934beba/sdk/src/sync/pushError.js#L448-L466 | train |
Azure/azure-mobile-apps-js-client | sdk/src/MobileServiceTable.js | removeSystemProperties | function removeSystemProperties(instance) {
var copy = {};
for (var property in instance) {
if ((property != MobileServiceSystemColumns.Version) &&
(property != MobileServiceSystemColumns.UpdatedAt) &&
(property != MobileServiceSystemColumns.CreatedAt) &&
(property != MobileServiceSystemColumns.Deleted))
{
copy[property] = instance[property];
}
}
return copy;
} | javascript | function removeSystemProperties(instance) {
var copy = {};
for (var property in instance) {
if ((property != MobileServiceSystemColumns.Version) &&
(property != MobileServiceSystemColumns.UpdatedAt) &&
(property != MobileServiceSystemColumns.CreatedAt) &&
(property != MobileServiceSystemColumns.Deleted))
{
copy[property] = instance[property];
}
}
return copy;
} | [
"function",
"removeSystemProperties",
"(",
"instance",
")",
"{",
"var",
"copy",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"property",
"in",
"instance",
")",
"{",
"if",
"(",
"(",
"property",
"!=",
"MobileServiceSystemColumns",
".",
"Version",
")",
"&&",
"(",
"property",
"!=",
"MobileServiceSystemColumns",
".",
"UpdatedAt",
")",
"&&",
"(",
"property",
"!=",
"MobileServiceSystemColumns",
".",
"CreatedAt",
")",
"&&",
"(",
"property",
"!=",
"MobileServiceSystemColumns",
".",
"Deleted",
")",
")",
"{",
"copy",
"[",
"property",
"]",
"=",
"instance",
"[",
"property",
"]",
";",
"}",
"}",
"return",
"copy",
";",
"}"
] | Table system properties | [
"Table",
"system",
"properties"
] | bd4f9ba795527fbb95eca0f4ab53eb798934beba | https://github.com/Azure/azure-mobile-apps-js-client/blob/bd4f9ba795527fbb95eca0f4ab53eb798934beba/sdk/src/MobileServiceTable.js#L654-L666 | train |
Azure/azure-mobile-apps-js-client | sdk/src/MobileServiceTable.js | getItemFromResponse | function getItemFromResponse(response) {
var result = _.fromJson(response.responseText);
if (response.getResponseHeader) {
var eTag = response.getResponseHeader('ETag');
if (!_.isNullOrEmpty(eTag)) {
result[MobileServiceSystemColumns.Version] = getVersionFromEtag(eTag);
}
}
return result;
} | javascript | function getItemFromResponse(response) {
var result = _.fromJson(response.responseText);
if (response.getResponseHeader) {
var eTag = response.getResponseHeader('ETag');
if (!_.isNullOrEmpty(eTag)) {
result[MobileServiceSystemColumns.Version] = getVersionFromEtag(eTag);
}
}
return result;
} | [
"function",
"getItemFromResponse",
"(",
"response",
")",
"{",
"var",
"result",
"=",
"_",
".",
"fromJson",
"(",
"response",
".",
"responseText",
")",
";",
"if",
"(",
"response",
".",
"getResponseHeader",
")",
"{",
"var",
"eTag",
"=",
"response",
".",
"getResponseHeader",
"(",
"'ETag'",
")",
";",
"if",
"(",
"!",
"_",
".",
"isNullOrEmpty",
"(",
"eTag",
")",
")",
"{",
"result",
"[",
"MobileServiceSystemColumns",
".",
"Version",
"]",
"=",
"getVersionFromEtag",
"(",
"eTag",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Add double quotes and unescape any internal quotes | [
"Add",
"double",
"quotes",
"and",
"unescape",
"any",
"internal",
"quotes"
] | bd4f9ba795527fbb95eca0f4ab53eb798934beba | https://github.com/Azure/azure-mobile-apps-js-client/blob/bd4f9ba795527fbb95eca0f4ab53eb798934beba/sdk/src/MobileServiceTable.js#L669-L678 | train |
Azure/azure-mobile-apps-js-client | sdk/src/MobileServiceTable.js | setServerItemIfPreconditionFailed | function setServerItemIfPreconditionFailed(error) {
if (error.request && error.request.status === 412) {
error.serverInstance = _.fromJson(error.request.responseText);
}
} | javascript | function setServerItemIfPreconditionFailed(error) {
if (error.request && error.request.status === 412) {
error.serverInstance = _.fromJson(error.request.responseText);
}
} | [
"function",
"setServerItemIfPreconditionFailed",
"(",
"error",
")",
"{",
"if",
"(",
"error",
".",
"request",
"&&",
"error",
".",
"request",
".",
"status",
"===",
"412",
")",
"{",
"error",
".",
"serverInstance",
"=",
"_",
".",
"fromJson",
"(",
"error",
".",
"request",
".",
"responseText",
")",
";",
"}",
"}"
] | Converts an error to precondition failed error | [
"Converts",
"an",
"error",
"to",
"precondition",
"failed",
"error"
] | bd4f9ba795527fbb95eca0f4ab53eb798934beba | https://github.com/Azure/azure-mobile-apps-js-client/blob/bd4f9ba795527fbb95eca0f4ab53eb798934beba/sdk/src/MobileServiceTable.js#L681-L685 | train |
Azure/azure-mobile-apps-js-client | sdk/src/MobileServiceTable.js | getVersionFromEtag | function getVersionFromEtag(etag) {
var len = etag.length,
result = etag;
if (len > 1 && etag[0] === '"' && etag[len - 1] === '"') {
result = etag.substr(1, len - 2);
}
return result.replace(/\\\"/g, '"');
} | javascript | function getVersionFromEtag(etag) {
var len = etag.length,
result = etag;
if (len > 1 && etag[0] === '"' && etag[len - 1] === '"') {
result = etag.substr(1, len - 2);
}
return result.replace(/\\\"/g, '"');
} | [
"function",
"getVersionFromEtag",
"(",
"etag",
")",
"{",
"var",
"len",
"=",
"etag",
".",
"length",
",",
"result",
"=",
"etag",
";",
"if",
"(",
"len",
">",
"1",
"&&",
"etag",
"[",
"0",
"]",
"===",
"'\"'",
"&&",
"etag",
"[",
"len",
"-",
"1",
"]",
"===",
"'\"'",
")",
"{",
"result",
"=",
"etag",
".",
"substr",
"(",
"1",
",",
"len",
"-",
"2",
")",
";",
"}",
"return",
"result",
".",
"replace",
"(",
"/",
"\\\\\\\"",
"/",
"g",
",",
"'\"'",
")",
";",
"}"
] | Remove surrounding double quotes and unescape internal quotes | [
"Remove",
"surrounding",
"double",
"quotes",
"and",
"unescape",
"internal",
"quotes"
] | bd4f9ba795527fbb95eca0f4ab53eb798934beba | https://github.com/Azure/azure-mobile-apps-js-client/blob/bd4f9ba795527fbb95eca0f4ab53eb798934beba/sdk/src/MobileServiceTable.js#L694-L702 | train |
Azure/azure-mobile-apps-js-client | sdk/src/MobileServiceTable.js | addQueryParametersFeaturesIfApplicable | function addQueryParametersFeaturesIfApplicable(features, userQueryParameters) {
var hasQueryParameters = false;
if (userQueryParameters) {
if (Array.isArray(userQueryParameters)) {
hasQueryParameters = userQueryParameters.length > 0;
} else if (_.isObject(userQueryParameters)) {
for (var k in userQueryParameters) {
hasQueryParameters = true;
break;
}
}
}
if (hasQueryParameters) {
features.push(constants.features.AdditionalQueryParameters);
}
return features;
} | javascript | function addQueryParametersFeaturesIfApplicable(features, userQueryParameters) {
var hasQueryParameters = false;
if (userQueryParameters) {
if (Array.isArray(userQueryParameters)) {
hasQueryParameters = userQueryParameters.length > 0;
} else if (_.isObject(userQueryParameters)) {
for (var k in userQueryParameters) {
hasQueryParameters = true;
break;
}
}
}
if (hasQueryParameters) {
features.push(constants.features.AdditionalQueryParameters);
}
return features;
} | [
"function",
"addQueryParametersFeaturesIfApplicable",
"(",
"features",
",",
"userQueryParameters",
")",
"{",
"var",
"hasQueryParameters",
"=",
"false",
";",
"if",
"(",
"userQueryParameters",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"userQueryParameters",
")",
")",
"{",
"hasQueryParameters",
"=",
"userQueryParameters",
".",
"length",
">",
"0",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isObject",
"(",
"userQueryParameters",
")",
")",
"{",
"for",
"(",
"var",
"k",
"in",
"userQueryParameters",
")",
"{",
"hasQueryParameters",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"hasQueryParameters",
")",
"{",
"features",
".",
"push",
"(",
"constants",
".",
"features",
".",
"AdditionalQueryParameters",
")",
";",
"}",
"return",
"features",
";",
"}"
] | Updates and returns the headers parameters with features used in the call | [
"Updates",
"and",
"returns",
"the",
"headers",
"parameters",
"with",
"features",
"used",
"in",
"the",
"call"
] | bd4f9ba795527fbb95eca0f4ab53eb798934beba | https://github.com/Azure/azure-mobile-apps-js-client/blob/bd4f9ba795527fbb95eca0f4ab53eb798934beba/sdk/src/MobileServiceTable.js#L705-L723 | train |
lethexa/leaflet-tracksymbol | leaflet-tracksymbol.js | function(gpsRefPos) {
if(gpsRefPos === undefined ||
gpsRefPos.length < 4) {
this._gpsRefPos = undefined;
}
else if(gpsRefPos[0] === 0 &&
gpsRefPos[1] === 0 &&
gpsRefPos[2] === 0 &&
gpsRefPos[3] === 0) {
this._gpsRefPos = undefined;
}
else {
this._gpsRefPos = gpsRefPos;
}
return this.redraw();
} | javascript | function(gpsRefPos) {
if(gpsRefPos === undefined ||
gpsRefPos.length < 4) {
this._gpsRefPos = undefined;
}
else if(gpsRefPos[0] === 0 &&
gpsRefPos[1] === 0 &&
gpsRefPos[2] === 0 &&
gpsRefPos[3] === 0) {
this._gpsRefPos = undefined;
}
else {
this._gpsRefPos = gpsRefPos;
}
return this.redraw();
} | [
"function",
"(",
"gpsRefPos",
")",
"{",
"if",
"(",
"gpsRefPos",
"===",
"undefined",
"||",
"gpsRefPos",
".",
"length",
"<",
"4",
")",
"{",
"this",
".",
"_gpsRefPos",
"=",
"undefined",
";",
"}",
"else",
"if",
"(",
"gpsRefPos",
"[",
"0",
"]",
"===",
"0",
"&&",
"gpsRefPos",
"[",
"1",
"]",
"===",
"0",
"&&",
"gpsRefPos",
"[",
"2",
"]",
"===",
"0",
"&&",
"gpsRefPos",
"[",
"3",
"]",
"===",
"0",
")",
"{",
"this",
".",
"_gpsRefPos",
"=",
"undefined",
";",
"}",
"else",
"{",
"this",
".",
"_gpsRefPos",
"=",
"gpsRefPos",
";",
"}",
"return",
"this",
".",
"redraw",
"(",
")",
";",
"}"
] | Sets the position offset of the silouette to the center of the symbol.
The array contains the refpoints from ITU R-REC-M.1371-4-201004 page 108
in sequence A,B,C,D.
@method setGPSRefPos
@param gpsRefPos {Array} The GPS offset from center. | [
"Sets",
"the",
"position",
"offset",
"of",
"the",
"silouette",
"to",
"the",
"center",
"of",
"the",
"symbol",
".",
"The",
"array",
"contains",
"the",
"refpoints",
"from",
"ITU",
"R",
"-",
"REC",
"-",
"M",
".",
"1371",
"-",
"4",
"-",
"201004",
"page",
"108",
"in",
"sequence",
"A",
"B",
"C",
"D",
"."
] | 835deeaa42a7de7c5ec6b96c5bd00dcc994abc15 | https://github.com/lethexa/leaflet-tracksymbol/blob/835deeaa42a7de7c5ec6b96c5bd00dcc994abc15/leaflet-tracksymbol.js#L191-L206 | train |
|
lethexa/leaflet-tracksymbol | leaflet-tracksymbol.js | function () {
var lngSize = this._getLngSize() / 2.0;
var latSize = this._getLatSize() / 2.0;
var latlng = this._latlng;
return new L.LatLngBounds(
[latlng.lat - latSize, latlng.lng - lngSize],
[latlng.lat + latSize, latlng.lng + lngSize]);
} | javascript | function () {
var lngSize = this._getLngSize() / 2.0;
var latSize = this._getLatSize() / 2.0;
var latlng = this._latlng;
return new L.LatLngBounds(
[latlng.lat - latSize, latlng.lng - lngSize],
[latlng.lat + latSize, latlng.lng + lngSize]);
} | [
"function",
"(",
")",
"{",
"var",
"lngSize",
"=",
"this",
".",
"_getLngSize",
"(",
")",
"/",
"2.0",
";",
"var",
"latSize",
"=",
"this",
".",
"_getLatSize",
"(",
")",
"/",
"2.0",
";",
"var",
"latlng",
"=",
"this",
".",
"_latlng",
";",
"return",
"new",
"L",
".",
"LatLngBounds",
"(",
"[",
"latlng",
".",
"lat",
"-",
"latSize",
",",
"latlng",
".",
"lng",
"-",
"lngSize",
"]",
",",
"[",
"latlng",
".",
"lat",
"+",
"latSize",
",",
"latlng",
".",
"lng",
"+",
"lngSize",
"]",
")",
";",
"}"
] | Returns the bounding box of the symbol.
@method getBounds
@return {LatLngBounds} The bounding box. | [
"Returns",
"the",
"bounding",
"box",
"of",
"the",
"symbol",
"."
] | 835deeaa42a7de7c5ec6b96c5bd00dcc994abc15 | https://github.com/lethexa/leaflet-tracksymbol/blob/835deeaa42a7de7c5ec6b96c5bd00dcc994abc15/leaflet-tracksymbol.js#L238-L245 | train |
|
lethexa/leaflet-tracksymbol | leaflet-tracksymbol.js | function(point, angle) {
var x = point[0];
var y = point[1];
var si_z = Math.sin(angle);
var co_z = Math.cos(angle);
var newX = x * co_z - y * si_z;
var newY = x * si_z + y * co_z;
return [newX, newY];
} | javascript | function(point, angle) {
var x = point[0];
var y = point[1];
var si_z = Math.sin(angle);
var co_z = Math.cos(angle);
var newX = x * co_z - y * si_z;
var newY = x * si_z + y * co_z;
return [newX, newY];
} | [
"function",
"(",
"point",
",",
"angle",
")",
"{",
"var",
"x",
"=",
"point",
"[",
"0",
"]",
";",
"var",
"y",
"=",
"point",
"[",
"1",
"]",
";",
"var",
"si_z",
"=",
"Math",
".",
"sin",
"(",
"angle",
")",
";",
"var",
"co_z",
"=",
"Math",
".",
"cos",
"(",
"angle",
")",
";",
"var",
"newX",
"=",
"x",
"*",
"co_z",
"-",
"y",
"*",
"si_z",
";",
"var",
"newY",
"=",
"x",
"*",
"si_z",
"+",
"y",
"*",
"co_z",
";",
"return",
"[",
"newX",
",",
"newY",
"]",
";",
"}"
] | Rotates the given point around the angle. @method _rotate @param point {Array} A point vector 2d. @param angle {Number} Angle for rotation [rad]. @return The rotated vector 2d. | [
"Rotates",
"the",
"given",
"point",
"around",
"the",
"angle",
"."
] | 835deeaa42a7de7c5ec6b96c5bd00dcc994abc15 | https://github.com/lethexa/leaflet-tracksymbol/blob/835deeaa42a7de7c5ec6b96c5bd00dcc994abc15/leaflet-tracksymbol.js#L263-L271 | train |
|
lethexa/leaflet-tracksymbol | leaflet-tracksymbol.js | function(points, angle) {
var result = [];
for(var i=0;i<points.length;i+=2) {
var x = points[i + 0] * this._size;
var y = points[i + 1] * this._size;
var pt = this._rotate([x, y], angle);
result.push(pt[0]);
result.push(pt[1]);
}
return result;
} | javascript | function(points, angle) {
var result = [];
for(var i=0;i<points.length;i+=2) {
var x = points[i + 0] * this._size;
var y = points[i + 1] * this._size;
var pt = this._rotate([x, y], angle);
result.push(pt[0]);
result.push(pt[1]);
}
return result;
} | [
"function",
"(",
"points",
",",
"angle",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"points",
".",
"length",
";",
"i",
"+=",
"2",
")",
"{",
"var",
"x",
"=",
"points",
"[",
"i",
"+",
"0",
"]",
"*",
"this",
".",
"_size",
";",
"var",
"y",
"=",
"points",
"[",
"i",
"+",
"1",
"]",
"*",
"this",
".",
"_size",
";",
"var",
"pt",
"=",
"this",
".",
"_rotate",
"(",
"[",
"x",
",",
"y",
"]",
",",
"angle",
")",
";",
"result",
".",
"push",
"(",
"pt",
"[",
"0",
"]",
")",
";",
"result",
".",
"push",
"(",
"pt",
"[",
"1",
"]",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Rotates the given point-array around the angle. @method _rotateAllPoints @param points {Array} A point vector 2d. @param angle {Number} Angle for rotation [rad]. @return The rotated vector-array 2d. | [
"Rotates",
"the",
"given",
"point",
"-",
"array",
"around",
"the",
"angle",
"."
] | 835deeaa42a7de7c5ec6b96c5bd00dcc994abc15 | https://github.com/lethexa/leaflet-tracksymbol/blob/835deeaa42a7de7c5ec6b96c5bd00dcc994abc15/leaflet-tracksymbol.js#L280-L290 | train |
|
lethexa/leaflet-tracksymbol | leaflet-tracksymbol.js | function () {
if(this._heading === undefined) {
return this._createNoHeadingSymbolPathString();
}
else {
if(this._gpsRefPos === undefined || this._map.getZoom() <= this._minSilouetteZoom ) {
return this._createWithHeadingSymbolPathString();
}
else {
return this._createSilouetteSymbolPathString();
}
}
} | javascript | function () {
if(this._heading === undefined) {
return this._createNoHeadingSymbolPathString();
}
else {
if(this._gpsRefPos === undefined || this._map.getZoom() <= this._minSilouetteZoom ) {
return this._createWithHeadingSymbolPathString();
}
else {
return this._createSilouetteSymbolPathString();
}
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_heading",
"===",
"undefined",
")",
"{",
"return",
"this",
".",
"_createNoHeadingSymbolPathString",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"this",
".",
"_gpsRefPos",
"===",
"undefined",
"||",
"this",
".",
"_map",
".",
"getZoom",
"(",
")",
"<=",
"this",
".",
"_minSilouetteZoom",
")",
"{",
"return",
"this",
".",
"_createWithHeadingSymbolPathString",
"(",
")",
";",
"}",
"else",
"{",
"return",
"this",
".",
"_createSilouetteSymbolPathString",
"(",
")",
";",
"}",
"}",
"}"
] | Generates the symbol as SVG path string.
depending on zoomlevel or track heading different symbol types are generated.
@return {String} The symbol path string. | [
"Generates",
"the",
"symbol",
"as",
"SVG",
"path",
"string",
".",
"depending",
"on",
"zoomlevel",
"or",
"track",
"heading",
"different",
"symbol",
"types",
"are",
"generated",
"."
] | 835deeaa42a7de7c5ec6b96c5bd00dcc994abc15 | https://github.com/lethexa/leaflet-tracksymbol/blob/835deeaa42a7de7c5ec6b96c5bd00dcc994abc15/leaflet-tracksymbol.js#L412-L424 | train |
|
KyleAMathews/superagent-bluebird-promise | index.js | function(message, originalError) {
var stack;
this.message = message;
this.originalError = originalError;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
stack = this.stack;
} else {
stack = new Error(message).stack;
}
if (Object.defineProperty) {
Object.defineProperty(this, "stack", {
configurable: true, // required for Bluebird long stack traces
get: function() {
if (this.originalError) {
return stack + "\nCaused by: " + this.originalError.stack;
}
return stack;
},
set: function(value) {
stack = value;
}
});
}
} | javascript | function(message, originalError) {
var stack;
this.message = message;
this.originalError = originalError;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
stack = this.stack;
} else {
stack = new Error(message).stack;
}
if (Object.defineProperty) {
Object.defineProperty(this, "stack", {
configurable: true, // required for Bluebird long stack traces
get: function() {
if (this.originalError) {
return stack + "\nCaused by: " + this.originalError.stack;
}
return stack;
},
set: function(value) {
stack = value;
}
});
}
} | [
"function",
"(",
"message",
",",
"originalError",
")",
"{",
"var",
"stack",
";",
"this",
".",
"message",
"=",
"message",
";",
"this",
".",
"originalError",
"=",
"originalError",
";",
"if",
"(",
"Error",
".",
"captureStackTrace",
")",
"{",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"this",
".",
"constructor",
")",
";",
"stack",
"=",
"this",
".",
"stack",
";",
"}",
"else",
"{",
"stack",
"=",
"new",
"Error",
"(",
"message",
")",
".",
"stack",
";",
"}",
"if",
"(",
"Object",
".",
"defineProperty",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"\"stack\"",
",",
"{",
"configurable",
":",
"true",
",",
"get",
":",
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"originalError",
")",
"{",
"return",
"stack",
"+",
"\"\\nCaused by: \"",
"+",
"\\n",
";",
"}",
"this",
".",
"originalError",
".",
"stack",
"}",
",",
"return",
"stack",
";",
"}",
")",
";",
"}",
"}"
] | Create custom error type. Create a new object, that prototypally inherits from the Error constructor. | [
"Create",
"custom",
"error",
"type",
".",
"Create",
"a",
"new",
"object",
"that",
"prototypally",
"inherits",
"from",
"the",
"Error",
"constructor",
"."
] | 31f8298e583b2cc5e70fb43a1c3a016d80755360 | https://github.com/KyleAMathews/superagent-bluebird-promise/blob/31f8298e583b2cc5e70fb43a1c3a016d80755360/index.js#L27-L54 | train |
|
karma-runner/karma-ie-launcher | index.js | getInternetExplorerExe | function getInternetExplorerExe () {
var suffix = path.join('Internet Explorer', PROCESS_NAME)
var locations = _.map(_.compact([
process.env['PROGRAMW6432'],
process.env['PROGRAMFILES(X86)'],
process.env['PROGRAMFILES']
]), function (prefix) {
return path.join(prefix, suffix)
})
return _.find(locations, function (location) {
return fs.existsSync(location)
})
} | javascript | function getInternetExplorerExe () {
var suffix = path.join('Internet Explorer', PROCESS_NAME)
var locations = _.map(_.compact([
process.env['PROGRAMW6432'],
process.env['PROGRAMFILES(X86)'],
process.env['PROGRAMFILES']
]), function (prefix) {
return path.join(prefix, suffix)
})
return _.find(locations, function (location) {
return fs.existsSync(location)
})
} | [
"function",
"getInternetExplorerExe",
"(",
")",
"{",
"var",
"suffix",
"=",
"path",
".",
"join",
"(",
"'Internet Explorer'",
",",
"PROCESS_NAME",
")",
"var",
"locations",
"=",
"_",
".",
"map",
"(",
"_",
".",
"compact",
"(",
"[",
"process",
".",
"env",
"[",
"'PROGRAMW6432'",
"]",
",",
"process",
".",
"env",
"[",
"'PROGRAMFILES(X86)'",
"]",
",",
"process",
".",
"env",
"[",
"'PROGRAMFILES'",
"]",
"]",
")",
",",
"function",
"(",
"prefix",
")",
"{",
"return",
"path",
".",
"join",
"(",
"prefix",
",",
"suffix",
")",
"}",
")",
"return",
"_",
".",
"find",
"(",
"locations",
",",
"function",
"(",
"location",
")",
"{",
"return",
"fs",
".",
"existsSync",
"(",
"location",
")",
"}",
")",
"}"
] | Find the ie executable | [
"Find",
"the",
"ie",
"executable"
] | 7c95ad6d2ae96a1fd6bf8bd5d04aa88d435f8145 | https://github.com/karma-runner/karma-ie-launcher/blob/7c95ad6d2ae96a1fd6bf8bd5d04aa88d435f8145/index.js#L20-L33 | train |
LvChengbin/url | dist/url.cjs.js | merge | function merge( a, l, m, r ) {
const n1 = m - l + 1;
const n2 = r - m;
const L = a.slice( l, m + 1 );
const R = a.slice( m + 1, 1 + r );
let i = 0, j = 0, k = l;
while( i < n1 && j < n2 ) {
if( L[ i ][ 0 ] <= R[ j ][ 0 ] ) {
a[ k ] = L[ i ];
i++;
} else {
a[ k ] = R[ j ];
j++;
}
k++;
}
while( i < n1 ) {
a[ k ] = L[ i ];
i++;
k++;
}
while( j < n2 ) {
a[ k ] = R[ j ];
j++;
k++;
}
} | javascript | function merge( a, l, m, r ) {
const n1 = m - l + 1;
const n2 = r - m;
const L = a.slice( l, m + 1 );
const R = a.slice( m + 1, 1 + r );
let i = 0, j = 0, k = l;
while( i < n1 && j < n2 ) {
if( L[ i ][ 0 ] <= R[ j ][ 0 ] ) {
a[ k ] = L[ i ];
i++;
} else {
a[ k ] = R[ j ];
j++;
}
k++;
}
while( i < n1 ) {
a[ k ] = L[ i ];
i++;
k++;
}
while( j < n2 ) {
a[ k ] = R[ j ];
j++;
k++;
}
} | [
"function",
"merge",
"(",
"a",
",",
"l",
",",
"m",
",",
"r",
")",
"{",
"const",
"n1",
"=",
"m",
"-",
"l",
"+",
"1",
";",
"const",
"n2",
"=",
"r",
"-",
"m",
";",
"const",
"L",
"=",
"a",
".",
"slice",
"(",
"l",
",",
"m",
"+",
"1",
")",
";",
"const",
"R",
"=",
"a",
".",
"slice",
"(",
"m",
"+",
"1",
",",
"1",
"+",
"r",
")",
";",
"let",
"i",
"=",
"0",
",",
"j",
"=",
"0",
",",
"k",
"=",
"l",
";",
"while",
"(",
"i",
"<",
"n1",
"&&",
"j",
"<",
"n2",
")",
"{",
"if",
"(",
"L",
"[",
"i",
"]",
"[",
"0",
"]",
"<=",
"R",
"[",
"j",
"]",
"[",
"0",
"]",
")",
"{",
"a",
"[",
"k",
"]",
"=",
"L",
"[",
"i",
"]",
";",
"i",
"++",
";",
"}",
"else",
"{",
"a",
"[",
"k",
"]",
"=",
"R",
"[",
"j",
"]",
";",
"j",
"++",
";",
"}",
"k",
"++",
";",
"}",
"while",
"(",
"i",
"<",
"n1",
")",
"{",
"a",
"[",
"k",
"]",
"=",
"L",
"[",
"i",
"]",
";",
"i",
"++",
";",
"k",
"++",
";",
"}",
"while",
"(",
"j",
"<",
"n2",
")",
"{",
"a",
"[",
"k",
"]",
"=",
"R",
"[",
"j",
"]",
";",
"j",
"++",
";",
"k",
"++",
";",
"}",
"}"
] | function for merge sort | [
"function",
"for",
"merge",
"sort"
] | 4b53d642903b386ed86185831fa5e33a6af693d5 | https://github.com/LvChengbin/url/blob/4b53d642903b386ed86185831fa5e33a6af693d5/dist/url.cjs.js#L551-L580 | train |
ef4/ember-browserify | lib/index.js | findHost | function findHost() {
var current = this;
var app;
// Keep iterating upward until we don't have a grandparent.
// Has to do this grandparent check because at some point we hit the project.
// Stop at lazy engine boundaries.
do {
if (current.lazyLoading === true) { return current; }
app = current.app || app;
} while (current.parent && current.parent.parent && (current = current.parent));
return app;
} | javascript | function findHost() {
var current = this;
var app;
// Keep iterating upward until we don't have a grandparent.
// Has to do this grandparent check because at some point we hit the project.
// Stop at lazy engine boundaries.
do {
if (current.lazyLoading === true) { return current; }
app = current.app || app;
} while (current.parent && current.parent.parent && (current = current.parent));
return app;
} | [
"function",
"findHost",
"(",
")",
"{",
"var",
"current",
"=",
"this",
";",
"var",
"app",
";",
"do",
"{",
"if",
"(",
"current",
".",
"lazyLoading",
"===",
"true",
")",
"{",
"return",
"current",
";",
"}",
"app",
"=",
"current",
".",
"app",
"||",
"app",
";",
"}",
"while",
"(",
"current",
".",
"parent",
"&&",
"current",
".",
"parent",
".",
"parent",
"&&",
"(",
"current",
"=",
"current",
".",
"parent",
")",
")",
";",
"return",
"app",
";",
"}"
] | Support old versions of Ember CLI. | [
"Support",
"old",
"versions",
"of",
"Ember",
"CLI",
"."
] | 851bcc988df26406b6fda76b08f84fd118e95e7a | https://github.com/ef4/ember-browserify/blob/851bcc988df26406b6fda76b08f84fd118e95e7a/lib/index.js#L2-L15 | train |
ef4/ember-browserify | lib/caching-browserify.js | function(path) {
return (path && path.match(/^[a-z]:\\/i)) ? path.charAt(0).toLowerCase() + path.slice(1) : path;
} | javascript | function(path) {
return (path && path.match(/^[a-z]:\\/i)) ? path.charAt(0).toLowerCase() + path.slice(1) : path;
} | [
"function",
"(",
"path",
")",
"{",
"return",
"(",
"path",
"&&",
"path",
".",
"match",
"(",
"/",
"^[a-z]:\\\\",
"/",
"i",
")",
")",
"?",
"path",
".",
"charAt",
"(",
"0",
")",
".",
"toLowerCase",
"(",
")",
"+",
"path",
".",
"slice",
"(",
"1",
")",
":",
"path",
";",
"}"
] | Changes path drive-letter to lowercase for Windows | [
"Changes",
"path",
"drive",
"-",
"letter",
"to",
"lowercase",
"for",
"Windows"
] | 851bcc988df26406b6fda76b08f84fd118e95e7a | https://github.com/ef4/ember-browserify/blob/851bcc988df26406b6fda76b08f84fd118e95e7a/lib/caching-browserify.js#L206-L208 | train |
|
dbusjs/mpris-service | src/index.js | Player | function Player(opts) {
if (!(this instanceof Player)) {
return new Player(opts);
}
events.EventEmitter.call(this);
this.name = opts.name;
this.supportedInterfaces = opts.supportedInterfaces || ['player'];
this._tracks = [];
this.init(opts);
} | javascript | function Player(opts) {
if (!(this instanceof Player)) {
return new Player(opts);
}
events.EventEmitter.call(this);
this.name = opts.name;
this.supportedInterfaces = opts.supportedInterfaces || ['player'];
this._tracks = [];
this.init(opts);
} | [
"function",
"Player",
"(",
"opts",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Player",
")",
")",
"{",
"return",
"new",
"Player",
"(",
"opts",
")",
";",
"}",
"events",
".",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"name",
"=",
"opts",
".",
"name",
";",
"this",
".",
"supportedInterfaces",
"=",
"opts",
".",
"supportedInterfaces",
"||",
"[",
"'player'",
"]",
";",
"this",
".",
"_tracks",
"=",
"[",
"]",
";",
"this",
".",
"init",
"(",
"opts",
")",
";",
"}"
] | Construct a new Player and export it on the DBus session bus.
For more information about the properties of this class, see [the MPRIS DBus Interface Specification](https://specifications.freedesktop.org/mpris-spec/latest/).
Method Call Events
------------------
The Player is an `EventEmitter` that emits events when the corresponding
methods are called on the DBus interface over the wire.
The Player emits events whenever the corresponding methods on the DBus
interface are called.
* `raise` - Brings the media player's user interface to the front using any appropriate mechanism available.
* `quit` - Causes the media player to stop running.
* `next` - Skips to the next track in the tracklist.
* `previous` - Skips to the previous track in the tracklist.
* `pause` - Pauses playback.
* `playPause` - Pauses playback. If playback is already paused, resumes playback. If playback is stopped, starts playback.
* `stop` - Stops playback.
* `play` - Starts or resumes playback.
* `seek` - Seeks forward in the current track by the specified number of microseconds. With event data `offset`.
* `position` - Sets the current track position in microseconds. With event data `{ trackId, position }`.
* `open` - Opens the Uri given as an argument. With event data `{ uri }`.
* `volume` - Sets the volume of the player. With event data `volume` (between 0.0 and 1.0).
* `shuffle` - Sets whether shuffle is enabled on the player. With event data `shuffleStatus` (boolean).
* `rate` - Sets the playback rate of the player. A value of 1.0 is the normal rate. With event data `rate`.
* `loopStatus` - Sets the loop status of the player to either 'None', 'Track', or 'Playlist'. With event data `loopStatus`.
* `activatePlaylist` - Starts playing the given playlist. With event data `playlistId`.
The Player may also emit an `error` event with the underlying Node `Error`
as the event data. After receiving this event, the Player may be
disconnected.
```
player.on('play', () => {
realPlayer.play();
});
player.on('shuffle', (enableShuffle) => {
realPlayer.setShuffle(enableShuffle);
player.shuffle = enableShuffle;
});
```
Player Properties
-----------------
Player properties (documented below) should be kept up to date to reflect
the state of your real player. These properties can be gotten by the client
through the `org.freedesktop.DBus.Properties` interface which will return
the value currently set on the player. Setting these properties on the
player to a different value will emit the `PropertiesChanged` signal on the
properties interface to notify clients that properties of the player have
changed.
```
realPlayer.on('shuffle:changed', (shuffleEnabled) => {
player.shuffle = shuffleEnabled;
});
realPlayer.on('play', () => {
player.playbackStatus = 'Playing';
});
```
Player Position
---------------
Clients can get the position of your player by getting the `Position`
property of the `org.mpris.MediaPlayer2.Player` interface. Since position
updates continuously, {@link Player#getPosition} is implemented as a getter
you can override on your Player. This getter will be called when a client
requests the position and should return the position of your player for the
client in microseconds.
```
player.getPosition() {
return realPlayer.getPositionInMicroseconds();
}
```
When your real player seeks to a new location, such as when someone clicks
on the time bar, you can notify clients of the new position by calling the
{@link Player#seeked} method. This will raise the `Seeked` signal on the
`org.mpris.MediaPlayer2.Player` interface with the given current time of the
player in microseconds.
```
realPlayer.on('seeked', (positionInMicroseconds) => {
player.seeked(positionInMicroseconds);
});
```
Clients can request to set position using the `Seek` and `SetPosition`
methods of the `org.mpris.MediaPlayer2.Player` interface. These requests are
implemented as events on the Player similar to the other requests.
```
player.on('seek', (offset) => {
// note that offset may be negative
let currentPosition = realPlayer.getPositionInMicroseconds();
let newPosition = currentPosition + offset;
realPlayer.setPosition(newPosition);
});
player.on('position', (event) => {
// check that event.trackId is the current track before continuing.
realPlayer.setPosition(event.position);
});
```
@class Player
@param {Object} options - Options for the player
@param {String} options.name - Name on the bus to export to as `org.mpris.MediaPlayer2.{name}`.
@param {String} options.identity - Identity for the player to display on the root media player interface.
@param {Array} options.supportedMimeTypes - Mime types this player can open with the `org.mpris.MediaPlayer2.Open` method.
@param {Array} options.supportedInterfaces - The interfaces this player supports. Can include `'player'`, `'playlists'`, and `'trackList'`.
@property {String} identity - A friendly name to identify the media player to users.
@property {Boolean} fullscreen - Whether the media player is occupying the fullscreen.
@property {Array} supportedUriSchemes - The URI schemes supported by the media player.
@property {Array} supportedMimeTypes - The mime-types supported by the media player.
@property {Boolean} canQuit - Whether the player can quit.
@property {Boolean} canRaise - Whether the player can raise.
@property {Boolean} canSetFullscreen - Whether the player can be set to fullscreen.
@property {Boolean} hasTrackList - Indicates whether the /org/mpris/MediaPlayer2 object implements the org.mpris.MediaPlayer2.TrackList interface.
@property {String} desktopEntry - The basename of an installed .desktop file which complies with the Desktop entry specification, with the ".desktop" extension stripped.
@property {String} playbackStatus - The current playback status. May be "Playing", "Paused" or "Stopped".
@property {String} loopStatus - The current loop/repeat status. May be "None", "Track", or "Playlist".
@property {Boolean} shuffle - Whether the player is shuffling.
@property {Object} metadata - The metadata of the current element. If there is a current track, this must have a "mpris:trackid" entry (of D-Bus type "o") at the very least, which contains a D-Bus path that uniquely identifies this track.
@property {Double} volume - The volume level.
@property {Boolean} canControl - Whether the media player may be controlled over this interface.
@property {Boolean} canPause - Whether playback can be paused using Pause or PlayPause.
@property {Boolean} canPlay - Whether playback can be started using Play or PlayPause.
@property {Boolean} canSeek - Whether the client can control the playback position using Seek and SetPosition.
@property {Boolean} canGoNext - Whether the client can call the Next method on this interface and expect the current track to change.
@property {Boolean} canGoPrevious - Whether the client can call the Previous method on this interface and expect the current track to change.
@property {Double} rate - The current playback rate.
@property {Double} minimumRate - The minimum value which the Rate property can take.
@property {Double} maximumRate - The maximum value which the Rate property can take.
@property {Array} playlists - The current playlists set by {@link Player#setPlaylists}. (Not a DBus property).
@property {String} activePlaylist - The id of the currently-active playlist. | [
"Construct",
"a",
"new",
"Player",
"and",
"export",
"it",
"on",
"the",
"DBus",
"session",
"bus",
"."
] | ee50820e0c10981713c25cfe3e99005b9ab619c5 | https://github.com/dbusjs/mpris-service/blob/ee50820e0c10981713c25cfe3e99005b9ab619c5/src/index.js#L166-L176 | train |
extrabacon/google-oauth-jwt | lib/token-cache.js | TokenRequest | function TokenRequest(authenticate, options) {
var self = this;
this.status = 'expired';
this.pendingCallbacks = [];
// execute accumulated callbacks during the 'pending' state
function fireCallbacks(err, token) {
self.pendingCallbacks.forEach(function (callback) {
callback(err, token);
});
self.pendingCallbacks = [];
}
TokenRequest.prototype.get = function (callback) {
if (this.status == 'expired') {
this.status = 'pending';
this.pendingCallbacks.push(callback);
authenticate(options, function (err, token) {
if (err) {
self.status = 'expired';
return fireCallbacks(err, null);
}
self.issued = Date.now();
self.duration = options.expiration || 60 * 60 * 1000;
self.token = token;
self.status = 'completed';
return fireCallbacks(null, token);
});
} else if (this.status == 'pending') {
// wait for the pending request instead of issuing a new one
this.pendingCallbacks.push(callback);
} else if (this.status == 'completed') {
if (this.issued + this.duration < Date.now()) {
this.status = 'expired';
debug('token is expired, a new token will be requested');
this.get(callback);
} else {
callback(null, this.token);
}
}
};
} | javascript | function TokenRequest(authenticate, options) {
var self = this;
this.status = 'expired';
this.pendingCallbacks = [];
// execute accumulated callbacks during the 'pending' state
function fireCallbacks(err, token) {
self.pendingCallbacks.forEach(function (callback) {
callback(err, token);
});
self.pendingCallbacks = [];
}
TokenRequest.prototype.get = function (callback) {
if (this.status == 'expired') {
this.status = 'pending';
this.pendingCallbacks.push(callback);
authenticate(options, function (err, token) {
if (err) {
self.status = 'expired';
return fireCallbacks(err, null);
}
self.issued = Date.now();
self.duration = options.expiration || 60 * 60 * 1000;
self.token = token;
self.status = 'completed';
return fireCallbacks(null, token);
});
} else if (this.status == 'pending') {
// wait for the pending request instead of issuing a new one
this.pendingCallbacks.push(callback);
} else if (this.status == 'completed') {
if (this.issued + this.duration < Date.now()) {
this.status = 'expired';
debug('token is expired, a new token will be requested');
this.get(callback);
} else {
callback(null, this.token);
}
}
};
} | [
"function",
"TokenRequest",
"(",
"authenticate",
",",
"options",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"status",
"=",
"'expired'",
";",
"this",
".",
"pendingCallbacks",
"=",
"[",
"]",
";",
"function",
"fireCallbacks",
"(",
"err",
",",
"token",
")",
"{",
"self",
".",
"pendingCallbacks",
".",
"forEach",
"(",
"function",
"(",
"callback",
")",
"{",
"callback",
"(",
"err",
",",
"token",
")",
";",
"}",
")",
";",
"self",
".",
"pendingCallbacks",
"=",
"[",
"]",
";",
"}",
"TokenRequest",
".",
"prototype",
".",
"get",
"=",
"function",
"(",
"callback",
")",
"{",
"if",
"(",
"this",
".",
"status",
"==",
"'expired'",
")",
"{",
"this",
".",
"status",
"=",
"'pending'",
";",
"this",
".",
"pendingCallbacks",
".",
"push",
"(",
"callback",
")",
";",
"authenticate",
"(",
"options",
",",
"function",
"(",
"err",
",",
"token",
")",
"{",
"if",
"(",
"err",
")",
"{",
"self",
".",
"status",
"=",
"'expired'",
";",
"return",
"fireCallbacks",
"(",
"err",
",",
"null",
")",
";",
"}",
"self",
".",
"issued",
"=",
"Date",
".",
"now",
"(",
")",
";",
"self",
".",
"duration",
"=",
"options",
".",
"expiration",
"||",
"60",
"*",
"60",
"*",
"1000",
";",
"self",
".",
"token",
"=",
"token",
";",
"self",
".",
"status",
"=",
"'completed'",
";",
"return",
"fireCallbacks",
"(",
"null",
",",
"token",
")",
";",
"}",
")",
";",
"}",
"else",
"if",
"(",
"this",
".",
"status",
"==",
"'pending'",
")",
"{",
"this",
".",
"pendingCallbacks",
".",
"push",
"(",
"callback",
")",
";",
"}",
"else",
"if",
"(",
"this",
".",
"status",
"==",
"'completed'",
")",
"{",
"if",
"(",
"this",
".",
"issued",
"+",
"this",
".",
"duration",
"<",
"Date",
".",
"now",
"(",
")",
")",
"{",
"this",
".",
"status",
"=",
"'expired'",
";",
"debug",
"(",
"'token is expired, a new token will be requested'",
")",
";",
"this",
".",
"get",
"(",
"callback",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"null",
",",
"this",
".",
"token",
")",
";",
"}",
"}",
"}",
";",
"}"
] | A single cacheable token request with support for concurrency.
@private
@constructor | [
"A",
"single",
"cacheable",
"token",
"request",
"with",
"support",
"for",
"concurrency",
"."
] | 9032bb3e272e7ae3f227f822dc0e708cc0c89a62 | https://github.com/extrabacon/google-oauth-jwt/blob/9032bb3e272e7ae3f227f822dc0e708cc0c89a62/lib/token-cache.js#L54-L102 | train |
extrabacon/google-oauth-jwt | lib/token-cache.js | fireCallbacks | function fireCallbacks(err, token) {
self.pendingCallbacks.forEach(function (callback) {
callback(err, token);
});
self.pendingCallbacks = [];
} | javascript | function fireCallbacks(err, token) {
self.pendingCallbacks.forEach(function (callback) {
callback(err, token);
});
self.pendingCallbacks = [];
} | [
"function",
"fireCallbacks",
"(",
"err",
",",
"token",
")",
"{",
"self",
".",
"pendingCallbacks",
".",
"forEach",
"(",
"function",
"(",
"callback",
")",
"{",
"callback",
"(",
"err",
",",
"token",
")",
";",
"}",
")",
";",
"self",
".",
"pendingCallbacks",
"=",
"[",
"]",
";",
"}"
] | execute accumulated callbacks during the 'pending' state | [
"execute",
"accumulated",
"callbacks",
"during",
"the",
"pending",
"state"
] | 9032bb3e272e7ae3f227f822dc0e708cc0c89a62 | https://github.com/extrabacon/google-oauth-jwt/blob/9032bb3e272e7ae3f227f822dc0e708cc0c89a62/lib/token-cache.js#L61-L66 | train |
eemeli/dot-properties | parse.js | parseLines | function parseLines (src) {
const lines = []
for (i = 0; i < src.length; ++i) {
if (src[i] === '\n' && src[i - 1] === '\r') i += 1
if (!src[i]) break
const keyStart = endOfIndent(src, i)
if (atLineEnd(src, keyStart)) {
lines.push('')
i = keyStart
continue
}
if (atComment(src, keyStart)) {
const commentEnd = endOfComment(src, keyStart)
lines.push(src.slice(keyStart, commentEnd))
i = commentEnd
continue
}
const keyEnd = endOfKey(src, keyStart)
const key = unescape(src.slice(keyStart, keyEnd))
const valueStart = endOfSeparator(src, keyEnd)
if (atLineEnd(src, valueStart)) {
lines.push([key, ''])
i = valueStart
continue
}
const valueEnd = endOfValue(src, valueStart)
const value = unescape(src.slice(valueStart, valueEnd))
lines.push([key, value])
i = valueEnd
}
return lines
} | javascript | function parseLines (src) {
const lines = []
for (i = 0; i < src.length; ++i) {
if (src[i] === '\n' && src[i - 1] === '\r') i += 1
if (!src[i]) break
const keyStart = endOfIndent(src, i)
if (atLineEnd(src, keyStart)) {
lines.push('')
i = keyStart
continue
}
if (atComment(src, keyStart)) {
const commentEnd = endOfComment(src, keyStart)
lines.push(src.slice(keyStart, commentEnd))
i = commentEnd
continue
}
const keyEnd = endOfKey(src, keyStart)
const key = unescape(src.slice(keyStart, keyEnd))
const valueStart = endOfSeparator(src, keyEnd)
if (atLineEnd(src, valueStart)) {
lines.push([key, ''])
i = valueStart
continue
}
const valueEnd = endOfValue(src, valueStart)
const value = unescape(src.slice(valueStart, valueEnd))
lines.push([key, value])
i = valueEnd
}
return lines
} | [
"function",
"parseLines",
"(",
"src",
")",
"{",
"const",
"lines",
"=",
"[",
"]",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"src",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"src",
"[",
"i",
"]",
"===",
"'\\n'",
"&&",
"\\n",
")",
"src",
"[",
"i",
"-",
"1",
"]",
"===",
"'\\r'",
"\\r",
"i",
"+=",
"1",
"if",
"(",
"!",
"src",
"[",
"i",
"]",
")",
"break",
"const",
"keyStart",
"=",
"endOfIndent",
"(",
"src",
",",
"i",
")",
"if",
"(",
"atLineEnd",
"(",
"src",
",",
"keyStart",
")",
")",
"{",
"lines",
".",
"push",
"(",
"''",
")",
"i",
"=",
"keyStart",
"continue",
"}",
"if",
"(",
"atComment",
"(",
"src",
",",
"keyStart",
")",
")",
"{",
"const",
"commentEnd",
"=",
"endOfComment",
"(",
"src",
",",
"keyStart",
")",
"lines",
".",
"push",
"(",
"src",
".",
"slice",
"(",
"keyStart",
",",
"commentEnd",
")",
")",
"i",
"=",
"commentEnd",
"continue",
"}",
"const",
"keyEnd",
"=",
"endOfKey",
"(",
"src",
",",
"keyStart",
")",
"const",
"key",
"=",
"unescape",
"(",
"src",
".",
"slice",
"(",
"keyStart",
",",
"keyEnd",
")",
")",
"const",
"valueStart",
"=",
"endOfSeparator",
"(",
"src",
",",
"keyEnd",
")",
"if",
"(",
"atLineEnd",
"(",
"src",
",",
"valueStart",
")",
")",
"{",
"lines",
".",
"push",
"(",
"[",
"key",
",",
"''",
"]",
")",
"i",
"=",
"valueStart",
"continue",
"}",
"const",
"valueEnd",
"=",
"endOfValue",
"(",
"src",
",",
"valueStart",
")",
"const",
"value",
"=",
"unescape",
"(",
"src",
".",
"slice",
"(",
"valueStart",
",",
"valueEnd",
")",
")",
"}",
"lines",
".",
"push",
"(",
"[",
"key",
",",
"value",
"]",
")",
"}"
] | Splits the input string into an array of logical lines
Key-value pairs are [key, value] arrays with string values. Escape sequences
in keys and values are parsed. Empty lines are included as empty strings, and
comments as strings that start with '#' or '! characters. Leading whitespace
is not included.
@see https://docs.oracle.com/javase/9/docs/api/java/util/Properties.html#load(java.io.Reader)
@param {string} src
@returns Array<string | string[]]> | [
"Splits",
"the",
"input",
"string",
"into",
"an",
"array",
"of",
"logical",
"lines"
] | d71e10eb5a975a59172c2c2716935eba6f6e16c5 | https://github.com/eemeli/dot-properties/blob/d71e10eb5a975a59172c2c2716935eba6f6e16c5/parse.js#L108-L139 | train |
eemeli/dot-properties | parse.js | parse | function parse (src, path) {
const pathSep = typeof path === 'string' ? path : '.'
return parseLines(src).reduce((res, line) => {
if (Array.isArray(line)) {
const [key, value] = line
if (path) {
const keyPath = key.split(pathSep)
let parent = res
while (keyPath.length >= 2) {
const p = keyPath.shift()
if (!parent[p]) {
parent[p] = {}
} else if (typeof parent[p] !== 'object') {
parent[p] = { '': parent[p] }
}
parent = parent[p]
}
const leaf = keyPath[0]
if (typeof parent[leaf] === 'object') {
parent[leaf][''] = value
} else {
parent[leaf] = value
}
} else {
res[key] = value
}
}
return res
}, {})
} | javascript | function parse (src, path) {
const pathSep = typeof path === 'string' ? path : '.'
return parseLines(src).reduce((res, line) => {
if (Array.isArray(line)) {
const [key, value] = line
if (path) {
const keyPath = key.split(pathSep)
let parent = res
while (keyPath.length >= 2) {
const p = keyPath.shift()
if (!parent[p]) {
parent[p] = {}
} else if (typeof parent[p] !== 'object') {
parent[p] = { '': parent[p] }
}
parent = parent[p]
}
const leaf = keyPath[0]
if (typeof parent[leaf] === 'object') {
parent[leaf][''] = value
} else {
parent[leaf] = value
}
} else {
res[key] = value
}
}
return res
}, {})
} | [
"function",
"parse",
"(",
"src",
",",
"path",
")",
"{",
"const",
"pathSep",
"=",
"typeof",
"path",
"===",
"'string'",
"?",
"path",
":",
"'.'",
"return",
"parseLines",
"(",
"src",
")",
".",
"reduce",
"(",
"(",
"res",
",",
"line",
")",
"=>",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"line",
")",
")",
"{",
"const",
"[",
"key",
",",
"value",
"]",
"=",
"line",
"if",
"(",
"path",
")",
"{",
"const",
"keyPath",
"=",
"key",
".",
"split",
"(",
"pathSep",
")",
"let",
"parent",
"=",
"res",
"while",
"(",
"keyPath",
".",
"length",
">=",
"2",
")",
"{",
"const",
"p",
"=",
"keyPath",
".",
"shift",
"(",
")",
"if",
"(",
"!",
"parent",
"[",
"p",
"]",
")",
"{",
"parent",
"[",
"p",
"]",
"=",
"{",
"}",
"}",
"else",
"if",
"(",
"typeof",
"parent",
"[",
"p",
"]",
"!==",
"'object'",
")",
"{",
"parent",
"[",
"p",
"]",
"=",
"{",
"''",
":",
"parent",
"[",
"p",
"]",
"}",
"}",
"parent",
"=",
"parent",
"[",
"p",
"]",
"}",
"const",
"leaf",
"=",
"keyPath",
"[",
"0",
"]",
"if",
"(",
"typeof",
"parent",
"[",
"leaf",
"]",
"===",
"'object'",
")",
"{",
"parent",
"[",
"leaf",
"]",
"[",
"''",
"]",
"=",
"value",
"}",
"else",
"{",
"parent",
"[",
"leaf",
"]",
"=",
"value",
"}",
"}",
"else",
"{",
"res",
"[",
"key",
"]",
"=",
"value",
"}",
"}",
"return",
"res",
"}",
",",
"{",
"}",
")",
"}"
] | Parses an input string read from a .properties file into a JavaScript Object
If the second `path` parameter is true, dots '.' in keys will result in a
multi-level object (use a string value to customise). If a parent level is
directly assigned a value while it also has a child with an assigned value,
the parent value will be assigned to its empty string '' key. Repeated keys
will take the last assigned value. Key order is not guaranteed, but is likely
to match the order of the input lines.
@param {string} src
@param {boolean | string} [path=false] | [
"Parses",
"an",
"input",
"string",
"read",
"from",
"a",
".",
"properties",
"file",
"into",
"a",
"JavaScript",
"Object"
] | d71e10eb5a975a59172c2c2716935eba6f6e16c5 | https://github.com/eemeli/dot-properties/blob/d71e10eb5a975a59172c2c2716935eba6f6e16c5/parse.js#L154-L183 | train |
eemeli/dot-properties | stringify.js | stringify | function stringify (input, {
commentPrefix = '# ',
defaultKey = '',
indent = ' ',
keySep = ' = ',
latin1 = true,
lineWidth = 80,
newline = '\n',
pathSep = '.'
} = {}) {
if (!input) return ''
if (!Array.isArray(input)) input = toLines(input, pathSep, defaultKey)
const foldLine = getFold({ indent, latin1, lineWidth, newline: '\\' + newline })
const foldComment = getFold({ indent: commentPrefix, latin1, lineWidth, newline })
return input
.map(line => {
switch (true) {
case !line:
return ''
case Array.isArray(line):
const key = escapeKey(line[0])
const value = escapeValue(line[1])
return foldLine(key + keySep + value)
default:
const cc = String(line).replace(/^\s*([#!][ \t\f]*)?/g, commentPrefix)
return foldComment(cc)
}
})
.join(newline)
} | javascript | function stringify (input, {
commentPrefix = '# ',
defaultKey = '',
indent = ' ',
keySep = ' = ',
latin1 = true,
lineWidth = 80,
newline = '\n',
pathSep = '.'
} = {}) {
if (!input) return ''
if (!Array.isArray(input)) input = toLines(input, pathSep, defaultKey)
const foldLine = getFold({ indent, latin1, lineWidth, newline: '\\' + newline })
const foldComment = getFold({ indent: commentPrefix, latin1, lineWidth, newline })
return input
.map(line => {
switch (true) {
case !line:
return ''
case Array.isArray(line):
const key = escapeKey(line[0])
const value = escapeValue(line[1])
return foldLine(key + keySep + value)
default:
const cc = String(line).replace(/^\s*([#!][ \t\f]*)?/g, commentPrefix)
return foldComment(cc)
}
})
.join(newline)
} | [
"function",
"stringify",
"(",
"input",
",",
"{",
"commentPrefix",
"=",
"'# '",
",",
"defaultKey",
"=",
"''",
",",
"indent",
"=",
"' '",
",",
"keySep",
"=",
"' = '",
",",
"latin1",
"=",
"true",
",",
"lineWidth",
"=",
"80",
",",
"newline",
"=",
"'\\n'",
",",
"\\n",
"}",
"=",
"pathSep",
"=",
"'.'",
")",
"{",
"}"
] | Stringifies a hierarchical object or an array of lines to .properties format
If the input is a hierarchical object, keys will consist of the path parts
joined by '.' characters. With array input, string values represent blank or
comment lines and string arrays are [key, value] pairs. The characters \, \n
and \r will be appropriately escaped. If the `latin1` option is not set to
false, all non-Latin-1 characters will also be `\u` escaped.
Output styling is controlled by the second options parameter; by default a
spaced '=' separates the key from the value, '\n' is the newline separator,
lines are folded at 80 characters, with subsequent lines indented by four
spaces, and comment lines are prefixed with a '#'. '' as a key value is
considered the default, and set as the value of a key corresponding to its
parent object's path.
@param {Object | Array<string | string[]>} input
@param {Object} [options={}]
@param {string} [options.commentPrefix='# ']
@param {string} [options.defaultKey='']
@param {string} [options.indent=' ']
@param {string} [options.keySep=' = ']
@param {boolean} [options.latin1=true]
@param {number} [options.lineWidth=80]
@param {string} [options.newline='\n']
@param {string} [options.pathSep='.'] | [
"Stringifies",
"a",
"hierarchical",
"object",
"or",
"an",
"array",
"of",
"lines",
"to",
".",
"properties",
"format"
] | d71e10eb5a975a59172c2c2716935eba6f6e16c5 | https://github.com/eemeli/dot-properties/blob/d71e10eb5a975a59172c2c2716935eba6f6e16c5/stringify.js#L117-L146 | train |
axemclion/react-native-cordova-plugin | cli/android-cli.js | mapVariablesToObject | function mapVariablesToObject(variables) {
var plugmanConsumableVariables = {};
for (var i in variables) {
var t = variables[i].split('=');
if (t[0] && t[1]) {
plugmanConsumableVariables[t[0]] = t[1];
}
}
return plugmanConsumableVariables;
} | javascript | function mapVariablesToObject(variables) {
var plugmanConsumableVariables = {};
for (var i in variables) {
var t = variables[i].split('=');
if (t[0] && t[1]) {
plugmanConsumableVariables[t[0]] = t[1];
}
}
return plugmanConsumableVariables;
} | [
"function",
"mapVariablesToObject",
"(",
"variables",
")",
"{",
"var",
"plugmanConsumableVariables",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"in",
"variables",
")",
"{",
"var",
"t",
"=",
"variables",
"[",
"i",
"]",
".",
"split",
"(",
"'='",
")",
";",
"if",
"(",
"t",
"[",
"0",
"]",
"&&",
"t",
"[",
"1",
"]",
")",
"{",
"plugmanConsumableVariables",
"[",
"t",
"[",
"0",
"]",
"]",
"=",
"t",
"[",
"1",
"]",
";",
"}",
"}",
"return",
"plugmanConsumableVariables",
";",
"}"
] | takes an array or variables and turns them into an object to be consumed by plugman | [
"takes",
"an",
"array",
"or",
"variables",
"and",
"turns",
"them",
"into",
"an",
"object",
"to",
"be",
"consumed",
"by",
"plugman"
] | a794a93a2702759863795dd4636bddc703dad678 | https://github.com/axemclion/react-native-cordova-plugin/blob/a794a93a2702759863795dd4636bddc703dad678/cli/android-cli.js#L54-L63 | train |
lucaslg26/TidalAPI | lib/client.js | TidalAPI | function TidalAPI(authData) {
if(typeof authData !== 'object')
{
throw new Error('You must pass auth data into the TidalAPI object correctly');
} else {
if(typeof authData.username !== 'string') {
throw new Error('Username invalid or missing');
}
if(typeof authData.password !== 'string') {
throw new Error('Password invalid or missing');
}
if(typeof authData.token !== 'string') {
throw new Error('Token invalid or missing');
}
if(typeof authData.quality !== 'string') {
throw new Error('Stream quality invalid or missing');
}
}
this.authData = authData;
/* try log in */
// tryLogin(authData);
} | javascript | function TidalAPI(authData) {
if(typeof authData !== 'object')
{
throw new Error('You must pass auth data into the TidalAPI object correctly');
} else {
if(typeof authData.username !== 'string') {
throw new Error('Username invalid or missing');
}
if(typeof authData.password !== 'string') {
throw new Error('Password invalid or missing');
}
if(typeof authData.token !== 'string') {
throw new Error('Token invalid or missing');
}
if(typeof authData.quality !== 'string') {
throw new Error('Stream quality invalid or missing');
}
}
this.authData = authData;
/* try log in */
// tryLogin(authData);
} | [
"function",
"TidalAPI",
"(",
"authData",
")",
"{",
"if",
"(",
"typeof",
"authData",
"!==",
"'object'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'You must pass auth data into the TidalAPI object correctly'",
")",
";",
"}",
"else",
"{",
"if",
"(",
"typeof",
"authData",
".",
"username",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Username invalid or missing'",
")",
";",
"}",
"if",
"(",
"typeof",
"authData",
".",
"password",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Password invalid or missing'",
")",
";",
"}",
"if",
"(",
"typeof",
"authData",
".",
"token",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Token invalid or missing'",
")",
";",
"}",
"if",
"(",
"typeof",
"authData",
".",
"quality",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Stream quality invalid or missing'",
")",
";",
"}",
"}",
"this",
".",
"authData",
"=",
"authData",
";",
"}"
] | Create TidalAPI instance
@param {{username: String, password: String, token: String, quality: String}}
@Constructor | [
"Create",
"TidalAPI",
"instance"
] | 0df9e2c7e62323e626adddd1f5332d7b47e37206 | https://github.com/lucaslg26/TidalAPI/blob/0df9e2c7e62323e626adddd1f5332d7b47e37206/lib/client.js#L71-L94 | train |
lucaslg26/TidalAPI | lib/client.js | tryLogin | function tryLogin(authInfo, cb) {
/**
* Logging?
* @type {boolean}
*/
var loggingIn = true;
request({
method: 'POST',
uri: '/login/username',
headers: {
'X-Tidal-Token': authInfo.token
},
form: {
username: authInfo.username,
password: authInfo.password,
clientUniqueKey: "vjknfvjbnjhbgjhbbg"
}
}, function(err, res, data) {
if(!err){
if (data && res && res.statusCode !== 200 || err) {
throw new Error(data)
}
data = JSON.parse(data);
_sessionID = data.sessionId;
_userID = data.userId;
_countryCode = data.countryCode;
_streamQuality = authInfo.quality;
loggingIn = false;
loggedIn = true;
if (cb) {
cb();
}
}
});
} | javascript | function tryLogin(authInfo, cb) {
/**
* Logging?
* @type {boolean}
*/
var loggingIn = true;
request({
method: 'POST',
uri: '/login/username',
headers: {
'X-Tidal-Token': authInfo.token
},
form: {
username: authInfo.username,
password: authInfo.password,
clientUniqueKey: "vjknfvjbnjhbgjhbbg"
}
}, function(err, res, data) {
if(!err){
if (data && res && res.statusCode !== 200 || err) {
throw new Error(data)
}
data = JSON.parse(data);
_sessionID = data.sessionId;
_userID = data.userId;
_countryCode = data.countryCode;
_streamQuality = authInfo.quality;
loggingIn = false;
loggedIn = true;
if (cb) {
cb();
}
}
});
} | [
"function",
"tryLogin",
"(",
"authInfo",
",",
"cb",
")",
"{",
"var",
"loggingIn",
"=",
"true",
";",
"request",
"(",
"{",
"method",
":",
"'POST'",
",",
"uri",
":",
"'/login/username'",
",",
"headers",
":",
"{",
"'X-Tidal-Token'",
":",
"authInfo",
".",
"token",
"}",
",",
"form",
":",
"{",
"username",
":",
"authInfo",
".",
"username",
",",
"password",
":",
"authInfo",
".",
"password",
",",
"clientUniqueKey",
":",
"\"vjknfvjbnjhbgjhbbg\"",
"}",
"}",
",",
"function",
"(",
"err",
",",
"res",
",",
"data",
")",
"{",
"if",
"(",
"!",
"err",
")",
"{",
"if",
"(",
"data",
"&&",
"res",
"&&",
"res",
".",
"statusCode",
"!==",
"200",
"||",
"err",
")",
"{",
"throw",
"new",
"Error",
"(",
"data",
")",
"}",
"data",
"=",
"JSON",
".",
"parse",
"(",
"data",
")",
";",
"_sessionID",
"=",
"data",
".",
"sessionId",
";",
"_userID",
"=",
"data",
".",
"userId",
";",
"_countryCode",
"=",
"data",
".",
"countryCode",
";",
"_streamQuality",
"=",
"authInfo",
".",
"quality",
";",
"loggingIn",
"=",
"false",
";",
"loggedIn",
"=",
"true",
";",
"if",
"(",
"cb",
")",
"{",
"cb",
"(",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] | Try login using credentials.
@param {{username: String, password: String}} | [
"Try",
"login",
"using",
"credentials",
"."
] | 0df9e2c7e62323e626adddd1f5332d7b47e37206 | https://github.com/lucaslg26/TidalAPI/blob/0df9e2c7e62323e626adddd1f5332d7b47e37206/lib/client.js#L100-L134 | train |
stbaer/rangeslider-js | src/utils.js | resize | function resize () {
if (!running) {
running = true
if (window.requestAnimationFrame) {
window.requestAnimationFrame(runCallbacks)
} else {
setTimeout(runCallbacks, 66)
}
}
} | javascript | function resize () {
if (!running) {
running = true
if (window.requestAnimationFrame) {
window.requestAnimationFrame(runCallbacks)
} else {
setTimeout(runCallbacks, 66)
}
}
} | [
"function",
"resize",
"(",
")",
"{",
"if",
"(",
"!",
"running",
")",
"{",
"running",
"=",
"true",
"if",
"(",
"window",
".",
"requestAnimationFrame",
")",
"{",
"window",
".",
"requestAnimationFrame",
"(",
"runCallbacks",
")",
"}",
"else",
"{",
"setTimeout",
"(",
"runCallbacks",
",",
"66",
")",
"}",
"}",
"}"
] | fired on resize event | [
"fired",
"on",
"resize",
"event"
] | 5000e1a8ff92ee849e8e7f84cf009f7c0c84b1bc | https://github.com/stbaer/rangeslider-js/blob/5000e1a8ff92ee849e8e7f84cf009f7c0c84b1bc/src/utils.js#L159-L169 | train |
tjmehta/graphql-date | index.js | function (value) {
assertErr(value instanceof Date, TypeError, 'Field error: value is not an instance of Date')
assertErr(!isNaN(value.getTime()), TypeError, 'Field error: value is an invalid Date')
return value.toJSON()
} | javascript | function (value) {
assertErr(value instanceof Date, TypeError, 'Field error: value is not an instance of Date')
assertErr(!isNaN(value.getTime()), TypeError, 'Field error: value is an invalid Date')
return value.toJSON()
} | [
"function",
"(",
"value",
")",
"{",
"assertErr",
"(",
"value",
"instanceof",
"Date",
",",
"TypeError",
",",
"'Field error: value is not an instance of Date'",
")",
"assertErr",
"(",
"!",
"isNaN",
"(",
"value",
".",
"getTime",
"(",
")",
")",
",",
"TypeError",
",",
"'Field error: value is an invalid Date'",
")",
"return",
"value",
".",
"toJSON",
"(",
")",
"}"
] | Serialize date value into string
@param {Date} value date value
@return {String} date as string | [
"Serialize",
"date",
"value",
"into",
"string"
] | ecd3fa27247a744914bd184a159c3818b91dd181 | https://github.com/tjmehta/graphql-date/blob/ecd3fa27247a744914bd184a159c3818b91dd181/index.js#L13-L17 | train |
|
tjmehta/graphql-date | index.js | function (value) {
var date = new Date(value)
assertErr(!isNaN(date.getTime()), TypeError, 'Field error: value is an invalid Date')
return date
} | javascript | function (value) {
var date = new Date(value)
assertErr(!isNaN(date.getTime()), TypeError, 'Field error: value is an invalid Date')
return date
} | [
"function",
"(",
"value",
")",
"{",
"var",
"date",
"=",
"new",
"Date",
"(",
"value",
")",
"assertErr",
"(",
"!",
"isNaN",
"(",
"date",
".",
"getTime",
"(",
")",
")",
",",
"TypeError",
",",
"'Field error: value is an invalid Date'",
")",
"return",
"date",
"}"
] | Parse value into date
@param {*} value serialized date value
@return {Date} date value | [
"Parse",
"value",
"into",
"date"
] | ecd3fa27247a744914bd184a159c3818b91dd181 | https://github.com/tjmehta/graphql-date/blob/ecd3fa27247a744914bd184a159c3818b91dd181/index.js#L23-L27 | train |
|
tjmehta/graphql-date | index.js | function (ast) {
assertErr(ast.kind === Kind.STRING,
GraphQLError, 'Query error: Can only parse strings to dates but got a: ' + ast.kind, [ast])
var result = new Date(ast.value)
assertErr(!isNaN(result.getTime()),
GraphQLError, 'Query error: Invalid date', [ast])
assertErr(ast.value === result.toJSON(),
GraphQLError, 'Query error: Invalid date format, only accepts: YYYY-MM-DDTHH:MM:SS.SSSZ', [ast])
return result
} | javascript | function (ast) {
assertErr(ast.kind === Kind.STRING,
GraphQLError, 'Query error: Can only parse strings to dates but got a: ' + ast.kind, [ast])
var result = new Date(ast.value)
assertErr(!isNaN(result.getTime()),
GraphQLError, 'Query error: Invalid date', [ast])
assertErr(ast.value === result.toJSON(),
GraphQLError, 'Query error: Invalid date format, only accepts: YYYY-MM-DDTHH:MM:SS.SSSZ', [ast])
return result
} | [
"function",
"(",
"ast",
")",
"{",
"assertErr",
"(",
"ast",
".",
"kind",
"===",
"Kind",
".",
"STRING",
",",
"GraphQLError",
",",
"'Query error: Can only parse strings to dates but got a: '",
"+",
"ast",
".",
"kind",
",",
"[",
"ast",
"]",
")",
"var",
"result",
"=",
"new",
"Date",
"(",
"ast",
".",
"value",
")",
"assertErr",
"(",
"!",
"isNaN",
"(",
"result",
".",
"getTime",
"(",
")",
")",
",",
"GraphQLError",
",",
"'Query error: Invalid date'",
",",
"[",
"ast",
"]",
")",
"assertErr",
"(",
"ast",
".",
"value",
"===",
"result",
".",
"toJSON",
"(",
")",
",",
"GraphQLError",
",",
"'Query error: Invalid date format, only accepts: YYYY-MM-DDTHH:MM:SS.SSSZ'",
",",
"[",
"ast",
"]",
")",
"return",
"result",
"}"
] | Parse ast literal to date
@param {Object} ast graphql ast
@return {Date} date value | [
"Parse",
"ast",
"literal",
"to",
"date"
] | ecd3fa27247a744914bd184a159c3818b91dd181 | https://github.com/tjmehta/graphql-date/blob/ecd3fa27247a744914bd184a159c3818b91dd181/index.js#L33-L44 | train |
|
audiojs/web-audio-stream | write.js | push | function push (chunk) {
if (!isAudioBuffer(chunk)) {
chunk = util.create(chunk, channels)
}
data.append(chunk)
isEmpty = false;
} | javascript | function push (chunk) {
if (!isAudioBuffer(chunk)) {
chunk = util.create(chunk, channels)
}
data.append(chunk)
isEmpty = false;
} | [
"function",
"push",
"(",
"chunk",
")",
"{",
"if",
"(",
"!",
"isAudioBuffer",
"(",
"chunk",
")",
")",
"{",
"chunk",
"=",
"util",
".",
"create",
"(",
"chunk",
",",
"channels",
")",
"}",
"data",
".",
"append",
"(",
"chunk",
")",
"isEmpty",
"=",
"false",
";",
"}"
] | push new data for the next WAA dinner | [
"push",
"new",
"data",
"for",
"the",
"next",
"WAA",
"dinner"
] | 0efbe9838c903dbc698024c256b85da4c9f91de7 | https://github.com/audiojs/web-audio-stream/blob/0efbe9838c903dbc698024c256b85da4c9f91de7/write.js#L105-L113 | train |
anvaka/ngraph.three | lib/defaults.js | createNodeUI | function createNodeUI(node) {
var nodeMaterial = new THREE.MeshBasicMaterial({ color: 0xfefefe });
var nodeGeometry = new THREE.BoxGeometry(NODE_SIZE, NODE_SIZE, NODE_SIZE);
return new THREE.Mesh(nodeGeometry, nodeMaterial);
} | javascript | function createNodeUI(node) {
var nodeMaterial = new THREE.MeshBasicMaterial({ color: 0xfefefe });
var nodeGeometry = new THREE.BoxGeometry(NODE_SIZE, NODE_SIZE, NODE_SIZE);
return new THREE.Mesh(nodeGeometry, nodeMaterial);
} | [
"function",
"createNodeUI",
"(",
"node",
")",
"{",
"var",
"nodeMaterial",
"=",
"new",
"THREE",
".",
"MeshBasicMaterial",
"(",
"{",
"color",
":",
"0xfefefe",
"}",
")",
";",
"var",
"nodeGeometry",
"=",
"new",
"THREE",
".",
"BoxGeometry",
"(",
"NODE_SIZE",
",",
"NODE_SIZE",
",",
"NODE_SIZE",
")",
";",
"return",
"new",
"THREE",
".",
"Mesh",
"(",
"nodeGeometry",
",",
"nodeMaterial",
")",
";",
"}"
] | default size of a node square | [
"default",
"size",
"of",
"a",
"node",
"square"
] | 7a1cc19574f27207a04f3ba269538b904c406161 | https://github.com/anvaka/ngraph.three/blob/7a1cc19574f27207a04f3ba269538b904c406161/lib/defaults.js#L30-L34 | train |
Yehzuna/jquery-schedule | dist/jquery.schedule.js | function () {
$('<table class="jqs-table"><tr></tr></table>').appendTo($(this.element));
for (var i = 0; i < this.settings.days; i++) {
$('<td><div class="jqs-day"></div></td>').
appendTo($('.jqs-table tr', this.element));
}
$('<div class="jqs-grid"><div class="jqs-grid-head"></div></div>').appendTo($(this.element));
for (var j = 0; j < 25; j++) {
$('<div class="jqs-grid-line"><div class="jqs-grid-hour">' + this.formatHour(j) + '</div></div>').
appendTo($('.jqs-grid', this.element));
}
var dayRemove = '';
var dayDuplicate = '';
if (this.settings.mode === 'edit') {
dayRemove = '<div class="jqs-day-remove" title="' + this.settings.periodRemoveButton + '"></div>';
dayDuplicate = '<div class="jqs-day-duplicate" title="' + this.settings.periodDuplicateButton +
'"></div>';
}
for (var k = 0; k < this.settings.days; k++) {
$('<div class="jqs-grid-day">' + this.settings.daysList[k] + dayRemove + dayDuplicate + '</div>').
appendTo($('.jqs-grid-head', this.element));
}
} | javascript | function () {
$('<table class="jqs-table"><tr></tr></table>').appendTo($(this.element));
for (var i = 0; i < this.settings.days; i++) {
$('<td><div class="jqs-day"></div></td>').
appendTo($('.jqs-table tr', this.element));
}
$('<div class="jqs-grid"><div class="jqs-grid-head"></div></div>').appendTo($(this.element));
for (var j = 0; j < 25; j++) {
$('<div class="jqs-grid-line"><div class="jqs-grid-hour">' + this.formatHour(j) + '</div></div>').
appendTo($('.jqs-grid', this.element));
}
var dayRemove = '';
var dayDuplicate = '';
if (this.settings.mode === 'edit') {
dayRemove = '<div class="jqs-day-remove" title="' + this.settings.periodRemoveButton + '"></div>';
dayDuplicate = '<div class="jqs-day-duplicate" title="' + this.settings.periodDuplicateButton +
'"></div>';
}
for (var k = 0; k < this.settings.days; k++) {
$('<div class="jqs-grid-day">' + this.settings.daysList[k] + dayRemove + dayDuplicate + '</div>').
appendTo($('.jqs-grid-head', this.element));
}
} | [
"function",
"(",
")",
"{",
"$",
"(",
"'<table class=\"jqs-table\"><tr></tr></table>'",
")",
".",
"appendTo",
"(",
"$",
"(",
"this",
".",
"element",
")",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"settings",
".",
"days",
";",
"i",
"++",
")",
"{",
"$",
"(",
"'<td><div class=\"jqs-day\"></div></td>'",
")",
".",
"appendTo",
"(",
"$",
"(",
"'.jqs-table tr'",
",",
"this",
".",
"element",
")",
")",
";",
"}",
"$",
"(",
"'<div class=\"jqs-grid\"><div class=\"jqs-grid-head\"></div></div>'",
")",
".",
"appendTo",
"(",
"$",
"(",
"this",
".",
"element",
")",
")",
";",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"25",
";",
"j",
"++",
")",
"{",
"$",
"(",
"'<div class=\"jqs-grid-line\"><div class=\"jqs-grid-hour\">'",
"+",
"this",
".",
"formatHour",
"(",
"j",
")",
"+",
"'</div></div>'",
")",
".",
"appendTo",
"(",
"$",
"(",
"'.jqs-grid'",
",",
"this",
".",
"element",
")",
")",
";",
"}",
"var",
"dayRemove",
"=",
"''",
";",
"var",
"dayDuplicate",
"=",
"''",
";",
"if",
"(",
"this",
".",
"settings",
".",
"mode",
"===",
"'edit'",
")",
"{",
"dayRemove",
"=",
"'<div class=\"jqs-day-remove\" title=\"'",
"+",
"this",
".",
"settings",
".",
"periodRemoveButton",
"+",
"'\"></div>'",
";",
"dayDuplicate",
"=",
"'<div class=\"jqs-day-duplicate\" title=\"'",
"+",
"this",
".",
"settings",
".",
"periodDuplicateButton",
"+",
"'\"></div>'",
";",
"}",
"for",
"(",
"var",
"k",
"=",
"0",
";",
"k",
"<",
"this",
".",
"settings",
".",
"days",
";",
"k",
"++",
")",
"{",
"$",
"(",
"'<div class=\"jqs-grid-day\">'",
"+",
"this",
".",
"settings",
".",
"daysList",
"[",
"k",
"]",
"+",
"dayRemove",
"+",
"dayDuplicate",
"+",
"'</div>'",
")",
".",
"appendTo",
"(",
"$",
"(",
"'.jqs-grid-head'",
",",
"this",
".",
"element",
")",
")",
";",
"}",
"}"
] | Generate schedule structure | [
"Generate",
"schedule",
"structure"
] | a9df541cb16572a83a5b1f5fdbe611ea88a77835 | https://github.com/Yehzuna/jquery-schedule/blob/a9df541cb16572a83a5b1f5fdbe611ea88a77835/dist/jquery.schedule.js#L222-L250 | train |
|
Yehzuna/jquery-schedule | dist/jquery.schedule.js | function (period) {
if (!this.settings.onDuplicatePeriod.call(this, period, this.element)) {
var options = this.periodData(period);
var position = Math.round(period.position().top / this.periodPosition);
var height = Math.round(period.height() / this.periodPosition);
var $this = this;
$('.jqs-day', this.element).each(function (index, parent) {
$this.add(parent, position, height, options);
});
this.closeOptions();
}
} | javascript | function (period) {
if (!this.settings.onDuplicatePeriod.call(this, period, this.element)) {
var options = this.periodData(period);
var position = Math.round(period.position().top / this.periodPosition);
var height = Math.round(period.height() / this.periodPosition);
var $this = this;
$('.jqs-day', this.element).each(function (index, parent) {
$this.add(parent, position, height, options);
});
this.closeOptions();
}
} | [
"function",
"(",
"period",
")",
"{",
"if",
"(",
"!",
"this",
".",
"settings",
".",
"onDuplicatePeriod",
".",
"call",
"(",
"this",
",",
"period",
",",
"this",
".",
"element",
")",
")",
"{",
"var",
"options",
"=",
"this",
".",
"periodData",
"(",
"period",
")",
";",
"var",
"position",
"=",
"Math",
".",
"round",
"(",
"period",
".",
"position",
"(",
")",
".",
"top",
"/",
"this",
".",
"periodPosition",
")",
";",
"var",
"height",
"=",
"Math",
".",
"round",
"(",
"period",
".",
"height",
"(",
")",
"/",
"this",
".",
"periodPosition",
")",
";",
"var",
"$this",
"=",
"this",
";",
"$",
"(",
"'.jqs-day'",
",",
"this",
".",
"element",
")",
".",
"each",
"(",
"function",
"(",
"index",
",",
"parent",
")",
"{",
"$this",
".",
"add",
"(",
"parent",
",",
"position",
",",
"height",
",",
"options",
")",
";",
"}",
")",
";",
"this",
".",
"closeOptions",
"(",
")",
";",
"}",
"}"
] | Duplicate a period
@param period | [
"Duplicate",
"a",
"period"
] | a9df541cb16572a83a5b1f5fdbe611ea88a77835 | https://github.com/Yehzuna/jquery-schedule/blob/a9df541cb16572a83a5b1f5fdbe611ea88a77835/dist/jquery.schedule.js#L421-L434 | train |
|
Yehzuna/jquery-schedule | dist/jquery.schedule.js | function (ui) {
var start = Math.round(ui.position.top / this.periodPosition);
var end = Math.round(($(ui.helper).height() + ui.position.top) / this.periodPosition);
return this.periodFormat(start) + ' - ' + this.periodFormat(end);
} | javascript | function (ui) {
var start = Math.round(ui.position.top / this.periodPosition);
var end = Math.round(($(ui.helper).height() + ui.position.top) / this.periodPosition);
return this.periodFormat(start) + ' - ' + this.periodFormat(end);
} | [
"function",
"(",
"ui",
")",
"{",
"var",
"start",
"=",
"Math",
".",
"round",
"(",
"ui",
".",
"position",
".",
"top",
"/",
"this",
".",
"periodPosition",
")",
";",
"var",
"end",
"=",
"Math",
".",
"round",
"(",
"(",
"$",
"(",
"ui",
".",
"helper",
")",
".",
"height",
"(",
")",
"+",
"ui",
".",
"position",
".",
"top",
")",
"/",
"this",
".",
"periodPosition",
")",
";",
"return",
"this",
".",
"periodFormat",
"(",
"start",
")",
"+",
"' - '",
"+",
"this",
".",
"periodFormat",
"(",
"end",
")",
";",
"}"
] | Return a readable period string from a drag event
@param ui
@returns {string} | [
"Return",
"a",
"readable",
"period",
"string",
"from",
"a",
"drag",
"event"
] | a9df541cb16572a83a5b1f5fdbe611ea88a77835 | https://github.com/Yehzuna/jquery-schedule/blob/a9df541cb16572a83a5b1f5fdbe611ea88a77835/dist/jquery.schedule.js#L554-L559 | train |
|
Yehzuna/jquery-schedule | dist/jquery.schedule.js | function (period) {
var start = Math.round(period.position().top / this.periodPosition);
var end = Math.round((period.height() + period.position().top) / this.periodPosition);
return {
start: this.periodFormat(start),
end: this.periodFormat(end),
title: $('.jqs-period-title', period).text(),
backgroundColor: $('.jqs-period-container', period).css('background-color'),
borderColor: $('.jqs-period-container', period).css('border-top-color'),
textColor: $('.jqs-period-container', period).css('color')
};
} | javascript | function (period) {
var start = Math.round(period.position().top / this.periodPosition);
var end = Math.round((period.height() + period.position().top) / this.periodPosition);
return {
start: this.periodFormat(start),
end: this.periodFormat(end),
title: $('.jqs-period-title', period).text(),
backgroundColor: $('.jqs-period-container', period).css('background-color'),
borderColor: $('.jqs-period-container', period).css('border-top-color'),
textColor: $('.jqs-period-container', period).css('color')
};
} | [
"function",
"(",
"period",
")",
"{",
"var",
"start",
"=",
"Math",
".",
"round",
"(",
"period",
".",
"position",
"(",
")",
".",
"top",
"/",
"this",
".",
"periodPosition",
")",
";",
"var",
"end",
"=",
"Math",
".",
"round",
"(",
"(",
"period",
".",
"height",
"(",
")",
"+",
"period",
".",
"position",
"(",
")",
".",
"top",
")",
"/",
"this",
".",
"periodPosition",
")",
";",
"return",
"{",
"start",
":",
"this",
".",
"periodFormat",
"(",
"start",
")",
",",
"end",
":",
"this",
".",
"periodFormat",
"(",
"end",
")",
",",
"title",
":",
"$",
"(",
"'.jqs-period-title'",
",",
"period",
")",
".",
"text",
"(",
")",
",",
"backgroundColor",
":",
"$",
"(",
"'.jqs-period-container'",
",",
"period",
")",
".",
"css",
"(",
"'background-color'",
")",
",",
"borderColor",
":",
"$",
"(",
"'.jqs-period-container'",
",",
"period",
")",
".",
"css",
"(",
"'border-top-color'",
")",
",",
"textColor",
":",
"$",
"(",
"'.jqs-period-container'",
",",
"period",
")",
".",
"css",
"(",
"'color'",
")",
"}",
";",
"}"
] | Return an object with all period data
@param period
@returns {[*,*]} | [
"Return",
"an",
"object",
"with",
"all",
"period",
"data"
] | a9df541cb16572a83a5b1f5fdbe611ea88a77835 | https://github.com/Yehzuna/jquery-schedule/blob/a9df541cb16572a83a5b1f5fdbe611ea88a77835/dist/jquery.schedule.js#L600-L612 | train |
|
Yehzuna/jquery-schedule | dist/jquery.schedule.js | function (position) {
if (position >= this.periodHeight) {
position = 0;
}
if (position < 0) {
position = 0;
}
var hour = Math.floor(position / this.periodInterval);
var mn = (position / this.periodInterval - hour) * 60;
if (this.settings.hour === 12) {
var time = hour;
var ind = '';
if (hour >= 12) {
ind = 'p';
}
if (hour > 12) {
time = hour - 12;
}
if (hour === 0 || hour === 24) {
ind = '';
time = 12;
}
if (mn !== 0) {
time += ':' + mn;
}
return time + ind;
}
if (hour < 10) {
hour = '0' + hour;
}
if (mn < 10) {
mn = '0' + mn;
}
return hour + ':' + mn;
} | javascript | function (position) {
if (position >= this.periodHeight) {
position = 0;
}
if (position < 0) {
position = 0;
}
var hour = Math.floor(position / this.periodInterval);
var mn = (position / this.periodInterval - hour) * 60;
if (this.settings.hour === 12) {
var time = hour;
var ind = '';
if (hour >= 12) {
ind = 'p';
}
if (hour > 12) {
time = hour - 12;
}
if (hour === 0 || hour === 24) {
ind = '';
time = 12;
}
if (mn !== 0) {
time += ':' + mn;
}
return time + ind;
}
if (hour < 10) {
hour = '0' + hour;
}
if (mn < 10) {
mn = '0' + mn;
}
return hour + ':' + mn;
} | [
"function",
"(",
"position",
")",
"{",
"if",
"(",
"position",
">=",
"this",
".",
"periodHeight",
")",
"{",
"position",
"=",
"0",
";",
"}",
"if",
"(",
"position",
"<",
"0",
")",
"{",
"position",
"=",
"0",
";",
"}",
"var",
"hour",
"=",
"Math",
".",
"floor",
"(",
"position",
"/",
"this",
".",
"periodInterval",
")",
";",
"var",
"mn",
"=",
"(",
"position",
"/",
"this",
".",
"periodInterval",
"-",
"hour",
")",
"*",
"60",
";",
"if",
"(",
"this",
".",
"settings",
".",
"hour",
"===",
"12",
")",
"{",
"var",
"time",
"=",
"hour",
";",
"var",
"ind",
"=",
"''",
";",
"if",
"(",
"hour",
">=",
"12",
")",
"{",
"ind",
"=",
"'p'",
";",
"}",
"if",
"(",
"hour",
">",
"12",
")",
"{",
"time",
"=",
"hour",
"-",
"12",
";",
"}",
"if",
"(",
"hour",
"===",
"0",
"||",
"hour",
"===",
"24",
")",
"{",
"ind",
"=",
"''",
";",
"time",
"=",
"12",
";",
"}",
"if",
"(",
"mn",
"!==",
"0",
")",
"{",
"time",
"+=",
"':'",
"+",
"mn",
";",
"}",
"return",
"time",
"+",
"ind",
";",
"}",
"if",
"(",
"hour",
"<",
"10",
")",
"{",
"hour",
"=",
"'0'",
"+",
"hour",
";",
"}",
"if",
"(",
"mn",
"<",
"10",
")",
"{",
"mn",
"=",
"'0'",
"+",
"mn",
";",
"}",
"return",
"hour",
"+",
"':'",
"+",
"mn",
";",
"}"
] | Return a readable hour from a position
@param position
@returns {number} | [
"Return",
"a",
"readable",
"hour",
"from",
"a",
"position"
] | a9df541cb16572a83a5b1f5fdbe611ea88a77835 | https://github.com/Yehzuna/jquery-schedule/blob/a9df541cb16572a83a5b1f5fdbe611ea88a77835/dist/jquery.schedule.js#L619-L660 | train |
|
Yehzuna/jquery-schedule | dist/jquery.schedule.js | function (time) {
var split = time.split(':');
var hour = parseInt(split[0]);
var mn = parseInt(split[1]);
if (this.settings.hour === 12) {
var matches = time.match(/([0-1]?[0-9]):?([0-5][0-9])?\s?(am|pm|p)?/);
var ind = matches[3];
if (!ind) {
ind = 'am';
}
hour = parseInt(matches[1]);
mn = parseInt(matches[2]);
if (!mn) {
mn = 0;
}
if (hour === 12 && ind === 'am') {
hour = 0;
}
if (hour === 12 && (ind === 'pm' || ind === 'p')) {
ind = 'am';
}
if (ind === 'pm' || ind === 'p') {
hour += 12;
}
}
var position = 0;
position += hour * this.periodInterval;
position += mn / 60 * this.periodInterval;
if (Math.floor(position) !== position) {
return -1;
}
return position;
} | javascript | function (time) {
var split = time.split(':');
var hour = parseInt(split[0]);
var mn = parseInt(split[1]);
if (this.settings.hour === 12) {
var matches = time.match(/([0-1]?[0-9]):?([0-5][0-9])?\s?(am|pm|p)?/);
var ind = matches[3];
if (!ind) {
ind = 'am';
}
hour = parseInt(matches[1]);
mn = parseInt(matches[2]);
if (!mn) {
mn = 0;
}
if (hour === 12 && ind === 'am') {
hour = 0;
}
if (hour === 12 && (ind === 'pm' || ind === 'p')) {
ind = 'am';
}
if (ind === 'pm' || ind === 'p') {
hour += 12;
}
}
var position = 0;
position += hour * this.periodInterval;
position += mn / 60 * this.periodInterval;
if (Math.floor(position) !== position) {
return -1;
}
return position;
} | [
"function",
"(",
"time",
")",
"{",
"var",
"split",
"=",
"time",
".",
"split",
"(",
"':'",
")",
";",
"var",
"hour",
"=",
"parseInt",
"(",
"split",
"[",
"0",
"]",
")",
";",
"var",
"mn",
"=",
"parseInt",
"(",
"split",
"[",
"1",
"]",
")",
";",
"if",
"(",
"this",
".",
"settings",
".",
"hour",
"===",
"12",
")",
"{",
"var",
"matches",
"=",
"time",
".",
"match",
"(",
"/",
"([0-1]?[0-9]):?([0-5][0-9])?\\s?(am|pm|p)?",
"/",
")",
";",
"var",
"ind",
"=",
"matches",
"[",
"3",
"]",
";",
"if",
"(",
"!",
"ind",
")",
"{",
"ind",
"=",
"'am'",
";",
"}",
"hour",
"=",
"parseInt",
"(",
"matches",
"[",
"1",
"]",
")",
";",
"mn",
"=",
"parseInt",
"(",
"matches",
"[",
"2",
"]",
")",
";",
"if",
"(",
"!",
"mn",
")",
"{",
"mn",
"=",
"0",
";",
"}",
"if",
"(",
"hour",
"===",
"12",
"&&",
"ind",
"===",
"'am'",
")",
"{",
"hour",
"=",
"0",
";",
"}",
"if",
"(",
"hour",
"===",
"12",
"&&",
"(",
"ind",
"===",
"'pm'",
"||",
"ind",
"===",
"'p'",
")",
")",
"{",
"ind",
"=",
"'am'",
";",
"}",
"if",
"(",
"ind",
"===",
"'pm'",
"||",
"ind",
"===",
"'p'",
")",
"{",
"hour",
"+=",
"12",
";",
"}",
"}",
"var",
"position",
"=",
"0",
";",
"position",
"+=",
"hour",
"*",
"this",
".",
"periodInterval",
";",
"position",
"+=",
"mn",
"/",
"60",
"*",
"this",
".",
"periodInterval",
";",
"if",
"(",
"Math",
".",
"floor",
"(",
"position",
")",
"!==",
"position",
")",
"{",
"return",
"-",
"1",
";",
"}",
"return",
"position",
";",
"}"
] | Return a position from a readable hour
@param time
@returns {number} | [
"Return",
"a",
"position",
"from",
"a",
"readable",
"hour"
] | a9df541cb16572a83a5b1f5fdbe611ea88a77835 | https://github.com/Yehzuna/jquery-schedule/blob/a9df541cb16572a83a5b1f5fdbe611ea88a77835/dist/jquery.schedule.js#L667-L706 | train |
|
Yehzuna/jquery-schedule | dist/jquery.schedule.js | function (current) {
var currentStart = Math.round(current.position().top);
var currentEnd = Math.round(current.position().top + current.height());
var start = 0;
var end = 0;
var check = true;
$('.jqs-period', $(current).parent()).each(function (index, period) {
if (current.attr('id') !== $(period).attr('id')) {
start = Math.round($(period).position().top);
end = Math.round($(period).position().top + $(period).height());
if (start > currentStart && start < currentEnd) {
check = false;
}
if (end > currentStart && end < currentEnd) {
check = false;
}
if (start < currentStart && end > currentEnd) {
check = false;
}
if (start === currentStart || end === currentEnd) {
check = false;
}
}
});
return check;
} | javascript | function (current) {
var currentStart = Math.round(current.position().top);
var currentEnd = Math.round(current.position().top + current.height());
var start = 0;
var end = 0;
var check = true;
$('.jqs-period', $(current).parent()).each(function (index, period) {
if (current.attr('id') !== $(period).attr('id')) {
start = Math.round($(period).position().top);
end = Math.round($(period).position().top + $(period).height());
if (start > currentStart && start < currentEnd) {
check = false;
}
if (end > currentStart && end < currentEnd) {
check = false;
}
if (start < currentStart && end > currentEnd) {
check = false;
}
if (start === currentStart || end === currentEnd) {
check = false;
}
}
});
return check;
} | [
"function",
"(",
"current",
")",
"{",
"var",
"currentStart",
"=",
"Math",
".",
"round",
"(",
"current",
".",
"position",
"(",
")",
".",
"top",
")",
";",
"var",
"currentEnd",
"=",
"Math",
".",
"round",
"(",
"current",
".",
"position",
"(",
")",
".",
"top",
"+",
"current",
".",
"height",
"(",
")",
")",
";",
"var",
"start",
"=",
"0",
";",
"var",
"end",
"=",
"0",
";",
"var",
"check",
"=",
"true",
";",
"$",
"(",
"'.jqs-period'",
",",
"$",
"(",
"current",
")",
".",
"parent",
"(",
")",
")",
".",
"each",
"(",
"function",
"(",
"index",
",",
"period",
")",
"{",
"if",
"(",
"current",
".",
"attr",
"(",
"'id'",
")",
"!==",
"$",
"(",
"period",
")",
".",
"attr",
"(",
"'id'",
")",
")",
"{",
"start",
"=",
"Math",
".",
"round",
"(",
"$",
"(",
"period",
")",
".",
"position",
"(",
")",
".",
"top",
")",
";",
"end",
"=",
"Math",
".",
"round",
"(",
"$",
"(",
"period",
")",
".",
"position",
"(",
")",
".",
"top",
"+",
"$",
"(",
"period",
")",
".",
"height",
"(",
")",
")",
";",
"if",
"(",
"start",
">",
"currentStart",
"&&",
"start",
"<",
"currentEnd",
")",
"{",
"check",
"=",
"false",
";",
"}",
"if",
"(",
"end",
">",
"currentStart",
"&&",
"end",
"<",
"currentEnd",
")",
"{",
"check",
"=",
"false",
";",
"}",
"if",
"(",
"start",
"<",
"currentStart",
"&&",
"end",
">",
"currentEnd",
")",
"{",
"check",
"=",
"false",
";",
"}",
"if",
"(",
"start",
"===",
"currentStart",
"||",
"end",
"===",
"currentEnd",
")",
"{",
"check",
"=",
"false",
";",
"}",
"}",
"}",
")",
";",
"return",
"check",
";",
"}"
] | Check if a period is valid
@param current
@returns {boolean} | [
"Check",
"if",
"a",
"period",
"is",
"valid"
] | a9df541cb16572a83a5b1f5fdbe611ea88a77835 | https://github.com/Yehzuna/jquery-schedule/blob/a9df541cb16572a83a5b1f5fdbe611ea88a77835/dist/jquery.schedule.js#L749-L780 | train |
|
Yehzuna/jquery-schedule | dist/jquery.schedule.js | function () {
var $this = this;
var data = [];
$('.jqs-day', $this.element).each(function (index, day) {
var periods = [];
$('.jqs-period', day).each(function (index, period) {
periods.push($this.periodData($(period)));
});
data.push({
day: index,
periods: periods
});
});
return JSON.stringify(data);
} | javascript | function () {
var $this = this;
var data = [];
$('.jqs-day', $this.element).each(function (index, day) {
var periods = [];
$('.jqs-period', day).each(function (index, period) {
periods.push($this.periodData($(period)));
});
data.push({
day: index,
periods: periods
});
});
return JSON.stringify(data);
} | [
"function",
"(",
")",
"{",
"var",
"$this",
"=",
"this",
";",
"var",
"data",
"=",
"[",
"]",
";",
"$",
"(",
"'.jqs-day'",
",",
"$this",
".",
"element",
")",
".",
"each",
"(",
"function",
"(",
"index",
",",
"day",
")",
"{",
"var",
"periods",
"=",
"[",
"]",
";",
"$",
"(",
"'.jqs-period'",
",",
"day",
")",
".",
"each",
"(",
"function",
"(",
"index",
",",
"period",
")",
"{",
"periods",
".",
"push",
"(",
"$this",
".",
"periodData",
"(",
"$",
"(",
"period",
")",
")",
")",
";",
"}",
")",
";",
"data",
".",
"push",
"(",
"{",
"day",
":",
"index",
",",
"periods",
":",
"periods",
"}",
")",
";",
"}",
")",
";",
"return",
"JSON",
".",
"stringify",
"(",
"data",
")",
";",
"}"
] | Export data to JSON string
@returns {string} | [
"Export",
"data",
"to",
"JSON",
"string"
] | a9df541cb16572a83a5b1f5fdbe611ea88a77835 | https://github.com/Yehzuna/jquery-schedule/blob/a9df541cb16572a83a5b1f5fdbe611ea88a77835/dist/jquery.schedule.js#L786-L803 | train |
|
Yehzuna/jquery-schedule | dist/jquery.schedule.js | function (args) {
var $this = this;
var dataImport = args[1];
var ret = [];
$.each(dataImport, function (index, data) {
$.each(data.periods, function (index, period) {
var parent = $('.jqs-day', $this.element).eq(data.day);
var options = {};
var height, position;
if ($.isArray(period)) {
position = $this.positionFormat(period[0]);
height = $this.positionFormat(period[1]);
} else {
position = $this.positionFormat(period.start);
height = $this.positionFormat(period.end);
options = period;
}
if (height === 0) {
height = $this.periodHeight;
}
var status = true;
if (!$this.add(parent, position, height - position, options)) {
status = false;
}
ret.push({
day: data.day,
period: [
$this.periodFormat(position),
$this.periodFormat(height)
],
status: status
});
});
});
return JSON.stringify(ret);
} | javascript | function (args) {
var $this = this;
var dataImport = args[1];
var ret = [];
$.each(dataImport, function (index, data) {
$.each(data.periods, function (index, period) {
var parent = $('.jqs-day', $this.element).eq(data.day);
var options = {};
var height, position;
if ($.isArray(period)) {
position = $this.positionFormat(period[0]);
height = $this.positionFormat(period[1]);
} else {
position = $this.positionFormat(period.start);
height = $this.positionFormat(period.end);
options = period;
}
if (height === 0) {
height = $this.periodHeight;
}
var status = true;
if (!$this.add(parent, position, height - position, options)) {
status = false;
}
ret.push({
day: data.day,
period: [
$this.periodFormat(position),
$this.periodFormat(height)
],
status: status
});
});
});
return JSON.stringify(ret);
} | [
"function",
"(",
"args",
")",
"{",
"var",
"$this",
"=",
"this",
";",
"var",
"dataImport",
"=",
"args",
"[",
"1",
"]",
";",
"var",
"ret",
"=",
"[",
"]",
";",
"$",
".",
"each",
"(",
"dataImport",
",",
"function",
"(",
"index",
",",
"data",
")",
"{",
"$",
".",
"each",
"(",
"data",
".",
"periods",
",",
"function",
"(",
"index",
",",
"period",
")",
"{",
"var",
"parent",
"=",
"$",
"(",
"'.jqs-day'",
",",
"$this",
".",
"element",
")",
".",
"eq",
"(",
"data",
".",
"day",
")",
";",
"var",
"options",
"=",
"{",
"}",
";",
"var",
"height",
",",
"position",
";",
"if",
"(",
"$",
".",
"isArray",
"(",
"period",
")",
")",
"{",
"position",
"=",
"$this",
".",
"positionFormat",
"(",
"period",
"[",
"0",
"]",
")",
";",
"height",
"=",
"$this",
".",
"positionFormat",
"(",
"period",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"position",
"=",
"$this",
".",
"positionFormat",
"(",
"period",
".",
"start",
")",
";",
"height",
"=",
"$this",
".",
"positionFormat",
"(",
"period",
".",
"end",
")",
";",
"options",
"=",
"period",
";",
"}",
"if",
"(",
"height",
"===",
"0",
")",
"{",
"height",
"=",
"$this",
".",
"periodHeight",
";",
"}",
"var",
"status",
"=",
"true",
";",
"if",
"(",
"!",
"$this",
".",
"add",
"(",
"parent",
",",
"position",
",",
"height",
"-",
"position",
",",
"options",
")",
")",
"{",
"status",
"=",
"false",
";",
"}",
"ret",
".",
"push",
"(",
"{",
"day",
":",
"data",
".",
"day",
",",
"period",
":",
"[",
"$this",
".",
"periodFormat",
"(",
"position",
")",
",",
"$this",
".",
"periodFormat",
"(",
"height",
")",
"]",
",",
"status",
":",
"status",
"}",
")",
";",
"}",
")",
";",
"}",
")",
";",
"return",
"JSON",
".",
"stringify",
"(",
"ret",
")",
";",
"}"
] | Import data on plugin init
@param args
@returns {Array} | [
"Import",
"data",
"on",
"plugin",
"init"
] | a9df541cb16572a83a5b1f5fdbe611ea88a77835 | https://github.com/Yehzuna/jquery-schedule/blob/a9df541cb16572a83a5b1f5fdbe611ea88a77835/dist/jquery.schedule.js#L810-L849 | train |
|
DanielBaulig/node-gettext | lib/gettext.js | function (d, msgctxt, msgid, msgid_plural, n, category) {
if (! msgid) {
return '';
}
var msg_ctxt_id = msgctxt ? msgctxt + this.context_glue + msgid : msgid;
var domainname = d || this.domain || 'messages';
var lang = this.lang;
// category is always LC_MESSAGES. We ignore all else
var category_name = 'LC_MESSAGES';
category = 5;
var locale_data = [];
if (typeof(this.data[lang]) != 'undefined' &&
this.data[lang][domainname]) {
locale_data.push(this.data[lang][domainname] );
} else if (typeof(this.data[lang]) != 'undefined') {
// didn't find domain we're looking for. Search all of them.
for (var dom in this.data[lang]) {
locale_data.push(this.data[lang][dom] );
}
}
var trans = [];
var found = false;
var domain_used; // so we can find plural-forms if needed
if (locale_data.length) {
for (var i=0; i<locale_data.length; i++) {
var locale = locale_data[i];
if (locale.msgs[msg_ctxt_id]) {
var msg_ctxt_str = locale.msgs[msg_ctxt_id].msgstr;
trans = msg_ctxt_str.concat(trans.slice(msg_ctxt_str.length));
domain_used = locale;
found = true;
// only break if found translation actually has a translation.
if ( trans.length > 0 && trans[0].length !== 0 ) {
break;
}
}
}
}
// default to english if we lack a match, or match has zero length
if ( trans.length === 0 || trans[0].length === 0 ) {
trans = [ msgid, msgid_plural ];
}
var translation = trans[0];
if (msgid_plural) {
var p;
if (found && domain_used.head.plural_func) {
var rv = domain_used.head.plural_func(n);
if (! rv.plural) {
rv.plural = 0;
}
if (! rv.nplural) {
rv.nplural = 0;
}
// if plurals returned is out of bound for total plural forms
if (rv.nplural <= rv.plural) {
rv.plural = 0;
}
p = rv.plural;
} else {
p = (n != 1) ? 1 : 0;
}
if (trans[p]) {
translation = trans[p];
}
}
return translation;
} | javascript | function (d, msgctxt, msgid, msgid_plural, n, category) {
if (! msgid) {
return '';
}
var msg_ctxt_id = msgctxt ? msgctxt + this.context_glue + msgid : msgid;
var domainname = d || this.domain || 'messages';
var lang = this.lang;
// category is always LC_MESSAGES. We ignore all else
var category_name = 'LC_MESSAGES';
category = 5;
var locale_data = [];
if (typeof(this.data[lang]) != 'undefined' &&
this.data[lang][domainname]) {
locale_data.push(this.data[lang][domainname] );
} else if (typeof(this.data[lang]) != 'undefined') {
// didn't find domain we're looking for. Search all of them.
for (var dom in this.data[lang]) {
locale_data.push(this.data[lang][dom] );
}
}
var trans = [];
var found = false;
var domain_used; // so we can find plural-forms if needed
if (locale_data.length) {
for (var i=0; i<locale_data.length; i++) {
var locale = locale_data[i];
if (locale.msgs[msg_ctxt_id]) {
var msg_ctxt_str = locale.msgs[msg_ctxt_id].msgstr;
trans = msg_ctxt_str.concat(trans.slice(msg_ctxt_str.length));
domain_used = locale;
found = true;
// only break if found translation actually has a translation.
if ( trans.length > 0 && trans[0].length !== 0 ) {
break;
}
}
}
}
// default to english if we lack a match, or match has zero length
if ( trans.length === 0 || trans[0].length === 0 ) {
trans = [ msgid, msgid_plural ];
}
var translation = trans[0];
if (msgid_plural) {
var p;
if (found && domain_used.head.plural_func) {
var rv = domain_used.head.plural_func(n);
if (! rv.plural) {
rv.plural = 0;
}
if (! rv.nplural) {
rv.nplural = 0;
}
// if plurals returned is out of bound for total plural forms
if (rv.nplural <= rv.plural) {
rv.plural = 0;
}
p = rv.plural;
} else {
p = (n != 1) ? 1 : 0;
}
if (trans[p]) {
translation = trans[p];
}
}
return translation;
} | [
"function",
"(",
"d",
",",
"msgctxt",
",",
"msgid",
",",
"msgid_plural",
",",
"n",
",",
"category",
")",
"{",
"if",
"(",
"!",
"msgid",
")",
"{",
"return",
"''",
";",
"}",
"var",
"msg_ctxt_id",
"=",
"msgctxt",
"?",
"msgctxt",
"+",
"this",
".",
"context_glue",
"+",
"msgid",
":",
"msgid",
";",
"var",
"domainname",
"=",
"d",
"||",
"this",
".",
"domain",
"||",
"'messages'",
";",
"var",
"lang",
"=",
"this",
".",
"lang",
";",
"var",
"category_name",
"=",
"'LC_MESSAGES'",
";",
"category",
"=",
"5",
";",
"var",
"locale_data",
"=",
"[",
"]",
";",
"if",
"(",
"typeof",
"(",
"this",
".",
"data",
"[",
"lang",
"]",
")",
"!=",
"'undefined'",
"&&",
"this",
".",
"data",
"[",
"lang",
"]",
"[",
"domainname",
"]",
")",
"{",
"locale_data",
".",
"push",
"(",
"this",
".",
"data",
"[",
"lang",
"]",
"[",
"domainname",
"]",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"(",
"this",
".",
"data",
"[",
"lang",
"]",
")",
"!=",
"'undefined'",
")",
"{",
"for",
"(",
"var",
"dom",
"in",
"this",
".",
"data",
"[",
"lang",
"]",
")",
"{",
"locale_data",
".",
"push",
"(",
"this",
".",
"data",
"[",
"lang",
"]",
"[",
"dom",
"]",
")",
";",
"}",
"}",
"var",
"trans",
"=",
"[",
"]",
";",
"var",
"found",
"=",
"false",
";",
"var",
"domain_used",
";",
"if",
"(",
"locale_data",
".",
"length",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"locale_data",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"locale",
"=",
"locale_data",
"[",
"i",
"]",
";",
"if",
"(",
"locale",
".",
"msgs",
"[",
"msg_ctxt_id",
"]",
")",
"{",
"var",
"msg_ctxt_str",
"=",
"locale",
".",
"msgs",
"[",
"msg_ctxt_id",
"]",
".",
"msgstr",
";",
"trans",
"=",
"msg_ctxt_str",
".",
"concat",
"(",
"trans",
".",
"slice",
"(",
"msg_ctxt_str",
".",
"length",
")",
")",
";",
"domain_used",
"=",
"locale",
";",
"found",
"=",
"true",
";",
"if",
"(",
"trans",
".",
"length",
">",
"0",
"&&",
"trans",
"[",
"0",
"]",
".",
"length",
"!==",
"0",
")",
"{",
"break",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"trans",
".",
"length",
"===",
"0",
"||",
"trans",
"[",
"0",
"]",
".",
"length",
"===",
"0",
")",
"{",
"trans",
"=",
"[",
"msgid",
",",
"msgid_plural",
"]",
";",
"}",
"var",
"translation",
"=",
"trans",
"[",
"0",
"]",
";",
"if",
"(",
"msgid_plural",
")",
"{",
"var",
"p",
";",
"if",
"(",
"found",
"&&",
"domain_used",
".",
"head",
".",
"plural_func",
")",
"{",
"var",
"rv",
"=",
"domain_used",
".",
"head",
".",
"plural_func",
"(",
"n",
")",
";",
"if",
"(",
"!",
"rv",
".",
"plural",
")",
"{",
"rv",
".",
"plural",
"=",
"0",
";",
"}",
"if",
"(",
"!",
"rv",
".",
"nplural",
")",
"{",
"rv",
".",
"nplural",
"=",
"0",
";",
"}",
"if",
"(",
"rv",
".",
"nplural",
"<=",
"rv",
".",
"plural",
")",
"{",
"rv",
".",
"plural",
"=",
"0",
";",
"}",
"p",
"=",
"rv",
".",
"plural",
";",
"}",
"else",
"{",
"p",
"=",
"(",
"n",
"!=",
"1",
")",
"?",
"1",
":",
"0",
";",
"}",
"if",
"(",
"trans",
"[",
"p",
"]",
")",
"{",
"translation",
"=",
"trans",
"[",
"p",
"]",
";",
"}",
"}",
"return",
"translation",
";",
"}"
] | this has all the options, so we use it for all of them. | [
"this",
"has",
"all",
"the",
"options",
"so",
"we",
"use",
"it",
"for",
"all",
"of",
"them",
"."
] | 39dd22e6af8a601cfbbd6eb27ac8dbbe6075cb63 | https://github.com/DanielBaulig/node-gettext/blob/39dd22e6af8a601cfbbd6eb27ac8dbbe6075cb63/lib/gettext.js#L311-L386 | train |
|
janvotava/swagger-koa | example/public/swagger/lib/handlebars-1.0.rc.1.js | function(mustache, program, inverse) {
var params = mustache.params;
this.pushParams(params);
this.opcode('pushProgram', program);
this.opcode('pushProgram', inverse);
if(mustache.hash) {
this.hash(mustache.hash);
} else {
this.opcode('pushLiteral', '{}');
}
return params;
} | javascript | function(mustache, program, inverse) {
var params = mustache.params;
this.pushParams(params);
this.opcode('pushProgram', program);
this.opcode('pushProgram', inverse);
if(mustache.hash) {
this.hash(mustache.hash);
} else {
this.opcode('pushLiteral', '{}');
}
return params;
} | [
"function",
"(",
"mustache",
",",
"program",
",",
"inverse",
")",
"{",
"var",
"params",
"=",
"mustache",
".",
"params",
";",
"this",
".",
"pushParams",
"(",
"params",
")",
";",
"this",
".",
"opcode",
"(",
"'pushProgram'",
",",
"program",
")",
";",
"this",
".",
"opcode",
"(",
"'pushProgram'",
",",
"inverse",
")",
";",
"if",
"(",
"mustache",
".",
"hash",
")",
"{",
"this",
".",
"hash",
"(",
"mustache",
".",
"hash",
")",
";",
"}",
"else",
"{",
"this",
".",
"opcode",
"(",
"'pushLiteral'",
",",
"'{}'",
")",
";",
"}",
"return",
"params",
";",
"}"
] | this will replace setupMustacheParams when we're done | [
"this",
"will",
"replace",
"setupMustacheParams",
"when",
"we",
"re",
"done"
] | 510696b3eca3bcaf23a0cd4d2debcb5986d55860 | https://github.com/janvotava/swagger-koa/blob/510696b3eca3bcaf23a0cd4d2debcb5986d55860/example/public/swagger/lib/handlebars-1.0.rc.1.js#L1140-L1154 | train |
|
janvotava/swagger-koa | lib/swagger-koa/index.js | parseCoffeeDocs | function parseCoffeeDocs(file, fn) {
fs.readFile(file, function(err, data) {
if (err) {
fn(err);
}
var js = coffee.compile(data.toString());
var regex = /\/\**([\s\S]*?)\*\//gm;
var fragments = js.match(regex);
var docs = [];
for (var i = 0; i < fragments.length; i++) {
var fragment = fragments[i];
var doc = doctrine.parse(fragment, {unwrap: true});
docs.push(doc);
if (i === fragments.length - 1) {
fn(null, docs);
}
}
});
} | javascript | function parseCoffeeDocs(file, fn) {
fs.readFile(file, function(err, data) {
if (err) {
fn(err);
}
var js = coffee.compile(data.toString());
var regex = /\/\**([\s\S]*?)\*\//gm;
var fragments = js.match(regex);
var docs = [];
for (var i = 0; i < fragments.length; i++) {
var fragment = fragments[i];
var doc = doctrine.parse(fragment, {unwrap: true});
docs.push(doc);
if (i === fragments.length - 1) {
fn(null, docs);
}
}
});
} | [
"function",
"parseCoffeeDocs",
"(",
"file",
",",
"fn",
")",
"{",
"fs",
".",
"readFile",
"(",
"file",
",",
"function",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
"err",
")",
"{",
"fn",
"(",
"err",
")",
";",
"}",
"var",
"js",
"=",
"coffee",
".",
"compile",
"(",
"data",
".",
"toString",
"(",
")",
")",
";",
"var",
"regex",
"=",
"/",
"\\/\\**([\\s\\S]*?)\\*\\/",
"/",
"gm",
";",
"var",
"fragments",
"=",
"js",
".",
"match",
"(",
"regex",
")",
";",
"var",
"docs",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"fragments",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"fragment",
"=",
"fragments",
"[",
"i",
"]",
";",
"var",
"doc",
"=",
"doctrine",
".",
"parse",
"(",
"fragment",
",",
"{",
"unwrap",
":",
"true",
"}",
")",
";",
"docs",
".",
"push",
"(",
"doc",
")",
";",
"if",
"(",
"i",
"===",
"fragments",
".",
"length",
"-",
"1",
")",
"{",
"fn",
"(",
"null",
",",
"docs",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] | Parse coffeeDoc from a coffee file
@api private
@param {String} file
@param {Function} fn | [
"Parse",
"coffeeDoc",
"from",
"a",
"coffee",
"file"
] | 510696b3eca3bcaf23a0cd4d2debcb5986d55860 | https://github.com/janvotava/swagger-koa/blob/510696b3eca3bcaf23a0cd4d2debcb5986d55860/lib/swagger-koa/index.js#L82-L104 | train |
janvotava/swagger-koa | lib/swagger-koa/index.js | getSwagger | function getSwagger(fragment, fn) {
for (var i = 0; i < fragment.tags.length; i++) {
var tag = fragment.tags[i];
if ('swagger' === tag.title) {
return yaml.safeLoadAll(tag.description, fn);
}
}
return fn(false);
} | javascript | function getSwagger(fragment, fn) {
for (var i = 0; i < fragment.tags.length; i++) {
var tag = fragment.tags[i];
if ('swagger' === tag.title) {
return yaml.safeLoadAll(tag.description, fn);
}
}
return fn(false);
} | [
"function",
"getSwagger",
"(",
"fragment",
",",
"fn",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"fragment",
".",
"tags",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"tag",
"=",
"fragment",
".",
"tags",
"[",
"i",
"]",
";",
"if",
"(",
"'swagger'",
"===",
"tag",
".",
"title",
")",
"{",
"return",
"yaml",
".",
"safeLoadAll",
"(",
"tag",
".",
"description",
",",
"fn",
")",
";",
"}",
"}",
"return",
"fn",
"(",
"false",
")",
";",
"}"
] | Get jsDoc tag with title '@swagger'
@api private
@param {Object} fragment
@param {Function} fn | [
"Get",
"jsDoc",
"tag",
"with",
"title"
] | 510696b3eca3bcaf23a0cd4d2debcb5986d55860 | https://github.com/janvotava/swagger-koa/blob/510696b3eca3bcaf23a0cd4d2debcb5986d55860/lib/swagger-koa/index.js#L112-L121 | train |
janvotava/swagger-koa | lib/swagger-koa/index.js | readApi | function readApi(file, fn) {
var ext = path.extname(file);
if ('.js' === ext || '.ts' === ext) {
readJsDoc(file, fn);
} else if ('.yml' === ext) {
readYml(file, fn);
} else if ('.coffee' === ext) {
readCoffee(file, fn);
} else {
throw new Error('Unsupported extension \'' + ext + '\'');
}
} | javascript | function readApi(file, fn) {
var ext = path.extname(file);
if ('.js' === ext || '.ts' === ext) {
readJsDoc(file, fn);
} else if ('.yml' === ext) {
readYml(file, fn);
} else if ('.coffee' === ext) {
readCoffee(file, fn);
} else {
throw new Error('Unsupported extension \'' + ext + '\'');
}
} | [
"function",
"readApi",
"(",
"file",
",",
"fn",
")",
"{",
"var",
"ext",
"=",
"path",
".",
"extname",
"(",
"file",
")",
";",
"if",
"(",
"'.js'",
"===",
"ext",
"||",
"'.ts'",
"===",
"ext",
")",
"{",
"readJsDoc",
"(",
"file",
",",
"fn",
")",
";",
"}",
"else",
"if",
"(",
"'.yml'",
"===",
"ext",
")",
"{",
"readYml",
"(",
"file",
",",
"fn",
")",
";",
"}",
"else",
"if",
"(",
"'.coffee'",
"===",
"ext",
")",
"{",
"readCoffee",
"(",
"file",
",",
"fn",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"'Unsupported extension \\''",
"+",
"\\'",
"+",
"ext",
")",
";",
"}",
"}"
] | Read API from file
@api private
@param {String} file
@param {Function} fn | [
"Read",
"API",
"from",
"file"
] | 510696b3eca3bcaf23a0cd4d2debcb5986d55860 | https://github.com/janvotava/swagger-koa/blob/510696b3eca3bcaf23a0cd4d2debcb5986d55860/lib/swagger-koa/index.js#L209-L220 | train |
thlorenz/proxyquireify | lib/prelude.js | function(x){
var pqify = (proxyquireifyName != null) && cache[proxyquireifyName];
// Only try to use the proxyquireify version if it has been `require`d
if (pqify && pqify.exports._proxy) {
return pqify.exports._proxy(req, x);
} else {
return req(x);
}
} | javascript | function(x){
var pqify = (proxyquireifyName != null) && cache[proxyquireifyName];
// Only try to use the proxyquireify version if it has been `require`d
if (pqify && pqify.exports._proxy) {
return pqify.exports._proxy(req, x);
} else {
return req(x);
}
} | [
"function",
"(",
"x",
")",
"{",
"var",
"pqify",
"=",
"(",
"proxyquireifyName",
"!=",
"null",
")",
"&&",
"cache",
"[",
"proxyquireifyName",
"]",
";",
"if",
"(",
"pqify",
"&&",
"pqify",
".",
"exports",
".",
"_proxy",
")",
"{",
"return",
"pqify",
".",
"exports",
".",
"_proxy",
"(",
"req",
",",
"x",
")",
";",
"}",
"else",
"{",
"return",
"req",
"(",
"x",
")",
";",
"}",
"}"
] | The require function substituted for proxyquireify | [
"The",
"require",
"function",
"substituted",
"for",
"proxyquireify"
] | 8f2596ee5b931a5646bb35746c805ab80f51aa99 | https://github.com/thlorenz/proxyquireify/blob/8f2596ee5b931a5646bb35746c805ab80f51aa99/lib/prelude.js#L65-L73 | train |
|
thienhung1989/angular-tree-dnd | dist/ng-tree-dnd.debug.js | pointIsInsideBounds | function pointIsInsideBounds(x, y, bounds) {
return x >= bounds.left &&
y >= bounds.top &&
x <= bounds.left + bounds.width &&
y <= bounds.top + bounds.height;
} | javascript | function pointIsInsideBounds(x, y, bounds) {
return x >= bounds.left &&
y >= bounds.top &&
x <= bounds.left + bounds.width &&
y <= bounds.top + bounds.height;
} | [
"function",
"pointIsInsideBounds",
"(",
"x",
",",
"y",
",",
"bounds",
")",
"{",
"return",
"x",
">=",
"bounds",
".",
"left",
"&&",
"y",
">=",
"bounds",
".",
"top",
"&&",
"x",
"<=",
"bounds",
".",
"left",
"+",
"bounds",
".",
"width",
"&&",
"y",
"<=",
"bounds",
".",
"top",
"+",
"bounds",
".",
"height",
";",
"}"
] | Check if a point is inside specified bounds
@param x
@param y
@param bounds
@returns {boolean} | [
"Check",
"if",
"a",
"point",
"is",
"inside",
"specified",
"bounds"
] | ac1a5cf6ccd14d17f117b39cf00328d6285362bb | https://github.com/thienhung1989/angular-tree-dnd/blob/ac1a5cf6ccd14d17f117b39cf00328d6285362bb/dist/ng-tree-dnd.debug.js#L1861-L1866 | train |
thienhung1989/angular-tree-dnd | dist/ng-tree-dnd.debug.js | add | function add(scope, element) {
updateDelayed();
items.push({
element: element,
scope: scope
});
} | javascript | function add(scope, element) {
updateDelayed();
items.push({
element: element,
scope: scope
});
} | [
"function",
"add",
"(",
"scope",
",",
"element",
")",
"{",
"updateDelayed",
"(",
")",
";",
"items",
".",
"push",
"(",
"{",
"element",
":",
"element",
",",
"scope",
":",
"scope",
"}",
")",
";",
"}"
] | Add listener for event
@param element
@param callback | [
"Add",
"listener",
"for",
"event"
] | ac1a5cf6ccd14d17f117b39cf00328d6285362bb | https://github.com/thienhung1989/angular-tree-dnd/blob/ac1a5cf6ccd14d17f117b39cf00328d6285362bb/dist/ng-tree-dnd.debug.js#L1904-L1911 | train |
thienhung1989/angular-tree-dnd | dist/ng-tree-dnd.debug.js | _fnCheck | function _fnCheck(callback, data) {
if (angular.isUndefinedOrNull(data) || angular.isArray(data)) {
return; // jmp out
}
if (angular.isFunction(callback)) {
return callback(data, $filter);
} else {
if (typeof callback === 'boolean') {
data = !!data;
return data === callback;
} else if (angular.isDefined(callback)) {
try {
var _regex = new RegExp(callback);
return _regex.test(data);
}
catch (err) {
if (typeof data === 'string') {
return data.indexOf(callback) > -1;
} else {
return; // jmp out
}
}
} else {
return; // jmp out
}
}
} | javascript | function _fnCheck(callback, data) {
if (angular.isUndefinedOrNull(data) || angular.isArray(data)) {
return; // jmp out
}
if (angular.isFunction(callback)) {
return callback(data, $filter);
} else {
if (typeof callback === 'boolean') {
data = !!data;
return data === callback;
} else if (angular.isDefined(callback)) {
try {
var _regex = new RegExp(callback);
return _regex.test(data);
}
catch (err) {
if (typeof data === 'string') {
return data.indexOf(callback) > -1;
} else {
return; // jmp out
}
}
} else {
return; // jmp out
}
}
} | [
"function",
"_fnCheck",
"(",
"callback",
",",
"data",
")",
"{",
"if",
"(",
"angular",
".",
"isUndefinedOrNull",
"(",
"data",
")",
"||",
"angular",
".",
"isArray",
"(",
"data",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"angular",
".",
"isFunction",
"(",
"callback",
")",
")",
"{",
"return",
"callback",
"(",
"data",
",",
"$filter",
")",
";",
"}",
"else",
"{",
"if",
"(",
"typeof",
"callback",
"===",
"'boolean'",
")",
"{",
"data",
"=",
"!",
"!",
"data",
";",
"return",
"data",
"===",
"callback",
";",
"}",
"else",
"if",
"(",
"angular",
".",
"isDefined",
"(",
"callback",
")",
")",
"{",
"try",
"{",
"var",
"_regex",
"=",
"new",
"RegExp",
"(",
"callback",
")",
";",
"return",
"_regex",
".",
"test",
"(",
"data",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"if",
"(",
"typeof",
"data",
"===",
"'string'",
")",
"{",
"return",
"data",
".",
"indexOf",
"(",
"callback",
")",
">",
"-",
"1",
";",
"}",
"else",
"{",
"return",
";",
"}",
"}",
"}",
"else",
"{",
"return",
";",
"}",
"}",
"}"
] | Check data with callback
@param {string|object|function|regex} callback
@param {*} data
@returns {undefined|boolean}
@private | [
"Check",
"data",
"with",
"callback"
] | ac1a5cf6ccd14d17f117b39cf00328d6285362bb | https://github.com/thienhung1989/angular-tree-dnd/blob/ac1a5cf6ccd14d17f117b39cf00328d6285362bb/dist/ng-tree-dnd.debug.js#L1975-L2002 | train |
thienhung1989/angular-tree-dnd | dist/ng-tree-dnd.debug.js | _fnAfter | function _fnAfter(options, node, isNodePassed, isChildPassed, isParentPassed) {
if (isNodePassed === true) {
node.__filtered__ = true;
node.__filtered_visible__ = true;
node.__filtered_index__ = options.filter_index++;
return; //jmp
} else if (isChildPassed === true && options.showParent === true
|| isParentPassed === true && options.showChild === true) {
node.__filtered__ = false;
node.__filtered_visible__ = true;
node.__filtered_index__ = options.filter_index++;
return; //jmp
}
// remove attr __filtered__
delete node.__filtered__;
delete node.__filtered_visible__;
delete node.__filtered_index__;
} | javascript | function _fnAfter(options, node, isNodePassed, isChildPassed, isParentPassed) {
if (isNodePassed === true) {
node.__filtered__ = true;
node.__filtered_visible__ = true;
node.__filtered_index__ = options.filter_index++;
return; //jmp
} else if (isChildPassed === true && options.showParent === true
|| isParentPassed === true && options.showChild === true) {
node.__filtered__ = false;
node.__filtered_visible__ = true;
node.__filtered_index__ = options.filter_index++;
return; //jmp
}
// remove attr __filtered__
delete node.__filtered__;
delete node.__filtered_visible__;
delete node.__filtered_index__;
} | [
"function",
"_fnAfter",
"(",
"options",
",",
"node",
",",
"isNodePassed",
",",
"isChildPassed",
",",
"isParentPassed",
")",
"{",
"if",
"(",
"isNodePassed",
"===",
"true",
")",
"{",
"node",
".",
"__filtered__",
"=",
"true",
";",
"node",
".",
"__filtered_visible__",
"=",
"true",
";",
"node",
".",
"__filtered_index__",
"=",
"options",
".",
"filter_index",
"++",
";",
"return",
";",
"}",
"else",
"if",
"(",
"isChildPassed",
"===",
"true",
"&&",
"options",
".",
"showParent",
"===",
"true",
"||",
"isParentPassed",
"===",
"true",
"&&",
"options",
".",
"showChild",
"===",
"true",
")",
"{",
"node",
".",
"__filtered__",
"=",
"false",
";",
"node",
".",
"__filtered_visible__",
"=",
"true",
";",
"node",
".",
"__filtered_index__",
"=",
"options",
".",
"filter_index",
"++",
";",
"return",
";",
"}",
"delete",
"node",
".",
"__filtered__",
";",
"delete",
"node",
".",
"__filtered_visible__",
";",
"delete",
"node",
".",
"__filtered_index__",
";",
"}"
] | Will call _fnAfter to clear data no need
@param {object} options
@param {object} node
@param {boolean} isNodePassed
@param {boolean} isChildPassed
@param {boolean} isParentPassed
@private | [
"Will",
"call",
"_fnAfter",
"to",
"clear",
"data",
"no",
"need"
] | ac1a5cf6ccd14d17f117b39cf00328d6285362bb | https://github.com/thienhung1989/angular-tree-dnd/blob/ac1a5cf6ccd14d17f117b39cf00328d6285362bb/dist/ng-tree-dnd.debug.js#L2077-L2095 | train |
thienhung1989/angular-tree-dnd | dist/ng-tree-dnd.debug.js | _fnConvert | function _fnConvert(filters) {
var _iF, _lenF, _keysF,
_filter,
_state;
// convert filter object to array filter
if (angular.isObject(filters) && !angular.isArray(filters)) {
_keysF = Object.keys(filters);
_lenF = _keysF.length;
_filter = [];
if (_lenF > 0) {
for (_iF = 0; _iF < _lenF; _iF++) {
if (typeof filters[_keysF[_iF]] === 'string' && filters[_keysF[_iF]].length === 0) {
continue;
} else if (angular.isArray(filters[_keysF[_iF]])) {
_state = filters[_keysF[_iF]];
} else if (angular.isObject(filters[_keysF[_iF]])) {
_state = _fnConvert(filters[_keysF[_iF]]);
} else {
_state = {
field: _keysF[_iF],
callback: filters[_keysF[_iF]]
};
}
_filter.push(_state);
}
}
return _filter;
}
else {
return filters;
}
} | javascript | function _fnConvert(filters) {
var _iF, _lenF, _keysF,
_filter,
_state;
// convert filter object to array filter
if (angular.isObject(filters) && !angular.isArray(filters)) {
_keysF = Object.keys(filters);
_lenF = _keysF.length;
_filter = [];
if (_lenF > 0) {
for (_iF = 0; _iF < _lenF; _iF++) {
if (typeof filters[_keysF[_iF]] === 'string' && filters[_keysF[_iF]].length === 0) {
continue;
} else if (angular.isArray(filters[_keysF[_iF]])) {
_state = filters[_keysF[_iF]];
} else if (angular.isObject(filters[_keysF[_iF]])) {
_state = _fnConvert(filters[_keysF[_iF]]);
} else {
_state = {
field: _keysF[_iF],
callback: filters[_keysF[_iF]]
};
}
_filter.push(_state);
}
}
return _filter;
}
else {
return filters;
}
} | [
"function",
"_fnConvert",
"(",
"filters",
")",
"{",
"var",
"_iF",
",",
"_lenF",
",",
"_keysF",
",",
"_filter",
",",
"_state",
";",
"if",
"(",
"angular",
".",
"isObject",
"(",
"filters",
")",
"&&",
"!",
"angular",
".",
"isArray",
"(",
"filters",
")",
")",
"{",
"_keysF",
"=",
"Object",
".",
"keys",
"(",
"filters",
")",
";",
"_lenF",
"=",
"_keysF",
".",
"length",
";",
"_filter",
"=",
"[",
"]",
";",
"if",
"(",
"_lenF",
">",
"0",
")",
"{",
"for",
"(",
"_iF",
"=",
"0",
";",
"_iF",
"<",
"_lenF",
";",
"_iF",
"++",
")",
"{",
"if",
"(",
"typeof",
"filters",
"[",
"_keysF",
"[",
"_iF",
"]",
"]",
"===",
"'string'",
"&&",
"filters",
"[",
"_keysF",
"[",
"_iF",
"]",
"]",
".",
"length",
"===",
"0",
")",
"{",
"continue",
";",
"}",
"else",
"if",
"(",
"angular",
".",
"isArray",
"(",
"filters",
"[",
"_keysF",
"[",
"_iF",
"]",
"]",
")",
")",
"{",
"_state",
"=",
"filters",
"[",
"_keysF",
"[",
"_iF",
"]",
"]",
";",
"}",
"else",
"if",
"(",
"angular",
".",
"isObject",
"(",
"filters",
"[",
"_keysF",
"[",
"_iF",
"]",
"]",
")",
")",
"{",
"_state",
"=",
"_fnConvert",
"(",
"filters",
"[",
"_keysF",
"[",
"_iF",
"]",
"]",
")",
";",
"}",
"else",
"{",
"_state",
"=",
"{",
"field",
":",
"_keysF",
"[",
"_iF",
"]",
",",
"callback",
":",
"filters",
"[",
"_keysF",
"[",
"_iF",
"]",
"]",
"}",
";",
"}",
"_filter",
".",
"push",
"(",
"_state",
")",
";",
"}",
"}",
"return",
"_filter",
";",
"}",
"else",
"{",
"return",
"filters",
";",
"}",
"}"
] | `_fnConvert` to convert `filter` `object` to `array` invaild.
@param {object|array} filters
@returns {array} Instead of `filter` or new array invaild *(converted from filter)*
@private | [
"_fnConvert",
"to",
"convert",
"filter",
"object",
"to",
"array",
"invaild",
"."
] | ac1a5cf6ccd14d17f117b39cf00328d6285362bb | https://github.com/thienhung1989/angular-tree-dnd/blob/ac1a5cf6ccd14d17f117b39cf00328d6285362bb/dist/ng-tree-dnd.debug.js#L2134-L2169 | train |
pattern-lab/styleguidekit-assets-default | dist/styleguide/js/patternlab-viewer.js | function (e) {
var patternName;
var state = e.state;
if (state === null) {
this.skipBack = false;
return;
} else if (state !== null) {
patternName = state.pattern;
}
var iFramePath = "";
iFramePath = this.getFileName(patternName);
if (iFramePath === "") {
iFramePath = "styleguide/html/styleguide.html";
}
var obj = JSON.stringify({
"event": "patternLab.updatePath",
"path": iFramePath
});
document.querySelector('.pl-js-iframe').contentWindow.postMessage(obj, urlHandler.targetOrigin);
document.getElementById("title").innerHTML = "Pattern Lab - " + patternName;
document.querySelector('.pl-js-open-new-window').setAttribute("href", urlHandler.getFileName(patternName));
} | javascript | function (e) {
var patternName;
var state = e.state;
if (state === null) {
this.skipBack = false;
return;
} else if (state !== null) {
patternName = state.pattern;
}
var iFramePath = "";
iFramePath = this.getFileName(patternName);
if (iFramePath === "") {
iFramePath = "styleguide/html/styleguide.html";
}
var obj = JSON.stringify({
"event": "patternLab.updatePath",
"path": iFramePath
});
document.querySelector('.pl-js-iframe').contentWindow.postMessage(obj, urlHandler.targetOrigin);
document.getElementById("title").innerHTML = "Pattern Lab - " + patternName;
document.querySelector('.pl-js-open-new-window').setAttribute("href", urlHandler.getFileName(patternName));
} | [
"function",
"(",
"e",
")",
"{",
"var",
"patternName",
";",
"var",
"state",
"=",
"e",
".",
"state",
";",
"if",
"(",
"state",
"===",
"null",
")",
"{",
"this",
".",
"skipBack",
"=",
"false",
";",
"return",
";",
"}",
"else",
"if",
"(",
"state",
"!==",
"null",
")",
"{",
"patternName",
"=",
"state",
".",
"pattern",
";",
"}",
"var",
"iFramePath",
"=",
"\"\"",
";",
"iFramePath",
"=",
"this",
".",
"getFileName",
"(",
"patternName",
")",
";",
"if",
"(",
"iFramePath",
"===",
"\"\"",
")",
"{",
"iFramePath",
"=",
"\"styleguide/html/styleguide.html\"",
";",
"}",
"var",
"obj",
"=",
"JSON",
".",
"stringify",
"(",
"{",
"\"event\"",
":",
"\"patternLab.updatePath\"",
",",
"\"path\"",
":",
"iFramePath",
"}",
")",
";",
"document",
".",
"querySelector",
"(",
"'.pl-js-iframe'",
")",
".",
"contentWindow",
".",
"postMessage",
"(",
"obj",
",",
"urlHandler",
".",
"targetOrigin",
")",
";",
"document",
".",
"getElementById",
"(",
"\"title\"",
")",
".",
"innerHTML",
"=",
"\"Pattern Lab - \"",
"+",
"patternName",
";",
"document",
".",
"querySelector",
"(",
"'.pl-js-open-new-window'",
")",
".",
"setAttribute",
"(",
"\"href\"",
",",
"urlHandler",
".",
"getFileName",
"(",
"patternName",
")",
")",
";",
"}"
] | based on a click forward or backward modify the url and iframe source
@param {Object} event info like state and properties set in pushState() | [
"based",
"on",
"a",
"click",
"forward",
"or",
"backward",
"modify",
"the",
"url",
"and",
"iframe",
"source"
] | a4d566b6bb9ed40474389168972ed1f39f042273 | https://github.com/pattern-lab/styleguidekit-assets-default/blob/a4d566b6bb9ed40474389168972ed1f39f042273/dist/styleguide/js/patternlab-viewer.js#L366-L391 | train |
|
pattern-lab/styleguidekit-assets-default | dist/styleguide/js/patternlab-viewer.js | function () {
// make sure the listener for checkpanels is set-up
Dispatcher.addListener('insertPanels', modalViewer.insert);
// add the info/code panel onclick handler
$('.pl-js-pattern-info-toggle').click(function (e) {
modalViewer.toggle();
});
// make sure the close button handles the click
$('.pl-js-modal-close-btn').on('click', function (e) {
// hide any open annotations
obj = JSON.stringify({
'event': 'patternLab.annotationsHighlightHide'
});
document.querySelector('.pl-js-iframe').contentWindow.postMessage(obj, modalViewer.targetOrigin);
// hide the viewer
modalViewer.close();
});
// see if the modal is already active, if so update attributes as appropriate
if (DataSaver.findValue('modalActive') === 'true') {
modalViewer.active = true;
$('.pl-js-pattern-info-toggle').html("Hide Pattern Info");
}
// make sure the modal viewer is not viewable, it's always hidden by default. the pageLoad event determines when it actually opens
modalViewer.hide();
// review the query strings in case there is something the modal viewer is supposed to handle by default
var queryStringVars = urlHandler.getRequestVars();
// show the modal if code view is called via query string
if ((queryStringVars.view !== undefined) && ((queryStringVars.view === 'code') || (queryStringVars.view === 'c'))) {
modalViewer.queryPattern();
}
// show the modal if the old annotations view is called via query string
if ((queryStringVars.view !== undefined) && ((queryStringVars.view === 'annotations') || (queryStringVars.view === 'a'))) {
modalViewer.queryPattern();
}
} | javascript | function () {
// make sure the listener for checkpanels is set-up
Dispatcher.addListener('insertPanels', modalViewer.insert);
// add the info/code panel onclick handler
$('.pl-js-pattern-info-toggle').click(function (e) {
modalViewer.toggle();
});
// make sure the close button handles the click
$('.pl-js-modal-close-btn').on('click', function (e) {
// hide any open annotations
obj = JSON.stringify({
'event': 'patternLab.annotationsHighlightHide'
});
document.querySelector('.pl-js-iframe').contentWindow.postMessage(obj, modalViewer.targetOrigin);
// hide the viewer
modalViewer.close();
});
// see if the modal is already active, if so update attributes as appropriate
if (DataSaver.findValue('modalActive') === 'true') {
modalViewer.active = true;
$('.pl-js-pattern-info-toggle').html("Hide Pattern Info");
}
// make sure the modal viewer is not viewable, it's always hidden by default. the pageLoad event determines when it actually opens
modalViewer.hide();
// review the query strings in case there is something the modal viewer is supposed to handle by default
var queryStringVars = urlHandler.getRequestVars();
// show the modal if code view is called via query string
if ((queryStringVars.view !== undefined) && ((queryStringVars.view === 'code') || (queryStringVars.view === 'c'))) {
modalViewer.queryPattern();
}
// show the modal if the old annotations view is called via query string
if ((queryStringVars.view !== undefined) && ((queryStringVars.view === 'annotations') || (queryStringVars.view === 'a'))) {
modalViewer.queryPattern();
}
} | [
"function",
"(",
")",
"{",
"Dispatcher",
".",
"addListener",
"(",
"'insertPanels'",
",",
"modalViewer",
".",
"insert",
")",
";",
"$",
"(",
"'.pl-js-pattern-info-toggle'",
")",
".",
"click",
"(",
"function",
"(",
"e",
")",
"{",
"modalViewer",
".",
"toggle",
"(",
")",
";",
"}",
")",
";",
"$",
"(",
"'.pl-js-modal-close-btn'",
")",
".",
"on",
"(",
"'click'",
",",
"function",
"(",
"e",
")",
"{",
"obj",
"=",
"JSON",
".",
"stringify",
"(",
"{",
"'event'",
":",
"'patternLab.annotationsHighlightHide'",
"}",
")",
";",
"document",
".",
"querySelector",
"(",
"'.pl-js-iframe'",
")",
".",
"contentWindow",
".",
"postMessage",
"(",
"obj",
",",
"modalViewer",
".",
"targetOrigin",
")",
";",
"modalViewer",
".",
"close",
"(",
")",
";",
"}",
")",
";",
"if",
"(",
"DataSaver",
".",
"findValue",
"(",
"'modalActive'",
")",
"===",
"'true'",
")",
"{",
"modalViewer",
".",
"active",
"=",
"true",
";",
"$",
"(",
"'.pl-js-pattern-info-toggle'",
")",
".",
"html",
"(",
"\"Hide Pattern Info\"",
")",
";",
"}",
"modalViewer",
".",
"hide",
"(",
")",
";",
"var",
"queryStringVars",
"=",
"urlHandler",
".",
"getRequestVars",
"(",
")",
";",
"if",
"(",
"(",
"queryStringVars",
".",
"view",
"!==",
"undefined",
")",
"&&",
"(",
"(",
"queryStringVars",
".",
"view",
"===",
"'code'",
")",
"||",
"(",
"queryStringVars",
".",
"view",
"===",
"'c'",
")",
")",
")",
"{",
"modalViewer",
".",
"queryPattern",
"(",
")",
";",
"}",
"if",
"(",
"(",
"queryStringVars",
".",
"view",
"!==",
"undefined",
")",
"&&",
"(",
"(",
"queryStringVars",
".",
"view",
"===",
"'annotations'",
")",
"||",
"(",
"queryStringVars",
".",
"view",
"===",
"'a'",
")",
")",
")",
"{",
"modalViewer",
".",
"queryPattern",
"(",
")",
";",
"}",
"}"
] | initialize the modal window | [
"initialize",
"the",
"modal",
"window"
] | a4d566b6bb9ed40474389168972ed1f39f042273 | https://github.com/pattern-lab/styleguidekit-assets-default/blob/a4d566b6bb9ed40474389168972ed1f39f042273/dist/styleguide/js/patternlab-viewer.js#L427-L473 | train |
|
pattern-lab/styleguidekit-assets-default | dist/styleguide/js/patternlab-viewer.js | function (templateRendered, patternPartial, iframePassback, switchText) {
if (iframePassback) {
// send a message to the pattern
var obj = JSON.stringify({
'event': 'patternLab.patternModalInsert',
'patternPartial': patternPartial,
'modalContent': templateRendered.outerHTML
});
document.querySelector('.pl-js-iframe').contentWindow.postMessage(obj, modalViewer.targetOrigin);
} else {
// insert the panels and open the viewer
$('.pl-js-modal-content').html(templateRendered);
modalViewer.open();
}
// update the wording unless this is a default viewall opening
if (switchText === true) {
$('.pl-js-pattern-info-toggle').html("Hide Pattern Info");
}
} | javascript | function (templateRendered, patternPartial, iframePassback, switchText) {
if (iframePassback) {
// send a message to the pattern
var obj = JSON.stringify({
'event': 'patternLab.patternModalInsert',
'patternPartial': patternPartial,
'modalContent': templateRendered.outerHTML
});
document.querySelector('.pl-js-iframe').contentWindow.postMessage(obj, modalViewer.targetOrigin);
} else {
// insert the panels and open the viewer
$('.pl-js-modal-content').html(templateRendered);
modalViewer.open();
}
// update the wording unless this is a default viewall opening
if (switchText === true) {
$('.pl-js-pattern-info-toggle').html("Hide Pattern Info");
}
} | [
"function",
"(",
"templateRendered",
",",
"patternPartial",
",",
"iframePassback",
",",
"switchText",
")",
"{",
"if",
"(",
"iframePassback",
")",
"{",
"var",
"obj",
"=",
"JSON",
".",
"stringify",
"(",
"{",
"'event'",
":",
"'patternLab.patternModalInsert'",
",",
"'patternPartial'",
":",
"patternPartial",
",",
"'modalContent'",
":",
"templateRendered",
".",
"outerHTML",
"}",
")",
";",
"document",
".",
"querySelector",
"(",
"'.pl-js-iframe'",
")",
".",
"contentWindow",
".",
"postMessage",
"(",
"obj",
",",
"modalViewer",
".",
"targetOrigin",
")",
";",
"}",
"else",
"{",
"$",
"(",
"'.pl-js-modal-content'",
")",
".",
"html",
"(",
"templateRendered",
")",
";",
"modalViewer",
".",
"open",
"(",
")",
";",
"}",
"if",
"(",
"switchText",
"===",
"true",
")",
"{",
"$",
"(",
"'.pl-js-pattern-info-toggle'",
")",
".",
"html",
"(",
"\"Hide Pattern Info\"",
")",
";",
"}",
"}"
] | insert the copy for the modal window. if it's meant to be sent back to the iframe, do that.
@param {String} the rendered template that should be inserted
@param {String} the patternPartial that the rendered template is related to
@param {Boolean} if the refresh is of a view-all view and the content should be sent back
@param {Boolean} if the text in the dropdown should be switched | [
"insert",
"the",
"copy",
"for",
"the",
"modal",
"window",
".",
"if",
"it",
"s",
"meant",
"to",
"be",
"sent",
"back",
"to",
"the",
"iframe",
"do",
"that",
"."
] | a4d566b6bb9ed40474389168972ed1f39f042273 | https://github.com/pattern-lab/styleguidekit-assets-default/blob/a4d566b6bb9ed40474389168972ed1f39f042273/dist/styleguide/js/patternlab-viewer.js#L546-L571 | train |
|
pattern-lab/styleguidekit-assets-default | dist/styleguide/js/patternlab-viewer.js | function (patternPartial, panelID) {
var els;
// turn off all of the active tabs
els = document.querySelectorAll('#pl-' + patternPartial + '-tabs .pl-js-tab-link');
for (i = 0; i < els.length; ++i) {
els[i].classList.remove('pl-is-active-tab');
}
// hide all of the panels
els = document.querySelectorAll('#pl-' + patternPartial + '-panels .pl-js-tab-panel');
for (i = 0; i < els.length; ++i) {
els[i].classList.remove('pl-is-active-tab');
}
// add active tab class
document.getElementById('pl-' + patternPartial + '-' + panelID + '-tab').classList.add('pl-is-active-tab');
// show the panel
document.getElementById('pl-' + patternPartial + '-' + panelID + '-panel').classList.add('pl-is-active-tab');
} | javascript | function (patternPartial, panelID) {
var els;
// turn off all of the active tabs
els = document.querySelectorAll('#pl-' + patternPartial + '-tabs .pl-js-tab-link');
for (i = 0; i < els.length; ++i) {
els[i].classList.remove('pl-is-active-tab');
}
// hide all of the panels
els = document.querySelectorAll('#pl-' + patternPartial + '-panels .pl-js-tab-panel');
for (i = 0; i < els.length; ++i) {
els[i].classList.remove('pl-is-active-tab');
}
// add active tab class
document.getElementById('pl-' + patternPartial + '-' + panelID + '-tab').classList.add('pl-is-active-tab');
// show the panel
document.getElementById('pl-' + patternPartial + '-' + panelID + '-panel').classList.add('pl-is-active-tab');
} | [
"function",
"(",
"patternPartial",
",",
"panelID",
")",
"{",
"var",
"els",
";",
"els",
"=",
"document",
".",
"querySelectorAll",
"(",
"'#pl-'",
"+",
"patternPartial",
"+",
"'-tabs .pl-js-tab-link'",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"els",
".",
"length",
";",
"++",
"i",
")",
"{",
"els",
"[",
"i",
"]",
".",
"classList",
".",
"remove",
"(",
"'pl-is-active-tab'",
")",
";",
"}",
"els",
"=",
"document",
".",
"querySelectorAll",
"(",
"'#pl-'",
"+",
"patternPartial",
"+",
"'-panels .pl-js-tab-panel'",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"els",
".",
"length",
";",
"++",
"i",
")",
"{",
"els",
"[",
"i",
"]",
".",
"classList",
".",
"remove",
"(",
"'pl-is-active-tab'",
")",
";",
"}",
"document",
".",
"getElementById",
"(",
"'pl-'",
"+",
"patternPartial",
"+",
"'-'",
"+",
"panelID",
"+",
"'-tab'",
")",
".",
"classList",
".",
"add",
"(",
"'pl-is-active-tab'",
")",
";",
"document",
".",
"getElementById",
"(",
"'pl-'",
"+",
"patternPartial",
"+",
"'-'",
"+",
"panelID",
"+",
"'-panel'",
")",
".",
"classList",
".",
"add",
"(",
"'pl-is-active-tab'",
")",
";",
"}"
] | Show a specific modal
@param {String} the pattern partial for the modal
@param {String} the ID of the panel to be shown | [
"Show",
"a",
"specific",
"modal"
] | a4d566b6bb9ed40474389168972ed1f39f042273 | https://github.com/pattern-lab/styleguidekit-assets-default/blob/a4d566b6bb9ed40474389168972ed1f39f042273/dist/styleguide/js/patternlab-viewer.js#L743-L765 | train |
|
pattern-lab/styleguidekit-assets-default | dist/styleguide/js/patternlab-viewer.js | function (patternData, iframePassback, switchText) {
Dispatcher.addListener('checkPanels', panelsViewer.checkPanels);
// set-up defaults
var template, templateCompiled, templateRendered, panel;
// get the base panels
var panels = Panels.get();
// evaluate panels array and create content
for (var i = 0; i < panels.length; ++i) {
panel = panels[i];
// catch pattern panel since it doesn't have a name defined by default
if (panel.name === undefined) {
panel.name = patternData.patternEngineName || patternData.patternExtension;
panel.language = patternData.patternExtension;
}
// if httpRequestReplace has not been set, use the extension. this is likely for the raw template
if (panel.httpRequestReplace === '') {
panel.httpRequestReplace = panel.httpRequestReplace + '.' + patternData.patternExtension;
}
if ((panel.templateID !== undefined) && (panel.templateID)) {
if ((panel.httpRequest !== undefined) && (panel.httpRequest)) {
// need a file and then render
var fileBase = urlHandler.getFileName(patternData.patternPartial, false);
var e = new XMLHttpRequest();
e.onload = (function (i, panels, patternData, iframeRequest) {
return function () {
prismedContent = Prism.highlight(this.responseText, Prism.languages['html']);
template = document.getElementById(panels[i].templateID);
templateCompiled = Hogan.compile(template.innerHTML);
templateRendered = templateCompiled.render({
'language': 'html',
'code': prismedContent
});
panels[i].content = templateRendered;
Dispatcher.trigger('checkPanels', [panels, patternData, iframePassback, switchText]);
};
})(i, panels, patternData, iframePassback);
e.open('GET', fileBase + panel.httpRequestReplace + '?' + (new Date()).getTime(), true);
e.send();
} else {
// vanilla render of pattern data
template = document.getElementById(panel.templateID);
templateCompiled = Hogan.compile(template.innerHTML);
templateRendered = templateCompiled.render(patternData);
panels[i].content = templateRendered;
Dispatcher.trigger('checkPanels', [panels, patternData, iframePassback, switchText]);
}
}
}
} | javascript | function (patternData, iframePassback, switchText) {
Dispatcher.addListener('checkPanels', panelsViewer.checkPanels);
// set-up defaults
var template, templateCompiled, templateRendered, panel;
// get the base panels
var panels = Panels.get();
// evaluate panels array and create content
for (var i = 0; i < panels.length; ++i) {
panel = panels[i];
// catch pattern panel since it doesn't have a name defined by default
if (panel.name === undefined) {
panel.name = patternData.patternEngineName || patternData.patternExtension;
panel.language = patternData.patternExtension;
}
// if httpRequestReplace has not been set, use the extension. this is likely for the raw template
if (panel.httpRequestReplace === '') {
panel.httpRequestReplace = panel.httpRequestReplace + '.' + patternData.patternExtension;
}
if ((panel.templateID !== undefined) && (panel.templateID)) {
if ((panel.httpRequest !== undefined) && (panel.httpRequest)) {
// need a file and then render
var fileBase = urlHandler.getFileName(patternData.patternPartial, false);
var e = new XMLHttpRequest();
e.onload = (function (i, panels, patternData, iframeRequest) {
return function () {
prismedContent = Prism.highlight(this.responseText, Prism.languages['html']);
template = document.getElementById(panels[i].templateID);
templateCompiled = Hogan.compile(template.innerHTML);
templateRendered = templateCompiled.render({
'language': 'html',
'code': prismedContent
});
panels[i].content = templateRendered;
Dispatcher.trigger('checkPanels', [panels, patternData, iframePassback, switchText]);
};
})(i, panels, patternData, iframePassback);
e.open('GET', fileBase + panel.httpRequestReplace + '?' + (new Date()).getTime(), true);
e.send();
} else {
// vanilla render of pattern data
template = document.getElementById(panel.templateID);
templateCompiled = Hogan.compile(template.innerHTML);
templateRendered = templateCompiled.render(patternData);
panels[i].content = templateRendered;
Dispatcher.trigger('checkPanels', [panels, patternData, iframePassback, switchText]);
}
}
}
} | [
"function",
"(",
"patternData",
",",
"iframePassback",
",",
"switchText",
")",
"{",
"Dispatcher",
".",
"addListener",
"(",
"'checkPanels'",
",",
"panelsViewer",
".",
"checkPanels",
")",
";",
"var",
"template",
",",
"templateCompiled",
",",
"templateRendered",
",",
"panel",
";",
"var",
"panels",
"=",
"Panels",
".",
"get",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"panels",
".",
"length",
";",
"++",
"i",
")",
"{",
"panel",
"=",
"panels",
"[",
"i",
"]",
";",
"if",
"(",
"panel",
".",
"name",
"===",
"undefined",
")",
"{",
"panel",
".",
"name",
"=",
"patternData",
".",
"patternEngineName",
"||",
"patternData",
".",
"patternExtension",
";",
"panel",
".",
"language",
"=",
"patternData",
".",
"patternExtension",
";",
"}",
"if",
"(",
"panel",
".",
"httpRequestReplace",
"===",
"''",
")",
"{",
"panel",
".",
"httpRequestReplace",
"=",
"panel",
".",
"httpRequestReplace",
"+",
"'.'",
"+",
"patternData",
".",
"patternExtension",
";",
"}",
"if",
"(",
"(",
"panel",
".",
"templateID",
"!==",
"undefined",
")",
"&&",
"(",
"panel",
".",
"templateID",
")",
")",
"{",
"if",
"(",
"(",
"panel",
".",
"httpRequest",
"!==",
"undefined",
")",
"&&",
"(",
"panel",
".",
"httpRequest",
")",
")",
"{",
"var",
"fileBase",
"=",
"urlHandler",
".",
"getFileName",
"(",
"patternData",
".",
"patternPartial",
",",
"false",
")",
";",
"var",
"e",
"=",
"new",
"XMLHttpRequest",
"(",
")",
";",
"e",
".",
"onload",
"=",
"(",
"function",
"(",
"i",
",",
"panels",
",",
"patternData",
",",
"iframeRequest",
")",
"{",
"return",
"function",
"(",
")",
"{",
"prismedContent",
"=",
"Prism",
".",
"highlight",
"(",
"this",
".",
"responseText",
",",
"Prism",
".",
"languages",
"[",
"'html'",
"]",
")",
";",
"template",
"=",
"document",
".",
"getElementById",
"(",
"panels",
"[",
"i",
"]",
".",
"templateID",
")",
";",
"templateCompiled",
"=",
"Hogan",
".",
"compile",
"(",
"template",
".",
"innerHTML",
")",
";",
"templateRendered",
"=",
"templateCompiled",
".",
"render",
"(",
"{",
"'language'",
":",
"'html'",
",",
"'code'",
":",
"prismedContent",
"}",
")",
";",
"panels",
"[",
"i",
"]",
".",
"content",
"=",
"templateRendered",
";",
"Dispatcher",
".",
"trigger",
"(",
"'checkPanels'",
",",
"[",
"panels",
",",
"patternData",
",",
"iframePassback",
",",
"switchText",
"]",
")",
";",
"}",
";",
"}",
")",
"(",
"i",
",",
"panels",
",",
"patternData",
",",
"iframePassback",
")",
";",
"e",
".",
"open",
"(",
"'GET'",
",",
"fileBase",
"+",
"panel",
".",
"httpRequestReplace",
"+",
"'?'",
"+",
"(",
"new",
"Date",
"(",
")",
")",
".",
"getTime",
"(",
")",
",",
"true",
")",
";",
"e",
".",
"send",
"(",
")",
";",
"}",
"else",
"{",
"template",
"=",
"document",
".",
"getElementById",
"(",
"panel",
".",
"templateID",
")",
";",
"templateCompiled",
"=",
"Hogan",
".",
"compile",
"(",
"template",
".",
"innerHTML",
")",
";",
"templateRendered",
"=",
"templateCompiled",
".",
"render",
"(",
"patternData",
")",
";",
"panels",
"[",
"i",
"]",
".",
"content",
"=",
"templateRendered",
";",
"Dispatcher",
".",
"trigger",
"(",
"'checkPanels'",
",",
"[",
"panels",
",",
"patternData",
",",
"iframePassback",
",",
"switchText",
"]",
")",
";",
"}",
"}",
"}",
"}"
] | Gather the panels related to the modal
@param {String} the data from the pattern
@param {Boolean} if this is going to be passed back to the styleguide | [
"Gather",
"the",
"panels",
"related",
"to",
"the",
"modal"
] | a4d566b6bb9ed40474389168972ed1f39f042273 | https://github.com/pattern-lab/styleguidekit-assets-default/blob/a4d566b6bb9ed40474389168972ed1f39f042273/dist/styleguide/js/patternlab-viewer.js#L960-L1025 | train |
|
pattern-lab/styleguidekit-assets-default | dist/styleguide/js/patternlab-viewer.js | goMedium | function goMedium() {
killDisco();
killHay();
fullMode = false;
sizeiframe(getRandom(
minViewportWidth,
config.ishViewportRange !== undefined ? parseInt(config.ishViewportRange.s[1]) : 500
));
} | javascript | function goMedium() {
killDisco();
killHay();
fullMode = false;
sizeiframe(getRandom(
minViewportWidth,
config.ishViewportRange !== undefined ? parseInt(config.ishViewportRange.s[1]) : 500
));
} | [
"function",
"goMedium",
"(",
")",
"{",
"killDisco",
"(",
")",
";",
"killHay",
"(",
")",
";",
"fullMode",
"=",
"false",
";",
"sizeiframe",
"(",
"getRandom",
"(",
"minViewportWidth",
",",
"config",
".",
"ishViewportRange",
"!==",
"undefined",
"?",
"parseInt",
"(",
"config",
".",
"ishViewportRange",
".",
"s",
"[",
"1",
"]",
")",
":",
"500",
")",
")",
";",
"}"
] | handle medium button | [
"handle",
"medium",
"button"
] | a4d566b6bb9ed40474389168972ed1f39f042273 | https://github.com/pattern-lab/styleguidekit-assets-default/blob/a4d566b6bb9ed40474389168972ed1f39f042273/dist/styleguide/js/patternlab-viewer.js#L1534-L1542 | train |
pattern-lab/styleguidekit-assets-default | dist/styleguide/js/patternlab-viewer.js | goLarge | function goLarge() {
killDisco();
killHay();
fullMode = false;
sizeiframe(getRandom(
config.ishViewportRange !== undefined ? parseInt(config.ishViewportRange.l[0]) : 800,
config.ishViewportRange !== undefined ? parseInt(config.ishViewportRange.l[1]) : 1200
));
} | javascript | function goLarge() {
killDisco();
killHay();
fullMode = false;
sizeiframe(getRandom(
config.ishViewportRange !== undefined ? parseInt(config.ishViewportRange.l[0]) : 800,
config.ishViewportRange !== undefined ? parseInt(config.ishViewportRange.l[1]) : 1200
));
} | [
"function",
"goLarge",
"(",
")",
"{",
"killDisco",
"(",
")",
";",
"killHay",
"(",
")",
";",
"fullMode",
"=",
"false",
";",
"sizeiframe",
"(",
"getRandom",
"(",
"config",
".",
"ishViewportRange",
"!==",
"undefined",
"?",
"parseInt",
"(",
"config",
".",
"ishViewportRange",
".",
"l",
"[",
"0",
"]",
")",
":",
"800",
",",
"config",
".",
"ishViewportRange",
"!==",
"undefined",
"?",
"parseInt",
"(",
"config",
".",
"ishViewportRange",
".",
"l",
"[",
"1",
"]",
")",
":",
"1200",
")",
")",
";",
"}"
] | handle large button | [
"handle",
"large",
"button"
] | a4d566b6bb9ed40474389168972ed1f39f042273 | https://github.com/pattern-lab/styleguidekit-assets-default/blob/a4d566b6bb9ed40474389168972ed1f39f042273/dist/styleguide/js/patternlab-viewer.js#L1555-L1563 | train |
pattern-lab/styleguidekit-assets-default | dist/styleguide/js/patternlab-viewer.js | killHay | function killHay() {
var currentWidth = $sgIframe.width();
hayMode = false;
$sgIframe.removeClass('hay-mode');
$('.pl-js-vp-iframe-container').removeClass('hay-mode');
sizeiframe(Math.floor(currentWidth));
} | javascript | function killHay() {
var currentWidth = $sgIframe.width();
hayMode = false;
$sgIframe.removeClass('hay-mode');
$('.pl-js-vp-iframe-container').removeClass('hay-mode');
sizeiframe(Math.floor(currentWidth));
} | [
"function",
"killHay",
"(",
")",
"{",
"var",
"currentWidth",
"=",
"$sgIframe",
".",
"width",
"(",
")",
";",
"hayMode",
"=",
"false",
";",
"$sgIframe",
".",
"removeClass",
"(",
"'hay-mode'",
")",
";",
"$",
"(",
"'.pl-js-vp-iframe-container'",
")",
".",
"removeClass",
"(",
"'hay-mode'",
")",
";",
"sizeiframe",
"(",
"Math",
".",
"floor",
"(",
"currentWidth",
")",
")",
";",
"}"
] | Stop Hay! Mode | [
"Stop",
"Hay!",
"Mode"
] | a4d566b6bb9ed40474389168972ed1f39f042273 | https://github.com/pattern-lab/styleguidekit-assets-default/blob/a4d566b6bb9ed40474389168972ed1f39f042273/dist/styleguide/js/patternlab-viewer.js#L1644-L1650 | train |
pattern-lab/styleguidekit-assets-default | dist/styleguide/js/patternlab-viewer.js | startHay | function startHay() {
hayMode = true;
$('.pl-js-vp-iframe-container').removeClass("vp-animate").width(minViewportWidth + viewportResizeHandleWidth);
$sgIframe.removeClass("vp-animate").width(minViewportWidth);
var timeoutID = window.setTimeout(function () {
$('.pl-js-vp-iframe-container').addClass('hay-mode').width(maxViewportWidth + viewportResizeHandleWidth);
$sgIframe.addClass('hay-mode').width(maxViewportWidth);
setInterval(function () {
var vpSize = $sgIframe.width();
updateSizeReading(vpSize);
}, 100);
}, 200);
} | javascript | function startHay() {
hayMode = true;
$('.pl-js-vp-iframe-container').removeClass("vp-animate").width(minViewportWidth + viewportResizeHandleWidth);
$sgIframe.removeClass("vp-animate").width(minViewportWidth);
var timeoutID = window.setTimeout(function () {
$('.pl-js-vp-iframe-container').addClass('hay-mode').width(maxViewportWidth + viewportResizeHandleWidth);
$sgIframe.addClass('hay-mode').width(maxViewportWidth);
setInterval(function () {
var vpSize = $sgIframe.width();
updateSizeReading(vpSize);
}, 100);
}, 200);
} | [
"function",
"startHay",
"(",
")",
"{",
"hayMode",
"=",
"true",
";",
"$",
"(",
"'.pl-js-vp-iframe-container'",
")",
".",
"removeClass",
"(",
"\"vp-animate\"",
")",
".",
"width",
"(",
"minViewportWidth",
"+",
"viewportResizeHandleWidth",
")",
";",
"$sgIframe",
".",
"removeClass",
"(",
"\"vp-animate\"",
")",
".",
"width",
"(",
"minViewportWidth",
")",
";",
"var",
"timeoutID",
"=",
"window",
".",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"$",
"(",
"'.pl-js-vp-iframe-container'",
")",
".",
"addClass",
"(",
"'hay-mode'",
")",
".",
"width",
"(",
"maxViewportWidth",
"+",
"viewportResizeHandleWidth",
")",
";",
"$sgIframe",
".",
"addClass",
"(",
"'hay-mode'",
")",
".",
"width",
"(",
"maxViewportWidth",
")",
";",
"setInterval",
"(",
"function",
"(",
")",
"{",
"var",
"vpSize",
"=",
"$sgIframe",
".",
"width",
"(",
")",
";",
"updateSizeReading",
"(",
"vpSize",
")",
";",
"}",
",",
"100",
")",
";",
"}",
",",
"200",
")",
";",
"}"
] | start Hay! mode | [
"start",
"Hay!",
"mode"
] | a4d566b6bb9ed40474389168972ed1f39f042273 | https://github.com/pattern-lab/styleguidekit-assets-default/blob/a4d566b6bb9ed40474389168972ed1f39f042273/dist/styleguide/js/patternlab-viewer.js#L1653-L1667 | train |
yacut/brackets-nodejs-integration | src/require_hint_provider.js | create_hint | function create_hint(value, match, type, title, description, link) {
var $hint = $(document.createElement('span'));
$hint.addClass('brackets-js-hints brackets-js-hints-with-type-details');
$hint.attr('title', title);
if (match) {
value = value.replace(match, '');
$hint.append($(document.createElement('span')).text(match).addClass('matched-hint'));
$hint.append($(document.createElement('span')).text(value).addClass('require-hint-value'));
}
else {
$hint.append($(document.createElement('span')).text(value).addClass('require-hint-value'));
}
if (link) {
$hint.append($(document.createElement('a')).addClass('jshint-link').attr('href', link));
}
$hint.append($(document.createElement('span')).text(type).addClass('brackets-js-hints-type-details'));
$hint.append($(document.createElement('span')).text(type).addClass('jshint-description'));
if (description) {
$hint.append($(document.createElement('span')).text(description).addClass('jshint-jsdoc'));
}
return $hint;
} | javascript | function create_hint(value, match, type, title, description, link) {
var $hint = $(document.createElement('span'));
$hint.addClass('brackets-js-hints brackets-js-hints-with-type-details');
$hint.attr('title', title);
if (match) {
value = value.replace(match, '');
$hint.append($(document.createElement('span')).text(match).addClass('matched-hint'));
$hint.append($(document.createElement('span')).text(value).addClass('require-hint-value'));
}
else {
$hint.append($(document.createElement('span')).text(value).addClass('require-hint-value'));
}
if (link) {
$hint.append($(document.createElement('a')).addClass('jshint-link').attr('href', link));
}
$hint.append($(document.createElement('span')).text(type).addClass('brackets-js-hints-type-details'));
$hint.append($(document.createElement('span')).text(type).addClass('jshint-description'));
if (description) {
$hint.append($(document.createElement('span')).text(description).addClass('jshint-jsdoc'));
}
return $hint;
} | [
"function",
"create_hint",
"(",
"value",
",",
"match",
",",
"type",
",",
"title",
",",
"description",
",",
"link",
")",
"{",
"var",
"$hint",
"=",
"$",
"(",
"document",
".",
"createElement",
"(",
"'span'",
")",
")",
";",
"$hint",
".",
"addClass",
"(",
"'brackets-js-hints brackets-js-hints-with-type-details'",
")",
";",
"$hint",
".",
"attr",
"(",
"'title'",
",",
"title",
")",
";",
"if",
"(",
"match",
")",
"{",
"value",
"=",
"value",
".",
"replace",
"(",
"match",
",",
"''",
")",
";",
"$hint",
".",
"append",
"(",
"$",
"(",
"document",
".",
"createElement",
"(",
"'span'",
")",
")",
".",
"text",
"(",
"match",
")",
".",
"addClass",
"(",
"'matched-hint'",
")",
")",
";",
"$hint",
".",
"append",
"(",
"$",
"(",
"document",
".",
"createElement",
"(",
"'span'",
")",
")",
".",
"text",
"(",
"value",
")",
".",
"addClass",
"(",
"'require-hint-value'",
")",
")",
";",
"}",
"else",
"{",
"$hint",
".",
"append",
"(",
"$",
"(",
"document",
".",
"createElement",
"(",
"'span'",
")",
")",
".",
"text",
"(",
"value",
")",
".",
"addClass",
"(",
"'require-hint-value'",
")",
")",
";",
"}",
"if",
"(",
"link",
")",
"{",
"$hint",
".",
"append",
"(",
"$",
"(",
"document",
".",
"createElement",
"(",
"'a'",
")",
")",
".",
"addClass",
"(",
"'jshint-link'",
")",
".",
"attr",
"(",
"'href'",
",",
"link",
")",
")",
";",
"}",
"$hint",
".",
"append",
"(",
"$",
"(",
"document",
".",
"createElement",
"(",
"'span'",
")",
")",
".",
"text",
"(",
"type",
")",
".",
"addClass",
"(",
"'brackets-js-hints-type-details'",
")",
")",
";",
"$hint",
".",
"append",
"(",
"$",
"(",
"document",
".",
"createElement",
"(",
"'span'",
")",
")",
".",
"text",
"(",
"type",
")",
".",
"addClass",
"(",
"'jshint-description'",
")",
")",
";",
"if",
"(",
"description",
")",
"{",
"$hint",
".",
"append",
"(",
"$",
"(",
"document",
".",
"createElement",
"(",
"'span'",
")",
")",
".",
"text",
"(",
"description",
")",
".",
"addClass",
"(",
"'jshint-jsdoc'",
")",
")",
";",
"}",
"return",
"$hint",
";",
"}"
] | Create code hint link with details
@param {string} value
@param {string} match
@param {string} type
@param {string} title
@param {string} link | [
"Create",
"code",
"hint",
"link",
"with",
"details"
] | f12976f7c21d43e40b8d5ccc5f73598e8e10593a | https://github.com/yacut/brackets-nodejs-integration/blob/f12976f7c21d43e40b8d5ccc5f73598e8e10593a/src/require_hint_provider.js#L210-L232 | train |
browserstack/selenium-webdriver-nodejs | phantomjs.js | findExecutable | function findExecutable(opt_exe) {
var exe = opt_exe || io.findInPath(PHANTOMJS_EXE, true);
if (!exe) {
throw Error(
'The PhantomJS executable could not be found on the current PATH. ' +
'Please download the latest version from ' +
'http://phantomjs.org/download.html and ensure it can be found on ' +
'your PATH. For more information, see ' +
'https://github.com/ariya/phantomjs/wiki');
}
if (!fs.existsSync(exe)) {
throw Error('File does not exist: ' + exe);
}
return exe;
} | javascript | function findExecutable(opt_exe) {
var exe = opt_exe || io.findInPath(PHANTOMJS_EXE, true);
if (!exe) {
throw Error(
'The PhantomJS executable could not be found on the current PATH. ' +
'Please download the latest version from ' +
'http://phantomjs.org/download.html and ensure it can be found on ' +
'your PATH. For more information, see ' +
'https://github.com/ariya/phantomjs/wiki');
}
if (!fs.existsSync(exe)) {
throw Error('File does not exist: ' + exe);
}
return exe;
} | [
"function",
"findExecutable",
"(",
"opt_exe",
")",
"{",
"var",
"exe",
"=",
"opt_exe",
"||",
"io",
".",
"findInPath",
"(",
"PHANTOMJS_EXE",
",",
"true",
")",
";",
"if",
"(",
"!",
"exe",
")",
"{",
"throw",
"Error",
"(",
"'The PhantomJS executable could not be found on the current PATH. '",
"+",
"'Please download the latest version from '",
"+",
"'http://phantomjs.org/download.html and ensure it can be found on '",
"+",
"'your PATH. For more information, see '",
"+",
"'https://github.com/ariya/phantomjs/wiki'",
")",
";",
"}",
"if",
"(",
"!",
"fs",
".",
"existsSync",
"(",
"exe",
")",
")",
"{",
"throw",
"Error",
"(",
"'File does not exist: '",
"+",
"exe",
")",
";",
"}",
"return",
"exe",
";",
"}"
] | Finds the PhantomJS executable.
@param {string=} opt_exe Path to the executable to use.
@return {string} The located executable.
@throws {Error} If the executable cannot be found on the PATH, or if the
provided executable path does not exist. | [
"Finds",
"the",
"PhantomJS",
"executable",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/phantomjs.js#L68-L82 | train |
browserstack/selenium-webdriver-nodejs | phantomjs.js | function(opt_capabilities, opt_flow) {
var capabilities = opt_capabilities || webdriver.Capabilities.phantomjs();
var exe = findExecutable(capabilities.get(BINARY_PATH_CAPABILITY));
var args = ['--webdriver-logfile=' + DEFAULT_LOG_FILE];
var logPrefs = capabilities.get(webdriver.Capability.LOGGING_PREFS);
if (logPrefs instanceof webdriver.logging.Preferences) {
logPrefs = logPrefs.toJSON();
}
if (logPrefs && logPrefs[webdriver.logging.Type.DRIVER]) {
var level = WEBDRIVER_TO_PHANTOMJS_LEVEL[
logPrefs[webdriver.logging.Type.DRIVER]];
if (level) {
args.push('--webdriver-loglevel=' + level);
}
}
var proxy = capabilities.get(webdriver.Capability.PROXY);
if (proxy) {
switch (proxy.proxyType) {
case 'manual':
if (proxy.httpProxy) {
args.push(
'--proxy-type=http',
'--proxy=http://' + proxy.httpProxy);
}
break;
case 'pac':
throw Error('PhantomJS does not support Proxy PAC files');
case 'system':
args.push('--proxy-type=system');
break;
case 'direct':
args.push('--proxy-type=none');
break;
}
}
args = args.concat(capabilities.get(CLI_ARGS_CAPABILITY) || []);
var port = portprober.findFreePort();
var service = new remote.DriverService(exe, {
port: port,
args: webdriver.promise.when(port, function(port) {
args.push('--webdriver=' + port);
return args;
})
});
var executor = executors.createExecutor(service.start());
var driver = webdriver.WebDriver.createSession(
executor, capabilities, opt_flow);
webdriver.WebDriver.call(
this, driver.getSession(), executor, driver.controlFlow());
var boundQuit = this.quit.bind(this);
/** @override */
this.quit = function() {
return boundQuit().thenFinally(service.kill.bind(service));
};
return driver;
} | javascript | function(opt_capabilities, opt_flow) {
var capabilities = opt_capabilities || webdriver.Capabilities.phantomjs();
var exe = findExecutable(capabilities.get(BINARY_PATH_CAPABILITY));
var args = ['--webdriver-logfile=' + DEFAULT_LOG_FILE];
var logPrefs = capabilities.get(webdriver.Capability.LOGGING_PREFS);
if (logPrefs instanceof webdriver.logging.Preferences) {
logPrefs = logPrefs.toJSON();
}
if (logPrefs && logPrefs[webdriver.logging.Type.DRIVER]) {
var level = WEBDRIVER_TO_PHANTOMJS_LEVEL[
logPrefs[webdriver.logging.Type.DRIVER]];
if (level) {
args.push('--webdriver-loglevel=' + level);
}
}
var proxy = capabilities.get(webdriver.Capability.PROXY);
if (proxy) {
switch (proxy.proxyType) {
case 'manual':
if (proxy.httpProxy) {
args.push(
'--proxy-type=http',
'--proxy=http://' + proxy.httpProxy);
}
break;
case 'pac':
throw Error('PhantomJS does not support Proxy PAC files');
case 'system':
args.push('--proxy-type=system');
break;
case 'direct':
args.push('--proxy-type=none');
break;
}
}
args = args.concat(capabilities.get(CLI_ARGS_CAPABILITY) || []);
var port = portprober.findFreePort();
var service = new remote.DriverService(exe, {
port: port,
args: webdriver.promise.when(port, function(port) {
args.push('--webdriver=' + port);
return args;
})
});
var executor = executors.createExecutor(service.start());
var driver = webdriver.WebDriver.createSession(
executor, capabilities, opt_flow);
webdriver.WebDriver.call(
this, driver.getSession(), executor, driver.controlFlow());
var boundQuit = this.quit.bind(this);
/** @override */
this.quit = function() {
return boundQuit().thenFinally(service.kill.bind(service));
};
return driver;
} | [
"function",
"(",
"opt_capabilities",
",",
"opt_flow",
")",
"{",
"var",
"capabilities",
"=",
"opt_capabilities",
"||",
"webdriver",
".",
"Capabilities",
".",
"phantomjs",
"(",
")",
";",
"var",
"exe",
"=",
"findExecutable",
"(",
"capabilities",
".",
"get",
"(",
"BINARY_PATH_CAPABILITY",
")",
")",
";",
"var",
"args",
"=",
"[",
"'--webdriver-logfile='",
"+",
"DEFAULT_LOG_FILE",
"]",
";",
"var",
"logPrefs",
"=",
"capabilities",
".",
"get",
"(",
"webdriver",
".",
"Capability",
".",
"LOGGING_PREFS",
")",
";",
"if",
"(",
"logPrefs",
"instanceof",
"webdriver",
".",
"logging",
".",
"Preferences",
")",
"{",
"logPrefs",
"=",
"logPrefs",
".",
"toJSON",
"(",
")",
";",
"}",
"if",
"(",
"logPrefs",
"&&",
"logPrefs",
"[",
"webdriver",
".",
"logging",
".",
"Type",
".",
"DRIVER",
"]",
")",
"{",
"var",
"level",
"=",
"WEBDRIVER_TO_PHANTOMJS_LEVEL",
"[",
"logPrefs",
"[",
"webdriver",
".",
"logging",
".",
"Type",
".",
"DRIVER",
"]",
"]",
";",
"if",
"(",
"level",
")",
"{",
"args",
".",
"push",
"(",
"'--webdriver-loglevel='",
"+",
"level",
")",
";",
"}",
"}",
"var",
"proxy",
"=",
"capabilities",
".",
"get",
"(",
"webdriver",
".",
"Capability",
".",
"PROXY",
")",
";",
"if",
"(",
"proxy",
")",
"{",
"switch",
"(",
"proxy",
".",
"proxyType",
")",
"{",
"case",
"'manual'",
":",
"if",
"(",
"proxy",
".",
"httpProxy",
")",
"{",
"args",
".",
"push",
"(",
"'--proxy-type=http'",
",",
"'--proxy=http://'",
"+",
"proxy",
".",
"httpProxy",
")",
";",
"}",
"break",
";",
"case",
"'pac'",
":",
"throw",
"Error",
"(",
"'PhantomJS does not support Proxy PAC files'",
")",
";",
"case",
"'system'",
":",
"args",
".",
"push",
"(",
"'--proxy-type=system'",
")",
";",
"break",
";",
"case",
"'direct'",
":",
"args",
".",
"push",
"(",
"'--proxy-type=none'",
")",
";",
"break",
";",
"}",
"}",
"args",
"=",
"args",
".",
"concat",
"(",
"capabilities",
".",
"get",
"(",
"CLI_ARGS_CAPABILITY",
")",
"||",
"[",
"]",
")",
";",
"var",
"port",
"=",
"portprober",
".",
"findFreePort",
"(",
")",
";",
"var",
"service",
"=",
"new",
"remote",
".",
"DriverService",
"(",
"exe",
",",
"{",
"port",
":",
"port",
",",
"args",
":",
"webdriver",
".",
"promise",
".",
"when",
"(",
"port",
",",
"function",
"(",
"port",
")",
"{",
"args",
".",
"push",
"(",
"'--webdriver='",
"+",
"port",
")",
";",
"return",
"args",
";",
"}",
")",
"}",
")",
";",
"var",
"executor",
"=",
"executors",
".",
"createExecutor",
"(",
"service",
".",
"start",
"(",
")",
")",
";",
"var",
"driver",
"=",
"webdriver",
".",
"WebDriver",
".",
"createSession",
"(",
"executor",
",",
"capabilities",
",",
"opt_flow",
")",
";",
"webdriver",
".",
"WebDriver",
".",
"call",
"(",
"this",
",",
"driver",
".",
"getSession",
"(",
")",
",",
"executor",
",",
"driver",
".",
"controlFlow",
"(",
")",
")",
";",
"var",
"boundQuit",
"=",
"this",
".",
"quit",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"quit",
"=",
"function",
"(",
")",
"{",
"return",
"boundQuit",
"(",
")",
".",
"thenFinally",
"(",
"service",
".",
"kill",
".",
"bind",
"(",
"service",
")",
")",
";",
"}",
";",
"return",
"driver",
";",
"}"
] | Creates a new WebDriver client for PhantomJS.
@param {webdriver.Capabilities=} opt_capabilities The desired capabilities.
@param {webdriver.promise.ControlFlow=} opt_flow The control flow to use, or
{@code null} to use the currently active flow.
@constructor
@extends {webdriver.WebDriver} | [
"Creates",
"a",
"new",
"WebDriver",
"client",
"for",
"PhantomJS",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/phantomjs.js#L123-L186 | train |
|
browserstack/selenium-webdriver-nodejs | firefox/index.js | function(opt_config, opt_flow) {
var caps;
if (opt_config instanceof Options) {
caps = opt_config.toCapabilities();
} else {
caps = new webdriver.Capabilities(opt_config);
}
var binary = caps.get('firefox_binary') || new Binary();
if (typeof binary === 'string') {
binary = new Binary(binary);
}
var profile = caps.get('firefox_profile') || new Profile();
caps.set('firefox_binary', null);
caps.set('firefox_profile', null);
var serverUrl = portprober.findFreePort().then(function(port) {
var prepareProfile;
if (typeof profile === 'string') {
prepareProfile = decodeProfile(profile).then(function(dir) {
var profile = new Profile(dir);
profile.setPreference('webdriver_firefox_port', port);
return profile.writeToDisk();
});
} else {
profile.setPreference('webdriver_firefox_port', port);
prepareProfile = profile.writeToDisk();
}
return prepareProfile.then(function(dir) {
return binary.launch(dir);
}).then(function() {
var serverUrl = url.format({
protocol: 'http',
hostname: net.getLoopbackAddress(),
port: port,
pathname: '/hub'
});
return httpUtil.waitForServer(serverUrl, 45 * 1000).then(function() {
return serverUrl;
});
});
});
var executor = executors.createExecutor(serverUrl);
var driver = webdriver.WebDriver.createSession(executor, caps, opt_flow);
webdriver.WebDriver.call(this, driver.getSession(), executor, opt_flow);
} | javascript | function(opt_config, opt_flow) {
var caps;
if (opt_config instanceof Options) {
caps = opt_config.toCapabilities();
} else {
caps = new webdriver.Capabilities(opt_config);
}
var binary = caps.get('firefox_binary') || new Binary();
if (typeof binary === 'string') {
binary = new Binary(binary);
}
var profile = caps.get('firefox_profile') || new Profile();
caps.set('firefox_binary', null);
caps.set('firefox_profile', null);
var serverUrl = portprober.findFreePort().then(function(port) {
var prepareProfile;
if (typeof profile === 'string') {
prepareProfile = decodeProfile(profile).then(function(dir) {
var profile = new Profile(dir);
profile.setPreference('webdriver_firefox_port', port);
return profile.writeToDisk();
});
} else {
profile.setPreference('webdriver_firefox_port', port);
prepareProfile = profile.writeToDisk();
}
return prepareProfile.then(function(dir) {
return binary.launch(dir);
}).then(function() {
var serverUrl = url.format({
protocol: 'http',
hostname: net.getLoopbackAddress(),
port: port,
pathname: '/hub'
});
return httpUtil.waitForServer(serverUrl, 45 * 1000).then(function() {
return serverUrl;
});
});
});
var executor = executors.createExecutor(serverUrl);
var driver = webdriver.WebDriver.createSession(executor, caps, opt_flow);
webdriver.WebDriver.call(this, driver.getSession(), executor, opt_flow);
} | [
"function",
"(",
"opt_config",
",",
"opt_flow",
")",
"{",
"var",
"caps",
";",
"if",
"(",
"opt_config",
"instanceof",
"Options",
")",
"{",
"caps",
"=",
"opt_config",
".",
"toCapabilities",
"(",
")",
";",
"}",
"else",
"{",
"caps",
"=",
"new",
"webdriver",
".",
"Capabilities",
"(",
"opt_config",
")",
";",
"}",
"var",
"binary",
"=",
"caps",
".",
"get",
"(",
"'firefox_binary'",
")",
"||",
"new",
"Binary",
"(",
")",
";",
"if",
"(",
"typeof",
"binary",
"===",
"'string'",
")",
"{",
"binary",
"=",
"new",
"Binary",
"(",
"binary",
")",
";",
"}",
"var",
"profile",
"=",
"caps",
".",
"get",
"(",
"'firefox_profile'",
")",
"||",
"new",
"Profile",
"(",
")",
";",
"caps",
".",
"set",
"(",
"'firefox_binary'",
",",
"null",
")",
";",
"caps",
".",
"set",
"(",
"'firefox_profile'",
",",
"null",
")",
";",
"var",
"serverUrl",
"=",
"portprober",
".",
"findFreePort",
"(",
")",
".",
"then",
"(",
"function",
"(",
"port",
")",
"{",
"var",
"prepareProfile",
";",
"if",
"(",
"typeof",
"profile",
"===",
"'string'",
")",
"{",
"prepareProfile",
"=",
"decodeProfile",
"(",
"profile",
")",
".",
"then",
"(",
"function",
"(",
"dir",
")",
"{",
"var",
"profile",
"=",
"new",
"Profile",
"(",
"dir",
")",
";",
"profile",
".",
"setPreference",
"(",
"'webdriver_firefox_port'",
",",
"port",
")",
";",
"return",
"profile",
".",
"writeToDisk",
"(",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"profile",
".",
"setPreference",
"(",
"'webdriver_firefox_port'",
",",
"port",
")",
";",
"prepareProfile",
"=",
"profile",
".",
"writeToDisk",
"(",
")",
";",
"}",
"return",
"prepareProfile",
".",
"then",
"(",
"function",
"(",
"dir",
")",
"{",
"return",
"binary",
".",
"launch",
"(",
"dir",
")",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"var",
"serverUrl",
"=",
"url",
".",
"format",
"(",
"{",
"protocol",
":",
"'http'",
",",
"hostname",
":",
"net",
".",
"getLoopbackAddress",
"(",
")",
",",
"port",
":",
"port",
",",
"pathname",
":",
"'/hub'",
"}",
")",
";",
"return",
"httpUtil",
".",
"waitForServer",
"(",
"serverUrl",
",",
"45",
"*",
"1000",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"serverUrl",
";",
"}",
")",
";",
"}",
")",
";",
"}",
")",
";",
"var",
"executor",
"=",
"executors",
".",
"createExecutor",
"(",
"serverUrl",
")",
";",
"var",
"driver",
"=",
"webdriver",
".",
"WebDriver",
".",
"createSession",
"(",
"executor",
",",
"caps",
",",
"opt_flow",
")",
";",
"webdriver",
".",
"WebDriver",
".",
"call",
"(",
"this",
",",
"driver",
".",
"getSession",
"(",
")",
",",
"executor",
",",
"opt_flow",
")",
";",
"}"
] | A WebDriver client for Firefox.
@param {(Options|webdriver.Capabilities|Object)=} opt_config The
configuration options for this driver, specified as either an
{@link Options} or {@link webdriver.Capabilities}, or as a raw hash
object.
@param {webdriver.promise.ControlFlow=} opt_flow The flow to
schedule commands through. Defaults to the active flow object.
@constructor
@extends {webdriver.WebDriver} | [
"A",
"WebDriver",
"client",
"for",
"Firefox",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/firefox/index.js#L141-L192 | train |
|
browserstack/selenium-webdriver-nodejs | remote/index.js | DriverService | function DriverService(executable, options) {
/** @private {string} */
this.executable_ = executable;
/** @private {boolean} */
this.loopbackOnly_ = !!options.loopback;
/** @private {(number|!webdriver.promise.Promise.<number>)} */
this.port_ = options.port;
/**
* @private {!(Array.<string>|webdriver.promise.Promise.<!Array.<string>>)}
*/
this.args_ = options.args;
/** @private {string} */
this.path_ = options.path || '/';
/** @private {!Object.<string, string>} */
this.env_ = options.env || process.env;
/** @private {(string|!Array.<string|number|!Stream|null|undefined>)} */
this.stdio_ = options.stdio || 'ignore';
/**
* A promise for the managed subprocess, or null if the server has not been
* started yet. This promise will never be rejected.
* @private {promise.Promise.<!exec.Command>}
*/
this.command_ = null;
/**
* Promise that resolves to the server's address or null if the server has
* not been started. This promise will be rejected if the server terminates
* before it starts accepting WebDriver requests.
* @private {promise.Promise.<string>}
*/
this.address_ = null;
} | javascript | function DriverService(executable, options) {
/** @private {string} */
this.executable_ = executable;
/** @private {boolean} */
this.loopbackOnly_ = !!options.loopback;
/** @private {(number|!webdriver.promise.Promise.<number>)} */
this.port_ = options.port;
/**
* @private {!(Array.<string>|webdriver.promise.Promise.<!Array.<string>>)}
*/
this.args_ = options.args;
/** @private {string} */
this.path_ = options.path || '/';
/** @private {!Object.<string, string>} */
this.env_ = options.env || process.env;
/** @private {(string|!Array.<string|number|!Stream|null|undefined>)} */
this.stdio_ = options.stdio || 'ignore';
/**
* A promise for the managed subprocess, or null if the server has not been
* started yet. This promise will never be rejected.
* @private {promise.Promise.<!exec.Command>}
*/
this.command_ = null;
/**
* Promise that resolves to the server's address or null if the server has
* not been started. This promise will be rejected if the server terminates
* before it starts accepting WebDriver requests.
* @private {promise.Promise.<string>}
*/
this.address_ = null;
} | [
"function",
"DriverService",
"(",
"executable",
",",
"options",
")",
"{",
"this",
".",
"executable_",
"=",
"executable",
";",
"this",
".",
"loopbackOnly_",
"=",
"!",
"!",
"options",
".",
"loopback",
";",
"this",
".",
"port_",
"=",
"options",
".",
"port",
";",
"this",
".",
"args_",
"=",
"options",
".",
"args",
";",
"this",
".",
"path_",
"=",
"options",
".",
"path",
"||",
"'/'",
";",
"this",
".",
"env_",
"=",
"options",
".",
"env",
"||",
"process",
".",
"env",
";",
"this",
".",
"stdio_",
"=",
"options",
".",
"stdio",
"||",
"'ignore'",
";",
"this",
".",
"command_",
"=",
"null",
";",
"this",
".",
"address_",
"=",
"null",
";",
"}"
] | Manages the life and death of a native executable WebDriver server.
<p>It is expected that the driver server implements the
<a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol">WebDriver
Wire Protocol</a>. Furthermore, the managed server should support multiple
concurrent sessions, so that this class may be reused for multiple clients.
@param {string} executable Path to the executable to run.
@param {!ServiceOptions} options Configuration options for the service.
@constructor | [
"Manages",
"the",
"life",
"and",
"death",
"of",
"a",
"native",
"executable",
"WebDriver",
"server",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/remote/index.js#L73-L112 | train |
browserstack/selenium-webdriver-nodejs | firefox/binary.js | defaultWindowsLocation | function defaultWindowsLocation() {
var files = [
process.env['PROGRAMFILES'] || 'C:\\Program Files',
process.env['PROGRAMFILES(X86)'] || 'C:\\Program Files (x86)'
].map(function(prefix) {
return path.join(prefix, 'Mozilla Firefox\\firefox.exe');
});
return io.exists(files[0]).then(function(exists) {
return exists ? files[0] : io.exists(files[1]).then(function(exists) {
return exists ? files[1] : null;
});
});
} | javascript | function defaultWindowsLocation() {
var files = [
process.env['PROGRAMFILES'] || 'C:\\Program Files',
process.env['PROGRAMFILES(X86)'] || 'C:\\Program Files (x86)'
].map(function(prefix) {
return path.join(prefix, 'Mozilla Firefox\\firefox.exe');
});
return io.exists(files[0]).then(function(exists) {
return exists ? files[0] : io.exists(files[1]).then(function(exists) {
return exists ? files[1] : null;
});
});
} | [
"function",
"defaultWindowsLocation",
"(",
")",
"{",
"var",
"files",
"=",
"[",
"process",
".",
"env",
"[",
"'PROGRAMFILES'",
"]",
"||",
"'C:\\\\Program Files'",
",",
"\\\\",
"]",
".",
"process",
".",
"env",
"[",
"'PROGRAMFILES(X86)'",
"]",
"||",
"'C:\\\\Program Files (x86)'",
"\\\\",
";",
"map",
"}"
] | Checks the default Windows Firefox locations in Program Files.
@return {!promise.Promise.<?string>} A promise for the located executable.
The promise will resolve to {@code null} if Fireox was not found. | [
"Checks",
"the",
"default",
"Windows",
"Firefox",
"locations",
"in",
"Program",
"Files",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/firefox/binary.js#L50-L62 | train |
browserstack/selenium-webdriver-nodejs | firefox/binary.js | findFirefox | function findFirefox() {
if (foundBinary) {
return foundBinary;
}
if (process.platform === 'darwin') {
var osxExe = '/Applications/Firefox.app/Contents/MacOS/firefox-bin';
foundBinary = io.exists(osxExe).then(function(exists) {
return exists ? osxExe : null;
});
} else if (process.platform === 'win32') {
foundBinary = defaultWindowsLocation();
} else {
foundBinary = promise.fulfilled(io.findInPath('firefox'));
}
return foundBinary = foundBinary.then(function(found) {
if (found) {
return found;
}
throw Error('Could not locate Firefox on the current system');
});
} | javascript | function findFirefox() {
if (foundBinary) {
return foundBinary;
}
if (process.platform === 'darwin') {
var osxExe = '/Applications/Firefox.app/Contents/MacOS/firefox-bin';
foundBinary = io.exists(osxExe).then(function(exists) {
return exists ? osxExe : null;
});
} else if (process.platform === 'win32') {
foundBinary = defaultWindowsLocation();
} else {
foundBinary = promise.fulfilled(io.findInPath('firefox'));
}
return foundBinary = foundBinary.then(function(found) {
if (found) {
return found;
}
throw Error('Could not locate Firefox on the current system');
});
} | [
"function",
"findFirefox",
"(",
")",
"{",
"if",
"(",
"foundBinary",
")",
"{",
"return",
"foundBinary",
";",
"}",
"if",
"(",
"process",
".",
"platform",
"===",
"'darwin'",
")",
"{",
"var",
"osxExe",
"=",
"'/Applications/Firefox.app/Contents/MacOS/firefox-bin'",
";",
"foundBinary",
"=",
"io",
".",
"exists",
"(",
"osxExe",
")",
".",
"then",
"(",
"function",
"(",
"exists",
")",
"{",
"return",
"exists",
"?",
"osxExe",
":",
"null",
";",
"}",
")",
";",
"}",
"else",
"if",
"(",
"process",
".",
"platform",
"===",
"'win32'",
")",
"{",
"foundBinary",
"=",
"defaultWindowsLocation",
"(",
")",
";",
"}",
"else",
"{",
"foundBinary",
"=",
"promise",
".",
"fulfilled",
"(",
"io",
".",
"findInPath",
"(",
"'firefox'",
")",
")",
";",
"}",
"return",
"foundBinary",
"=",
"foundBinary",
".",
"then",
"(",
"function",
"(",
"found",
")",
"{",
"if",
"(",
"found",
")",
"{",
"return",
"found",
";",
"}",
"throw",
"Error",
"(",
"'Could not locate Firefox on the current system'",
")",
";",
"}",
")",
";",
"}"
] | Locates the Firefox binary for the current system.
@return {!promise.Promise.<string>} A promise for the located binary. The
promise will be rejected if Firefox cannot be located. | [
"Locates",
"the",
"Firefox",
"binary",
"for",
"the",
"current",
"system",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/firefox/binary.js#L70-L92 | train |
browserstack/selenium-webdriver-nodejs | firefox/binary.js | installNoFocusLibs | function installNoFocusLibs(profileDir) {
var x86 = path.join(profileDir, 'x86');
var amd64 = path.join(profileDir, 'amd64');
return mkdir(x86)
.then(copyLib.bind(null, NO_FOCUS_LIB_X86, x86))
.then(mkdir.bind(null, amd64))
.then(copyLib.bind(null, NO_FOCUS_LIB_AMD64, amd64))
.then(function() {
return x86 + ':' + amd64;
});
function mkdir(dir) {
return io.exists(dir).then(function(exists) {
if (!exists) {
return promise.checkedNodeCall(fs.mkdir, dir);
}
});
}
function copyLib(src, dir) {
return io.copy(src, path.join(dir, X_IGNORE_NO_FOCUS_LIB));
}
} | javascript | function installNoFocusLibs(profileDir) {
var x86 = path.join(profileDir, 'x86');
var amd64 = path.join(profileDir, 'amd64');
return mkdir(x86)
.then(copyLib.bind(null, NO_FOCUS_LIB_X86, x86))
.then(mkdir.bind(null, amd64))
.then(copyLib.bind(null, NO_FOCUS_LIB_AMD64, amd64))
.then(function() {
return x86 + ':' + amd64;
});
function mkdir(dir) {
return io.exists(dir).then(function(exists) {
if (!exists) {
return promise.checkedNodeCall(fs.mkdir, dir);
}
});
}
function copyLib(src, dir) {
return io.copy(src, path.join(dir, X_IGNORE_NO_FOCUS_LIB));
}
} | [
"function",
"installNoFocusLibs",
"(",
"profileDir",
")",
"{",
"var",
"x86",
"=",
"path",
".",
"join",
"(",
"profileDir",
",",
"'x86'",
")",
";",
"var",
"amd64",
"=",
"path",
".",
"join",
"(",
"profileDir",
",",
"'amd64'",
")",
";",
"return",
"mkdir",
"(",
"x86",
")",
".",
"then",
"(",
"copyLib",
".",
"bind",
"(",
"null",
",",
"NO_FOCUS_LIB_X86",
",",
"x86",
")",
")",
".",
"then",
"(",
"mkdir",
".",
"bind",
"(",
"null",
",",
"amd64",
")",
")",
".",
"then",
"(",
"copyLib",
".",
"bind",
"(",
"null",
",",
"NO_FOCUS_LIB_AMD64",
",",
"amd64",
")",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"x86",
"+",
"':'",
"+",
"amd64",
";",
"}",
")",
";",
"function",
"mkdir",
"(",
"dir",
")",
"{",
"return",
"io",
".",
"exists",
"(",
"dir",
")",
".",
"then",
"(",
"function",
"(",
"exists",
")",
"{",
"if",
"(",
"!",
"exists",
")",
"{",
"return",
"promise",
".",
"checkedNodeCall",
"(",
"fs",
".",
"mkdir",
",",
"dir",
")",
";",
"}",
"}",
")",
";",
"}",
"function",
"copyLib",
"(",
"src",
",",
"dir",
")",
"{",
"return",
"io",
".",
"copy",
"(",
"src",
",",
"path",
".",
"join",
"(",
"dir",
",",
"X_IGNORE_NO_FOCUS_LIB",
")",
")",
";",
"}",
"}"
] | Copies the no focus libs into the given profile directory.
@param {string} profileDir Path to the profile directory to install into.
@return {!promise.Promise.<string>} The LD_LIBRARY_PATH prefix string to use
for the installed libs. | [
"Copies",
"the",
"no",
"focus",
"libs",
"into",
"the",
"given",
"profile",
"directory",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/firefox/binary.js#L101-L124 | train |
browserstack/selenium-webdriver-nodejs | firefox/binary.js | function(opt_exe) {
/** @private {(string|undefined)} */
this.exe_ = opt_exe;
/** @private {!Array.<string>} */
this.args_ = [];
/** @private {!Object.<string, string>} */
this.env_ = {};
Object.keys(process.env).forEach(function(key) {
this.env_[key] = process.env[key];
}.bind(this));
this.env_['MOZ_CRASHREPORTER_DISABLE'] = '1';
this.env_['MOZ_NO_REMOTE'] = '1';
this.env_['NO_EM_RESTART'] = '1';
/** @private {promise.Promise.<!exec.Command>} */
this.command_ = null;
} | javascript | function(opt_exe) {
/** @private {(string|undefined)} */
this.exe_ = opt_exe;
/** @private {!Array.<string>} */
this.args_ = [];
/** @private {!Object.<string, string>} */
this.env_ = {};
Object.keys(process.env).forEach(function(key) {
this.env_[key] = process.env[key];
}.bind(this));
this.env_['MOZ_CRASHREPORTER_DISABLE'] = '1';
this.env_['MOZ_NO_REMOTE'] = '1';
this.env_['NO_EM_RESTART'] = '1';
/** @private {promise.Promise.<!exec.Command>} */
this.command_ = null;
} | [
"function",
"(",
"opt_exe",
")",
"{",
"this",
".",
"exe_",
"=",
"opt_exe",
";",
"this",
".",
"args_",
"=",
"[",
"]",
";",
"this",
".",
"env_",
"=",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"process",
".",
"env",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"this",
".",
"env_",
"[",
"key",
"]",
"=",
"process",
".",
"env",
"[",
"key",
"]",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"this",
".",
"env_",
"[",
"'MOZ_CRASHREPORTER_DISABLE'",
"]",
"=",
"'1'",
";",
"this",
".",
"env_",
"[",
"'MOZ_NO_REMOTE'",
"]",
"=",
"'1'",
";",
"this",
".",
"env_",
"[",
"'NO_EM_RESTART'",
"]",
"=",
"'1'",
";",
"this",
".",
"command_",
"=",
"null",
";",
"}"
] | Manages a Firefox subprocess configured for use with WebDriver.
@param {string=} opt_exe Path to the Firefox binary to use. If not
specified, will attempt to locate Firefox on the current system.
@constructor | [
"Manages",
"a",
"Firefox",
"subprocess",
"configured",
"for",
"use",
"with",
"WebDriver",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/firefox/binary.js#L155-L173 | train |
|
browserstack/selenium-webdriver-nodejs | firefox/profile.js | getDefaultPreferences | function getDefaultPreferences() {
if (!defaultPreferences) {
var contents = fs.readFileSync(WEBDRIVER_PREFERENCES_PATH, 'utf8');
defaultPreferences = JSON.parse(contents);
}
return defaultPreferences;
} | javascript | function getDefaultPreferences() {
if (!defaultPreferences) {
var contents = fs.readFileSync(WEBDRIVER_PREFERENCES_PATH, 'utf8');
defaultPreferences = JSON.parse(contents);
}
return defaultPreferences;
} | [
"function",
"getDefaultPreferences",
"(",
")",
"{",
"if",
"(",
"!",
"defaultPreferences",
")",
"{",
"var",
"contents",
"=",
"fs",
".",
"readFileSync",
"(",
"WEBDRIVER_PREFERENCES_PATH",
",",
"'utf8'",
")",
";",
"defaultPreferences",
"=",
"JSON",
".",
"parse",
"(",
"contents",
")",
";",
"}",
"return",
"defaultPreferences",
";",
"}"
] | Synchronously loads the default preferences used for the FirefoxDriver.
@return {!Object} The default preferences JSON object. | [
"Synchronously",
"loads",
"the",
"default",
"preferences",
"used",
"for",
"the",
"FirefoxDriver",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/firefox/profile.js#L52-L58 | train |
browserstack/selenium-webdriver-nodejs | firefox/profile.js | loadUserPrefs | function loadUserPrefs(f) {
var done = promise.defer();
fs.readFile(f, function(err, contents) {
if (err && err.code === 'ENOENT') {
done.fulfill({});
return;
}
if (err) {
done.reject(err);
return;
}
var prefs = {};
var context = vm.createContext({
'user_pref': function(key, value) {
prefs[key] = value;
}
});
vm.runInContext(contents, context, f);
done.fulfill(prefs);
});
return done.promise;
} | javascript | function loadUserPrefs(f) {
var done = promise.defer();
fs.readFile(f, function(err, contents) {
if (err && err.code === 'ENOENT') {
done.fulfill({});
return;
}
if (err) {
done.reject(err);
return;
}
var prefs = {};
var context = vm.createContext({
'user_pref': function(key, value) {
prefs[key] = value;
}
});
vm.runInContext(contents, context, f);
done.fulfill(prefs);
});
return done.promise;
} | [
"function",
"loadUserPrefs",
"(",
"f",
")",
"{",
"var",
"done",
"=",
"promise",
".",
"defer",
"(",
")",
";",
"fs",
".",
"readFile",
"(",
"f",
",",
"function",
"(",
"err",
",",
"contents",
")",
"{",
"if",
"(",
"err",
"&&",
"err",
".",
"code",
"===",
"'ENOENT'",
")",
"{",
"done",
".",
"fulfill",
"(",
"{",
"}",
")",
";",
"return",
";",
"}",
"if",
"(",
"err",
")",
"{",
"done",
".",
"reject",
"(",
"err",
")",
";",
"return",
";",
"}",
"var",
"prefs",
"=",
"{",
"}",
";",
"var",
"context",
"=",
"vm",
".",
"createContext",
"(",
"{",
"'user_pref'",
":",
"function",
"(",
"key",
",",
"value",
")",
"{",
"prefs",
"[",
"key",
"]",
"=",
"value",
";",
"}",
"}",
")",
";",
"vm",
".",
"runInContext",
"(",
"contents",
",",
"context",
",",
"f",
")",
";",
"done",
".",
"fulfill",
"(",
"prefs",
")",
";",
"}",
")",
";",
"return",
"done",
".",
"promise",
";",
"}"
] | Parses a user.js file in a Firefox profile directory.
@param {string} f Path to the file to parse.
@return {!promise.Promise.<!Object>} A promise for the parsed preferences as
a JSON object. If the file does not exist, an empty object will be
returned. | [
"Parses",
"a",
"user",
".",
"js",
"file",
"in",
"a",
"Firefox",
"profile",
"directory",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/firefox/profile.js#L68-L92 | train |
browserstack/selenium-webdriver-nodejs | firefox/profile.js | mixin | function mixin(a, b) {
Object.keys(b).forEach(function(key) {
a[key] = b[key];
});
} | javascript | function mixin(a, b) {
Object.keys(b).forEach(function(key) {
a[key] = b[key];
});
} | [
"function",
"mixin",
"(",
"a",
",",
"b",
")",
"{",
"Object",
".",
"keys",
"(",
"b",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"a",
"[",
"key",
"]",
"=",
"b",
"[",
"key",
"]",
";",
"}",
")",
";",
"}"
] | Copies the properties of one object into another.
@param {!Object} a The destination object.
@param {!Object} b The source object to apply as a mixin. | [
"Copies",
"the",
"properties",
"of",
"one",
"object",
"into",
"another",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/firefox/profile.js#L100-L104 | train |
browserstack/selenium-webdriver-nodejs | firefox/profile.js | installExtensions | function installExtensions(extensions, dir, opt_excludeWebDriverExt) {
var hasWebDriver = !!opt_excludeWebDriverExt;
var next = 0;
var extensionDir = path.join(dir, 'extensions');
var done = promise.defer();
return io.exists(extensionDir).then(function(exists) {
if (!exists) {
return promise.checkedNodeCall(fs.mkdir, extensionDir);
}
}).then(function() {
installNext();
return done.promise;
});
function installNext() {
if (!done.isPending()) {
return;
}
if (next >= extensions.length) {
if (hasWebDriver) {
done.fulfill(dir);
} else {
install(WEBDRIVER_EXTENSION_PATH);
}
} else {
install(extensions[next++]);
}
}
function install(ext) {
extension.install(ext, extensionDir).then(function(id) {
hasWebDriver = hasWebDriver || (id === WEBDRIVER_EXTENSION_NAME);
installNext();
}, done.reject);
}
} | javascript | function installExtensions(extensions, dir, opt_excludeWebDriverExt) {
var hasWebDriver = !!opt_excludeWebDriverExt;
var next = 0;
var extensionDir = path.join(dir, 'extensions');
var done = promise.defer();
return io.exists(extensionDir).then(function(exists) {
if (!exists) {
return promise.checkedNodeCall(fs.mkdir, extensionDir);
}
}).then(function() {
installNext();
return done.promise;
});
function installNext() {
if (!done.isPending()) {
return;
}
if (next >= extensions.length) {
if (hasWebDriver) {
done.fulfill(dir);
} else {
install(WEBDRIVER_EXTENSION_PATH);
}
} else {
install(extensions[next++]);
}
}
function install(ext) {
extension.install(ext, extensionDir).then(function(id) {
hasWebDriver = hasWebDriver || (id === WEBDRIVER_EXTENSION_NAME);
installNext();
}, done.reject);
}
} | [
"function",
"installExtensions",
"(",
"extensions",
",",
"dir",
",",
"opt_excludeWebDriverExt",
")",
"{",
"var",
"hasWebDriver",
"=",
"!",
"!",
"opt_excludeWebDriverExt",
";",
"var",
"next",
"=",
"0",
";",
"var",
"extensionDir",
"=",
"path",
".",
"join",
"(",
"dir",
",",
"'extensions'",
")",
";",
"var",
"done",
"=",
"promise",
".",
"defer",
"(",
")",
";",
"return",
"io",
".",
"exists",
"(",
"extensionDir",
")",
".",
"then",
"(",
"function",
"(",
"exists",
")",
"{",
"if",
"(",
"!",
"exists",
")",
"{",
"return",
"promise",
".",
"checkedNodeCall",
"(",
"fs",
".",
"mkdir",
",",
"extensionDir",
")",
";",
"}",
"}",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"installNext",
"(",
")",
";",
"return",
"done",
".",
"promise",
";",
"}",
")",
";",
"function",
"installNext",
"(",
")",
"{",
"if",
"(",
"!",
"done",
".",
"isPending",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"next",
">=",
"extensions",
".",
"length",
")",
"{",
"if",
"(",
"hasWebDriver",
")",
"{",
"done",
".",
"fulfill",
"(",
"dir",
")",
";",
"}",
"else",
"{",
"install",
"(",
"WEBDRIVER_EXTENSION_PATH",
")",
";",
"}",
"}",
"else",
"{",
"install",
"(",
"extensions",
"[",
"next",
"++",
"]",
")",
";",
"}",
"}",
"function",
"install",
"(",
"ext",
")",
"{",
"extension",
".",
"install",
"(",
"ext",
",",
"extensionDir",
")",
".",
"then",
"(",
"function",
"(",
"id",
")",
"{",
"hasWebDriver",
"=",
"hasWebDriver",
"||",
"(",
"id",
"===",
"WEBDRIVER_EXTENSION_NAME",
")",
";",
"installNext",
"(",
")",
";",
"}",
",",
"done",
".",
"reject",
")",
";",
"}",
"}"
] | Installs a group of extensions in the given profile directory. If the
WebDriver extension is not included in this set, the default version
bundled with this package will be installed.
@param {!Array.<string>} extensions The extensions to install, as a
path to an unpacked extension directory or a path to a xpi file.
@param {string} dir The profile directory to install to.
@param {boolean=} opt_excludeWebDriverExt Whether to skip installation of
the default WebDriver extension.
@return {!promise.Promise.<string>} A promise for the main profile directory
once all extensions have been installed. | [
"Installs",
"a",
"group",
"of",
"extensions",
"in",
"the",
"given",
"profile",
"directory",
".",
"If",
"the",
"WebDriver",
"extension",
"is",
"not",
"included",
"in",
"this",
"set",
"the",
"default",
"version",
"bundled",
"with",
"this",
"package",
"will",
"be",
"installed",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/firefox/profile.js#L147-L184 | train |
browserstack/selenium-webdriver-nodejs | firefox/profile.js | decode | function decode(data) {
return io.tmpFile().then(function(file) {
var buf = new Buffer(data, 'base64');
return promise.checkedNodeCall(fs.writeFile, file, buf).then(function() {
return io.tmpDir();
}).then(function(dir) {
var zip = new AdmZip(file);
zip.extractAllTo(dir); // Sync only? Why?? :-(
return dir;
});
});
} | javascript | function decode(data) {
return io.tmpFile().then(function(file) {
var buf = new Buffer(data, 'base64');
return promise.checkedNodeCall(fs.writeFile, file, buf).then(function() {
return io.tmpDir();
}).then(function(dir) {
var zip = new AdmZip(file);
zip.extractAllTo(dir); // Sync only? Why?? :-(
return dir;
});
});
} | [
"function",
"decode",
"(",
"data",
")",
"{",
"return",
"io",
".",
"tmpFile",
"(",
")",
".",
"then",
"(",
"function",
"(",
"file",
")",
"{",
"var",
"buf",
"=",
"new",
"Buffer",
"(",
"data",
",",
"'base64'",
")",
";",
"return",
"promise",
".",
"checkedNodeCall",
"(",
"fs",
".",
"writeFile",
",",
"file",
",",
"buf",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"io",
".",
"tmpDir",
"(",
")",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
"dir",
")",
"{",
"var",
"zip",
"=",
"new",
"AdmZip",
"(",
"file",
")",
";",
"zip",
".",
"extractAllTo",
"(",
"dir",
")",
";",
"return",
"dir",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | Decodes a base64 encoded profile.
@param {string} data The base64 encoded string.
@return {!promise.Promise.<string>} A promise for the path to the decoded
profile directory. | [
"Decodes",
"a",
"base64",
"encoded",
"profile",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/firefox/profile.js#L193-L204 | train |
browserstack/selenium-webdriver-nodejs | _base.js | Context | function Context(opt_configureForTesting) {
var closure = this.closure = vm.createContext({
console: console,
setTimeout: setTimeout,
setInterval: setInterval,
clearTimeout: clearTimeout,
clearInterval: clearInterval,
process: process,
require: require,
Buffer: Buffer,
Error: Error,
CLOSURE_BASE_PATH: path.dirname(CLOSURE_BASE_FILE_PATH) + '/',
CLOSURE_IMPORT_SCRIPT: function(src) {
loadScript(src);
return true;
},
CLOSURE_NO_DEPS: !isDevMode(),
goog: {}
});
closure.window = closure.top = closure;
if (opt_configureForTesting) {
closure.document = {
body: {},
createElement: function() { return {}; },
getElementsByTagName: function() { return []; }
};
closure.document.body.ownerDocument = closure.document;
}
loadScript(CLOSURE_BASE_FILE_PATH);
loadScript(DEPS_FILE_PATH);
/**
* Synchronously loads a script into the protected Closure context.
* @param {string} src Path to the file to load.
*/
function loadScript(src) {
src = path.normalize(src);
var contents = fs.readFileSync(src, 'utf8');
vm.runInContext(contents, closure, src);
}
} | javascript | function Context(opt_configureForTesting) {
var closure = this.closure = vm.createContext({
console: console,
setTimeout: setTimeout,
setInterval: setInterval,
clearTimeout: clearTimeout,
clearInterval: clearInterval,
process: process,
require: require,
Buffer: Buffer,
Error: Error,
CLOSURE_BASE_PATH: path.dirname(CLOSURE_BASE_FILE_PATH) + '/',
CLOSURE_IMPORT_SCRIPT: function(src) {
loadScript(src);
return true;
},
CLOSURE_NO_DEPS: !isDevMode(),
goog: {}
});
closure.window = closure.top = closure;
if (opt_configureForTesting) {
closure.document = {
body: {},
createElement: function() { return {}; },
getElementsByTagName: function() { return []; }
};
closure.document.body.ownerDocument = closure.document;
}
loadScript(CLOSURE_BASE_FILE_PATH);
loadScript(DEPS_FILE_PATH);
/**
* Synchronously loads a script into the protected Closure context.
* @param {string} src Path to the file to load.
*/
function loadScript(src) {
src = path.normalize(src);
var contents = fs.readFileSync(src, 'utf8');
vm.runInContext(contents, closure, src);
}
} | [
"function",
"Context",
"(",
"opt_configureForTesting",
")",
"{",
"var",
"closure",
"=",
"this",
".",
"closure",
"=",
"vm",
".",
"createContext",
"(",
"{",
"console",
":",
"console",
",",
"setTimeout",
":",
"setTimeout",
",",
"setInterval",
":",
"setInterval",
",",
"clearTimeout",
":",
"clearTimeout",
",",
"clearInterval",
":",
"clearInterval",
",",
"process",
":",
"process",
",",
"require",
":",
"require",
",",
"Buffer",
":",
"Buffer",
",",
"Error",
":",
"Error",
",",
"CLOSURE_BASE_PATH",
":",
"path",
".",
"dirname",
"(",
"CLOSURE_BASE_FILE_PATH",
")",
"+",
"'/'",
",",
"CLOSURE_IMPORT_SCRIPT",
":",
"function",
"(",
"src",
")",
"{",
"loadScript",
"(",
"src",
")",
";",
"return",
"true",
";",
"}",
",",
"CLOSURE_NO_DEPS",
":",
"!",
"isDevMode",
"(",
")",
",",
"goog",
":",
"{",
"}",
"}",
")",
";",
"closure",
".",
"window",
"=",
"closure",
".",
"top",
"=",
"closure",
";",
"if",
"(",
"opt_configureForTesting",
")",
"{",
"closure",
".",
"document",
"=",
"{",
"body",
":",
"{",
"}",
",",
"createElement",
":",
"function",
"(",
")",
"{",
"return",
"{",
"}",
";",
"}",
",",
"getElementsByTagName",
":",
"function",
"(",
")",
"{",
"return",
"[",
"]",
";",
"}",
"}",
";",
"closure",
".",
"document",
".",
"body",
".",
"ownerDocument",
"=",
"closure",
".",
"document",
";",
"}",
"loadScript",
"(",
"CLOSURE_BASE_FILE_PATH",
")",
";",
"loadScript",
"(",
"DEPS_FILE_PATH",
")",
";",
"function",
"loadScript",
"(",
"src",
")",
"{",
"src",
"=",
"path",
".",
"normalize",
"(",
"src",
")",
";",
"var",
"contents",
"=",
"fs",
".",
"readFileSync",
"(",
"src",
",",
"'utf8'",
")",
";",
"vm",
".",
"runInContext",
"(",
"contents",
",",
"closure",
",",
"src",
")",
";",
"}",
"}"
] | Maintains a unique context for Closure library-based code.
@param {boolean=} opt_configureForTesting Whether to configure a fake DOM
for Closure-testing code that (incorrectly) assumes a DOM is always
present.
@constructor | [
"Maintains",
"a",
"unique",
"context",
"for",
"Closure",
"library",
"-",
"based",
"code",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/_base.js#L84-L126 | train |
browserstack/selenium-webdriver-nodejs | _base.js | loadScript | function loadScript(src) {
src = path.normalize(src);
var contents = fs.readFileSync(src, 'utf8');
vm.runInContext(contents, closure, src);
} | javascript | function loadScript(src) {
src = path.normalize(src);
var contents = fs.readFileSync(src, 'utf8');
vm.runInContext(contents, closure, src);
} | [
"function",
"loadScript",
"(",
"src",
")",
"{",
"src",
"=",
"path",
".",
"normalize",
"(",
"src",
")",
";",
"var",
"contents",
"=",
"fs",
".",
"readFileSync",
"(",
"src",
",",
"'utf8'",
")",
";",
"vm",
".",
"runInContext",
"(",
"contents",
",",
"closure",
",",
"src",
")",
";",
"}"
] | Synchronously loads a script into the protected Closure context.
@param {string} src Path to the file to load. | [
"Synchronously",
"loads",
"a",
"script",
"into",
"the",
"protected",
"Closure",
"context",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/_base.js#L121-L125 | train |
browserstack/selenium-webdriver-nodejs | io/exec.js | function(result, onKill) {
/** @return {boolean} Whether this command is still running. */
this.isRunning = function() {
return result.isPending();
};
/**
* @return {!promise.Promise.<!Result>} A promise for the result of this
* command.
*/
this.result = function() {
return result;
};
/**
* Sends a signal to the underlying process.
* @param {string=} opt_signal The signal to send; defaults to
* {@code SIGTERM}.
*/
this.kill = function(opt_signal) {
onKill(opt_signal || 'SIGTERM');
};
} | javascript | function(result, onKill) {
/** @return {boolean} Whether this command is still running. */
this.isRunning = function() {
return result.isPending();
};
/**
* @return {!promise.Promise.<!Result>} A promise for the result of this
* command.
*/
this.result = function() {
return result;
};
/**
* Sends a signal to the underlying process.
* @param {string=} opt_signal The signal to send; defaults to
* {@code SIGTERM}.
*/
this.kill = function(opt_signal) {
onKill(opt_signal || 'SIGTERM');
};
} | [
"function",
"(",
"result",
",",
"onKill",
")",
"{",
"this",
".",
"isRunning",
"=",
"function",
"(",
")",
"{",
"return",
"result",
".",
"isPending",
"(",
")",
";",
"}",
";",
"this",
".",
"result",
"=",
"function",
"(",
")",
"{",
"return",
"result",
";",
"}",
";",
"this",
".",
"kill",
"=",
"function",
"(",
"opt_signal",
")",
"{",
"onKill",
"(",
"opt_signal",
"||",
"'SIGTERM'",
")",
";",
"}",
";",
"}"
] | Represents a command running in a sub-process.
@param {!promise.Promise.<!Result>} result The command result.
@constructor | [
"Represents",
"a",
"command",
"running",
"in",
"a",
"sub",
"-",
"process",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/io/exec.js#L73-L95 | train |
|
browserstack/selenium-webdriver-nodejs | lib/webdriver/promise.js | resolve | function resolve(newState, newValue) {
if (webdriver.promise.Deferred.State_.PENDING !== state) {
return;
}
if (newValue === self) {
// See promise a+, 2.3.1
// http://promises-aplus.github.io/promises-spec/#point-48
throw TypeError('A promise may not resolve to itself');
}
state = webdriver.promise.Deferred.State_.BLOCKED;
if (webdriver.promise.isPromise(newValue)) {
var onFulfill = goog.partial(notifyAll, newState);
var onReject = goog.partial(
notifyAll, webdriver.promise.Deferred.State_.REJECTED);
if (newValue instanceof webdriver.promise.Deferred) {
newValue.then(onFulfill, onReject);
} else {
webdriver.promise.asap(newValue, onFulfill, onReject);
}
} else {
notifyAll(newState, newValue);
}
} | javascript | function resolve(newState, newValue) {
if (webdriver.promise.Deferred.State_.PENDING !== state) {
return;
}
if (newValue === self) {
// See promise a+, 2.3.1
// http://promises-aplus.github.io/promises-spec/#point-48
throw TypeError('A promise may not resolve to itself');
}
state = webdriver.promise.Deferred.State_.BLOCKED;
if (webdriver.promise.isPromise(newValue)) {
var onFulfill = goog.partial(notifyAll, newState);
var onReject = goog.partial(
notifyAll, webdriver.promise.Deferred.State_.REJECTED);
if (newValue instanceof webdriver.promise.Deferred) {
newValue.then(onFulfill, onReject);
} else {
webdriver.promise.asap(newValue, onFulfill, onReject);
}
} else {
notifyAll(newState, newValue);
}
} | [
"function",
"resolve",
"(",
"newState",
",",
"newValue",
")",
"{",
"if",
"(",
"webdriver",
".",
"promise",
".",
"Deferred",
".",
"State_",
".",
"PENDING",
"!==",
"state",
")",
"{",
"return",
";",
"}",
"if",
"(",
"newValue",
"===",
"self",
")",
"{",
"throw",
"TypeError",
"(",
"'A promise may not resolve to itself'",
")",
";",
"}",
"state",
"=",
"webdriver",
".",
"promise",
".",
"Deferred",
".",
"State_",
".",
"BLOCKED",
";",
"if",
"(",
"webdriver",
".",
"promise",
".",
"isPromise",
"(",
"newValue",
")",
")",
"{",
"var",
"onFulfill",
"=",
"goog",
".",
"partial",
"(",
"notifyAll",
",",
"newState",
")",
";",
"var",
"onReject",
"=",
"goog",
".",
"partial",
"(",
"notifyAll",
",",
"webdriver",
".",
"promise",
".",
"Deferred",
".",
"State_",
".",
"REJECTED",
")",
";",
"if",
"(",
"newValue",
"instanceof",
"webdriver",
".",
"promise",
".",
"Deferred",
")",
"{",
"newValue",
".",
"then",
"(",
"onFulfill",
",",
"onReject",
")",
";",
"}",
"else",
"{",
"webdriver",
".",
"promise",
".",
"asap",
"(",
"newValue",
",",
"onFulfill",
",",
"onReject",
")",
";",
"}",
"}",
"else",
"{",
"notifyAll",
"(",
"newState",
",",
"newValue",
")",
";",
"}",
"}"
] | Resolves this deferred. If the new value is a promise, this function will
wait for it to be resolved before notifying the registered listeners.
@param {!webdriver.promise.Deferred.State_} newState The deferred's new
state.
@param {*} newValue The deferred's new value. | [
"Resolves",
"this",
"deferred",
".",
"If",
"the",
"new",
"value",
"is",
"a",
"promise",
"this",
"function",
"will",
"wait",
"for",
"it",
"to",
"be",
"resolved",
"before",
"notifying",
"the",
"registered",
"listeners",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/lib/webdriver/promise.js#L376-L402 | train |
browserstack/selenium-webdriver-nodejs | lib/webdriver/promise.js | notify | function notify(listener) {
var func = state == webdriver.promise.Deferred.State_.RESOLVED ?
listener.callback : listener.errback;
if (func) {
flow.runInNewFrame_(goog.partial(func, value),
listener.fulfill, listener.reject);
} else if (state == webdriver.promise.Deferred.State_.REJECTED) {
listener.reject(value);
} else {
listener.fulfill(value);
}
} | javascript | function notify(listener) {
var func = state == webdriver.promise.Deferred.State_.RESOLVED ?
listener.callback : listener.errback;
if (func) {
flow.runInNewFrame_(goog.partial(func, value),
listener.fulfill, listener.reject);
} else if (state == webdriver.promise.Deferred.State_.REJECTED) {
listener.reject(value);
} else {
listener.fulfill(value);
}
} | [
"function",
"notify",
"(",
"listener",
")",
"{",
"var",
"func",
"=",
"state",
"==",
"webdriver",
".",
"promise",
".",
"Deferred",
".",
"State_",
".",
"RESOLVED",
"?",
"listener",
".",
"callback",
":",
"listener",
".",
"errback",
";",
"if",
"(",
"func",
")",
"{",
"flow",
".",
"runInNewFrame_",
"(",
"goog",
".",
"partial",
"(",
"func",
",",
"value",
")",
",",
"listener",
".",
"fulfill",
",",
"listener",
".",
"reject",
")",
";",
"}",
"else",
"if",
"(",
"state",
"==",
"webdriver",
".",
"promise",
".",
"Deferred",
".",
"State_",
".",
"REJECTED",
")",
"{",
"listener",
".",
"reject",
"(",
"value",
")",
";",
"}",
"else",
"{",
"listener",
".",
"fulfill",
"(",
"value",
")",
";",
"}",
"}"
] | Notifies a single listener of this Deferred's change in state.
@param {!webdriver.promise.Deferred.Listener_} listener The listener to
notify. | [
"Notifies",
"a",
"single",
"listener",
"of",
"this",
"Deferred",
"s",
"change",
"in",
"state",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/lib/webdriver/promise.js#L440-L451 | train |
browserstack/selenium-webdriver-nodejs | lib/webdriver/promise.js | cancel | function cancel(opt_reason) {
if (!isPending()) {
return;
}
if (opt_canceller) {
opt_reason = opt_canceller(opt_reason) || opt_reason;
}
reject(opt_reason);
} | javascript | function cancel(opt_reason) {
if (!isPending()) {
return;
}
if (opt_canceller) {
opt_reason = opt_canceller(opt_reason) || opt_reason;
}
reject(opt_reason);
} | [
"function",
"cancel",
"(",
"opt_reason",
")",
"{",
"if",
"(",
"!",
"isPending",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"opt_canceller",
")",
"{",
"opt_reason",
"=",
"opt_canceller",
"(",
"opt_reason",
")",
"||",
"opt_reason",
";",
"}",
"reject",
"(",
"opt_reason",
")",
";",
"}"
] | Attempts to cancel the computation of this instance's value. This attempt
will silently fail if this instance has already resolved.
@param {*=} opt_reason The reason for cancelling this promise. | [
"Attempts",
"to",
"cancel",
"the",
"computation",
"of",
"this",
"instance",
"s",
"value",
".",
"This",
"attempt",
"will",
"silently",
"fail",
"if",
"this",
"instance",
"has",
"already",
"resolved",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/lib/webdriver/promise.js#L530-L540 | train |
browserstack/selenium-webdriver-nodejs | firefox/extension.js | AddonFormatError | function AddonFormatError(msg) {
Error.call(this);
Error.captureStackTrace(this, AddonFormatError);
/** @override */
this.name = AddonFormatError.name;
/** @override */
this.message = msg;
} | javascript | function AddonFormatError(msg) {
Error.call(this);
Error.captureStackTrace(this, AddonFormatError);
/** @override */
this.name = AddonFormatError.name;
/** @override */
this.message = msg;
} | [
"function",
"AddonFormatError",
"(",
"msg",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"AddonFormatError",
")",
";",
"this",
".",
"name",
"=",
"AddonFormatError",
".",
"name",
";",
"this",
".",
"message",
"=",
"msg",
";",
"}"
] | Thrown when there an add-on is malformed.
@param {string} msg The error message.
@constructor
@extends {Error} | [
"Thrown",
"when",
"there",
"an",
"add",
"-",
"on",
"is",
"malformed",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/firefox/extension.js#L37-L47 | train |
browserstack/selenium-webdriver-nodejs | firefox/extension.js | getDetails | function getDetails(addonPath) {
return readManifest(addonPath).then(function(doc) {
var em = getNamespaceId(doc, 'http://www.mozilla.org/2004/em-rdf#');
var rdf = getNamespaceId(
doc, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
var description = doc[rdf + 'RDF'][rdf + 'Description'][0];
var details = {
id: getNodeText(description, em + 'id'),
name: getNodeText(description, em + 'name'),
version: getNodeText(description, em + 'version'),
unpack: getNodeText(description, em + 'unpack') || false
};
if (typeof details.unpack === 'string') {
details.unpack = details.unpack.toLowerCase() === 'true';
}
if (!details.id) {
throw new AddonFormatError('Could not find add-on ID for ' + addonPath);
}
return details;
});
function getNodeText(node, name) {
return node[name] && node[name][0] || '';
}
function getNamespaceId(doc, url) {
var keys = Object.keys(doc);
if (keys.length !== 1) {
throw new AddonFormatError('Malformed manifest for add-on ' + addonPath);
}
var namespaces = doc[keys[0]].$;
var id = '';
Object.keys(namespaces).some(function(ns) {
if (namespaces[ns] !== url) {
return false;
}
if (ns.indexOf(':') != -1) {
id = ns.split(':')[1] + ':';
}
return true;
});
return id;
}
} | javascript | function getDetails(addonPath) {
return readManifest(addonPath).then(function(doc) {
var em = getNamespaceId(doc, 'http://www.mozilla.org/2004/em-rdf#');
var rdf = getNamespaceId(
doc, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
var description = doc[rdf + 'RDF'][rdf + 'Description'][0];
var details = {
id: getNodeText(description, em + 'id'),
name: getNodeText(description, em + 'name'),
version: getNodeText(description, em + 'version'),
unpack: getNodeText(description, em + 'unpack') || false
};
if (typeof details.unpack === 'string') {
details.unpack = details.unpack.toLowerCase() === 'true';
}
if (!details.id) {
throw new AddonFormatError('Could not find add-on ID for ' + addonPath);
}
return details;
});
function getNodeText(node, name) {
return node[name] && node[name][0] || '';
}
function getNamespaceId(doc, url) {
var keys = Object.keys(doc);
if (keys.length !== 1) {
throw new AddonFormatError('Malformed manifest for add-on ' + addonPath);
}
var namespaces = doc[keys[0]].$;
var id = '';
Object.keys(namespaces).some(function(ns) {
if (namespaces[ns] !== url) {
return false;
}
if (ns.indexOf(':') != -1) {
id = ns.split(':')[1] + ':';
}
return true;
});
return id;
}
} | [
"function",
"getDetails",
"(",
"addonPath",
")",
"{",
"return",
"readManifest",
"(",
"addonPath",
")",
".",
"then",
"(",
"function",
"(",
"doc",
")",
"{",
"var",
"em",
"=",
"getNamespaceId",
"(",
"doc",
",",
"'http://www.mozilla.org/2004/em-rdf#'",
")",
";",
"var",
"rdf",
"=",
"getNamespaceId",
"(",
"doc",
",",
"'http://www.w3.org/1999/02/22-rdf-syntax-ns#'",
")",
";",
"var",
"description",
"=",
"doc",
"[",
"rdf",
"+",
"'RDF'",
"]",
"[",
"rdf",
"+",
"'Description'",
"]",
"[",
"0",
"]",
";",
"var",
"details",
"=",
"{",
"id",
":",
"getNodeText",
"(",
"description",
",",
"em",
"+",
"'id'",
")",
",",
"name",
":",
"getNodeText",
"(",
"description",
",",
"em",
"+",
"'name'",
")",
",",
"version",
":",
"getNodeText",
"(",
"description",
",",
"em",
"+",
"'version'",
")",
",",
"unpack",
":",
"getNodeText",
"(",
"description",
",",
"em",
"+",
"'unpack'",
")",
"||",
"false",
"}",
";",
"if",
"(",
"typeof",
"details",
".",
"unpack",
"===",
"'string'",
")",
"{",
"details",
".",
"unpack",
"=",
"details",
".",
"unpack",
".",
"toLowerCase",
"(",
")",
"===",
"'true'",
";",
"}",
"if",
"(",
"!",
"details",
".",
"id",
")",
"{",
"throw",
"new",
"AddonFormatError",
"(",
"'Could not find add-on ID for '",
"+",
"addonPath",
")",
";",
"}",
"return",
"details",
";",
"}",
")",
";",
"function",
"getNodeText",
"(",
"node",
",",
"name",
")",
"{",
"return",
"node",
"[",
"name",
"]",
"&&",
"node",
"[",
"name",
"]",
"[",
"0",
"]",
"||",
"''",
";",
"}",
"function",
"getNamespaceId",
"(",
"doc",
",",
"url",
")",
"{",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"doc",
")",
";",
"if",
"(",
"keys",
".",
"length",
"!==",
"1",
")",
"{",
"throw",
"new",
"AddonFormatError",
"(",
"'Malformed manifest for add-on '",
"+",
"addonPath",
")",
";",
"}",
"var",
"namespaces",
"=",
"doc",
"[",
"keys",
"[",
"0",
"]",
"]",
".",
"$",
";",
"var",
"id",
"=",
"''",
";",
"Object",
".",
"keys",
"(",
"namespaces",
")",
".",
"some",
"(",
"function",
"(",
"ns",
")",
"{",
"if",
"(",
"namespaces",
"[",
"ns",
"]",
"!==",
"url",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"ns",
".",
"indexOf",
"(",
"':'",
")",
"!=",
"-",
"1",
")",
"{",
"id",
"=",
"ns",
".",
"split",
"(",
"':'",
")",
"[",
"1",
"]",
"+",
"':'",
";",
"}",
"return",
"true",
";",
"}",
")",
";",
"return",
"id",
";",
"}",
"}"
] | Extracts the details needed to install an add-on.
@param {string} addonPath Path to the extension directory.
@return {!promise.Promise.<!AddonDetails>} A promise for the add-on details. | [
"Extracts",
"the",
"details",
"needed",
"to",
"install",
"an",
"add",
"-",
"on",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/firefox/extension.js#L94-L143 | train |
browserstack/selenium-webdriver-nodejs | firefox/extension.js | readManifest | function readManifest(addonPath) {
var manifest;
if (addonPath.slice(-4) === '.xpi') {
manifest = checkedCall(fs.readFile, addonPath).then(function(buff) {
var zip = new AdmZip(buff);
if (!zip.getEntry('install.rdf')) {
throw new AddonFormatError(
'Could not find install.rdf in ' + addonPath);
}
var done = promise.defer();
zip.readAsTextAsync('install.rdf', done.fulfill);
return done.promise;
});
} else {
manifest = checkedCall(fs.stat, addonPath).then(function(stats) {
if (!stats.isDirectory()) {
throw Error(
'Add-on path is niether a xpi nor a directory: ' + addonPath);
}
return checkedCall(fs.readFile, path.join(addonPath, 'install.rdf'));
});
}
return manifest.then(function(content) {
return checkedCall(xml.parseString, content);
});
} | javascript | function readManifest(addonPath) {
var manifest;
if (addonPath.slice(-4) === '.xpi') {
manifest = checkedCall(fs.readFile, addonPath).then(function(buff) {
var zip = new AdmZip(buff);
if (!zip.getEntry('install.rdf')) {
throw new AddonFormatError(
'Could not find install.rdf in ' + addonPath);
}
var done = promise.defer();
zip.readAsTextAsync('install.rdf', done.fulfill);
return done.promise;
});
} else {
manifest = checkedCall(fs.stat, addonPath).then(function(stats) {
if (!stats.isDirectory()) {
throw Error(
'Add-on path is niether a xpi nor a directory: ' + addonPath);
}
return checkedCall(fs.readFile, path.join(addonPath, 'install.rdf'));
});
}
return manifest.then(function(content) {
return checkedCall(xml.parseString, content);
});
} | [
"function",
"readManifest",
"(",
"addonPath",
")",
"{",
"var",
"manifest",
";",
"if",
"(",
"addonPath",
".",
"slice",
"(",
"-",
"4",
")",
"===",
"'.xpi'",
")",
"{",
"manifest",
"=",
"checkedCall",
"(",
"fs",
".",
"readFile",
",",
"addonPath",
")",
".",
"then",
"(",
"function",
"(",
"buff",
")",
"{",
"var",
"zip",
"=",
"new",
"AdmZip",
"(",
"buff",
")",
";",
"if",
"(",
"!",
"zip",
".",
"getEntry",
"(",
"'install.rdf'",
")",
")",
"{",
"throw",
"new",
"AddonFormatError",
"(",
"'Could not find install.rdf in '",
"+",
"addonPath",
")",
";",
"}",
"var",
"done",
"=",
"promise",
".",
"defer",
"(",
")",
";",
"zip",
".",
"readAsTextAsync",
"(",
"'install.rdf'",
",",
"done",
".",
"fulfill",
")",
";",
"return",
"done",
".",
"promise",
";",
"}",
")",
";",
"}",
"else",
"{",
"manifest",
"=",
"checkedCall",
"(",
"fs",
".",
"stat",
",",
"addonPath",
")",
".",
"then",
"(",
"function",
"(",
"stats",
")",
"{",
"if",
"(",
"!",
"stats",
".",
"isDirectory",
"(",
")",
")",
"{",
"throw",
"Error",
"(",
"'Add-on path is niether a xpi nor a directory: '",
"+",
"addonPath",
")",
";",
"}",
"return",
"checkedCall",
"(",
"fs",
".",
"readFile",
",",
"path",
".",
"join",
"(",
"addonPath",
",",
"'install.rdf'",
")",
")",
";",
"}",
")",
";",
"}",
"return",
"manifest",
".",
"then",
"(",
"function",
"(",
"content",
")",
"{",
"return",
"checkedCall",
"(",
"xml",
".",
"parseString",
",",
"content",
")",
";",
"}",
")",
";",
"}"
] | Reads the manifest for a Firefox add-on.
@param {string} addonPath Path to a Firefox add-on as a xpi or an extension.
@return {!promise.Promise.<!Object>} A promise for the parsed manifest. | [
"Reads",
"the",
"manifest",
"for",
"a",
"Firefox",
"add",
"-",
"on",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/firefox/extension.js#L151-L178 | train |
browserstack/selenium-webdriver-nodejs | chrome.js | function(opt_config, opt_service, opt_flow) {
var service = opt_service || getDefaultService();
var executor = executors.createExecutor(service.start());
var capabilities =
opt_config instanceof Options ? opt_config.toCapabilities() :
(opt_config || webdriver.Capabilities.chrome());
var driver = webdriver.WebDriver.createSession(
executor, capabilities, opt_flow);
webdriver.WebDriver.call(
this, driver.getSession(), executor, driver.controlFlow());
} | javascript | function(opt_config, opt_service, opt_flow) {
var service = opt_service || getDefaultService();
var executor = executors.createExecutor(service.start());
var capabilities =
opt_config instanceof Options ? opt_config.toCapabilities() :
(opt_config || webdriver.Capabilities.chrome());
var driver = webdriver.WebDriver.createSession(
executor, capabilities, opt_flow);
webdriver.WebDriver.call(
this, driver.getSession(), executor, driver.controlFlow());
} | [
"function",
"(",
"opt_config",
",",
"opt_service",
",",
"opt_flow",
")",
"{",
"var",
"service",
"=",
"opt_service",
"||",
"getDefaultService",
"(",
")",
";",
"var",
"executor",
"=",
"executors",
".",
"createExecutor",
"(",
"service",
".",
"start",
"(",
")",
")",
";",
"var",
"capabilities",
"=",
"opt_config",
"instanceof",
"Options",
"?",
"opt_config",
".",
"toCapabilities",
"(",
")",
":",
"(",
"opt_config",
"||",
"webdriver",
".",
"Capabilities",
".",
"chrome",
"(",
")",
")",
";",
"var",
"driver",
"=",
"webdriver",
".",
"WebDriver",
".",
"createSession",
"(",
"executor",
",",
"capabilities",
",",
"opt_flow",
")",
";",
"webdriver",
".",
"WebDriver",
".",
"call",
"(",
"this",
",",
"driver",
".",
"getSession",
"(",
")",
",",
"executor",
",",
"driver",
".",
"controlFlow",
"(",
")",
")",
";",
"}"
] | Creates a new WebDriver client for Chrome.
@param {(webdriver.Capabilities|Options)=} opt_config The configuration
options.
@param {remote.DriverService=} opt_service The session to use; will use
the {@link getDefaultService default service} by default.
@param {webdriver.promise.ControlFlow=} opt_flow The control flow to use, or
{@code null} to use the currently active flow.
@constructor
@extends {webdriver.WebDriver} | [
"Creates",
"a",
"new",
"WebDriver",
"client",
"for",
"Chrome",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/chrome.js#L469-L482 | train |
|
browserstack/selenium-webdriver-nodejs | net/portprober.js | findUnixPortRange | function findUnixPortRange() {
var cmd;
if (process.platform === 'sunos') {
cmd =
'/usr/sbin/ndd /dev/tcp tcp_smallest_anon_port tcp_largest_anon_port';
} else if (fs.existsSync('/proc/sys/net/ipv4/ip_local_port_range')) {
// Linux
cmd = 'cat /proc/sys/net/ipv4/ip_local_port_range';
} else {
cmd = 'sysctl net.inet.ip.portrange.first net.inet.ip.portrange.last' +
' | sed -e "s/.*:\\s*//"';
}
return execute(cmd).then(function(stdout) {
if (!stdout || !stdout.length) return DEFAULT_IANA_RANGE;
var range = stdout.trim().split(/\s+/).map(Number);
if (range.some(isNaN)) return DEFAULT_IANA_RANGE;
return {min: range[0], max: range[1]};
});
} | javascript | function findUnixPortRange() {
var cmd;
if (process.platform === 'sunos') {
cmd =
'/usr/sbin/ndd /dev/tcp tcp_smallest_anon_port tcp_largest_anon_port';
} else if (fs.existsSync('/proc/sys/net/ipv4/ip_local_port_range')) {
// Linux
cmd = 'cat /proc/sys/net/ipv4/ip_local_port_range';
} else {
cmd = 'sysctl net.inet.ip.portrange.first net.inet.ip.portrange.last' +
' | sed -e "s/.*:\\s*//"';
}
return execute(cmd).then(function(stdout) {
if (!stdout || !stdout.length) return DEFAULT_IANA_RANGE;
var range = stdout.trim().split(/\s+/).map(Number);
if (range.some(isNaN)) return DEFAULT_IANA_RANGE;
return {min: range[0], max: range[1]};
});
} | [
"function",
"findUnixPortRange",
"(",
")",
"{",
"var",
"cmd",
";",
"if",
"(",
"process",
".",
"platform",
"===",
"'sunos'",
")",
"{",
"cmd",
"=",
"'/usr/sbin/ndd /dev/tcp tcp_smallest_anon_port tcp_largest_anon_port'",
";",
"}",
"else",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"'/proc/sys/net/ipv4/ip_local_port_range'",
")",
")",
"{",
"cmd",
"=",
"'cat /proc/sys/net/ipv4/ip_local_port_range'",
";",
"}",
"else",
"{",
"cmd",
"=",
"'sysctl net.inet.ip.portrange.first net.inet.ip.portrange.last'",
"+",
"' | sed -e \"s/.*:\\\\s*//\"'",
";",
"}",
"\\\\",
"}"
] | Computes the ephemeral port range for a Unix-like system.
@return {!webdriver.promise.Promise.<{min: number, max: number}>} A promise
that will resolve with the ephemeral port range on the current system. | [
"Computes",
"the",
"ephemeral",
"port",
"range",
"for",
"a",
"Unix",
"-",
"like",
"system",
"."
] | 80a1379f73354aaf722a343c2d0ccc1aa7674b29 | https://github.com/browserstack/selenium-webdriver-nodejs/blob/80a1379f73354aaf722a343c2d0ccc1aa7674b29/net/portprober.js#L84-L103 | train |
Cerealkillerway/materialNote | src/js/base/core/agent.js | function (fontName) {
var testFontName = fontName === 'Comic Sans MS' ? 'Courier New' : 'Comic Sans MS';
var $tester = $('<div>').css({
position: 'absolute',
left: '-9999px',
top: '-9999px',
fontSize: '200px'
}).text('mmmmmmmmmwwwwwww').appendTo(document.body);
var originalWidth = $tester.css('fontFamily', testFontName).width();
var width = $tester.css('fontFamily', fontName + ',' + testFontName).width();
$tester.remove();
return originalWidth !== width;
} | javascript | function (fontName) {
var testFontName = fontName === 'Comic Sans MS' ? 'Courier New' : 'Comic Sans MS';
var $tester = $('<div>').css({
position: 'absolute',
left: '-9999px',
top: '-9999px',
fontSize: '200px'
}).text('mmmmmmmmmwwwwwww').appendTo(document.body);
var originalWidth = $tester.css('fontFamily', testFontName).width();
var width = $tester.css('fontFamily', fontName + ',' + testFontName).width();
$tester.remove();
return originalWidth !== width;
} | [
"function",
"(",
"fontName",
")",
"{",
"var",
"testFontName",
"=",
"fontName",
"===",
"'Comic Sans MS'",
"?",
"'Courier New'",
":",
"'Comic Sans MS'",
";",
"var",
"$tester",
"=",
"$",
"(",
"'<div>'",
")",
".",
"css",
"(",
"{",
"position",
":",
"'absolute'",
",",
"left",
":",
"'-9999px'",
",",
"top",
":",
"'-9999px'",
",",
"fontSize",
":",
"'200px'",
"}",
")",
".",
"text",
"(",
"'mmmmmmmmmwwwwwww'",
")",
".",
"appendTo",
"(",
"document",
".",
"body",
")",
";",
"var",
"originalWidth",
"=",
"$tester",
".",
"css",
"(",
"'fontFamily'",
",",
"testFontName",
")",
".",
"width",
"(",
")",
";",
"var",
"width",
"=",
"$tester",
".",
"css",
"(",
"'fontFamily'",
",",
"fontName",
"+",
"','",
"+",
"testFontName",
")",
".",
"width",
"(",
")",
";",
"$tester",
".",
"remove",
"(",
")",
";",
"return",
"originalWidth",
"!==",
"width",
";",
"}"
] | returns whether font is installed or not.
@param {String} fontName
@return {Boolean} | [
"returns",
"whether",
"font",
"is",
"installed",
"or",
"not",
"."
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/js/base/core/agent.js#L10-L25 | train |
|
Cerealkillerway/materialNote | src/js/base/core/range.js | function (sc, so, ec, eo) {
if (arguments.length === 4) {
return new WrappedRange(sc, so, ec, eo);
} else if (arguments.length === 2) { //collapsed
ec = sc;
eo = so;
return new WrappedRange(sc, so, ec, eo);
} else {
var wrappedRange = this.createFromSelection();
if (!wrappedRange && arguments.length === 1) {
wrappedRange = this.createFromNode(arguments[0]);
return wrappedRange.collapse(dom.emptyPara === arguments[0].innerHTML);
}
return wrappedRange;
}
} | javascript | function (sc, so, ec, eo) {
if (arguments.length === 4) {
return new WrappedRange(sc, so, ec, eo);
} else if (arguments.length === 2) { //collapsed
ec = sc;
eo = so;
return new WrappedRange(sc, so, ec, eo);
} else {
var wrappedRange = this.createFromSelection();
if (!wrappedRange && arguments.length === 1) {
wrappedRange = this.createFromNode(arguments[0]);
return wrappedRange.collapse(dom.emptyPara === arguments[0].innerHTML);
}
return wrappedRange;
}
} | [
"function",
"(",
"sc",
",",
"so",
",",
"ec",
",",
"eo",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"===",
"4",
")",
"{",
"return",
"new",
"WrappedRange",
"(",
"sc",
",",
"so",
",",
"ec",
",",
"eo",
")",
";",
"}",
"else",
"if",
"(",
"arguments",
".",
"length",
"===",
"2",
")",
"{",
"ec",
"=",
"sc",
";",
"eo",
"=",
"so",
";",
"return",
"new",
"WrappedRange",
"(",
"sc",
",",
"so",
",",
"ec",
",",
"eo",
")",
";",
"}",
"else",
"{",
"var",
"wrappedRange",
"=",
"this",
".",
"createFromSelection",
"(",
")",
";",
"if",
"(",
"!",
"wrappedRange",
"&&",
"arguments",
".",
"length",
"===",
"1",
")",
"{",
"wrappedRange",
"=",
"this",
".",
"createFromNode",
"(",
"arguments",
"[",
"0",
"]",
")",
";",
"return",
"wrappedRange",
".",
"collapse",
"(",
"dom",
".",
"emptyPara",
"===",
"arguments",
"[",
"0",
"]",
".",
"innerHTML",
")",
";",
"}",
"return",
"wrappedRange",
";",
"}",
"}"
] | create Range Object From arguments or Browser Selection
@param {Node} sc - start container
@param {Number} so - start offset
@param {Node} ec - end container
@param {Number} eo - end offset
@return {WrappedRange} | [
"create",
"Range",
"Object",
"From",
"arguments",
"or",
"Browser",
"Selection"
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/js/base/core/range.js#L654-L669 | train |
|
Cerealkillerway/materialNote | src/materialize/materialize.js | returnToOriginal | function returnToOriginal() {
doneAnimating = false;
var placeholder = origin.parent('.material-placeholder');
var windowWidth = window.innerWidth;
var windowHeight = window.innerHeight;
var originalWidth = origin.data('width');
var originalHeight = origin.data('height');
origin.velocity("stop", true);
$('#materialbox-overlay').velocity("stop", true);
$('.materialbox-caption').velocity("stop", true);
$('#materialbox-overlay').velocity({opacity: 0}, {
duration: outDuration, // Delay prevents animation overlapping
queue: false, easing: 'easeOutQuad',
complete: function(){
// Remove Overlay
overlayActive = false;
$(this).remove();
}
});
// Resize Image
origin.velocity(
{
width: originalWidth,
height: originalHeight,
left: 0,
top: 0
},
{
duration: outDuration,
queue: false, easing: 'easeOutQuad',
complete: function() {
placeholder.css({
height: '',
width: '',
position: '',
top: '',
left: ''
});
origin.removeAttr('style');
origin.attr('style', originInlineStyles);
// Remove class
origin.removeClass('active');
doneAnimating = true;
// Remove overflow overrides on ancestors
if (ancestorsChanged) {
ancestorsChanged.css('overflow', '');
}
}
}
);
// Remove Caption + reset css settings on image
$('.materialbox-caption').velocity({opacity: 0}, {
duration: outDuration, // Delay prevents animation overlapping
queue: false, easing: 'easeOutQuad',
complete: function(){
$(this).remove();
}
});
} | javascript | function returnToOriginal() {
doneAnimating = false;
var placeholder = origin.parent('.material-placeholder');
var windowWidth = window.innerWidth;
var windowHeight = window.innerHeight;
var originalWidth = origin.data('width');
var originalHeight = origin.data('height');
origin.velocity("stop", true);
$('#materialbox-overlay').velocity("stop", true);
$('.materialbox-caption').velocity("stop", true);
$('#materialbox-overlay').velocity({opacity: 0}, {
duration: outDuration, // Delay prevents animation overlapping
queue: false, easing: 'easeOutQuad',
complete: function(){
// Remove Overlay
overlayActive = false;
$(this).remove();
}
});
// Resize Image
origin.velocity(
{
width: originalWidth,
height: originalHeight,
left: 0,
top: 0
},
{
duration: outDuration,
queue: false, easing: 'easeOutQuad',
complete: function() {
placeholder.css({
height: '',
width: '',
position: '',
top: '',
left: ''
});
origin.removeAttr('style');
origin.attr('style', originInlineStyles);
// Remove class
origin.removeClass('active');
doneAnimating = true;
// Remove overflow overrides on ancestors
if (ancestorsChanged) {
ancestorsChanged.css('overflow', '');
}
}
}
);
// Remove Caption + reset css settings on image
$('.materialbox-caption').velocity({opacity: 0}, {
duration: outDuration, // Delay prevents animation overlapping
queue: false, easing: 'easeOutQuad',
complete: function(){
$(this).remove();
}
});
} | [
"function",
"returnToOriginal",
"(",
")",
"{",
"doneAnimating",
"=",
"false",
";",
"var",
"placeholder",
"=",
"origin",
".",
"parent",
"(",
"'.material-placeholder'",
")",
";",
"var",
"windowWidth",
"=",
"window",
".",
"innerWidth",
";",
"var",
"windowHeight",
"=",
"window",
".",
"innerHeight",
";",
"var",
"originalWidth",
"=",
"origin",
".",
"data",
"(",
"'width'",
")",
";",
"var",
"originalHeight",
"=",
"origin",
".",
"data",
"(",
"'height'",
")",
";",
"origin",
".",
"velocity",
"(",
"\"stop\"",
",",
"true",
")",
";",
"$",
"(",
"'#materialbox-overlay'",
")",
".",
"velocity",
"(",
"\"stop\"",
",",
"true",
")",
";",
"$",
"(",
"'.materialbox-caption'",
")",
".",
"velocity",
"(",
"\"stop\"",
",",
"true",
")",
";",
"$",
"(",
"'#materialbox-overlay'",
")",
".",
"velocity",
"(",
"{",
"opacity",
":",
"0",
"}",
",",
"{",
"duration",
":",
"outDuration",
",",
"queue",
":",
"false",
",",
"easing",
":",
"'easeOutQuad'",
",",
"complete",
":",
"function",
"(",
")",
"{",
"overlayActive",
"=",
"false",
";",
"$",
"(",
"this",
")",
".",
"remove",
"(",
")",
";",
"}",
"}",
")",
";",
"origin",
".",
"velocity",
"(",
"{",
"width",
":",
"originalWidth",
",",
"height",
":",
"originalHeight",
",",
"left",
":",
"0",
",",
"top",
":",
"0",
"}",
",",
"{",
"duration",
":",
"outDuration",
",",
"queue",
":",
"false",
",",
"easing",
":",
"'easeOutQuad'",
",",
"complete",
":",
"function",
"(",
")",
"{",
"placeholder",
".",
"css",
"(",
"{",
"height",
":",
"''",
",",
"width",
":",
"''",
",",
"position",
":",
"''",
",",
"top",
":",
"''",
",",
"left",
":",
"''",
"}",
")",
";",
"origin",
".",
"removeAttr",
"(",
"'style'",
")",
";",
"origin",
".",
"attr",
"(",
"'style'",
",",
"originInlineStyles",
")",
";",
"origin",
".",
"removeClass",
"(",
"'active'",
")",
";",
"doneAnimating",
"=",
"true",
";",
"if",
"(",
"ancestorsChanged",
")",
"{",
"ancestorsChanged",
".",
"css",
"(",
"'overflow'",
",",
"''",
")",
";",
"}",
"}",
"}",
")",
";",
"$",
"(",
"'.materialbox-caption'",
")",
".",
"velocity",
"(",
"{",
"opacity",
":",
"0",
"}",
",",
"{",
"duration",
":",
"outDuration",
",",
"queue",
":",
"false",
",",
"easing",
":",
"'easeOutQuad'",
",",
"complete",
":",
"function",
"(",
")",
"{",
"$",
"(",
"this",
")",
".",
"remove",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | This function returns the modaled image to the original spot | [
"This",
"function",
"returns",
"the",
"modaled",
"image",
"to",
"the",
"original",
"spot"
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/materialize/materialize.js#L1265-L1334 | train |
Cerealkillerway/materialNote | src/materialize/materialize.js | function(string, $el) {
var img = $el.find('img');
var matchStart = $el.text().toLowerCase().indexOf("" + string.toLowerCase() + ""),
matchEnd = matchStart + string.length - 1,
beforeMatch = $el.text().slice(0, matchStart),
matchText = $el.text().slice(matchStart, matchEnd + 1),
afterMatch = $el.text().slice(matchEnd + 1);
$el.html("<span>" + beforeMatch + "<span class='highlight'>" + matchText + "</span>" + afterMatch + "</span>");
if (img.length) {
$el.prepend(img);
}
} | javascript | function(string, $el) {
var img = $el.find('img');
var matchStart = $el.text().toLowerCase().indexOf("" + string.toLowerCase() + ""),
matchEnd = matchStart + string.length - 1,
beforeMatch = $el.text().slice(0, matchStart),
matchText = $el.text().slice(matchStart, matchEnd + 1),
afterMatch = $el.text().slice(matchEnd + 1);
$el.html("<span>" + beforeMatch + "<span class='highlight'>" + matchText + "</span>" + afterMatch + "</span>");
if (img.length) {
$el.prepend(img);
}
} | [
"function",
"(",
"string",
",",
"$el",
")",
"{",
"var",
"img",
"=",
"$el",
".",
"find",
"(",
"'img'",
")",
";",
"var",
"matchStart",
"=",
"$el",
".",
"text",
"(",
")",
".",
"toLowerCase",
"(",
")",
".",
"indexOf",
"(",
"\"\"",
"+",
"string",
".",
"toLowerCase",
"(",
")",
"+",
"\"\"",
")",
",",
"matchEnd",
"=",
"matchStart",
"+",
"string",
".",
"length",
"-",
"1",
",",
"beforeMatch",
"=",
"$el",
".",
"text",
"(",
")",
".",
"slice",
"(",
"0",
",",
"matchStart",
")",
",",
"matchText",
"=",
"$el",
".",
"text",
"(",
")",
".",
"slice",
"(",
"matchStart",
",",
"matchEnd",
"+",
"1",
")",
",",
"afterMatch",
"=",
"$el",
".",
"text",
"(",
")",
".",
"slice",
"(",
"matchEnd",
"+",
"1",
")",
";",
"$el",
".",
"html",
"(",
"\"<span>\"",
"+",
"beforeMatch",
"+",
"\"<span class='highlight'>\"",
"+",
"matchText",
"+",
"\"</span>\"",
"+",
"afterMatch",
"+",
"\"</span>\"",
")",
";",
"if",
"(",
"img",
".",
"length",
")",
"{",
"$el",
".",
"prepend",
"(",
"img",
")",
";",
"}",
"}"
] | Highlight partial match. | [
"Highlight",
"partial",
"match",
"."
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/materialize/materialize.js#L3298-L3309 | train |
|
Cerealkillerway/materialNote | src/materialize/materialize.js | function(collection, newOption, firstActivation) {
if (newOption) {
collection.find('li.selected').removeClass('selected');
var option = $(newOption);
option.addClass('selected');
if (!multiple || !!firstActivation) {
options.scrollTo(option);
}
}
} | javascript | function(collection, newOption, firstActivation) {
if (newOption) {
collection.find('li.selected').removeClass('selected');
var option = $(newOption);
option.addClass('selected');
if (!multiple || !!firstActivation) {
options.scrollTo(option);
}
}
} | [
"function",
"(",
"collection",
",",
"newOption",
",",
"firstActivation",
")",
"{",
"if",
"(",
"newOption",
")",
"{",
"collection",
".",
"find",
"(",
"'li.selected'",
")",
".",
"removeClass",
"(",
"'selected'",
")",
";",
"var",
"option",
"=",
"$",
"(",
"newOption",
")",
";",
"option",
".",
"addClass",
"(",
"'selected'",
")",
";",
"if",
"(",
"!",
"multiple",
"||",
"!",
"!",
"firstActivation",
")",
"{",
"options",
".",
"scrollTo",
"(",
"option",
")",
";",
"}",
"}",
"}"
] | Make option as selected and scroll to selected position
@param {jQuery} collection Select options jQuery element
@param {Element} newOption element of the new option
@param {Boolean} firstActivation If on first activation of select | [
"Make",
"option",
"as",
"selected",
"and",
"scroll",
"to",
"selected",
"position"
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/materialize/materialize.js#L3629-L3638 | train |
|
Cerealkillerway/materialNote | src/materialize/materialize.js | function(btn) {
if (btn.attr('data-open') === "true") {
return;
}
var offsetX, offsetY, scaleFactor;
var windowWidth = window.innerWidth;
var windowHeight = window.innerHeight;
var btnRect = btn[0].getBoundingClientRect();
var anchor = btn.find('> a').first();
var menu = btn.find('> ul').first();
var backdrop = $('<div class="fab-backdrop"></div>');
var fabColor = anchor.css('background-color');
anchor.append(backdrop);
offsetX = btnRect.left - (windowWidth / 2) + (btnRect.width / 2);
offsetY = windowHeight - btnRect.bottom;
scaleFactor = windowWidth / backdrop.width();
btn.attr('data-origin-bottom', btnRect.bottom);
btn.attr('data-origin-left', btnRect.left);
btn.attr('data-origin-width', btnRect.width);
// Set initial state
btn.addClass('active');
btn.attr('data-open', true);
btn.css({
'text-align': 'center',
width: '100%',
bottom: 0,
left: 0,
transform: 'translateX(' + offsetX + 'px)',
transition: 'none'
});
anchor.css({
transform: 'translateY(' + -offsetY + 'px)',
transition: 'none'
});
backdrop.css({
'background-color': fabColor
});
setTimeout(function() {
btn.css({
transform: '',
transition: 'transform .2s cubic-bezier(0.550, 0.085, 0.680, 0.530), background-color 0s linear .2s'
});
anchor.css({
overflow: 'visible',
transform: '',
transition: 'transform .2s'
});
setTimeout(function() {
btn.css({
overflow: 'hidden',
'background-color': fabColor
});
backdrop.css({
transform: 'scale(' + scaleFactor + ')',
transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)'
});
menu.find('> li > a').css({
opacity: 1
});
// Scroll to close.
$(window).on('scroll.fabToolbarClose', function() {
toolbarToFAB(btn);
$(window).off('scroll.fabToolbarClose');
$(document).off('click.fabToolbarClose');
});
$(document).on('click.fabToolbarClose', function(e) {
if (!$(e.target).closest(menu).length) {
toolbarToFAB(btn);
$(window).off('scroll.fabToolbarClose');
$(document).off('click.fabToolbarClose');
}
});
}, 100);
}, 0);
} | javascript | function(btn) {
if (btn.attr('data-open') === "true") {
return;
}
var offsetX, offsetY, scaleFactor;
var windowWidth = window.innerWidth;
var windowHeight = window.innerHeight;
var btnRect = btn[0].getBoundingClientRect();
var anchor = btn.find('> a').first();
var menu = btn.find('> ul').first();
var backdrop = $('<div class="fab-backdrop"></div>');
var fabColor = anchor.css('background-color');
anchor.append(backdrop);
offsetX = btnRect.left - (windowWidth / 2) + (btnRect.width / 2);
offsetY = windowHeight - btnRect.bottom;
scaleFactor = windowWidth / backdrop.width();
btn.attr('data-origin-bottom', btnRect.bottom);
btn.attr('data-origin-left', btnRect.left);
btn.attr('data-origin-width', btnRect.width);
// Set initial state
btn.addClass('active');
btn.attr('data-open', true);
btn.css({
'text-align': 'center',
width: '100%',
bottom: 0,
left: 0,
transform: 'translateX(' + offsetX + 'px)',
transition: 'none'
});
anchor.css({
transform: 'translateY(' + -offsetY + 'px)',
transition: 'none'
});
backdrop.css({
'background-color': fabColor
});
setTimeout(function() {
btn.css({
transform: '',
transition: 'transform .2s cubic-bezier(0.550, 0.085, 0.680, 0.530), background-color 0s linear .2s'
});
anchor.css({
overflow: 'visible',
transform: '',
transition: 'transform .2s'
});
setTimeout(function() {
btn.css({
overflow: 'hidden',
'background-color': fabColor
});
backdrop.css({
transform: 'scale(' + scaleFactor + ')',
transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)'
});
menu.find('> li > a').css({
opacity: 1
});
// Scroll to close.
$(window).on('scroll.fabToolbarClose', function() {
toolbarToFAB(btn);
$(window).off('scroll.fabToolbarClose');
$(document).off('click.fabToolbarClose');
});
$(document).on('click.fabToolbarClose', function(e) {
if (!$(e.target).closest(menu).length) {
toolbarToFAB(btn);
$(window).off('scroll.fabToolbarClose');
$(document).off('click.fabToolbarClose');
}
});
}, 100);
}, 0);
} | [
"function",
"(",
"btn",
")",
"{",
"if",
"(",
"btn",
".",
"attr",
"(",
"'data-open'",
")",
"===",
"\"true\"",
")",
"{",
"return",
";",
"}",
"var",
"offsetX",
",",
"offsetY",
",",
"scaleFactor",
";",
"var",
"windowWidth",
"=",
"window",
".",
"innerWidth",
";",
"var",
"windowHeight",
"=",
"window",
".",
"innerHeight",
";",
"var",
"btnRect",
"=",
"btn",
"[",
"0",
"]",
".",
"getBoundingClientRect",
"(",
")",
";",
"var",
"anchor",
"=",
"btn",
".",
"find",
"(",
"'> a'",
")",
".",
"first",
"(",
")",
";",
"var",
"menu",
"=",
"btn",
".",
"find",
"(",
"'> ul'",
")",
".",
"first",
"(",
")",
";",
"var",
"backdrop",
"=",
"$",
"(",
"'<div class=\"fab-backdrop\"></div>'",
")",
";",
"var",
"fabColor",
"=",
"anchor",
".",
"css",
"(",
"'background-color'",
")",
";",
"anchor",
".",
"append",
"(",
"backdrop",
")",
";",
"offsetX",
"=",
"btnRect",
".",
"left",
"-",
"(",
"windowWidth",
"/",
"2",
")",
"+",
"(",
"btnRect",
".",
"width",
"/",
"2",
")",
";",
"offsetY",
"=",
"windowHeight",
"-",
"btnRect",
".",
"bottom",
";",
"scaleFactor",
"=",
"windowWidth",
"/",
"backdrop",
".",
"width",
"(",
")",
";",
"btn",
".",
"attr",
"(",
"'data-origin-bottom'",
",",
"btnRect",
".",
"bottom",
")",
";",
"btn",
".",
"attr",
"(",
"'data-origin-left'",
",",
"btnRect",
".",
"left",
")",
";",
"btn",
".",
"attr",
"(",
"'data-origin-width'",
",",
"btnRect",
".",
"width",
")",
";",
"btn",
".",
"addClass",
"(",
"'active'",
")",
";",
"btn",
".",
"attr",
"(",
"'data-open'",
",",
"true",
")",
";",
"btn",
".",
"css",
"(",
"{",
"'text-align'",
":",
"'center'",
",",
"width",
":",
"'100%'",
",",
"bottom",
":",
"0",
",",
"left",
":",
"0",
",",
"transform",
":",
"'translateX('",
"+",
"offsetX",
"+",
"'px)'",
",",
"transition",
":",
"'none'",
"}",
")",
";",
"anchor",
".",
"css",
"(",
"{",
"transform",
":",
"'translateY('",
"+",
"-",
"offsetY",
"+",
"'px)'",
",",
"transition",
":",
"'none'",
"}",
")",
";",
"backdrop",
".",
"css",
"(",
"{",
"'background-color'",
":",
"fabColor",
"}",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"btn",
".",
"css",
"(",
"{",
"transform",
":",
"''",
",",
"transition",
":",
"'transform .2s cubic-bezier(0.550, 0.085, 0.680, 0.530), background-color 0s linear .2s'",
"}",
")",
";",
"anchor",
".",
"css",
"(",
"{",
"overflow",
":",
"'visible'",
",",
"transform",
":",
"''",
",",
"transition",
":",
"'transform .2s'",
"}",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"btn",
".",
"css",
"(",
"{",
"overflow",
":",
"'hidden'",
",",
"'background-color'",
":",
"fabColor",
"}",
")",
";",
"backdrop",
".",
"css",
"(",
"{",
"transform",
":",
"'scale('",
"+",
"scaleFactor",
"+",
"')'",
",",
"transition",
":",
"'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)'",
"}",
")",
";",
"menu",
".",
"find",
"(",
"'> li > a'",
")",
".",
"css",
"(",
"{",
"opacity",
":",
"1",
"}",
")",
";",
"$",
"(",
"window",
")",
".",
"on",
"(",
"'scroll.fabToolbarClose'",
",",
"function",
"(",
")",
"{",
"toolbarToFAB",
"(",
"btn",
")",
";",
"$",
"(",
"window",
")",
".",
"off",
"(",
"'scroll.fabToolbarClose'",
")",
";",
"$",
"(",
"document",
")",
".",
"off",
"(",
"'click.fabToolbarClose'",
")",
";",
"}",
")",
";",
"$",
"(",
"document",
")",
".",
"on",
"(",
"'click.fabToolbarClose'",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"!",
"$",
"(",
"e",
".",
"target",
")",
".",
"closest",
"(",
"menu",
")",
".",
"length",
")",
"{",
"toolbarToFAB",
"(",
"btn",
")",
";",
"$",
"(",
"window",
")",
".",
"off",
"(",
"'scroll.fabToolbarClose'",
")",
";",
"$",
"(",
"document",
")",
".",
"off",
"(",
"'click.fabToolbarClose'",
")",
";",
"}",
"}",
")",
";",
"}",
",",
"100",
")",
";",
"}",
",",
"0",
")",
";",
"}"
] | Transform FAB into toolbar
@param {Object} object jQuery object | [
"Transform",
"FAB",
"into",
"toolbar"
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/materialize/materialize.js#L4597-L4679 | train |
|
Cerealkillerway/materialNote | src/materialize/materialize.js | function(btn) {
if (btn.attr('data-open') !== "true") {
return;
}
var offsetX, offsetY, scaleFactor;
var windowWidth = window.innerWidth;
var windowHeight = window.innerHeight;
var btnWidth = btn.attr('data-origin-width');
var btnBottom = btn.attr('data-origin-bottom');
var btnLeft = btn.attr('data-origin-left');
var anchor = btn.find('> .btn-floating').first();
var menu = btn.find('> ul').first();
var backdrop = btn.find('.fab-backdrop');
var fabColor = anchor.css('background-color');
offsetX = btnLeft - (windowWidth / 2) + (btnWidth / 2);
offsetY = windowHeight - btnBottom;
scaleFactor = windowWidth / backdrop.width();
// Hide backdrop
btn.removeClass('active');
btn.attr('data-open', false);
btn.css({
'background-color': 'transparent',
transition: 'none'
});
anchor.css({
transition: 'none'
});
backdrop.css({
transform: 'scale(0)',
'background-color': fabColor
});
menu.find('> li > a').css({
opacity: ''
});
setTimeout(function() {
backdrop.remove();
// Set initial state.
btn.css({
'text-align': '',
width: '',
bottom: '',
left: '',
overflow: '',
'background-color': '',
transform: 'translate3d(' + -offsetX + 'px,0,0)'
});
anchor.css({
overflow: '',
transform: 'translate3d(0,' + offsetY + 'px,0)'
});
setTimeout(function() {
btn.css({
transform: 'translate3d(0,0,0)',
transition: 'transform .2s'
});
anchor.css({
transform: 'translate3d(0,0,0)',
transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)'
});
}, 20);
}, 200);
} | javascript | function(btn) {
if (btn.attr('data-open') !== "true") {
return;
}
var offsetX, offsetY, scaleFactor;
var windowWidth = window.innerWidth;
var windowHeight = window.innerHeight;
var btnWidth = btn.attr('data-origin-width');
var btnBottom = btn.attr('data-origin-bottom');
var btnLeft = btn.attr('data-origin-left');
var anchor = btn.find('> .btn-floating').first();
var menu = btn.find('> ul').first();
var backdrop = btn.find('.fab-backdrop');
var fabColor = anchor.css('background-color');
offsetX = btnLeft - (windowWidth / 2) + (btnWidth / 2);
offsetY = windowHeight - btnBottom;
scaleFactor = windowWidth / backdrop.width();
// Hide backdrop
btn.removeClass('active');
btn.attr('data-open', false);
btn.css({
'background-color': 'transparent',
transition: 'none'
});
anchor.css({
transition: 'none'
});
backdrop.css({
transform: 'scale(0)',
'background-color': fabColor
});
menu.find('> li > a').css({
opacity: ''
});
setTimeout(function() {
backdrop.remove();
// Set initial state.
btn.css({
'text-align': '',
width: '',
bottom: '',
left: '',
overflow: '',
'background-color': '',
transform: 'translate3d(' + -offsetX + 'px,0,0)'
});
anchor.css({
overflow: '',
transform: 'translate3d(0,' + offsetY + 'px,0)'
});
setTimeout(function() {
btn.css({
transform: 'translate3d(0,0,0)',
transition: 'transform .2s'
});
anchor.css({
transform: 'translate3d(0,0,0)',
transition: 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)'
});
}, 20);
}, 200);
} | [
"function",
"(",
"btn",
")",
"{",
"if",
"(",
"btn",
".",
"attr",
"(",
"'data-open'",
")",
"!==",
"\"true\"",
")",
"{",
"return",
";",
"}",
"var",
"offsetX",
",",
"offsetY",
",",
"scaleFactor",
";",
"var",
"windowWidth",
"=",
"window",
".",
"innerWidth",
";",
"var",
"windowHeight",
"=",
"window",
".",
"innerHeight",
";",
"var",
"btnWidth",
"=",
"btn",
".",
"attr",
"(",
"'data-origin-width'",
")",
";",
"var",
"btnBottom",
"=",
"btn",
".",
"attr",
"(",
"'data-origin-bottom'",
")",
";",
"var",
"btnLeft",
"=",
"btn",
".",
"attr",
"(",
"'data-origin-left'",
")",
";",
"var",
"anchor",
"=",
"btn",
".",
"find",
"(",
"'> .btn-floating'",
")",
".",
"first",
"(",
")",
";",
"var",
"menu",
"=",
"btn",
".",
"find",
"(",
"'> ul'",
")",
".",
"first",
"(",
")",
";",
"var",
"backdrop",
"=",
"btn",
".",
"find",
"(",
"'.fab-backdrop'",
")",
";",
"var",
"fabColor",
"=",
"anchor",
".",
"css",
"(",
"'background-color'",
")",
";",
"offsetX",
"=",
"btnLeft",
"-",
"(",
"windowWidth",
"/",
"2",
")",
"+",
"(",
"btnWidth",
"/",
"2",
")",
";",
"offsetY",
"=",
"windowHeight",
"-",
"btnBottom",
";",
"scaleFactor",
"=",
"windowWidth",
"/",
"backdrop",
".",
"width",
"(",
")",
";",
"btn",
".",
"removeClass",
"(",
"'active'",
")",
";",
"btn",
".",
"attr",
"(",
"'data-open'",
",",
"false",
")",
";",
"btn",
".",
"css",
"(",
"{",
"'background-color'",
":",
"'transparent'",
",",
"transition",
":",
"'none'",
"}",
")",
";",
"anchor",
".",
"css",
"(",
"{",
"transition",
":",
"'none'",
"}",
")",
";",
"backdrop",
".",
"css",
"(",
"{",
"transform",
":",
"'scale(0)'",
",",
"'background-color'",
":",
"fabColor",
"}",
")",
";",
"menu",
".",
"find",
"(",
"'> li > a'",
")",
".",
"css",
"(",
"{",
"opacity",
":",
"''",
"}",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"backdrop",
".",
"remove",
"(",
")",
";",
"btn",
".",
"css",
"(",
"{",
"'text-align'",
":",
"''",
",",
"width",
":",
"''",
",",
"bottom",
":",
"''",
",",
"left",
":",
"''",
",",
"overflow",
":",
"''",
",",
"'background-color'",
":",
"''",
",",
"transform",
":",
"'translate3d('",
"+",
"-",
"offsetX",
"+",
"'px,0,0)'",
"}",
")",
";",
"anchor",
".",
"css",
"(",
"{",
"overflow",
":",
"''",
",",
"transform",
":",
"'translate3d(0,'",
"+",
"offsetY",
"+",
"'px,0)'",
"}",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"btn",
".",
"css",
"(",
"{",
"transform",
":",
"'translate3d(0,0,0)'",
",",
"transition",
":",
"'transform .2s'",
"}",
")",
";",
"anchor",
".",
"css",
"(",
"{",
"transform",
":",
"'translate3d(0,0,0)'",
",",
"transition",
":",
"'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)'",
"}",
")",
";",
"}",
",",
"20",
")",
";",
"}",
",",
"200",
")",
";",
"}"
] | Transform toolbar back into FAB
@param {Object} object jQuery object | [
"Transform",
"toolbar",
"back",
"into",
"FAB"
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/materialize/materialize.js#L4685-L4753 | train |
|
Cerealkillerway/materialNote | src/materialize/materialize.js | function( giveFocus ) {
// If we need to give focus, do it before changing states.
if ( giveFocus ) {
// ....ah yes! It would’ve been incomplete without a crazy workaround for IE :|
// The focus is triggered *after* the close has completed - causing it
// to open again. So unbind and rebind the event at the next tick.
P.$root.off( 'focus.toOpen' ).eq(0).focus()
setTimeout( function() {
P.$root.on( 'focus.toOpen', handleFocusToOpenEvent )
}, 0 )
}
// Remove the “active” class.
$ELEMENT.removeClass( CLASSES.active )
aria( ELEMENT, 'expanded', false )
// * A Firefox bug, when `html` has `overflow:hidden`, results in
// killing transitions :(. So remove the “opened” state on the next tick.
// Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289
setTimeout( function() {
// Remove the “opened” and “focused” class from the picker root.
P.$root.removeClass( CLASSES.opened + ' ' + CLASSES.focused )
aria( P.$root[0], 'hidden', true )
}, 0 )
// If it’s already closed, do nothing more.
if ( !STATE.open ) return P
// Set it as closed.
STATE.open = false
// Allow the page to scroll.
if ( IS_DEFAULT_THEME ) {
$html.
css( 'overflow', '' ).
css( 'padding-right', '-=' + getScrollbarWidth() )
}
// Unbind the document events.
$document.off( '.' + STATE.id )
// Trigger the queued “close” events.
return P.trigger( 'close' )
} | javascript | function( giveFocus ) {
// If we need to give focus, do it before changing states.
if ( giveFocus ) {
// ....ah yes! It would’ve been incomplete without a crazy workaround for IE :|
// The focus is triggered *after* the close has completed - causing it
// to open again. So unbind and rebind the event at the next tick.
P.$root.off( 'focus.toOpen' ).eq(0).focus()
setTimeout( function() {
P.$root.on( 'focus.toOpen', handleFocusToOpenEvent )
}, 0 )
}
// Remove the “active” class.
$ELEMENT.removeClass( CLASSES.active )
aria( ELEMENT, 'expanded', false )
// * A Firefox bug, when `html` has `overflow:hidden`, results in
// killing transitions :(. So remove the “opened” state on the next tick.
// Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289
setTimeout( function() {
// Remove the “opened” and “focused” class from the picker root.
P.$root.removeClass( CLASSES.opened + ' ' + CLASSES.focused )
aria( P.$root[0], 'hidden', true )
}, 0 )
// If it’s already closed, do nothing more.
if ( !STATE.open ) return P
// Set it as closed.
STATE.open = false
// Allow the page to scroll.
if ( IS_DEFAULT_THEME ) {
$html.
css( 'overflow', '' ).
css( 'padding-right', '-=' + getScrollbarWidth() )
}
// Unbind the document events.
$document.off( '.' + STATE.id )
// Trigger the queued “close” events.
return P.trigger( 'close' )
} | [
"function",
"(",
"giveFocus",
")",
"{",
"if",
"(",
"giveFocus",
")",
"{",
"P",
".",
"$root",
".",
"off",
"(",
"'focus.toOpen'",
")",
".",
"eq",
"(",
"0",
")",
".",
"focus",
"(",
")",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"P",
".",
"$root",
".",
"on",
"(",
"'focus.toOpen'",
",",
"handleFocusToOpenEvent",
")",
"}",
",",
"0",
")",
"}",
"$ELEMENT",
".",
"removeClass",
"(",
"CLASSES",
".",
"active",
")",
"aria",
"(",
"ELEMENT",
",",
"'expanded'",
",",
"false",
")",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"P",
".",
"$root",
".",
"removeClass",
"(",
"CLASSES",
".",
"opened",
"+",
"' '",
"+",
"CLASSES",
".",
"focused",
")",
"aria",
"(",
"P",
".",
"$root",
"[",
"0",
"]",
",",
"'hidden'",
",",
"true",
")",
"}",
",",
"0",
")",
"if",
"(",
"!",
"STATE",
".",
"open",
")",
"return",
"P",
"STATE",
".",
"open",
"=",
"false",
"if",
"(",
"IS_DEFAULT_THEME",
")",
"{",
"$html",
".",
"css",
"(",
"'overflow'",
",",
"''",
")",
".",
"css",
"(",
"'padding-right'",
",",
"'-='",
"+",
"getScrollbarWidth",
"(",
")",
")",
"}",
"$document",
".",
"off",
"(",
"'.'",
"+",
"STATE",
".",
"id",
")",
"return",
"P",
".",
"trigger",
"(",
"'close'",
")",
"}"
] | open
Close the picker | [
"open",
"Close",
"the",
"picker"
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/materialize/materialize.js#L5300-L5346 | train |
|
Cerealkillerway/materialNote | src/js/base/core/func.js | function (obj) {
var inverted = {};
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
inverted[obj[key]] = key;
}
}
return inverted;
} | javascript | function (obj) {
var inverted = {};
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
inverted[obj[key]] = key;
}
}
return inverted;
} | [
"function",
"(",
"obj",
")",
"{",
"var",
"inverted",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"key",
"in",
"obj",
")",
"{",
"if",
"(",
"obj",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"inverted",
"[",
"obj",
"[",
"key",
"]",
"]",
"=",
"key",
";",
"}",
"}",
"return",
"inverted",
";",
"}"
] | returns a copy of the object where the keys have become the values and the values the keys.
@param {Object} obj
@return {Object} | [
"returns",
"a",
"copy",
"of",
"the",
"object",
"where",
"the",
"keys",
"have",
"become",
"the",
"values",
"and",
"the",
"values",
"the",
"keys",
"."
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/js/base/core/func.js#L97-L105 | train |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.