didier

ajouts forge

var ARCSForge = {};
var Document = function() {
var contents = "";
var fileName = "";
var lines = [""];
var updateLines = function() {
lines = contents.split("\n");
};
this.load = function() {
};
this.save = function() {
};
this.setFile = function(fn) {
fileName = fn;
};
this.getFile = function() {
return fileName;
};
this.change = function(src,obj) {
var i,lstart,lend,span ;
if (obj.removed === undefined || obj.to === undefined ||
obj.from === undefined || obj.text === undefined)
return;
lstart = lines[obj.from.line].slice(0,obj.from.ch);
lend = lines[obj.to.line].slice(obj.to.ch);
// all lines removed
lines.splice(obj.from.line, obj.to.line - obj.from.line + 1);
// creating lines
var newlines = [ lstart + obj.text[0] ];
for (i = 1; i < obj.text.length; i++) {
newlines[i] = obj.text[i];
}
newlines[obj.text.length-1] += lend;
// inserting lines
for (i=0; i < newlines.length; i++) {
lines.splice(obj.from.line + i,0, newlines[i]);
}
};
};
var cm = CodeMirror(document.body);
var doc = new Document();
......
#!/bin/node
require('fs');
var Document = function() {
var contents = "";
var fileName = "";
var lineIndices = [];
var updateLineIndices = function() {
var currentIndex = 0;
lineIndices = [];
while ( (currentIndex = contents.indexOf('\n',currentIndex)) > 0) {
lineIndices.push(currentIndex);
}
};
this.load = function() {
};
this.save = function() {
};
this.setFile = function(fn) {
fileName = fn;
};
this.getFile = function() {
return fileName;
};
this.change = function(obj) {
if ( removed !== "" ) {
}
};
};
var fs = require('fs');
var http = require('http');
var https = require('https');
var express = require('express');
var app = express();
var expressWs = require('express-ws')(app);
var Document = require('./document.js');
var httpServer = http.createServer(app);
......
var fs = require('fs');
exports.Document = function() {
var contents = "";
var fileName = "";
var lines = [""];
var updateLines = function() {
lines = contents.split("\n");
};
this.load = function() {
};
this.save = function() {
};
this.setFile = function(fn) {
fileName = fn;
};
this.getFile = function() {
return fileName;
};
this.change = function(src,obj) {
var i,lstart,lend,span ;
if (obj.removed === undefined || obj.to === undefined ||
obj.from === undefined || obj.text === undefined)
return;
lstart = lines[obj.from.line].slice(0,obj.from.ch);
lend = lines[obj.to.line].slice(obj.to.ch);
// all lines removed
lines.splice(obj.from.line, obj.to.line - obj.from.line + 1);
// creating lines
var newlines = [ lstart + obj.text[0] ];
for (i = 1; i < obj.text.length; i++) {
newlines[i] = obj.text[i];
}
newlines[obj.text.length-1] += lend;
// inserting lines
for (i=0; i < newlines.length; i++) {
lines.splice(obj.from.line + i,0, newlines[i]);
}
};
};
{
"name": "ARCS-Forge",
"version": "0.1.0",
"description": "Augmented Reality Component System Forge service",
"main": "arcsforgeservice.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"Augmented",
"Reality"
],
"author": "Jean-Yves Didier",
"license": "GPL",
"devDependencies": {
"express" : ">=4.13.4",
"express-ws" : ">=1.0.0"
}
}