query stringlengths 9 34k | document stringlengths 8 5.39M | negatives sequencelengths 19 20 | metadata dict |
|---|---|---|---|
Function that shuffles cards based on css order | function shuffle(cards) {
cards.forEach(card => {
let randomize = Math.floor(Math.random() * 10);
card.style.order = randomize;
});
} | [
"function shuffle() {\n cards.forEach(card => {\n let randPos = Math.floor(Math.random() * 12);\n card.style.order = randPos;\n })\n}",
"function shuffleCards() {\n removeCards();\n const shuffleArray = cards.sort(() => Math.random() - 0.5);\n displayCards(shuffleArray);\n styleCards();\n}... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
sort the deliquents by percentLogged | function percentLoggedDesc(a,b) {
if (a.percentLogged < b.percentLogged) {
return -1;
} else if (a.percentLogged > b.percentLogged) {
return 1;
} else {
return 0;
}
} | [
"function sortChartData() {\n chartData.sort((element1, element2) => {\n return element2.percentUnique - element1.percentUnique;\n });\n }",
"function filterAndSort(langs) {\n return langs.filter(function(e) { return e.language })\n .sort(function(a,b) { return b.percent - a.percent })\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If the debug window exists, then close it | function hideDebug() {
if (window.top.debugWindow && ! window.top.debugWindow.closed) {
window.top.debugWindow.close();
window.top.debugWindow = null;
}
} | [
"function closeHelpDesk() {\n window.close();\n}",
"function __zdbCloseWorkWindow(myWindowId){\n if(myWindowId == null) return false;\n application.activeWindow.close();\n application.activateWindow(myWindowId);\n return;\n}",
"function onClose() {\n\tdebug( 'Window closed. Dereferencing window obj... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
function that gets the number input | function getNumber() {
// store the input as an integer in num
num = parseInt(input.value());
} | [
"function getInputNumber(input){\n if(inputNum == undefined){\n inputNum = input;\n }else{\n inputNum = (inputNum * 10) + (input * 1);\n }\n calcDisplay.value = inputNum; \n }",
"function getInputNumber(id){\n const Amount = document.getElementById(id).v... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
$g by JoeSimmons. Supports ID, Class, and XPath (full with types) in one query Supports multiple id/class grabs in one query (split by spaces), and the ability to remove all nodes regardless of type See script page for syntax examples: | function $g(que, obj) {
if(!que || !(que=que.replace(/^\s+/,''))) return;
var obj=(obj?obj:({del:false,type:6,node:document})), r,
class_re=/^\.[A-Za-z0-9-_]/, id_re=/^\#[^\s]/, xp_re=/^\.?(\/\/|count|id)\(?[A-Za-z0-9\'\"]/;
if(!que || typeof que!='string' || que=='') return false;
else if(id_re.test(que)) {
var s=que.split(' '), r=new Array();
for(var n=0;n<s.length;n++) r.push(document.getElementById(s[n].substring(1)));
if(r.length==1) r=r[0];
} else if(xp_re.test(que)) {
r = document.evaluate(que,(obj['node']||document),null,(obj['type']||6),null);
switch((obj['type']||6)){case 1:r=r.numberValue;break;case 2: r=r.stringValue;break;case 3:r=r.booleanValue;break;case 8:case 9:r=r.singleNodeValue;break;}
} else if(class_re.test(que)) {
var expr='', s=que.split(' ');
for(var n=0;n<s.length && s[n].indexOf('.')==0;n++) expr+="@class='"+s[n].substring(1)+"' or ";
r = document.evaluate("//*["+expr.replace(/( or )$/,'')+"]",document,null,6,null);
if(r.snapshotLength==1) r=r.snapshotItem(0);
} else return null;
if(obj['del']===true && r) {
if(r.nodeType==1) r.parentNode.removeChild(r);
else if(r.snapshotItem) for(var i=r.snapshotLength-1; (item=r.snapshotItem(i)); i--) item.parentNode.removeChild(item);
else if(!r.snapshotItem) for(var i=r.length-1; i>=0; i--) if(r[i]) r[i].parentNode.removeChild(r[i]);
} else return r;
} | [
"function removeNodes (cssClass) {\n let selector = 'div.' + cssClass;\n let elements = document.querySelectorAll(selector);\n Array.prototype.forEach.call(elements, function (element) {\n document.body.removeChild(element);\n });\n}",
"function $g(que, O) {\r\nif(!que||typeof(que)!='string'||que==''||!(qu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Switch to the video to the right in the playlist from the current one. | function shiftRight() {
right_video = current_video - 1;
if(right_video < 1) {
right_video = vid_array.length-1;
}
switchToVideo(right_video);
} | [
"function shiftLeft() {\n\tleft_video = current_video + 1;\n\tif (left_video >= vid_array.length) {\n\t\tleft_video = 1;\n\t}\n\tswitchToVideo(left_video);\n}",
"function forwardButtonTrigger() {\n if (window.currentVideoSelectedForPlayback) {\n setCurrentlyPlaying(false)\n const currentNode = window.curre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
find closest panel and scroll to it | function findClosestPanel() {
var differences = [],
lowestDiff = Infinity
if (lowestDiff !== 0) {
// work out closest element
for (var i = 0; i < sections.length; i++) {
var difference = window.scrollY - sections[i].offsetTop
if (difference < 0) {
// turn any negative number into a positive
negativeDiff = true
difference = Math.abs(difference)
}
else {
negativeDiff = false
}
// if less than the last number, compare this with lowestDiff
// if smaller, updated difference and closestPanel
if (difference < lowestDiff) {
lowestDiff = difference
closestPanel = sections[i]
}
// briefly remove scrollInit
window.onscroll = null
scroll()
setTimeout(function(){
scrollInit()
}, 500)
}
}
} | [
"function panelScroll() {\n\t\"use strict\";\n\t$('.panel-group').one('shown.bs.collapse', function () {\n\t\tvar panelExpanded = $(this).find('.in');\n\t\t\n\t\t$('html, body').animate({\n\t\t\tscrollTop: panelExpanded.offset().top - 105\n\t\t}, 400);\n\t});\n}",
"function scrollSub(id){\n var topPos = document... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get date and time to start according to service window for current workrequest Calls WFR AbBldgOpsHelpDeskgetServiceWindowStartFromSLA Fills in date and time started | function getDateAndTimeStarted(){
var panel = View.panels.get('tool_form');
var wrId = panel.getFieldValue("wrtl.wr_id");
var result = {};
try {
result = Workflow.callMethod("AbBldgOpsHelpDesk-SLAService-getServiceWindowStartFromSLA", 'wr','wr_id',wrId);
}
catch (e) {
Workflow.handleError(e);
}
if (result.code == 'executed') {
var start = eval('(' + result.jsonExpression + ')');
//split isodate yyyy-mm-dd
temp = start.date_start.substring(1, start.date_start.length - 1).split("-");
date = FormattingDate(temp[2], temp[1], temp[0], strDateShortPattern);
//split isotime hh:mm:ss
tmp = start.time_start.substring(1, start.time_start.length - 1).split(":");
if (tmp[0] > 12) {
time = FormattingTime(tmp[0], tmp[1], "PM", timePattern);
}
else {
time = FormattingTime(tmp[0], tmp[1], "AM", timePattern);
}
$("tool_form_wrtl.date_start").value = date;
$("tool_form_wrtl.time_start").value = time;
$("Storedtool_form_wrtl.time_start").value = tmp[0] + ":" + tmp[1] + ".00.000";
}
else {
Workflow.handleError(result);
}
} | [
"function getDateAndTimeStarted(){\n var panel = View.getControl('', 'sched_wr_cf_cf_form');\n var wrId = panel.getFieldValue(\"wrcf.wr_id\");\n\n //kb:3024805\n\tvar result = {};\n\t//Retrieves service window start for SLA, next working day for this SLA after today ,file=\"ServiceLevelAgreementHandler\"\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates the jsTree for the given selector | function updateTreeStructure(selector) {
$.getJSON(tree_url + '?dir=' + dir_url, function(data) {
if (data.html) {
/*
* Remove the existing tree, update the content and build the new tree.
* Need to do it this way, otherwise the tree doesn't open to the correct folder.
*/
$(selector).jstree('destroy');
$(selector).html(data.html);
createTree(selector);
}
});
} | [
"updateTreeSelection_() {\n if (angular.isUndefined(this.tree_)) {\n return;\n }\n\n this.tree_['deselect_all']();\n this.tree_['select_node'](this.selectionName_);\n }",
"function updateJSTree( updateJSTreeAction ) {\n //alert(\"JSTreeAction : \" + updateJSTreeAction);\n\n var objClassVal... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parse the image (get the buffer and offset) into a new zipLoaderInstance | function parseImageFromZip(doSkipJPG, offsetInReader) {
return new Promise(function(resolve){
var zipLoaderInstance2 = ZipLoader.unzip( MLJ.core.Scene._zipFileArrayBuffer, doSkipJPG, offsetInReader );
resolve(zipLoaderInstance2);
});
} | [
"zipParser(blob){\n var zip = O.esri.zip;\n var _this = this;\n /*O.esri.*/zip.createReader(new /*O.esri.*/zip.BlobReader(blob), function (zipReader) {\n zipReader.getEntries(function (entries) {\n _this.initMap(entries);\n //if(entries)alert(\"TPK downloaded and unzipped!\");\n zip... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets if the provided structure is a JSDocableNodeStructure. | static isJSDocable(structure) {
switch (structure.kind) {
case StructureKind_1.StructureKind.Class:
case StructureKind_1.StructureKind.Constructor:
case StructureKind_1.StructureKind.ConstructorOverload:
case StructureKind_1.StructureKind.GetAccessor:
case StructureKind_1.StructureKind.Method:
case StructureKind_1.StructureKind.MethodOverload:
case StructureKind_1.StructureKind.Property:
case StructureKind_1.StructureKind.SetAccessor:
case StructureKind_1.StructureKind.Enum:
case StructureKind_1.StructureKind.EnumMember:
case StructureKind_1.StructureKind.Function:
case StructureKind_1.StructureKind.FunctionOverload:
case StructureKind_1.StructureKind.CallSignature:
case StructureKind_1.StructureKind.ConstructSignature:
case StructureKind_1.StructureKind.IndexSignature:
case StructureKind_1.StructureKind.Interface:
case StructureKind_1.StructureKind.MethodSignature:
case StructureKind_1.StructureKind.PropertySignature:
case StructureKind_1.StructureKind.Namespace:
case StructureKind_1.StructureKind.VariableStatement:
case StructureKind_1.StructureKind.TypeAlias:
return true;
default:
return false;
}
} | [
"static isJSDoc(structure) {\r\n return structure.kind === StructureKind_1.StructureKind.JSDoc;\r\n }",
"static isJSDocableNode(node) {\r\n switch (node.getKind()) {\r\n case typescript_1.SyntaxKind.ClassDeclaration:\r\n case typescript_1.SyntaxKind.ClassExpression:\r\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
do invoice transition on save activity | function saveActivityAndDoTransition() {
Y.doccirrus.jsonrpc.api.activity.read( { query: { _id: ko.unwrap( activities[0] ) } } )
.then(function( res ) {
var
data = res.data && res.data[0],
isCorrectTransition = false;
// checking if transition is allowed
if( 'INVOICEREF' === data.actType || 'INVOICE' === data.actType ) {
fsm[data.status].forEach(function( item ) {
if( item.transition === transition.transition ) {
isCorrectTransition = true;
}
});
}
if( !isCorrectTransition ) {
Y.doccirrus.DCWindow.notice( {
type: 'info',
message: i18n( 'InCaseMojit.ActivityDetailsVM.error.not_correct_status' ),
window: {
width: 'medium'
}
} );
return null;
}
return data;
}).then(function( res ) {
if( res ) {
// test transition
activityDetailsVM.saveAttachmentsAndTransition( transitionArgs )
.then(function( res ) {
return res;
}).then(function() {
roundReceiptAmount = parseFloat( currentActivity && currentActivity.amount ? currentActivity.amount() : 0 ).toFixed( 2 );
roundOutstanding = parseFloat( res.totalReceiptsOutstanding ).toFixed( 2 );
if ( currentActivity && ( roundReceiptAmount !== roundOutstanding ) && ( 'pay' === transition.transition || 'derecognize' === transition.transition ) ) {
willBalanceInvoice = true;
}
if( !willBalanceInvoice ) {
Y.doccirrus.api.activity
.transitionActivity( {
activity: res,
transitionDescription: transition,
letMeHandleErrors: true,
isTest: true
} );
}
}).then(function() {
if( !willBalanceInvoice ) {
res.notCreateNew = true;
return Y.doccirrus.api.activity
.transitionActivity( {
activity: res,
transitionDescription: transition,
letMeHandleErrors: true,
isTest: false
} ).then( function() {
var patientId = unwrap( currentPatient._id() );
if( patientId ) {
caseFolders.load( { patientId: patientId } );
}
});
}
});
}
}).fail( function( error ) {
Y.Array.invoke( Y.doccirrus.errorTable.getErrorsFromResponse( error ), 'display' );
} );
} | [
"function saveInvoiceNumber( itcb ) {\n // this step only applies to invoices\n if ( 'INVOICE' !== activity.actType && 'RECEIPT' !== activity.actType ) { return itcb( null ); }\n\n var\n setArgs = {\n 'conten... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Serialize the map of all resources in JSON | entitiesToJSON(){
let res = {
"id": this.id,
"resources": {}
};
(this.entitiesByID||{})::entries().forEach(([id,obj]) => res.resources[id] = (obj instanceof Resource) ? obj.toJSON(): obj);
return res;
} | [
"toJSON(depth = 0, initDepth = depth){\n\n /**\n * Converts a resource object into serializable JSON.\n * May fail to serialize recursive objects which are not instances of Resource\n * @param value - resource object\n * @param depth - depth of nested resources to output\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Byteswap an arbitrary buffer, flipping from one endian to the other, returning a new buffer with the resultant data | function byteswap64(buf) {
var swap = Buffer.alloc(buf.length);
for (var i = 0; i < buf.length; i++) {
swap[i] = buf[buf.length -1 - i];
}
return swap;
} | [
"function byteswap64(buf) {\n var swap = new Buffer(buf.length);\n for (var i = 0; i < buf.length; i++) {\n swap[i] = buf[buf.length -1 - i];\n }\n return swap;\n}",
"function to_little_endian(){\n\tbinary_input.reverse();\n\tbinary_key.reverse();\n}",
"function _swapEndian(val, length) {\n if (length <... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check that the selected values are allowed, IE we have resources named after it | function check_allowed() {
var material = $(select_div+" "+"#pd-material-type").find("option[selected]").attr("value");
var material_dict = get_material_dict(data, material);
var allowed = material_dict.allowed;
for(var i = 0; i < allowed.length; i++) {
var good = true;
var chem = allowed[i];
for(var j = 0; j < elements_nums.length; j++) {
if(chem[elements_nums[0]] != elements_nums[1]){
good = false;
break;
}
}
if(good){
return true
}
}
return false
} | [
"function validation_for_select_boxes(element){\n\tif(element.value != \"Default\")\n\t\treturn true;\n\telse{\n\t\talert(\"please select \"+ element.name);\n\t\treturn false;\n\t}\n}",
"function requireSelects ( form, requiredSelect ) {\n for ( var i = 0; i < requiredSelect.length; i++ ) {\n element = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
if this relates to the active query being executed then immediately send the cancel, else the query can be removed from the queue and never submitted to the driver. | function cancel (notify, callback) {
const qid = notify.getQueryId()
if (workQueue.length() === 0) {
setImmediate(() => {
callback(new Error(`Error: [msnodesql] cannot cancel query (empty queue) id ${qid}`))
})
return
}
const first = workQueue.first((_idx, currentItem) => {
if (currentItem.commandType !== driverCommandEnum.QUERY) {
return false
}
const args = currentItem.args
const not = args[0]
const currentQueryId = not.getQueryId()
return qid === currentQueryId
})
if (first) {
if (first.paused) {
execCancel(qid, first, () => {
freeStatement(notify, () => {
workQueue.dropItem(first)
callback(null)
})
})
} else {
execCancel(qid, first, callback)
}
} else {
setImmediate(() => {
callback(new Error(`Error: [msnodesql] cannot cancel query (not found) id ${qid}`))
})
}
} | [
"function cancelQuery() {\n// console.log(\"Cancelling query, currentQuery: \" + qwQueryService.currentQueryRequest);\n if (qwQueryService.currentQueryRequest != null) {\n var queryInFly = mnPendingQueryKeeper.getQueryInFly(qwQueryService.currentQueryRequest);\n queryInFly && queryInFly.canc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns memory usage as a percentage of total memory available (0100) | function getMemUsage() {
var total = os.totalmem(),
usage = total - os.freemem(),
perc = usage / total * 100;
return {
usage : usage
, total : total
, percentage : perc
};
} | [
"function calcPhysicalMem()\n{\n\tvar os = require('os');\n\n\tvar totalm = (os.totalmem() / 1024 / 1024).toFixed(2);\n\tvar freem = (os.freemem() / 1024 / 1024).toFixed(2) ;\n\tvar usedm = (totalm - freem);\n\n\n\tmetrics[\"phys_mem_used\"].value = usedm;\n\tmetrics[\"phys_mem_free\"].value = freem;\n\tmetrics[\"p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Evaluates, or attempts to evaluate, a ForInStatement | function evaluateForInStatement({ node, environment, evaluate, logger, reporting, typescript, statementTraversalStack }) {
// Compute the 'of' part
const expressionResult = evaluate.expression(node.expression, environment, statementTraversalStack);
// Ensure that the initializer is a proper VariableDeclarationList
if (!typescript.isVariableDeclarationList(node.initializer)) {
throw new UnexpectedNodeError({ node: node.initializer, typescript });
}
// Only 1 declaration is allowed in a ForOfStatement
else if (node.initializer.declarations.length > 1) {
throw new UnexpectedNodeError({ node: node.initializer.declarations[1], typescript });
}
for (const literal in expressionResult) {
// Prepare a lexical environment for the current iteration
const localEnvironment = cloneLexicalEnvironment(environment);
// Define a new binding for a break symbol within the environment
setInLexicalEnvironment({ env: localEnvironment, path: BREAK_SYMBOL, value: false, newBinding: true, reporting, node });
// Define a new binding for a continue symbol within the environment
setInLexicalEnvironment({ env: localEnvironment, path: CONTINUE_SYMBOL, value: false, newBinding: true, reporting, node });
// Evaluate the VariableDeclaration and manually pass in the current literal as the initializer for the variable assignment
evaluate.nodeWithArgument(node.initializer.declarations[0], localEnvironment, literal, statementTraversalStack);
// Evaluate the Statement
evaluate.statement(node.statement, localEnvironment);
// Check if a 'break' statement has been encountered and break if so
if (pathInLexicalEnvironmentEquals(node, localEnvironment, true, BREAK_SYMBOL)) {
logger.logBreak(node, typescript);
break;
}
else if (pathInLexicalEnvironmentEquals(node, localEnvironment, true, CONTINUE_SYMBOL)) {
logger.logContinue(node, typescript);
// noinspection UnnecessaryContinueJS
continue;
}
else if (pathInLexicalEnvironmentEquals(node, localEnvironment, true, RETURN_SYMBOL)) {
logger.logReturn(node, typescript);
return;
}
}
} | [
"function ForInStatement() {\n}",
"function evaluateForOfStatement({ node, environment, evaluate, logger, reporting, typescript, statementTraversalStack }) {\n // Compute the 'of' part\n const expressionResult = evaluate.expression(node.expression, environment, statementTraversalStack);\n // Ensure that ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
yesterday(thisDate) / /All my troubles seemed so far away. | function yesterday(thisDate) {
// adjustForLeapYears(thisDate);
if (thisDate[2]!=1) {
return [thisDate[0],thisDate[1],thisDate[2]-1];
} else if (thisDate[1]!=0) {
return [thisDate[0],thisDate[1]-1,monthLength[thisDate[1]-1]];
} else {
var tempYear = thisDate[0]-1;
adjustForLeapYears('yesterday()',tempYear);
return [tempYear,11,31];
}
} | [
"function getYesterday(){\n\treturn getDate(-1);\n}",
"getYesterday() {\n let yesterday = new Date();\n yesterday.setDate(yesterday.getDate() - 1);\n return this.format(yesterday);\n }",
"function dateForYesterday() {\n var date = new Date().toMidnight();\n date.setDate(date.getDate() - 1);\n retur... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 473