_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q17000
openLocation
train
function openLocation(location, noFlash) { var editor = EditorManager.getCurrentFullEditor(); var codeMirror = editor._codeMirror; if (typeof location === "number") { location = codeMirror.posFromIndex(location); } codeMirror.setCursor(location); editor.focus(...
javascript
{ "resource": "" }
q17001
open
train
function open(url, location, noFlash) { console.assert(url.substr(0, 7) === "file://", "Cannot open non-file URLs"); var result = new $.Deferred(); url = _urlWithoutQueryString(url); // Extract the path, also strip the third slash when on Windows var path = url.slice(brackets.p...
javascript
{ "resource": "" }
q17002
_onRemoteGoto
train
function _onRemoteGoto(event, res) { // res = {nodeId, name, value} var location, url = res.value; var matches = /^(.*):([^:]+)$/.exec(url); if (matches) { url = matches[1]; location = matches[2].split(","); if (location.length === 1) { ...
javascript
{ "resource": "" }
q17003
_removeQuotes
train
function _removeQuotes(src) { if (_isQuote(src[0]) && src[src.length - 1] === src[0]) { var q = src[0]; src = src.substr(1, src.length - 2); src = src.replace("\\" + q, q); } return src; }
javascript
{ "resource": "" }
q17004
_find
train
function _find(src, match, skip, quotes, comments) { if (typeof match === "string") { match = [match, match.length]; } if (skip === undefined) { skip = 0; } var i, activeQuote, isComment = false; for (i = skip; i < src.length; i++) { if...
javascript
{ "resource": "" }
q17005
_findEach
train
function _findEach(src, match, quotes, comments, callback) { var from = 0; var to; while (from < src.length) { to = _find(src, match, from, quotes, comments); if (to < 0) { to = src.length; } callback(src.substr(from, to - from)); ...
javascript
{ "resource": "" }
q17006
_findTag
train
function _findTag(src, skip) { var from, to, inc; from = _find(src, [/<[a-z!\/]/i, 2], skip); if (from < 0) { return null; } if (src.substr(from, 4) === "<!--") { // html comments to = _find(src, "-->", from + 4); inc = 3; }...
javascript
{ "resource": "" }
q17007
_extractAttributes
train
function _extractAttributes(content) { // remove the node name and the closing bracket and optional slash content = content.replace(/^<\S+\s*/, ""); content = content.replace(/\s*\/?>$/, ""); if (content.length === 0) { return; } // go through the items and ...
javascript
{ "resource": "" }
q17008
extractPayload
train
function extractPayload(content) { var payload = {}; if (content[0] !== "<") { // text payload.nodeType = 3; payload.nodeValue = content; } else if (content.substr(0, 4) === "<!--") { // comment payload.nodeType = 8; payloa...
javascript
{ "resource": "" }
q17009
eachNode
train
function eachNode(src, callback) { var index = 0; var text, range, length, payload; while (index < src.length) { // find the next tag range = _findTag(src, index); if (!range) { range = { from: src.length, length: 0 }; } ...
javascript
{ "resource": "" }
q17010
Document
train
function Document(file, initialTimestamp, rawText) { this.file = file; this.editable = !file.readOnly; this._updateLanguage(); this.refreshText(rawText, initialTimestamp, true); // List of full editors which are initialized as master editors for this doc. this._associated...
javascript
{ "resource": "" }
q17011
call
train
function call(method, varargs) { var argsArray = [_objectId, "_LD." + method]; if (arguments.length > 1) { argsArray = argsArray.concat(Array.prototype.slice.call(arguments, 1)); } return _call.apply(null, argsArray); }
javascript
{ "resource": "" }
q17012
InlineColorEditor
train
function InlineColorEditor(color, marker) { this._color = color; this._marker = marker; this._isOwnChange = false; this._isHostChange = false; this._origin = "+InlineColorEditor_" + (lastOriginId++); this._handleColorChange = this._handleColorChange.bind(this); t...
javascript
{ "resource": "" }
q17013
_colorSort
train
function _colorSort(a, b) { if (a.count === b.count) { return 0; } if (a.count > b.count) { return -1; } if (a.count < b.count) { return 1; } }
javascript
{ "resource": "" }
q17014
isValidDrop
train
function isValidDrop(items) { var i, len = items.length; for (i = 0; i < len; i++) { if (items[i].kind === "file") { var entry = items[i].webkitGetAsEntry(); if (entry.isFile) { // If any files are being dropped, this is a valid drop ...
javascript
{ "resource": "" }
q17015
stopURIListPropagation
train
function stopURIListPropagation(files, event) { var types = event.dataTransfer.types; if ((!files || !files.length) && types) { // We only want to check if a string of text was dragged into the editor types.forEach(function (value) { //Dragging text externally (d...
javascript
{ "resource": "" }
q17016
openDroppedFiles
train
function openDroppedFiles(paths) { var errorFiles = [], ERR_MULTIPLE_ITEMS_WITH_DIR = {}; return Async.doInParallel(paths, function (path, idx) { var result = new $.Deferred(); // Only open files. FileSystem.resolve(path, function (err, item) { ...
javascript
{ "resource": "" }
q17017
_calcScaling
train
function _calcScaling() { var $sb = _getScrollbar(editor); trackHt = $sb[0].offsetHeight; if (trackHt > 0) { trackOffset = getScrollbarTrackOffset(); trackHt -= trackOffset * 2; } else { // No scrollbar: use the height of the entire code content ...
javascript
{ "resource": "" }
q17018
_renderMarks
train
function _renderMarks(posArray) { var html = "", cm = editor._codeMirror, editorHt = cm.getScrollerElement().scrollHeight; // We've pretty much taken these vars and the getY function from CodeMirror's annotatescrollbar addon // https://github.com/codemirror/CodeMirror/bl...
javascript
{ "resource": "" }
q17019
setVisible
train
function setVisible(curEditor, visible) { // short-circuit no-ops if ((visible && curEditor === editor) || (!visible && !editor)) { return; } if (visible) { console.assert(!editor); editor = curEditor; // Don't support inline editors yet ...
javascript
{ "resource": "" }
q17020
addTickmarks
train
function addTickmarks(curEditor, posArray) { console.assert(editor === curEditor); marks = marks.concat(posArray); _renderMarks(posArray); }
javascript
{ "resource": "" }
q17021
maybeIdentifier
train
function maybeIdentifier(key) { var result = false, i; for (i = 0; i < key.length; i++) { result = Acorn.isIdentifierChar(key.charCodeAt(i)); if (!result) { break; } } return result; }
javascript
{ "resource": "" }
q17022
_closeSubtree
train
function _closeSubtree(directory) { directory = directory.delete("open"); var children = directory.get("children"); if (children) { children.keySeq().forEach(function (name) { var subdir = children.get(name); if (!isFile(subdir)) { ...
javascript
{ "resource": "" }
q17023
getRefs
train
function getRefs(fileInfo, offset) { ScopeManager.postMessage({ type: MessageIds.TERN_REFS, fileInfo: fileInfo, offset: offset }); return ScopeManager.addPendingRequest(fileInfo.name, offset, MessageIds.TERN_REFS); }
javascript
{ "resource": "" }
q17024
requestFindRefs
train
function requestFindRefs(session, document, offset) { if (!document || !session) { return; } var path = document.file.fullPath, fileInfo = { type: MessageIds.TERN_FILE_INFO_TYPE_FULL, name: path, offsetLines: 0, ...
javascript
{ "resource": "" }
q17025
handleFindRefs
train
function handleFindRefs (refsResp) { if (!refsResp || !refsResp.references || !refsResp.references.refs) { return; } var inlineWidget = EditorManager.getFocusedInlineWidget(), editor = EditorManager.getActiveEditor(), refs = refsResp.r...
javascript
{ "resource": "" }
q17026
requestFindReferences
train
function requestFindReferences(session, offset) { var response = requestFindRefs(session, session.editor.document, offset); if (response && response.hasOwnProperty("promise")) { response.promise.done(handleFindRefs).fail(function () { result.reject(); ...
javascript
{ "resource": "" }
q17027
_classForDocument
train
function _classForDocument(doc) { switch (doc.getLanguage().getId()) { case "less": case "scss": return CSSPreprocessorDocument; case "css": return CSSDocument; case "javascript": return exports.config.experimental ? JSDocument : null; ...
javascript
{ "resource": "" }
q17028
enableAgent
train
function enableAgent(name) { if (agents.hasOwnProperty(name) && !_enabledAgentNames.hasOwnProperty(name)) { _enabledAgentNames[name] = true; } }
javascript
{ "resource": "" }
q17029
_onError
train
function _onError(event, error, msgData) { var message; // Sometimes error.message is undefined if (!error.message) { console.warn("Expected a non-empty string in error.message, got this instead:", error.message); message = JSON.stringify(error); } else { ...
javascript
{ "resource": "" }
q17030
loadAgents
train
function loadAgents() { // If we're already loading agents return same promise if (_loadAgentsPromise) { return _loadAgentsPromise; } var result = new $.Deferred(), allAgentsPromise; _loadAgentsPromise = result.promise(); _setStatus(STATUS_LOADI...
javascript
{ "resource": "" }
q17031
onActiveEditorChange
train
function onActiveEditorChange(event, current, previous) { if (previous && previous.document && CSSUtils.isCSSPreprocessorFile(previous.document.file.fullPath)) { var prevDocUrl = _server && _server.pathToUrl(previous.document.file.fullPath); if (_relatedDocuments && _rel...
javascript
{ "resource": "" }
q17032
reconnect
train
function reconnect() { if (_loadAgentsPromise) { // Agents are already loading, so don't unload return _loadAgentsPromise; } unloadAgents(); // Clear any existing related documents before we reload the agents. // We need to recreate them for the reloaded...
javascript
{ "resource": "" }
q17033
_onConnect
train
function _onConnect(event) { // When the browser navigates away from the primary live document Inspector.Page.on("frameNavigated.livedev", _onFrameNavigated); // When the Inspector WebSocket disconnects unexpectedely Inspector.on("disconnect.livedev", _onDisconnect); _waitForIn...
javascript
{ "resource": "" }
q17034
_doLaunchAfterServerReady
train
function _doLaunchAfterServerReady(initialDoc) { // update status _setStatus(STATUS_CONNECTING); _createLiveDocumentForFrame(initialDoc); // start listening for requests _server.start(); // Install a one-time event handler when connected to the launcher page Ins...
javascript
{ "resource": "" }
q17035
open
train
function open(restart) { // If close() is still pending, wait for close to finish before opening if (_isPromisePending(_closeDeferred)) { return _closeDeferred.then(function () { return open(restart); }); } if (!restart) { // Return ex...
javascript
{ "resource": "" }
q17036
_onDocumentSaved
train
function _onDocumentSaved(event, doc) { if (!Inspector.connected() || !_server) { return; } var absolutePath = doc.file.fullPath, liveDocument = absolutePath && _server.get(absolutePath), liveEditingEnabled = liveDocument && liveDoc...
javascript
{ "resource": "" }
q17037
_onDirtyFlagChange
train
function _onDirtyFlagChange(event, doc) { if (doc && Inspector.connected() && _server && agents.network && agents.network.wasURLRequested(_server.pathToUrl(doc.file.fullPath))) { // Set status to out of sync if dirty. Otherwise, set it to active status. _setStatus(_docIsO...
javascript
{ "resource": "" }
q17038
init
train
function init(theConfig) { exports.config = theConfig; Inspector.on("error", _onError); Inspector.Inspector.on("detached", _onDetached); // Only listen for styleSheetAdded // We may get interim added/removed events when pushing incremental updates CSSAgent.on("styleShee...
javascript
{ "resource": "" }
q17039
addCommand
train
function addCommand() { CommandManager.register(Strings.CMD_HEALTH_DATA_STATISTICS, healthDataCmdId, handleHealthDataStatistics); menu.addMenuItem(healthDataCmdId, "", Menus.AFTER, Commands.HELP_SHOW_EXT_FOLDER); menu.addMenuDivider(Menus.AFTER, Commands.HELP_SHOW_EXT_FOLDER); }
javascript
{ "resource": "" }
q17040
getCurrentFullEditor
train
function getCurrentFullEditor() { var currentPath = MainViewManager.getCurrentlyViewedPath(MainViewManager.ACTIVE_PANE), doc = currentPath && DocumentManager.getOpenDocumentForPath(currentPath); return doc && doc._masterEditor; }
javascript
{ "resource": "" }
q17041
_restoreEditorViewState
train
function _restoreEditorViewState(editor) { // We want to ignore the current state of the editor, so don't call __getViewState() var viewState = ViewStateManager.getViewState(editor.document.file); if (viewState) { editor.restoreViewState(viewState); } }
javascript
{ "resource": "" }
q17042
_notifyActiveEditorChanged
train
function _notifyActiveEditorChanged(current) { // Skip if the Editor that gained focus was already the most recently focused editor. // This may happen e.g. if the window loses then regains focus. if (_lastFocusedEditor === current) { return; } var previous = _lastFoc...
javascript
{ "resource": "" }
q17043
_createEditorForDocument
train
function _createEditorForDocument(doc, makeMasterEditor, container, range, editorOptions) { var editor = new Editor(doc, makeMasterEditor, container, range, editorOptions); editor.on("focus", function () { _notifyActiveEditorChanged(editor); }); editor.on("beforeDestroy", f...
javascript
{ "resource": "" }
q17044
_toggleInlineWidget
train
function _toggleInlineWidget(providers, errorMsg) { var result = new $.Deferred(); var currentEditor = getCurrentFullEditor(); if (currentEditor) { var inlineWidget = currentEditor.getFocusedInlineWidget(); if (inlineWidget) { // an inline widget's edit...
javascript
{ "resource": "" }
q17045
registerInlineEditProvider
train
function registerInlineEditProvider(provider, priority) { if (priority === undefined) { priority = 0; } _insertProviderSorted(_inlineEditProviders, provider, priority); }
javascript
{ "resource": "" }
q17046
registerInlineDocsProvider
train
function registerInlineDocsProvider(provider, priority) { if (priority === undefined) { priority = 0; } _insertProviderSorted(_inlineDocsProviders, provider, priority); }
javascript
{ "resource": "" }
q17047
openDocument
train
function openDocument(doc, pane, editorOptions) { var perfTimerName = PerfUtils.markStart("EditorManager.openDocument():\t" + (!doc || doc.file.fullPath)); if (doc && pane) { _showEditor(doc, pane, editorOptions); } PerfUtils.addMeasurement(perfTimerName); }
javascript
{ "resource": "" }
q17048
_handleRemoveFromPaneView
train
function _handleRemoveFromPaneView(e, removedFiles) { var handleFileRemoved = function (file) { var doc = DocumentManager.getOpenDocumentForPath(file.fullPath); if (doc) { MainViewManager._destroyEditorIfNotNeeded(doc); } }; // when files are...
javascript
{ "resource": "" }
q17049
_setContextMenuItemsVisible
train
function _setContextMenuItemsVisible(enabled, items) { items.forEach(function (item) { CommandManager.get(item).setEnabled(enabled); }); }
javascript
{ "resource": "" }
q17050
_setMenuItemsVisible
train
function _setMenuItemsVisible() { var file = MainViewManager.getCurrentlyViewedFile(MainViewManager.ACTIVE_PANE); if (file) { file.exists(function (err, isPresent) { if (err) { return err; } _setContextMenuItemsVisible(isPre...
javascript
{ "resource": "" }
q17051
normalizeStats
train
function normalizeStats(nodeFsStats) { // current shell's stat method floors the mtime to the nearest thousand // which causes problems when comparing timestamps // so we have to round mtime to the nearest thousand too var mtime = Math.floor(nodeFsStats.mtime.getTime() / 1000) * 1000; // from shell...
javascript
{ "resource": "" }
q17052
_unwatchPath
train
function _unwatchPath(path) { var watcher = _watcherMap[path]; if (watcher) { try { watcher.close(); } catch (err) { console.warn("Failed to unwatch file " + path + ": " + (err && err.message)); } finally { delete _watcherMap[path]; } } }
javascript
{ "resource": "" }
q17053
unwatchPath
train
function unwatchPath(path) { Object.keys(_watcherMap).forEach(function (keyPath) { if (keyPath.indexOf(path) === 0) { _unwatchPath(keyPath); } }); }
javascript
{ "resource": "" }
q17054
watchPath
train
function watchPath(path, ignored) { if (_watcherMap.hasOwnProperty(path)) { return; } return _watcherImpl.watchPath(path, ignored, _watcherMap, _domainManager); }
javascript
{ "resource": "" }
q17055
_shortTitleForDocument
train
function _shortTitleForDocument(doc) { var fullPath = doc.file.fullPath; // If the document is untitled then return the filename, ("Untitled-n.ext"); // otherwise show the project-relative path if the file is inside the // current project or the full absolute path if it's not in the pro...
javascript
{ "resource": "" }
q17056
handleCurrentFileChange
train
function handleCurrentFileChange() { var newFile = MainViewManager.getCurrentlyViewedFile(MainViewManager.ACTIVE_PANE); if (newFile) { var newDocument = DocumentManager.getOpenDocumentForPath(newFile.fullPath); if (newDocument) { _currentTitlePath = _shortTitleF...
javascript
{ "resource": "" }
q17057
handleDirtyChange
train
function handleDirtyChange(event, changedDoc) { var currentDoc = DocumentManager.getCurrentDocument(); if (currentDoc && changedDoc.file.fullPath === currentDoc.file.fullPath) { _updateTitle(); } }
javascript
{ "resource": "" }
q17058
showFileOpenError
train
function showFileOpenError(name, path) { return Dialogs.showModalDialog( DefaultDialogs.DIALOG_ID_ERROR, Strings.ERROR_OPENING_FILE_TITLE, StringUtils.format( Strings.ERROR_OPENING_FILE, StringUtils.breakableUrl(path), FileUtils...
javascript
{ "resource": "" }
q17059
handleDocumentOpen
train
function handleDocumentOpen(commandData) { var result = new $.Deferred(); handleFileOpen(commandData) .done(function (file) { // if we succeeded with an open file // then we need to resolve that to a document. // getOpenDocumentForPath will r...
javascript
{ "resource": "" }
q17060
handleFileAddToWorkingSetAndOpen
train
function handleFileAddToWorkingSetAndOpen(commandData) { return handleFileOpen(commandData).done(function (file) { var paneId = (commandData && commandData.paneId) || MainViewManager.ACTIVE_PANE; MainViewManager.addToWorkingSet(paneId, file, commandData.index, commandData.forceRedraw); ...
javascript
{ "resource": "" }
q17061
_handleNewItemInProject
train
function _handleNewItemInProject(isFolder) { if (fileNewInProgress) { ProjectManager.forceFinishRename(); return; } fileNewInProgress = true; // Determine the directory to put the new file // If a file is currently selected in the tree, put it next to it....
javascript
{ "resource": "" }
q17062
createWithSuggestedName
train
function createWithSuggestedName(suggestedName) { return ProjectManager.createNewItem(baseDirEntry, suggestedName, false, isFolder) .always(function () { fileNewInProgress = false; }); }
javascript
{ "resource": "" }
q17063
doSave
train
function doSave(docToSave, force) { var result = new $.Deferred(), file = docToSave.file; function handleError(error) { _showSaveFileError(error, file.fullPath) .done(function () { result.reject(error); }); } f...
javascript
{ "resource": "" }
q17064
_doRevert
train
function _doRevert(doc, suppressError) { var result = new $.Deferred(); FileUtils.readAsText(doc.file) .done(function (text, readTimestamp) { doc.refreshText(text, readTimestamp); result.resolve(); }) .fail(function (error) { ...
javascript
{ "resource": "" }
q17065
_configureEditorAndResolve
train
function _configureEditorAndResolve() { var editor = EditorManager.getActiveEditor(); if (editor) { if (settings) { editor.setSelections(settings.selections); editor.setScrollPos(settings.scrollPos.x, settings.scrollPos....
javascript
{ "resource": "" }
q17066
openNewFile
train
function openNewFile() { var fileOpenPromise; if (FileViewController.getFileSelectionFocus() === FileViewController.PROJECT_MANAGER) { // If selection is in the tree, leave workingset unchanged - even if orig file is in the list fileOpenPromise = ...
javascript
{ "resource": "" }
q17067
handleFileSave
train
function handleFileSave(commandData) { var activeEditor = EditorManager.getActiveEditor(), activeDoc = activeEditor && activeEditor.document, doc = (commandData && commandData.doc) || activeDoc, settings; if (doc && !doc.isSaving) { if (doc.isUntitled()) ...
javascript
{ "resource": "" }
q17068
handleFileQuit
train
function handleFileQuit(commandData) { return _handleWindowGoingAway( commandData, function () { brackets.app.quit(); }, function () { // if fail, don't exit: user canceled (or asked us to save changes first, but we failed to do so)...
javascript
{ "resource": "" }
q17069
_disableCache
train
function _disableCache() { var result = new $.Deferred(); if (brackets.inBrowser) { result.resolve(); } else { var port = brackets.app.getRemoteDebuggingPort ? brackets.app.getRemoteDebuggingPort() : 9234; Inspector.getDebuggableWindows("127.0.0.1", port) ...
javascript
{ "resource": "" }
q17070
browserReload
train
function browserReload(href) { if (_isReloading) { return; } _isReloading = true; return CommandManager.execute(Commands.FILE_CLOSE_ALL, { promptOnly: true }).done(function () { // Give everyone a chance to save their state - but don't let any problems block ...
javascript
{ "resource": "" }
q17071
handleReload
train
function handleReload(loadWithoutExtensions) { var href = window.location.href, params = new UrlParams(); // Make sure the Reload Without User Extensions parameter is removed params.parse(); if (loadWithoutExtensions) { if (!params.get("reloadWithoutUserExts...
javascript
{ "resource": "" }
q17072
getTagAttributes
train
function getTagAttributes(tagName) { var tag; if (!cachedAttributes.hasOwnProperty(tagName)) { tag = tagData.tags[tagName]; cachedAttributes[tagName] = []; if (tag.attributes) { cachedAttributes[tagName] = cachedAttributes[tagName].concat(tag.attribu...
javascript
{ "resource": "" }
q17073
normalizeGradientExpressionForQuickview
train
function normalizeGradientExpressionForQuickview(expression) { if (expression.indexOf("px") > 0) { var paramStart = expression.indexOf("(") + 1, paramEnd = expression.lastIndexOf(")"), parameters = expression.substring(paramStart, paramEnd), ...
javascript
{ "resource": "" }
q17074
showPreview
train
function showPreview(editor, popover) { var token, cm; // Figure out which editor we are over if (!editor) { editor = getHoveredEditor(lastMousePos); } if (!editor || !editor._codeMirror) { hidePreview(); return; } cm = edito...
javascript
{ "resource": "" }
q17075
getFunctionArgs
train
function getFunctionArgs(args) { if (args.length > 2) { var fnArgs = new Array(args.length - 2), i; for (i = 2; i < args.length; ++i) { fnArgs[i - 2] = args[i]; } return fnArgs; } return []; }
javascript
{ "resource": "" }
q17076
postMessageToBrackets
train
function postMessageToBrackets(messageId, requester) { if(!requesters[requester]) { for (var key in requesters) { requester = key; break; } } var msgObj = { fn: messageId, args: getFunctionArgs(arguments), ...
javascript
{ "resource": "" }
q17077
validateChecksum
train
function validateChecksum(requester, params) { params = params || { filePath: installerPath, expectedChecksum: _updateParams.checksum }; var hash = crypto.createHash('sha256'), currentRequester = requester || ""; if (fs.existsSync(params.filePath)) {...
javascript
{ "resource": "" }
q17078
parseInstallerLog
train
function parseInstallerLog(filepath, searchstring, encoding, callback) { var line = ""; var searchFn = function searchFn(str) { var arr = str.split('\n'), lineNum, pos; for (lineNum = arr.length - 1; lineNum >= 0; lineNum--) { var s...
javascript
{ "resource": "" }
q17079
checkInstallerStatus
train
function checkInstallerStatus(requester, searchParams) { var installErrorStr = searchParams.installErrorStr, bracketsErrorStr = searchParams.bracketsErrorStr, updateDirectory = searchParams.updateDir, encoding = searchParams.encoding || "utf8", statusObj = ...
javascript
{ "resource": "" }
q17080
downloadInstaller
train
function downloadInstaller(requester, isInitialAttempt, updateParams) { updateParams = updateParams || _updateParams; var currentRequester = requester || ""; try { var ext = path.extname(updateParams.installerName); var localInstallerPath = path.resolve(updateDir, Date.no...
javascript
{ "resource": "" }
q17081
performCleanup
train
function performCleanup(requester, filesToCache, notifyBack) { var currentRequester = requester || ""; function filterFilesAndNotify(files, filesToCacheArr, notifyBackToBrackets) { files.forEach(function (file) { var fileExt = path.extname(path.basename(file)); ...
javascript
{ "resource": "" }
q17082
initializeState
train
function initializeState(requester, updateParams) { var currentRequester = requester || ""; _updateParams = updateParams; installerPath = path.resolve(updateDir, updateParams.installerName); postMessageToBrackets(MessageIds.NOTIFY_INITIALIZATION_COMPLETE, currentRequester); }
javascript
{ "resource": "" }
q17083
registerNodeFunctions
train
function registerNodeFunctions() { functionMap["node.downloadInstaller"] = downloadInstaller; functionMap["node.performCleanup"] = performCleanup; functionMap["node.validateInstaller"] = validateChecksum; functionMap["node.initializeState"] = initializeState; functionMap["node.ch...
javascript
{ "resource": "" }
q17084
initNode
train
function initNode(initObj) { var resetUpdateProgres = false; if (!isNodeDomainInitialized) { MessageIds = initObj.messageIds; updateDir = path.resolve(initObj.updateDir); logFilePath = path.resolve(updateDir, logFile); installStatusFilePath = path.resolve(...
javascript
{ "resource": "" }
q17085
receiveMessageFromBrackets
train
function receiveMessageFromBrackets(msgObj) { var argList = msgObj.args; argList.unshift(msgObj.requester || ""); functionMap[msgObj.fn].apply(null, argList); }
javascript
{ "resource": "" }
q17086
init
train
function init(domainManager) { if (!domainManager.hasDomain("AutoUpdate")) { domainManager.registerDomain("AutoUpdate", { major: 0, minor: 1 }); } _domainManager = domainManager; domainManager.registerCommand( "AutoUpda...
javascript
{ "resource": "" }
q17087
_buildPreferencesContext
train
function _buildPreferencesContext(fullPath) { return PreferencesManager._buildContext(fullPath, fullPath ? LanguageManager.getLanguageForPath(fullPath).getId() : undefined); }
javascript
{ "resource": "" }
q17088
_onKeyEvent
train
function _onKeyEvent(instance, event) { self.trigger("keyEvent", self, event); // deprecated self.trigger(event.type, self, event); return event.defaultPrevented; // false tells CodeMirror we didn't eat the event }
javascript
{ "resource": "" }
q17089
format
train
function format(str) { // arguments[0] is the base string, so we need to adjust index values here var args = [].slice.call(arguments, 1); return str.replace(/\{(\d+)\}/g, function (match, num) { return typeof args[num] !== "undefined" ? args[num] : match; }); }
javascript
{ "resource": "" }
q17090
breakableUrl
train
function breakableUrl(url) { // This is for displaying in UI, so always want it escaped var escUrl = _.escape(url); // Inject zero-width space character (U+200B) near path separators (/) to allow line breaking there return escUrl.replace( new RegExp(regexEscape("/"), "g"), ...
javascript
{ "resource": "" }
q17091
prettyPrintBytes
train
function prettyPrintBytes(bytes, precision) { var kilobyte = 1024, megabyte = kilobyte * 1024, gigabyte = megabyte * 1024, terabyte = gigabyte * 1024, returnVal = bytes; if ((bytes >= 0) && (bytes < kilobyte)) { returnVal = bytes + " B"; ...
javascript
{ "resource": "" }
q17092
truncate
train
function truncate(str, len) { // Truncate text to specified length if (str.length > len) { str = str.substr(0, len); // To prevent awkwardly truncating in the middle of a word, // attempt to truncate at the end of the last whole word var lastSpaceChar = s...
javascript
{ "resource": "" }
q17093
isInteger
train
function isInteger(value) { // Validate value is a number if (typeof (value) !== "number" || isNaN(parseInt(value, 10))) { return false; } // Validate number is an integer if (Math.floor(value) !== value) { return false; } // Validate num...
javascript
{ "resource": "" }
q17094
isIntegerInRange
train
function isIntegerInRange(value, lowerLimit, upperLimit) { // Validate value is an integer if (!isInteger(value)) { return false; } // Validate integer is in range var hasLowerLimt = (typeof (lowerLimit) === "number"), hasUpperLimt = (typeof (upperLimit) ...
javascript
{ "resource": "" }
q17095
TextRange
train
function TextRange(document, startLine, endLine) { this.startLine = startLine; this.endLine = endLine; this.document = document; document.addRef(); // store this-bound versions of listeners so we can remove them later this._handleDocumentChange = this._handleDocumentChan...
javascript
{ "resource": "" }
q17096
getInfoAtPos
train
function getInfoAtPos(editor, constPos) { // We're going to be changing pos a lot, but we don't want to mess up // the pos the caller passed in so we use extend to make a safe copy of it. var pos = $.extend({}, constPos), ctx = TokenUtils.getInitialContext(editor._codeMirror, pos), ...
javascript
{ "resource": "" }
q17097
getCompleteSelectors
train
function getCompleteSelectors(info, useGroup) { if (info.parentSelectors) { // Show parents with / separators. var completeSelectors = info.parentSelectors + " / "; if (useGroup && info.selectorGroup) { completeSelectors += info.selectorGroup; } el...
javascript
{ "resource": "" }
q17098
_getSelectorInFinalCSSForm
train
function _getSelectorInFinalCSSForm(selectorArray) { var finalSelectorArray = [""], parentSelectorArray = [], group = []; _.forEach(selectorArray, function (selector) { selector = _stripAtRules(selector); group = selector.split(","); parentSele...
javascript
{ "resource": "" }
q17099
_findAllMatchingSelectorsInText
train
function _findAllMatchingSelectorsInText(text, selector, mode) { var allSelectors = extractAllSelectors(text, mode); var result = []; // For now, we only match the rightmost simple selector, and ignore // attribute selectors and pseudo selectors var classOrIdSelector = selector[...
javascript
{ "resource": "" }