Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions core/core_27_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ $.hosts.code['/objectPanel'].buildData = function buildData(query) {
for (var i = 0; i < ownProps.length; i++) {
var prop = ownProps[i];
var type = this.getType(value[prop]);
ownProps[i] = {name: prop, type: type};
ownProps[i] = { name: prop, type: type };
}
data.properties.push(ownProps);
value = Object.getPrototypeOf(value);
Expand All @@ -94,7 +94,7 @@ $.hosts.code['/objectPanel'].buildData = function buildData(query) {
// Add typeof information.
var global = $.utils.code.getGlobal();
for (var name in global) {
data.roots.push({name: name, type: this.getType(global[name])});
data.roots.push({ name: name, type: this.getType(global[name]) });
}
}
return data;
Expand All @@ -119,7 +119,7 @@ $.hosts.code['/editorXhr'].www = function code_editorXhr_www(request, response)
* only present if save was requested
* - login: boolean indicating if the user is logged in
*/
var data = {login: !!request.user};
var data = { login: !!request.user };
try { // ends with ... finally {response.write(JSON.stringify(data));}
if (!request.fromSameOrigin()) {
// Security check to ensure this is being loaded by the code editor.
Expand All @@ -141,7 +141,7 @@ $.hosts.code['/editorXhr'].www = function code_editorXhr_www(request, response)
// Global variable; no parent object.
object = null;
} else if (request.parameters.key &&
(object = $.db.tempId.getObjById(request.parameters.key))) {
(object = $.db.tempId.getObjById(request.parameters.key))) {
// Successfully retrieved parent object from tempID DB.
} else {
// Get parent object via selector.
Expand Down Expand Up @@ -370,7 +370,7 @@ $.hosts.code['/editorXhr'].generateMetaData = function generateMetaData(value, s
for (var i = 0, prop; (prop = props[i]); i++) {
try {
meta += '// ' + (value[prop] ? '@set_prop ' + prop + ' = ' +
JSON.stringify(value[prop]) : '@delete_prop ' + prop) + '\n';
JSON.stringify(value[prop]) : '@delete_prop ' + prop) + '\n';
} catch (e) {
// Unstringable value, or read perms error. Skip.
}
Expand Down
11 changes: 7 additions & 4 deletions static/connect/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,13 @@ CCC.Common.parentFocus = function(e) {
var ct = parent.document.getElementById('commandTextarea');
ct.focus();
// Chrome won't type the character in the textarea after a focus change.
// For the easy case where the field is empty, just add the character.
// TODO: Handle cases where the field is not empty.
if (e && e.key.length === 1 && !ct.value.length) {
ct.value = e.key;
// Insert the character at the cursor, replacing any selected text.
if (e && e.key.length === 1) {
var start = ct.selectionStart;
var end = ct.selectionEnd;
ct.value = ct.value.substring(0, start) + e.key +
ct.value.substring(end);
ct.selectionStart = ct.selectionEnd = start + e.key.length;
// Firefox will type the character a second time, prevent this.
e.preventDefault();
}
Expand Down
25 changes: 25 additions & 0 deletions static/connect/tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,31 @@ function testCommonEscapeSpaces() {
assertEquals('\u00A0a\u00A0 \u00A0 \u00A0 \u00A0 b', CCC.Common.escapeSpaces(' a\tb'));
}

function testCommonParentFocus() {
var textarea = document.createElement('textarea');
textarea.id = 'commandTextarea';
document.body.appendChild(textarea);
try {
var event = {key: 'x', preventDefault: function() {}};
CCC.Common.parentFocus(event);
assertEquals('x', textarea.value);
assertEquals(1, textarea.selectionStart);

textarea.value = 'look north';
textarea.setSelectionRange(5, 5);
CCC.Common.parentFocus(event);
assertEquals('look xnorth', textarea.value);
assertEquals(6, textarea.selectionStart);

textarea.setSelectionRange(5, 10);
CCC.Common.parentFocus(event);
assertEquals('look x', textarea.value);
assertEquals(6, textarea.selectionStart);
} finally {
document.body.removeChild(textarea);
}
}

// log.js

function testLogGetTemplate() {
Expand Down