forked from audreyt/ethercalc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
player-broadcast.js
133 lines (132 loc) · 5.76 KB
/
player-broadcast.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// Generated by LiveScript 1.4.0
(function(){
this.include = function(){
return this.client({
'/player/broadcast.js': function(){
var SocialCalc, md5;
SocialCalc = window.SocialCalc || alert('Cannot find window.SocialCalc');
if (SocialCalc != null && SocialCalc.OrigDoPositionCalculations) {
return;
}
SocialCalc.OrigDoPositionCalculations = SocialCalc.DoPositionCalculations;
SocialCalc.DoPositionCalculations = function(){
var ref$;
SocialCalc.OrigDoPositionCalculations.apply(SocialCalc, arguments);
if (typeof (ref$ = SocialCalc.Callbacks).broadcast == 'function') {
ref$.broadcast('ask.ecell');
}
};
if (window.CryptoJS) {
md5 = function(it){
return CryptoJS.MD5(it).toString();
};
SocialCalc.hadSnapshot = true;
SocialCalc.OrigLoadEditorSettings = SocialCalc.LoadEditorSettings;
SocialCalc.LoadEditorSettings = function(editor, str, flags){
editor.SettingsCallbacks.ethercalc = {
save: function(){
return "ethercalc:" + md5(editor.context.sheetobj.CreateSheetSave()) + "\n";
},
load: function(editor, setting, line, flags){
var hash;
hash = line.replace(/^\w+:/, '');
if (hash === md5(editor.context.sheetobj.CreateSheetSave())) {
return SocialCalc.hadSnapshot = false;
} else {
return SocialCalc.hadSnapshot = true;
}
}
};
SocialCalc.LoadEditorSettings = SocialCalc.OrigLoadEditorSettings;
return SocialCalc.OrigLoadEditorSettings(editor, str, flags);
};
} else {
SocialCalc.hadSnapshot = false;
}
SocialCalc.OrigSizeSSDiv = SocialCalc.SizeSSDiv;
SocialCalc.SizeSSDiv = function(spreadsheet){
if (!(spreadsheet != null && spreadsheet.parentNode)) {
return;
}
return SocialCalc.OrigSizeSSDiv(spreadsheet);
};
SocialCalc.Sheet.prototype.ScheduleSheetCommands = function(){
return SocialCalc.ScheduleSheetCommands.apply(SocialCalc, [this].concat([].slice.call(arguments)));
};
SocialCalc.OrigScheduleSheetCommands = SocialCalc.ScheduleSheetCommands;
SocialCalc.ScheduleSheetCommands = function(sheet, cmdstr, saveundo, isRemote){
var ref$, ref1$, i$, ref2$, len$, ref3$, link, title;
cmdstr = cmdstr.replace(/\n\n+/g, '\n');
if (!/\S/.test(cmdstr)) {
return;
}
if (!isRemote && cmdstr !== 'redisplay' && cmdstr !== 'recalc') {
if (((ref$ = window.__MULTI__) != null && ((ref1$ = ref$.rows) != null && ref1$.length)) && /set \w+ formula /.exec(cmdstr)) {
for (i$ = 0, len$ = (ref2$ = window.__MULTI__.rows).length; i$ < len$; ++i$) {
ref3$ = ref2$[i$], link = ref3$.link, title = ref3$.title;
cmdstr = cmdstr.replace(RegExp('\\$' + title + '\\.([A-Z]+[1-9][0-9]*)', 'ig'), "\"" + link.replace('/', '') + "\"!$1");
}
}
if (typeof (ref2$ = SocialCalc.Callbacks).broadcast == 'function') {
ref2$.broadcast('execute', {
cmdstr: cmdstr,
saveundo: saveundo
});
}
}
return SocialCalc.OrigScheduleSheetCommands(sheet, cmdstr, saveundo, isRemote);
};
return SocialCalc.MoveECell = function(editor, newcell){
var highlights, ref$, cell, f;
highlights = editor.context.highlights;
if (editor.ecell) {
if (editor.ecell.coord === newcell) {
return newcell;
}
if (typeof (ref$ = SocialCalc.Callbacks).broadcast == 'function') {
ref$.broadcast('ecell', {
original: editor.ecell.coord,
ecell: newcell
});
}
cell = SocialCalc.GetEditorCellElement(editor, editor.ecell.row, editor.ecell.col);
delete highlights[editor.ecell.coord];
if (editor.range2.hasrange && editor.ecell.row >= editor.range2.top && editor.ecell.row <= editor.range2.bottom && editor.ecell.col >= editor.range2.left && editor.ecell.col <= editor.range2.right) {
highlights[editor.ecell.coord] = 'range2';
}
editor.UpdateCellCSS(cell, editor.ecell.row, editor.ecell.col);
editor.SetECellHeaders('');
editor.cellhandles.ShowCellHandles(false);
} else {
if (typeof (ref$ = SocialCalc.Callbacks).broadcast == 'function') {
ref$.broadcast('ecell', {
ecell: newcell
});
}
}
newcell = editor.context.cellskip[newcell] || newcell;
editor.ecell = SocialCalc.coordToCr(newcell);
editor.ecell.coord = newcell;
cell = SocialCalc.GetEditorCellElement(editor, editor.ecell.row, editor.ecell.col);
highlights[newcell] = 'cursor';
for (f in editor.MoveECellCallback) {
editor.MoveECellCallback[f](editor);
}
editor.UpdateCellCSS(cell, editor.ecell.row, editor.ecell.col);
editor.SetECellHeaders('selected');
for (f in editor.StatusCallback) {
editor.StatusCallback[f].func(editor, 'moveecell', newcell, editor.StatusCallback[f].params);
}
if (editor.busy) {
editor.ensureecell = true;
} else {
editor.ensureecell = false;
editor.EnsureECellVisible();
}
return newcell;
};
}
});
};
}).call(this);
//# sourceMappingURL=player-broadcast.js.map