move sheet/ to .git

pull/1/head
ansuz 9 years ago
parent cdf02ac725
commit 06b464c524

@ -1,29 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<script data-main="main" src="/bower_components/requirejs/require.js"></script>
<style>
#sheet-iframe {
position:fixed;
top:0px;
left:0px;
bottom:0px;
right:0px;
width:100%;
height:96%;
border:none;
margin:0;
padding:0;
overflow:hidden;
}
#sheet-json {
display:none;
}
</style>
</head>
<body>
<textarea id="sheet-json"></textarea>
<iframe id="sheet-iframe" src="inner.html"></iframe>
</body>
</html>

@ -1,36 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<title>jQuery.sheet - The Ajax Spreadsheet DTS Lazy Loading</title>
<script src="/bower_components/jquery-legacy/dist/jquery.js"></script>
<script src="/bower_components/jquery.sheet/parser/formula/formula.js"></script>
<script src="/bower_components/jquery.sheet/jquery.sheet.js"></script>
<script>
var numColumns = 10;
var numRows = 20;
var spreadsheetJson = [ { "title": "", "rows": [ ] } ];
for (var i = 0; i < numRows; i++) {
var columns = [];
spreadsheetJson[0].rows.push({ columns: columns });
for (var j = 0; j < numColumns; j++) { columns[j] = { "value": "" }; }
}
$.sheet.preLoad('/bower_components/jquery.sheet/');
$(function () {
window.sheetLdr = new Sheet.JSONLoader( spreadsheetJson );
window.sh = $('#sheet-json').height($(window).height()).width($(window).width()).sheet({
loader: window.sheetLdr,
minSize: { rows:numRows, cols:numColumns }
});
});
</script>
</head>
<body>
<div id="sheet-json" title="CryptSheet"></div>
</body>
</html>

@ -1,138 +0,0 @@
define([
'/api/config?cb=' + Math.random().toString(16).substring(2),
'/common/messages.js',
'/common/crypto.js',
'/common/toolbar.js',
'/common/chainpad.js',
'/bower_components/jquery/dist/jquery.min.js',
'/common/otaml.js',
'/customize/sheet.js'
], function (Config, Messages, Crypto, Toolbar) {
var $ = window.jQuery;
var ChainPad = window.ChainPad;
var Otaml = window.Otaml;
var module = { exports: {} };
var sheetToJson = function (ifrWindow) {
var xx = ifrWindow.sh[0].jS;
var m = [];
for (var i = 0; i < xx.spreadsheets.length; i++) {
m[i]=[];
var sheet = xx.spreadsheets[i];
for (var j = 1; j < sheet.length; j++) {
m[i][j]=[];
var row = sheet[j];
for (var k = 1; k < row.length; k++) {
var col = row[k];
m[i][j][k] = { value: col.value, formula: col.formula };
}
}
}
return m;
};
var jsonToSheet = function (ifrWindow, json) {
var xx = ifrWindow.sh[0].jS;
for (var i = 0; i < xx.spreadsheets.length; i++) {
var sheet = xx.spreadsheets[i];
for (var j = 1; j < sheet.length; j++) {
var row = sheet[j];
for (var k = 1; k < row.length; k++) {
var col = row[k];
var jcol = json[i][j][k];
if (jcol.value === col.value && jcol.formula === col.formula) { continue; }
col.value = jcol.value;
col.formula = jcol.formula;
col.displayValue();
}
}
}
};
var applyChange = function(ctx, oldval, newval) {
if (oldval === newval) {
return;
}
var commonStart = 0;
while (oldval.charAt(commonStart) === newval.charAt(commonStart)) {
commonStart++;
}
var commonEnd = 0;
while (oldval.charAt(oldval.length - 1 - commonEnd) === newval.charAt(newval.length - 1 - commonEnd) &&
commonEnd + commonStart < oldval.length && commonEnd + commonStart < newval.length) {
commonEnd++;
}
if (oldval.length !== commonStart + commonEnd) {
ctx.remove(commonStart, oldval.length - commonStart - commonEnd);
}
if (newval.length !== commonStart + commonEnd) {
ctx.insert(commonStart, newval.slice(commonStart, newval.length - commonEnd));
}
};
$(function () {
if (window.location.href.indexOf('#') === -1) {
window.location.href = window.location.href + '#' + Crypto.genKey();
}
$(window).on('hashchange', function() {
window.location.reload();
});
var $sheetJson = $('#sheet-json');
var ifrw = $('iframe')[0].contentWindow;
var sheetEvent = function (realtime) {
var sheetJson = JSON.stringify(sheetToJson(ifrw));
applyChange(realtime, realtime.getUserDoc(), sheetJson);
$sheetJson.text(sheetJson);
};
var eventPending = false;
var realtimeEvent = function (realtime) {
if (eventPending) { return; }
eventPending = true;
setTimeout(function () {
eventPending = false;
try{
var data = window.data = realtime.getUserDoc();
$sheetJson.text(data);
var json = JSON.parse(data);
jsonToSheet(ifrw, json);
}catch(e) { console.log(e.stack); }
}, 0);
};
var key = Crypto.parseKey(window.location.hash.substring(1));
var myUserName = Crypto.rand64(8);
var socket = new WebSocket(Config.websocketURL);
socket.onopen = function () {
var realtime = ChainPad.create(
myUserName, 'x', key.channel, '', { transformFunction: Otaml.transform });
socket.onmessage = function (evt) {
var message = Crypto.decrypt(evt.data, key.cryptKey);
realtime.message(message);
};
realtime.onMessage(function (message) {
message = Crypto.encrypt(message, key.cryptKey);
try {
socket.send(message);
} catch (e) {
console.log(e.stack);
}
});
ifrw.sh.on('sheetCellEdited', function () { sheetEvent(realtime); });
sheetEvent(realtime);
realtime.onPatch(function () { realtimeEvent(realtime); });
ifrw.$('.jSTitle').html('');
Toolbar.create(ifrw.$('.jSTitle'), myUserName, realtime);
realtime.start();
};
});
});
Loading…
Cancel
Save