initial commit

This commit is contained in:
Blue 2018-08-05 00:46:25 +03:00 committed by Юрий Губич
commit 4b60ece582
327 changed files with 28286 additions and 0 deletions

12
lorgar/lib/CMakeLists.txt Normal file
View file

@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 2.8.12)
add_subdirectory(requirejs)
add_subdirectory(wSocket)
add_subdirectory(bintrees)
add_subdirectory(wContainer)
add_subdirectory(utils)
add_subdirectory(wType)
add_subdirectory(wDispatcher)
add_subdirectory(wTest)
add_subdirectory(wController)
add_subdirectory(fonts)

View file

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 2.8.12)
configure_file(index.js index.js)

View file

@ -0,0 +1,478 @@
"use strict";
(function rbtree_js() {
var moduleName = "lib/bintrees/index";
var defineArray = [];
define(moduleName, defineArray, function rbtree_module() {
var require = function(name) {
var fn = require.m[name];
if (fn.mod) {
return fn.mod.exports;
}
var mod = fn.mod = { exports: {} };
fn(mod, mod.exports);
return mod.exports;
};
require.m = {};
require.m['./treebase'] = function(module, exports) {
function TreeBase() {}
// removes all nodes from the tree
TreeBase.prototype.clear = function() {
this._root = null;
this.size = 0;
};
// returns node data if found, null otherwise
TreeBase.prototype.find = function(data) {
var res = this._root;
while(res !== null) {
var c = this._comparator(data, res.data);
if(c === 0) {
return res.data;
}
else {
res = res.get_child(c > 0);
}
}
return null;
};
// returns iterator to node if found, null otherwise
TreeBase.prototype.findIter = function(data) {
var res = this._root;
var iter = this.iterator();
while(res !== null) {
var c = this._comparator(data, res.data);
if(c === 0) {
iter._cursor = res;
return iter;
}
else {
iter._ancestors.push(res);
res = res.get_child(c > 0);
}
}
return null;
};
// Returns an iterator to the tree node at or immediately after the item
TreeBase.prototype.lowerBound = function(item) {
var cur = this._root;
var iter = this.iterator();
var cmp = this._comparator;
while(cur !== null) {
var c = cmp(item, cur.data);
if(c === 0) {
iter._cursor = cur;
return iter;
}
iter._ancestors.push(cur);
cur = cur.get_child(c > 0);
}
for(var i=iter._ancestors.length - 1; i >= 0; --i) {
cur = iter._ancestors[i];
if(cmp(item, cur.data) < 0) {
iter._cursor = cur;
iter._ancestors.length = i;
return iter;
}
}
iter._ancestors.length = 0;
return iter;
};
// Returns an iterator to the tree node immediately after the item
TreeBase.prototype.upperBound = function(item) {
var iter = this.lowerBound(item);
var cmp = this._comparator;
while(iter.data() !== null && cmp(iter.data(), item) === 0) {
iter.next();
}
return iter;
};
// returns null if tree is empty
TreeBase.prototype.min = function() {
var res = this._root;
if(res === null) {
return null;
}
while(res.left !== null) {
res = res.left;
}
return res.data;
};
// returns null if tree is empty
TreeBase.prototype.max = function() {
var res = this._root;
if(res === null) {
return null;
}
while(res.right !== null) {
res = res.right;
}
return res.data;
};
// returns a null iterator
// call next() or prev() to point to an element
TreeBase.prototype.iterator = function() {
return new Iterator(this);
};
// calls cb on each node's data, in order
TreeBase.prototype.each = function(cb) {
var it=this.iterator(), data;
while((data = it.next()) !== null) {
cb(data);
}
};
// calls cb on each node's data, in reverse order
TreeBase.prototype.reach = function(cb) {
var it=this.iterator(), data;
while((data = it.prev()) !== null) {
cb(data);
}
};
function Iterator(tree) {
this._tree = tree;
this._ancestors = [];
this._cursor = null;
}
Iterator.prototype.data = function() {
return this._cursor !== null ? this._cursor.data : null;
};
// if null-iterator, returns first node
// otherwise, returns next node
Iterator.prototype.next = function() {
if(this._cursor === null) {
var root = this._tree._root;
if(root !== null) {
this._minNode(root);
}
}
else {
if(this._cursor.right === null) {
// no greater node in subtree, go up to parent
// if coming from a right child, continue up the stack
var save;
do {
save = this._cursor;
if(this._ancestors.length) {
this._cursor = this._ancestors.pop();
}
else {
this._cursor = null;
break;
}
} while(this._cursor.right === save);
}
else {
// get the next node from the subtree
this._ancestors.push(this._cursor);
this._minNode(this._cursor.right);
}
}
return this._cursor !== null ? this._cursor.data : null;
};
// if null-iterator, returns last node
// otherwise, returns previous node
Iterator.prototype.prev = function() {
if(this._cursor === null) {
var root = this._tree._root;
if(root !== null) {
this._maxNode(root);
}
}
else {
if(this._cursor.left === null) {
var save;
do {
save = this._cursor;
if(this._ancestors.length) {
this._cursor = this._ancestors.pop();
}
else {
this._cursor = null;
break;
}
} while(this._cursor.left === save);
}
else {
this._ancestors.push(this._cursor);
this._maxNode(this._cursor.left);
}
}
return this._cursor !== null ? this._cursor.data : null;
};
Iterator.prototype._minNode = function(start) {
while(start.left !== null) {
this._ancestors.push(start);
start = start.left;
}
this._cursor = start;
};
Iterator.prototype._maxNode = function(start) {
while(start.right !== null) {
this._ancestors.push(start);
start = start.right;
}
this._cursor = start;
};
module.exports = TreeBase;
};
require.m['__main__'] = function(module, exports) {
var TreeBase = require('./treebase');
function Node(data) {
this.data = data;
this.left = null;
this.right = null;
this.red = true;
}
Node.prototype.get_child = function(dir) {
return dir ? this.right : this.left;
};
Node.prototype.set_child = function(dir, val) {
if(dir) {
this.right = val;
}
else {
this.left = val;
}
};
function RBTree(comparator) {
this._root = null;
this._comparator = comparator;
this.size = 0;
}
RBTree.prototype = new TreeBase();
// returns true if inserted, false if duplicate
RBTree.prototype.insert = function(data) {
var ret = false;
if(this._root === null) {
// empty tree
this._root = new Node(data);
ret = true;
this.size++;
}
else {
var head = new Node(undefined); // fake tree root
var dir = 0;
var last = 0;
// setup
var gp = null; // grandparent
var ggp = head; // grand-grand-parent
var p = null; // parent
var node = this._root;
ggp.right = this._root;
// search down
while(true) {
if(node === null) {
// insert new node at the bottom
node = new Node(data);
p.set_child(dir, node);
ret = true;
this.size++;
}
else if(is_red(node.left) && is_red(node.right)) {
// color flip
node.red = true;
node.left.red = false;
node.right.red = false;
}
// fix red violation
if(is_red(node) && is_red(p)) {
var dir2 = ggp.right === gp;
if(node === p.get_child(last)) {
ggp.set_child(dir2, single_rotate(gp, !last));
}
else {
ggp.set_child(dir2, double_rotate(gp, !last));
}
}
var cmp = this._comparator(node.data, data);
// stop if found
if(cmp === 0) {
break;
}
last = dir;
dir = cmp < 0;
// update helpers
if(gp !== null) {
ggp = gp;
}
gp = p;
p = node;
node = node.get_child(dir);
}
// update root
this._root = head.right;
}
// make root black
this._root.red = false;
return ret;
};
// returns true if removed, false if not found
RBTree.prototype.remove = function(data) {
if(this._root === null) {
return false;
}
var head = new Node(undefined); // fake tree root
var node = head;
node.right = this._root;
var p = null; // parent
var gp = null; // grand parent
var found = null; // found item
var dir = 1;
while(node.get_child(dir) !== null) {
var last = dir;
// update helpers
gp = p;
p = node;
node = node.get_child(dir);
var cmp = this._comparator(data, node.data);
dir = cmp > 0;
// save found node
if(cmp === 0) {
found = node;
}
// push the red node down
if(!is_red(node) && !is_red(node.get_child(dir))) {
if(is_red(node.get_child(!dir))) {
var sr = single_rotate(node, dir);
p.set_child(last, sr);
p = sr;
}
else if(!is_red(node.get_child(!dir))) {
var sibling = p.get_child(!last);
if(sibling !== null) {
if(!is_red(sibling.get_child(!last)) && !is_red(sibling.get_child(last))) {
// color flip
p.red = false;
sibling.red = true;
node.red = true;
}
else {
var dir2 = gp.right === p;
if(is_red(sibling.get_child(last))) {
gp.set_child(dir2, double_rotate(p, last));
}
else if(is_red(sibling.get_child(!last))) {
gp.set_child(dir2, single_rotate(p, last));
}
// ensure correct coloring
var gpc = gp.get_child(dir2);
gpc.red = true;
node.red = true;
gpc.left.red = false;
gpc.right.red = false;
}
}
}
}
}
// replace and remove if found
if(found !== null) {
found.data = node.data;
p.set_child(p.right === node, node.get_child(node.left === null));
this.size--;
}
// update root and make it black
this._root = head.right;
if(this._root !== null) {
this._root.red = false;
}
return found !== null;
};
function is_red(node) {
return node !== null && node.red;
}
function single_rotate(root, dir) {
var save = root.get_child(!dir);
root.set_child(!dir, save.get_child(dir));
save.set_child(dir, root);
root.red = true;
save.red = false;
return save;
}
function double_rotate(root, dir) {
root.set_child(!dir, single_rotate(root.get_child(!dir), !dir));
return single_rotate(root, dir);
}
module.exports = RBTree;
};
return {
RBTree: require('__main__')
};
});
})();

View file

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 2.8.12)
configure_file(Liberation.js Liberation.js)

View file

@ -0,0 +1,94 @@
(function() {
var moduleName = "lib/fonts/Liberation";
define(moduleName, [], function() {
return {
"ascent": 1854,
"descent": -434,
"lineGap": 67,
"unitsPerEm": 2048,
"advanceWidthArray": [
1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536,
1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536,
569, 569, 727, 1139, 1139, 1821, 1366, 391, 682, 682, 797, 1196, 569, 682, 569, 569,
1139, 1139, 1139, 1139, 1139, 1139, 1139, 1139, 1139, 1139, 569, 569, 1196, 1196, 1196, 1139,
2079, 1366, 1366, 1479, 1479, 1366, 1251, 1593, 1479, 569, 1024, 1366, 1139, 1706, 1479, 1593,
1366, 1593, 1479, 1366, 1251, 1479, 1366, 1933, 1366, 1366, 1251, 569, 569, 569, 961, 1139,
682, 1139, 1139, 1024, 1139, 1139, 569, 1139, 1139, 455, 455, 1024, 455, 1706, 1139, 1139,
1139, 1139, 682, 1024, 569, 1139, 1024, 1479, 1024, 1024, 1024, 684, 532, 684, 1196, 1536,
1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536,
1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536, 1536,
569, 682, 1139, 1139, 1139, 1139, 532, 1139, 682, 1509, 758, 1139, 1196, 682, 1509, 1131,
819, 1124, 682, 682, 682, 1180, 1100, 682, 682, 682, 748, 1139, 1708, 1708, 1708, 1251,
1366, 1366, 1366, 1366, 1366, 1366, 2048, 1479, 1366, 1366, 1366, 1366, 569, 569, 569, 569,
1479, 1479, 1593, 1593, 1593, 1593, 1593, 1196, 1593, 1479, 1479, 1479, 1479, 1366, 1366, 1251,
1139, 1139, 1139, 1139, 1139, 1139, 1821, 1024, 1139, 1139, 1139, 1139, 569, 569, 569, 569,
1139, 1139, 1139, 1139, 1139, 1139, 1139, 1124, 1251, 1139, 1139, 1139, 1139, 1024, 1139, 1024,
1366, 1139, 1366, 1139, 1366, 1139, 1479, 1024, 1479, 1024, 1479, 1024, 1479, 1024, 1479, 1259,
1479, 1139, 1366, 1139, 1366, 1139, 1366, 1139, 1366, 1139, 1366, 1139, 1593, 1139, 1593, 1139,
1593, 1139, 1593, 1139, 1479, 1139, 1479, 1139, 569, 569, 569, 569, 569, 569, 569, 455,
569, 569, 1505, 909, 1024, 455, 1366, 1024, 1024, 1139, 455, 1139, 455, 1139, 597, 1139,
684, 1139, 455, 1479, 1139, 1479, 1139, 1479, 1139, 1237, 1481, 1139, 1593, 1139, 1593, 1139,
1593, 1139, 2048, 1933, 1479, 682, 1479, 682, 1479, 682, 1366, 1024, 1366, 1024, 1366, 1024,
1366, 1024, 1251, 569, 1251, 768, 1251, 569, 1479, 1139, 1479, 1139, 1479, 1139, 1479, 1139,
1479, 1139, 1479, 1139, 1933, 1479, 1366, 1024, 1366, 1251, 1024, 1251, 1024, 1251, 1024, 455,
1139, 1553, 1344, 1139, 1344, 1139, 1479, 1479, 1024, 1479, 1658, 1344, 1139, 1140, 1366, 1541,
1237, 1251, 1139, 1593, 1278, 1804, 455, 569, 1366, 1024, 455, 1024, 1824, 1479, 1139, 1593,
1756, 1343, 1778, 1367, 1545, 1139, 1366, 1366, 1024, 1266, 779, 569, 1251, 569, 1251, 1749,
1371, 1531, 1479, 1582, 1024, 1251, 1024, 1251, 1251, 1116, 1116, 1139, 1139, 939, 997, 1139,
532, 846, 1196, 569, 2730, 2503, 2148, 2175, 1706, 924, 2503, 1934, 1579, 1366, 1139, 569,
455, 1593, 1139, 1479, 1139, 1479, 1139, 1479, 1139, 1479, 1139, 1479, 1139, 1139, 1366, 1139,
1366, 1139, 2048, 1821, 1593, 1139, 1593, 1139, 1366, 1024, 1593, 1139, 1593, 1139, 1251, 1116,
455, 2730, 2503, 2148, 1593, 1139, 2118, 1266, 1479, 1139, 1366, 1139, 2048, 1821, 1593, 1251,
1366, 1139, 1366, 1139, 1366, 1139, 1366, 1139, 569, 569, 569, 569, 1593, 1139, 1593, 1139,
1479, 682, 1479, 682, 1479, 1139, 1479, 1139, 1366, 1024, 1251, 569, 1116, 894, 1479, 1139,
1446, 1396, 1238, 1158, 1251, 1024, 1366, 1139, 1366, 1139, 1593, 1139, 1593, 1139, 1593, 1139,
1593, 1139, 1366, 1024, 715, 1402, 752, 455, 1816, 1816, 1366, 1479, 1024, 1139, 1251, 1024,
1024, 1189, 928, 1366, 1479, 1368, 1366, 1139, 1024, 455, 1510, 1139, 1479, 682, 1366, 1024,
1139, 1139, 1139, 1139, 1024, 1024, 1139, 1139, 1139, 1139, 1513, 939, 939, 1293, 1039, 569,
1139, 1139, 1144, 1026, 1263, 1139, 1139, 1139, 455, 455, 729, 670, 622, 455, 1171, 1706,
1706, 1706, 1139, 1139, 1132, 1139, 1619, 1599, 1126, 682, 682, 682, 682, 682, 682, 682,
1109, 1109, 1024, 455, 532, 455, 715, 569, 569, 1139, 1164, 1120, 1024, 1479, 1024, 1064,
1024, 1108, 1116, 1116, 1024, 1024, 1024, 1024, 1593, 1088, 1039, 1144, 1131, 814, 1024, 827,
1139, 1024, 1024, 1975, 1856, 2059, 1459, 879, 1472, 1564, 1354, 1295, 994, 1080, 1407, 1407,
785, 785, 326, 491, 491, 491, 746, 985, 657, 391, 727, 455, 455, 455, 682, 682,
714, 714, 1196, 1196, 1196, 1196, 682, 682, 682, 682, 682, 682, 682, 682, 682, 682,
569, 569, 682, 682, 682, 682, 682, 682, 682, 682, 682, 682, 682, 682, 682, 682,
660, 322, 696, 672, 714, 784, 784, 784, 784, 784, 682, 682, 682, 682, 682, 682,
682, 682, 682, 682, 682, 682, 682, 682, 569, 682, 682, 682, 682, 814, 814, 682,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1536, 1536, 1536, 1536, 682, 682, 1536, 1536, 1536, 1536, 682, 1024, 1024, 1024, 569, 1536,
1536, 1536, 1536, 1536, 682, 682, 1367, 569, 1606, 1716, 786, 1536, 1586, 1536, 1752, 1541,
455, 1366, 1366, 1128, 1368, 1366, 1251, 1479, 1593, 569, 1366, 1368, 1706, 1479, 1331, 1593,
1479, 1366, 1536, 1266, 1251, 1366, 1634, 1366, 1711, 1531, 569, 1366, 1184, 913, 1139, 455,
1120, 1184, 1178, 1024, 1140, 913, 903, 1139, 1139, 455, 1024, 1024, 1180, 1024, 917, 1139,
1413, 1165, 987, 1264, 809, 1120, 1328, 1075, 1460, 1599, 455, 1120, 1139, 1120, 1599, 1536,
1178, 1120, 1582, 1962, 1582, 1147, 1599, 1231, 1593, 1139, 1479, 1024, 1251, 827, 1279, 1084,
1549, 1181, 1824, 1706, 1381, 1139, 1380, 1024, 1366, 1366, 1248, 1221, 1509, 1134, 950, 839,
1231, 1173, 1024, 455, 1593, 905, 905, 1366, 1139, 1479, 1706, 1408, 1165, 1479, 1479, 1479,
1366, 1367, 1771, 1109, 1472, 1366, 569, 569, 1024, 2165, 2069, 1749, 1193, 1472, 1301, 1472,
1366, 1344, 1366, 1109, 1387, 1366, 1891, 1237, 1472, 1472, 1193, 1344, 1706, 1479, 1593, 1472,
1366, 1479, 1251, 1301, 1557, 1366, 1515, 1365, 1877, 1920, 1621, 1813, 1344, 1472, 2069, 1479,
1139, 1173, 1088, 747, 1195, 1139, 1370, 939, 1144, 1144, 896, 1195, 1408, 1131, 1139, 1109,
1139, 1024, 938, 1024, 1685, 1024, 1173, 1067, 1643, 1685, 1280, 1472, 1067, 1045, 1536, 1109,
1139, 1139, 1139, 747, 1045, 1024, 455, 569, 455, 1856, 1664, 1139, 896, 1144, 1024, 1131,
2740, 1278, 1593, 1255, 1945, 1461, 1368, 1024, 1838, 1424, 1697, 1403, 2157, 1776, 1237, 939,
1631, 1410, 1593, 1139, 1645, 1292, 1645, 1292, 2200, 1836, 1706, 1254, 2439, 1744, 2740, 1278,
1479, 1024, 1031, 0, 0, 0, 0, 0, 0, 0, 1472, 1144, 1344, 1067, 1366, 1139,
1001, 842, 1109, 747, 1373, 1124, 1891, 1370, 1237, 939, 1193, 896, 1193, 896, 1193, 896,
1519, 1097, 1479, 1131, 1801, 1327, 2328, 1782, 1542, 1067, 1479, 1024, 1251, 938, 1139, 1024,
1139, 1024, 1366, 1024, 1895, 1415, 1365, 1067, 1365, 1067, 1365, 1139, 1764, 1364, 1764, 1364,
569, 1891, 1370, 1367, 1128, 1344, 1195, 1479, 1131, 1479, 1131, 1365, 1067, 1706, 1408, 455,
1366, 1139, 1366, 1139, 2048, 1821, 1366, 1139, 1541, 1139, 1541, 1139, 1891, 1370, 1237, 939,
1237, 1116, 1472, 1144, 1472, 1144, 1593, 1139, 1593, 1139, 1593, 1139, 1472, 1045, 1301, 1024,
1301, 1024, 1301, 1024, 1365, 1067, 1109, 747, 1813, 1472, 1109, 747, 1366, 1024, 1366, 1024
]
}
});
})();

View file

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 2.8.12)
configure_file(require.js require.js)

View file

@ -0,0 +1,37 @@
/*
RequireJS 2.1.22 Copyright (c) 2010-2015, The Dojo Foundation All Rights Reserved.
Available via the MIT or new BSD license.
see: http://github.com/jrburke/requirejs for details
*/
var requirejs,require,define;
(function(ha){function L(b){return"[object Function]"===R.call(b)}function M(b){return"[object Array]"===R.call(b)}function x(b,c){if(b){var d;for(d=0;d<b.length&&(!b[d]||!c(b[d],d,b));d+=1);}}function Y(b,c){if(b){var d;for(d=b.length-1;-1<d&&(!b[d]||!c(b[d],d,b));--d);}}function w(b,c){return la.call(b,c)}function g(b,c){return w(b,c)&&b[c]}function E(b,c){for(var d in b)if(w(b,d)&&c(b[d],d))break}function Z(b,c,d,k){c&&E(c,function(c,g){if(d||!w(b,g))!k||"object"!==typeof c||!c||M(c)||L(c)||c instanceof
RegExp?b[g]=c:(b[g]||(b[g]={}),Z(b[g],c,d,k))});return b}function y(b,c){return function(){return c.apply(b,arguments)}}function ia(b){throw b;}function ja(b){if(!b)return b;var c=ha;x(b.split("."),function(b){c=c[b]});return c}function G(b,c,d,g){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.requireModules=g;d&&(c.originalError=d);return c}function ma(b){function c(a,n,b){var f,l,c,d,h,k,e,A;n=n&&n.split("/");var q=m.map,p=q&&q["*"];if(a){a=a.split("/");l=a.length-1;m.nodeIdCompat&&
V.test(a[l])&&(a[l]=a[l].replace(V,""));"."===a[0].charAt(0)&&n&&(l=n.slice(0,n.length-1),a=l.concat(a));l=a;for(c=0;c<l.length;c++)d=l[c],"."===d?(l.splice(c,1),--c):".."===d&&0!==c&&(1!==c||".."!==l[2])&&".."!==l[c-1]&&0<c&&(l.splice(c-1,2),c-=2);a=a.join("/")}if(b&&q&&(n||p)){l=a.split("/");c=l.length;a:for(;0<c;--c){h=l.slice(0,c).join("/");if(n)for(d=n.length;0<d;--d)if(b=g(q,n.slice(0,d).join("/")))if(b=g(b,h)){f=b;k=c;break a}!e&&p&&g(p,h)&&(e=g(p,h),A=c)}!f&&e&&(f=e,k=A);f&&(l.splice(0,k,
f),a=l.join("/"))}return(f=g(m.pkgs,a))?f:a}function d(a){F&&x(document.getElementsByTagName("script"),function(n){if(n.getAttribute("data-requiremodule")===a&&n.getAttribute("data-requirecontext")===h.contextName)return n.parentNode.removeChild(n),!0})}function p(a){var n=g(m.paths,a);if(n&&M(n)&&1<n.length)return n.shift(),h.require.undef(a),h.makeRequire(null,{skipMap:!0})([a]),!0}function e(a){var n,b=a?a.indexOf("!"):-1;-1<b&&(n=a.substring(0,b),a=a.substring(b+1,a.length));return[n,a]}function q(a,
n,b,f){var l,d,z=null,k=n?n.name:null,m=a,q=!0,A="";a||(q=!1,a="_@r"+(R+=1));a=e(a);z=a[0];a=a[1];z&&(z=c(z,k,f),d=g(r,z));a&&(z?A=d&&d.normalize?d.normalize(a,function(a){return c(a,k,f)}):-1===a.indexOf("!")?c(a,k,f):a:(A=c(a,k,f),a=e(A),z=a[0],A=a[1],b=!0,l=h.nameToUrl(A)));b=!z||d||b?"":"_unnormalized"+(U+=1);return{prefix:z,name:A,parentMap:n,unnormalized:!!b,url:l,originalName:m,isDefine:q,id:(z?z+"!"+A:A)+b}}function u(a){var b=a.id,c=g(t,b);c||(c=t[b]=new h.Module(a));return c}function v(a,
b,c){var f=a.id,l=g(t,f);if(!w(r,f)||l&&!l.defineEmitComplete)if(l=u(a),l.error&&"error"===b)c(l.error);else l.on(b,c);else"defined"===b&&c(r[f])}function B(a,b){var c=a.requireModules,f=!1;if(b)b(a);else if(x(c,function(b){if(b=g(t,b))b.error=a,b.events.error&&(f=!0,b.emit("error",a))}),!f)k.onError(a)}function C(){W.length&&(x(W,function(a){var b=a[0];"string"===typeof b&&(h.defQueueMap[b]=!0);H.push(a)}),W=[])}function D(a){delete t[a];delete aa[a]}function K(a,b,c){var f=a.map.id;a.error?a.emit("error",
a.error):(b[f]=!0,x(a.depMaps,function(f,d){var h=f.id,k=g(t,h);!k||a.depMatched[d]||c[h]||(g(b,h)?(a.defineDep(d,r[h]),a.check()):K(k,b,c))}),c[f]=!0)}function I(){var a,b,c=(a=1E3*m.waitSeconds)&&h.startTime+a<(new Date).getTime(),f=[],l=[],k=!1,g=!0;if(!ba){ba=!0;E(aa,function(a){var h=a.map,e=h.id;if(a.enabled&&(h.isDefine||l.push(a),!a.error))if(!a.inited&&c)p(e)?k=b=!0:(f.push(e),d(e));else if(!a.inited&&a.fetched&&h.isDefine&&(k=!0,!h.prefix))return g=!1});if(c&&f.length)return a=G("timeout",
"Load timeout for modules: "+f,null,f),a.contextName=h.contextName,B(a);g&&x(l,function(a){K(a,{},{})});c&&!b||!k||!F&&!ka||ca||(ca=setTimeout(function(){ca=0;I()},50));ba=!1}}function J(a){w(r,a[0])||u(q(a[0],null,!0)).init(a[1],a[2])}function P(a){a=a.currentTarget||a.srcElement;var b=h.onScriptLoad;a.detachEvent&&!da?a.detachEvent("onreadystatechange",b):a.removeEventListener("load",b,!1);b=h.onScriptError;a.detachEvent&&!da||a.removeEventListener("error",b,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}
function Q(){var a;for(C();H.length;){a=H.shift();if(null===a[0])return B(G("mismatch","Mismatched anonymous define() module: "+a[a.length-1]));J(a)}h.defQueueMap={}}var ba,ea,h,S,ca,m={waitSeconds:7,baseUrl:"./",paths:{},bundles:{},pkgs:{},shim:{},config:{}},t={},aa={},fa={},H=[],r={},X={},ga={},R=1,U=1;S={require:function(a){return a.require?a.require:a.require=h.makeRequire(a.map)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports?r[a.map.id]=a.exports:a.exports=r[a.map.id]=
{}},module:function(a){return a.module?a.module:a.module={id:a.map.id,uri:a.map.url,config:function(){return g(m.config,a.map.id)||{}},exports:a.exports||(a.exports={})}}};ea=function(a){this.events=g(fa,a.id)||{};this.map=a;this.shim=g(m.shim,a.id);this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};ea.prototype={init:function(a,b,c,f){f=f||{};if(!this.inited){this.factory=b;if(c)this.on("error",c);else this.events.error&&(c=y(this,function(a){this.emit("error",
a)}));this.depMaps=a&&a.slice(0);this.errback=c;this.inited=!0;this.ignore=f.ignore;f.enabled||this.enabled?this.enable():this.check()}},defineDep:function(a,b){this.depMatched[a]||(this.depMatched[a]=!0,--this.depCount,this.depExports[a]=b)},fetch:function(){if(!this.fetched){this.fetched=!0;h.startTime=(new Date).getTime();var a=this.map;if(this.shim)h.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],y(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?
this.callPlugin():this.load()}},load:function(){var a=this.map.url;X[a]||(X[a]=!0,h.load(this.map.id,a))},check:function(){if(this.enabled&&!this.enabling){var a,b,c=this.map.id;b=this.depExports;var f=this.exports,l=this.factory;if(!this.inited)w(h.defQueueMap,c)||this.fetch();else if(this.error)this.emit("error",this.error);else if(!this.defining){this.defining=!0;if(1>this.depCount&&!this.defined){if(L(l)){try{f=h.execCb(c,l,b,f)}catch(d){a=d}this.map.isDefine&&void 0===f&&((b=this.module)?f=b.exports:
this.usingExports&&(f=this.exports));if(a){if(this.events.error&&this.map.isDefine||k.onError!==ia)return a.requireMap=this.map,a.requireModules=this.map.isDefine?[this.map.id]:null,a.requireType=this.map.isDefine?"define":"require",B(this.error=a);if("undefined"!==typeof console&&console.error)console.error(a);else k.onError(a)}}else f=l;this.exports=f;if(this.map.isDefine&&!this.ignore&&(r[c]=f,k.onResourceLoad)){var e=[];x(this.depMaps,function(a){e.push(a.normalizedMap||a)});k.onResourceLoad(h,
this.map,e)}D(c);this.defined=!0}this.defining=!1;this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}},callPlugin:function(){var a=this.map,b=a.id,d=q(a.prefix);this.depMaps.push(d);v(d,"defined",y(this,function(f){var l,d,e=g(ga,this.map.id),N=this.map.name,p=this.map.parentMap?this.map.parentMap.name:null,r=h.makeRequire(a.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){if(f.normalize&&(N=f.normalize(N,function(a){return c(a,
p,!0)})||""),d=q(a.prefix+"!"+N,this.map.parentMap),v(d,"defined",y(this,function(a){this.map.normalizedMap=d;this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),f=g(t,d.id)){this.depMaps.push(d);if(this.events.error)f.on("error",y(this,function(a){this.emit("error",a)}));f.enable()}}else e?(this.map.url=h.nameToUrl(e),this.load()):(l=y(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),l.error=y(this,function(a){this.inited=!0;this.error=a;a.requireModules=[b];
E(t,function(a){0===a.map.id.indexOf(b+"_unnormalized")&&D(a.map.id)});B(a)}),l.fromText=y(this,function(f,c){var d=a.name,e=q(d),N=T;c&&(f=c);N&&(T=!1);u(e);w(m.config,b)&&(m.config[d]=m.config[b]);try{k.exec(f)}catch(g){return B(G("fromtexteval","fromText eval for "+b+" failed: "+g,g,[b]))}N&&(T=!0);this.depMaps.push(e);h.completeLoad(d);r([d],l)}),f.load(a.name,r,l,m))}));h.enable(d,this);this.pluginMaps[d.id]=d},enable:function(){aa[this.map.id]=this;this.enabling=this.enabled=!0;x(this.depMaps,
y(this,function(a,b){var c,f;if("string"===typeof a){a=q(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=g(S,a.id)){this.depExports[b]=c(this);return}this.depCount+=1;v(a,"defined",y(this,function(a){this.undefed||(this.defineDep(b,a),this.check())}));this.errback?v(a,"error",y(this,this.errback)):this.events.error&&v(a,"error",y(this,function(a){this.emit("error",a)}))}c=a.id;f=t[c];w(S,c)||!f||f.enabled||h.enable(a,this)}));E(this.pluginMaps,y(this,function(a){var b=
g(t,a.id);b&&!b.enabled&&h.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){x(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}};h={config:m,contextName:b,registry:t,defined:r,urlFetched:X,defQueue:H,defQueueMap:{},Module:ea,makeModuleMap:q,nextTick:k.nextTick,onError:B,configure:function(a){a.baseUrl&&"/"!==a.baseUrl.charAt(a.baseUrl.length-1)&&(a.baseUrl+="/");var b=m.shim,c={paths:!0,
bundles:!0,config:!0,map:!0};E(a,function(a,b){c[b]?(m[b]||(m[b]={}),Z(m[b],a,!0,!0)):m[b]=a});a.bundles&&E(a.bundles,function(a,b){x(a,function(a){a!==b&&(ga[a]=b)})});a.shim&&(E(a.shim,function(a,c){M(a)&&(a={deps:a});!a.exports&&!a.init||a.exportsFn||(a.exportsFn=h.makeShimExports(a));b[c]=a}),m.shim=b);a.packages&&x(a.packages,function(a){var b;a="string"===typeof a?{name:a}:a;b=a.name;a.location&&(m.paths[b]=a.location);m.pkgs[b]=a.name+"/"+(a.main||"main").replace(na,"").replace(V,"")});E(t,
function(a,b){a.inited||a.map.unnormalized||(a.map=q(b,null,!0))});(a.deps||a.callback)&&h.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b;a.init&&(b=a.init.apply(ha,arguments));return b||a.exports&&ja(a.exports)}},makeRequire:function(a,n){function e(c,d,g){var m,p;n.enableBuildCallback&&d&&L(d)&&(d.__requireJsBuild=!0);if("string"===typeof c){if(L(d))return B(G("requireargs","Invalid require call"),g);if(a&&w(S,c))return S[c](t[a.id]);if(k.get)return k.get(h,
c,a,e);m=q(c,a,!1,!0);m=m.id;return w(r,m)?r[m]:B(G("notloaded",'Module name "'+m+'" has not been loaded yet for context: '+b+(a?"":". Use require([])")))}Q();h.nextTick(function(){Q();p=u(q(null,a));p.skipMap=n.skipMap;p.init(c,d,g,{enabled:!0});I()});return e}n=n||{};Z(e,{isBrowser:F,toUrl:function(b){var d,e=b.lastIndexOf("."),n=b.split("/")[0];-1!==e&&("."!==n&&".."!==n||1<e)&&(d=b.substring(e,b.length),b=b.substring(0,e));return h.nameToUrl(c(b,a&&a.id,!0),d,!0)},defined:function(b){return w(r,
q(b,a,!1,!0).id)},specified:function(b){b=q(b,a,!1,!0).id;return w(r,b)||w(t,b)}});a||(e.undef=function(b){C();var c=q(b,a,!0),e=g(t,b);e.undefed=!0;d(b);delete r[b];delete X[c.url];delete fa[b];Y(H,function(a,c){a[0]===b&&H.splice(c,1)});delete h.defQueueMap[b];e&&(e.events.defined&&(fa[b]=e.events),D(b))});return e},enable:function(a){g(t,a.id)&&u(a).enable()},completeLoad:function(a){var b,c,d=g(m.shim,a)||{},e=d.exports;for(C();H.length;){c=H.shift();if(null===c[0]){c[0]=a;if(b)break;b=!0}else c[0]===
a&&(b=!0);J(c)}h.defQueueMap={};c=g(t,a);if(!b&&!w(r,a)&&c&&!c.inited)if(!m.enforceDefine||e&&ja(e))J([a,d.deps||[],d.exportsFn]);else return p(a)?void 0:B(G("nodefine","No define call for "+a,null,[a]));I()},nameToUrl:function(a,b,c){var d,e,p;(d=g(m.pkgs,a))&&(a=d);if(d=g(ga,a))return h.nameToUrl(d,b,c);if(k.jsExtRegExp.test(a))d=a+(b||"");else{d=m.paths;a=a.split("/");for(e=a.length;0<e;--e)if(p=a.slice(0,e).join("/"),p=g(d,p)){M(p)&&(p=p[0]);a.splice(0,e,p);break}d=a.join("/");d+=b||(/^data\:|\?/.test(d)||
c?"":".js");d=("/"===d.charAt(0)||d.match(/^[\w\+\.\-]+:/)?"":m.baseUrl)+d}return m.urlArgs?d+((-1===d.indexOf("?")?"?":"&")+m.urlArgs):d},load:function(a,b){k.load(h,a,b)},execCb:function(a,b,c,d){return b.apply(d,c)},onScriptLoad:function(a){if("load"===a.type||oa.test((a.currentTarget||a.srcElement).readyState))O=null,a=P(a),h.completeLoad(a.id)},onScriptError:function(a){var b=P(a);if(!p(b.id)){var c=[];E(t,function(a,d){0!==d.indexOf("_@r")&&x(a.depMaps,function(a){a.id===b.id&&c.push(d);return!0})});
return B(G("scripterror",'Script error for "'+b.id+(c.length?'", needed by: '+c.join(", "):'"'),a,[b.id]))}}};h.require=h.makeRequire();return h}function pa(){if(O&&"interactive"===O.readyState)return O;Y(document.getElementsByTagName("script"),function(b){if("interactive"===b.readyState)return O=b});return O}var k,C,D,I,P,J,O,Q,u,U,qa=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,ra=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,V=/\.js$/,na=/^\.\//;C=Object.prototype;var R=C.toString,la=C.hasOwnProperty,
F=!("undefined"===typeof window||"undefined"===typeof navigator||!window.document),ka=!F&&"undefined"!==typeof importScripts,oa=F&&"PLAYSTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/,da="undefined"!==typeof opera&&"[object Opera]"===opera.toString(),K={},v={},W=[],T=!1;if("undefined"===typeof define){if("undefined"!==typeof requirejs){if(L(requirejs))return;v=requirejs;requirejs=void 0}"undefined"===typeof require||L(require)||(v=require,require=void 0);k=requirejs=function(b,
c,d,p){var e,q="_";M(b)||"string"===typeof b||(e=b,M(c)?(b=c,c=d,d=p):b=[]);e&&e.context&&(q=e.context);(p=g(K,q))||(p=K[q]=k.s.newContext(q));e&&p.configure(e);return p.require(b,c,d)};k.config=function(b){return k(b)};k.nextTick="undefined"!==typeof setTimeout?function(b){setTimeout(b,4)}:function(b){b()};require||(require=k);k.version="2.1.22";k.jsExtRegExp=/^\/|:|\?|\.js$/;k.isBrowser=F;C=k.s={contexts:K,newContext:ma};k({});x(["toUrl","undef","defined","specified"],function(b){k[b]=function(){var c=
K._;return c.require[b].apply(c,arguments)}});F&&(D=C.head=document.getElementsByTagName("head")[0],I=document.getElementsByTagName("base")[0])&&(D=C.head=I.parentNode);k.onError=ia;k.createNode=function(b,c,d){c=b.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script");c.type=b.scriptType||"text/javascript";c.charset="utf-8";c.async=!0;return c};k.load=function(b,c,d){var g=b&&b.config||{},e;if(F){e=k.createNode(g,c,d);if(g.onNodeCreated)g.onNodeCreated(e,
g,c,d);e.setAttribute("data-requirecontext",b.contextName);e.setAttribute("data-requiremodule",c);!e.attachEvent||e.attachEvent.toString&&0>e.attachEvent.toString().indexOf("[native code")||da?(e.addEventListener("load",b.onScriptLoad,!1),e.addEventListener("error",b.onScriptError,!1)):(T=!0,e.attachEvent("onreadystatechange",b.onScriptLoad));e.src=d;Q=e;I?D.insertBefore(e,I):D.appendChild(e);Q=null;return e}if(ka)try{importScripts(d),b.completeLoad(c)}catch(q){b.onError(G("importscripts","importScripts failed for "+
c+" at "+d,q,[c]))}};F&&!v.skipDataMain&&Y(document.getElementsByTagName("script"),function(b){D||(D=b.parentNode);if(P=b.getAttribute("data-main"))return u=P,v.baseUrl||(J=u.split("/"),u=J.pop(),U=J.length?J.join("/")+"/":"./",v.baseUrl=U),u=u.replace(V,""),k.jsExtRegExp.test(u)&&(u=P),v.deps=v.deps?v.deps.concat(u):[u],!0});define=function(b,c,d){var g,e;"string"!==typeof b&&(d=c,c=b,b=null);M(c)||(d=c,c=null);!c&&L(d)&&(c=[],d.length&&(d.toString().replace(qa,"").replace(ra,function(b,d){c.push(d)}),
c=(1===d.length?["require"]:["require","exports","module"]).concat(c)));T&&(g=Q||pa())&&(b||(b=g.getAttribute("data-requiremodule")),e=K[g.getAttribute("data-requirecontext")]);e?(e.defQueue.push([b,c,d]),e.defQueueMap[b]=!0):W.push([b,c,d])};define.amd={jQuery:!0};k.exec=function(b){return eval(b)};k(v)}})(this);

View file

@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 2.8.12)
add_jslib(utils/class.js lib/utils/class ${LORGAR_DIR} browser)
add_jslib(utils/subscribable.js lib/utils/subscribable ${LORGAR_DIR} browser)
add_jslib(utils/globalMethods.js lib/utils/globalMethods ${LORGAR_DIR} browser)

View file

@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 2.8.12)
add_jslib(wContainer/abstractmap.js lib/wContainer/abstractmap ${LORGAR_DIR} browser)
add_jslib(wContainer/abstractlist.js lib/wContainer/abstractlist ${LORGAR_DIR} browser)
add_jslib(wContainer/abstractorder.js lib/wContainer/abstractorder ${LORGAR_DIR} browser)
add_jslib(wContainer/abstractpair.js lib/wContainer/abstractpair ${LORGAR_DIR} browser)

View file

@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 2.8.12)
add_jslib(wController/controller.js lib/wController/controller ${LORGAR_DIR} browser)
add_jslib(wController/globalControls.js lib/wController/globalControls ${LORGAR_DIR} browser)
add_jslib(wController/link.js lib/wController/link ${LORGAR_DIR} browser)
add_jslib(wController/list.js lib/wController/list ${LORGAR_DIR} browser)
add_jslib(wController/navigationPanel.js lib/wController/navigationPanel ${LORGAR_DIR} browser)
add_jslib(wController/page.js lib/wController/page ${LORGAR_DIR} browser)
add_jslib(wController/pageStorage.js lib/wController/pageStorage ${LORGAR_DIR} browser)
add_jslib(wController/panesList.js lib/wController/panesList ${LORGAR_DIR} browser)
add_jslib(wController/string.js lib/wController/string ${LORGAR_DIR} browser)
add_jslib(wController/theme.js lib/wController/theme ${LORGAR_DIR} browser)
add_jslib(wController/themeSelecter.js lib/wController/themeSelecter ${LORGAR_DIR} browser)
add_jslib(wController/vocabulary.js lib/wController/vocabulary ${LORGAR_DIR} browser)
add_jslib(wController/attributes.js lib/wController/attributes ${LORGAR_DIR} browser)
add_jslib(wController/localModel.js lib/wController/localModel ${LORGAR_DIR} browser)
add_jslib(wController/imagePane.js lib/wController/imagePane ${LORGAR_DIR} browser)
add_jslib(wController/file/file.js lib/wController/file/file ${LORGAR_DIR} browser)
add_jslib(wController/image.js lib/wController/image ${LORGAR_DIR} browser)

View file

@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 2.8.12)
add_jslib(wDispatcher/dispatcher.js lib/wDispatcher/dispatcher ${LORGAR_DIR} browser)
add_jslib(wDispatcher/defaulthandler.js lib/wDispatcher/defaulthandler ${LORGAR_DIR} browser)
add_jslib(wDispatcher/handler.js lib/wDispatcher/handler ${LORGAR_DIR} browser)
add_jslib(wDispatcher/logger.js lib/wDispatcher/logger ${LORGAR_DIR} browser)

View file

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 2.8.12)
configure_file(socket.js socket.js)

View file

@ -0,0 +1,203 @@
"use strict";
(function socket_js() {
var moduleName = "lib/wSocket/socket"
var defineArray = [];
defineArray.push("lib/utils/subscribable");
defineArray.push("lib/wType/event");
defineArray.push("lib/wType/bytearray");
defineArray.push("lib/wType/string");
defineArray.push("lib/wType/vocabulary");
defineArray.push("lib/wType/uint64");
defineArray.push("lib/wType/address");
defineArray.push("lib/wType/factory");
define(moduleName, defineArray, function socket_module() {
var Subscribable = require("lib/utils/subscribable");
var Event = require("lib/wType/event");
var ByteArray = require("lib/wType/bytearray");
var String = require("lib/wType/string");
var Vocabulary = require("lib/wType/vocabulary");
var Uint64 = require("lib/wType/uint64");
var Address = require("lib/wType/address");
var factory = require("lib/wType/factory");
var Socket = Subscribable.inherit({
"className": "Socket",
"constructor": function(name) {
if (!name) {
throw new Error("Can't construct a socket without a name");
}
Subscribable.fn.constructor.call(this);
this._state = DISCONNECTED;
this._dState = SIZE;
this._name = name instanceof String ? name : new String(name);
this._remoteName = new String();
this._id = new Uint64(0);
this._socket = undefined;
this._helperBuffer = new ByteArray(4);
this._initProxy();
},
"destructor": function() {
this.close();
if (this._state === DISCONNECTING) {
this.on("disconnected", function() {
Subscribable.fn.destructor.call(this);
})
} else {
Subscribable.fn.destructor.call(this);
}
},
"close": function() {
if ((this._state !== DISCONNECTED) && (this._state !== DISCONNECTING)) {
this._state = DISCONNECTING;
this._socket.close();
}
},
"_emitEvent": function(ev) {
this.trigger("message", ev);
ev.destructor();
},
"getId": function() {
return this._id;
},
"isOpened": function() {
return this._state === CONNECTED;
},
"open": function(addr, port) {
if (this._state === DISCONNECTED) {
this._state = CONNECTING;
this._socket = new WebSocket("ws://"+ addr + ":" + port);
this._socket.binaryType = "arraybuffer";
this._socket.onclose = this._proxy.onSocketClose;
this._socket.onerror = this._proxy.onSocketError;
this._socket.onmessage = this._proxy.onSocketMessage
}
},
"send": function(ev) {
var size = ev.size();
var ba = new ByteArray(size + 5);
ba.push32(size);
ba.push8(ev.getType());
ev.serialize(ba);
this._socket.send(ba.data().buffer);
},
"_initProxy": function() {
this._proxy = {
onSocketClose: this._onSocketClose.bind(this),
onSocketError: this._onSocketError.bind(this),
onSocketMessage: this._onSocketMessage.bind(this)
}
},
"_onEvent": function(ev) {
if (ev.isSystem()) {
var cmd = ev._data.at("command").toString();
switch(cmd) {
case "setId":
this._setId(ev._data.at("id"));
this._setRemoteName();
break;
case "setName":
this._setName(ev._data.at("name"));
this._state = CONNECTED;
this.trigger("connected");
break;
default:
throw new Error("Unknown system command: " + cmd);
}
ev.destructor();
} else {
setTimeout(this._emitEvent.bind(this, ev), 5); //TODO event queue
}
},
"_onSocketClose": function(ev) {
this._state = DISCONNECTED;
this._id.destructor();
this._id = new Uint64(0);
this._remoteName.destructor();
this._remoteName = new String();
console.log(ev);
this.trigger("disconnected", ev);
},
"_onSocketError": function(err) {
this.trigger("error", err);
},
"_onSocketMessage": function(mes) {
var raw = new Uint8Array(mes.data);
var i = 0;
while (i < raw.length) {
switch (this._dState) {
case SIZE:
i = this._helperBuffer.fill(raw, raw.length, i);
if (this._helperBuffer.filled()) {
var size = this._helperBuffer.pop32();
this._helperBuffer.destructor();
this._helperBuffer = new ByteArray(size + 1);
this._dState = BODY;
}
break;
case BODY:
i = this._helperBuffer.fill(raw, raw.length, i);
if (this._helperBuffer.filled()) {
var ev = factory(this._helperBuffer);
this._onEvent(ev);
this._helperBuffer.destructor();
this._helperBuffer = new ByteArray(4);
this._dState = SIZE;
}
break;
}
}
},
"_setId": function(id) {
if (this._state === CONNECTING) {
this._id.destructor();
this._id = id.clone();
} else {
throw new Error("An attempt to set id in unexpected time");
}
},
"_setName": function(name) {
if ((this._state === CONNECTING) && (this._id.valueOf() !== 0)) {
this._remoteName.destructor();
this._remoteName = name.clone();
} else {
throw new Error("An attempt to set name in unexpected time");
}
},
"_setRemoteName": function() {
var vc = new Vocabulary();
vc.insert("command", new String("setName"));
vc.insert("name", this._name.clone());
vc.insert("yourName", this._remoteName.clone());
var ev = new Event(new Address(), vc, true);
ev.setSenderId(this._id.clone());
this.send(ev);
ev.destructor();
}
});
return Socket;
});
var DISCONNECTED = 111;
var DISCONNECTING = 110;
var CONNECTING = 101;
var CONNECTED = 100;
var SIZE = 11;
var BODY = 10;
})();

View file

@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 2.8.12)
add_jslib(wTest/test.js lib/wTest/test ${LORGAR_DIR} browser)
add_jslib(wTest/abstractmap.js lib/wTest/abstractmap ${LORGAR_DIR} browser)
add_jslib(wTest/abstractlist.js lib/wTest/abstractlist ${LORGAR_DIR} browser)
add_jslib(wTest/abstractorder.js lib/wTest/abstractorder ${LORGAR_DIR} browser)

View file

@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 2.8.12)
add_jslib(wType/address.js lib/wType/address ${LORGAR_DIR} browser)
add_jslib(wType/boolean.js lib/wType/boolean ${LORGAR_DIR} browser)
add_jslib(wType/bytearray.js lib/wType/bytearray ${LORGAR_DIR} browser)
add_jslib(wType/event.js lib/wType/event ${LORGAR_DIR} browser)
add_jslib(wType/object.js lib/wType/object ${LORGAR_DIR} browser)
add_jslib(wType/string.js lib/wType/string ${LORGAR_DIR} browser)
add_jslib(wType/uint64.js lib/wType/uint64 ${LORGAR_DIR} browser)
add_jslib(wType/vector.js lib/wType/vector ${LORGAR_DIR} browser)
add_jslib(wType/vocabulary.js lib/wType/vocabulary ${LORGAR_DIR} browser)
add_jslib(wType/blob.js lib/wType/blob ${LORGAR_DIR} browser)
add_jslib(wType/factory.js lib/wType/factory ${LORGAR_DIR} browser)