App-SocialCalc-Multiplayer
view release on metacpan or search on metacpan
socialcalc/socialcalctableeditor.js view on Meta::CPAN
case "[ctrl-s]": // !!!! temporary hack
window.setTimeout(
function() {
if (!SocialCalc.GetSpreadsheetControlObject) return;
var s = SocialCalc.GetSpreadsheetControlObject();
if (!s) return;
var editor = s.editor;
var sheet = editor.context.sheetobj;
var cell = sheet.GetAssuredCell(editor.ecell.coord);
var ntvf = cell.nontextvalueformat ? sheet.valueformats[cell.nontextvalueformat-0] || "" : "";
var newntvf = window.prompt("Advanced Feature:\n\nCustom Numeric Format or Command", ntvf);
if (newntvf != null) { // not cancelled
if (newntvf.match(/^cmd:/)) {
cmd = newntvf.substring(4); // execute as command
}
else if (newntvf.match(/^edit:/)) {
cmd = newntvf.substring(5); // execute as command
if (SocialCalc.CtrlSEditor) {
SocialCalc.CtrlSEditor(cmd);
}
return;
}
else {
if (editor.range.hasrange) {
sel = SocialCalc.crToCoord(editor.range.left, editor.range.top)+
":"+SocialCalc.crToCoord(editor.range.right, editor.range.bottom);
}
else {
sel = editor.ecell.coord;
}
cmd = "set "+sel+" nontextvalueformat "+newntvf;
}
editor.EditorScheduleSheetCommands(cmd, true, false);
}
},
200);
return false;
default:
break;
}
return true;
};
// Set sheet's status callback:
context.sheetobj.statuscallback = SocialCalc.EditorSheetStatusCallback;
context.sheetobj.statuscallbackparams = this; // this object: the table editor object
// StatusCallback: all values are called at appropriate times, add with unique name, delete when done
//
// Each value must be an object in the form of:
//
// func: function(editor, status, arg, params) {...},
// params: params value to call func with
//
// The values for status and arg are:
//
// all the SocialCalc RecalcSheet statuscallbacks, including:
//
// calccheckdone, calclist length
// calcorder, {coord: coord, total: celllist length, count: count}
// calcstep, {coord: coord, total: calclist length, count: count}
// calcfinished, time in milliseconds
//
// the command callbacks, like cmdstart and cmdend
// cmdendnorender
//
// calcstart, null
// moveecell, new ecell coord
// rangechange, "coord:coord" or "coord" or ""
// specialkey, keyname ("[esc]")
//
this.StatusCallback = {};
this.MoveECellCallback = {}; // all values are called with editor as arg; add with unique name, delete when done
this.RangeChangeCallback = {}; // all values are called with editor as arg; add with unique name, delete when done
this.SettingsCallbacks = {}; // See SocialCalc.SaveEditorSettings
// Set initial cursor
this.ecell = {coord: "A1", row: 1, col: 1};
context.highlights[this.ecell.coord] = "cursor";
// Initialize range data
// Range has at least hasrange (true/false).
// It may also have: anchorcoord, anchorrow, anchorcol, top, bottom, left, and right.
this.range = {hasrange: false};
// Initialize range2 data (used to show selections, such as for move)
// Range2 has at least hasrange (true/false).
// It may also have: top, bottom, left, and right.
this.range2 = {hasrange: false};
}
// Methods:
SocialCalc.TableEditor.prototype.CreateTableEditor = function(width, height) {return SocialCalc.CreateTableEditor(this, width, height);};
SocialCalc.TableEditor.prototype.ResizeTableEditor = function(width, height) {return SocialCalc.ResizeTableEditor(this, width, height);};
SocialCalc.TableEditor.prototype.SaveEditorSettings = function() {return SocialCalc.SaveEditorSettings(this);};
SocialCalc.TableEditor.prototype.LoadEditorSettings = function(str, flags) {return SocialCalc.LoadEditorSettings(this, str, flags);};
SocialCalc.TableEditor.prototype.EditorRenderSheet = function() {SocialCalc.EditorRenderSheet(this);};
SocialCalc.TableEditor.prototype.EditorScheduleSheetCommands = function(cmdstr, saveundo, ignorebusy) {SocialCalc.EditorScheduleSheetCommands(this, cmdstr, saveundo, ignorebusy);};
SocialCalc.TableEditor.prototype.ScheduleSheetCommands = function(cmdstr, saveundo) {
this.context.sheetobj.ScheduleSheetCommands(cmdstr, saveundo);
};
SocialCalc.TableEditor.prototype.SheetUndo = function() {
this.context.sheetobj.SheetUndo();
};
SocialCalc.TableEditor.prototype.SheetRedo = function() {
this.context.sheetobj.SheetRedo();
};
SocialCalc.TableEditor.prototype.EditorStepSet = function(status, arg) {SocialCalc.EditorStepSet(this, status, arg);};
SocialCalc.TableEditor.prototype.GetStatuslineString = function(status, arg, params) {return SocialCalc.EditorGetStatuslineString(this, status, arg, params);};
SocialCalc.TableEditor.prototype.EditorMouseRegister = function() {return SocialCalc.EditorMouseRegister(this);};
SocialCalc.TableEditor.prototype.EditorMouseUnregister = function() {return SocialCalc.EditorMouseUnregister(this);};
SocialCalc.TableEditor.prototype.EditorMouseRange = function(coord) {return SocialCalc.EditorMouseRange(this, coord);};
( run in 2.420 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )