id
int32 0
58k
| repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
list | docstring
stringlengths 4
11.8k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 86
226
|
|---|---|---|---|---|---|---|---|---|---|---|---|
14,600
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/gcli/gcli/types/resource.js
|
Resource
|
function Resource(name, type, inline, element) {
this.name = name;
this.type = type;
this.inline = inline;
this.element = element;
}
|
javascript
|
function Resource(name, type, inline, element) {
this.name = name;
this.type = type;
this.inline = inline;
this.element = element;
}
|
[
"function",
"Resource",
"(",
"name",
",",
"type",
",",
"inline",
",",
"element",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"type",
"=",
"type",
";",
"this",
".",
"inline",
"=",
"inline",
";",
"this",
".",
"element",
"=",
"element",
";",
"}"
] |
Resources are bits of CSS and JavaScript that the page either includes
directly or as a result of reading some remote resource.
Resource should not be used directly, but instead through a sub-class like
CssResource or ScriptResource.
|
[
"Resources",
"are",
"bits",
"of",
"CSS",
"and",
"JavaScript",
"that",
"the",
"page",
"either",
"includes",
"directly",
"or",
"as",
"a",
"result",
"of",
"reading",
"some",
"remote",
"resource",
".",
"Resource",
"should",
"not",
"be",
"used",
"directly",
"but",
"instead",
"through",
"a",
"sub",
"-",
"class",
"like",
"CssResource",
"or",
"ScriptResource",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/gcli/gcli/types/resource.js#L80-L85
|
14,601
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/gcli/gcli/types/resource.js
|
dedupe
|
function dedupe(resources, onDupe) {
// first create a map of name->[array of resources with same name]
var names = {};
resources.forEach(function(scriptResource) {
if (names[scriptResource.name] == null) {
names[scriptResource.name] = [];
}
names[scriptResource.name].push(scriptResource);
});
// Call the de-dupe function for each set of dupes
Object.keys(names).forEach(function(name) {
var clones = names[name];
if (clones.length > 1) {
onDupe(clones);
}
});
}
|
javascript
|
function dedupe(resources, onDupe) {
// first create a map of name->[array of resources with same name]
var names = {};
resources.forEach(function(scriptResource) {
if (names[scriptResource.name] == null) {
names[scriptResource.name] = [];
}
names[scriptResource.name].push(scriptResource);
});
// Call the de-dupe function for each set of dupes
Object.keys(names).forEach(function(name) {
var clones = names[name];
if (clones.length > 1) {
onDupe(clones);
}
});
}
|
[
"function",
"dedupe",
"(",
"resources",
",",
"onDupe",
")",
"{",
"// first create a map of name->[array of resources with same name]",
"var",
"names",
"=",
"{",
"}",
";",
"resources",
".",
"forEach",
"(",
"function",
"(",
"scriptResource",
")",
"{",
"if",
"(",
"names",
"[",
"scriptResource",
".",
"name",
"]",
"==",
"null",
")",
"{",
"names",
"[",
"scriptResource",
".",
"name",
"]",
"=",
"[",
"]",
";",
"}",
"names",
"[",
"scriptResource",
".",
"name",
"]",
".",
"push",
"(",
"scriptResource",
")",
";",
"}",
")",
";",
"// Call the de-dupe function for each set of dupes",
"Object",
".",
"keys",
"(",
"names",
")",
".",
"forEach",
"(",
"function",
"(",
"name",
")",
"{",
"var",
"clones",
"=",
"names",
"[",
"name",
"]",
";",
"if",
"(",
"clones",
".",
"length",
">",
"1",
")",
"{",
"onDupe",
"(",
"clones",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Find resources with the same name, and call onDupe to change the names
|
[
"Find",
"resources",
"with",
"the",
"same",
"name",
"and",
"call",
"onDupe",
"to",
"change",
"the",
"names"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/gcli/gcli/types/resource.js#L225-L242
|
14,602
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/gcli/gcli/types/resource.js
|
ResourceType
|
function ResourceType(typeSpec) {
this.include = typeSpec.include;
if (this.include !== Resource.TYPE_SCRIPT &&
this.include !== Resource.TYPE_CSS &&
this.include != null) {
throw new Error('invalid include property: ' + this.include);
}
}
|
javascript
|
function ResourceType(typeSpec) {
this.include = typeSpec.include;
if (this.include !== Resource.TYPE_SCRIPT &&
this.include !== Resource.TYPE_CSS &&
this.include != null) {
throw new Error('invalid include property: ' + this.include);
}
}
|
[
"function",
"ResourceType",
"(",
"typeSpec",
")",
"{",
"this",
".",
"include",
"=",
"typeSpec",
".",
"include",
";",
"if",
"(",
"this",
".",
"include",
"!==",
"Resource",
".",
"TYPE_SCRIPT",
"&&",
"this",
".",
"include",
"!==",
"Resource",
".",
"TYPE_CSS",
"&&",
"this",
".",
"include",
"!=",
"null",
")",
"{",
"throw",
"new",
"Error",
"(",
"'invalid include property: '",
"+",
"this",
".",
"include",
")",
";",
"}",
"}"
] |
Use the Resource implementations to create a type based on SelectionType
|
[
"Use",
"the",
"Resource",
"implementations",
"to",
"create",
"a",
"type",
"based",
"on",
"SelectionType"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/gcli/gcli/types/resource.js#L247-L254
|
14,603
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/gcli/gcli/types/resource.js
|
function(node) {
for (var i = 0; i < ResourceCache._cached.length; i++) {
if (ResourceCache._cached[i].node === node) {
return ResourceCache._cached[i].resource;
}
}
return null;
}
|
javascript
|
function(node) {
for (var i = 0; i < ResourceCache._cached.length; i++) {
if (ResourceCache._cached[i].node === node) {
return ResourceCache._cached[i].resource;
}
}
return null;
}
|
[
"function",
"(",
"node",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"ResourceCache",
".",
"_cached",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"ResourceCache",
".",
"_cached",
"[",
"i",
"]",
".",
"node",
"===",
"node",
")",
"{",
"return",
"ResourceCache",
".",
"_cached",
"[",
"i",
"]",
".",
"resource",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Do we already have a resource that was created for the given node
|
[
"Do",
"we",
"already",
"have",
"a",
"resource",
"that",
"was",
"created",
"for",
"the",
"given",
"node"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/gcli/gcli/types/resource.js#L292-L299
|
|
14,604
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.core/web/orion/fileClient.js
|
function(deleteLocation, eventData) {
//return _doServiceCall(this._getService(deleteLocation), "deleteFile", arguments); //$NON-NLS-1$
return _doServiceCall(this._getService(deleteLocation), "deleteFile", arguments).then(function(result){ //$NON-NLS-0$
if(this.isEventFrozen()) {
if(!this._frozenEvent.deleted) {
this._frozenEvent.deleted = [];
}
this._frozenEvent.deleted.push({deleteLocation: deleteLocation, eventData: eventData});
} else {
this.dispatchEvent({ type: "Changed", deleted: [{deleteLocation: deleteLocation, eventData: eventData}]}); //$NON-NLS-0$
}
return result;
}.bind(this));
}
|
javascript
|
function(deleteLocation, eventData) {
//return _doServiceCall(this._getService(deleteLocation), "deleteFile", arguments); //$NON-NLS-1$
return _doServiceCall(this._getService(deleteLocation), "deleteFile", arguments).then(function(result){ //$NON-NLS-0$
if(this.isEventFrozen()) {
if(!this._frozenEvent.deleted) {
this._frozenEvent.deleted = [];
}
this._frozenEvent.deleted.push({deleteLocation: deleteLocation, eventData: eventData});
} else {
this.dispatchEvent({ type: "Changed", deleted: [{deleteLocation: deleteLocation, eventData: eventData}]}); //$NON-NLS-0$
}
return result;
}.bind(this));
}
|
[
"function",
"(",
"deleteLocation",
",",
"eventData",
")",
"{",
"//return _doServiceCall(this._getService(deleteLocation), \"deleteFile\", arguments); //$NON-NLS-1$",
"return",
"_doServiceCall",
"(",
"this",
".",
"_getService",
"(",
"deleteLocation",
")",
",",
"\"deleteFile\"",
",",
"arguments",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"//$NON-NLS-0$",
"if",
"(",
"this",
".",
"isEventFrozen",
"(",
")",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_frozenEvent",
".",
"deleted",
")",
"{",
"this",
".",
"_frozenEvent",
".",
"deleted",
"=",
"[",
"]",
";",
"}",
"this",
".",
"_frozenEvent",
".",
"deleted",
".",
"push",
"(",
"{",
"deleteLocation",
":",
"deleteLocation",
",",
"eventData",
":",
"eventData",
"}",
")",
";",
"}",
"else",
"{",
"this",
".",
"dispatchEvent",
"(",
"{",
"type",
":",
"\"Changed\"",
",",
"deleted",
":",
"[",
"{",
"deleteLocation",
":",
"deleteLocation",
",",
"eventData",
":",
"eventData",
"}",
"]",
"}",
")",
";",
"//$NON-NLS-0$",
"}",
"return",
"result",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] |
Deletes a file, directory, project or workspace.
@param {String} deleteLocation The location of the file or directory to delete.
@param {Object} eventData The event data that will be sent back.
@public
@returns {Deferred} A deferred that will delete the given file
|
[
"Deletes",
"a",
"file",
"directory",
"project",
"or",
"workspace",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.core/web/orion/fileClient.js#L454-L467
|
|
14,605
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.core/web/orion/fileClient.js
|
function(targetLocation, options, parentLocation) {
//return _doServiceCall(this._getService(targetLocation), "remoteImport", arguments); //$NON-NLS-1$
return _doServiceCall(this._getService(targetLocation), "remoteImport", arguments).then(function(result){ //$NON-NLS-0$
if(this.isEventFrozen()) {
if(!this._frozenEvent.copied) {
this._frozenEvent.copied = [];
}
this._frozenEvent.copied.push({target: parentLocation});
} else {
this.dispatchEvent({ type: "Changed", copied: [{target: parentLocation}]}); //$NON-NLS-0$
}
return result;
}.bind(this));
}
|
javascript
|
function(targetLocation, options, parentLocation) {
//return _doServiceCall(this._getService(targetLocation), "remoteImport", arguments); //$NON-NLS-1$
return _doServiceCall(this._getService(targetLocation), "remoteImport", arguments).then(function(result){ //$NON-NLS-0$
if(this.isEventFrozen()) {
if(!this._frozenEvent.copied) {
this._frozenEvent.copied = [];
}
this._frozenEvent.copied.push({target: parentLocation});
} else {
this.dispatchEvent({ type: "Changed", copied: [{target: parentLocation}]}); //$NON-NLS-0$
}
return result;
}.bind(this));
}
|
[
"function",
"(",
"targetLocation",
",",
"options",
",",
"parentLocation",
")",
"{",
"//return _doServiceCall(this._getService(targetLocation), \"remoteImport\", arguments); //$NON-NLS-1$",
"return",
"_doServiceCall",
"(",
"this",
".",
"_getService",
"(",
"targetLocation",
")",
",",
"\"remoteImport\"",
",",
"arguments",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"//$NON-NLS-0$",
"if",
"(",
"this",
".",
"isEventFrozen",
"(",
")",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_frozenEvent",
".",
"copied",
")",
"{",
"this",
".",
"_frozenEvent",
".",
"copied",
"=",
"[",
"]",
";",
"}",
"this",
".",
"_frozenEvent",
".",
"copied",
".",
"push",
"(",
"{",
"target",
":",
"parentLocation",
"}",
")",
";",
"}",
"else",
"{",
"this",
".",
"dispatchEvent",
"(",
"{",
"type",
":",
"\"Changed\"",
",",
"copied",
":",
"[",
"{",
"target",
":",
"parentLocation",
"}",
"]",
"}",
")",
";",
"//$NON-NLS-0$",
"}",
"return",
"result",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] |
Imports file and directory contents from another server
@param {String} targetLocation The location of the folder to import into
@param {Object} options An object specifying the import parameters
@public
@return {Deferred} A deferred for chaining events after the import completes
|
[
"Imports",
"file",
"and",
"directory",
"contents",
"from",
"another",
"server"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.core/web/orion/fileClient.js#L630-L643
|
|
14,606
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/folderView.js
|
FolderView
|
function FolderView(options) {
this.idCount = ID_COUNT++;
this._parent = options.parent;
this._metadata = options.metadata;
this.menuBar = options.menuBar;
this.fileClient = options.fileService;
this.progress = options.progressService;
this.serviceRegistry = options.serviceRegistry;
this.commandRegistry = options.commandRegistry;
this.contentTypeRegistry = options.contentTypeRegistry;
this.editorInputManager = options.inputManager;
this.preferences = options.preferences;
this.generalPrefs = new mGeneralPrefs.GeneralPreferences(this.preferences);
this.showProjectView = options.showProjectView === undefined ? !options.metadata.Projects : options.showProjectView;
this.showFolderNav = true;
this._init();
}
|
javascript
|
function FolderView(options) {
this.idCount = ID_COUNT++;
this._parent = options.parent;
this._metadata = options.metadata;
this.menuBar = options.menuBar;
this.fileClient = options.fileService;
this.progress = options.progressService;
this.serviceRegistry = options.serviceRegistry;
this.commandRegistry = options.commandRegistry;
this.contentTypeRegistry = options.contentTypeRegistry;
this.editorInputManager = options.inputManager;
this.preferences = options.preferences;
this.generalPrefs = new mGeneralPrefs.GeneralPreferences(this.preferences);
this.showProjectView = options.showProjectView === undefined ? !options.metadata.Projects : options.showProjectView;
this.showFolderNav = true;
this._init();
}
|
[
"function",
"FolderView",
"(",
"options",
")",
"{",
"this",
".",
"idCount",
"=",
"ID_COUNT",
"++",
";",
"this",
".",
"_parent",
"=",
"options",
".",
"parent",
";",
"this",
".",
"_metadata",
"=",
"options",
".",
"metadata",
";",
"this",
".",
"menuBar",
"=",
"options",
".",
"menuBar",
";",
"this",
".",
"fileClient",
"=",
"options",
".",
"fileService",
";",
"this",
".",
"progress",
"=",
"options",
".",
"progressService",
";",
"this",
".",
"serviceRegistry",
"=",
"options",
".",
"serviceRegistry",
";",
"this",
".",
"commandRegistry",
"=",
"options",
".",
"commandRegistry",
";",
"this",
".",
"contentTypeRegistry",
"=",
"options",
".",
"contentTypeRegistry",
";",
"this",
".",
"editorInputManager",
"=",
"options",
".",
"inputManager",
";",
"this",
".",
"preferences",
"=",
"options",
".",
"preferences",
";",
"this",
".",
"generalPrefs",
"=",
"new",
"mGeneralPrefs",
".",
"GeneralPreferences",
"(",
"this",
".",
"preferences",
")",
";",
"this",
".",
"showProjectView",
"=",
"options",
".",
"showProjectView",
"===",
"undefined",
"?",
"!",
"options",
".",
"metadata",
".",
"Projects",
":",
"options",
".",
"showProjectView",
";",
"this",
".",
"showFolderNav",
"=",
"true",
";",
"this",
".",
"_init",
"(",
")",
";",
"}"
] |
Constructs a new FolderView object.
@class
@name orion.FolderView
|
[
"Constructs",
"a",
"new",
"FolderView",
"object",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/folderView.js#L149-L165
|
14,607
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.javascript/web/javascript/ternPlugins/jsdoc.js
|
getEnvsListForTemplate
|
function getEnvsListForTemplate(){
var envsList = [];
var keys = Object.keys(allEnvs).sort();
for(var j = 0; j < keys.length; j++) {
var key = keys[j];
if(key !== 'builtin'){
envsList.push(key);
}
}
var templateList = {
type: "link", //$NON-NLS-0$
values: envsList,
title: 'ESLint Environments',
style: 'no_emphasis' //$NON-NLS-1$
};
return JSON.stringify(templateList).replace("}", "\\}");
}
|
javascript
|
function getEnvsListForTemplate(){
var envsList = [];
var keys = Object.keys(allEnvs).sort();
for(var j = 0; j < keys.length; j++) {
var key = keys[j];
if(key !== 'builtin'){
envsList.push(key);
}
}
var templateList = {
type: "link", //$NON-NLS-0$
values: envsList,
title: 'ESLint Environments',
style: 'no_emphasis' //$NON-NLS-1$
};
return JSON.stringify(templateList).replace("}", "\\}");
}
|
[
"function",
"getEnvsListForTemplate",
"(",
")",
"{",
"var",
"envsList",
"=",
"[",
"]",
";",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"allEnvs",
")",
".",
"sort",
"(",
")",
";",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"keys",
".",
"length",
";",
"j",
"++",
")",
"{",
"var",
"key",
"=",
"keys",
"[",
"j",
"]",
";",
"if",
"(",
"key",
"!==",
"'builtin'",
")",
"{",
"envsList",
".",
"push",
"(",
"key",
")",
";",
"}",
"}",
"var",
"templateList",
"=",
"{",
"type",
":",
"\"link\"",
",",
"//$NON-NLS-0$\r",
"values",
":",
"envsList",
",",
"title",
":",
"'ESLint Environments'",
",",
"style",
":",
"'no_emphasis'",
"//$NON-NLS-1$\r",
"}",
";",
"return",
"JSON",
".",
"stringify",
"(",
"templateList",
")",
".",
"replace",
"(",
"\"}\"",
",",
"\"\\\\}\"",
")",
";",
"}"
] |
Takes the allEnvs object, extracts the envs list and formats it into a JSON string that the template
computer will accept.
@returns {String} A string list of eslint environment directives that the template computer will accept
|
[
"Takes",
"the",
"allEnvs",
"object",
"extracts",
"the",
"envs",
"list",
"and",
"formats",
"it",
"into",
"a",
"JSON",
"string",
"that",
"the",
"template",
"computer",
"will",
"accept",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.javascript/web/javascript/ternPlugins/jsdoc.js#L540-L556
|
14,608
|
eclipse/orion.client
|
modules/orionode.debug.server/lib/adapterManager.js
|
createAdapter
|
function createAdapter(type) {
var adapterConfig = adaptersConfig[type];
if (!adapterConfig) {
throw new Error('Adapter type ' + type + ' has not been registered.');
}
return new DebugAdapter(adaptersConfig[type], adaptersCwd[type]);
}
|
javascript
|
function createAdapter(type) {
var adapterConfig = adaptersConfig[type];
if (!adapterConfig) {
throw new Error('Adapter type ' + type + ' has not been registered.');
}
return new DebugAdapter(adaptersConfig[type], adaptersCwd[type]);
}
|
[
"function",
"createAdapter",
"(",
"type",
")",
"{",
"var",
"adapterConfig",
"=",
"adaptersConfig",
"[",
"type",
"]",
";",
"if",
"(",
"!",
"adapterConfig",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Adapter type '",
"+",
"type",
"+",
"' has not been registered.'",
")",
";",
"}",
"return",
"new",
"DebugAdapter",
"(",
"adaptersConfig",
"[",
"type",
"]",
",",
"adaptersCwd",
"[",
"type",
"]",
")",
";",
"}"
] |
Create a new adapter instance
@param {string} type - adapter type name
@return {DebugAdapter}
|
[
"Create",
"a",
"new",
"adapter",
"instance"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/modules/orionode.debug.server/lib/adapterManager.js#L58-L64
|
14,609
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/crawler/searchCrawler.js
|
SearchCrawler
|
function SearchCrawler( serviceRegistry, fileClient, searchParams, options) {
this.registry= serviceRegistry;
this.fileClient = fileClient;
this.fileLocations = [];
this.fileSkeleton = [];
this._hitCounter = 0;
this._totalCounter = 0;
this._searchOnName = options && options.searchOnName;
this._buildSkeletonOnly = options && options.buildSkeletonOnly;
this._fetchChildrenCallBack = options && options.fetchChildrenCallBack;
this._searchParams = searchParams;
this.searchHelper = (this._searchOnName || this._buildSkeletonOnly || !this._searchParams) ? null: mSearchUtils.generateSearchHelper(searchParams);
this._location = searchParams ? searchParams.resource : options && options.location;
this._childrenLocation = options && options.childrenLocation ? options.childrenLocation : this._location;
this._reportOnCancel = options && options.reportOnCancel;
this._visitSingleFile = options && options.visitSingleFile;
if(!this._visitSingleFile) {
this._visitSingleFile = this._searchSingleFile;
}
this._cancelMessage = options && options.cancelMessage;
if(!this._cancelMessage) {
this._cancelMessage = messages["searchCancelled"];
}
this._cancelled = false;
this._statusService = this.registry.getService("orion.page.message"); //$NON-NLS-0$
this._progressService = this.registry.getService("orion.page.progress"); //$NON-NLS-0$
if(this._statusService) {
this._statusService.setCancelFunction(function() {this._cancelFileVisit();}.bind(this));
}
}
|
javascript
|
function SearchCrawler( serviceRegistry, fileClient, searchParams, options) {
this.registry= serviceRegistry;
this.fileClient = fileClient;
this.fileLocations = [];
this.fileSkeleton = [];
this._hitCounter = 0;
this._totalCounter = 0;
this._searchOnName = options && options.searchOnName;
this._buildSkeletonOnly = options && options.buildSkeletonOnly;
this._fetchChildrenCallBack = options && options.fetchChildrenCallBack;
this._searchParams = searchParams;
this.searchHelper = (this._searchOnName || this._buildSkeletonOnly || !this._searchParams) ? null: mSearchUtils.generateSearchHelper(searchParams);
this._location = searchParams ? searchParams.resource : options && options.location;
this._childrenLocation = options && options.childrenLocation ? options.childrenLocation : this._location;
this._reportOnCancel = options && options.reportOnCancel;
this._visitSingleFile = options && options.visitSingleFile;
if(!this._visitSingleFile) {
this._visitSingleFile = this._searchSingleFile;
}
this._cancelMessage = options && options.cancelMessage;
if(!this._cancelMessage) {
this._cancelMessage = messages["searchCancelled"];
}
this._cancelled = false;
this._statusService = this.registry.getService("orion.page.message"); //$NON-NLS-0$
this._progressService = this.registry.getService("orion.page.progress"); //$NON-NLS-0$
if(this._statusService) {
this._statusService.setCancelFunction(function() {this._cancelFileVisit();}.bind(this));
}
}
|
[
"function",
"SearchCrawler",
"(",
"serviceRegistry",
",",
"fileClient",
",",
"searchParams",
",",
"options",
")",
"{",
"this",
".",
"registry",
"=",
"serviceRegistry",
";",
"this",
".",
"fileClient",
"=",
"fileClient",
";",
"this",
".",
"fileLocations",
"=",
"[",
"]",
";",
"this",
".",
"fileSkeleton",
"=",
"[",
"]",
";",
"this",
".",
"_hitCounter",
"=",
"0",
";",
"this",
".",
"_totalCounter",
"=",
"0",
";",
"this",
".",
"_searchOnName",
"=",
"options",
"&&",
"options",
".",
"searchOnName",
";",
"this",
".",
"_buildSkeletonOnly",
"=",
"options",
"&&",
"options",
".",
"buildSkeletonOnly",
";",
"this",
".",
"_fetchChildrenCallBack",
"=",
"options",
"&&",
"options",
".",
"fetchChildrenCallBack",
";",
"this",
".",
"_searchParams",
"=",
"searchParams",
";",
"this",
".",
"searchHelper",
"=",
"(",
"this",
".",
"_searchOnName",
"||",
"this",
".",
"_buildSkeletonOnly",
"||",
"!",
"this",
".",
"_searchParams",
")",
"?",
"null",
":",
"mSearchUtils",
".",
"generateSearchHelper",
"(",
"searchParams",
")",
";",
"this",
".",
"_location",
"=",
"searchParams",
"?",
"searchParams",
".",
"resource",
":",
"options",
"&&",
"options",
".",
"location",
";",
"this",
".",
"_childrenLocation",
"=",
"options",
"&&",
"options",
".",
"childrenLocation",
"?",
"options",
".",
"childrenLocation",
":",
"this",
".",
"_location",
";",
"this",
".",
"_reportOnCancel",
"=",
"options",
"&&",
"options",
".",
"reportOnCancel",
";",
"this",
".",
"_visitSingleFile",
"=",
"options",
"&&",
"options",
".",
"visitSingleFile",
";",
"if",
"(",
"!",
"this",
".",
"_visitSingleFile",
")",
"{",
"this",
".",
"_visitSingleFile",
"=",
"this",
".",
"_searchSingleFile",
";",
"}",
"this",
".",
"_cancelMessage",
"=",
"options",
"&&",
"options",
".",
"cancelMessage",
";",
"if",
"(",
"!",
"this",
".",
"_cancelMessage",
")",
"{",
"this",
".",
"_cancelMessage",
"=",
"messages",
"[",
"\"searchCancelled\"",
"]",
";",
"}",
"this",
".",
"_cancelled",
"=",
"false",
";",
"this",
".",
"_statusService",
"=",
"this",
".",
"registry",
".",
"getService",
"(",
"\"orion.page.message\"",
")",
";",
"//$NON-NLS-0$",
"this",
".",
"_progressService",
"=",
"this",
".",
"registry",
".",
"getService",
"(",
"\"orion.page.progress\"",
")",
";",
"//$NON-NLS-0$",
"if",
"(",
"this",
".",
"_statusService",
")",
"{",
"this",
".",
"_statusService",
".",
"setCancelFunction",
"(",
"function",
"(",
")",
"{",
"this",
".",
"_cancelFileVisit",
"(",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}",
"}"
] |
SearchCrawler is an alternative when a file service does not provide the search API.
It assumes that the file client at least provides the fetchChildren and read APIs.
It basically visits all the children recursively under a given directory location and search on a given keyword, either literal or wild card.
@param {serviceRegistry} serviceRegistry The service registry.
@param {fileClient} fileClient The file client that provides fetchChildren and read APIs.
@param {Object} searchParams The search parameters.
@param {Object} options Not used yet. For future use.
@name orion.search.SearchCrawler
|
[
"SearchCrawler",
"is",
"an",
"alternative",
"when",
"a",
"file",
"service",
"does",
"not",
"provide",
"the",
"search",
"API",
".",
"It",
"assumes",
"that",
"the",
"file",
"client",
"at",
"least",
"provides",
"the",
"fetchChildren",
"and",
"read",
"APIs",
".",
"It",
"basically",
"visits",
"all",
"the",
"children",
"recursively",
"under",
"a",
"given",
"directory",
"location",
"and",
"search",
"on",
"a",
"given",
"keyword",
"either",
"literal",
"or",
"wild",
"card",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/crawler/searchCrawler.js#L28-L57
|
14,610
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/webui/tooltip.js
|
function(hideDelay) {
this._showByKB = undefined;
if (this._timeout) {
window.clearTimeout(this._timeout);
this._timeout = null;
}
if (!this.isShowing()) { //$NON-NLS-0$
return;
}
if (hideDelay === undefined) {
hideDelay = this._hideDelay;
}
var self = this;
this._timeout = window.setTimeout(function() {
self._tip.classList.remove("tooltipShowing"); //$NON-NLS-0$
self._tip.removeAttribute("style"); //$NON-NLS-0$
if (self._afterHiding) {
self._afterHiding();
}
}, hideDelay);
}
|
javascript
|
function(hideDelay) {
this._showByKB = undefined;
if (this._timeout) {
window.clearTimeout(this._timeout);
this._timeout = null;
}
if (!this.isShowing()) { //$NON-NLS-0$
return;
}
if (hideDelay === undefined) {
hideDelay = this._hideDelay;
}
var self = this;
this._timeout = window.setTimeout(function() {
self._tip.classList.remove("tooltipShowing"); //$NON-NLS-0$
self._tip.removeAttribute("style"); //$NON-NLS-0$
if (self._afterHiding) {
self._afterHiding();
}
}, hideDelay);
}
|
[
"function",
"(",
"hideDelay",
")",
"{",
"this",
".",
"_showByKB",
"=",
"undefined",
";",
"if",
"(",
"this",
".",
"_timeout",
")",
"{",
"window",
".",
"clearTimeout",
"(",
"this",
".",
"_timeout",
")",
";",
"this",
".",
"_timeout",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"this",
".",
"isShowing",
"(",
")",
")",
"{",
"//$NON-NLS-0$",
"return",
";",
"}",
"if",
"(",
"hideDelay",
"===",
"undefined",
")",
"{",
"hideDelay",
"=",
"this",
".",
"_hideDelay",
";",
"}",
"var",
"self",
"=",
"this",
";",
"this",
".",
"_timeout",
"=",
"window",
".",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"self",
".",
"_tip",
".",
"classList",
".",
"remove",
"(",
"\"tooltipShowing\"",
")",
";",
"//$NON-NLS-0$",
"self",
".",
"_tip",
".",
"removeAttribute",
"(",
"\"style\"",
")",
";",
"//$NON-NLS-0$",
"if",
"(",
"self",
".",
"_afterHiding",
")",
"{",
"self",
".",
"_afterHiding",
"(",
")",
";",
"}",
"}",
",",
"hideDelay",
")",
";",
"}"
] |
Hide the tooltip.
|
[
"Hide",
"the",
"tooltip",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/webui/tooltip.js#L371-L392
|
|
14,611
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/widgets/nav/common-nav.js
|
function(childrenLocation, force) {
return this.commandsRegistered.then(function() {
if (childrenLocation && typeof childrenLocation === "object") {
return this.load(childrenLocation);
}
return this.loadResourceList(childrenLocation, force);
}.bind(this));
}
|
javascript
|
function(childrenLocation, force) {
return this.commandsRegistered.then(function() {
if (childrenLocation && typeof childrenLocation === "object") {
return this.load(childrenLocation);
}
return this.loadResourceList(childrenLocation, force);
}.bind(this));
}
|
[
"function",
"(",
"childrenLocation",
",",
"force",
")",
"{",
"return",
"this",
".",
"commandsRegistered",
".",
"then",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"childrenLocation",
"&&",
"typeof",
"childrenLocation",
"===",
"\"object\"",
")",
"{",
"return",
"this",
".",
"load",
"(",
"childrenLocation",
")",
";",
"}",
"return",
"this",
".",
"loadResourceList",
"(",
"childrenLocation",
",",
"force",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] |
Loads the given children location as the root.
@param {String|Object} childrentLocation The childrenLocation or an object with a ChildrenLocation field.
@returns {orion.Promise}
|
[
"Loads",
"the",
"given",
"children",
"location",
"as",
"the",
"root",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/widgets/nav/common-nav.js#L190-L197
|
|
14,612
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/widgets/nav/common-nav.js
|
function(rowElement, model) {
NavigatorRenderer.prototype.rowCallback.call(this, rowElement, model);
// Search for the model in the Cut buffer and disable it if it is found
var cutBuffer = FileCommands.getCutBuffer();
if (cutBuffer) {
var matchFound = cutBuffer.some(function(cutModel) {
return FileCommands.isEqualToOrChildOf(model, cutModel);
});
if (matchFound) {
var navHandler = this.explorer.getNavHandler();
navHandler.disableItem(model);
}
}
}
|
javascript
|
function(rowElement, model) {
NavigatorRenderer.prototype.rowCallback.call(this, rowElement, model);
// Search for the model in the Cut buffer and disable it if it is found
var cutBuffer = FileCommands.getCutBuffer();
if (cutBuffer) {
var matchFound = cutBuffer.some(function(cutModel) {
return FileCommands.isEqualToOrChildOf(model, cutModel);
});
if (matchFound) {
var navHandler = this.explorer.getNavHandler();
navHandler.disableItem(model);
}
}
}
|
[
"function",
"(",
"rowElement",
",",
"model",
")",
"{",
"NavigatorRenderer",
".",
"prototype",
".",
"rowCallback",
".",
"call",
"(",
"this",
",",
"rowElement",
",",
"model",
")",
";",
"// Search for the model in the Cut buffer and disable it if it is found",
"var",
"cutBuffer",
"=",
"FileCommands",
".",
"getCutBuffer",
"(",
")",
";",
"if",
"(",
"cutBuffer",
")",
"{",
"var",
"matchFound",
"=",
"cutBuffer",
".",
"some",
"(",
"function",
"(",
"cutModel",
")",
"{",
"return",
"FileCommands",
".",
"isEqualToOrChildOf",
"(",
"model",
",",
"cutModel",
")",
";",
"}",
")",
";",
"if",
"(",
"matchFound",
")",
"{",
"var",
"navHandler",
"=",
"this",
".",
"explorer",
".",
"getNavHandler",
"(",
")",
";",
"navHandler",
".",
"disableItem",
"(",
"model",
")",
";",
"}",
"}",
"}"
] |
Overrides NavigatorRenderer.prototype.rowCallback
@param {Element} rowElement
|
[
"Overrides",
"NavigatorRenderer",
".",
"prototype",
".",
"rowCallback"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/widgets/nav/common-nav.js#L500-L515
|
|
14,613
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.core/web/lsp/utils.js
|
convertPositions
|
function convertPositions(deferred, editorContext, item, proposal) {
editorContext.getLineStart(item.textEdit.range.start.line).then(function(startLineOffset) {
var completionOffset = item.textEdit.range.start.character + startLineOffset;
for (var i = 0; i < proposal.positions.length; i++) {
proposal.positions[i].offset = completionOffset + proposal.positions[i].offset;
}
proposal.escapePosition = completionOffset + proposal.escapePosition;
deferred.resolve(proposal);
});
}
|
javascript
|
function convertPositions(deferred, editorContext, item, proposal) {
editorContext.getLineStart(item.textEdit.range.start.line).then(function(startLineOffset) {
var completionOffset = item.textEdit.range.start.character + startLineOffset;
for (var i = 0; i < proposal.positions.length; i++) {
proposal.positions[i].offset = completionOffset + proposal.positions[i].offset;
}
proposal.escapePosition = completionOffset + proposal.escapePosition;
deferred.resolve(proposal);
});
}
|
[
"function",
"convertPositions",
"(",
"deferred",
",",
"editorContext",
",",
"item",
",",
"proposal",
")",
"{",
"editorContext",
".",
"getLineStart",
"(",
"item",
".",
"textEdit",
".",
"range",
".",
"start",
".",
"line",
")",
".",
"then",
"(",
"function",
"(",
"startLineOffset",
")",
"{",
"var",
"completionOffset",
"=",
"item",
".",
"textEdit",
".",
"range",
".",
"start",
".",
"character",
"+",
"startLineOffset",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"proposal",
".",
"positions",
".",
"length",
";",
"i",
"++",
")",
"{",
"proposal",
".",
"positions",
"[",
"i",
"]",
".",
"offset",
"=",
"completionOffset",
"+",
"proposal",
".",
"positions",
"[",
"i",
"]",
".",
"offset",
";",
"}",
"proposal",
".",
"escapePosition",
"=",
"completionOffset",
"+",
"proposal",
".",
"escapePosition",
";",
"deferred",
".",
"resolve",
"(",
"proposal",
")",
";",
"}",
")",
";",
"}"
] |
Converts the linked mode and escape positional offsets of this
proposal to the full offset within the document.
@param {Deferred} deferred the promise for resolving the converted proposal
@param editorContext the current context of the editor
@param item the converted JSON item from the LSP
@param proposal the proposal to have its linked mode and escape positions converted
|
[
"Converts",
"the",
"linked",
"mode",
"and",
"escape",
"positional",
"offsets",
"of",
"this",
"proposal",
"to",
"the",
"full",
"offset",
"within",
"the",
"document",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.core/web/lsp/utils.js#L429-L438
|
14,614
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.core/web/requirejs/order.js
|
onFetchOnly
|
function onFetchOnly(node) {
var i, loadedNode, resourceName;
//Mark this script as loaded.
node.setAttribute('data-orderloaded', 'loaded');
//Cycle through waiting scripts. If the matching node for them
//is loaded, and is in the right order, add it to the DOM
//to execute the script.
for (i = 0; (resourceName = scriptWaiting[i]); i++) {
loadedNode = scriptNodes[resourceName];
if (loadedNode &&
loadedNode.getAttribute('data-orderloaded') === 'loaded') {
delete scriptNodes[resourceName];
require.addScriptToDom(loadedNode);
} else {
break;
}
}
//If just loaded some items, remove them from waiting.
if (i > 0) {
scriptWaiting.splice(0, i);
}
}
|
javascript
|
function onFetchOnly(node) {
var i, loadedNode, resourceName;
//Mark this script as loaded.
node.setAttribute('data-orderloaded', 'loaded');
//Cycle through waiting scripts. If the matching node for them
//is loaded, and is in the right order, add it to the DOM
//to execute the script.
for (i = 0; (resourceName = scriptWaiting[i]); i++) {
loadedNode = scriptNodes[resourceName];
if (loadedNode &&
loadedNode.getAttribute('data-orderloaded') === 'loaded') {
delete scriptNodes[resourceName];
require.addScriptToDom(loadedNode);
} else {
break;
}
}
//If just loaded some items, remove them from waiting.
if (i > 0) {
scriptWaiting.splice(0, i);
}
}
|
[
"function",
"onFetchOnly",
"(",
"node",
")",
"{",
"var",
"i",
",",
"loadedNode",
",",
"resourceName",
";",
"//Mark this script as loaded.",
"node",
".",
"setAttribute",
"(",
"'data-orderloaded'",
",",
"'loaded'",
")",
";",
"//Cycle through waiting scripts. If the matching node for them",
"//is loaded, and is in the right order, add it to the DOM",
"//to execute the script.",
"for",
"(",
"i",
"=",
"0",
";",
"(",
"resourceName",
"=",
"scriptWaiting",
"[",
"i",
"]",
")",
";",
"i",
"++",
")",
"{",
"loadedNode",
"=",
"scriptNodes",
"[",
"resourceName",
"]",
";",
"if",
"(",
"loadedNode",
"&&",
"loadedNode",
".",
"getAttribute",
"(",
"'data-orderloaded'",
")",
"===",
"'loaded'",
")",
"{",
"delete",
"scriptNodes",
"[",
"resourceName",
"]",
";",
"require",
".",
"addScriptToDom",
"(",
"loadedNode",
")",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"//If just loaded some items, remove them from waiting.",
"if",
"(",
"i",
">",
"0",
")",
"{",
"scriptWaiting",
".",
"splice",
"(",
"0",
",",
"i",
")",
";",
"}",
"}"
] |
Used for the IE case, where fetching is done by creating script element
but not attaching it to the DOM. This function will be called when that
happens so it can be determined when the node can be attached to the
DOM to trigger its execution.
|
[
"Used",
"for",
"the",
"IE",
"case",
"where",
"fetching",
"is",
"done",
"by",
"creating",
"script",
"element",
"but",
"not",
"attaching",
"it",
"to",
"the",
"DOM",
".",
"This",
"function",
"will",
"be",
"called",
"when",
"that",
"happens",
"so",
"it",
"can",
"be",
"determined",
"when",
"the",
"node",
"can",
"be",
"attached",
"to",
"the",
"DOM",
"to",
"trigger",
"its",
"execution",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.core/web/requirejs/order.js#L96-L120
|
14,615
|
eclipse/orion.client
|
modules/orionode/lib/cf/domains.js
|
getCFdomains
|
function getCFdomains(appTarget, UserId, targetUrl, domainName, defaultDomainMode) {
var domainArray = [];
var waitFor;
if (!defaultDomainMode){
waitFor = target.cfRequest("GET", UserId, targetUrl + appTarget.Org.entity.private_domains_url,
domainName ? {"q": "name:" + api.encodeURIComponent(domainName)}: null, null, null, null, appTarget);
}else{
waitFor = Promise.resolve();
}
return waitFor
.then(function(result) {
if (defaultDomainMode || !domainName || result.total_results < 1) {
var qs = domainName ? {
"q": "name:" + api.encodeURIComponent(domainName)
} : {
"page": "1",
"results-per-page": "1"
};
return target.cfRequest("GET", UserId, targetUrl + "/v2/shared_domains", qs, null, null, null, appTarget)
.then(function(result){
return result;
});
}
return result;
}).then(function(result) {
var domainResources = result.resources;
for (var k = 0; k < domainResources.length; k++) {
var domainJson = {
"Guid": domainResources[k].metadata.guid,
"DomainName": domainResources[k].entity.name,
"Type": "Domain"
};
domainArray.push(domainJson);
}
return domainArray;
});
}
|
javascript
|
function getCFdomains(appTarget, UserId, targetUrl, domainName, defaultDomainMode) {
var domainArray = [];
var waitFor;
if (!defaultDomainMode){
waitFor = target.cfRequest("GET", UserId, targetUrl + appTarget.Org.entity.private_domains_url,
domainName ? {"q": "name:" + api.encodeURIComponent(domainName)}: null, null, null, null, appTarget);
}else{
waitFor = Promise.resolve();
}
return waitFor
.then(function(result) {
if (defaultDomainMode || !domainName || result.total_results < 1) {
var qs = domainName ? {
"q": "name:" + api.encodeURIComponent(domainName)
} : {
"page": "1",
"results-per-page": "1"
};
return target.cfRequest("GET", UserId, targetUrl + "/v2/shared_domains", qs, null, null, null, appTarget)
.then(function(result){
return result;
});
}
return result;
}).then(function(result) {
var domainResources = result.resources;
for (var k = 0; k < domainResources.length; k++) {
var domainJson = {
"Guid": domainResources[k].metadata.guid,
"DomainName": domainResources[k].entity.name,
"Type": "Domain"
};
domainArray.push(domainJson);
}
return domainArray;
});
}
|
[
"function",
"getCFdomains",
"(",
"appTarget",
",",
"UserId",
",",
"targetUrl",
",",
"domainName",
",",
"defaultDomainMode",
")",
"{",
"var",
"domainArray",
"=",
"[",
"]",
";",
"var",
"waitFor",
";",
"if",
"(",
"!",
"defaultDomainMode",
")",
"{",
"waitFor",
"=",
"target",
".",
"cfRequest",
"(",
"\"GET\"",
",",
"UserId",
",",
"targetUrl",
"+",
"appTarget",
".",
"Org",
".",
"entity",
".",
"private_domains_url",
",",
"domainName",
"?",
"{",
"\"q\"",
":",
"\"name:\"",
"+",
"api",
".",
"encodeURIComponent",
"(",
"domainName",
")",
"}",
":",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"appTarget",
")",
";",
"}",
"else",
"{",
"waitFor",
"=",
"Promise",
".",
"resolve",
"(",
")",
";",
"}",
"return",
"waitFor",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"if",
"(",
"defaultDomainMode",
"||",
"!",
"domainName",
"||",
"result",
".",
"total_results",
"<",
"1",
")",
"{",
"var",
"qs",
"=",
"domainName",
"?",
"{",
"\"q\"",
":",
"\"name:\"",
"+",
"api",
".",
"encodeURIComponent",
"(",
"domainName",
")",
"}",
":",
"{",
"\"page\"",
":",
"\"1\"",
",",
"\"results-per-page\"",
":",
"\"1\"",
"}",
";",
"return",
"target",
".",
"cfRequest",
"(",
"\"GET\"",
",",
"UserId",
",",
"targetUrl",
"+",
"\"/v2/shared_domains\"",
",",
"qs",
",",
"null",
",",
"null",
",",
"null",
",",
"appTarget",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"return",
"result",
";",
"}",
")",
";",
"}",
"return",
"result",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"var",
"domainResources",
"=",
"result",
".",
"resources",
";",
"for",
"(",
"var",
"k",
"=",
"0",
";",
"k",
"<",
"domainResources",
".",
"length",
";",
"k",
"++",
")",
"{",
"var",
"domainJson",
"=",
"{",
"\"Guid\"",
":",
"domainResources",
"[",
"k",
"]",
".",
"metadata",
".",
"guid",
",",
"\"DomainName\"",
":",
"domainResources",
"[",
"k",
"]",
".",
"entity",
".",
"name",
",",
"\"Type\"",
":",
"\"Domain\"",
"}",
";",
"domainArray",
".",
"push",
"(",
"domainJson",
")",
";",
"}",
"return",
"domainArray",
";",
"}",
")",
";",
"}"
] |
This method can not accept req, because the req something has a body instead of a query.
|
[
"This",
"method",
"can",
"not",
"accept",
"req",
"because",
"the",
"req",
"something",
"has",
"a",
"body",
"instead",
"of",
"a",
"query",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/modules/orionode/lib/cf/domains.js#L64-L100
|
14,616
|
eclipse/orion.client
|
modules/orionode.debug.server/lib/debugFile.js
|
createDebugFileRouter
|
function createDebugFileRouter(adapterPool) {
var router = express.Router();
router.get('/:connectionId/:referenceId/*', function(req, res) {
if (!adapterPool.has(req.params.connectionId)) {
res.sendStatus(404);
return;
}
var adapter = adapterPool.get(req.params.connectionId);
adapter.sendRequest('source', { sourceReference: parseInt(req.params.referenceId, 10) }, TIMEOUT, function(response) {
if (!response.success) {
res.sendStatus(404);
return;
} else {
if (response.body.mimeType) {
res.setHeader('Content-Type', response.body.mimeType);
}
res.write(response.body.content);
res.end();
}
});
});
return router;
}
|
javascript
|
function createDebugFileRouter(adapterPool) {
var router = express.Router();
router.get('/:connectionId/:referenceId/*', function(req, res) {
if (!adapterPool.has(req.params.connectionId)) {
res.sendStatus(404);
return;
}
var adapter = adapterPool.get(req.params.connectionId);
adapter.sendRequest('source', { sourceReference: parseInt(req.params.referenceId, 10) }, TIMEOUT, function(response) {
if (!response.success) {
res.sendStatus(404);
return;
} else {
if (response.body.mimeType) {
res.setHeader('Content-Type', response.body.mimeType);
}
res.write(response.body.content);
res.end();
}
});
});
return router;
}
|
[
"function",
"createDebugFileRouter",
"(",
"adapterPool",
")",
"{",
"var",
"router",
"=",
"express",
".",
"Router",
"(",
")",
";",
"router",
".",
"get",
"(",
"'/:connectionId/:referenceId/*'",
",",
"function",
"(",
"req",
",",
"res",
")",
"{",
"if",
"(",
"!",
"adapterPool",
".",
"has",
"(",
"req",
".",
"params",
".",
"connectionId",
")",
")",
"{",
"res",
".",
"sendStatus",
"(",
"404",
")",
";",
"return",
";",
"}",
"var",
"adapter",
"=",
"adapterPool",
".",
"get",
"(",
"req",
".",
"params",
".",
"connectionId",
")",
";",
"adapter",
".",
"sendRequest",
"(",
"'source'",
",",
"{",
"sourceReference",
":",
"parseInt",
"(",
"req",
".",
"params",
".",
"referenceId",
",",
"10",
")",
"}",
",",
"TIMEOUT",
",",
"function",
"(",
"response",
")",
"{",
"if",
"(",
"!",
"response",
".",
"success",
")",
"{",
"res",
".",
"sendStatus",
"(",
"404",
")",
";",
"return",
";",
"}",
"else",
"{",
"if",
"(",
"response",
".",
"body",
".",
"mimeType",
")",
"{",
"res",
".",
"setHeader",
"(",
"'Content-Type'",
",",
"response",
".",
"body",
".",
"mimeType",
")",
";",
"}",
"res",
".",
"write",
"(",
"response",
".",
"body",
".",
"content",
")",
";",
"res",
".",
"end",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"return",
"router",
";",
"}"
] |
Create a router for debug file
@param {Map.<string, DebugAdapter>} adapterPool
@return {Express.Router}
|
[
"Create",
"a",
"router",
"for",
"debug",
"file"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/modules/orionode.debug.server/lib/debugFile.js#L23-L47
|
14,617
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.javascript/web/eslint/lib/rules/yoda.js
|
isParenWrapped
|
function isParenWrapped() {
var tokenBefore, tokenAfter;
return (tokenBefore = sourceCode.getTokenBefore(node)) &&
tokenBefore.value === "(" &&
(tokenAfter = sourceCode.getTokenAfter(node)) &&
tokenAfter.value === ")";
}
|
javascript
|
function isParenWrapped() {
var tokenBefore, tokenAfter;
return (tokenBefore = sourceCode.getTokenBefore(node)) &&
tokenBefore.value === "(" &&
(tokenAfter = sourceCode.getTokenAfter(node)) &&
tokenAfter.value === ")";
}
|
[
"function",
"isParenWrapped",
"(",
")",
"{",
"var",
"tokenBefore",
",",
"tokenAfter",
";",
"return",
"(",
"tokenBefore",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"node",
")",
")",
"&&",
"tokenBefore",
".",
"value",
"===",
"\"(\"",
"&&",
"(",
"tokenAfter",
"=",
"sourceCode",
".",
"getTokenAfter",
"(",
"node",
")",
")",
"&&",
"tokenAfter",
".",
"value",
"===",
"\")\"",
";",
"}"
] |
Determines whether node is wrapped in parentheses.
@returns {Boolean} Whether node is preceded immediately by an open
paren token and followed immediately by a close
paren token.
|
[
"Determines",
"whether",
"node",
"is",
"wrapped",
"in",
"parentheses",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/rules/yoda.js#L183-L190
|
14,618
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.javascript/web/eslint/lib/utils/source-code.js
|
findJSDocComment
|
function findJSDocComment(comments, line) {
if (comments) {
for (var i = comments.length - 1; i >= 0; i--) {
if (comments[i].type === "Block" && comments[i].value.charAt(0) === "*") {
if (line - comments[i].loc.end.line <= 1) {
return comments[i];
}
break;
}
}
}
return null;
}
|
javascript
|
function findJSDocComment(comments, line) {
if (comments) {
for (var i = comments.length - 1; i >= 0; i--) {
if (comments[i].type === "Block" && comments[i].value.charAt(0) === "*") {
if (line - comments[i].loc.end.line <= 1) {
return comments[i];
}
break;
}
}
}
return null;
}
|
[
"function",
"findJSDocComment",
"(",
"comments",
",",
"line",
")",
"{",
"if",
"(",
"comments",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"comments",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"comments",
"[",
"i",
"]",
".",
"type",
"===",
"\"Block\"",
"&&",
"comments",
"[",
"i",
"]",
".",
"value",
".",
"charAt",
"(",
"0",
")",
"===",
"\"*\"",
")",
"{",
"if",
"(",
"line",
"-",
"comments",
"[",
"i",
"]",
".",
"loc",
".",
"end",
".",
"line",
"<=",
"1",
")",
"{",
"return",
"comments",
"[",
"i",
"]",
";",
"}",
"break",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] |
Finds a JSDoc comment node in an array of comment nodes.
@param {ASTNode[]} comments The array of comment nodes to search.
@param {int} line Line number to look around
@returns {ASTNode} The node if found, null if not.
@private
|
[
"Finds",
"a",
"JSDoc",
"comment",
"node",
"in",
"an",
"array",
"of",
"comment",
"nodes",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/utils/source-code.js#L52-L67
|
14,619
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.javascript/web/eslint/lib/utils/source-code.js
|
function(node, beforeCount, afterCount) {
if (node) {
return (this.text !== null) ? this.text.slice(Math.max(node.range[0] - (beforeCount || 0), 0),
node.range[1] + (afterCount || 0)) : null;
}
return this.text;
}
|
javascript
|
function(node, beforeCount, afterCount) {
if (node) {
return (this.text !== null) ? this.text.slice(Math.max(node.range[0] - (beforeCount || 0), 0),
node.range[1] + (afterCount || 0)) : null;
}
return this.text;
}
|
[
"function",
"(",
"node",
",",
"beforeCount",
",",
"afterCount",
")",
"{",
"if",
"(",
"node",
")",
"{",
"return",
"(",
"this",
".",
"text",
"!==",
"null",
")",
"?",
"this",
".",
"text",
".",
"slice",
"(",
"Math",
".",
"max",
"(",
"node",
".",
"range",
"[",
"0",
"]",
"-",
"(",
"beforeCount",
"||",
"0",
")",
",",
"0",
")",
",",
"node",
".",
"range",
"[",
"1",
"]",
"+",
"(",
"afterCount",
"||",
"0",
")",
")",
":",
"null",
";",
"}",
"return",
"this",
".",
"text",
";",
"}"
] |
Gets the source code for the given node.
@param {ASTNode=} node The AST node to get the text for.
@param {int=} beforeCount The number of characters before the node to retrieve.
@param {int=} afterCount The number of characters after the node to retrieve.
@returns {string} The text representing the AST node.
|
[
"Gets",
"the",
"source",
"code",
"for",
"the",
"given",
"node",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/utils/source-code.js#L161-L168
|
|
14,620
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.javascript/web/eslint/lib/utils/source-code.js
|
function(node) {
var leadingComments = node.leadingComments || [],
trailingComments = node.trailingComments || [];
/*
* espree adds a "comments" array on Program nodes rather than
* leadingComments/trailingComments. Comments are only left in the
* Program node comments array if there is no executable code.
*/
if (node.type === "Program") {
if (node.body.length === 0) {
leadingComments = node.comments;
}
}
return {
leading: leadingComments,
trailing: trailingComments
};
}
|
javascript
|
function(node) {
var leadingComments = node.leadingComments || [],
trailingComments = node.trailingComments || [];
/*
* espree adds a "comments" array on Program nodes rather than
* leadingComments/trailingComments. Comments are only left in the
* Program node comments array if there is no executable code.
*/
if (node.type === "Program") {
if (node.body.length === 0) {
leadingComments = node.comments;
}
}
return {
leading: leadingComments,
trailing: trailingComments
};
}
|
[
"function",
"(",
"node",
")",
"{",
"var",
"leadingComments",
"=",
"node",
".",
"leadingComments",
"||",
"[",
"]",
",",
"trailingComments",
"=",
"node",
".",
"trailingComments",
"||",
"[",
"]",
";",
"/*\n * espree adds a \"comments\" array on Program nodes rather than\n * leadingComments/trailingComments. Comments are only left in the\n * Program node comments array if there is no executable code.\n */",
"if",
"(",
"node",
".",
"type",
"===",
"\"Program\"",
")",
"{",
"if",
"(",
"node",
".",
"body",
".",
"length",
"===",
"0",
")",
"{",
"leadingComments",
"=",
"node",
".",
"comments",
";",
"}",
"}",
"return",
"{",
"leading",
":",
"leadingComments",
",",
"trailing",
":",
"trailingComments",
"}",
";",
"}"
] |
Gets all comments for the given node.
@param {ASTNode} node The AST node to get the comments for.
@returns {Object} The list of comments indexed by their position.
@public
|
[
"Gets",
"all",
"comments",
"for",
"the",
"given",
"node",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/utils/source-code.js#L192-L212
|
|
14,621
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.javascript/web/eslint/lib/utils/source-code.js
|
function(node) {
var parent = node.parent;
switch (node.type) {
case "ClassDeclaration":
case "FunctionDeclaration":
if (looksLikeExport(parent)) {
return findJSDocComment(parent.leadingComments, parent.loc.start.line);
}
return findJSDocComment(node.leadingComments, node.loc.start.line);
case "ClassExpression":
return findJSDocComment(parent.parent.leadingComments, parent.parent.loc.start.line);
case "ArrowFunctionExpression":
case "FunctionExpression":
if (parent.type !== "CallExpression" && parent.type !== "NewExpression") {
while (parent && !parent.leadingComments && !/Function/.test(parent.type) && parent.type !== "MethodDefinition" && parent.type !== "Property") {
parent = parent.parent;
}
return parent && parent.type !== "FunctionDeclaration" ? findJSDocComment(parent.leadingComments, parent.loc.start.line) : null;
} else if (node.leadingComments) {
return findJSDocComment(node.leadingComments, node.loc.start.line);
}
// falls through
default:
return null;
}
}
|
javascript
|
function(node) {
var parent = node.parent;
switch (node.type) {
case "ClassDeclaration":
case "FunctionDeclaration":
if (looksLikeExport(parent)) {
return findJSDocComment(parent.leadingComments, parent.loc.start.line);
}
return findJSDocComment(node.leadingComments, node.loc.start.line);
case "ClassExpression":
return findJSDocComment(parent.parent.leadingComments, parent.parent.loc.start.line);
case "ArrowFunctionExpression":
case "FunctionExpression":
if (parent.type !== "CallExpression" && parent.type !== "NewExpression") {
while (parent && !parent.leadingComments && !/Function/.test(parent.type) && parent.type !== "MethodDefinition" && parent.type !== "Property") {
parent = parent.parent;
}
return parent && parent.type !== "FunctionDeclaration" ? findJSDocComment(parent.leadingComments, parent.loc.start.line) : null;
} else if (node.leadingComments) {
return findJSDocComment(node.leadingComments, node.loc.start.line);
}
// falls through
default:
return null;
}
}
|
[
"function",
"(",
"node",
")",
"{",
"var",
"parent",
"=",
"node",
".",
"parent",
";",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"case",
"\"ClassDeclaration\"",
":",
"case",
"\"FunctionDeclaration\"",
":",
"if",
"(",
"looksLikeExport",
"(",
"parent",
")",
")",
"{",
"return",
"findJSDocComment",
"(",
"parent",
".",
"leadingComments",
",",
"parent",
".",
"loc",
".",
"start",
".",
"line",
")",
";",
"}",
"return",
"findJSDocComment",
"(",
"node",
".",
"leadingComments",
",",
"node",
".",
"loc",
".",
"start",
".",
"line",
")",
";",
"case",
"\"ClassExpression\"",
":",
"return",
"findJSDocComment",
"(",
"parent",
".",
"parent",
".",
"leadingComments",
",",
"parent",
".",
"parent",
".",
"loc",
".",
"start",
".",
"line",
")",
";",
"case",
"\"ArrowFunctionExpression\"",
":",
"case",
"\"FunctionExpression\"",
":",
"if",
"(",
"parent",
".",
"type",
"!==",
"\"CallExpression\"",
"&&",
"parent",
".",
"type",
"!==",
"\"NewExpression\"",
")",
"{",
"while",
"(",
"parent",
"&&",
"!",
"parent",
".",
"leadingComments",
"&&",
"!",
"/",
"Function",
"/",
".",
"test",
"(",
"parent",
".",
"type",
")",
"&&",
"parent",
".",
"type",
"!==",
"\"MethodDefinition\"",
"&&",
"parent",
".",
"type",
"!==",
"\"Property\"",
")",
"{",
"parent",
"=",
"parent",
".",
"parent",
";",
"}",
"return",
"parent",
"&&",
"parent",
".",
"type",
"!==",
"\"FunctionDeclaration\"",
"?",
"findJSDocComment",
"(",
"parent",
".",
"leadingComments",
",",
"parent",
".",
"loc",
".",
"start",
".",
"line",
")",
":",
"null",
";",
"}",
"else",
"if",
"(",
"node",
".",
"leadingComments",
")",
"{",
"return",
"findJSDocComment",
"(",
"node",
".",
"leadingComments",
",",
"node",
".",
"loc",
".",
"start",
".",
"line",
")",
";",
"}",
"// falls through",
"default",
":",
"return",
"null",
";",
"}",
"}"
] |
Retrieves the JSDoc comment for a given node.
@param {ASTNode} node The AST node to get the comment for.
@returns {ASTNode} The BlockComment node containing the JSDoc for the
given node or null if not found.
@public
|
[
"Retrieves",
"the",
"JSDoc",
"comment",
"for",
"a",
"given",
"node",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/utils/source-code.js#L221-L254
|
|
14,622
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.javascript/web/eslint/lib/utils/source-code.js
|
function(index) {
var result = null,
resultParent = null,
traverser = new Traverser();
traverser.traverse(this.ast, {
enter: function(node, parent) {
if (node.range[0] <= index && index < node.range[1]) {
result = node;
resultParent = parent;
} else {
this.skip();
}
},
leave: function(node) {
if (node === result) {
this.break();
}
}
});
return result ? utils.mixin({parent: resultParent}, result) : null; // ORION
}
|
javascript
|
function(index) {
var result = null,
resultParent = null,
traverser = new Traverser();
traverser.traverse(this.ast, {
enter: function(node, parent) {
if (node.range[0] <= index && index < node.range[1]) {
result = node;
resultParent = parent;
} else {
this.skip();
}
},
leave: function(node) {
if (node === result) {
this.break();
}
}
});
return result ? utils.mixin({parent: resultParent}, result) : null; // ORION
}
|
[
"function",
"(",
"index",
")",
"{",
"var",
"result",
"=",
"null",
",",
"resultParent",
"=",
"null",
",",
"traverser",
"=",
"new",
"Traverser",
"(",
")",
";",
"traverser",
".",
"traverse",
"(",
"this",
".",
"ast",
",",
"{",
"enter",
":",
"function",
"(",
"node",
",",
"parent",
")",
"{",
"if",
"(",
"node",
".",
"range",
"[",
"0",
"]",
"<=",
"index",
"&&",
"index",
"<",
"node",
".",
"range",
"[",
"1",
"]",
")",
"{",
"result",
"=",
"node",
";",
"resultParent",
"=",
"parent",
";",
"}",
"else",
"{",
"this",
".",
"skip",
"(",
")",
";",
"}",
"}",
",",
"leave",
":",
"function",
"(",
"node",
")",
"{",
"if",
"(",
"node",
"===",
"result",
")",
"{",
"this",
".",
"break",
"(",
")",
";",
"}",
"}",
"}",
")",
";",
"return",
"result",
"?",
"utils",
".",
"mixin",
"(",
"{",
"parent",
":",
"resultParent",
"}",
",",
"result",
")",
":",
"null",
";",
"// ORION",
"}"
] |
Gets the deepest node containing a range index.
@param {int} index Range index of the desired node.
@returns {ASTNode} The node if found or null if not found.
|
[
"Gets",
"the",
"deepest",
"node",
"containing",
"a",
"range",
"index",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/utils/source-code.js#L261-L283
|
|
14,623
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.javascript/web/eslint/lib/utils/source-code.js
|
function(first, second) {
var text = this.text.slice(first.range[1], second.range[0]);
return /\s/.test(text.replace(/\/\*.*?\*\//g, ""));
}
|
javascript
|
function(first, second) {
var text = this.text.slice(first.range[1], second.range[0]);
return /\s/.test(text.replace(/\/\*.*?\*\//g, ""));
}
|
[
"function",
"(",
"first",
",",
"second",
")",
"{",
"var",
"text",
"=",
"this",
".",
"text",
".",
"slice",
"(",
"first",
".",
"range",
"[",
"1",
"]",
",",
"second",
".",
"range",
"[",
"0",
"]",
")",
";",
"return",
"/",
"\\s",
"/",
".",
"test",
"(",
"text",
".",
"replace",
"(",
"/",
"\\/\\*.*?\\*\\/",
"/",
"g",
",",
"\"\"",
")",
")",
";",
"}"
] |
Determines if two tokens have at least one whitespace character
between them. This completely disregards comments in making the
determination, so comments count as zero-length substrings.
@param {Token} first The token to check after.
@param {Token} second The token to check before.
@returns {boolean} True if there is only space between tokens, false
if there is anything other than whitespace between tokens.
|
[
"Determines",
"if",
"two",
"tokens",
"have",
"at",
"least",
"one",
"whitespace",
"character",
"between",
"them",
".",
"This",
"completely",
"disregards",
"comments",
"in",
"making",
"the",
"determination",
"so",
"comments",
"count",
"as",
"zero",
"-",
"length",
"substrings",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/utils/source-code.js#L294-L297
|
|
14,624
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.git/web/orion/git/uiUtil.js
|
createCompareWidget
|
function createCompareWidget(serviceRegistry, commandService, resource, hasConflicts, parentDivId, commandSpanId, editableInComparePage, gridRenderer, compareTo, toggleCommandSpanId,
preferencesService, saveCmdContainerId, saveCmdId, titleIds, containerModel, standAloneOptions) {
var setCompareSelection = function(diffProvider, cmdProvider, ignoreWhitespace, type) {
var comparerOptions = {
toggleable: true,
type: type, //$NON-NLS-0$ //From user preference
ignoreWhitespace: ignoreWhitespace,//From user reference
readonly: !saveCmdContainerId || !editableInComparePage,
hasConflicts: hasConflicts,
diffProvider: diffProvider,
resource: resource,
compareTo: compareTo,
saveLeft: { saveCmdContainerId: saveCmdContainerId, saveCmdId: saveCmdId, titleIds: titleIds},
editableInComparePage: editableInComparePage,
standAlone: (standAloneOptions ? true : false)
};
var viewOptions = {
parentDivId: parentDivId,
commandProvider: cmdProvider,
highlighters: (standAloneOptions ? standAloneOptions.highlighters : null)
};
var comparer = new mResourceComparer.ResourceComparer(serviceRegistry, commandService, comparerOptions, viewOptions);
if(containerModel) {
containerModel.resourceComparer = comparer;
containerModel.destroy = function() {
this.resourceComparer.destroy();
};
}
comparer.start().then(function(maxHeight) {
var vH = 420;
if (maxHeight < vH) {
vH = maxHeight;
}
var diffContainer = lib.node(parentDivId);
diffContainer.style.height = vH + "px"; //$NON-NLS-0$
});
};
var diffProvider = new mResourceComparer.DefaultDiffProvider(serviceRegistry);
var cmdProvider = new mCompareCommands.CompareCommandFactory({commandService: commandService, commandSpanId: commandSpanId, toggleCommandSpanId: toggleCommandSpanId, gridRenderer: gridRenderer, serviceRegistry: serviceRegistry});
var ignoreWhitespace = false;
var mode = "inline"; //$NON-NLS-0$
if (preferencesService) {
cmdProvider.addEventListener("compareConfigChanged", function(e) { //$NON-NLS-0$
var data;
switch (e.name) {
case "mode": //$NON-NLS-0$
data = {mode: e.value};
break;
case "ignoreWhiteSpace": //$NON-NLS-0$
data = {ignoreWhitespace: e.value};
break;
}
if (data) {
preferencesService.put("/git/compareSettings", data); //$NON-NLS-1$
}
}.bind(this));
preferencesService.get("/git/compareSettings").then(function(prefs) { //$NON-NLS-0$
ignoreWhitespace = prefs["ignoreWhitespace"] || ignoreWhitespace; //$NON-NLS-0$
mode = prefs["mode"] || mode; //$NON-NLS-0$
setCompareSelection(diffProvider, cmdProvider, ignoreWhitespace, mode);
});
} else {
setCompareSelection(diffProvider, cmdProvider, ignoreWhitespace, mode);
}
}
|
javascript
|
function createCompareWidget(serviceRegistry, commandService, resource, hasConflicts, parentDivId, commandSpanId, editableInComparePage, gridRenderer, compareTo, toggleCommandSpanId,
preferencesService, saveCmdContainerId, saveCmdId, titleIds, containerModel, standAloneOptions) {
var setCompareSelection = function(diffProvider, cmdProvider, ignoreWhitespace, type) {
var comparerOptions = {
toggleable: true,
type: type, //$NON-NLS-0$ //From user preference
ignoreWhitespace: ignoreWhitespace,//From user reference
readonly: !saveCmdContainerId || !editableInComparePage,
hasConflicts: hasConflicts,
diffProvider: diffProvider,
resource: resource,
compareTo: compareTo,
saveLeft: { saveCmdContainerId: saveCmdContainerId, saveCmdId: saveCmdId, titleIds: titleIds},
editableInComparePage: editableInComparePage,
standAlone: (standAloneOptions ? true : false)
};
var viewOptions = {
parentDivId: parentDivId,
commandProvider: cmdProvider,
highlighters: (standAloneOptions ? standAloneOptions.highlighters : null)
};
var comparer = new mResourceComparer.ResourceComparer(serviceRegistry, commandService, comparerOptions, viewOptions);
if(containerModel) {
containerModel.resourceComparer = comparer;
containerModel.destroy = function() {
this.resourceComparer.destroy();
};
}
comparer.start().then(function(maxHeight) {
var vH = 420;
if (maxHeight < vH) {
vH = maxHeight;
}
var diffContainer = lib.node(parentDivId);
diffContainer.style.height = vH + "px"; //$NON-NLS-0$
});
};
var diffProvider = new mResourceComparer.DefaultDiffProvider(serviceRegistry);
var cmdProvider = new mCompareCommands.CompareCommandFactory({commandService: commandService, commandSpanId: commandSpanId, toggleCommandSpanId: toggleCommandSpanId, gridRenderer: gridRenderer, serviceRegistry: serviceRegistry});
var ignoreWhitespace = false;
var mode = "inline"; //$NON-NLS-0$
if (preferencesService) {
cmdProvider.addEventListener("compareConfigChanged", function(e) { //$NON-NLS-0$
var data;
switch (e.name) {
case "mode": //$NON-NLS-0$
data = {mode: e.value};
break;
case "ignoreWhiteSpace": //$NON-NLS-0$
data = {ignoreWhitespace: e.value};
break;
}
if (data) {
preferencesService.put("/git/compareSettings", data); //$NON-NLS-1$
}
}.bind(this));
preferencesService.get("/git/compareSettings").then(function(prefs) { //$NON-NLS-0$
ignoreWhitespace = prefs["ignoreWhitespace"] || ignoreWhitespace; //$NON-NLS-0$
mode = prefs["mode"] || mode; //$NON-NLS-0$
setCompareSelection(diffProvider, cmdProvider, ignoreWhitespace, mode);
});
} else {
setCompareSelection(diffProvider, cmdProvider, ignoreWhitespace, mode);
}
}
|
[
"function",
"createCompareWidget",
"(",
"serviceRegistry",
",",
"commandService",
",",
"resource",
",",
"hasConflicts",
",",
"parentDivId",
",",
"commandSpanId",
",",
"editableInComparePage",
",",
"gridRenderer",
",",
"compareTo",
",",
"toggleCommandSpanId",
",",
"preferencesService",
",",
"saveCmdContainerId",
",",
"saveCmdId",
",",
"titleIds",
",",
"containerModel",
",",
"standAloneOptions",
")",
"{",
"var",
"setCompareSelection",
"=",
"function",
"(",
"diffProvider",
",",
"cmdProvider",
",",
"ignoreWhitespace",
",",
"type",
")",
"{",
"var",
"comparerOptions",
"=",
"{",
"toggleable",
":",
"true",
",",
"type",
":",
"type",
",",
"//$NON-NLS-0$ //From user preference",
"ignoreWhitespace",
":",
"ignoreWhitespace",
",",
"//From user reference",
"readonly",
":",
"!",
"saveCmdContainerId",
"||",
"!",
"editableInComparePage",
",",
"hasConflicts",
":",
"hasConflicts",
",",
"diffProvider",
":",
"diffProvider",
",",
"resource",
":",
"resource",
",",
"compareTo",
":",
"compareTo",
",",
"saveLeft",
":",
"{",
"saveCmdContainerId",
":",
"saveCmdContainerId",
",",
"saveCmdId",
":",
"saveCmdId",
",",
"titleIds",
":",
"titleIds",
"}",
",",
"editableInComparePage",
":",
"editableInComparePage",
",",
"standAlone",
":",
"(",
"standAloneOptions",
"?",
"true",
":",
"false",
")",
"}",
";",
"var",
"viewOptions",
"=",
"{",
"parentDivId",
":",
"parentDivId",
",",
"commandProvider",
":",
"cmdProvider",
",",
"highlighters",
":",
"(",
"standAloneOptions",
"?",
"standAloneOptions",
".",
"highlighters",
":",
"null",
")",
"}",
";",
"var",
"comparer",
"=",
"new",
"mResourceComparer",
".",
"ResourceComparer",
"(",
"serviceRegistry",
",",
"commandService",
",",
"comparerOptions",
",",
"viewOptions",
")",
";",
"if",
"(",
"containerModel",
")",
"{",
"containerModel",
".",
"resourceComparer",
"=",
"comparer",
";",
"containerModel",
".",
"destroy",
"=",
"function",
"(",
")",
"{",
"this",
".",
"resourceComparer",
".",
"destroy",
"(",
")",
";",
"}",
";",
"}",
"comparer",
".",
"start",
"(",
")",
".",
"then",
"(",
"function",
"(",
"maxHeight",
")",
"{",
"var",
"vH",
"=",
"420",
";",
"if",
"(",
"maxHeight",
"<",
"vH",
")",
"{",
"vH",
"=",
"maxHeight",
";",
"}",
"var",
"diffContainer",
"=",
"lib",
".",
"node",
"(",
"parentDivId",
")",
";",
"diffContainer",
".",
"style",
".",
"height",
"=",
"vH",
"+",
"\"px\"",
";",
"//$NON-NLS-0$",
"}",
")",
";",
"}",
";",
"var",
"diffProvider",
"=",
"new",
"mResourceComparer",
".",
"DefaultDiffProvider",
"(",
"serviceRegistry",
")",
";",
"var",
"cmdProvider",
"=",
"new",
"mCompareCommands",
".",
"CompareCommandFactory",
"(",
"{",
"commandService",
":",
"commandService",
",",
"commandSpanId",
":",
"commandSpanId",
",",
"toggleCommandSpanId",
":",
"toggleCommandSpanId",
",",
"gridRenderer",
":",
"gridRenderer",
",",
"serviceRegistry",
":",
"serviceRegistry",
"}",
")",
";",
"var",
"ignoreWhitespace",
"=",
"false",
";",
"var",
"mode",
"=",
"\"inline\"",
";",
"//$NON-NLS-0$",
"if",
"(",
"preferencesService",
")",
"{",
"cmdProvider",
".",
"addEventListener",
"(",
"\"compareConfigChanged\"",
",",
"function",
"(",
"e",
")",
"{",
"//$NON-NLS-0$",
"var",
"data",
";",
"switch",
"(",
"e",
".",
"name",
")",
"{",
"case",
"\"mode\"",
":",
"//$NON-NLS-0$",
"data",
"=",
"{",
"mode",
":",
"e",
".",
"value",
"}",
";",
"break",
";",
"case",
"\"ignoreWhiteSpace\"",
":",
"//$NON-NLS-0$",
"data",
"=",
"{",
"ignoreWhitespace",
":",
"e",
".",
"value",
"}",
";",
"break",
";",
"}",
"if",
"(",
"data",
")",
"{",
"preferencesService",
".",
"put",
"(",
"\"/git/compareSettings\"",
",",
"data",
")",
";",
"//$NON-NLS-1$",
"}",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"preferencesService",
".",
"get",
"(",
"\"/git/compareSettings\"",
")",
".",
"then",
"(",
"function",
"(",
"prefs",
")",
"{",
"//$NON-NLS-0$",
"ignoreWhitespace",
"=",
"prefs",
"[",
"\"ignoreWhitespace\"",
"]",
"||",
"ignoreWhitespace",
";",
"//$NON-NLS-0$",
"mode",
"=",
"prefs",
"[",
"\"mode\"",
"]",
"||",
"mode",
";",
"//$NON-NLS-0$",
"setCompareSelection",
"(",
"diffProvider",
",",
"cmdProvider",
",",
"ignoreWhitespace",
",",
"mode",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"setCompareSelection",
"(",
"diffProvider",
",",
"cmdProvider",
",",
"ignoreWhitespace",
",",
"mode",
")",
";",
"}",
"}"
] |
Create an embedded toggleable compare widget inside a given DIV.
@param {Object} serviceRegistry The serviceRegistry.
@param {Object} commandService The commandService.
@param {String} resoure The URL string of the complex URL which will be resolved by a diff provider into two file URLs and the unified diff.
@param {Boolean} hasConflicts The flag to indicate if the compare contains conflicts.
@param {Object} parentDivId The DIV node or string id of the DIV that holds the compare widget.
@param {String} commandSpanId The id of the DIV where all the commands of the compare view are rendered. "Open in compare page", "toggle", "navigate diff" commands will be rendered.
@param {Boolean} editableInComparePage The flag to indicate if opening compage will be editable on the left side. Default is false. Optional.
@param {Object} gridRenderer If all the commands have to be rendered as grids, especially inside a row of Orion explorer, this has to be provided. Optional.
@param {String} compareTo Optional. If the resource parameter is a simple file URL then this can be used as the second file URI to compare with.
@param {String} toggleCommandSpanId Optional. The id of the DIV where the "toggle" command will be rendered. If this parameter is defined, the "toggle" command will ONLY be rendered in this DIV.
|
[
"Create",
"an",
"embedded",
"toggleable",
"compare",
"widget",
"inside",
"a",
"given",
"DIV",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.git/web/orion/git/uiUtil.js#L116-L181
|
14,625
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/wizardUtils.js
|
function(defaultDecorateError){
return function(error, target){
if(error.HttpCode !== 401){
error = defaultDecorateError(error, target);
window.parent.postMessage(JSON.stringify({pageService: "orion.page.delegatedUI", //$NON-NLS-0$
source: "org.eclipse.orion.client.cf.deploy.uritemplate", //$NON-NLS-0$
status: error}), "*"); //$NON-NLS-0$
}
};
}
|
javascript
|
function(defaultDecorateError){
return function(error, target){
if(error.HttpCode !== 401){
error = defaultDecorateError(error, target);
window.parent.postMessage(JSON.stringify({pageService: "orion.page.delegatedUI", //$NON-NLS-0$
source: "org.eclipse.orion.client.cf.deploy.uritemplate", //$NON-NLS-0$
status: error}), "*"); //$NON-NLS-0$
}
};
}
|
[
"function",
"(",
"defaultDecorateError",
")",
"{",
"return",
"function",
"(",
"error",
",",
"target",
")",
"{",
"if",
"(",
"error",
".",
"HttpCode",
"!==",
"401",
")",
"{",
"error",
"=",
"defaultDecorateError",
"(",
"error",
",",
"target",
")",
";",
"window",
".",
"parent",
".",
"postMessage",
"(",
"JSON",
".",
"stringify",
"(",
"{",
"pageService",
":",
"\"orion.page.delegatedUI\"",
",",
"//$NON-NLS-0$",
"source",
":",
"\"org.eclipse.orion.client.cf.deploy.uritemplate\"",
",",
"//$NON-NLS-0$",
"status",
":",
"error",
"}",
")",
",",
"\"*\"",
")",
";",
"//$NON-NLS-0$",
"}",
"}",
";",
"}"
] |
Builds the post error.
|
[
"Builds",
"the",
"post",
"error",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/wizardUtils.js#L32-L41
|
|
14,626
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/wizardUtils.js
|
function(msg){
if (msg.HTML) {
// msg is HTML to be inserted directly
var span = document.createElement("span");
span.innerHTML = msg.Message;
return span;
}
msg = msg.Message || msg;
var chunks, msgNode;
try {
chunks = URLUtil.detectValidURL(msg);
} catch (e) {
/* contained a corrupt URL */
chunks = [];
}
if (chunks.length) {
msgNode = document.createDocumentFragment();
URLUtil.processURLSegments(msgNode, chunks);
/* all status links open in new window */
Array.prototype.forEach.call(lib.$$("a", msgNode), function(link) { //$NON-NLS-0$
link.target = "_blank"; //$NON-NLS-0$
});
}
return msgNode || document.createTextNode(msg);
}
|
javascript
|
function(msg){
if (msg.HTML) {
// msg is HTML to be inserted directly
var span = document.createElement("span");
span.innerHTML = msg.Message;
return span;
}
msg = msg.Message || msg;
var chunks, msgNode;
try {
chunks = URLUtil.detectValidURL(msg);
} catch (e) {
/* contained a corrupt URL */
chunks = [];
}
if (chunks.length) {
msgNode = document.createDocumentFragment();
URLUtil.processURLSegments(msgNode, chunks);
/* all status links open in new window */
Array.prototype.forEach.call(lib.$$("a", msgNode), function(link) { //$NON-NLS-0$
link.target = "_blank"; //$NON-NLS-0$
});
}
return msgNode || document.createTextNode(msg);
}
|
[
"function",
"(",
"msg",
")",
"{",
"if",
"(",
"msg",
".",
"HTML",
")",
"{",
"// msg is HTML to be inserted directly",
"var",
"span",
"=",
"document",
".",
"createElement",
"(",
"\"span\"",
")",
";",
"span",
".",
"innerHTML",
"=",
"msg",
".",
"Message",
";",
"return",
"span",
";",
"}",
"msg",
"=",
"msg",
".",
"Message",
"||",
"msg",
";",
"var",
"chunks",
",",
"msgNode",
";",
"try",
"{",
"chunks",
"=",
"URLUtil",
".",
"detectValidURL",
"(",
"msg",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"/* contained a corrupt URL */",
"chunks",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"chunks",
".",
"length",
")",
"{",
"msgNode",
"=",
"document",
".",
"createDocumentFragment",
"(",
")",
";",
"URLUtil",
".",
"processURLSegments",
"(",
"msgNode",
",",
"chunks",
")",
";",
"/* all status links open in new window */",
"Array",
".",
"prototype",
".",
"forEach",
".",
"call",
"(",
"lib",
".",
"$$",
"(",
"\"a\"",
",",
"msgNode",
")",
",",
"function",
"(",
"link",
")",
"{",
"//$NON-NLS-0$",
"link",
".",
"target",
"=",
"\"_blank\"",
";",
"//$NON-NLS-0$",
"}",
")",
";",
"}",
"return",
"msgNode",
"||",
"document",
".",
"createTextNode",
"(",
"msg",
")",
";",
"}"
] |
Parses the given message creating a decorated UI.
|
[
"Parses",
"the",
"given",
"message",
"creating",
"a",
"decorated",
"UI",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/wizardUtils.js#L54-L82
|
|
14,627
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/wizardUtils.js
|
function(message){
document.getElementById('messageLabel').classList.remove("errorMessage"); //$NON-NLS-0$//$NON-NLS-1$
document.getElementById('messageContainer').classList.remove("errorMessage"); //$NON-NLS-0$ //$NON-NLS-1$
lib.empty(document.getElementById('messageText')); //$NON-NLS-0$
document.getElementById('messageText').style.width = "100%"; //$NON-NLS-0$ //$NON-NLS-1$
document.getElementById('messageText').appendChild(WizardUtils.defaultParseMessage(message)); //$NON-NLS-0$
document.getElementById('messageButton').className = ""; //$NON-NLS-0$
document.getElementById('messageContainer').classList.add("showing"); //$NON-NLS-0$ //$NON-NLS-1$
}
|
javascript
|
function(message){
document.getElementById('messageLabel').classList.remove("errorMessage"); //$NON-NLS-0$//$NON-NLS-1$
document.getElementById('messageContainer').classList.remove("errorMessage"); //$NON-NLS-0$ //$NON-NLS-1$
lib.empty(document.getElementById('messageText')); //$NON-NLS-0$
document.getElementById('messageText').style.width = "100%"; //$NON-NLS-0$ //$NON-NLS-1$
document.getElementById('messageText').appendChild(WizardUtils.defaultParseMessage(message)); //$NON-NLS-0$
document.getElementById('messageButton').className = ""; //$NON-NLS-0$
document.getElementById('messageContainer').classList.add("showing"); //$NON-NLS-0$ //$NON-NLS-1$
}
|
[
"function",
"(",
"message",
")",
"{",
"document",
".",
"getElementById",
"(",
"'messageLabel'",
")",
".",
"classList",
".",
"remove",
"(",
"\"errorMessage\"",
")",
";",
"//$NON-NLS-0$//$NON-NLS-1$",
"document",
".",
"getElementById",
"(",
"'messageContainer'",
")",
".",
"classList",
".",
"remove",
"(",
"\"errorMessage\"",
")",
";",
"//$NON-NLS-0$ //$NON-NLS-1$",
"lib",
".",
"empty",
"(",
"document",
".",
"getElementById",
"(",
"'messageText'",
")",
")",
";",
"//$NON-NLS-0$",
"document",
".",
"getElementById",
"(",
"'messageText'",
")",
".",
"style",
".",
"width",
"=",
"\"100%\"",
";",
"//$NON-NLS-0$ //$NON-NLS-1$",
"document",
".",
"getElementById",
"(",
"'messageText'",
")",
".",
"appendChild",
"(",
"WizardUtils",
".",
"defaultParseMessage",
"(",
"message",
")",
")",
";",
"//$NON-NLS-0$",
"document",
".",
"getElementById",
"(",
"'messageButton'",
")",
".",
"className",
"=",
"\"\"",
";",
"//$NON-NLS-0$",
"document",
".",
"getElementById",
"(",
"'messageContainer'",
")",
".",
"classList",
".",
"add",
"(",
"\"showing\"",
")",
";",
"//$NON-NLS-0$ //$NON-NLS-1$",
"}"
] |
Displays the message bar panel with the given message.
|
[
"Displays",
"the",
"message",
"bar",
"panel",
"with",
"the",
"given",
"message",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/wizardUtils.js#L87-L97
|
|
14,628
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/wizardUtils.js
|
function(){
document.getElementById('messageLabel').classList.remove("errorMessage"); //$NON-NLS-0$ //$NON-NLS-1$
document.getElementById('messageContainer').classList.remove("errorMessage"); //$NON-NLS-0$ //$NON-NLS-1$
lib.empty(document.getElementById('messageText')); //$NON-NLS-0$
document.getElementById('messageContainer').classList.remove("showing"); //$NON-NLS-0$ //$NON-NLS-1$
}
|
javascript
|
function(){
document.getElementById('messageLabel').classList.remove("errorMessage"); //$NON-NLS-0$ //$NON-NLS-1$
document.getElementById('messageContainer').classList.remove("errorMessage"); //$NON-NLS-0$ //$NON-NLS-1$
lib.empty(document.getElementById('messageText')); //$NON-NLS-0$
document.getElementById('messageContainer').classList.remove("showing"); //$NON-NLS-0$ //$NON-NLS-1$
}
|
[
"function",
"(",
")",
"{",
"document",
".",
"getElementById",
"(",
"'messageLabel'",
")",
".",
"classList",
".",
"remove",
"(",
"\"errorMessage\"",
")",
";",
"//$NON-NLS-0$ //$NON-NLS-1$",
"document",
".",
"getElementById",
"(",
"'messageContainer'",
")",
".",
"classList",
".",
"remove",
"(",
"\"errorMessage\"",
")",
";",
"//$NON-NLS-0$ //$NON-NLS-1$",
"lib",
".",
"empty",
"(",
"document",
".",
"getElementById",
"(",
"'messageText'",
")",
")",
";",
"//$NON-NLS-0$",
"document",
".",
"getElementById",
"(",
"'messageContainer'",
")",
".",
"classList",
".",
"remove",
"(",
"\"showing\"",
")",
";",
"//$NON-NLS-0$ //$NON-NLS-1$",
"}"
] |
Hides the message bar panel.
|
[
"Hides",
"the",
"message",
"bar",
"panel",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/wizardUtils.js#L102-L107
|
|
14,629
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/wizardUtils.js
|
function(message){
document.getElementById('messageLabel').classList.add("errorMessage"); //$NON-NLS-0$ //$NON-NLS-1$
document.getElementById('messageContainer').classList.add("errorMessage"); //$NON-NLS-0$ //$NON-NLS-1$
lib.empty(document.getElementById('messageText')); //$NON-NLS-0$
document.getElementById('messageText').style.width = "calc(100% - 10px)"; //$NON-NLS-0$ //$NON-NLS-1$
document.getElementById('messageText').appendChild(WizardUtils.defaultParseMessage(message)); //$NON-NLS-0$
lib.empty(document.getElementById('messageButton')); //$NON-NLS-0$
document.getElementById('messageButton').className = "dismissButton core-sprite-close imageSprite"; //$NON-NLS-0$ //$NON-NLS-1$
document.getElementById('messageButton').onclick = WizardUtils.defaultHideMessage; //$NON-NLS-0$
document.getElementById('messageContainer').classList.add("showing"); //$NON-NLS-0$ //$NON-NLS-1$
}
|
javascript
|
function(message){
document.getElementById('messageLabel').classList.add("errorMessage"); //$NON-NLS-0$ //$NON-NLS-1$
document.getElementById('messageContainer').classList.add("errorMessage"); //$NON-NLS-0$ //$NON-NLS-1$
lib.empty(document.getElementById('messageText')); //$NON-NLS-0$
document.getElementById('messageText').style.width = "calc(100% - 10px)"; //$NON-NLS-0$ //$NON-NLS-1$
document.getElementById('messageText').appendChild(WizardUtils.defaultParseMessage(message)); //$NON-NLS-0$
lib.empty(document.getElementById('messageButton')); //$NON-NLS-0$
document.getElementById('messageButton').className = "dismissButton core-sprite-close imageSprite"; //$NON-NLS-0$ //$NON-NLS-1$
document.getElementById('messageButton').onclick = WizardUtils.defaultHideMessage; //$NON-NLS-0$
document.getElementById('messageContainer').classList.add("showing"); //$NON-NLS-0$ //$NON-NLS-1$
}
|
[
"function",
"(",
"message",
")",
"{",
"document",
".",
"getElementById",
"(",
"'messageLabel'",
")",
".",
"classList",
".",
"add",
"(",
"\"errorMessage\"",
")",
";",
"//$NON-NLS-0$ //$NON-NLS-1$",
"document",
".",
"getElementById",
"(",
"'messageContainer'",
")",
".",
"classList",
".",
"add",
"(",
"\"errorMessage\"",
")",
";",
"//$NON-NLS-0$ //$NON-NLS-1$",
"lib",
".",
"empty",
"(",
"document",
".",
"getElementById",
"(",
"'messageText'",
")",
")",
";",
"//$NON-NLS-0$",
"document",
".",
"getElementById",
"(",
"'messageText'",
")",
".",
"style",
".",
"width",
"=",
"\"calc(100% - 10px)\"",
";",
"//$NON-NLS-0$ //$NON-NLS-1$",
"document",
".",
"getElementById",
"(",
"'messageText'",
")",
".",
"appendChild",
"(",
"WizardUtils",
".",
"defaultParseMessage",
"(",
"message",
")",
")",
";",
"//$NON-NLS-0$",
"lib",
".",
"empty",
"(",
"document",
".",
"getElementById",
"(",
"'messageButton'",
")",
")",
";",
"//$NON-NLS-0$",
"document",
".",
"getElementById",
"(",
"'messageButton'",
")",
".",
"className",
"=",
"\"dismissButton core-sprite-close imageSprite\"",
";",
"//$NON-NLS-0$ //$NON-NLS-1$",
"document",
".",
"getElementById",
"(",
"'messageButton'",
")",
".",
"onclick",
"=",
"WizardUtils",
".",
"defaultHideMessage",
";",
"//$NON-NLS-0$",
"document",
".",
"getElementById",
"(",
"'messageContainer'",
")",
".",
"classList",
".",
"add",
"(",
"\"showing\"",
")",
";",
"//$NON-NLS-0$ //$NON-NLS-1$",
"}"
] |
Displays the message bar panel with the given error message.
|
[
"Displays",
"the",
"message",
"bar",
"panel",
"with",
"the",
"given",
"error",
"message",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/wizardUtils.js#L112-L124
|
|
14,630
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/wizardUtils.js
|
function(frameHolder){
var iframe = window.frameElement;
setTimeout(function(){
var titleBar = document.getElementById('titleBar'); //$NON-NLS-0$
titleBar.addEventListener('mousedown', function(e) { //$NON-NLS-0$
if (e.srcElement.id !== 'closeDialog') {
frameHolder._dragging = true;
if (titleBar.setCapture)
titleBar.setCapture();
frameHolder.start = {
screenX: e.screenX,
screenY: e.screenY
};
}
});
titleBar.addEventListener('mousemove', function(e) { //$NON-NLS-0$
if (frameHolder._dragging) {
var dx = e.screenX - frameHolder.start.screenX;
var dy = e.screenY - frameHolder.start.screenY;
frameHolder.start.screenX = e.screenX;
frameHolder.start.screenY = e.screenY;
var x = parseInt(iframe.style.left) + dx;
var y = parseInt(iframe.style.top) + dy;
iframe.style.left = x+"px"; //$NON-NLS-0$
iframe.style.top = y+"px"; //$NON-NLS-0$
}
});
titleBar.addEventListener('mouseup', function(e) { //$NON-NLS-0$
frameHolder._dragging = false;
if (titleBar.releaseCapture) {
titleBar.releaseCapture();
}
});
});
}
|
javascript
|
function(frameHolder){
var iframe = window.frameElement;
setTimeout(function(){
var titleBar = document.getElementById('titleBar'); //$NON-NLS-0$
titleBar.addEventListener('mousedown', function(e) { //$NON-NLS-0$
if (e.srcElement.id !== 'closeDialog') {
frameHolder._dragging = true;
if (titleBar.setCapture)
titleBar.setCapture();
frameHolder.start = {
screenX: e.screenX,
screenY: e.screenY
};
}
});
titleBar.addEventListener('mousemove', function(e) { //$NON-NLS-0$
if (frameHolder._dragging) {
var dx = e.screenX - frameHolder.start.screenX;
var dy = e.screenY - frameHolder.start.screenY;
frameHolder.start.screenX = e.screenX;
frameHolder.start.screenY = e.screenY;
var x = parseInt(iframe.style.left) + dx;
var y = parseInt(iframe.style.top) + dy;
iframe.style.left = x+"px"; //$NON-NLS-0$
iframe.style.top = y+"px"; //$NON-NLS-0$
}
});
titleBar.addEventListener('mouseup', function(e) { //$NON-NLS-0$
frameHolder._dragging = false;
if (titleBar.releaseCapture) {
titleBar.releaseCapture();
}
});
});
}
|
[
"function",
"(",
"frameHolder",
")",
"{",
"var",
"iframe",
"=",
"window",
".",
"frameElement",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"var",
"titleBar",
"=",
"document",
".",
"getElementById",
"(",
"'titleBar'",
")",
";",
"//$NON-NLS-0$",
"titleBar",
".",
"addEventListener",
"(",
"'mousedown'",
",",
"function",
"(",
"e",
")",
"{",
"//$NON-NLS-0$",
"if",
"(",
"e",
".",
"srcElement",
".",
"id",
"!==",
"'closeDialog'",
")",
"{",
"frameHolder",
".",
"_dragging",
"=",
"true",
";",
"if",
"(",
"titleBar",
".",
"setCapture",
")",
"titleBar",
".",
"setCapture",
"(",
")",
";",
"frameHolder",
".",
"start",
"=",
"{",
"screenX",
":",
"e",
".",
"screenX",
",",
"screenY",
":",
"e",
".",
"screenY",
"}",
";",
"}",
"}",
")",
";",
"titleBar",
".",
"addEventListener",
"(",
"'mousemove'",
",",
"function",
"(",
"e",
")",
"{",
"//$NON-NLS-0$",
"if",
"(",
"frameHolder",
".",
"_dragging",
")",
"{",
"var",
"dx",
"=",
"e",
".",
"screenX",
"-",
"frameHolder",
".",
"start",
".",
"screenX",
";",
"var",
"dy",
"=",
"e",
".",
"screenY",
"-",
"frameHolder",
".",
"start",
".",
"screenY",
";",
"frameHolder",
".",
"start",
".",
"screenX",
"=",
"e",
".",
"screenX",
";",
"frameHolder",
".",
"start",
".",
"screenY",
"=",
"e",
".",
"screenY",
";",
"var",
"x",
"=",
"parseInt",
"(",
"iframe",
".",
"style",
".",
"left",
")",
"+",
"dx",
";",
"var",
"y",
"=",
"parseInt",
"(",
"iframe",
".",
"style",
".",
"top",
")",
"+",
"dy",
";",
"iframe",
".",
"style",
".",
"left",
"=",
"x",
"+",
"\"px\"",
";",
"//$NON-NLS-0$",
"iframe",
".",
"style",
".",
"top",
"=",
"y",
"+",
"\"px\"",
";",
"//$NON-NLS-0$",
"}",
"}",
")",
";",
"titleBar",
".",
"addEventListener",
"(",
"'mouseup'",
",",
"function",
"(",
"e",
")",
"{",
"//$NON-NLS-0$",
"frameHolder",
".",
"_dragging",
"=",
"false",
";",
"if",
"(",
"titleBar",
".",
"releaseCapture",
")",
"{",
"titleBar",
".",
"releaseCapture",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}"
] |
Makes the current iframe draggable.
|
[
"Makes",
"the",
"current",
"iframe",
"draggable",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/wizardUtils.js#L129-L170
|
|
14,631
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/wizardUtils.js
|
function(options){
options = options || {};
var message = options.message || messages["loadingDeploymentSettings..."];
var showMessage = options.showMessage;
var hideMessage = options.hideMessage;
var preferences = options.preferences;
var fileClient = options.fileClient;
var resource = options.resource;
var d = new Deferred();
showMessage(message);
fileClient.read(resource.ContentLocation, true).then(
function(result){
mCfUtil.getTargets(preferences, result).then(function(result){
hideMessage();
d.resolve(result);
}, d.reject);
}, d.reject);
return d;
}
|
javascript
|
function(options){
options = options || {};
var message = options.message || messages["loadingDeploymentSettings..."];
var showMessage = options.showMessage;
var hideMessage = options.hideMessage;
var preferences = options.preferences;
var fileClient = options.fileClient;
var resource = options.resource;
var d = new Deferred();
showMessage(message);
fileClient.read(resource.ContentLocation, true).then(
function(result){
mCfUtil.getTargets(preferences, result).then(function(result){
hideMessage();
d.resolve(result);
}, d.reject);
}, d.reject);
return d;
}
|
[
"function",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"message",
"=",
"options",
".",
"message",
"||",
"messages",
"[",
"\"loadingDeploymentSettings...\"",
"]",
";",
"var",
"showMessage",
"=",
"options",
".",
"showMessage",
";",
"var",
"hideMessage",
"=",
"options",
".",
"hideMessage",
";",
"var",
"preferences",
"=",
"options",
".",
"preferences",
";",
"var",
"fileClient",
"=",
"options",
".",
"fileClient",
";",
"var",
"resource",
"=",
"options",
".",
"resource",
";",
"var",
"d",
"=",
"new",
"Deferred",
"(",
")",
";",
"showMessage",
"(",
"message",
")",
";",
"fileClient",
".",
"read",
"(",
"resource",
".",
"ContentLocation",
",",
"true",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"mCfUtil",
".",
"getTargets",
"(",
"preferences",
",",
"result",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"hideMessage",
"(",
")",
";",
"d",
".",
"resolve",
"(",
"result",
")",
";",
"}",
",",
"d",
".",
"reject",
")",
";",
"}",
",",
"d",
".",
"reject",
")",
";",
"return",
"d",
";",
"}"
] |
Summons the available clouds with the
default one if present.
|
[
"Summons",
"the",
"available",
"clouds",
"with",
"the",
"default",
"one",
"if",
"present",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/wizardUtils.js#L176-L199
|
|
14,632
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/treeModelIterator.js
|
function(from, to) {
var currentCursor = this.cursor();
var selection = this._scan(true, from, to);
if(!selection){
selection = this._scan(false, from, to);
}
this.setCursor(currentCursor);
return selection;
}
|
javascript
|
function(from, to) {
var currentCursor = this.cursor();
var selection = this._scan(true, from, to);
if(!selection){
selection = this._scan(false, from, to);
}
this.setCursor(currentCursor);
return selection;
}
|
[
"function",
"(",
"from",
",",
"to",
")",
"{",
"var",
"currentCursor",
"=",
"this",
".",
"cursor",
"(",
")",
";",
"var",
"selection",
"=",
"this",
".",
"_scan",
"(",
"true",
",",
"from",
",",
"to",
")",
";",
"if",
"(",
"!",
"selection",
")",
"{",
"selection",
"=",
"this",
".",
"_scan",
"(",
"false",
",",
"from",
",",
"to",
")",
";",
"}",
"this",
".",
"setCursor",
"(",
"currentCursor",
")",
";",
"return",
"selection",
";",
"}"
] |
Iterate from the current cursor
@param {object} from the model object that the selection range starts from. Will be included in the return array.
@param {object} to the model object that the selection range ends at. Will be included in the return array.
@returns {Array} The selection of models in the array.
|
[
"Iterate",
"from",
"the",
"current",
"cursor"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/treeModelIterator.js#L225-L233
|
|
14,633
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/treeModelIterator.js
|
function(forward, roundTrip) {
var topSibling = this._findSibling(this._getTopLevelParent(this.cursor()), forward);
if(topSibling){
this.setCursor(topSibling);
} else if(roundTrip && this.firstLevelChildren.length > 0) {
this.setCursor(forward ? this.firstLevelChildren[0] : this.firstLevelChildren[this.firstLevelChildren.length - 1]);
}
}
|
javascript
|
function(forward, roundTrip) {
var topSibling = this._findSibling(this._getTopLevelParent(this.cursor()), forward);
if(topSibling){
this.setCursor(topSibling);
} else if(roundTrip && this.firstLevelChildren.length > 0) {
this.setCursor(forward ? this.firstLevelChildren[0] : this.firstLevelChildren[this.firstLevelChildren.length - 1]);
}
}
|
[
"function",
"(",
"forward",
",",
"roundTrip",
")",
"{",
"var",
"topSibling",
"=",
"this",
".",
"_findSibling",
"(",
"this",
".",
"_getTopLevelParent",
"(",
"this",
".",
"cursor",
"(",
")",
")",
",",
"forward",
")",
";",
"if",
"(",
"topSibling",
")",
"{",
"this",
".",
"setCursor",
"(",
"topSibling",
")",
";",
"}",
"else",
"if",
"(",
"roundTrip",
"&&",
"this",
".",
"firstLevelChildren",
".",
"length",
">",
"0",
")",
"{",
"this",
".",
"setCursor",
"(",
"forward",
"?",
"this",
".",
"firstLevelChildren",
"[",
"0",
"]",
":",
"this",
".",
"firstLevelChildren",
"[",
"this",
".",
"firstLevelChildren",
".",
"length",
"-",
"1",
"]",
")",
";",
"}",
"}"
] |
Iterate from the current cursor only on the top level children
@param {boolean} forward the iteration direction. If true then iterate to next, otherwise previous.
@param {boolean} roundTrip the round trip flag. If true then iterate to the beginning at bottom or end at beginning.
|
[
"Iterate",
"from",
"the",
"current",
"cursor",
"only",
"on",
"the",
"top",
"level",
"children"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/treeModelIterator.js#L251-L258
|
|
14,634
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/treeModelIterator.js
|
function(collapsedModel) {
if(!this._cursor){
return null;
}
if(this._inParentChain(this._cursor, collapsedModel)){
this.setCursor(collapsedModel);
return this._cursor;
}
return null;
}
|
javascript
|
function(collapsedModel) {
if(!this._cursor){
return null;
}
if(this._inParentChain(this._cursor, collapsedModel)){
this.setCursor(collapsedModel);
return this._cursor;
}
return null;
}
|
[
"function",
"(",
"collapsedModel",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_cursor",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"this",
".",
"_inParentChain",
"(",
"this",
".",
"_cursor",
",",
"collapsedModel",
")",
")",
"{",
"this",
".",
"setCursor",
"(",
"collapsedModel",
")",
";",
"return",
"this",
".",
"_cursor",
";",
"}",
"return",
"null",
";",
"}"
] |
When the parent model containing the cursor is collapsed, the cursor has to be surfaced to the parent
|
[
"When",
"the",
"parent",
"model",
"containing",
"the",
"cursor",
"is",
"collapsed",
"the",
"cursor",
"has",
"to",
"be",
"surfaced",
"to",
"the",
"parent"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/treeModelIterator.js#L263-L272
|
|
14,635
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/treeModelIterator.js
|
function(){
this._cursor = null;
this._prevCursor = null;
this.root = null;
//By default the cursor is pointed to the first child
if(this.firstLevelChildren.length > 0){
this._cursor = this.firstLevelChildren[0];
this.root = this.firstLevelChildren[0].parent;
}
}
|
javascript
|
function(){
this._cursor = null;
this._prevCursor = null;
this.root = null;
//By default the cursor is pointed to the first child
if(this.firstLevelChildren.length > 0){
this._cursor = this.firstLevelChildren[0];
this.root = this.firstLevelChildren[0].parent;
}
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"_cursor",
"=",
"null",
";",
"this",
".",
"_prevCursor",
"=",
"null",
";",
"this",
".",
"root",
"=",
"null",
";",
"//By default the cursor is pointed to the first child ",
"if",
"(",
"this",
".",
"firstLevelChildren",
".",
"length",
">",
"0",
")",
"{",
"this",
".",
"_cursor",
"=",
"this",
".",
"firstLevelChildren",
"[",
"0",
"]",
";",
"this",
".",
"root",
"=",
"this",
".",
"firstLevelChildren",
"[",
"0",
"]",
".",
"parent",
";",
"}",
"}"
] |
Reset cursor and previous cursor
|
[
"Reset",
"cursor",
"and",
"previous",
"cursor"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/treeModelIterator.js#L277-L286
|
|
14,636
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/uiUtils.js
|
openInNewWindow
|
function openInNewWindow(event) {
var isMac = window.navigator.platform.indexOf("Mac") !== -1; //$NON-NLS-0$
return (isMac && event.metaKey) || (!isMac && event.ctrlKey);
}
|
javascript
|
function openInNewWindow(event) {
var isMac = window.navigator.platform.indexOf("Mac") !== -1; //$NON-NLS-0$
return (isMac && event.metaKey) || (!isMac && event.ctrlKey);
}
|
[
"function",
"openInNewWindow",
"(",
"event",
")",
"{",
"var",
"isMac",
"=",
"window",
".",
"navigator",
".",
"platform",
".",
"indexOf",
"(",
"\"Mac\"",
")",
"!==",
"-",
"1",
";",
"//$NON-NLS-0$",
"return",
"(",
"isMac",
"&&",
"event",
".",
"metaKey",
")",
"||",
"(",
"!",
"isMac",
"&&",
"event",
".",
"ctrlKey",
")",
";",
"}"
] |
Returns whether the given event should cause a reference
to open in a new window or not.
@param {Object} event The key event
@name orion.util#openInNewWindow
@function
|
[
"Returns",
"whether",
"the",
"given",
"event",
"should",
"cause",
"a",
"reference",
"to",
"open",
"in",
"a",
"new",
"window",
"or",
"not",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/uiUtils.js#L263-L266
|
14,637
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/uiUtils.js
|
followLink
|
function followLink(href, event) {
if (event && openInNewWindow(event)) {
window.open(urlModifier(href));
} else {
window.location = urlModifier(href);
}
}
|
javascript
|
function followLink(href, event) {
if (event && openInNewWindow(event)) {
window.open(urlModifier(href));
} else {
window.location = urlModifier(href);
}
}
|
[
"function",
"followLink",
"(",
"href",
",",
"event",
")",
"{",
"if",
"(",
"event",
"&&",
"openInNewWindow",
"(",
"event",
")",
")",
"{",
"window",
".",
"open",
"(",
"urlModifier",
"(",
"href",
")",
")",
";",
"}",
"else",
"{",
"window",
".",
"location",
"=",
"urlModifier",
"(",
"href",
")",
";",
"}",
"}"
] |
Opens a link in response to some event. Whether the link
is opened in the same window or a new window depends on the event
@param {String} href The link location
@name orion.util#followLink
@function
|
[
"Opens",
"a",
"link",
"in",
"response",
"to",
"some",
"event",
".",
"Whether",
"the",
"link",
"is",
"opened",
"in",
"the",
"same",
"window",
"or",
"a",
"new",
"window",
"depends",
"on",
"the",
"event"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/uiUtils.js#L275-L281
|
14,638
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/uiUtils.js
|
path2FolderName
|
function path2FolderName(filePath, keepTailSlash){
var pathSegs = filePath.split("/");
pathSegs.splice(pathSegs.length -1, 1);
return keepTailSlash ? pathSegs.join("/") + "/" : pathSegs.join("/");
}
|
javascript
|
function path2FolderName(filePath, keepTailSlash){
var pathSegs = filePath.split("/");
pathSegs.splice(pathSegs.length -1, 1);
return keepTailSlash ? pathSegs.join("/") + "/" : pathSegs.join("/");
}
|
[
"function",
"path2FolderName",
"(",
"filePath",
",",
"keepTailSlash",
")",
"{",
"var",
"pathSegs",
"=",
"filePath",
".",
"split",
"(",
"\"/\"",
")",
";",
"pathSegs",
".",
"splice",
"(",
"pathSegs",
".",
"length",
"-",
"1",
",",
"1",
")",
";",
"return",
"keepTailSlash",
"?",
"pathSegs",
".",
"join",
"(",
"\"/\"",
")",
"+",
"\"/\"",
":",
"pathSegs",
".",
"join",
"(",
"\"/\"",
")",
";",
"}"
] |
Returns the folder name from path.
@param {String} filePath
@param {Boolean} keepTailSlash
@returns {String}
|
[
"Returns",
"the",
"folder",
"name",
"from",
"path",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/uiUtils.js#L334-L338
|
14,639
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/uiUtils.js
|
timeElapsed
|
function timeElapsed(timeStamp) {
var diff = _timeDifference(timeStamp);
var yearStr = _generateTimeString(diff.year, "a year", "years");
var monthStr = _generateTimeString(diff.month, "a month", "months");
var dayStr = _generateTimeString(diff.day, "a day", "days");
var hourStr = _generateTimeString(diff.hour, "an hour", "hours");
var minuteStr = _generateTimeString(diff.minute, "a minute", "minutes");
var disPlayStr = "";
if(yearStr) {
disPlayStr = diff.year > 0 ? yearStr : yearStr + monthStr;
} else if(monthStr) {
disPlayStr = diff.month > 0 ? monthStr : monthStr + dayStr;
} else if(dayStr) {
disPlayStr = diff.day > 0 ? dayStr : dayStr + hourStr;
} else if(hourStr) {
disPlayStr = diff.hour > 0 ? hourStr : hourStr + minuteStr;
} else if(minuteStr) {
disPlayStr = minuteStr;
}
return disPlayStr;
}
|
javascript
|
function timeElapsed(timeStamp) {
var diff = _timeDifference(timeStamp);
var yearStr = _generateTimeString(diff.year, "a year", "years");
var monthStr = _generateTimeString(diff.month, "a month", "months");
var dayStr = _generateTimeString(diff.day, "a day", "days");
var hourStr = _generateTimeString(diff.hour, "an hour", "hours");
var minuteStr = _generateTimeString(diff.minute, "a minute", "minutes");
var disPlayStr = "";
if(yearStr) {
disPlayStr = diff.year > 0 ? yearStr : yearStr + monthStr;
} else if(monthStr) {
disPlayStr = diff.month > 0 ? monthStr : monthStr + dayStr;
} else if(dayStr) {
disPlayStr = diff.day > 0 ? dayStr : dayStr + hourStr;
} else if(hourStr) {
disPlayStr = diff.hour > 0 ? hourStr : hourStr + minuteStr;
} else if(minuteStr) {
disPlayStr = minuteStr;
}
return disPlayStr;
}
|
[
"function",
"timeElapsed",
"(",
"timeStamp",
")",
"{",
"var",
"diff",
"=",
"_timeDifference",
"(",
"timeStamp",
")",
";",
"var",
"yearStr",
"=",
"_generateTimeString",
"(",
"diff",
".",
"year",
",",
"\"a year\"",
",",
"\"years\"",
")",
";",
"var",
"monthStr",
"=",
"_generateTimeString",
"(",
"diff",
".",
"month",
",",
"\"a month\"",
",",
"\"months\"",
")",
";",
"var",
"dayStr",
"=",
"_generateTimeString",
"(",
"diff",
".",
"day",
",",
"\"a day\"",
",",
"\"days\"",
")",
";",
"var",
"hourStr",
"=",
"_generateTimeString",
"(",
"diff",
".",
"hour",
",",
"\"an hour\"",
",",
"\"hours\"",
")",
";",
"var",
"minuteStr",
"=",
"_generateTimeString",
"(",
"diff",
".",
"minute",
",",
"\"a minute\"",
",",
"\"minutes\"",
")",
";",
"var",
"disPlayStr",
"=",
"\"\"",
";",
"if",
"(",
"yearStr",
")",
"{",
"disPlayStr",
"=",
"diff",
".",
"year",
">",
"0",
"?",
"yearStr",
":",
"yearStr",
"+",
"monthStr",
";",
"}",
"else",
"if",
"(",
"monthStr",
")",
"{",
"disPlayStr",
"=",
"diff",
".",
"month",
">",
"0",
"?",
"monthStr",
":",
"monthStr",
"+",
"dayStr",
";",
"}",
"else",
"if",
"(",
"dayStr",
")",
"{",
"disPlayStr",
"=",
"diff",
".",
"day",
">",
"0",
"?",
"dayStr",
":",
"dayStr",
"+",
"hourStr",
";",
"}",
"else",
"if",
"(",
"hourStr",
")",
"{",
"disPlayStr",
"=",
"diff",
".",
"hour",
">",
"0",
"?",
"hourStr",
":",
"hourStr",
"+",
"minuteStr",
";",
"}",
"else",
"if",
"(",
"minuteStr",
")",
"{",
"disPlayStr",
"=",
"minuteStr",
";",
"}",
"return",
"disPlayStr",
";",
"}"
] |
Returns the time duration passed by now. E.g. "2 minutes", "an hour", "a day", "3 months", "2 years"
@param {String} timeStamp
@returns {String} If the duration is less than 1 minute, it returns empty string "". Otherwise it returns a duration value.
|
[
"Returns",
"the",
"time",
"duration",
"passed",
"by",
"now",
".",
"E",
".",
"g",
".",
"2",
"minutes",
"an",
"hour",
"a",
"day",
"3",
"months",
"2",
"years"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/uiUtils.js#L372-L392
|
14,640
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/uiUtils.js
|
displayableTimeElapsed
|
function displayableTimeElapsed(timeStamp) {
var duration = timeElapsed(timeStamp);
if(duration) {
return i18nUtil.formatMessage(messages["timeAgo"], duration);
}
return messages["justNow"];
}
|
javascript
|
function displayableTimeElapsed(timeStamp) {
var duration = timeElapsed(timeStamp);
if(duration) {
return i18nUtil.formatMessage(messages["timeAgo"], duration);
}
return messages["justNow"];
}
|
[
"function",
"displayableTimeElapsed",
"(",
"timeStamp",
")",
"{",
"var",
"duration",
"=",
"timeElapsed",
"(",
"timeStamp",
")",
";",
"if",
"(",
"duration",
")",
"{",
"return",
"i18nUtil",
".",
"formatMessage",
"(",
"messages",
"[",
"\"timeAgo\"",
"]",
",",
"duration",
")",
";",
"}",
"return",
"messages",
"[",
"\"justNow\"",
"]",
";",
"}"
] |
Returns the displayable time duration passed by now. E.g. "just now", "2 minutes ago", "an hour ago", "a day ago", "3 months ago", "2 years ago"
@param {String} timeStamp
@returns {String} If the duration is less than 1 minute, it returns empty string "just now". Otherwise it returns a duration value.
|
[
"Returns",
"the",
"displayable",
"time",
"duration",
"passed",
"by",
"now",
".",
"E",
".",
"g",
".",
"just",
"now",
"2",
"minutes",
"ago",
"an",
"hour",
"ago",
"a",
"day",
"ago",
"3",
"months",
"ago",
"2",
"years",
"ago"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/uiUtils.js#L398-L404
|
14,641
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js
|
WrappedWorker
|
function WrappedWorker(script, onMessage, onError) {
var wUrl = new URL(script, window.location.href);
wUrl = new URL(urlModifier(wUrl.href));
wUrl.query.set("worker-language", ((navigator.languages && navigator.languages[0]) ||
navigator.language || navigator.userLanguage || 'root').toLowerCase()); //$NON-NLS-1$
this.worker = new Worker(wUrl.href);
this.worker.onmessage = onMessage.bind(this);
this.worker.onerror = onError.bind(this);
this.worker.postMessage({
request: "start_worker"
});
this.messageId = 0;
this.callbacks = Object.create(null);
}
|
javascript
|
function WrappedWorker(script, onMessage, onError) {
var wUrl = new URL(script, window.location.href);
wUrl = new URL(urlModifier(wUrl.href));
wUrl.query.set("worker-language", ((navigator.languages && navigator.languages[0]) ||
navigator.language || navigator.userLanguage || 'root').toLowerCase()); //$NON-NLS-1$
this.worker = new Worker(wUrl.href);
this.worker.onmessage = onMessage.bind(this);
this.worker.onerror = onError.bind(this);
this.worker.postMessage({
request: "start_worker"
});
this.messageId = 0;
this.callbacks = Object.create(null);
}
|
[
"function",
"WrappedWorker",
"(",
"script",
",",
"onMessage",
",",
"onError",
")",
"{",
"var",
"wUrl",
"=",
"new",
"URL",
"(",
"script",
",",
"window",
".",
"location",
".",
"href",
")",
";",
"wUrl",
"=",
"new",
"URL",
"(",
"urlModifier",
"(",
"wUrl",
".",
"href",
")",
")",
";",
"wUrl",
".",
"query",
".",
"set",
"(",
"\"worker-language\"",
",",
"(",
"(",
"navigator",
".",
"languages",
"&&",
"navigator",
".",
"languages",
"[",
"0",
"]",
")",
"||",
"navigator",
".",
"language",
"||",
"navigator",
".",
"userLanguage",
"||",
"'root'",
")",
".",
"toLowerCase",
"(",
")",
")",
";",
"//$NON-NLS-1$",
"this",
".",
"worker",
"=",
"new",
"Worker",
"(",
"wUrl",
".",
"href",
")",
";",
"this",
".",
"worker",
".",
"onmessage",
"=",
"onMessage",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"worker",
".",
"onerror",
"=",
"onError",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"worker",
".",
"postMessage",
"(",
"{",
"request",
":",
"\"start_worker\"",
"}",
")",
";",
"this",
".",
"messageId",
"=",
"0",
";",
"this",
".",
"callbacks",
"=",
"Object",
".",
"create",
"(",
"null",
")",
";",
"}"
] |
for add and removes only
@description Make a new worker
|
[
"for",
"add",
"and",
"removes",
"only"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js#L142-L155
|
14,642
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js
|
function(options) {
PropertyWidget.apply(this, arguments);
SettingsTextfield.apply(this, arguments);
if (this.node && options.indent) {
var spans = this.node.getElementsByTagName('span');
if (spans) {
var span = spans[0];
var existingClassName = span.className;
if (existingClassName) {
span.className += " setting-indent";
} else {
span.className = "setting-indent";
}
}
}
}
|
javascript
|
function(options) {
PropertyWidget.apply(this, arguments);
SettingsTextfield.apply(this, arguments);
if (this.node && options.indent) {
var spans = this.node.getElementsByTagName('span');
if (spans) {
var span = spans[0];
var existingClassName = span.className;
if (existingClassName) {
span.className += " setting-indent";
} else {
span.className = "setting-indent";
}
}
}
}
|
[
"function",
"(",
"options",
")",
"{",
"PropertyWidget",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"SettingsTextfield",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"if",
"(",
"this",
".",
"node",
"&&",
"options",
".",
"indent",
")",
"{",
"var",
"spans",
"=",
"this",
".",
"node",
".",
"getElementsByTagName",
"(",
"'span'",
")",
";",
"if",
"(",
"spans",
")",
"{",
"var",
"span",
"=",
"spans",
"[",
"0",
"]",
";",
"var",
"existingClassName",
"=",
"span",
".",
"className",
";",
"if",
"(",
"existingClassName",
")",
"{",
"span",
".",
"className",
"+=",
"\" setting-indent\"",
";",
"}",
"else",
"{",
"span",
".",
"className",
"=",
"\"setting-indent\"",
";",
"}",
"}",
"}",
"}"
] |
Widget displaying a string-typed plugin setting. Mixes in SettingsTextfield and PropertyWidget.
@callback
|
[
"Widget",
"displaying",
"a",
"string",
"-",
"typed",
"plugin",
"setting",
".",
"Mixes",
"in",
"SettingsTextfield",
"and",
"PropertyWidget",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js#L81-L96
|
|
14,643
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js
|
ConfigController
|
function ConfigController(preferences, configAdmin, pid) {
this.preferences = preferences;
this.configAdmin = configAdmin;
this.pid = pid;
this.config = this.defaultConfig = this.configPromise = null;
}
|
javascript
|
function ConfigController(preferences, configAdmin, pid) {
this.preferences = preferences;
this.configAdmin = configAdmin;
this.pid = pid;
this.config = this.defaultConfig = this.configPromise = null;
}
|
[
"function",
"ConfigController",
"(",
"preferences",
",",
"configAdmin",
",",
"pid",
")",
"{",
"this",
".",
"preferences",
"=",
"preferences",
";",
"this",
".",
"configAdmin",
"=",
"configAdmin",
";",
"this",
".",
"pid",
"=",
"pid",
";",
"this",
".",
"config",
"=",
"this",
".",
"defaultConfig",
"=",
"this",
".",
"configPromise",
"=",
"null",
";",
"}"
] |
Controller for modifying a configuration
|
[
"Controller",
"for",
"modifying",
"a",
"configuration"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js#L282-L287
|
14,644
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js
|
function() {
var configuration = this.config;
if (!configuration) {
var pid = this.pid, self = this;
this.configPromise = this.configPromise ||
Deferred.all([
this.configAdmin.getDefaultConfiguration(pid),
this.configAdmin.getConfiguration(pid)
]).then(function(result) {
self.defaultConfig = result[0];
self.config = result[1];
return self.config;
});
return this.configPromise;
}
return new Deferred().resolve(configuration);
}
|
javascript
|
function() {
var configuration = this.config;
if (!configuration) {
var pid = this.pid, self = this;
this.configPromise = this.configPromise ||
Deferred.all([
this.configAdmin.getDefaultConfiguration(pid),
this.configAdmin.getConfiguration(pid)
]).then(function(result) {
self.defaultConfig = result[0];
self.config = result[1];
return self.config;
});
return this.configPromise;
}
return new Deferred().resolve(configuration);
}
|
[
"function",
"(",
")",
"{",
"var",
"configuration",
"=",
"this",
".",
"config",
";",
"if",
"(",
"!",
"configuration",
")",
"{",
"var",
"pid",
"=",
"this",
".",
"pid",
",",
"self",
"=",
"this",
";",
"this",
".",
"configPromise",
"=",
"this",
".",
"configPromise",
"||",
"Deferred",
".",
"all",
"(",
"[",
"this",
".",
"configAdmin",
".",
"getDefaultConfiguration",
"(",
"pid",
")",
",",
"this",
".",
"configAdmin",
".",
"getConfiguration",
"(",
"pid",
")",
"]",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"self",
".",
"defaultConfig",
"=",
"result",
"[",
"0",
"]",
";",
"self",
".",
"config",
"=",
"result",
"[",
"1",
"]",
";",
"return",
"self",
".",
"config",
";",
"}",
")",
";",
"return",
"this",
".",
"configPromise",
";",
"}",
"return",
"new",
"Deferred",
"(",
")",
".",
"resolve",
"(",
"configuration",
")",
";",
"}"
] |
Creates a new configuration if necessary
|
[
"Creates",
"a",
"new",
"configuration",
"if",
"necessary"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js#L290-L306
|
|
14,645
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js
|
function() {
return this.initConfiguration().then(function(configuration) {
var defaultProps = this.getDefaultProps();
if (!defaultProps) {
return this.remove();
}
configuration.update(defaultProps);
}.bind(this));
}
|
javascript
|
function() {
return this.initConfiguration().then(function(configuration) {
var defaultProps = this.getDefaultProps();
if (!defaultProps) {
return this.remove();
}
configuration.update(defaultProps);
}.bind(this));
}
|
[
"function",
"(",
")",
"{",
"return",
"this",
".",
"initConfiguration",
"(",
")",
".",
"then",
"(",
"function",
"(",
"configuration",
")",
"{",
"var",
"defaultProps",
"=",
"this",
".",
"getDefaultProps",
"(",
")",
";",
"if",
"(",
"!",
"defaultProps",
")",
"{",
"return",
"this",
".",
"remove",
"(",
")",
";",
"}",
"configuration",
".",
"update",
"(",
"defaultProps",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] |
Reset the configuration back to the effective defaults, whatever they are
|
[
"Reset",
"the",
"configuration",
"back",
"to",
"the",
"effective",
"defaults",
"whatever",
"they",
"are"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js#L329-L337
|
|
14,646
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js
|
function() {
return this.initConfiguration().then(function(configuration) {
configuration.remove();
this.config = null;
this.configPromise = null;
}.bind(this));
}
|
javascript
|
function() {
return this.initConfiguration().then(function(configuration) {
configuration.remove();
this.config = null;
this.configPromise = null;
}.bind(this));
}
|
[
"function",
"(",
")",
"{",
"return",
"this",
".",
"initConfiguration",
"(",
")",
".",
"then",
"(",
"function",
"(",
"configuration",
")",
"{",
"configuration",
".",
"remove",
"(",
")",
";",
"this",
".",
"config",
"=",
"null",
";",
"this",
".",
"configPromise",
"=",
"null",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] |
Remove the configuration
|
[
"Remove",
"the",
"configuration"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js#L339-L345
|
|
14,647
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js
|
SettingsRenderer
|
function SettingsRenderer(settingsListExplorer, serviceRegistry) {
this.serviceRegistry = serviceRegistry;
this.childWidgets = [];
SelectionRenderer.call(this, {cachePrefix: 'pluginSettings', noRowHighlighting: true}, settingsListExplorer); //$NON-NLS-0$
}
|
javascript
|
function SettingsRenderer(settingsListExplorer, serviceRegistry) {
this.serviceRegistry = serviceRegistry;
this.childWidgets = [];
SelectionRenderer.call(this, {cachePrefix: 'pluginSettings', noRowHighlighting: true}, settingsListExplorer); //$NON-NLS-0$
}
|
[
"function",
"SettingsRenderer",
"(",
"settingsListExplorer",
",",
"serviceRegistry",
")",
"{",
"this",
".",
"serviceRegistry",
"=",
"serviceRegistry",
";",
"this",
".",
"childWidgets",
"=",
"[",
"]",
";",
"SelectionRenderer",
".",
"call",
"(",
"this",
",",
"{",
"cachePrefix",
":",
"'pluginSettings'",
",",
"noRowHighlighting",
":",
"true",
"}",
",",
"settingsListExplorer",
")",
";",
"//$NON-NLS-0$",
"}"
] |
Renderer for SettingsList.
|
[
"Renderer",
"for",
"SettingsList",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js#L351-L355
|
14,648
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js
|
SettingsListExplorer
|
function SettingsListExplorer(serviceRegistry, categoryTitle) {
Explorer.call(this, serviceRegistry, undefined, new SettingsRenderer(this, serviceRegistry));
this.categoryTitle = categoryTitle;
}
|
javascript
|
function SettingsListExplorer(serviceRegistry, categoryTitle) {
Explorer.call(this, serviceRegistry, undefined, new SettingsRenderer(this, serviceRegistry));
this.categoryTitle = categoryTitle;
}
|
[
"function",
"SettingsListExplorer",
"(",
"serviceRegistry",
",",
"categoryTitle",
")",
"{",
"Explorer",
".",
"call",
"(",
"this",
",",
"serviceRegistry",
",",
"undefined",
",",
"new",
"SettingsRenderer",
"(",
"this",
",",
"serviceRegistry",
")",
")",
";",
"this",
".",
"categoryTitle",
"=",
"categoryTitle",
";",
"}"
] |
Explorer for SettingsList.
|
[
"Explorer",
"for",
"SettingsList",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js#L400-L403
|
14,649
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js
|
SettingsList
|
function SettingsList(options) {
this.serviceRegistry = options.serviceRegistry;
this.prefService = this.serviceRegistry.getService('orion.core.preference'); //$NON-NLS-1$
var commandRegistry = this.commandRegistry = options.commandRegistry;
this.settings = options.settings;
this.title = options.title;
this.fileClient = options.fileClient;
if (!options.parent || !options.serviceRegistry || !options.settings || !options.title) {
throw new Error('Missing required option'); //$NON-NLS-0$
}
this.parent = typeof options.parent === 'string' ? document.getElementById('parent') : options.parent; //$NON-NLS-0$ //$NON-NLS-1$
var restoreCommand = new Command({
id: "orion.pluginsettings.restore", //$NON-NLS-0$
name: messages["Restore"],
callback: function(data) {
var dialog = new ConfirmDialog({
confirmMessage: messages["ConfirmRestore"],
title: messages["Restore"]
});
dialog.show();
var _self = this;
dialog.addEventListener("dismiss", function(event) {
if (event.value) {
if(data.items) {
_self.restore(data.items.pid);
} else {
_self.restore();
}
}
});
}.bind(this)
});
commandRegistry.addCommand(restoreCommand);
commandRegistry.registerCommandContribution("restoreDefaults", "orion.pluginsettings.restore", 2); //$NON-NLS-1$ //$NON-NLS-2$
this.render(this.parent, this.serviceRegistry, this.settings, this.title);
}
|
javascript
|
function SettingsList(options) {
this.serviceRegistry = options.serviceRegistry;
this.prefService = this.serviceRegistry.getService('orion.core.preference'); //$NON-NLS-1$
var commandRegistry = this.commandRegistry = options.commandRegistry;
this.settings = options.settings;
this.title = options.title;
this.fileClient = options.fileClient;
if (!options.parent || !options.serviceRegistry || !options.settings || !options.title) {
throw new Error('Missing required option'); //$NON-NLS-0$
}
this.parent = typeof options.parent === 'string' ? document.getElementById('parent') : options.parent; //$NON-NLS-0$ //$NON-NLS-1$
var restoreCommand = new Command({
id: "orion.pluginsettings.restore", //$NON-NLS-0$
name: messages["Restore"],
callback: function(data) {
var dialog = new ConfirmDialog({
confirmMessage: messages["ConfirmRestore"],
title: messages["Restore"]
});
dialog.show();
var _self = this;
dialog.addEventListener("dismiss", function(event) {
if (event.value) {
if(data.items) {
_self.restore(data.items.pid);
} else {
_self.restore();
}
}
});
}.bind(this)
});
commandRegistry.addCommand(restoreCommand);
commandRegistry.registerCommandContribution("restoreDefaults", "orion.pluginsettings.restore", 2); //$NON-NLS-1$ //$NON-NLS-2$
this.render(this.parent, this.serviceRegistry, this.settings, this.title);
}
|
[
"function",
"SettingsList",
"(",
"options",
")",
"{",
"this",
".",
"serviceRegistry",
"=",
"options",
".",
"serviceRegistry",
";",
"this",
".",
"prefService",
"=",
"this",
".",
"serviceRegistry",
".",
"getService",
"(",
"'orion.core.preference'",
")",
";",
"//$NON-NLS-1$",
"var",
"commandRegistry",
"=",
"this",
".",
"commandRegistry",
"=",
"options",
".",
"commandRegistry",
";",
"this",
".",
"settings",
"=",
"options",
".",
"settings",
";",
"this",
".",
"title",
"=",
"options",
".",
"title",
";",
"this",
".",
"fileClient",
"=",
"options",
".",
"fileClient",
";",
"if",
"(",
"!",
"options",
".",
"parent",
"||",
"!",
"options",
".",
"serviceRegistry",
"||",
"!",
"options",
".",
"settings",
"||",
"!",
"options",
".",
"title",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Missing required option'",
")",
";",
"//$NON-NLS-0$",
"}",
"this",
".",
"parent",
"=",
"typeof",
"options",
".",
"parent",
"===",
"'string'",
"?",
"document",
".",
"getElementById",
"(",
"'parent'",
")",
":",
"options",
".",
"parent",
";",
"//$NON-NLS-0$ //$NON-NLS-1$",
"var",
"restoreCommand",
"=",
"new",
"Command",
"(",
"{",
"id",
":",
"\"orion.pluginsettings.restore\"",
",",
"//$NON-NLS-0$",
"name",
":",
"messages",
"[",
"\"Restore\"",
"]",
",",
"callback",
":",
"function",
"(",
"data",
")",
"{",
"var",
"dialog",
"=",
"new",
"ConfirmDialog",
"(",
"{",
"confirmMessage",
":",
"messages",
"[",
"\"ConfirmRestore\"",
"]",
",",
"title",
":",
"messages",
"[",
"\"Restore\"",
"]",
"}",
")",
";",
"dialog",
".",
"show",
"(",
")",
";",
"var",
"_self",
"=",
"this",
";",
"dialog",
".",
"addEventListener",
"(",
"\"dismiss\"",
",",
"function",
"(",
"event",
")",
"{",
"if",
"(",
"event",
".",
"value",
")",
"{",
"if",
"(",
"data",
".",
"items",
")",
"{",
"_self",
".",
"restore",
"(",
"data",
".",
"items",
".",
"pid",
")",
";",
"}",
"else",
"{",
"_self",
".",
"restore",
"(",
")",
";",
"}",
"}",
"}",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
"}",
")",
";",
"commandRegistry",
".",
"addCommand",
"(",
"restoreCommand",
")",
";",
"commandRegistry",
".",
"registerCommandContribution",
"(",
"\"restoreDefaults\"",
",",
"\"orion.pluginsettings.restore\"",
",",
"2",
")",
";",
"//$NON-NLS-1$ //$NON-NLS-2$",
"this",
".",
"render",
"(",
"this",
".",
"parent",
",",
"this",
".",
"serviceRegistry",
",",
"this",
".",
"settings",
",",
"this",
".",
"title",
")",
";",
"}"
] |
Widget showing list of Plugin Settings.
Requires the 'orion.cm.configadmin' service.
@param {DomNode|String} options.parent
@param {orion.serviceregistry.ServiceRegistry} options.serviceRegistry
@param {orion.settings.Settings[]} options.settings
|
[
"Widget",
"showing",
"list",
"of",
"Plugin",
"Settings",
".",
"Requires",
"the",
"orion",
".",
"cm",
".",
"configadmin",
"service",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js#L418-L455
|
14,650
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/HTML5LocalFileImpl.js
|
function(parentLocation, folderName) {
var that = this;
return this._getEntry(parentLocation).then(function(dirEntry) {
var d = new orion.Deferred();
dirEntry.getDirectory(folderName, {create:true}, function() {d.resolve(that.read(parentLocation + "/" + folderName, true));}, d.reject);
return d;
});
}
|
javascript
|
function(parentLocation, folderName) {
var that = this;
return this._getEntry(parentLocation).then(function(dirEntry) {
var d = new orion.Deferred();
dirEntry.getDirectory(folderName, {create:true}, function() {d.resolve(that.read(parentLocation + "/" + folderName, true));}, d.reject);
return d;
});
}
|
[
"function",
"(",
"parentLocation",
",",
"folderName",
")",
"{",
"var",
"that",
"=",
"this",
";",
"return",
"this",
".",
"_getEntry",
"(",
"parentLocation",
")",
".",
"then",
"(",
"function",
"(",
"dirEntry",
")",
"{",
"var",
"d",
"=",
"new",
"orion",
".",
"Deferred",
"(",
")",
";",
"dirEntry",
".",
"getDirectory",
"(",
"folderName",
",",
"{",
"create",
":",
"true",
"}",
",",
"function",
"(",
")",
"{",
"d",
".",
"resolve",
"(",
"that",
".",
"read",
"(",
"parentLocation",
"+",
"\"/\"",
"+",
"folderName",
",",
"true",
")",
")",
";",
"}",
",",
"d",
".",
"reject",
")",
";",
"return",
"d",
";",
"}",
")",
";",
"}"
] |
Creates a folder.
@param {String} parentLocation The location of the parent folder
@param {String} folderName The name of the folder to create
@return {Object} JSON representation of the created folder
|
[
"Creates",
"a",
"folder",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/HTML5LocalFileImpl.js#L203-L210
|
|
14,651
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/HTML5LocalFileImpl.js
|
function(sourceLocation, targetLocation, name) {
var that = this;
if (sourceLocation.indexOf(this._rootLocation) === -1 || targetLocation.indexOf(this._rootLocation) === -1) {
throw "Not supported";
}
return this._getEntry(sourceLocation).then(function(entry) {
return that._getEntry(targetLocation).then(function(parent) {
var d = new orion.Deferred();
entry.copyTo(parent, name, function() {d.resolve(that.read(targetLocation + "/" + (name || entry.name), true));}, d.reject);
return d;
});
});
}
|
javascript
|
function(sourceLocation, targetLocation, name) {
var that = this;
if (sourceLocation.indexOf(this._rootLocation) === -1 || targetLocation.indexOf(this._rootLocation) === -1) {
throw "Not supported";
}
return this._getEntry(sourceLocation).then(function(entry) {
return that._getEntry(targetLocation).then(function(parent) {
var d = new orion.Deferred();
entry.copyTo(parent, name, function() {d.resolve(that.read(targetLocation + "/" + (name || entry.name), true));}, d.reject);
return d;
});
});
}
|
[
"function",
"(",
"sourceLocation",
",",
"targetLocation",
",",
"name",
")",
"{",
"var",
"that",
"=",
"this",
";",
"if",
"(",
"sourceLocation",
".",
"indexOf",
"(",
"this",
".",
"_rootLocation",
")",
"===",
"-",
"1",
"||",
"targetLocation",
".",
"indexOf",
"(",
"this",
".",
"_rootLocation",
")",
"===",
"-",
"1",
")",
"{",
"throw",
"\"Not supported\"",
";",
"}",
"return",
"this",
".",
"_getEntry",
"(",
"sourceLocation",
")",
".",
"then",
"(",
"function",
"(",
"entry",
")",
"{",
"return",
"that",
".",
"_getEntry",
"(",
"targetLocation",
")",
".",
"then",
"(",
"function",
"(",
"parent",
")",
"{",
"var",
"d",
"=",
"new",
"orion",
".",
"Deferred",
"(",
")",
";",
"entry",
".",
"copyTo",
"(",
"parent",
",",
"name",
",",
"function",
"(",
")",
"{",
"d",
".",
"resolve",
"(",
"that",
".",
"read",
"(",
"targetLocation",
"+",
"\"/\"",
"+",
"(",
"name",
"||",
"entry",
".",
"name",
")",
",",
"true",
")",
")",
";",
"}",
",",
"d",
".",
"reject",
")",
";",
"return",
"d",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] |
Copies a file or directory.
@param {String} sourceLocation The location of the file or directory to copy.
@param {String} targetLocation The location of the target folder.
@param {String} [name] The name of the destination file or directory in the case of a rename
|
[
"Copies",
"a",
"file",
"or",
"directory",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/HTML5LocalFileImpl.js#L266-L279
|
|
14,652
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.editor/web/orion/editor/projectionTextModel.js
|
function() {
if (this._model) {
this._model.removeEventListener("postChanged", this._listener.onChanged); //$NON-NLS-0$
this._model.removeEventListener("preChanging", this._listener.onChanging); //$NON-NLS-0$
this._model = null;
}
}
|
javascript
|
function() {
if (this._model) {
this._model.removeEventListener("postChanged", this._listener.onChanged); //$NON-NLS-0$
this._model.removeEventListener("preChanging", this._listener.onChanging); //$NON-NLS-0$
this._model = null;
}
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_model",
")",
"{",
"this",
".",
"_model",
".",
"removeEventListener",
"(",
"\"postChanged\"",
",",
"this",
".",
"_listener",
".",
"onChanged",
")",
";",
"//$NON-NLS-0$",
"this",
".",
"_model",
".",
"removeEventListener",
"(",
"\"preChanging\"",
",",
"this",
".",
"_listener",
".",
"onChanging",
")",
";",
"//$NON-NLS-0$",
"this",
".",
"_model",
"=",
"null",
";",
"}",
"}"
] |
Destroys this projection text model.
|
[
"Destroys",
"this",
"projection",
"text",
"model",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.editor/web/orion/editor/projectionTextModel.js#L75-L81
|
|
14,653
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.editor/web/orion/editor/projectionTextModel.js
|
function(offset, baseOffset) {
var projections = this._projections, delta = 0, i, projection;
if (baseOffset) {
for (i = 0; i < projections.length; i++) {
projection = projections[i];
if (projection.start > offset) { break; }
if (projection.end > offset) { return -1; }
delta += projection._model.getCharCount() - (projection.end - projection.start);
}
return offset + delta;
}
for (i = 0; i < projections.length; i++) {
projection = projections[i];
if (projection.start > offset - delta) { break; }
var charCount = projection._model.getCharCount();
if (projection.start + charCount > offset - delta) {
return -1;
}
delta += charCount - (projection.end - projection.start);
}
return offset - delta;
}
|
javascript
|
function(offset, baseOffset) {
var projections = this._projections, delta = 0, i, projection;
if (baseOffset) {
for (i = 0; i < projections.length; i++) {
projection = projections[i];
if (projection.start > offset) { break; }
if (projection.end > offset) { return -1; }
delta += projection._model.getCharCount() - (projection.end - projection.start);
}
return offset + delta;
}
for (i = 0; i < projections.length; i++) {
projection = projections[i];
if (projection.start > offset - delta) { break; }
var charCount = projection._model.getCharCount();
if (projection.start + charCount > offset - delta) {
return -1;
}
delta += charCount - (projection.end - projection.start);
}
return offset - delta;
}
|
[
"function",
"(",
"offset",
",",
"baseOffset",
")",
"{",
"var",
"projections",
"=",
"this",
".",
"_projections",
",",
"delta",
"=",
"0",
",",
"i",
",",
"projection",
";",
"if",
"(",
"baseOffset",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"projections",
".",
"length",
";",
"i",
"++",
")",
"{",
"projection",
"=",
"projections",
"[",
"i",
"]",
";",
"if",
"(",
"projection",
".",
"start",
">",
"offset",
")",
"{",
"break",
";",
"}",
"if",
"(",
"projection",
".",
"end",
">",
"offset",
")",
"{",
"return",
"-",
"1",
";",
"}",
"delta",
"+=",
"projection",
".",
"_model",
".",
"getCharCount",
"(",
")",
"-",
"(",
"projection",
".",
"end",
"-",
"projection",
".",
"start",
")",
";",
"}",
"return",
"offset",
"+",
"delta",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"projections",
".",
"length",
";",
"i",
"++",
")",
"{",
"projection",
"=",
"projections",
"[",
"i",
"]",
";",
"if",
"(",
"projection",
".",
"start",
">",
"offset",
"-",
"delta",
")",
"{",
"break",
";",
"}",
"var",
"charCount",
"=",
"projection",
".",
"_model",
".",
"getCharCount",
"(",
")",
";",
"if",
"(",
"projection",
".",
"start",
"+",
"charCount",
">",
"offset",
"-",
"delta",
")",
"{",
"return",
"-",
"1",
";",
"}",
"delta",
"+=",
"charCount",
"-",
"(",
"projection",
".",
"end",
"-",
"projection",
".",
"start",
")",
";",
"}",
"return",
"offset",
"-",
"delta",
";",
"}"
] |
Maps offsets between the projection model and its base model.
@param {Number} offset The offset to be mapped.
@param {Boolean} [baseOffset=false] <code>true</code> if <code>offset</code> is in base model and
should be mapped to the projection model.
@return {Number} The mapped offset
|
[
"Maps",
"offsets",
"between",
"the",
"projection",
"model",
"and",
"its",
"base",
"model",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.editor/web/orion/editor/projectionTextModel.js#L160-L181
|
|
14,654
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.editor/web/orion/editor/linkedMode.js
|
function(escapePosition) {
if (!this.isActive()) {
return;
}
if (this._compoundChange) {
this.endUndo();
this._compoundChange = null;
}
this._sortedPositions = null;
var model = this.linkedModeModel;
this.linkedModeModel = model.previousModel;
model.parentGroup = model.previousModel = undefined;
if (this.linkedModeModel) {
this.linkedModeModel.nextModel = undefined;
}
if (!this.linkedModeModel) {
var editor = this.editor;
var textView = editor.getTextView();
textView.removeKeyMode(this);
textView.removeEventListener("Verify", this.linkedModeListener.onVerify);
textView.removeEventListener("ModelChanged", this.linkedModeListener.onModelChanged);
var contentAssist = this.contentAssist;
contentAssist.removeEventListener("Activating", this.linkedModeListener.onActivating);
contentAssist.offset = undefined;
this.editor.reportStatus(messages.linkedModeExited, null, true);
}
if (escapePosition && typeof model.escapePosition === "number") {
editor.setCaretOffset(model.escapePosition, false);
}
this.selectLinkedGroup(0);
}
|
javascript
|
function(escapePosition) {
if (!this.isActive()) {
return;
}
if (this._compoundChange) {
this.endUndo();
this._compoundChange = null;
}
this._sortedPositions = null;
var model = this.linkedModeModel;
this.linkedModeModel = model.previousModel;
model.parentGroup = model.previousModel = undefined;
if (this.linkedModeModel) {
this.linkedModeModel.nextModel = undefined;
}
if (!this.linkedModeModel) {
var editor = this.editor;
var textView = editor.getTextView();
textView.removeKeyMode(this);
textView.removeEventListener("Verify", this.linkedModeListener.onVerify);
textView.removeEventListener("ModelChanged", this.linkedModeListener.onModelChanged);
var contentAssist = this.contentAssist;
contentAssist.removeEventListener("Activating", this.linkedModeListener.onActivating);
contentAssist.offset = undefined;
this.editor.reportStatus(messages.linkedModeExited, null, true);
}
if (escapePosition && typeof model.escapePosition === "number") {
editor.setCaretOffset(model.escapePosition, false);
}
this.selectLinkedGroup(0);
}
|
[
"function",
"(",
"escapePosition",
")",
"{",
"if",
"(",
"!",
"this",
".",
"isActive",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"this",
".",
"_compoundChange",
")",
"{",
"this",
".",
"endUndo",
"(",
")",
";",
"this",
".",
"_compoundChange",
"=",
"null",
";",
"}",
"this",
".",
"_sortedPositions",
"=",
"null",
";",
"var",
"model",
"=",
"this",
".",
"linkedModeModel",
";",
"this",
".",
"linkedModeModel",
"=",
"model",
".",
"previousModel",
";",
"model",
".",
"parentGroup",
"=",
"model",
".",
"previousModel",
"=",
"undefined",
";",
"if",
"(",
"this",
".",
"linkedModeModel",
")",
"{",
"this",
".",
"linkedModeModel",
".",
"nextModel",
"=",
"undefined",
";",
"}",
"if",
"(",
"!",
"this",
".",
"linkedModeModel",
")",
"{",
"var",
"editor",
"=",
"this",
".",
"editor",
";",
"var",
"textView",
"=",
"editor",
".",
"getTextView",
"(",
")",
";",
"textView",
".",
"removeKeyMode",
"(",
"this",
")",
";",
"textView",
".",
"removeEventListener",
"(",
"\"Verify\"",
",",
"this",
".",
"linkedModeListener",
".",
"onVerify",
")",
";",
"textView",
".",
"removeEventListener",
"(",
"\"ModelChanged\"",
",",
"this",
".",
"linkedModeListener",
".",
"onModelChanged",
")",
";",
"var",
"contentAssist",
"=",
"this",
".",
"contentAssist",
";",
"contentAssist",
".",
"removeEventListener",
"(",
"\"Activating\"",
",",
"this",
".",
"linkedModeListener",
".",
"onActivating",
")",
";",
"contentAssist",
".",
"offset",
"=",
"undefined",
";",
"this",
".",
"editor",
".",
"reportStatus",
"(",
"messages",
".",
"linkedModeExited",
",",
"null",
",",
"true",
")",
";",
"}",
"if",
"(",
"escapePosition",
"&&",
"typeof",
"model",
".",
"escapePosition",
"===",
"\"number\"",
")",
"{",
"editor",
".",
"setCaretOffset",
"(",
"model",
".",
"escapePosition",
",",
"false",
")",
";",
"}",
"this",
".",
"selectLinkedGroup",
"(",
"0",
")",
";",
"}"
] |
Exits Linked Mode. Optionally places the caret at linkedMode escapePosition.
@param {Boolean} [escapePosition=false] if true, place the caret at the escape position.
|
[
"Exits",
"Linked",
"Mode",
".",
"Optionally",
"places",
"the",
"caret",
"at",
"linkedMode",
"escapePosition",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.editor/web/orion/editor/linkedMode.js#L336-L366
|
|
14,655
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js
|
function(_name, id) {
//return the deferred so client can chain on post-processing
var data = {};
data.Id = id;
return _xhr("POST", this.workspaceBase, {
headers: {
"Orion-Version": "1",
"Content-Type": "application/json;charset=UTF-8",
"Slug": form.encodeSlug(_name)
},
data: JSON.stringify(data),
timeout: 15000
}).then(function(result) {
var jsonData = result.response ? JSON.parse(result.response) : {};
return jsonData;
});
}
|
javascript
|
function(_name, id) {
//return the deferred so client can chain on post-processing
var data = {};
data.Id = id;
return _xhr("POST", this.workspaceBase, {
headers: {
"Orion-Version": "1",
"Content-Type": "application/json;charset=UTF-8",
"Slug": form.encodeSlug(_name)
},
data: JSON.stringify(data),
timeout: 15000
}).then(function(result) {
var jsonData = result.response ? JSON.parse(result.response) : {};
return jsonData;
});
}
|
[
"function",
"(",
"_name",
",",
"id",
")",
"{",
"//return the deferred so client can chain on post-processing",
"var",
"data",
"=",
"{",
"}",
";",
"data",
".",
"Id",
"=",
"id",
";",
"return",
"_xhr",
"(",
"\"POST\"",
",",
"this",
".",
"workspaceBase",
",",
"{",
"headers",
":",
"{",
"\"Orion-Version\"",
":",
"\"1\"",
",",
"\"Content-Type\"",
":",
"\"application/json;charset=UTF-8\"",
",",
"\"Slug\"",
":",
"form",
".",
"encodeSlug",
"(",
"_name",
")",
"}",
",",
"data",
":",
"JSON",
".",
"stringify",
"(",
"data",
")",
",",
"timeout",
":",
"15000",
"}",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"var",
"jsonData",
"=",
"result",
".",
"response",
"?",
"JSON",
".",
"parse",
"(",
"result",
".",
"response",
")",
":",
"{",
"}",
";",
"return",
"jsonData",
";",
"}",
")",
";",
"}"
] |
Creates a new workspace with the given name. The resulting workspace is
passed as a parameter to the provided onCreate function.
@param {String} _name The name of the new workspace
|
[
"Creates",
"a",
"new",
"workspace",
"with",
"the",
"given",
"name",
".",
"The",
"resulting",
"workspace",
"is",
"passed",
"as",
"a",
"parameter",
"to",
"the",
"provided",
"onCreate",
"function",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js#L237-L253
|
|
14,656
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js
|
function() {
return _xhr("GET", this.workspaceBase, {
headers: {
"Orion-Version": "1"
},
timeout: 15000
}).then(function(result) {
var jsonData = result.response ? JSON.parse(result.response) : {};
return jsonData.Workspaces;
}).then(function(result) {
if (this.makeAbsolute) {
_normalizeLocations(result);
}
return result;
}.bind(this));
}
|
javascript
|
function() {
return _xhr("GET", this.workspaceBase, {
headers: {
"Orion-Version": "1"
},
timeout: 15000
}).then(function(result) {
var jsonData = result.response ? JSON.parse(result.response) : {};
return jsonData.Workspaces;
}).then(function(result) {
if (this.makeAbsolute) {
_normalizeLocations(result);
}
return result;
}.bind(this));
}
|
[
"function",
"(",
")",
"{",
"return",
"_xhr",
"(",
"\"GET\"",
",",
"this",
".",
"workspaceBase",
",",
"{",
"headers",
":",
"{",
"\"Orion-Version\"",
":",
"\"1\"",
"}",
",",
"timeout",
":",
"15000",
"}",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"var",
"jsonData",
"=",
"result",
".",
"response",
"?",
"JSON",
".",
"parse",
"(",
"result",
".",
"response",
")",
":",
"{",
"}",
";",
"return",
"jsonData",
".",
"Workspaces",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"if",
"(",
"this",
".",
"makeAbsolute",
")",
"{",
"_normalizeLocations",
"(",
"result",
")",
";",
"}",
"return",
"result",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] |
Loads all the user's workspaces. Returns a deferred that will provide the loaded
workspaces when ready.
|
[
"Loads",
"all",
"the",
"user",
"s",
"workspaces",
".",
"Returns",
"a",
"deferred",
"that",
"will",
"provide",
"the",
"loaded",
"workspaces",
"when",
"ready",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js#L259-L274
|
|
14,657
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js
|
function(loc) {
if (loc === this.fileBase) {
loc = null;
}
return _xhr("GET", loc ? loc : this.workspaceBase, {
headers: {
"Orion-Version": "1"
},
timeout: 15000,
log: false
}).then(function(result) {
var jsonData = result.response ? JSON.parse(result.response) : {};
//in most cases the returned object is the workspace we care about
if (loc) {
return jsonData;
}
//user didn't specify a workspace so we are at the root
//just pick the first location in the provided list
if (jsonData.Workspaces.length > 0) {
return this.loadWorkspace(jsonData.Workspaces[0].Location);
}
//no workspace exists, and the user didn't specify one. We'll create one for them
return this.createWorkspace("Orion Content");
}.bind(this)).then(function(result) {
if (this.makeAbsolute) {
_normalizeLocations(result);
}
return result;
}.bind(this));
}
|
javascript
|
function(loc) {
if (loc === this.fileBase) {
loc = null;
}
return _xhr("GET", loc ? loc : this.workspaceBase, {
headers: {
"Orion-Version": "1"
},
timeout: 15000,
log: false
}).then(function(result) {
var jsonData = result.response ? JSON.parse(result.response) : {};
//in most cases the returned object is the workspace we care about
if (loc) {
return jsonData;
}
//user didn't specify a workspace so we are at the root
//just pick the first location in the provided list
if (jsonData.Workspaces.length > 0) {
return this.loadWorkspace(jsonData.Workspaces[0].Location);
}
//no workspace exists, and the user didn't specify one. We'll create one for them
return this.createWorkspace("Orion Content");
}.bind(this)).then(function(result) {
if (this.makeAbsolute) {
_normalizeLocations(result);
}
return result;
}.bind(this));
}
|
[
"function",
"(",
"loc",
")",
"{",
"if",
"(",
"loc",
"===",
"this",
".",
"fileBase",
")",
"{",
"loc",
"=",
"null",
";",
"}",
"return",
"_xhr",
"(",
"\"GET\"",
",",
"loc",
"?",
"loc",
":",
"this",
".",
"workspaceBase",
",",
"{",
"headers",
":",
"{",
"\"Orion-Version\"",
":",
"\"1\"",
"}",
",",
"timeout",
":",
"15000",
",",
"log",
":",
"false",
"}",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"var",
"jsonData",
"=",
"result",
".",
"response",
"?",
"JSON",
".",
"parse",
"(",
"result",
".",
"response",
")",
":",
"{",
"}",
";",
"//in most cases the returned object is the workspace we care about",
"if",
"(",
"loc",
")",
"{",
"return",
"jsonData",
";",
"}",
"//user didn't specify a workspace so we are at the root",
"//just pick the first location in the provided list",
"if",
"(",
"jsonData",
".",
"Workspaces",
".",
"length",
">",
"0",
")",
"{",
"return",
"this",
".",
"loadWorkspace",
"(",
"jsonData",
".",
"Workspaces",
"[",
"0",
"]",
".",
"Location",
")",
";",
"}",
"//no workspace exists, and the user didn't specify one. We'll create one for them",
"return",
"this",
".",
"createWorkspace",
"(",
"\"Orion Content\"",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"if",
"(",
"this",
".",
"makeAbsolute",
")",
"{",
"_normalizeLocations",
"(",
"result",
")",
";",
"}",
"return",
"result",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] |
Loads the workspace with the given id and sets it to be the current
workspace for the IDE. The workspace is created if none already exists.
@param {String} loc the location of the workspace to load
@param {Function} onLoad the function to invoke when the workspace is loaded
|
[
"Loads",
"the",
"workspace",
"with",
"the",
"given",
"id",
"and",
"sets",
"it",
"to",
"be",
"the",
"current",
"workspace",
"for",
"the",
"IDE",
".",
"The",
"workspace",
"is",
"created",
"if",
"none",
"already",
"exists",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js#L282-L311
|
|
14,658
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js
|
function(sourceLocation, options) {
var headerData = {
"Orion-Version": "1"
};
if (options.OptionHeader) {
headerData["X-Xfer-Options"] = options.OptionHeader;
delete options.OptionHeader;
}
return sftpOperation("POST", sourceLocation, {
headers: headerData,
data: JSON.stringify(options),
timeout: 15000
}).then(function(result) {
if (this.makeAbsolute) {
_normalizeLocations(result);
}
return result;
}.bind(this));
}
|
javascript
|
function(sourceLocation, options) {
var headerData = {
"Orion-Version": "1"
};
if (options.OptionHeader) {
headerData["X-Xfer-Options"] = options.OptionHeader;
delete options.OptionHeader;
}
return sftpOperation("POST", sourceLocation, {
headers: headerData,
data: JSON.stringify(options),
timeout: 15000
}).then(function(result) {
if (this.makeAbsolute) {
_normalizeLocations(result);
}
return result;
}.bind(this));
}
|
[
"function",
"(",
"sourceLocation",
",",
"options",
")",
"{",
"var",
"headerData",
"=",
"{",
"\"Orion-Version\"",
":",
"\"1\"",
"}",
";",
"if",
"(",
"options",
".",
"OptionHeader",
")",
"{",
"headerData",
"[",
"\"X-Xfer-Options\"",
"]",
"=",
"options",
".",
"OptionHeader",
";",
"delete",
"options",
".",
"OptionHeader",
";",
"}",
"return",
"sftpOperation",
"(",
"\"POST\"",
",",
"sourceLocation",
",",
"{",
"headers",
":",
"headerData",
",",
"data",
":",
"JSON",
".",
"stringify",
"(",
"options",
")",
",",
"timeout",
":",
"15000",
"}",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"if",
"(",
"this",
".",
"makeAbsolute",
")",
"{",
"_normalizeLocations",
"(",
"result",
")",
";",
"}",
"return",
"result",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] |
Exports file and directory contents to another server
@param {String} sourceLocation The location of the folder to export from
@param {Object} options An object specifying the export parameters
@return A deferred for chaining events after the export completes
|
[
"Exports",
"file",
"and",
"directory",
"contents",
"to",
"another",
"server"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js#L704-L722
|
|
14,659
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js
|
function(sourceLocation, findStr, option) {
var url = new URL(sourceLocation, self.location);
url.query.set("findStr", findStr);
return _xhr("GET", url.href, {
timeout: 120000,
headers: {
"Orion-Version": "1"
},
log: false
}).then(function(result) {
return result.response ? JSON.parse(result.response) : null;
}.bind(this));
}
|
javascript
|
function(sourceLocation, findStr, option) {
var url = new URL(sourceLocation, self.location);
url.query.set("findStr", findStr);
return _xhr("GET", url.href, {
timeout: 120000,
headers: {
"Orion-Version": "1"
},
log: false
}).then(function(result) {
return result.response ? JSON.parse(result.response) : null;
}.bind(this));
}
|
[
"function",
"(",
"sourceLocation",
",",
"findStr",
",",
"option",
")",
"{",
"var",
"url",
"=",
"new",
"URL",
"(",
"sourceLocation",
",",
"self",
".",
"location",
")",
";",
"url",
".",
"query",
".",
"set",
"(",
"\"findStr\"",
",",
"findStr",
")",
";",
"return",
"_xhr",
"(",
"\"GET\"",
",",
"url",
".",
"href",
",",
"{",
"timeout",
":",
"120000",
",",
"headers",
":",
"{",
"\"Orion-Version\"",
":",
"\"1\"",
"}",
",",
"log",
":",
"false",
"}",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"return",
"result",
".",
"response",
"?",
"JSON",
".",
"parse",
"(",
"result",
".",
"response",
")",
":",
"null",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] |
Find a string inside a file
@param {String} sourceLocation The location of the folder to export from
@param {String} findStr The string to search
@public
@return {Deferred} A deferred for chaining events after the export completes
|
[
"Find",
"a",
"string",
"inside",
"a",
"file"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js#L731-L743
|
|
14,660
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js
|
function(searchParams) {
var query = _generateLuceneQuery(searchParams);
return _xhr("GET", this.fileBase + "/../filesearch" + query, {
headers: {
"Accept": "application/json",
"Orion-Version": "1"
}
}).then(function(result) {
return result.response ? JSON.parse(result.response) : {};
}).then(function(result) {
if (this.makeAbsolute) {
_normalizeLocations(result);
}
return result;
}.bind(this));
}
|
javascript
|
function(searchParams) {
var query = _generateLuceneQuery(searchParams);
return _xhr("GET", this.fileBase + "/../filesearch" + query, {
headers: {
"Accept": "application/json",
"Orion-Version": "1"
}
}).then(function(result) {
return result.response ? JSON.parse(result.response) : {};
}).then(function(result) {
if (this.makeAbsolute) {
_normalizeLocations(result);
}
return result;
}.bind(this));
}
|
[
"function",
"(",
"searchParams",
")",
"{",
"var",
"query",
"=",
"_generateLuceneQuery",
"(",
"searchParams",
")",
";",
"return",
"_xhr",
"(",
"\"GET\"",
",",
"this",
".",
"fileBase",
"+",
"\"/../filesearch\"",
"+",
"query",
",",
"{",
"headers",
":",
"{",
"\"Accept\"",
":",
"\"application/json\"",
",",
"\"Orion-Version\"",
":",
"\"1\"",
"}",
"}",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"return",
"result",
".",
"response",
"?",
"JSON",
".",
"parse",
"(",
"result",
".",
"response",
")",
":",
"{",
"}",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"if",
"(",
"this",
".",
"makeAbsolute",
")",
"{",
"_normalizeLocations",
"(",
"result",
")",
";",
"}",
"return",
"result",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] |
Performs a search with the given search parameters.
@param {Object} searchParams The JSON object that describes all the search parameters.
@param {String} searchParams.resource Required. The location where search is performed. Required. Normally a sub folder of the file system. Empty string means the root of the file system.
@param {String} searchParams.keyword The search keyword. Required but can be empty string. If fileType is a specific type and the keyword is empty, then list up all the files of that type. If searchParams.regEx is true then the keyword has to be a valid regular expression.
@param {String} searchParams.sort Required. Defines the order of the return results. Should be either "Path asc" or "Name asc". Extensions are possible but not currently supported.
@param {boolean} searchParams.nameSearch Optional. If true, the search performs only file name search.
@param {String} searchParams.fileType Optional. The file type. If specified, search will be performed under this file type. E.g. "*.*" means all file types. "html" means html files.
@param {Boolean} searchParams.regEx Optional. The option of regular expression search.
@param {integer} searchParams.start Optional. The zero based strat number for the range of the returned hits. E.g if there are 1000 hits in total, then 5 means the 6th hit.
@param {integer} searchParams.rows Optional. The number of hits of the range. E.g if there are 1000 hits in total and start=5 and rows=40, then the return range is 6th-45th.
@param {String} searchParams.fileNamePatterns Optional. The file name patterns within which to search. If specified, search will be performed under files which match the provided patterns. Patterns should be comma-separated and may use "*" and "?" as wildcards.
E.g. "*" means all files. "*.html,test*.js" means all html files html files and all .js files that start with "test".
@param {[String]} searchParams.exclude Optional. An array of file / folder names to exclude while searching.
|
[
"Performs",
"a",
"search",
"with",
"the",
"given",
"search",
"parameters",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js#L759-L774
|
|
14,661
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/widgets/plugin/PluginList.js
|
PluginList
|
function PluginList(options, parentNode) {
objects.mixin(this, options);
this.node = parentNode || document.createElement("div"); //$NON-NLS-0$
}
|
javascript
|
function PluginList(options, parentNode) {
objects.mixin(this, options);
this.node = parentNode || document.createElement("div"); //$NON-NLS-0$
}
|
[
"function",
"PluginList",
"(",
"options",
",",
"parentNode",
")",
"{",
"objects",
".",
"mixin",
"(",
"this",
",",
"options",
")",
";",
"this",
".",
"node",
"=",
"parentNode",
"||",
"document",
".",
"createElement",
"(",
"\"div\"",
")",
";",
"//$NON-NLS-0$\r",
"}"
] |
PluginList
UI interface element showing a list of plugins
|
[
"PluginList",
"UI",
"interface",
"element",
"showing",
"a",
"list",
"of",
"plugins"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/widgets/plugin/PluginList.js#L60-L63
|
14,662
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.debug/web/orion/debug/debugSocket.js
|
function(serviceRegistry) {
EventTarget.attach(this);
this._id = ID_INCREMENT++;
debugSockets[this._id] = this;
this._debugService = serviceRegistry.getService('orion.debug.service');
this._messageService = serviceRegistry.getService('orion.page.message');
this._socket = null;
this._connectionId = undefined;
this.supportsConfigurationDoneRequest = false;
this.supportsConditionalBreakpoints = false;
this.supportsEvaluateForHovers = false;
this._launched = false;
this._remoteRoot = '';
this._localRoot = '';
this._status = StatusEvent.STATUS.IDLE;
this._project = null;
this._frameId = undefined;
this._breakpointModifiedHandler = this._handleBreakpointModified.bind(this);
this._debugService.addEventListener('BreakpointAdded', this._breakpointModifiedHandler);
this._debugService.addEventListener('BreakpointRemoved', this._breakpointModifiedHandler);
this._debugService.addEventListener('BreakpointEnabled', this._breakpointModifiedHandler);
this._debugService.addEventListener('BreakpointDisabled', this._breakpointModifiedHandler);
}
|
javascript
|
function(serviceRegistry) {
EventTarget.attach(this);
this._id = ID_INCREMENT++;
debugSockets[this._id] = this;
this._debugService = serviceRegistry.getService('orion.debug.service');
this._messageService = serviceRegistry.getService('orion.page.message');
this._socket = null;
this._connectionId = undefined;
this.supportsConfigurationDoneRequest = false;
this.supportsConditionalBreakpoints = false;
this.supportsEvaluateForHovers = false;
this._launched = false;
this._remoteRoot = '';
this._localRoot = '';
this._status = StatusEvent.STATUS.IDLE;
this._project = null;
this._frameId = undefined;
this._breakpointModifiedHandler = this._handleBreakpointModified.bind(this);
this._debugService.addEventListener('BreakpointAdded', this._breakpointModifiedHandler);
this._debugService.addEventListener('BreakpointRemoved', this._breakpointModifiedHandler);
this._debugService.addEventListener('BreakpointEnabled', this._breakpointModifiedHandler);
this._debugService.addEventListener('BreakpointDisabled', this._breakpointModifiedHandler);
}
|
[
"function",
"(",
"serviceRegistry",
")",
"{",
"EventTarget",
".",
"attach",
"(",
"this",
")",
";",
"this",
".",
"_id",
"=",
"ID_INCREMENT",
"++",
";",
"debugSockets",
"[",
"this",
".",
"_id",
"]",
"=",
"this",
";",
"this",
".",
"_debugService",
"=",
"serviceRegistry",
".",
"getService",
"(",
"'orion.debug.service'",
")",
";",
"this",
".",
"_messageService",
"=",
"serviceRegistry",
".",
"getService",
"(",
"'orion.page.message'",
")",
";",
"this",
".",
"_socket",
"=",
"null",
";",
"this",
".",
"_connectionId",
"=",
"undefined",
";",
"this",
".",
"supportsConfigurationDoneRequest",
"=",
"false",
";",
"this",
".",
"supportsConditionalBreakpoints",
"=",
"false",
";",
"this",
".",
"supportsEvaluateForHovers",
"=",
"false",
";",
"this",
".",
"_launched",
"=",
"false",
";",
"this",
".",
"_remoteRoot",
"=",
"''",
";",
"this",
".",
"_localRoot",
"=",
"''",
";",
"this",
".",
"_status",
"=",
"StatusEvent",
".",
"STATUS",
".",
"IDLE",
";",
"this",
".",
"_project",
"=",
"null",
";",
"this",
".",
"_frameId",
"=",
"undefined",
";",
"this",
".",
"_breakpointModifiedHandler",
"=",
"this",
".",
"_handleBreakpointModified",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_debugService",
".",
"addEventListener",
"(",
"'BreakpointAdded'",
",",
"this",
".",
"_breakpointModifiedHandler",
")",
";",
"this",
".",
"_debugService",
".",
"addEventListener",
"(",
"'BreakpointRemoved'",
",",
"this",
".",
"_breakpointModifiedHandler",
")",
";",
"this",
".",
"_debugService",
".",
"addEventListener",
"(",
"'BreakpointEnabled'",
",",
"this",
".",
"_breakpointModifiedHandler",
")",
";",
"this",
".",
"_debugService",
".",
"addEventListener",
"(",
"'BreakpointDisabled'",
",",
"this",
".",
"_breakpointModifiedHandler",
")",
";",
"}"
] |
A debug socket provides the interface between orion and orion debug server.
@class {orion.debug.DebugSocket}
@see https://github.com/Microsoft/vscode-debugadapter-node/blob/master/protocol/src/debugProtocol.ts
@fires {StatusEvent} - Reports the debugger's status (idle, running or paused)
@fires {DebugProtocol.Event} event - Events from the debug adapter
@fires {CapabilitiesEvent} - Reports the capabilities of the current adapter
@param {orion.serviceregistry.ServiceRegistry} serviceRegistry
|
[
"A",
"debug",
"socket",
"provides",
"the",
"interface",
"between",
"orion",
"and",
"orion",
"debug",
"server",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.debug/web/orion/debug/debugSocket.js#L48-L73
|
|
14,663
|
eclipse/orion.client
|
modules/orionode.collab.hub/client.js
|
generateColorByName
|
function generateColorByName(str) {
var hue = 0;
for (var i = 0; i < str.length; i++) {
hue = (hue * PRIME + str.charCodeAt(i)) % MASK;
}
hue = Math.floor(hue * PRIME) % MASK / MASK;
var rgb = hslToRgb(hue, SATURATION, LIGHTNESS);
return ('#' + rgb[0].toString(16) + rgb[1].toString(16) + rgb[2].toString(16)).toUpperCase();
}
|
javascript
|
function generateColorByName(str) {
var hue = 0;
for (var i = 0; i < str.length; i++) {
hue = (hue * PRIME + str.charCodeAt(i)) % MASK;
}
hue = Math.floor(hue * PRIME) % MASK / MASK;
var rgb = hslToRgb(hue, SATURATION, LIGHTNESS);
return ('#' + rgb[0].toString(16) + rgb[1].toString(16) + rgb[2].toString(16)).toUpperCase();
}
|
[
"function",
"generateColorByName",
"(",
"str",
")",
"{",
"var",
"hue",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"str",
".",
"length",
";",
"i",
"++",
")",
"{",
"hue",
"=",
"(",
"hue",
"*",
"PRIME",
"+",
"str",
".",
"charCodeAt",
"(",
"i",
")",
")",
"%",
"MASK",
";",
"}",
"hue",
"=",
"Math",
".",
"floor",
"(",
"hue",
"*",
"PRIME",
")",
"%",
"MASK",
"/",
"MASK",
";",
"var",
"rgb",
"=",
"hslToRgb",
"(",
"hue",
",",
"SATURATION",
",",
"LIGHTNESS",
")",
";",
"return",
"(",
"'#'",
"+",
"rgb",
"[",
"0",
"]",
".",
"toString",
"(",
"16",
")",
"+",
"rgb",
"[",
"1",
"]",
".",
"toString",
"(",
"16",
")",
"+",
"rgb",
"[",
"2",
"]",
".",
"toString",
"(",
"16",
")",
")",
".",
"toUpperCase",
"(",
")",
";",
"}"
] |
Generate an RGB value from a string
@param {string} str
@return {string} - RGB value
|
[
"Generate",
"an",
"RGB",
"value",
"from",
"a",
"string"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/modules/orionode.collab.hub/client.js#L61-L69
|
14,664
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/gcli/gcli/commands/help.js
|
getManTemplateData
|
function getManTemplateData(command, context) {
var manTemplateData = {
l10n: l10n.propertyLookup,
command: command,
onclick: function(ev) {
util.updateCommand(ev.currentTarget, context);
},
ondblclick: function(ev) {
util.executeCommand(ev.currentTarget, context);
},
describe: function(item) {
return item.manual || item.description;
},
getTypeDescription: function(param) {
var input = '';
if (param.defaultValue === undefined) {
input = l10n.lookup('helpManRequired');
}
else if (param.defaultValue === null) {
input = l10n.lookup('helpManOptional');
}
else {
input = param.defaultValue;
}
return '(' + param.type.name + ', ' + input + ')';
}
};
Object.defineProperty(manTemplateData, 'subcommands', {
get: function() {
var matching = canon.getCommands().filter(function(subcommand) {
return subcommand.name.indexOf(command.name) === 0 &&
subcommand.name !== command.name;
});
matching.sort(function(c1, c2) {
return c1.name.localeCompare(c2.name);
});
return matching;
},
enumerable: true
});
return manTemplateData;
}
|
javascript
|
function getManTemplateData(command, context) {
var manTemplateData = {
l10n: l10n.propertyLookup,
command: command,
onclick: function(ev) {
util.updateCommand(ev.currentTarget, context);
},
ondblclick: function(ev) {
util.executeCommand(ev.currentTarget, context);
},
describe: function(item) {
return item.manual || item.description;
},
getTypeDescription: function(param) {
var input = '';
if (param.defaultValue === undefined) {
input = l10n.lookup('helpManRequired');
}
else if (param.defaultValue === null) {
input = l10n.lookup('helpManOptional');
}
else {
input = param.defaultValue;
}
return '(' + param.type.name + ', ' + input + ')';
}
};
Object.defineProperty(manTemplateData, 'subcommands', {
get: function() {
var matching = canon.getCommands().filter(function(subcommand) {
return subcommand.name.indexOf(command.name) === 0 &&
subcommand.name !== command.name;
});
matching.sort(function(c1, c2) {
return c1.name.localeCompare(c2.name);
});
return matching;
},
enumerable: true
});
return manTemplateData;
}
|
[
"function",
"getManTemplateData",
"(",
"command",
",",
"context",
")",
"{",
"var",
"manTemplateData",
"=",
"{",
"l10n",
":",
"l10n",
".",
"propertyLookup",
",",
"command",
":",
"command",
",",
"onclick",
":",
"function",
"(",
"ev",
")",
"{",
"util",
".",
"updateCommand",
"(",
"ev",
".",
"currentTarget",
",",
"context",
")",
";",
"}",
",",
"ondblclick",
":",
"function",
"(",
"ev",
")",
"{",
"util",
".",
"executeCommand",
"(",
"ev",
".",
"currentTarget",
",",
"context",
")",
";",
"}",
",",
"describe",
":",
"function",
"(",
"item",
")",
"{",
"return",
"item",
".",
"manual",
"||",
"item",
".",
"description",
";",
"}",
",",
"getTypeDescription",
":",
"function",
"(",
"param",
")",
"{",
"var",
"input",
"=",
"''",
";",
"if",
"(",
"param",
".",
"defaultValue",
"===",
"undefined",
")",
"{",
"input",
"=",
"l10n",
".",
"lookup",
"(",
"'helpManRequired'",
")",
";",
"}",
"else",
"if",
"(",
"param",
".",
"defaultValue",
"===",
"null",
")",
"{",
"input",
"=",
"l10n",
".",
"lookup",
"(",
"'helpManOptional'",
")",
";",
"}",
"else",
"{",
"input",
"=",
"param",
".",
"defaultValue",
";",
"}",
"return",
"'('",
"+",
"param",
".",
"type",
".",
"name",
"+",
"', '",
"+",
"input",
"+",
"')'",
";",
"}",
"}",
";",
"Object",
".",
"defineProperty",
"(",
"manTemplateData",
",",
"'subcommands'",
",",
"{",
"get",
":",
"function",
"(",
")",
"{",
"var",
"matching",
"=",
"canon",
".",
"getCommands",
"(",
")",
".",
"filter",
"(",
"function",
"(",
"subcommand",
")",
"{",
"return",
"subcommand",
".",
"name",
".",
"indexOf",
"(",
"command",
".",
"name",
")",
"===",
"0",
"&&",
"subcommand",
".",
"name",
"!==",
"command",
".",
"name",
";",
"}",
")",
";",
"matching",
".",
"sort",
"(",
"function",
"(",
"c1",
",",
"c2",
")",
"{",
"return",
"c1",
".",
"name",
".",
"localeCompare",
"(",
"c2",
".",
"name",
")",
";",
"}",
")",
";",
"return",
"matching",
";",
"}",
",",
"enumerable",
":",
"true",
"}",
")",
";",
"return",
"manTemplateData",
";",
"}"
] |
Create a block of data suitable to be passed to the help_man.html template
|
[
"Create",
"a",
"block",
"of",
"data",
"suitable",
"to",
"be",
"passed",
"to",
"the",
"help_man",
".",
"html",
"template"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/gcli/gcli/commands/help.js#L136-L183
|
14,665
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.editor/web/orion/editor/actions.js
|
TextActions
|
function TextActions(editor, undoStack, find) {
this.editor = editor;
this.undoStack = undoStack;
this._incrementalFind = new mFind.IncrementalFind(editor);
this._find = find ? find : new mFindUI.FindUI(editor, undoStack);
this._lastEditLocation = null;
this.init();
}
|
javascript
|
function TextActions(editor, undoStack, find) {
this.editor = editor;
this.undoStack = undoStack;
this._incrementalFind = new mFind.IncrementalFind(editor);
this._find = find ? find : new mFindUI.FindUI(editor, undoStack);
this._lastEditLocation = null;
this.init();
}
|
[
"function",
"TextActions",
"(",
"editor",
",",
"undoStack",
",",
"find",
")",
"{",
"this",
".",
"editor",
"=",
"editor",
";",
"this",
".",
"undoStack",
"=",
"undoStack",
";",
"this",
".",
"_incrementalFind",
"=",
"new",
"mFind",
".",
"IncrementalFind",
"(",
"editor",
")",
";",
"this",
".",
"_find",
"=",
"find",
"?",
"find",
":",
"new",
"mFindUI",
".",
"FindUI",
"(",
"editor",
",",
"undoStack",
")",
";",
"this",
".",
"_lastEditLocation",
"=",
"null",
";",
"this",
".",
"init",
"(",
")",
";",
"}"
] |
TextActions connects common text editing keybindings onto an editor.
|
[
"TextActions",
"connects",
"common",
"text",
"editing",
"keybindings",
"onto",
"an",
"editor",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.editor/web/orion/editor/actions.js#L48-L55
|
14,666
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.editor/web/orion/editor/actions.js
|
function(openBracket, closeBracket) {
if (openBracket === "[" && !this.autoPairSquareBrackets) { //$NON-NLS-0$
return false;
} else if (openBracket === "{" && !this.autoPairBraces) { //$NON-NLS-0$
return false;
} else if (openBracket === "(" && !this.autoPairParentheses) { //$NON-NLS-0$
return false;
} else if (openBracket === "<" && !this.autoPairAngleBrackets) { //$NON-NLS-0$
return false;
}
var editor = this.editor;
var textView = editor.getTextView();
if (textView.getOptions("readonly")) { return false; } //$NON-NLS-0$
var isClosingBracket = new RegExp("^$|[)}\\]>]"); //$NON-NLS-0$ // matches any empty string and closing bracket
var model = editor.getModel();
forEachSelection(this, false, function(selection, setText) {
var nextChar = (selection.start === model.getCharCount()) ? "" : model.getText(selection.start, selection.start + 1).trim(); //$NON-NLS-0$
var text;
if (selection.start === selection.end && isClosingBracket.test(nextChar)) {
// No selection and subsequent character is not a closing bracket - wrap the caret with the opening and closing brackets,
// and maintain the caret position inbetween the brackets
text = openBracket + closeBracket;
setText(text, selection.start, selection.start);
selection.start = selection.end = selection.start + 1;
} else if (selection.start !== selection.end) {
// Wrap the selected text with the specified opening and closing brackets and keep selection on text
text = openBracket + model.getText(selection.start, selection.end) + closeBracket;
setText(text, selection.start, selection.end);
selection.start += 1;
selection.end += 1;
} else {
setText(openBracket, selection.start, selection.end);
selection.start = selection.end = selection.start + openBracket.length;
}
});
return true;
}
|
javascript
|
function(openBracket, closeBracket) {
if (openBracket === "[" && !this.autoPairSquareBrackets) { //$NON-NLS-0$
return false;
} else if (openBracket === "{" && !this.autoPairBraces) { //$NON-NLS-0$
return false;
} else if (openBracket === "(" && !this.autoPairParentheses) { //$NON-NLS-0$
return false;
} else if (openBracket === "<" && !this.autoPairAngleBrackets) { //$NON-NLS-0$
return false;
}
var editor = this.editor;
var textView = editor.getTextView();
if (textView.getOptions("readonly")) { return false; } //$NON-NLS-0$
var isClosingBracket = new RegExp("^$|[)}\\]>]"); //$NON-NLS-0$ // matches any empty string and closing bracket
var model = editor.getModel();
forEachSelection(this, false, function(selection, setText) {
var nextChar = (selection.start === model.getCharCount()) ? "" : model.getText(selection.start, selection.start + 1).trim(); //$NON-NLS-0$
var text;
if (selection.start === selection.end && isClosingBracket.test(nextChar)) {
// No selection and subsequent character is not a closing bracket - wrap the caret with the opening and closing brackets,
// and maintain the caret position inbetween the brackets
text = openBracket + closeBracket;
setText(text, selection.start, selection.start);
selection.start = selection.end = selection.start + 1;
} else if (selection.start !== selection.end) {
// Wrap the selected text with the specified opening and closing brackets and keep selection on text
text = openBracket + model.getText(selection.start, selection.end) + closeBracket;
setText(text, selection.start, selection.end);
selection.start += 1;
selection.end += 1;
} else {
setText(openBracket, selection.start, selection.end);
selection.start = selection.end = selection.start + openBracket.length;
}
});
return true;
}
|
[
"function",
"(",
"openBracket",
",",
"closeBracket",
")",
"{",
"if",
"(",
"openBracket",
"===",
"\"[\"",
"&&",
"!",
"this",
".",
"autoPairSquareBrackets",
")",
"{",
"//$NON-NLS-0$\r",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"openBracket",
"===",
"\"{\"",
"&&",
"!",
"this",
".",
"autoPairBraces",
")",
"{",
"//$NON-NLS-0$\r",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"openBracket",
"===",
"\"(\"",
"&&",
"!",
"this",
".",
"autoPairParentheses",
")",
"{",
"//$NON-NLS-0$\r",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"openBracket",
"===",
"\"<\"",
"&&",
"!",
"this",
".",
"autoPairAngleBrackets",
")",
"{",
"//$NON-NLS-0$\r",
"return",
"false",
";",
"}",
"var",
"editor",
"=",
"this",
".",
"editor",
";",
"var",
"textView",
"=",
"editor",
".",
"getTextView",
"(",
")",
";",
"if",
"(",
"textView",
".",
"getOptions",
"(",
"\"readonly\"",
")",
")",
"{",
"return",
"false",
";",
"}",
"//$NON-NLS-0$\r",
"var",
"isClosingBracket",
"=",
"new",
"RegExp",
"(",
"\"^$|[)}\\\\]>]\"",
")",
";",
"//$NON-NLS-0$ // matches any empty string and closing bracket\r",
"var",
"model",
"=",
"editor",
".",
"getModel",
"(",
")",
";",
"forEachSelection",
"(",
"this",
",",
"false",
",",
"function",
"(",
"selection",
",",
"setText",
")",
"{",
"var",
"nextChar",
"=",
"(",
"selection",
".",
"start",
"===",
"model",
".",
"getCharCount",
"(",
")",
")",
"?",
"\"\"",
":",
"model",
".",
"getText",
"(",
"selection",
".",
"start",
",",
"selection",
".",
"start",
"+",
"1",
")",
".",
"trim",
"(",
")",
";",
"//$NON-NLS-0$\r",
"var",
"text",
";",
"if",
"(",
"selection",
".",
"start",
"===",
"selection",
".",
"end",
"&&",
"isClosingBracket",
".",
"test",
"(",
"nextChar",
")",
")",
"{",
"// No selection and subsequent character is not a closing bracket - wrap the caret with the opening and closing brackets,\r",
"// and maintain the caret position inbetween the brackets\r",
"text",
"=",
"openBracket",
"+",
"closeBracket",
";",
"setText",
"(",
"text",
",",
"selection",
".",
"start",
",",
"selection",
".",
"start",
")",
";",
"selection",
".",
"start",
"=",
"selection",
".",
"end",
"=",
"selection",
".",
"start",
"+",
"1",
";",
"}",
"else",
"if",
"(",
"selection",
".",
"start",
"!==",
"selection",
".",
"end",
")",
"{",
"// Wrap the selected text with the specified opening and closing brackets and keep selection on text\r",
"text",
"=",
"openBracket",
"+",
"model",
".",
"getText",
"(",
"selection",
".",
"start",
",",
"selection",
".",
"end",
")",
"+",
"closeBracket",
";",
"setText",
"(",
"text",
",",
"selection",
".",
"start",
",",
"selection",
".",
"end",
")",
";",
"selection",
".",
"start",
"+=",
"1",
";",
"selection",
".",
"end",
"+=",
"1",
";",
"}",
"else",
"{",
"setText",
"(",
"openBracket",
",",
"selection",
".",
"start",
",",
"selection",
".",
"end",
")",
";",
"selection",
".",
"start",
"=",
"selection",
".",
"end",
"=",
"selection",
".",
"start",
"+",
"openBracket",
".",
"length",
";",
"}",
"}",
")",
";",
"return",
"true",
";",
"}"
] |
Called on an opening bracket keypress.
Automatically inserts the specified opening and closing brackets around the caret or selected text.
|
[
"Called",
"on",
"an",
"opening",
"bracket",
"keypress",
".",
"Automatically",
"inserts",
"the",
"specified",
"opening",
"and",
"closing",
"brackets",
"around",
"the",
"caret",
"or",
"selected",
"text",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.editor/web/orion/editor/actions.js#L893-L930
|
|
14,667
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.editor/web/orion/editor/actions.js
|
function(quotation) {
if (!this.autoPairQuotation) { return false; }
var editor = this.editor;
var textView = editor.getTextView();
if (textView.getOptions("readonly")) { return false; } //$NON-NLS-0$
var isQuotation = new RegExp("^\"$|^'$"); //$NON-NLS-0$
var isAlpha = new RegExp("\\w"); //$NON-NLS-0$
var isClosingBracket = new RegExp("^$|[)}\\]>]"); //$NON-NLS-0$ // matches any empty string and closing bracket
var model = editor.getModel();
forEachSelection(this, false, function(selection, setText) {
var prevChar = (selection.start === 0) ? "" : model.getText(selection.start - 1, selection.start).trim(); //$NON-NLS-0$
var nextChar = (selection.start === model.getCharCount()) ? "" : model.getText(selection.start, selection.start + 1).trim(); //$NON-NLS-0$
function insertQuotation() {
setText(quotation, selection.start, selection.end);
selection.start = selection.end = selection.start + quotation.length;
}
// Wrap the selected text with the specified opening and closing quotation marks and keep selection on text
if (selection.start !== selection.end) {
var text = model.getText(selection.start, selection.end);
if (isQuotation.test(text)) {
insertQuotation();
} else {
setText(quotation + text + quotation, selection.start, selection.end);
selection.start += 1;
selection.end += 1;
}
} else if (nextChar === quotation) {
// Skip over the next character if it matches the specified quotation mark
selection.start = selection.end = selection.start + 1;
} else if (prevChar === quotation || isQuotation.test(nextChar) || isAlpha.test(prevChar) || !isClosingBracket.test(nextChar)) {
insertQuotation();
} else {
// No selection - wrap the caret with the opening and closing quotation marks, and maintain the caret position inbetween the quotations
setText(quotation + quotation, selection.start, selection.end);
selection.start = selection.end = selection.start + quotation.length;
}
});
return true;
}
|
javascript
|
function(quotation) {
if (!this.autoPairQuotation) { return false; }
var editor = this.editor;
var textView = editor.getTextView();
if (textView.getOptions("readonly")) { return false; } //$NON-NLS-0$
var isQuotation = new RegExp("^\"$|^'$"); //$NON-NLS-0$
var isAlpha = new RegExp("\\w"); //$NON-NLS-0$
var isClosingBracket = new RegExp("^$|[)}\\]>]"); //$NON-NLS-0$ // matches any empty string and closing bracket
var model = editor.getModel();
forEachSelection(this, false, function(selection, setText) {
var prevChar = (selection.start === 0) ? "" : model.getText(selection.start - 1, selection.start).trim(); //$NON-NLS-0$
var nextChar = (selection.start === model.getCharCount()) ? "" : model.getText(selection.start, selection.start + 1).trim(); //$NON-NLS-0$
function insertQuotation() {
setText(quotation, selection.start, selection.end);
selection.start = selection.end = selection.start + quotation.length;
}
// Wrap the selected text with the specified opening and closing quotation marks and keep selection on text
if (selection.start !== selection.end) {
var text = model.getText(selection.start, selection.end);
if (isQuotation.test(text)) {
insertQuotation();
} else {
setText(quotation + text + quotation, selection.start, selection.end);
selection.start += 1;
selection.end += 1;
}
} else if (nextChar === quotation) {
// Skip over the next character if it matches the specified quotation mark
selection.start = selection.end = selection.start + 1;
} else if (prevChar === quotation || isQuotation.test(nextChar) || isAlpha.test(prevChar) || !isClosingBracket.test(nextChar)) {
insertQuotation();
} else {
// No selection - wrap the caret with the opening and closing quotation marks, and maintain the caret position inbetween the quotations
setText(quotation + quotation, selection.start, selection.end);
selection.start = selection.end = selection.start + quotation.length;
}
});
return true;
}
|
[
"function",
"(",
"quotation",
")",
"{",
"if",
"(",
"!",
"this",
".",
"autoPairQuotation",
")",
"{",
"return",
"false",
";",
"}",
"var",
"editor",
"=",
"this",
".",
"editor",
";",
"var",
"textView",
"=",
"editor",
".",
"getTextView",
"(",
")",
";",
"if",
"(",
"textView",
".",
"getOptions",
"(",
"\"readonly\"",
")",
")",
"{",
"return",
"false",
";",
"}",
"//$NON-NLS-0$\r",
"var",
"isQuotation",
"=",
"new",
"RegExp",
"(",
"\"^\\\"$|^'$\"",
")",
";",
"//$NON-NLS-0$\r",
"var",
"isAlpha",
"=",
"new",
"RegExp",
"(",
"\"\\\\w\"",
")",
";",
"//$NON-NLS-0$\r",
"var",
"isClosingBracket",
"=",
"new",
"RegExp",
"(",
"\"^$|[)}\\\\]>]\"",
")",
";",
"//$NON-NLS-0$ // matches any empty string and closing bracket\r",
"var",
"model",
"=",
"editor",
".",
"getModel",
"(",
")",
";",
"forEachSelection",
"(",
"this",
",",
"false",
",",
"function",
"(",
"selection",
",",
"setText",
")",
"{",
"var",
"prevChar",
"=",
"(",
"selection",
".",
"start",
"===",
"0",
")",
"?",
"\"\"",
":",
"model",
".",
"getText",
"(",
"selection",
".",
"start",
"-",
"1",
",",
"selection",
".",
"start",
")",
".",
"trim",
"(",
")",
";",
"//$NON-NLS-0$\r",
"var",
"nextChar",
"=",
"(",
"selection",
".",
"start",
"===",
"model",
".",
"getCharCount",
"(",
")",
")",
"?",
"\"\"",
":",
"model",
".",
"getText",
"(",
"selection",
".",
"start",
",",
"selection",
".",
"start",
"+",
"1",
")",
".",
"trim",
"(",
")",
";",
"//$NON-NLS-0$\r",
"function",
"insertQuotation",
"(",
")",
"{",
"setText",
"(",
"quotation",
",",
"selection",
".",
"start",
",",
"selection",
".",
"end",
")",
";",
"selection",
".",
"start",
"=",
"selection",
".",
"end",
"=",
"selection",
".",
"start",
"+",
"quotation",
".",
"length",
";",
"}",
"// Wrap the selected text with the specified opening and closing quotation marks and keep selection on text\r",
"if",
"(",
"selection",
".",
"start",
"!==",
"selection",
".",
"end",
")",
"{",
"var",
"text",
"=",
"model",
".",
"getText",
"(",
"selection",
".",
"start",
",",
"selection",
".",
"end",
")",
";",
"if",
"(",
"isQuotation",
".",
"test",
"(",
"text",
")",
")",
"{",
"insertQuotation",
"(",
")",
";",
"}",
"else",
"{",
"setText",
"(",
"quotation",
"+",
"text",
"+",
"quotation",
",",
"selection",
".",
"start",
",",
"selection",
".",
"end",
")",
";",
"selection",
".",
"start",
"+=",
"1",
";",
"selection",
".",
"end",
"+=",
"1",
";",
"}",
"}",
"else",
"if",
"(",
"nextChar",
"===",
"quotation",
")",
"{",
"// Skip over the next character if it matches the specified quotation mark\r",
"selection",
".",
"start",
"=",
"selection",
".",
"end",
"=",
"selection",
".",
"start",
"+",
"1",
";",
"}",
"else",
"if",
"(",
"prevChar",
"===",
"quotation",
"||",
"isQuotation",
".",
"test",
"(",
"nextChar",
")",
"||",
"isAlpha",
".",
"test",
"(",
"prevChar",
")",
"||",
"!",
"isClosingBracket",
".",
"test",
"(",
"nextChar",
")",
")",
"{",
"insertQuotation",
"(",
")",
";",
"}",
"else",
"{",
"// No selection - wrap the caret with the opening and closing quotation marks, and maintain the caret position inbetween the quotations\r",
"setText",
"(",
"quotation",
"+",
"quotation",
",",
"selection",
".",
"start",
",",
"selection",
".",
"end",
")",
";",
"selection",
".",
"start",
"=",
"selection",
".",
"end",
"=",
"selection",
".",
"start",
"+",
"quotation",
".",
"length",
";",
"}",
"}",
")",
";",
"return",
"true",
";",
"}"
] |
Called on a quotation mark keypress.
Automatically inserts a pair of the specified quotation around the caret the caret or selected text.
|
[
"Called",
"on",
"a",
"quotation",
"mark",
"keypress",
".",
"Automatically",
"inserts",
"a",
"pair",
"of",
"the",
"specified",
"quotation",
"around",
"the",
"caret",
"the",
"caret",
"or",
"selected",
"text",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.editor/web/orion/editor/actions.js#L935-L973
|
|
14,668
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.editor/web/orion/editor/actions.js
|
function(event) {
/*
* The event.proposal is an object with this shape:
* { proposal: "[proposal string]", // Actual text of the proposal
* description: "diplay string", // Optional
* positions: [{
* offset: 10, // Offset of start position of parameter i
* length: 3 // Length of parameter string for parameter i
* }], // One object for each parameter; can be null
* escapePosition: 19, // Optional; offset that caret will be placed at after exiting Linked Mode.
* style: 'emphasis', // Optional: either emphasis, noemphasis, hr to provide custom styling for the proposal
* unselectable: false // Optional: if set to true, then this proposal cannnot be selected through the keyboard
* }
* Offsets are relative to the text buffer.
*/
var proposal = event.data.proposal;
// If escapePosition is not provided, positioned the cursor at the end of the inserted text
function escapePosition() {
if (typeof proposal.escapePosition === "number") { //$NON-NLS-0$
return proposal.escapePosition;
}
return event.data.start + proposal.proposal.length;
}
//if the proposal specifies linked positions, build the model and enter linked mode
if (Array.isArray(proposal.positions) && this.linkedMode) {
var positionGroups = [];
proposal.positions.forEach(function(pos) {
//ignore bad proposal values
//@see https://bugs.eclipse.org/bugs/show_bug.cgi?id=513146
if(typeof pos.offset === "number" && typeof pos.length === "number") {
positionGroups.push({positions: [{offset: pos.offset, length: pos.length}]});
}
});
if(positionGroups.length > 0) {
this.linkedMode.enterLinkedMode({
groups: positionGroups,
escapePosition: escapePosition()
});
} else {
this.editor.getTextView().setCaretOffset(escapePosition());
}
} else if (proposal.groups && proposal.groups.length > 0 && this.linkedMode) {
this.linkedMode.enterLinkedMode({
groups: proposal.groups,
escapePosition: escapePosition()
});
} else if (typeof proposal.escapePosition === "number") { //$NON-NLS-0$
//we don't want linked mode, but there is an escape position, so just set cursor position
this.editor.getTextView().setCaretOffset(proposal.escapePosition);
}
return true;
}
|
javascript
|
function(event) {
/*
* The event.proposal is an object with this shape:
* { proposal: "[proposal string]", // Actual text of the proposal
* description: "diplay string", // Optional
* positions: [{
* offset: 10, // Offset of start position of parameter i
* length: 3 // Length of parameter string for parameter i
* }], // One object for each parameter; can be null
* escapePosition: 19, // Optional; offset that caret will be placed at after exiting Linked Mode.
* style: 'emphasis', // Optional: either emphasis, noemphasis, hr to provide custom styling for the proposal
* unselectable: false // Optional: if set to true, then this proposal cannnot be selected through the keyboard
* }
* Offsets are relative to the text buffer.
*/
var proposal = event.data.proposal;
// If escapePosition is not provided, positioned the cursor at the end of the inserted text
function escapePosition() {
if (typeof proposal.escapePosition === "number") { //$NON-NLS-0$
return proposal.escapePosition;
}
return event.data.start + proposal.proposal.length;
}
//if the proposal specifies linked positions, build the model and enter linked mode
if (Array.isArray(proposal.positions) && this.linkedMode) {
var positionGroups = [];
proposal.positions.forEach(function(pos) {
//ignore bad proposal values
//@see https://bugs.eclipse.org/bugs/show_bug.cgi?id=513146
if(typeof pos.offset === "number" && typeof pos.length === "number") {
positionGroups.push({positions: [{offset: pos.offset, length: pos.length}]});
}
});
if(positionGroups.length > 0) {
this.linkedMode.enterLinkedMode({
groups: positionGroups,
escapePosition: escapePosition()
});
} else {
this.editor.getTextView().setCaretOffset(escapePosition());
}
} else if (proposal.groups && proposal.groups.length > 0 && this.linkedMode) {
this.linkedMode.enterLinkedMode({
groups: proposal.groups,
escapePosition: escapePosition()
});
} else if (typeof proposal.escapePosition === "number") { //$NON-NLS-0$
//we don't want linked mode, but there is an escape position, so just set cursor position
this.editor.getTextView().setCaretOffset(proposal.escapePosition);
}
return true;
}
|
[
"function",
"(",
"event",
")",
"{",
"/*\r\n\t\t\t * The event.proposal is an object with this shape:\r\n\t\t\t * { proposal: \"[proposal string]\", // Actual text of the proposal\r\n\t\t\t * description: \"diplay string\", // Optional\r\n\t\t\t * positions: [{\r\n\t\t\t * offset: 10, // Offset of start position of parameter i\r\n\t\t\t * length: 3 // Length of parameter string for parameter i\r\n\t\t\t * }], // One object for each parameter; can be null\r\n\t\t\t * escapePosition: 19, // Optional; offset that caret will be placed at after exiting Linked Mode.\r\n\t\t\t * style: 'emphasis', // Optional: either emphasis, noemphasis, hr to provide custom styling for the proposal\r\n\t\t\t * unselectable: false // Optional: if set to true, then this proposal cannnot be selected through the keyboard\r\n\t\t\t * }\r\n\t\t\t * Offsets are relative to the text buffer.\r\n\t\t\t */",
"var",
"proposal",
"=",
"event",
".",
"data",
".",
"proposal",
";",
"// If escapePosition is not provided, positioned the cursor at the end of the inserted text \r",
"function",
"escapePosition",
"(",
")",
"{",
"if",
"(",
"typeof",
"proposal",
".",
"escapePosition",
"===",
"\"number\"",
")",
"{",
"//$NON-NLS-0$\r",
"return",
"proposal",
".",
"escapePosition",
";",
"}",
"return",
"event",
".",
"data",
".",
"start",
"+",
"proposal",
".",
"proposal",
".",
"length",
";",
"}",
"//if the proposal specifies linked positions, build the model and enter linked mode\r",
"if",
"(",
"Array",
".",
"isArray",
"(",
"proposal",
".",
"positions",
")",
"&&",
"this",
".",
"linkedMode",
")",
"{",
"var",
"positionGroups",
"=",
"[",
"]",
";",
"proposal",
".",
"positions",
".",
"forEach",
"(",
"function",
"(",
"pos",
")",
"{",
"//ignore bad proposal values\r",
"//@see https://bugs.eclipse.org/bugs/show_bug.cgi?id=513146\r",
"if",
"(",
"typeof",
"pos",
".",
"offset",
"===",
"\"number\"",
"&&",
"typeof",
"pos",
".",
"length",
"===",
"\"number\"",
")",
"{",
"positionGroups",
".",
"push",
"(",
"{",
"positions",
":",
"[",
"{",
"offset",
":",
"pos",
".",
"offset",
",",
"length",
":",
"pos",
".",
"length",
"}",
"]",
"}",
")",
";",
"}",
"}",
")",
";",
"if",
"(",
"positionGroups",
".",
"length",
">",
"0",
")",
"{",
"this",
".",
"linkedMode",
".",
"enterLinkedMode",
"(",
"{",
"groups",
":",
"positionGroups",
",",
"escapePosition",
":",
"escapePosition",
"(",
")",
"}",
")",
";",
"}",
"else",
"{",
"this",
".",
"editor",
".",
"getTextView",
"(",
")",
".",
"setCaretOffset",
"(",
"escapePosition",
"(",
")",
")",
";",
"}",
"}",
"else",
"if",
"(",
"proposal",
".",
"groups",
"&&",
"proposal",
".",
"groups",
".",
"length",
">",
"0",
"&&",
"this",
".",
"linkedMode",
")",
"{",
"this",
".",
"linkedMode",
".",
"enterLinkedMode",
"(",
"{",
"groups",
":",
"proposal",
".",
"groups",
",",
"escapePosition",
":",
"escapePosition",
"(",
")",
"}",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"proposal",
".",
"escapePosition",
"===",
"\"number\"",
")",
"{",
"//$NON-NLS-0$\r",
"//we don't want linked mode, but there is an escape position, so just set cursor position\r",
"this",
".",
"editor",
".",
"getTextView",
"(",
")",
".",
"setCaretOffset",
"(",
"proposal",
".",
"escapePosition",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Called when a content assist proposal has been applied. Inserts the proposal into the
document. Activates Linked Mode if applicable for the selected proposal.
@param {orion.editor.ContentAssist#ProposalAppliedEvent} event
|
[
"Called",
"when",
"a",
"content",
"assist",
"proposal",
"has",
"been",
"applied",
".",
"Inserts",
"the",
"proposal",
"into",
"the",
"document",
".",
"Activates",
"Linked",
"Mode",
"if",
"applicable",
"for",
"the",
"selected",
"proposal",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.editor/web/orion/editor/actions.js#L979-L1032
|
|
14,669
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.editor/web/orion/editor/actions.js
|
escapePosition
|
function escapePosition() {
if (typeof proposal.escapePosition === "number") { //$NON-NLS-0$
return proposal.escapePosition;
}
return event.data.start + proposal.proposal.length;
}
|
javascript
|
function escapePosition() {
if (typeof proposal.escapePosition === "number") { //$NON-NLS-0$
return proposal.escapePosition;
}
return event.data.start + proposal.proposal.length;
}
|
[
"function",
"escapePosition",
"(",
")",
"{",
"if",
"(",
"typeof",
"proposal",
".",
"escapePosition",
"===",
"\"number\"",
")",
"{",
"//$NON-NLS-0$\r",
"return",
"proposal",
".",
"escapePosition",
";",
"}",
"return",
"event",
".",
"data",
".",
"start",
"+",
"proposal",
".",
"proposal",
".",
"length",
";",
"}"
] |
If escapePosition is not provided, positioned the cursor at the end of the inserted text
|
[
"If",
"escapePosition",
"is",
"not",
"provided",
"positioned",
"the",
"cursor",
"at",
"the",
"end",
"of",
"the",
"inserted",
"text"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.editor/web/orion/editor/actions.js#L997-L1002
|
14,670
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.editor/web/orion/editor/actions.js
|
function() {
var editor = this.editor;
var textView = editor.getTextView();
if (textView.getOptions("readonly")) { return false; } //$NON-NLS-0$
var model = editor.getModel();
forEachSelection(this, false, function(selection, setText) {
if (selection.start !== selection.end) { return; }
var prevChar = (selection.start === 0) ? "" : model.getText(selection.start - 1, selection.start); //$NON-NLS-0$
var nextChar = (selection.start === model.getCharCount()) ? "" : model.getText(selection.start, selection.start + 1); //$NON-NLS-0$
if (prevChar === "(" && nextChar === ")" || //$NON-NLS-1$ //$NON-NLS-2$
prevChar === "[" && nextChar === "]" || //$NON-NLS-1$ //$NON-NLS-2$
prevChar === "{" && nextChar === "}" || //$NON-NLS-1$ //$NON-NLS-2$
prevChar === "<" && nextChar === ">" || //$NON-NLS-1$ //$NON-NLS-2$
prevChar === '"' && nextChar === '"' || //$NON-NLS-1$ //$NON-NLS-2$
prevChar === "'" && nextChar === "'") { //$NON-NLS-1$ //$NON-NLS-2$
setText("", selection.start, selection.start + 1); //$NON-NLS-0$
}
}, true);
return false;
}
|
javascript
|
function() {
var editor = this.editor;
var textView = editor.getTextView();
if (textView.getOptions("readonly")) { return false; } //$NON-NLS-0$
var model = editor.getModel();
forEachSelection(this, false, function(selection, setText) {
if (selection.start !== selection.end) { return; }
var prevChar = (selection.start === 0) ? "" : model.getText(selection.start - 1, selection.start); //$NON-NLS-0$
var nextChar = (selection.start === model.getCharCount()) ? "" : model.getText(selection.start, selection.start + 1); //$NON-NLS-0$
if (prevChar === "(" && nextChar === ")" || //$NON-NLS-1$ //$NON-NLS-2$
prevChar === "[" && nextChar === "]" || //$NON-NLS-1$ //$NON-NLS-2$
prevChar === "{" && nextChar === "}" || //$NON-NLS-1$ //$NON-NLS-2$
prevChar === "<" && nextChar === ">" || //$NON-NLS-1$ //$NON-NLS-2$
prevChar === '"' && nextChar === '"' || //$NON-NLS-1$ //$NON-NLS-2$
prevChar === "'" && nextChar === "'") { //$NON-NLS-1$ //$NON-NLS-2$
setText("", selection.start, selection.start + 1); //$NON-NLS-0$
}
}, true);
return false;
}
|
[
"function",
"(",
")",
"{",
"var",
"editor",
"=",
"this",
".",
"editor",
";",
"var",
"textView",
"=",
"editor",
".",
"getTextView",
"(",
")",
";",
"if",
"(",
"textView",
".",
"getOptions",
"(",
"\"readonly\"",
")",
")",
"{",
"return",
"false",
";",
"}",
"//$NON-NLS-0$\r",
"var",
"model",
"=",
"editor",
".",
"getModel",
"(",
")",
";",
"forEachSelection",
"(",
"this",
",",
"false",
",",
"function",
"(",
"selection",
",",
"setText",
")",
"{",
"if",
"(",
"selection",
".",
"start",
"!==",
"selection",
".",
"end",
")",
"{",
"return",
";",
"}",
"var",
"prevChar",
"=",
"(",
"selection",
".",
"start",
"===",
"0",
")",
"?",
"\"\"",
":",
"model",
".",
"getText",
"(",
"selection",
".",
"start",
"-",
"1",
",",
"selection",
".",
"start",
")",
";",
"//$NON-NLS-0$\r",
"var",
"nextChar",
"=",
"(",
"selection",
".",
"start",
"===",
"model",
".",
"getCharCount",
"(",
")",
")",
"?",
"\"\"",
":",
"model",
".",
"getText",
"(",
"selection",
".",
"start",
",",
"selection",
".",
"start",
"+",
"1",
")",
";",
"//$NON-NLS-0$\r",
"if",
"(",
"prevChar",
"===",
"\"(\"",
"&&",
"nextChar",
"===",
"\")\"",
"||",
"//$NON-NLS-1$ //$NON-NLS-2$\r",
"prevChar",
"===",
"\"[\"",
"&&",
"nextChar",
"===",
"\"]\"",
"||",
"//$NON-NLS-1$ //$NON-NLS-2$\r",
"prevChar",
"===",
"\"{\"",
"&&",
"nextChar",
"===",
"\"}\"",
"||",
"//$NON-NLS-1$ //$NON-NLS-2$\r",
"prevChar",
"===",
"\"<\"",
"&&",
"nextChar",
"===",
"\">\"",
"||",
"//$NON-NLS-1$ //$NON-NLS-2$\r",
"prevChar",
"===",
"'\"'",
"&&",
"nextChar",
"===",
"'\"'",
"||",
"//$NON-NLS-1$ //$NON-NLS-2$\r",
"prevChar",
"===",
"\"'\"",
"&&",
"nextChar",
"===",
"\"'\"",
")",
"{",
"//$NON-NLS-1$ //$NON-NLS-2$\r",
"setText",
"(",
"\"\"",
",",
"selection",
".",
"start",
",",
"selection",
".",
"start",
"+",
"1",
")",
";",
"//$NON-NLS-0$\r",
"}",
"}",
",",
"true",
")",
";",
"return",
"false",
";",
"}"
] |
On backspace keypress, checks if there are a pair of brackets or quotation marks to be deleted
|
[
"On",
"backspace",
"keypress",
"checks",
"if",
"there",
"are",
"a",
"pair",
"of",
"brackets",
"or",
"quotation",
"marks",
"to",
"be",
"deleted"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.editor/web/orion/editor/actions.js#L1034-L1055
|
|
14,671
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.git/web/orion/git/util.js
|
trimCommitMessage
|
function trimCommitMessage(message) {
var splitted = message.split(/\r\n|\n/);
var iterator = 0;
while(splitted.length > 0 && /^\s*$/.test(splitted[iterator])) {
iterator++;
}
var maxMessageLength = 100;
if (splitted[iterator].length > maxMessageLength) return splitted[iterator].substring(0,maxMessageLength);
return splitted[iterator];
}
|
javascript
|
function trimCommitMessage(message) {
var splitted = message.split(/\r\n|\n/);
var iterator = 0;
while(splitted.length > 0 && /^\s*$/.test(splitted[iterator])) {
iterator++;
}
var maxMessageLength = 100;
if (splitted[iterator].length > maxMessageLength) return splitted[iterator].substring(0,maxMessageLength);
return splitted[iterator];
}
|
[
"function",
"trimCommitMessage",
"(",
"message",
")",
"{",
"var",
"splitted",
"=",
"message",
".",
"split",
"(",
"/",
"\\r\\n|\\n",
"/",
")",
";",
"var",
"iterator",
"=",
"0",
";",
"while",
"(",
"splitted",
".",
"length",
">",
"0",
"&&",
"/",
"^\\s*$",
"/",
".",
"test",
"(",
"splitted",
"[",
"iterator",
"]",
")",
")",
"{",
"iterator",
"++",
";",
"}",
"var",
"maxMessageLength",
"=",
"100",
";",
"if",
"(",
"splitted",
"[",
"iterator",
"]",
".",
"length",
">",
"maxMessageLength",
")",
"return",
"splitted",
"[",
"iterator",
"]",
".",
"substring",
"(",
"0",
",",
"maxMessageLength",
")",
";",
"return",
"splitted",
"[",
"iterator",
"]",
";",
"}"
] |
Trims messages, skips empty lines until non-empty one is found
|
[
"Trims",
"messages",
"skips",
"empty",
"lines",
"until",
"non",
"-",
"empty",
"one",
"is",
"found"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.git/web/orion/git/util.js#L100-L110
|
14,672
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.git/web/orion/git/util.js
|
getGerritFooter
|
function getGerritFooter(message) {
var splitted = message.split(/\r\n|\n/);
var footer = {};
var changeIdCount = 0,
signedOffByPresent = false;
for (var i = splitted.length-1; i >= 0; --i) {
var changeId = "Change-Id: "; //$NON-NLS-0$
var signedOffBy = "Signed-off-by: "; //$NON-NLS-0$
if (splitted[i].indexOf(changeId) === 0) {
footer.changeId = splitted[i].substring(changeId.length,splitted[i].length);
if (++changeIdCount > 1) {
footer = {};
break;
}
} else if (!signedOffByPresent && splitted[i].indexOf(signedOffBy) === 0) {
footer.signedOffBy = splitted[i].substring(signedOffBy.length,splitted[i].length);
signedOffBy = true;
}
}
return footer;
}
|
javascript
|
function getGerritFooter(message) {
var splitted = message.split(/\r\n|\n/);
var footer = {};
var changeIdCount = 0,
signedOffByPresent = false;
for (var i = splitted.length-1; i >= 0; --i) {
var changeId = "Change-Id: "; //$NON-NLS-0$
var signedOffBy = "Signed-off-by: "; //$NON-NLS-0$
if (splitted[i].indexOf(changeId) === 0) {
footer.changeId = splitted[i].substring(changeId.length,splitted[i].length);
if (++changeIdCount > 1) {
footer = {};
break;
}
} else if (!signedOffByPresent && splitted[i].indexOf(signedOffBy) === 0) {
footer.signedOffBy = splitted[i].substring(signedOffBy.length,splitted[i].length);
signedOffBy = true;
}
}
return footer;
}
|
[
"function",
"getGerritFooter",
"(",
"message",
")",
"{",
"var",
"splitted",
"=",
"message",
".",
"split",
"(",
"/",
"\\r\\n|\\n",
"/",
")",
";",
"var",
"footer",
"=",
"{",
"}",
";",
"var",
"changeIdCount",
"=",
"0",
",",
"signedOffByPresent",
"=",
"false",
";",
"for",
"(",
"var",
"i",
"=",
"splitted",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"--",
"i",
")",
"{",
"var",
"changeId",
"=",
"\"Change-Id: \"",
";",
"//$NON-NLS-0$",
"var",
"signedOffBy",
"=",
"\"Signed-off-by: \"",
";",
"//$NON-NLS-0$",
"if",
"(",
"splitted",
"[",
"i",
"]",
".",
"indexOf",
"(",
"changeId",
")",
"===",
"0",
")",
"{",
"footer",
".",
"changeId",
"=",
"splitted",
"[",
"i",
"]",
".",
"substring",
"(",
"changeId",
".",
"length",
",",
"splitted",
"[",
"i",
"]",
".",
"length",
")",
";",
"if",
"(",
"++",
"changeIdCount",
">",
"1",
")",
"{",
"footer",
"=",
"{",
"}",
";",
"break",
";",
"}",
"}",
"else",
"if",
"(",
"!",
"signedOffByPresent",
"&&",
"splitted",
"[",
"i",
"]",
".",
"indexOf",
"(",
"signedOffBy",
")",
"===",
"0",
")",
"{",
"footer",
".",
"signedOffBy",
"=",
"splitted",
"[",
"i",
"]",
".",
"substring",
"(",
"signedOffBy",
".",
"length",
",",
"splitted",
"[",
"i",
"]",
".",
"length",
")",
";",
"signedOffBy",
"=",
"true",
";",
"}",
"}",
"return",
"footer",
";",
"}"
] |
Returns Change-Id and Signed-off-by of a commit if present
|
[
"Returns",
"Change",
"-",
"Id",
"and",
"Signed",
"-",
"off",
"-",
"by",
"of",
"a",
"commit",
"if",
"present"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.git/web/orion/git/util.js#L133-L155
|
14,673
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/deploymentLogic.js
|
buildDeploymentTrigger
|
function buildDeploymentTrigger(options){
options = options || {};
return function(results){
var initialConfName = options.ConfName;
var confName = results.ConfName;
var disableUI = options.disableUI;
var enableUI = options.enableUI;
var showMessage = options.showMessage;
var closeFrame = options.closeFrame;
var postMsg = options.postMsg;
var postError = options.postError;
var fileService = options.FileService;
var targetSelection = options.getTargetSelection();
var userManifest = options.Manifest;
var contentLocation = options.ContentLocation;
var appPath = options.getManifestPath();
var selection = targetSelection.getSelection();
if(selection === null || selection.length === 0){
closeFrame();
return;
}
/* disable any UI at this point */
disableUI();
var instrumentation = _getManifestInstrumentation(userManifest, results);
var appName = results.name;
var target = selection;
if (!confName){
postError(new Error("Could not determine the launch config name"));
return;
}
return checkContinue(fileService, contentLocation, initialConfName, confName).then(function(keepGoing) {
if (!keepGoing) {
enableUI();
return;
}
showMessage(messages["saving..."]); //$NON-NLS-0$
return mCfUtil.prepareLaunchConfigurationContent(confName, target, appName, appPath, instrumentation).then(
function(launchConfigurationContent){
postMsg(launchConfigurationContent);
});
}).then(null, function(error){
postError(error, selection);
});
};
}
|
javascript
|
function buildDeploymentTrigger(options){
options = options || {};
return function(results){
var initialConfName = options.ConfName;
var confName = results.ConfName;
var disableUI = options.disableUI;
var enableUI = options.enableUI;
var showMessage = options.showMessage;
var closeFrame = options.closeFrame;
var postMsg = options.postMsg;
var postError = options.postError;
var fileService = options.FileService;
var targetSelection = options.getTargetSelection();
var userManifest = options.Manifest;
var contentLocation = options.ContentLocation;
var appPath = options.getManifestPath();
var selection = targetSelection.getSelection();
if(selection === null || selection.length === 0){
closeFrame();
return;
}
/* disable any UI at this point */
disableUI();
var instrumentation = _getManifestInstrumentation(userManifest, results);
var appName = results.name;
var target = selection;
if (!confName){
postError(new Error("Could not determine the launch config name"));
return;
}
return checkContinue(fileService, contentLocation, initialConfName, confName).then(function(keepGoing) {
if (!keepGoing) {
enableUI();
return;
}
showMessage(messages["saving..."]); //$NON-NLS-0$
return mCfUtil.prepareLaunchConfigurationContent(confName, target, appName, appPath, instrumentation).then(
function(launchConfigurationContent){
postMsg(launchConfigurationContent);
});
}).then(null, function(error){
postError(error, selection);
});
};
}
|
[
"function",
"buildDeploymentTrigger",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"return",
"function",
"(",
"results",
")",
"{",
"var",
"initialConfName",
"=",
"options",
".",
"ConfName",
";",
"var",
"confName",
"=",
"results",
".",
"ConfName",
";",
"var",
"disableUI",
"=",
"options",
".",
"disableUI",
";",
"var",
"enableUI",
"=",
"options",
".",
"enableUI",
";",
"var",
"showMessage",
"=",
"options",
".",
"showMessage",
";",
"var",
"closeFrame",
"=",
"options",
".",
"closeFrame",
";",
"var",
"postMsg",
"=",
"options",
".",
"postMsg",
";",
"var",
"postError",
"=",
"options",
".",
"postError",
";",
"var",
"fileService",
"=",
"options",
".",
"FileService",
";",
"var",
"targetSelection",
"=",
"options",
".",
"getTargetSelection",
"(",
")",
";",
"var",
"userManifest",
"=",
"options",
".",
"Manifest",
";",
"var",
"contentLocation",
"=",
"options",
".",
"ContentLocation",
";",
"var",
"appPath",
"=",
"options",
".",
"getManifestPath",
"(",
")",
";",
"var",
"selection",
"=",
"targetSelection",
".",
"getSelection",
"(",
")",
";",
"if",
"(",
"selection",
"===",
"null",
"||",
"selection",
".",
"length",
"===",
"0",
")",
"{",
"closeFrame",
"(",
")",
";",
"return",
";",
"}",
"/* disable any UI at this point */",
"disableUI",
"(",
")",
";",
"var",
"instrumentation",
"=",
"_getManifestInstrumentation",
"(",
"userManifest",
",",
"results",
")",
";",
"var",
"appName",
"=",
"results",
".",
"name",
";",
"var",
"target",
"=",
"selection",
";",
"if",
"(",
"!",
"confName",
")",
"{",
"postError",
"(",
"new",
"Error",
"(",
"\"Could not determine the launch config name\"",
")",
")",
";",
"return",
";",
"}",
"return",
"checkContinue",
"(",
"fileService",
",",
"contentLocation",
",",
"initialConfName",
",",
"confName",
")",
".",
"then",
"(",
"function",
"(",
"keepGoing",
")",
"{",
"if",
"(",
"!",
"keepGoing",
")",
"{",
"enableUI",
"(",
")",
";",
"return",
";",
"}",
"showMessage",
"(",
"messages",
"[",
"\"saving...\"",
"]",
")",
";",
"//$NON-NLS-0$",
"return",
"mCfUtil",
".",
"prepareLaunchConfigurationContent",
"(",
"confName",
",",
"target",
",",
"appName",
",",
"appPath",
",",
"instrumentation",
")",
".",
"then",
"(",
"function",
"(",
"launchConfigurationContent",
")",
"{",
"postMsg",
"(",
"launchConfigurationContent",
")",
";",
"}",
")",
";",
"}",
")",
".",
"then",
"(",
"null",
",",
"function",
"(",
"error",
")",
"{",
"postError",
"(",
"error",
",",
"selection",
")",
";",
"}",
")",
";",
"}",
";",
"}"
] |
A utility trigger factory for Cloud Foundry deployment logic
after the 'Deploy' button in a deployment wizard was clicked.
|
[
"A",
"utility",
"trigger",
"factory",
"for",
"Cloud",
"Foundry",
"deployment",
"logic",
"after",
"the",
"Deploy",
"button",
"in",
"a",
"deployment",
"wizard",
"was",
"clicked",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/deploymentLogic.js#L78-L133
|
14,674
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/deploymentLogic.js
|
uniqueLaunchConfigName
|
function uniqueLaunchConfigName(fileService, contentLocation, baseName) {
return readLaunchConfigsFolder(fileService, contentLocation).then(function(children) {
var counter = 0;
for(var i=0; i<children.length; i++){
var childName = children[i].Name.replace(/\.launch$/, ""); //$NON-NLS-0$
if (baseName === childName){
if (counter === 0) counter++;
continue;
}
childName = childName.replace(baseName + "-", "");
var launchConfCounter = parseInt(Number(childName), 10);
if (!isNaN(launchConfCounter) && launchConfCounter >= counter)
counter = launchConfCounter + 1;
}
return (counter > 0 ? baseName + "-" + counter : baseName);
}, function(error){
if (error.status === 404 || error.status === 410){
return baseName;
}
throw error;
});
}
|
javascript
|
function uniqueLaunchConfigName(fileService, contentLocation, baseName) {
return readLaunchConfigsFolder(fileService, contentLocation).then(function(children) {
var counter = 0;
for(var i=0; i<children.length; i++){
var childName = children[i].Name.replace(/\.launch$/, ""); //$NON-NLS-0$
if (baseName === childName){
if (counter === 0) counter++;
continue;
}
childName = childName.replace(baseName + "-", "");
var launchConfCounter = parseInt(Number(childName), 10);
if (!isNaN(launchConfCounter) && launchConfCounter >= counter)
counter = launchConfCounter + 1;
}
return (counter > 0 ? baseName + "-" + counter : baseName);
}, function(error){
if (error.status === 404 || error.status === 410){
return baseName;
}
throw error;
});
}
|
[
"function",
"uniqueLaunchConfigName",
"(",
"fileService",
",",
"contentLocation",
",",
"baseName",
")",
"{",
"return",
"readLaunchConfigsFolder",
"(",
"fileService",
",",
"contentLocation",
")",
".",
"then",
"(",
"function",
"(",
"children",
")",
"{",
"var",
"counter",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"children",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"childName",
"=",
"children",
"[",
"i",
"]",
".",
"Name",
".",
"replace",
"(",
"/",
"\\.launch$",
"/",
",",
"\"\"",
")",
";",
"//$NON-NLS-0$",
"if",
"(",
"baseName",
"===",
"childName",
")",
"{",
"if",
"(",
"counter",
"===",
"0",
")",
"counter",
"++",
";",
"continue",
";",
"}",
"childName",
"=",
"childName",
".",
"replace",
"(",
"baseName",
"+",
"\"-\"",
",",
"\"\"",
")",
";",
"var",
"launchConfCounter",
"=",
"parseInt",
"(",
"Number",
"(",
"childName",
")",
",",
"10",
")",
";",
"if",
"(",
"!",
"isNaN",
"(",
"launchConfCounter",
")",
"&&",
"launchConfCounter",
">=",
"counter",
")",
"counter",
"=",
"launchConfCounter",
"+",
"1",
";",
"}",
"return",
"(",
"counter",
">",
"0",
"?",
"baseName",
"+",
"\"-\"",
"+",
"counter",
":",
"baseName",
")",
";",
"}",
",",
"function",
"(",
"error",
")",
"{",
"if",
"(",
"error",
".",
"status",
"===",
"404",
"||",
"error",
".",
"status",
"===",
"410",
")",
"{",
"return",
"baseName",
";",
"}",
"throw",
"error",
";",
"}",
")",
";",
"}"
] |
Calculates a uniqe name for the launch config
@returns {orion.Promise} resolving to String
|
[
"Calculates",
"a",
"uniqe",
"name",
"for",
"the",
"launch",
"config"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/deploymentLogic.js#L187-L208
|
14,675
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.core/web/orion/contentTypes.js
|
function() {
var map = this.getContentTypesMap();
var types = [];
for (var type in map) {
if (Object.prototype.hasOwnProperty.call(map, type)) {
types.push(map[type]);
}
}
return types;
}
|
javascript
|
function() {
var map = this.getContentTypesMap();
var types = [];
for (var type in map) {
if (Object.prototype.hasOwnProperty.call(map, type)) {
types.push(map[type]);
}
}
return types;
}
|
[
"function",
"(",
")",
"{",
"var",
"map",
"=",
"this",
".",
"getContentTypesMap",
"(",
")",
";",
"var",
"types",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"type",
"in",
"map",
")",
"{",
"if",
"(",
"Object",
".",
"prototype",
".",
"hasOwnProperty",
".",
"call",
"(",
"map",
",",
"type",
")",
")",
"{",
"types",
".",
"push",
"(",
"map",
"[",
"type",
"]",
")",
";",
"}",
"}",
"return",
"types",
";",
"}"
] |
Gets all the ContentTypes in the registry.
@returns {orion.core.ContentType[]} An array of all registered ContentTypes.
|
[
"Gets",
"all",
"the",
"ContentTypes",
"in",
"the",
"registry",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.core/web/orion/contentTypes.js#L220-L229
|
|
14,676
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.core/web/orion/contentTypes.js
|
function(contentTypeA, contentTypeB) {
contentTypeA = (typeof contentTypeA === "string") ? this.getContentType(contentTypeA) : contentTypeA; //$NON-NLS-0$
contentTypeB = (typeof contentTypeB === "string") ? this.getContentType(contentTypeB) : contentTypeB; //$NON-NLS-0$
if (!contentTypeA || !contentTypeB) { return false; }
if (contentTypeA.id === contentTypeB.id) { return true; }
else {
var parent = contentTypeA, seen = {};
while (parent && (parent = this.getContentType(parent['extends']))) { //$NON-NLS-0$
if (parent.id === contentTypeB.id) { return true; }
if (seen[parent.id]) { throw new Error("Cycle: " + parent.id); } //$NON-NLS-0$
seen[parent.id] = true;
}
}
return false;
}
|
javascript
|
function(contentTypeA, contentTypeB) {
contentTypeA = (typeof contentTypeA === "string") ? this.getContentType(contentTypeA) : contentTypeA; //$NON-NLS-0$
contentTypeB = (typeof contentTypeB === "string") ? this.getContentType(contentTypeB) : contentTypeB; //$NON-NLS-0$
if (!contentTypeA || !contentTypeB) { return false; }
if (contentTypeA.id === contentTypeB.id) { return true; }
else {
var parent = contentTypeA, seen = {};
while (parent && (parent = this.getContentType(parent['extends']))) { //$NON-NLS-0$
if (parent.id === contentTypeB.id) { return true; }
if (seen[parent.id]) { throw new Error("Cycle: " + parent.id); } //$NON-NLS-0$
seen[parent.id] = true;
}
}
return false;
}
|
[
"function",
"(",
"contentTypeA",
",",
"contentTypeB",
")",
"{",
"contentTypeA",
"=",
"(",
"typeof",
"contentTypeA",
"===",
"\"string\"",
")",
"?",
"this",
".",
"getContentType",
"(",
"contentTypeA",
")",
":",
"contentTypeA",
";",
"//$NON-NLS-0$",
"contentTypeB",
"=",
"(",
"typeof",
"contentTypeB",
"===",
"\"string\"",
")",
"?",
"this",
".",
"getContentType",
"(",
"contentTypeB",
")",
":",
"contentTypeB",
";",
"//$NON-NLS-0$",
"if",
"(",
"!",
"contentTypeA",
"||",
"!",
"contentTypeB",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"contentTypeA",
".",
"id",
"===",
"contentTypeB",
".",
"id",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"var",
"parent",
"=",
"contentTypeA",
",",
"seen",
"=",
"{",
"}",
";",
"while",
"(",
"parent",
"&&",
"(",
"parent",
"=",
"this",
".",
"getContentType",
"(",
"parent",
"[",
"'extends'",
"]",
")",
")",
")",
"{",
"//$NON-NLS-0$",
"if",
"(",
"parent",
".",
"id",
"===",
"contentTypeB",
".",
"id",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"seen",
"[",
"parent",
".",
"id",
"]",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Cycle: \"",
"+",
"parent",
".",
"id",
")",
";",
"}",
"//$NON-NLS-0$",
"seen",
"[",
"parent",
".",
"id",
"]",
"=",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Determines whether a ContentType is an extension of another.
@param {orion.core.ContentType|String} contentTypeA ContentType or ContentType ID.
@param {orion.core.ContentType|String} contentTypeB ContentType or ContentType ID.
@returns {Boolean} Returns <code>true</code> if <code>contentTypeA</code> equals <code>contentTypeB</code>,
or <code>contentTypeA</code> descends from <code>contentTypeB</code>.
|
[
"Determines",
"whether",
"a",
"ContentType",
"is",
"an",
"extension",
"of",
"another",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.core/web/orion/contentTypes.js#L268-L282
|
|
14,677
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.cf/web/cfui/cfUtil.js
|
function(error, target){
error.Severity = "Error"; //$NON-NLS-0$
if (error.Message && error.Message.indexOf("The host is taken") === 0) //$NON-NLS-0$
error.Message = messages["theHostIsAlreadyIn"];
if (error.HttpCode === 404){
error = {
State: "NOT_DEPLOYED", //$NON-NLS-0$
Message: error.Message,
Severity: "Error" //$NON-NLS-0$
};
} else if (error.JsonData && error.JsonData.error_code) {
var err = error.JsonData;
if (err.error_code === "CF-InvalidAuthToken" || err.error_code === "CF-NotAuthenticated"){ //$NON-NLS-0$ //$NON-NLS-1$
error.Retry = {
parameters: [{
id: "user", //$NON-NLS-0$
type: "text", //$NON-NLS-0$
name: messages["iD:"]
}, {
id: "password", //$NON-NLS-0$
type: "password", //$NON-NLS-0$
name: messages["password:"]
}, {
id: "url", //$NON-NLS-0$
hidden: true,
value: target.Url
}]
};
error.forceShowMessage = true;
error.Severity = "Info"; //$NON-NLS-0$
error.Message = this.getLoginMessage(target.ManageUrl);
} else if (err.error_code === "CF-TargetNotSet"){ //$NON-NLS-0$
var cloudSettingsPageUrl = new URITemplate("{+OrionHome}/settings/settings.html#,category=cloud").expand({OrionHome : PageLinks.getOrionHome()}); //$NON-NLS-0$
error.Message = i18Util.formatMessage(messages["setUpYourCloud.Go"], cloudSettingsPageUrl);
} else if (err.error_code === "ServiceNotFound"){
if(target.ManageUrl){
var redirectToDashboard = target.ManageUrl;
var serviceName = err.metadata.service;
error.Message = i18Util.formatMessage(messages["service${0}NotFoundsetUpYourService.Go${1}"], serviceName, redirectToDashboard);
}
}
}
return error;
}
|
javascript
|
function(error, target){
error.Severity = "Error"; //$NON-NLS-0$
if (error.Message && error.Message.indexOf("The host is taken") === 0) //$NON-NLS-0$
error.Message = messages["theHostIsAlreadyIn"];
if (error.HttpCode === 404){
error = {
State: "NOT_DEPLOYED", //$NON-NLS-0$
Message: error.Message,
Severity: "Error" //$NON-NLS-0$
};
} else if (error.JsonData && error.JsonData.error_code) {
var err = error.JsonData;
if (err.error_code === "CF-InvalidAuthToken" || err.error_code === "CF-NotAuthenticated"){ //$NON-NLS-0$ //$NON-NLS-1$
error.Retry = {
parameters: [{
id: "user", //$NON-NLS-0$
type: "text", //$NON-NLS-0$
name: messages["iD:"]
}, {
id: "password", //$NON-NLS-0$
type: "password", //$NON-NLS-0$
name: messages["password:"]
}, {
id: "url", //$NON-NLS-0$
hidden: true,
value: target.Url
}]
};
error.forceShowMessage = true;
error.Severity = "Info"; //$NON-NLS-0$
error.Message = this.getLoginMessage(target.ManageUrl);
} else if (err.error_code === "CF-TargetNotSet"){ //$NON-NLS-0$
var cloudSettingsPageUrl = new URITemplate("{+OrionHome}/settings/settings.html#,category=cloud").expand({OrionHome : PageLinks.getOrionHome()}); //$NON-NLS-0$
error.Message = i18Util.formatMessage(messages["setUpYourCloud.Go"], cloudSettingsPageUrl);
} else if (err.error_code === "ServiceNotFound"){
if(target.ManageUrl){
var redirectToDashboard = target.ManageUrl;
var serviceName = err.metadata.service;
error.Message = i18Util.formatMessage(messages["service${0}NotFoundsetUpYourService.Go${1}"], serviceName, redirectToDashboard);
}
}
}
return error;
}
|
[
"function",
"(",
"error",
",",
"target",
")",
"{",
"error",
".",
"Severity",
"=",
"\"Error\"",
";",
"//$NON-NLS-0$",
"if",
"(",
"error",
".",
"Message",
"&&",
"error",
".",
"Message",
".",
"indexOf",
"(",
"\"The host is taken\"",
")",
"===",
"0",
")",
"//$NON-NLS-0$",
"error",
".",
"Message",
"=",
"messages",
"[",
"\"theHostIsAlreadyIn\"",
"]",
";",
"if",
"(",
"error",
".",
"HttpCode",
"===",
"404",
")",
"{",
"error",
"=",
"{",
"State",
":",
"\"NOT_DEPLOYED\"",
",",
"//$NON-NLS-0$",
"Message",
":",
"error",
".",
"Message",
",",
"Severity",
":",
"\"Error\"",
"//$NON-NLS-0$",
"}",
";",
"}",
"else",
"if",
"(",
"error",
".",
"JsonData",
"&&",
"error",
".",
"JsonData",
".",
"error_code",
")",
"{",
"var",
"err",
"=",
"error",
".",
"JsonData",
";",
"if",
"(",
"err",
".",
"error_code",
"===",
"\"CF-InvalidAuthToken\"",
"||",
"err",
".",
"error_code",
"===",
"\"CF-NotAuthenticated\"",
")",
"{",
"//$NON-NLS-0$ //$NON-NLS-1$",
"error",
".",
"Retry",
"=",
"{",
"parameters",
":",
"[",
"{",
"id",
":",
"\"user\"",
",",
"//$NON-NLS-0$",
"type",
":",
"\"text\"",
",",
"//$NON-NLS-0$",
"name",
":",
"messages",
"[",
"\"iD:\"",
"]",
"}",
",",
"{",
"id",
":",
"\"password\"",
",",
"//$NON-NLS-0$",
"type",
":",
"\"password\"",
",",
"//$NON-NLS-0$",
"name",
":",
"messages",
"[",
"\"password:\"",
"]",
"}",
",",
"{",
"id",
":",
"\"url\"",
",",
"//$NON-NLS-0$",
"hidden",
":",
"true",
",",
"value",
":",
"target",
".",
"Url",
"}",
"]",
"}",
";",
"error",
".",
"forceShowMessage",
"=",
"true",
";",
"error",
".",
"Severity",
"=",
"\"Info\"",
";",
"//$NON-NLS-0$",
"error",
".",
"Message",
"=",
"this",
".",
"getLoginMessage",
"(",
"target",
".",
"ManageUrl",
")",
";",
"}",
"else",
"if",
"(",
"err",
".",
"error_code",
"===",
"\"CF-TargetNotSet\"",
")",
"{",
"//$NON-NLS-0$",
"var",
"cloudSettingsPageUrl",
"=",
"new",
"URITemplate",
"(",
"\"{+OrionHome}/settings/settings.html#,category=cloud\"",
")",
".",
"expand",
"(",
"{",
"OrionHome",
":",
"PageLinks",
".",
"getOrionHome",
"(",
")",
"}",
")",
";",
"//$NON-NLS-0$",
"error",
".",
"Message",
"=",
"i18Util",
".",
"formatMessage",
"(",
"messages",
"[",
"\"setUpYourCloud.Go\"",
"]",
",",
"cloudSettingsPageUrl",
")",
";",
"}",
"else",
"if",
"(",
"err",
".",
"error_code",
"===",
"\"ServiceNotFound\"",
")",
"{",
"if",
"(",
"target",
".",
"ManageUrl",
")",
"{",
"var",
"redirectToDashboard",
"=",
"target",
".",
"ManageUrl",
";",
"var",
"serviceName",
"=",
"err",
".",
"metadata",
".",
"service",
";",
"error",
".",
"Message",
"=",
"i18Util",
".",
"formatMessage",
"(",
"messages",
"[",
"\"service${0}NotFoundsetUpYourService.Go${1}\"",
"]",
",",
"serviceName",
",",
"redirectToDashboard",
")",
";",
"}",
"}",
"}",
"return",
"error",
";",
"}"
] |
Decorates the given error object.
|
[
"Decorates",
"the",
"given",
"error",
"object",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.cf/web/cfui/cfUtil.js#L89-L141
|
|
14,678
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.cf/web/cfui/cfUtil.js
|
function(options){
var cFService = options.cFService;
var showMessage = options.showMessage;
var hideMessage = options.hideMessage;
var showError = options.showError;
var render = options.render;
var self = this;
var handleError = function(error, target, retryFunc){
error = self.defaultDecorateError(error, target);
showError(error);
if(error.Retry && error.Retry.parameters){
var paramInputs = {};
function submitParams(){
var params = {};
error.Retry.parameters.forEach(function(param){
if(param.hidden)
params[param.id] = param.value;
else
params[param.id] = paramInputs[param.id].value;
});
/* handle login errors */
if(params.url && params.user && params.password){
showMessage(i18Util.formatMessage(messages["loggingInTo${0}..."], params.url));
cFService.login(params.url, params.user, params.password).then(function(result){
hideMessage();
if(retryFunc)
retryFunc(result);
}, function(newError){
hideMessage();
if(newError.HttpCode === 401)
handleError(error, target, retryFunc);
else
handleError(newError, target, retryFunc);
});
}
}
var fields = document.createElement("div"); //$NON-NLS-0$
fields.className = "retryFields"; //$NON-NLS-0$
var firstField;
error.Retry.parameters.forEach(function(param, i){
if(!param.hidden){
var div = document.createElement("div"); //$NON-NLS-0$
var label = document.createElement("label"); //$NON-NLS-0$
label.appendChild(document.createTextNode(param.name));
var input = document.createElement("input"); //$NON-NLS-0$
if(i===0)
firstField = input;
input.type = param.type;
input.id = param.id;
input.onkeydown = function(event){
if(event.keyCode === 13)
submitParams();
else if(event.keyCode === 27)
hideMessage();
};
paramInputs[param.id] = input;
div.appendChild(label);
div.appendChild(input);
fields.appendChild(div);
}
});
var submitButton = document.createElement("button"); //$NON-NLS-0$
submitButton.appendChild(document.createTextNode(messages["submit"]));
submitButton.onclick = submitParams;
fields.appendChild(submitButton);
render(fields);
if(firstField)
firstField.focus();
}
};
return handleError;
}
|
javascript
|
function(options){
var cFService = options.cFService;
var showMessage = options.showMessage;
var hideMessage = options.hideMessage;
var showError = options.showError;
var render = options.render;
var self = this;
var handleError = function(error, target, retryFunc){
error = self.defaultDecorateError(error, target);
showError(error);
if(error.Retry && error.Retry.parameters){
var paramInputs = {};
function submitParams(){
var params = {};
error.Retry.parameters.forEach(function(param){
if(param.hidden)
params[param.id] = param.value;
else
params[param.id] = paramInputs[param.id].value;
});
/* handle login errors */
if(params.url && params.user && params.password){
showMessage(i18Util.formatMessage(messages["loggingInTo${0}..."], params.url));
cFService.login(params.url, params.user, params.password).then(function(result){
hideMessage();
if(retryFunc)
retryFunc(result);
}, function(newError){
hideMessage();
if(newError.HttpCode === 401)
handleError(error, target, retryFunc);
else
handleError(newError, target, retryFunc);
});
}
}
var fields = document.createElement("div"); //$NON-NLS-0$
fields.className = "retryFields"; //$NON-NLS-0$
var firstField;
error.Retry.parameters.forEach(function(param, i){
if(!param.hidden){
var div = document.createElement("div"); //$NON-NLS-0$
var label = document.createElement("label"); //$NON-NLS-0$
label.appendChild(document.createTextNode(param.name));
var input = document.createElement("input"); //$NON-NLS-0$
if(i===0)
firstField = input;
input.type = param.type;
input.id = param.id;
input.onkeydown = function(event){
if(event.keyCode === 13)
submitParams();
else if(event.keyCode === 27)
hideMessage();
};
paramInputs[param.id] = input;
div.appendChild(label);
div.appendChild(input);
fields.appendChild(div);
}
});
var submitButton = document.createElement("button"); //$NON-NLS-0$
submitButton.appendChild(document.createTextNode(messages["submit"]));
submitButton.onclick = submitParams;
fields.appendChild(submitButton);
render(fields);
if(firstField)
firstField.focus();
}
};
return handleError;
}
|
[
"function",
"(",
"options",
")",
"{",
"var",
"cFService",
"=",
"options",
".",
"cFService",
";",
"var",
"showMessage",
"=",
"options",
".",
"showMessage",
";",
"var",
"hideMessage",
"=",
"options",
".",
"hideMessage",
";",
"var",
"showError",
"=",
"options",
".",
"showError",
";",
"var",
"render",
"=",
"options",
".",
"render",
";",
"var",
"self",
"=",
"this",
";",
"var",
"handleError",
"=",
"function",
"(",
"error",
",",
"target",
",",
"retryFunc",
")",
"{",
"error",
"=",
"self",
".",
"defaultDecorateError",
"(",
"error",
",",
"target",
")",
";",
"showError",
"(",
"error",
")",
";",
"if",
"(",
"error",
".",
"Retry",
"&&",
"error",
".",
"Retry",
".",
"parameters",
")",
"{",
"var",
"paramInputs",
"=",
"{",
"}",
";",
"function",
"submitParams",
"(",
")",
"{",
"var",
"params",
"=",
"{",
"}",
";",
"error",
".",
"Retry",
".",
"parameters",
".",
"forEach",
"(",
"function",
"(",
"param",
")",
"{",
"if",
"(",
"param",
".",
"hidden",
")",
"params",
"[",
"param",
".",
"id",
"]",
"=",
"param",
".",
"value",
";",
"else",
"params",
"[",
"param",
".",
"id",
"]",
"=",
"paramInputs",
"[",
"param",
".",
"id",
"]",
".",
"value",
";",
"}",
")",
";",
"/* handle login errors */",
"if",
"(",
"params",
".",
"url",
"&&",
"params",
".",
"user",
"&&",
"params",
".",
"password",
")",
"{",
"showMessage",
"(",
"i18Util",
".",
"formatMessage",
"(",
"messages",
"[",
"\"loggingInTo${0}...\"",
"]",
",",
"params",
".",
"url",
")",
")",
";",
"cFService",
".",
"login",
"(",
"params",
".",
"url",
",",
"params",
".",
"user",
",",
"params",
".",
"password",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"hideMessage",
"(",
")",
";",
"if",
"(",
"retryFunc",
")",
"retryFunc",
"(",
"result",
")",
";",
"}",
",",
"function",
"(",
"newError",
")",
"{",
"hideMessage",
"(",
")",
";",
"if",
"(",
"newError",
".",
"HttpCode",
"===",
"401",
")",
"handleError",
"(",
"error",
",",
"target",
",",
"retryFunc",
")",
";",
"else",
"handleError",
"(",
"newError",
",",
"target",
",",
"retryFunc",
")",
";",
"}",
")",
";",
"}",
"}",
"var",
"fields",
"=",
"document",
".",
"createElement",
"(",
"\"div\"",
")",
";",
"//$NON-NLS-0$",
"fields",
".",
"className",
"=",
"\"retryFields\"",
";",
"//$NON-NLS-0$",
"var",
"firstField",
";",
"error",
".",
"Retry",
".",
"parameters",
".",
"forEach",
"(",
"function",
"(",
"param",
",",
"i",
")",
"{",
"if",
"(",
"!",
"param",
".",
"hidden",
")",
"{",
"var",
"div",
"=",
"document",
".",
"createElement",
"(",
"\"div\"",
")",
";",
"//$NON-NLS-0$",
"var",
"label",
"=",
"document",
".",
"createElement",
"(",
"\"label\"",
")",
";",
"//$NON-NLS-0$",
"label",
".",
"appendChild",
"(",
"document",
".",
"createTextNode",
"(",
"param",
".",
"name",
")",
")",
";",
"var",
"input",
"=",
"document",
".",
"createElement",
"(",
"\"input\"",
")",
";",
"//$NON-NLS-0$",
"if",
"(",
"i",
"===",
"0",
")",
"firstField",
"=",
"input",
";",
"input",
".",
"type",
"=",
"param",
".",
"type",
";",
"input",
".",
"id",
"=",
"param",
".",
"id",
";",
"input",
".",
"onkeydown",
"=",
"function",
"(",
"event",
")",
"{",
"if",
"(",
"event",
".",
"keyCode",
"===",
"13",
")",
"submitParams",
"(",
")",
";",
"else",
"if",
"(",
"event",
".",
"keyCode",
"===",
"27",
")",
"hideMessage",
"(",
")",
";",
"}",
";",
"paramInputs",
"[",
"param",
".",
"id",
"]",
"=",
"input",
";",
"div",
".",
"appendChild",
"(",
"label",
")",
";",
"div",
".",
"appendChild",
"(",
"input",
")",
";",
"fields",
".",
"appendChild",
"(",
"div",
")",
";",
"}",
"}",
")",
";",
"var",
"submitButton",
"=",
"document",
".",
"createElement",
"(",
"\"button\"",
")",
";",
"//$NON-NLS-0$",
"submitButton",
".",
"appendChild",
"(",
"document",
".",
"createTextNode",
"(",
"messages",
"[",
"\"submit\"",
"]",
")",
")",
";",
"submitButton",
".",
"onclick",
"=",
"submitParams",
";",
"fields",
".",
"appendChild",
"(",
"submitButton",
")",
";",
"render",
"(",
"fields",
")",
";",
"if",
"(",
"firstField",
")",
"firstField",
".",
"focus",
"(",
")",
";",
"}",
"}",
";",
"return",
"handleError",
";",
"}"
] |
Builds a default error handler which handles the given error
in the wizard without communication with the parent window.
|
[
"Builds",
"a",
"default",
"error",
"handler",
"which",
"handles",
"the",
"given",
"error",
"in",
"the",
"wizard",
"without",
"communication",
"with",
"the",
"parent",
"window",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.cf/web/cfui/cfUtil.js#L147-L236
|
|
14,679
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/widgets/input/ComboTextInput.js
|
function() {
var value = this.getTextInputValue();
if (value) {
var recentEntryArray = this.getRecentEntryArray();
if (!recentEntryArray) {
recentEntryArray = [];
}
var indexOfElement = this._getIndexOfValue(recentEntryArray, value); //check if a duplicate entry exists
if (0 !== indexOfElement) {
// element is either not in array, or not in first position
if (-1 !== indexOfElement) {
// element is in array, remove it because we want to add it to beginning
recentEntryArray.splice(indexOfElement, 1);
}
//add new entry to beginning of array
recentEntryArray.unshift({
type: "proposal", //$NON-NLS-0$
label: value,
value: value
});
this._storeRecentEntryArray(recentEntryArray);
this._showRecentEntryButton();
}
}
}
|
javascript
|
function() {
var value = this.getTextInputValue();
if (value) {
var recentEntryArray = this.getRecentEntryArray();
if (!recentEntryArray) {
recentEntryArray = [];
}
var indexOfElement = this._getIndexOfValue(recentEntryArray, value); //check if a duplicate entry exists
if (0 !== indexOfElement) {
// element is either not in array, or not in first position
if (-1 !== indexOfElement) {
// element is in array, remove it because we want to add it to beginning
recentEntryArray.splice(indexOfElement, 1);
}
//add new entry to beginning of array
recentEntryArray.unshift({
type: "proposal", //$NON-NLS-0$
label: value,
value: value
});
this._storeRecentEntryArray(recentEntryArray);
this._showRecentEntryButton();
}
}
}
|
[
"function",
"(",
")",
"{",
"var",
"value",
"=",
"this",
".",
"getTextInputValue",
"(",
")",
";",
"if",
"(",
"value",
")",
"{",
"var",
"recentEntryArray",
"=",
"this",
".",
"getRecentEntryArray",
"(",
")",
";",
"if",
"(",
"!",
"recentEntryArray",
")",
"{",
"recentEntryArray",
"=",
"[",
"]",
";",
"}",
"var",
"indexOfElement",
"=",
"this",
".",
"_getIndexOfValue",
"(",
"recentEntryArray",
",",
"value",
")",
";",
"//check if a duplicate entry exists\r",
"if",
"(",
"0",
"!==",
"indexOfElement",
")",
"{",
"// element is either not in array, or not in first position\r",
"if",
"(",
"-",
"1",
"!==",
"indexOfElement",
")",
"{",
"// element is in array, remove it because we want to add it to beginning\r",
"recentEntryArray",
".",
"splice",
"(",
"indexOfElement",
",",
"1",
")",
";",
"}",
"//add new entry to beginning of array\r",
"recentEntryArray",
".",
"unshift",
"(",
"{",
"type",
":",
"\"proposal\"",
",",
"//$NON-NLS-0$\r",
"label",
":",
"value",
",",
"value",
":",
"value",
"}",
")",
";",
"this",
".",
"_storeRecentEntryArray",
"(",
"recentEntryArray",
")",
";",
"this",
".",
"_showRecentEntryButton",
"(",
")",
";",
"}",
"}",
"}"
] |
Adds the value that is in the text input field to the
recent entries in localStorage. Empty and duplicate
values are ignored.
|
[
"Adds",
"the",
"value",
"that",
"is",
"in",
"the",
"text",
"input",
"field",
"to",
"the",
"recent",
"entries",
"in",
"localStorage",
".",
"Empty",
"and",
"duplicate",
"values",
"are",
"ignored",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/widgets/input/ComboTextInput.js#L226-L253
|
|
14,680
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.ui/web/orion/widgets/input/ComboTextInput.js
|
function(recentEntryArray, value) {
var indexOfElement = -1;
recentEntryArray.some(function(entry, index){
if (entry.value === value) {
indexOfElement = index;
return true;
}
return false;
});
return indexOfElement;
}
|
javascript
|
function(recentEntryArray, value) {
var indexOfElement = -1;
recentEntryArray.some(function(entry, index){
if (entry.value === value) {
indexOfElement = index;
return true;
}
return false;
});
return indexOfElement;
}
|
[
"function",
"(",
"recentEntryArray",
",",
"value",
")",
"{",
"var",
"indexOfElement",
"=",
"-",
"1",
";",
"recentEntryArray",
".",
"some",
"(",
"function",
"(",
"entry",
",",
"index",
")",
"{",
"if",
"(",
"entry",
".",
"value",
"===",
"value",
")",
"{",
"indexOfElement",
"=",
"index",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
")",
";",
"return",
"indexOfElement",
";",
"}"
] |
Looks for an entry in the specified recentEntryArray with
a value that is equivalent to the specified value parameter.
@returns The index of the matching entry in the array or -1
|
[
"Looks",
"for",
"an",
"entry",
"in",
"the",
"specified",
"recentEntryArray",
"with",
"a",
"value",
"that",
"is",
"equivalent",
"to",
"the",
"specified",
"value",
"parameter",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.ui/web/orion/widgets/input/ComboTextInput.js#L261-L273
|
|
14,681
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.javascript/web/javascript/scriptResolver.js
|
_samePaths
|
function _samePaths(file, path2, meta) {
if (file === null) {
return path2 === null;
}
if (typeof file === 'undefined') {
return typeof path2 === 'undefined';
}
if (path2 === null) {
return file === null;
}
if (typeof path2 === 'undefined') {
return typeof file === 'undefined';
}
//get rid of extensions and compare the names
var loc = file.location ? file.location : file.Location;
if (!loc) {
return false;
}
var idx = loc.lastIndexOf('.');
var p1 = loc;
if (idx > -1) {
p1 = loc.slice(0, idx);
}
if (path2 === p1) {
return true; //could be that only the extension was missing from the other path
}
idx = path2.lastIndexOf('.');
var p2 = path2;
if (idx > -1) {
p2 = path2.slice(0, idx);
}
if (p1 === p2) {
return true;
} else if (p1 === decodeURIComponent(p2)) {
return true;
}
return false;
}
|
javascript
|
function _samePaths(file, path2, meta) {
if (file === null) {
return path2 === null;
}
if (typeof file === 'undefined') {
return typeof path2 === 'undefined';
}
if (path2 === null) {
return file === null;
}
if (typeof path2 === 'undefined') {
return typeof file === 'undefined';
}
//get rid of extensions and compare the names
var loc = file.location ? file.location : file.Location;
if (!loc) {
return false;
}
var idx = loc.lastIndexOf('.');
var p1 = loc;
if (idx > -1) {
p1 = loc.slice(0, idx);
}
if (path2 === p1) {
return true; //could be that only the extension was missing from the other path
}
idx = path2.lastIndexOf('.');
var p2 = path2;
if (idx > -1) {
p2 = path2.slice(0, idx);
}
if (p1 === p2) {
return true;
} else if (p1 === decodeURIComponent(p2)) {
return true;
}
return false;
}
|
[
"function",
"_samePaths",
"(",
"file",
",",
"path2",
",",
"meta",
")",
"{",
"if",
"(",
"file",
"===",
"null",
")",
"{",
"return",
"path2",
"===",
"null",
";",
"}",
"if",
"(",
"typeof",
"file",
"===",
"'undefined'",
")",
"{",
"return",
"typeof",
"path2",
"===",
"'undefined'",
";",
"}",
"if",
"(",
"path2",
"===",
"null",
")",
"{",
"return",
"file",
"===",
"null",
";",
"}",
"if",
"(",
"typeof",
"path2",
"===",
"'undefined'",
")",
"{",
"return",
"typeof",
"file",
"===",
"'undefined'",
";",
"}",
"//get rid of extensions and compare the names",
"var",
"loc",
"=",
"file",
".",
"location",
"?",
"file",
".",
"location",
":",
"file",
".",
"Location",
";",
"if",
"(",
"!",
"loc",
")",
"{",
"return",
"false",
";",
"}",
"var",
"idx",
"=",
"loc",
".",
"lastIndexOf",
"(",
"'.'",
")",
";",
"var",
"p1",
"=",
"loc",
";",
"if",
"(",
"idx",
">",
"-",
"1",
")",
"{",
"p1",
"=",
"loc",
".",
"slice",
"(",
"0",
",",
"idx",
")",
";",
"}",
"if",
"(",
"path2",
"===",
"p1",
")",
"{",
"return",
"true",
";",
"//could be that only the extension was missing from the other path",
"}",
"idx",
"=",
"path2",
".",
"lastIndexOf",
"(",
"'.'",
")",
";",
"var",
"p2",
"=",
"path2",
";",
"if",
"(",
"idx",
">",
"-",
"1",
")",
"{",
"p2",
"=",
"path2",
".",
"slice",
"(",
"0",
",",
"idx",
")",
";",
"}",
"if",
"(",
"p1",
"===",
"p2",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"p1",
"===",
"decodeURIComponent",
"(",
"p2",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Returns if the two paths are the same
@param {String} file The first path
@param {String} path2 The second path
@returns {Boolean} If the paths are the same
|
[
"Returns",
"if",
"the",
"two",
"paths",
"are",
"the",
"same"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.javascript/web/javascript/scriptResolver.js#L218-L255
|
14,682
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.webtools/web/webtools/htmlOutliner.js
|
function(node) {
var label = node.name;
//include id if present
var match = /id=['"]\S*["']/.exec(node.raw); //$NON-NLS-0$
if (match) {
label = label + " " + match[0]; //$NON-NLS-0$
}
//include class if present
match = /class=['"]\S*["']/.exec(node.raw); //$NON-NLS-0$
if (match) {
label = label + " " + match[0]; //$NON-NLS-0$
}
return label;
}
|
javascript
|
function(node) {
var label = node.name;
//include id if present
var match = /id=['"]\S*["']/.exec(node.raw); //$NON-NLS-0$
if (match) {
label = label + " " + match[0]; //$NON-NLS-0$
}
//include class if present
match = /class=['"]\S*["']/.exec(node.raw); //$NON-NLS-0$
if (match) {
label = label + " " + match[0]; //$NON-NLS-0$
}
return label;
}
|
[
"function",
"(",
"node",
")",
"{",
"var",
"label",
"=",
"node",
".",
"name",
";",
"//include id if present\r",
"var",
"match",
"=",
"/",
"id=['\"]\\S*[\"']",
"/",
".",
"exec",
"(",
"node",
".",
"raw",
")",
";",
"//$NON-NLS-0$\r",
"if",
"(",
"match",
")",
"{",
"label",
"=",
"label",
"+",
"\" \"",
"+",
"match",
"[",
"0",
"]",
";",
"//$NON-NLS-0$\r",
"}",
"//include class if present\r",
"match",
"=",
"/",
"class=['\"]\\S*[\"']",
"/",
".",
"exec",
"(",
"node",
".",
"raw",
")",
";",
"//$NON-NLS-0$\r",
"if",
"(",
"match",
")",
"{",
"label",
"=",
"label",
"+",
"\" \"",
"+",
"match",
"[",
"0",
"]",
";",
"//$NON-NLS-0$\r",
"}",
"return",
"label",
";",
"}"
] |
Converts an HTML dom element into a label
@param {Object} element The HTML element
@return {String} A human readable label
|
[
"Converts",
"an",
"HTML",
"dom",
"element",
"into",
"a",
"label"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.webtools/web/webtools/htmlOutliner.js#L50-L63
|
|
14,683
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.webtools/web/webtools/htmlOutliner.js
|
function(dom) {
//end recursion
if (!dom) {
return null;
}
var outline = [];
for (var i = 0; i < dom.length; i++) {
var node = dom[i];
if(this.skip(node)) {
continue;
}
var element = {
label: this.domToLabel(node),
children: this.domToOutline(node.children),
start: node.range[0],
end: node.range[1]
};
outline.push(element);
}
if(outline.length > 0) {
return outline;
}
return null;
}
|
javascript
|
function(dom) {
//end recursion
if (!dom) {
return null;
}
var outline = [];
for (var i = 0; i < dom.length; i++) {
var node = dom[i];
if(this.skip(node)) {
continue;
}
var element = {
label: this.domToLabel(node),
children: this.domToOutline(node.children),
start: node.range[0],
end: node.range[1]
};
outline.push(element);
}
if(outline.length > 0) {
return outline;
}
return null;
}
|
[
"function",
"(",
"dom",
")",
"{",
"//end recursion\r",
"if",
"(",
"!",
"dom",
")",
"{",
"return",
"null",
";",
"}",
"var",
"outline",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"dom",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"node",
"=",
"dom",
"[",
"i",
"]",
";",
"if",
"(",
"this",
".",
"skip",
"(",
"node",
")",
")",
"{",
"continue",
";",
"}",
"var",
"element",
"=",
"{",
"label",
":",
"this",
".",
"domToLabel",
"(",
"node",
")",
",",
"children",
":",
"this",
".",
"domToOutline",
"(",
"node",
".",
"children",
")",
",",
"start",
":",
"node",
".",
"range",
"[",
"0",
"]",
",",
"end",
":",
"node",
".",
"range",
"[",
"1",
"]",
"}",
";",
"outline",
".",
"push",
"(",
"element",
")",
";",
"}",
"if",
"(",
"outline",
".",
"length",
">",
"0",
")",
"{",
"return",
"outline",
";",
"}",
"return",
"null",
";",
"}"
] |
Converts an HTML DOM node into an outline element
@param {Object} An HTML DOM node as returned by the Tautologistics HTML parser
@return {Object} A node in the outline tree
|
[
"Converts",
"an",
"HTML",
"DOM",
"node",
"into",
"an",
"outline",
"element"
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.webtools/web/webtools/htmlOutliner.js#L71-L94
|
|
14,684
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.webtools/web/webtools/htmlOutliner.js
|
function(node) {
//skip nodes with no name
if (!node.name) {
return true;
}
//skip formatting elements
if (node.name === "b" || node.name === "i" || node.name === "em") { //$NON-NLS-0$ //$NON-NLS-1$ //$NON-NLS-2$
return true;
}
//skip paragraphs and other blocks of formatted text
if (node.name === "tt" || node.name === "code" || node.name === "blockquote") { //$NON-NLS-0$ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return true;
}
//include the element if we have no reason to skip it
return false;
}
|
javascript
|
function(node) {
//skip nodes with no name
if (!node.name) {
return true;
}
//skip formatting elements
if (node.name === "b" || node.name === "i" || node.name === "em") { //$NON-NLS-0$ //$NON-NLS-1$ //$NON-NLS-2$
return true;
}
//skip paragraphs and other blocks of formatted text
if (node.name === "tt" || node.name === "code" || node.name === "blockquote") { //$NON-NLS-0$ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return true;
}
//include the element if we have no reason to skip it
return false;
}
|
[
"function",
"(",
"node",
")",
"{",
"//skip nodes with no name\r",
"if",
"(",
"!",
"node",
".",
"name",
")",
"{",
"return",
"true",
";",
"}",
"//skip formatting elements\r",
"if",
"(",
"node",
".",
"name",
"===",
"\"b\"",
"||",
"node",
".",
"name",
"===",
"\"i\"",
"||",
"node",
".",
"name",
"===",
"\"em\"",
")",
"{",
"//$NON-NLS-0$ //$NON-NLS-1$ //$NON-NLS-2$\r",
"return",
"true",
";",
"}",
"//skip paragraphs and other blocks of formatted text\r",
"if",
"(",
"node",
".",
"name",
"===",
"\"tt\"",
"||",
"node",
".",
"name",
"===",
"\"code\"",
"||",
"node",
".",
"name",
"===",
"\"blockquote\"",
")",
"{",
"//$NON-NLS-0$ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r",
"return",
"true",
";",
"}",
"//include the element if we have no reason to skip it\r",
"return",
"false",
";",
"}"
] |
Returns whether this HTML node should be omitted from the outline.
@function
@private
@param {Object} node The HTML element
@return {Boolean} true if the element should be skipped, and false otherwise
|
[
"Returns",
"whether",
"this",
"HTML",
"node",
"should",
"be",
"omitted",
"from",
"the",
"outline",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.webtools/web/webtools/htmlOutliner.js#L104-L121
|
|
14,685
|
eclipse/orion.client
|
bundles/org.eclipse.orion.client.webtools/web/webtools/htmlOutliner.js
|
function(dom) {
//recursively walk the dom looking for a body element
for (var i = 0; i < dom.length; i++) {
if (dom[i].name === "body") { //$NON-NLS-0$
return dom[i].children;
}
if (dom[i].children) {
var result = this.findBody(dom[i].children);
if (result) {
return result;
}
}
}
return null;
}
|
javascript
|
function(dom) {
//recursively walk the dom looking for a body element
for (var i = 0; i < dom.length; i++) {
if (dom[i].name === "body") { //$NON-NLS-0$
return dom[i].children;
}
if (dom[i].children) {
var result = this.findBody(dom[i].children);
if (result) {
return result;
}
}
}
return null;
}
|
[
"function",
"(",
"dom",
")",
"{",
"//recursively walk the dom looking for a body element\r",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"dom",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"dom",
"[",
"i",
"]",
".",
"name",
"===",
"\"body\"",
")",
"{",
"//$NON-NLS-0$\r",
"return",
"dom",
"[",
"i",
"]",
".",
"children",
";",
"}",
"if",
"(",
"dom",
"[",
"i",
"]",
".",
"children",
")",
"{",
"var",
"result",
"=",
"this",
".",
"findBody",
"(",
"dom",
"[",
"i",
"]",
".",
"children",
")",
";",
"if",
"(",
"result",
")",
"{",
"return",
"result",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] |
Returns the DOM node corresponding to the HTML body,
or null if no such node could be found.
|
[
"Returns",
"the",
"DOM",
"node",
"corresponding",
"to",
"the",
"HTML",
"body",
"or",
"null",
"if",
"no",
"such",
"node",
"could",
"be",
"found",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/bundles/org.eclipse.orion.client.webtools/web/webtools/htmlOutliner.js#L127-L141
|
|
14,686
|
eclipse/orion.client
|
modules/orionode/lib/shared/tree.js
|
getSharedWorkspace
|
function getSharedWorkspace(req, res) {
return sharedUtil.getSharedProjects(req, res, function(projects) {
var workspaces = [];
projects.forEach(function(project){
var projectSegs = project.Location.split("/");
var projectBelongingWorkspaceId = sharedUtil.getWorkspaceIdFromprojectLocation(project.Location);
if(!workspaces.some(function(workspace){
return workspace.Id === projectBelongingWorkspaceId;
})){
workspaces.push({
Id: projectBelongingWorkspaceId,
Location: api.join(sharedWorkspaceFileRoot, projectBelongingWorkspaceId),
Name: projectSegs[2] + "'s " + projectSegs[3]
});
}
});
writeResponse(null, res, null, {
Id: req.user.username,
Name: req.user.username,
UserName: req.user.fullname || req.user.username,
Workspaces: workspaces
}, true);
});
}
|
javascript
|
function getSharedWorkspace(req, res) {
return sharedUtil.getSharedProjects(req, res, function(projects) {
var workspaces = [];
projects.forEach(function(project){
var projectSegs = project.Location.split("/");
var projectBelongingWorkspaceId = sharedUtil.getWorkspaceIdFromprojectLocation(project.Location);
if(!workspaces.some(function(workspace){
return workspace.Id === projectBelongingWorkspaceId;
})){
workspaces.push({
Id: projectBelongingWorkspaceId,
Location: api.join(sharedWorkspaceFileRoot, projectBelongingWorkspaceId),
Name: projectSegs[2] + "'s " + projectSegs[3]
});
}
});
writeResponse(null, res, null, {
Id: req.user.username,
Name: req.user.username,
UserName: req.user.fullname || req.user.username,
Workspaces: workspaces
}, true);
});
}
|
[
"function",
"getSharedWorkspace",
"(",
"req",
",",
"res",
")",
"{",
"return",
"sharedUtil",
".",
"getSharedProjects",
"(",
"req",
",",
"res",
",",
"function",
"(",
"projects",
")",
"{",
"var",
"workspaces",
"=",
"[",
"]",
";",
"projects",
".",
"forEach",
"(",
"function",
"(",
"project",
")",
"{",
"var",
"projectSegs",
"=",
"project",
".",
"Location",
".",
"split",
"(",
"\"/\"",
")",
";",
"var",
"projectBelongingWorkspaceId",
"=",
"sharedUtil",
".",
"getWorkspaceIdFromprojectLocation",
"(",
"project",
".",
"Location",
")",
";",
"if",
"(",
"!",
"workspaces",
".",
"some",
"(",
"function",
"(",
"workspace",
")",
"{",
"return",
"workspace",
".",
"Id",
"===",
"projectBelongingWorkspaceId",
";",
"}",
")",
")",
"{",
"workspaces",
".",
"push",
"(",
"{",
"Id",
":",
"projectBelongingWorkspaceId",
",",
"Location",
":",
"api",
".",
"join",
"(",
"sharedWorkspaceFileRoot",
",",
"projectBelongingWorkspaceId",
")",
",",
"Name",
":",
"projectSegs",
"[",
"2",
"]",
"+",
"\"'s \"",
"+",
"projectSegs",
"[",
"3",
"]",
"}",
")",
";",
"}",
"}",
")",
";",
"writeResponse",
"(",
"null",
",",
"res",
",",
"null",
",",
"{",
"Id",
":",
"req",
".",
"user",
".",
"username",
",",
"Name",
":",
"req",
".",
"user",
".",
"username",
",",
"UserName",
":",
"req",
".",
"user",
".",
"fullname",
"||",
"req",
".",
"user",
".",
"username",
",",
"Workspaces",
":",
"workspaces",
"}",
",",
"true",
")",
";",
"}",
")",
";",
"}"
] |
Get shared projects for the user.
|
[
"Get",
"shared",
"projects",
"for",
"the",
"user",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/modules/orionode/lib/shared/tree.js#L43-L66
|
14,687
|
eclipse/orion.client
|
modules/orionode/lib/shared/tree.js
|
putFile
|
function putFile(req, res) {
var rest = req.params["0"];
var file = fileUtil.getFile(req, rest);
var fileRoot = options.fileRoot;
if (req.params['parts'] === 'meta') {
// TODO implement put of file attributes
return sendStatus(501, res);
}
function write() {
var ws = fs.createWriteStream(file.path);
ws.on('finish', function() {
fileUtil.withStatsAndETag(file.path, function(error, stats, etag) {
if (error && error.code === 'ENOENT') {
return writeResponse(404, res);
}
writeFileMetadata(fileRoot, req, res, file.path, stats, etag);
});
});
ws.on('error', function(err) {
writeError(500, res, err);
});
req.pipe(ws);
}
var ifMatchHeader = req.headers['if-match'];
fileUtil.withETag(file.path, function(error, etag) {
if (error && error.code === 'ENOENT') {
writeResponse(404, res);
}
else if (ifMatchHeader && ifMatchHeader !== etag) {
writeResponse(412, res);
}
else {
write();
}
});
}
|
javascript
|
function putFile(req, res) {
var rest = req.params["0"];
var file = fileUtil.getFile(req, rest);
var fileRoot = options.fileRoot;
if (req.params['parts'] === 'meta') {
// TODO implement put of file attributes
return sendStatus(501, res);
}
function write() {
var ws = fs.createWriteStream(file.path);
ws.on('finish', function() {
fileUtil.withStatsAndETag(file.path, function(error, stats, etag) {
if (error && error.code === 'ENOENT') {
return writeResponse(404, res);
}
writeFileMetadata(fileRoot, req, res, file.path, stats, etag);
});
});
ws.on('error', function(err) {
writeError(500, res, err);
});
req.pipe(ws);
}
var ifMatchHeader = req.headers['if-match'];
fileUtil.withETag(file.path, function(error, etag) {
if (error && error.code === 'ENOENT') {
writeResponse(404, res);
}
else if (ifMatchHeader && ifMatchHeader !== etag) {
writeResponse(412, res);
}
else {
write();
}
});
}
|
[
"function",
"putFile",
"(",
"req",
",",
"res",
")",
"{",
"var",
"rest",
"=",
"req",
".",
"params",
"[",
"\"0\"",
"]",
";",
"var",
"file",
"=",
"fileUtil",
".",
"getFile",
"(",
"req",
",",
"rest",
")",
";",
"var",
"fileRoot",
"=",
"options",
".",
"fileRoot",
";",
"if",
"(",
"req",
".",
"params",
"[",
"'parts'",
"]",
"===",
"'meta'",
")",
"{",
"// TODO implement put of file attributes",
"return",
"sendStatus",
"(",
"501",
",",
"res",
")",
";",
"}",
"function",
"write",
"(",
")",
"{",
"var",
"ws",
"=",
"fs",
".",
"createWriteStream",
"(",
"file",
".",
"path",
")",
";",
"ws",
".",
"on",
"(",
"'finish'",
",",
"function",
"(",
")",
"{",
"fileUtil",
".",
"withStatsAndETag",
"(",
"file",
".",
"path",
",",
"function",
"(",
"error",
",",
"stats",
",",
"etag",
")",
"{",
"if",
"(",
"error",
"&&",
"error",
".",
"code",
"===",
"'ENOENT'",
")",
"{",
"return",
"writeResponse",
"(",
"404",
",",
"res",
")",
";",
"}",
"writeFileMetadata",
"(",
"fileRoot",
",",
"req",
",",
"res",
",",
"file",
".",
"path",
",",
"stats",
",",
"etag",
")",
";",
"}",
")",
";",
"}",
")",
";",
"ws",
".",
"on",
"(",
"'error'",
",",
"function",
"(",
"err",
")",
"{",
"writeError",
"(",
"500",
",",
"res",
",",
"err",
")",
";",
"}",
")",
";",
"req",
".",
"pipe",
"(",
"ws",
")",
";",
"}",
"var",
"ifMatchHeader",
"=",
"req",
".",
"headers",
"[",
"'if-match'",
"]",
";",
"fileUtil",
".",
"withETag",
"(",
"file",
".",
"path",
",",
"function",
"(",
"error",
",",
"etag",
")",
"{",
"if",
"(",
"error",
"&&",
"error",
".",
"code",
"===",
"'ENOENT'",
")",
"{",
"writeResponse",
"(",
"404",
",",
"res",
")",
";",
"}",
"else",
"if",
"(",
"ifMatchHeader",
"&&",
"ifMatchHeader",
"!==",
"etag",
")",
"{",
"writeResponse",
"(",
"412",
",",
"res",
")",
";",
"}",
"else",
"{",
"write",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
For file save.
|
[
"For",
"file",
"save",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/modules/orionode/lib/shared/tree.js#L173-L208
|
14,688
|
eclipse/orion.client
|
modules/orionode/lib/shared/tree.js
|
deleteFile
|
function deleteFile(req, res) {
var rest = req.params["0"];
var file = fileUtil.getFile(req, rest);
fileUtil.withStatsAndETag(file.path, function(error, stats, etag) {
var callback = function(error) {
if (error) {
return writeError(500, res, error);
}
sendStatus(204, res);
};
var ifMatchHeader = req.headers['if-match'];
if (error && error.code === 'ENOENT') {
return sendStatus(204, res);
} else if (error) {
writeError(500, res, error);
} else if (ifMatchHeader && ifMatchHeader !== etag) {
return sendStatus(412, res);
} else if (stats.isDirectory()) {
fileUtil.rumRuff(file.path, callback);
} else {
fs.unlink(file.path, callback);
}
});
}
|
javascript
|
function deleteFile(req, res) {
var rest = req.params["0"];
var file = fileUtil.getFile(req, rest);
fileUtil.withStatsAndETag(file.path, function(error, stats, etag) {
var callback = function(error) {
if (error) {
return writeError(500, res, error);
}
sendStatus(204, res);
};
var ifMatchHeader = req.headers['if-match'];
if (error && error.code === 'ENOENT') {
return sendStatus(204, res);
} else if (error) {
writeError(500, res, error);
} else if (ifMatchHeader && ifMatchHeader !== etag) {
return sendStatus(412, res);
} else if (stats.isDirectory()) {
fileUtil.rumRuff(file.path, callback);
} else {
fs.unlink(file.path, callback);
}
});
}
|
[
"function",
"deleteFile",
"(",
"req",
",",
"res",
")",
"{",
"var",
"rest",
"=",
"req",
".",
"params",
"[",
"\"0\"",
"]",
";",
"var",
"file",
"=",
"fileUtil",
".",
"getFile",
"(",
"req",
",",
"rest",
")",
";",
"fileUtil",
".",
"withStatsAndETag",
"(",
"file",
".",
"path",
",",
"function",
"(",
"error",
",",
"stats",
",",
"etag",
")",
"{",
"var",
"callback",
"=",
"function",
"(",
"error",
")",
"{",
"if",
"(",
"error",
")",
"{",
"return",
"writeError",
"(",
"500",
",",
"res",
",",
"error",
")",
";",
"}",
"sendStatus",
"(",
"204",
",",
"res",
")",
";",
"}",
";",
"var",
"ifMatchHeader",
"=",
"req",
".",
"headers",
"[",
"'if-match'",
"]",
";",
"if",
"(",
"error",
"&&",
"error",
".",
"code",
"===",
"'ENOENT'",
")",
"{",
"return",
"sendStatus",
"(",
"204",
",",
"res",
")",
";",
"}",
"else",
"if",
"(",
"error",
")",
"{",
"writeError",
"(",
"500",
",",
"res",
",",
"error",
")",
";",
"}",
"else",
"if",
"(",
"ifMatchHeader",
"&&",
"ifMatchHeader",
"!==",
"etag",
")",
"{",
"return",
"sendStatus",
"(",
"412",
",",
"res",
")",
";",
"}",
"else",
"if",
"(",
"stats",
".",
"isDirectory",
"(",
")",
")",
"{",
"fileUtil",
".",
"rumRuff",
"(",
"file",
".",
"path",
",",
"callback",
")",
";",
"}",
"else",
"{",
"fs",
".",
"unlink",
"(",
"file",
".",
"path",
",",
"callback",
")",
";",
"}",
"}",
")",
";",
"}"
] |
For file delete.
|
[
"For",
"file",
"delete",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/modules/orionode/lib/shared/tree.js#L233-L256
|
14,689
|
eclipse/orion.client
|
modules/orionode/lib/shared/tree.js
|
loadFile
|
function loadFile(req, res) {
if (req.user) {
// User access is not allowed. This method is only for the collab server
writeError(403, res, 'Forbidden');
return;
}
var relativeFilePath = req.params['0'];
var hubid = req.params['hubId'];
return sharedProjects.getProjectPathFromHubID(hubid)
.then(function(filepath) {
if (!filepath) {
writeError(404, res, 'Session not found: ' + hubid);
return;
}
getTree(req, res);
});
}
|
javascript
|
function loadFile(req, res) {
if (req.user) {
// User access is not allowed. This method is only for the collab server
writeError(403, res, 'Forbidden');
return;
}
var relativeFilePath = req.params['0'];
var hubid = req.params['hubId'];
return sharedProjects.getProjectPathFromHubID(hubid)
.then(function(filepath) {
if (!filepath) {
writeError(404, res, 'Session not found: ' + hubid);
return;
}
getTree(req, res);
});
}
|
[
"function",
"loadFile",
"(",
"req",
",",
"res",
")",
"{",
"if",
"(",
"req",
".",
"user",
")",
"{",
"// User access is not allowed. This method is only for the collab server",
"writeError",
"(",
"403",
",",
"res",
",",
"'Forbidden'",
")",
";",
"return",
";",
"}",
"var",
"relativeFilePath",
"=",
"req",
".",
"params",
"[",
"'0'",
"]",
";",
"var",
"hubid",
"=",
"req",
".",
"params",
"[",
"'hubId'",
"]",
";",
"return",
"sharedProjects",
".",
"getProjectPathFromHubID",
"(",
"hubid",
")",
".",
"then",
"(",
"function",
"(",
"filepath",
")",
"{",
"if",
"(",
"!",
"filepath",
")",
"{",
"writeError",
"(",
"404",
",",
"res",
",",
"'Session not found: '",
"+",
"hubid",
")",
";",
"return",
";",
"}",
"getTree",
"(",
"req",
",",
"res",
")",
";",
"}",
")",
";",
"}"
] |
Get request from websocket server to load a file. Requires project HUBID and relative file path.
|
[
"Get",
"request",
"from",
"websocket",
"server",
"to",
"load",
"a",
"file",
".",
"Requires",
"project",
"HUBID",
"and",
"relative",
"file",
"path",
"."
] |
eb2583100c662b5cfc1b461a978b31d3b8555ce1
|
https://github.com/eclipse/orion.client/blob/eb2583100c662b5cfc1b461a978b31d3b8555ce1/modules/orionode/lib/shared/tree.js#L289-L306
|
14,690
|
mapbox/cheap-ruler
|
index.js
|
function (a, b) {
var dx = (b[0] - a[0]) * this.kx;
var dy = (b[1] - a[1]) * this.ky;
if (!dx && !dy) return 0;
var bearing = Math.atan2(dx, dy) * 180 / Math.PI;
if (bearing > 180) bearing -= 360;
return bearing;
}
|
javascript
|
function (a, b) {
var dx = (b[0] - a[0]) * this.kx;
var dy = (b[1] - a[1]) * this.ky;
if (!dx && !dy) return 0;
var bearing = Math.atan2(dx, dy) * 180 / Math.PI;
if (bearing > 180) bearing -= 360;
return bearing;
}
|
[
"function",
"(",
"a",
",",
"b",
")",
"{",
"var",
"dx",
"=",
"(",
"b",
"[",
"0",
"]",
"-",
"a",
"[",
"0",
"]",
")",
"*",
"this",
".",
"kx",
";",
"var",
"dy",
"=",
"(",
"b",
"[",
"1",
"]",
"-",
"a",
"[",
"1",
"]",
")",
"*",
"this",
".",
"ky",
";",
"if",
"(",
"!",
"dx",
"&&",
"!",
"dy",
")",
"return",
"0",
";",
"var",
"bearing",
"=",
"Math",
".",
"atan2",
"(",
"dx",
",",
"dy",
")",
"*",
"180",
"/",
"Math",
".",
"PI",
";",
"if",
"(",
"bearing",
">",
"180",
")",
"bearing",
"-=",
"360",
";",
"return",
"bearing",
";",
"}"
] |
Returns the bearing between two points in angles.
@param {Array<number>} a point [longitude, latitude]
@param {Array<number>} b point [longitude, latitude]
@returns {number} bearing
@example
var bearing = ruler.bearing([30.5, 50.5], [30.51, 50.49]);
//=bearing
|
[
"Returns",
"the",
"bearing",
"between",
"two",
"points",
"in",
"angles",
"."
] |
d078203640f66e4d2d3bd04b61c1e734a3aead90
|
https://github.com/mapbox/cheap-ruler/blob/d078203640f66e4d2d3bd04b61c1e734a3aead90/index.js#L99-L106
|
|
14,691
|
mapbox/cheap-ruler
|
index.js
|
function (p, dist, bearing) {
var a = bearing * Math.PI / 180;
return this.offset(p,
Math.sin(a) * dist,
Math.cos(a) * dist);
}
|
javascript
|
function (p, dist, bearing) {
var a = bearing * Math.PI / 180;
return this.offset(p,
Math.sin(a) * dist,
Math.cos(a) * dist);
}
|
[
"function",
"(",
"p",
",",
"dist",
",",
"bearing",
")",
"{",
"var",
"a",
"=",
"bearing",
"*",
"Math",
".",
"PI",
"/",
"180",
";",
"return",
"this",
".",
"offset",
"(",
"p",
",",
"Math",
".",
"sin",
"(",
"a",
")",
"*",
"dist",
",",
"Math",
".",
"cos",
"(",
"a",
")",
"*",
"dist",
")",
";",
"}"
] |
Returns a new point given distance and bearing from the starting point.
@param {Array<number>} p point [longitude, latitude]
@param {number} dist distance
@param {number} bearing
@returns {Array<number>} point [longitude, latitude]
@example
var point = ruler.destination([30.5, 50.5], 0.1, 90);
//=point
|
[
"Returns",
"a",
"new",
"point",
"given",
"distance",
"and",
"bearing",
"from",
"the",
"starting",
"point",
"."
] |
d078203640f66e4d2d3bd04b61c1e734a3aead90
|
https://github.com/mapbox/cheap-ruler/blob/d078203640f66e4d2d3bd04b61c1e734a3aead90/index.js#L119-L124
|
|
14,692
|
mapbox/cheap-ruler
|
index.js
|
function (line, dist) {
var sum = 0;
if (dist <= 0) return line[0];
for (var i = 0; i < line.length - 1; i++) {
var p0 = line[i];
var p1 = line[i + 1];
var d = this.distance(p0, p1);
sum += d;
if (sum > dist) return interpolate(p0, p1, (dist - (sum - d)) / d);
}
return line[line.length - 1];
}
|
javascript
|
function (line, dist) {
var sum = 0;
if (dist <= 0) return line[0];
for (var i = 0; i < line.length - 1; i++) {
var p0 = line[i];
var p1 = line[i + 1];
var d = this.distance(p0, p1);
sum += d;
if (sum > dist) return interpolate(p0, p1, (dist - (sum - d)) / d);
}
return line[line.length - 1];
}
|
[
"function",
"(",
"line",
",",
"dist",
")",
"{",
"var",
"sum",
"=",
"0",
";",
"if",
"(",
"dist",
"<=",
"0",
")",
"return",
"line",
"[",
"0",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"line",
".",
"length",
"-",
"1",
";",
"i",
"++",
")",
"{",
"var",
"p0",
"=",
"line",
"[",
"i",
"]",
";",
"var",
"p1",
"=",
"line",
"[",
"i",
"+",
"1",
"]",
";",
"var",
"d",
"=",
"this",
".",
"distance",
"(",
"p0",
",",
"p1",
")",
";",
"sum",
"+=",
"d",
";",
"if",
"(",
"sum",
">",
"dist",
")",
"return",
"interpolate",
"(",
"p0",
",",
"p1",
",",
"(",
"dist",
"-",
"(",
"sum",
"-",
"d",
")",
")",
"/",
"d",
")",
";",
"}",
"return",
"line",
"[",
"line",
".",
"length",
"-",
"1",
"]",
";",
"}"
] |
Returns the point at a specified distance along the line.
@param {Array<Array<number>>} line
@param {number} dist distance
@returns {Array<number>} point [longitude, latitude]
@example
var point = ruler.along(line, 2.5);
//=point
|
[
"Returns",
"the",
"point",
"at",
"a",
"specified",
"distance",
"along",
"the",
"line",
"."
] |
d078203640f66e4d2d3bd04b61c1e734a3aead90
|
https://github.com/mapbox/cheap-ruler/blob/d078203640f66e4d2d3bd04b61c1e734a3aead90/index.js#L200-L214
|
|
14,693
|
mapbox/cheap-ruler
|
index.js
|
function (start, stop, line) {
var sum = 0;
var slice = [];
for (var i = 0; i < line.length - 1; i++) {
var p0 = line[i];
var p1 = line[i + 1];
var d = this.distance(p0, p1);
sum += d;
if (sum > start && slice.length === 0) {
slice.push(interpolate(p0, p1, (start - (sum - d)) / d));
}
if (sum >= stop) {
slice.push(interpolate(p0, p1, (stop - (sum - d)) / d));
return slice;
}
if (sum > start) slice.push(p1);
}
return slice;
}
|
javascript
|
function (start, stop, line) {
var sum = 0;
var slice = [];
for (var i = 0; i < line.length - 1; i++) {
var p0 = line[i];
var p1 = line[i + 1];
var d = this.distance(p0, p1);
sum += d;
if (sum > start && slice.length === 0) {
slice.push(interpolate(p0, p1, (start - (sum - d)) / d));
}
if (sum >= stop) {
slice.push(interpolate(p0, p1, (stop - (sum - d)) / d));
return slice;
}
if (sum > start) slice.push(p1);
}
return slice;
}
|
[
"function",
"(",
"start",
",",
"stop",
",",
"line",
")",
"{",
"var",
"sum",
"=",
"0",
";",
"var",
"slice",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"line",
".",
"length",
"-",
"1",
";",
"i",
"++",
")",
"{",
"var",
"p0",
"=",
"line",
"[",
"i",
"]",
";",
"var",
"p1",
"=",
"line",
"[",
"i",
"+",
"1",
"]",
";",
"var",
"d",
"=",
"this",
".",
"distance",
"(",
"p0",
",",
"p1",
")",
";",
"sum",
"+=",
"d",
";",
"if",
"(",
"sum",
">",
"start",
"&&",
"slice",
".",
"length",
"===",
"0",
")",
"{",
"slice",
".",
"push",
"(",
"interpolate",
"(",
"p0",
",",
"p1",
",",
"(",
"start",
"-",
"(",
"sum",
"-",
"d",
")",
")",
"/",
"d",
")",
")",
";",
"}",
"if",
"(",
"sum",
">=",
"stop",
")",
"{",
"slice",
".",
"push",
"(",
"interpolate",
"(",
"p0",
",",
"p1",
",",
"(",
"stop",
"-",
"(",
"sum",
"-",
"d",
")",
")",
"/",
"d",
")",
")",
";",
"return",
"slice",
";",
"}",
"if",
"(",
"sum",
">",
"start",
")",
"slice",
".",
"push",
"(",
"p1",
")",
";",
"}",
"return",
"slice",
";",
"}"
] |
Returns a part of the given line between the start and the stop points indicated by distance along the line.
@param {number} start distance
@param {number} stop distance
@param {Array<Array<number>>} line
@returns {Array<Array<number>>} line part of a line
@example
var line2 = ruler.lineSliceAlong(10, 20, line1);
//=line2
|
[
"Returns",
"a",
"part",
"of",
"the",
"given",
"line",
"between",
"the",
"start",
"and",
"the",
"stop",
"points",
"indicated",
"by",
"distance",
"along",
"the",
"line",
"."
] |
d078203640f66e4d2d3bd04b61c1e734a3aead90
|
https://github.com/mapbox/cheap-ruler/blob/d078203640f66e4d2d3bd04b61c1e734a3aead90/index.js#L324-L348
|
|
14,694
|
mapbox/cheap-ruler
|
index.js
|
function (bbox, buffer) {
var v = buffer / this.ky;
var h = buffer / this.kx;
return [
bbox[0] - h,
bbox[1] - v,
bbox[2] + h,
bbox[3] + v
];
}
|
javascript
|
function (bbox, buffer) {
var v = buffer / this.ky;
var h = buffer / this.kx;
return [
bbox[0] - h,
bbox[1] - v,
bbox[2] + h,
bbox[3] + v
];
}
|
[
"function",
"(",
"bbox",
",",
"buffer",
")",
"{",
"var",
"v",
"=",
"buffer",
"/",
"this",
".",
"ky",
";",
"var",
"h",
"=",
"buffer",
"/",
"this",
".",
"kx",
";",
"return",
"[",
"bbox",
"[",
"0",
"]",
"-",
"h",
",",
"bbox",
"[",
"1",
"]",
"-",
"v",
",",
"bbox",
"[",
"2",
"]",
"+",
"h",
",",
"bbox",
"[",
"3",
"]",
"+",
"v",
"]",
";",
"}"
] |
Given a bounding box, returns the box buffered by a given distance.
@param {Array<number>} box object ([w, s, e, n])
@param {number} buffer
@returns {Array<number>} box object ([w, s, e, n])
@example
var bbox = ruler.bufferBBox([30.5, 50.5, 31, 51], 0.2);
//=bbox
|
[
"Given",
"a",
"bounding",
"box",
"returns",
"the",
"box",
"buffered",
"by",
"a",
"given",
"distance",
"."
] |
d078203640f66e4d2d3bd04b61c1e734a3aead90
|
https://github.com/mapbox/cheap-ruler/blob/d078203640f66e4d2d3bd04b61c1e734a3aead90/index.js#L381-L390
|
|
14,695
|
mapbox/cheap-ruler
|
index.js
|
function (p, bbox) {
return p[0] >= bbox[0] &&
p[0] <= bbox[2] &&
p[1] >= bbox[1] &&
p[1] <= bbox[3];
}
|
javascript
|
function (p, bbox) {
return p[0] >= bbox[0] &&
p[0] <= bbox[2] &&
p[1] >= bbox[1] &&
p[1] <= bbox[3];
}
|
[
"function",
"(",
"p",
",",
"bbox",
")",
"{",
"return",
"p",
"[",
"0",
"]",
">=",
"bbox",
"[",
"0",
"]",
"&&",
"p",
"[",
"0",
"]",
"<=",
"bbox",
"[",
"2",
"]",
"&&",
"p",
"[",
"1",
"]",
">=",
"bbox",
"[",
"1",
"]",
"&&",
"p",
"[",
"1",
"]",
"<=",
"bbox",
"[",
"3",
"]",
";",
"}"
] |
Returns true if the given point is inside in the given bounding box, otherwise false.
@param {Array<number>} p point [longitude, latitude]
@param {Array<number>} box object ([w, s, e, n])
@returns {boolean}
@example
var inside = ruler.insideBBox([30.5, 50.5], [30, 50, 31, 51]);
//=inside
|
[
"Returns",
"true",
"if",
"the",
"given",
"point",
"is",
"inside",
"in",
"the",
"given",
"bounding",
"box",
"otherwise",
"false",
"."
] |
d078203640f66e4d2d3bd04b61c1e734a3aead90
|
https://github.com/mapbox/cheap-ruler/blob/d078203640f66e4d2d3bd04b61c1e734a3aead90/index.js#L402-L407
|
|
14,696
|
adrai/node-cqrs-domain
|
lib/definitions/context.js
|
function (aggregate) {
if (!aggregate || !(aggregate instanceof Aggregate)) {
throw new Error('Passed object should be an Aggregate');
}
aggregate.defineContext(this);
if (this.aggregates.indexOf(aggregate) < 0) {
this.aggregates.push(aggregate);
}
}
|
javascript
|
function (aggregate) {
if (!aggregate || !(aggregate instanceof Aggregate)) {
throw new Error('Passed object should be an Aggregate');
}
aggregate.defineContext(this);
if (this.aggregates.indexOf(aggregate) < 0) {
this.aggregates.push(aggregate);
}
}
|
[
"function",
"(",
"aggregate",
")",
"{",
"if",
"(",
"!",
"aggregate",
"||",
"!",
"(",
"aggregate",
"instanceof",
"Aggregate",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Passed object should be an Aggregate'",
")",
";",
"}",
"aggregate",
".",
"defineContext",
"(",
"this",
")",
";",
"if",
"(",
"this",
".",
"aggregates",
".",
"indexOf",
"(",
"aggregate",
")",
"<",
"0",
")",
"{",
"this",
".",
"aggregates",
".",
"push",
"(",
"aggregate",
")",
";",
"}",
"}"
] |
Adds an aggregate to this context.
@param {Aggregate} aggregate the aggregate that should be added
|
[
"Adds",
"an",
"aggregate",
"to",
"this",
"context",
"."
] |
4e70105b11a444b02c12f2850c61242b4998361c
|
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/context.js#L30-L40
|
|
14,697
|
adrai/node-cqrs-domain
|
lib/definitions/context.js
|
function (name) {
if (!name || !_.isString(name)) {
throw new Error('Please pass in an aggregate name!');
}
return _.find(this.aggregates, function (agg) {
return agg.name === name;
});
}
|
javascript
|
function (name) {
if (!name || !_.isString(name)) {
throw new Error('Please pass in an aggregate name!');
}
return _.find(this.aggregates, function (agg) {
return agg.name === name;
});
}
|
[
"function",
"(",
"name",
")",
"{",
"if",
"(",
"!",
"name",
"||",
"!",
"_",
".",
"isString",
"(",
"name",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Please pass in an aggregate name!'",
")",
";",
"}",
"return",
"_",
".",
"find",
"(",
"this",
".",
"aggregates",
",",
"function",
"(",
"agg",
")",
"{",
"return",
"agg",
".",
"name",
"===",
"name",
";",
"}",
")",
";",
"}"
] |
Returns the aggregate with the requested name.
@param {String} name command name
@returns {Aggregate}
|
[
"Returns",
"the",
"aggregate",
"with",
"the",
"requested",
"name",
"."
] |
4e70105b11a444b02c12f2850c61242b4998361c
|
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/context.js#L47-L55
|
|
14,698
|
adrai/node-cqrs-domain
|
lib/definitions/context.js
|
function (name, version) {
if (!name || !_.isString(name)) {
throw new Error('Please pass in a command name!');
}
for (var a in this.aggregates) {
var aggr = this.aggregates[a];
var cmd = aggr.getCommand(name, version);
if (cmd) {
return aggr;
}
}
for (var a in this.aggregates) {
var aggr = this.aggregates[a];
var cmdHndl = aggr.getCommandHandler(name, version);
if (cmdHndl && cmdHndl !== aggr.defaultCommandHandler) {
return aggr;
}
}
debug('no matching aggregate found for command ' + name);
return null;
}
|
javascript
|
function (name, version) {
if (!name || !_.isString(name)) {
throw new Error('Please pass in a command name!');
}
for (var a in this.aggregates) {
var aggr = this.aggregates[a];
var cmd = aggr.getCommand(name, version);
if (cmd) {
return aggr;
}
}
for (var a in this.aggregates) {
var aggr = this.aggregates[a];
var cmdHndl = aggr.getCommandHandler(name, version);
if (cmdHndl && cmdHndl !== aggr.defaultCommandHandler) {
return aggr;
}
}
debug('no matching aggregate found for command ' + name);
return null;
}
|
[
"function",
"(",
"name",
",",
"version",
")",
"{",
"if",
"(",
"!",
"name",
"||",
"!",
"_",
".",
"isString",
"(",
"name",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Please pass in a command name!'",
")",
";",
"}",
"for",
"(",
"var",
"a",
"in",
"this",
".",
"aggregates",
")",
"{",
"var",
"aggr",
"=",
"this",
".",
"aggregates",
"[",
"a",
"]",
";",
"var",
"cmd",
"=",
"aggr",
".",
"getCommand",
"(",
"name",
",",
"version",
")",
";",
"if",
"(",
"cmd",
")",
"{",
"return",
"aggr",
";",
"}",
"}",
"for",
"(",
"var",
"a",
"in",
"this",
".",
"aggregates",
")",
"{",
"var",
"aggr",
"=",
"this",
".",
"aggregates",
"[",
"a",
"]",
";",
"var",
"cmdHndl",
"=",
"aggr",
".",
"getCommandHandler",
"(",
"name",
",",
"version",
")",
";",
"if",
"(",
"cmdHndl",
"&&",
"cmdHndl",
"!==",
"aggr",
".",
"defaultCommandHandler",
")",
"{",
"return",
"aggr",
";",
"}",
"}",
"debug",
"(",
"'no matching aggregate found for command '",
"+",
"name",
")",
";",
"return",
"null",
";",
"}"
] |
Return the aggregate that handles the requested command.
@param {String} name command name
@param {Number} version command version
@returns {Aggregate}
|
[
"Return",
"the",
"aggregate",
"that",
"handles",
"the",
"requested",
"command",
"."
] |
4e70105b11a444b02c12f2850c61242b4998361c
|
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/definitions/context.js#L63-L87
|
|
14,699
|
adrai/node-cqrs-domain
|
lib/aggregateModel.js
|
function (streamInfo, rev) {
this.set('_revision', rev);
streamInfo.context = streamInfo.context || '_general';
this.get('_revisions')[streamInfo.context + '_' + streamInfo.aggregate + '_' + streamInfo.aggregateId] = rev;
}
|
javascript
|
function (streamInfo, rev) {
this.set('_revision', rev);
streamInfo.context = streamInfo.context || '_general';
this.get('_revisions')[streamInfo.context + '_' + streamInfo.aggregate + '_' + streamInfo.aggregateId] = rev;
}
|
[
"function",
"(",
"streamInfo",
",",
"rev",
")",
"{",
"this",
".",
"set",
"(",
"'_revision'",
",",
"rev",
")",
";",
"streamInfo",
".",
"context",
"=",
"streamInfo",
".",
"context",
"||",
"'_general'",
";",
"this",
".",
"get",
"(",
"'_revisions'",
")",
"[",
"streamInfo",
".",
"context",
"+",
"'_'",
"+",
"streamInfo",
".",
"aggregate",
"+",
"'_'",
"+",
"streamInfo",
".",
"aggregateId",
"]",
"=",
"rev",
";",
"}"
] |
Sets the revision for this aggregate.
@param {Object} streamInfo The stream info.
@param {Number} rev The revision number.
|
[
"Sets",
"the",
"revision",
"for",
"this",
"aggregate",
"."
] |
4e70105b11a444b02c12f2850c61242b4998361c
|
https://github.com/adrai/node-cqrs-domain/blob/4e70105b11a444b02c12f2850c61242b4998361c/lib/aggregateModel.js#L57-L61
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.