svg.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. if (!String.prototype.encodeHTML) {
  2. String.prototype.encodeHTML = function () {
  3. return this.replace(/&/g, '&')
  4. .replace(/</g, '&lt;')
  5. .replace(/>/g, '&gt;')
  6. .replace(/"/g, '&quot;')
  7. .replace(/'/g, '&apos;');
  8. };
  9. }
  10. var transition = {pid: '', port: '8080' };
  11. // BERT Protocol
  12. var players = ["Gabrielo","Mustafa","Alina","Me"];
  13. function statsRow(start_name,i,games) {
  14. var start_score = 200;
  15. var name = template_engine(
  16. '<tspan xmlns="http://www.w3.org/2000/svg" x="{this.x}" y="{this.y}">{this.body}</tspan>',{
  17. x: start_name,
  18. y: 180+25*i,
  19. body: games[i].value[0][0] + " — " + games[i].value[0][1]});
  20. var element1 = svg(name);
  21. document.getElementById('Stat-Right').appendChild(element1);
  22. }
  23. var user_count = 0;
  24. function handle_web_socket(body) {
  25. // console.log(dec(body).value[0][0].value);
  26. switch (dec(body).value[0][0].value) {
  27. case 'roster_item':
  28. var id = dec(body).value[0][1].value;
  29. var names = dec(body).value[0][2].value;
  30. var surnames = dec(body).value[0][3].value;
  31. addOnlineUser(id,names+" "+surnames+ " "+user_count++,'appendChild');
  32. break;
  33. case 'roster_group':
  34. var list = dec(body).value[0][1];
  35. for (var i=0;i<list.length;i++) {
  36. var item = list[i];
  37. var id = item.value[0][0].value;
  38. var names = item.value[0][1].value;
  39. var surnames = item.value[0][2].value;
  40. addOnlineUser(id,names+" "+surnames+ " "+user_count++,'appendChild');
  41. }
  42. break;
  43. case 'roster_end':
  44. onlineHover();
  45. mouseWheelHandler({'detail':5,'wheelDelta':5});
  46. onlineHoverOut();
  47. break;
  48. case 'online':
  49. var id = dec(body).value[0][1].value;
  50. var name = dec(body).value[0][2].value;
  51. var surname = dec(body).value[0][3].value;
  52. try{removeOnlineUser(id)}catch(e){}
  53. addOnlineUser(id,name+" "+surname,"insertTop");
  54. break;
  55. case 'offline':
  56. var id = dec(body).value[0][1].value;
  57. var name = dec(body).value[0][2].value;
  58. var surname = dec(body).value[0][3].value;
  59. try{removeOnlineUser(id)}catch(e){}
  60. addOnlineUser(id,name+" "+surname,"appendChild");
  61. break;
  62. case 'online_number':
  63. var number = dec(body).value[0][1];
  64. document.getElementById("722").firstElementChild.textContent = number.toString();
  65. break;
  66. case 'stats_event':
  67. document.getElementById('Player-Statistics').style.display = '';
  68. var games = dec(body).value[0][2];
  69. var reveals = dec(body).value[0][3];
  70. var protocol = dec(body).value[0][4];
  71. removeChilds(document.getElementById('Stat-Left'));
  72. removeChilds(document.getElementById('Stat-Right'));
  73. for (var i=0;i<games.length;i++) { statsRow(24, i,games); }
  74. for (var i=0;i<protocol.length;i++) { statsRow(340,i,protocol); }
  75. // for (var i=0;i<reveals.length;i++) { statsRow(340,i,reveals); }
  76. break;
  77. }
  78. switch (dec(body).value[0][2].value) {
  79. case 'okey_game_info':
  80. var a = dec(body).value[0][3][0].value[0][1];
  81. // console.log("Players: " + a.length);
  82. for (var i=0;i<a.length;i++) {
  83. var c = a[i].value[0][3].value;
  84. var v = a[i].value[0][4].value;
  85. setPlayerName(players[i],c + " " + v);
  86. // console.log("Player: " + c + " " + v);
  87. }
  88. break;
  89. case 'okey_game_started':
  90. var a = dec(body).value[0][3][0].value[0][1];
  91. // console.log("Cards: " + a.length);
  92. for (var i=1;i<=a.length;i++) {
  93. var c = a[i-1].value[0][1];
  94. var v = a[i-1].value[0][2];
  95. // console.log("Card: " + c + " " + v);
  96. place_card(i,rand(1,2),c,v);
  97. }
  98. break;
  99. case 'okey_game_player_state': /// these two messages should be combined
  100. var a = dec(body).value[0][3][3].value[0][1];
  101. // console.log("Cards: " + a.length);
  102. for (var i=1;i<=a.length;i++) {
  103. var c = a[i-1].value[0][1];
  104. var v = a[i-1].value[0][2];
  105. // console.log("Card: " + c + " " + v);
  106. place_card(i,1,c,v);
  107. }
  108. break;
  109. case 'okey_tile_discarded':
  110. console.log(String(dec(body)));
  111. var player = dec(body).value[0][3][0].value[0][1];
  112. var tile = dec(body).value[0][3][1].value[0][1];
  113. if (player.value == document.user) {
  114. console.log("Discard: " + player.value);
  115. var p = findCardOnTable(tile.value[0][1],tile.value[0][2]);
  116. empty_card(p.x,p.y);
  117. }
  118. break;
  119. case 'okey_tile_taken':
  120. console.log(String(dec(body)));
  121. var player = dec(body).value[0][3][0].value[0][1];
  122. var taken = dec(body).value[0][3][2].value[0][1];
  123. if (taken.value != 'null' && player.value == document.user) {
  124. console.log("Taken: " + player.value);
  125. var c = taken.value[0][1];
  126. var v = taken.value[0][2];
  127. var pos = findPlace();
  128. // console.log(pos);
  129. place_card(pos.x,pos.y,c,v);
  130. }
  131. break;
  132. default:
  133. console.log(String(dec(body)));
  134. }
  135. }
  136. // SVG DOM and Template Engine
  137. function template_engine(html, data) {
  138. var re = /{([^}]+)?}/g, code = 'var r=[];', cursor = 0;
  139. var add = function(line,js) {
  140. js? (code += 'r.push(' + line + ');') :
  141. (code += line != '' ? 'r.push("' + line.replace(/"/g, '\\"') + '");' : '');
  142. return add; }
  143. while(match = re.exec(html)) {
  144. add(html.slice(cursor, match.index))(match[1],true);
  145. cursor = match.index + match[0].length; }
  146. add(html.substr(cursor, html.length - cursor));
  147. code += 'return r.join("");';
  148. return new Function(code.replace(/[\r\t\n]/g, '')).apply(data); }
  149. function reload(file, name2) { var name = name2==null?file:name2;
  150. var slot = document.getElementById(name);
  151. if (slot == null) return;
  152. slot.parentNode.replaceChild(svg(localStorage.getItem(file)),slot);}
  153. function reload_cont(cont,name,element) { reload(name,element); if (null != cont) (cont)(); }
  154. function loadFile(name,cont,element) {
  155. if (localStorage.getItem(name) == null) {
  156. var client = new XMLHttpRequest();
  157. client.open('GET', name, true);
  158. client.onload = function() {
  159. localStorage.setItem(name,client.responseText);
  160. reload_cont(cont,name,element);
  161. }
  162. client.send(); }
  163. else reload_cont(cont,name,element); }
  164. function svg(html) {
  165. return new DOMParser().parseFromString(html, "text/xml").firstChild;
  166. }
  167. function svgBulk() {
  168. var res = [];
  169. var node = new DOMParser().parseFromString(html, "text/xml").firstChild;
  170. for (var i=0;i<node.childnode.length;i++) { var child = childNodes.item(i);
  171. if (child.tagName != undefined) res.push(child); } }
  172. // The Card
  173. //var color = ['#CE290F','#3B5998','#48AF5E','#FFEC00'];
  174. var color = ['#DE3F26','#606060','#48AF5E','#FFC800'];
  175. var slotName = slotNameDef;
  176. function slotNameDef(x,y) { return "Slot-"+y+","+x; }
  177. function card(line,pos,col,v) {
  178. return template_engine(
  179. localStorage.getItem("templates/Card.svg"),
  180. { name: slotName(pos,line),
  181. suit: color[col-1],
  182. value: v,
  183. y: (line-1)*69,
  184. x: (pos-1)*42 }); }
  185. // Game Scene
  186. function setPlayerName(e, playerName) {
  187. var dx = (document.getElementById(e).attributes['fill'].value == "#FFFFFF") ? 65 : 20;
  188. document.getElementById(e).setAttribute("y",27);
  189. document.getElementById(e).setAttribute("x",dx);
  190. document.getElementById(e).textContent = playerName;
  191. // console.log("Bounding Box: " + document.getElementById(e).getBBox().width);
  192. document.getElementById(e+"-Pad").setAttribute('width',
  193. document.getElementById(e).getBBox().width + 45); }
  194. function place_card(x,y,c,v) {
  195. var slot = document.getElementById(slotName(x,y));
  196. slot.parentNode.replaceChild(svg(card(y,x,c,v)),slot); }
  197. function empty_card(x,y) { var slot = document.getElementById(slotName(x,y));
  198. var html = '<g xmlns="http://www.w3.org/2000/svg" id="'+slotName(x,y)+'"/>';
  199. slot.parentNode.replaceChild(svg(html),slot); }
  200. function rand(lo,hi) { return Math.floor((Math.random()*hi)+lo); }
  201. function loadScene() {
  202. reload("Kakaranet-Scene.svg", "Refined");
  203. //drawSampleCards();
  204. }
  205. function findPlace() {
  206. for (var y=1;y<3;y++) for (var x=1;x<15;x++) {
  207. var e = document.getElementById(slotName(x,y));
  208. if (e.childElementCount == 0) {
  209. var pos = e.attributes['id'].value.split("-")[1].split(",");
  210. console.log("Free");
  211. console.log(pos[0]);
  212. console.log(pos[1]);
  213. return { y: pos[0], x: pos[1] }; } } }
  214. function findCardOnTable(c,v) {
  215. console.log("Find Card " + c + " " + v);
  216. for (var y=1;y<3;y++) for (var x=1;x<15;x++) {
  217. var e = document.getElementById(slotName(x,y));
  218. if (e.childElementCount > 0) {
  219. var value = e.lastChild.textContent;
  220. var col = color.indexOf(e.lastChild.attributes['fill'].value) + 1;
  221. console.log(col + " " + value);
  222. if (c == col && v == value) return { 'x': x, 'y': y }; } }
  223. console.log("Card Not Found");
  224. return ""; }
  225. function loadAppend(file, animation, name) {
  226. loadFile(file, function() {
  227. var slot = document.getElementById(name);
  228. var r = template_engine(localStorage.getItem(file),{'name': animation});
  229. document.getElementById(name).appendChild(svg(r)); }); }
  230. function loadAnimationForButton(a, b) { return loadAppend('templates/ButtonAnimation.svg', a, b); }
  231. // TODO: Rollout Monadic Chain here
  232. loadFile('templates/Card.svg', function() {
  233. loadFile('Kakaranet-Scene.svg', function() {
  234. var a = [{button: "Create", pathes: ["CreateShow", "CreateHide"]},
  235. {button: "Play", pathes: ["PlayShow", "PlayHide"]}];
  236. for (var y=0;y<a.length;y++) for (var x=0;x<a[y].pathes.length;x++)
  237. loadAnimationForButton(a[y].pathes[x],a[y].button);
  238. document.getElementById("Right-Menu") .setAttribute('onclick', 'onRightMenu(evt)');
  239. document.getElementById("Play") .setAttribute('onclick', 'onRightMenuDown(evt)');
  240. document.getElementById("Create") .setAttribute('onclick', 'onRightMenuDown(evt)');
  241. document.getElementById("Point-Table").setAttribute('onclick', 'onPlayerInfo(evt)');
  242. document.getElementById("Player-Statistics").setAttribute('onclick', 'onPlayerInfoClose(evt)');
  243. for (var i=1;i<16;i++) { empty_card(i,2); empty_card(i,1); }
  244. document.getElementById('Page-1').addEventListener("mousewheel", mouseWheelHandler, false);
  245. var clipPath1 = svg('<clipPath id="myClip1"><rect xmlns="http://www.w3.org/2000/svg" id="Clip-Path-Left" x="0" y="0" width="216" height="400"/></clipPath>');
  246. var clipPath2 = svg('<clipPath id="myClip2"><rect xmlns="http://www.w3.org/2000/svg" id="Clip-Path-Right" x="0" y="0" width="216" height="400"/></clipPath>');
  247. document.getElementsByTagName('defs').item(0).appendChild(clipPath1);
  248. document.getElementsByTagName('defs').item(0).appendChild(clipPath2);
  249. document.getElementById("Online-List").setAttribute("clip-path","url(#myClip1)");
  250. document.getElementById("Chat").setAttribute("clip-path","url(#myClip2)");
  251. document.getElementById("Clip-Path-Left").setAttribute("transform", "translate(0,0)");
  252. document.getElementById("Clip-Path-Right").setAttribute("transform", "translate(0,0)");
  253. document.getElementById('Player-Statistics').style.display = 'none';
  254. document.getElementById("Right-Bar").setAttribute("fill","skyblue");
  255. document.getElementById("Right-Bar").onmouseover = barHover;
  256. document.getElementById("Right-Bar").onmouseout = barHoverOut;
  257. document.getElementById("Left-Bar").onmouseover = onlineHover;
  258. document.getElementById("Left-Bar").onmouseout = onlineHoverOut;
  259. document.getElementById('edit').setAttribute("contentEditable","true");
  260. document.getElementById('edit').onkeydown = chatEditor;
  261. onRightMenuDown();
  262. }, "Refined");
  263. });
  264. var removeChilds = function (node) {
  265. var last;
  266. while (last = node.lastChild) node.removeChild(last);
  267. };
  268. function onPlayerInfo(evt) {
  269. ws.send(enc(tuple(atom('client'),
  270. tuple(atom('stats_action'),bin(document.user),atom('game_okey')))));
  271. }
  272. function onPlayerInfoClose(evt) {
  273. document.getElementById('Player-Statistics').style.display = 'none';
  274. }
  275. function onRightMenu(evt) {
  276. localStorage.clear();
  277. ["PlayShow","CreateShow"].map(function (x) {
  278. document.getElementById(x+"-Motion").beginElement(); }); }
  279. function onRightMenuDown(evt) {
  280. ["PlayHide","CreateHide"].map(function (x) {
  281. document.getElementById(x+"-Motion").beginElement(); }); }
  282. function slotName1(x,y) { return "1Slot-"+y+","+x; }
  283. function drawSampleCards() {
  284. slotName = slotName1;
  285. for (var i=1;i<15;i++) { place_card(i,rand(1,2),rand(1,4),rand(1,13)); }
  286. slotName = slotNameDef; }
  287. var scrollSensitivity = 0.2;
  288. var scroll_left = 5;
  289. var scroll_right = -10000;
  290. function chatMessage(id, me, string) {
  291. var i=0;
  292. var colors=['#FDFDFD','#DFF1F4'];
  293. var x1 = 7;
  294. var y1 = 0;
  295. var translate_y = parseFloat(document.getElementById("Chat").getBBox().height);
  296. var x2 = 205;
  297. var textElement = chatText(id,me,string);
  298. var dy = translate_y == 0 ? 0 : translate_y + 10;
  299. var html = "<g xmlns='http://www.w3.org/2000/svg' " +
  300. "id='Message-"+id+"' transform='translate(0,"+dy+")'></g>";
  301. var messageElement = svg(html);
  302. messageElement.appendChild(textElement);
  303. document.getElementById("Chat").appendChild(messageElement);
  304. create_multiline(textElement);
  305. var y2 = textElement.getBBox().height + 5;
  306. var box = "<path xmlns='http://www.w3.org/2000/svg' d='M"+x1+","+y1+
  307. " L"+x2+","+y1+
  308. ((me == "Maxim") ?
  309. (" L"+x2+","+parseFloat(y2-7)+
  310. " L"+parseFloat(x2+7)+","+y2+
  311. " L"+x1+","+y2)
  312. :
  313. (" L"+x2+","+y2+
  314. " L"+0+","+y2+
  315. " L"+x1+","+parseFloat(y2-7)))
  316. + " L"+x1+","+y1+"' fill='"+colors[me=="Maxim"?1:0]+"'></path>";
  317. var boxElement = svg(box);
  318. messageElement.insertBefore(boxElement,textElement);
  319. boxElement.setAttribute("mouseover","barHover(evt);");
  320. boxElement.setAttribute("mouseout","barHoverOut(evt);");
  321. textElement.setAttribute("mouseover","barHover(evt);");
  322. textElement.setAttribute("mouseout","barHoverOut(evt);");
  323. messageElement.setAttribute("onmouseover","barHover(evt);");
  324. messageElement.setAttribute("onmouseout","barHoverOut(evt);");
  325. // console.log(messageElement);
  326. }
  327. function chatText(id, me, string) {
  328. var i = 0;
  329. var colors=['#3B5998'];
  330. var html = "<text id='ChatText-"+id+"' width='180' " +
  331. " xmlns='http://www.w3.org/2000/svg' "+
  332. " font-family='Exo 2' font-size='16' font-weight='normal' fill='"+colors[i]+"'>" +
  333. string + "</text>";
  334. // console.log(html);
  335. return svg(html);
  336. }
  337. function mouseWheelHandler(e) {
  338. var leftBar = document.getElementById("Left-Bar");
  339. var rightBar = document.getElementById("Right-Bar");
  340. var leftFill = leftBar.getAttribute("fill");
  341. var rightFill = rightBar.getAttribute("fill");
  342. var leftActive = leftFill == "skyblue";
  343. var rightActive = rightFill == "skyblue";
  344. if (!leftActive && !rightActive) return;
  345. // console.log(leftActive);
  346. var evt = e;
  347. var scroll_dy = evt.detail ? evt.detail * scrollSensitivity : evt.wheelDelta * scrollSensitivity;
  348. var ori = leftActive ? scroll_left : scroll_right;
  349. var scroll = parseFloat(scroll_dy) + parseFloat(ori);
  350. var selectedBar = leftActive ? "Online-List" : "Chat";
  351. var selectedClip = leftActive ? "Clip-Path-Left" : "Clip-Path-Right";
  352. var selectedBarShift = leftActive ? 0 : 857;
  353. var limit = parseFloat(document.getElementById(selectedBar).getBBox().height) - 400;
  354. if (scroll > 5) scroll = 5;
  355. if (scroll < -limit) scroll = -limit;
  356. document.getElementById(selectedClip).setAttribute("transform", "translate(0,"+parseFloat(-scroll)+")");
  357. document.getElementById(selectedBar).setAttribute("transform", "translate("+selectedBarShift+","+(parseFloat(95+scroll))+")");
  358. if (leftActive) scroll_left = scroll; else scroll_right = scroll;
  359. return true;
  360. }
  361. var svgNS = "http://www.w3.org/2000/svg";
  362. function create_multiline(target) {
  363. var text_element = target; // evt.target;
  364. var width = 190; //target.getAttribute("width");
  365. var words = text_element.firstChild.data.split('');
  366. // console.log(words);
  367. // var words = [].concat.apply([],lines.map(function(line) { return line.split(' '); }));;
  368. var start_x = 15; //text_element.getAttribute('x');
  369. text_element.firstChild.data = '';
  370. var tspan_element = document.createElementNS(svgNS, "tspan");
  371. tspan_element.setAttribute("x", start_x);
  372. tspan_element.setAttribute("dy", 18);
  373. var text_node = document.createTextNode(words[0]);
  374. tspan_element.appendChild(text_node);
  375. text_element.appendChild(tspan_element);
  376. for(var i=1; i<words.length; i++) {
  377. if (words[i]=="") continue;
  378. var len = tspan_element.firstChild.data.length;
  379. tspan_element.firstChild.data += words[i];
  380. if (tspan_element.getComputedTextLength() > width || words[i]=="\n") {
  381. if (words[i]=='\n') words[i]="";
  382. tspan_element.firstChild.data = tspan_element.firstChild.data.slice(0, len);
  383. var tspan_element = document.createElementNS(svgNS, "tspan");
  384. tspan_element.setAttribute("x", start_x);
  385. tspan_element.setAttribute("dy", 18);
  386. text_node = document.createTextNode(words[i]);
  387. tspan_element.appendChild(text_node);
  388. text_element.appendChild(tspan_element);
  389. }
  390. }
  391. }
  392. function barHover(evt) { document.getElementById("Right-Bar").setAttribute("fill","skyblue"); }
  393. function barHoverOut(evt) { document.getElementById("Right-Bar").setAttribute("fill","lightblue"); }
  394. function onlineHover(evt) { document.getElementById("Left-Bar").setAttribute("fill","skyblue"); }
  395. function onlineHoverOut(evt) { document.getElementById("Left-Bar").setAttribute("fill","lightblue"); }
  396. function onlineHoverColor(evt) {
  397. onlineHover(evt);
  398. var name = evt.target.getAttribute("xmlns:data");
  399. if (null != name) document.getElementById(name).setAttribute("fill","#FFF687");
  400. }
  401. function onlineHoverOutColor(evt) {
  402. onlineHoverOut(evt);
  403. var name = evt.target.getAttribute("xmlns:data");
  404. if (null != name) document.getElementById(name).setAttribute("fill","#DBEBED");
  405. }
  406. function chatEditor(evt) {
  407. if (evt.keyCode == 13 && evt.metaKey == false) {
  408. var e = document.getElementById('edit');
  409. if (e.innerText.trim() != ""){
  410. chatMessage("100","Maxim",e.innerText.trim().encodeHTML());
  411. e.innerHTML = '';
  412. }
  413. } else if (evt.keyCode == 13 && evt.metaKey == true) {
  414. document.execCommand('insertText',false, '\n');
  415. }
  416. var scroll = -1000000;
  417. mouseWheelHandler({'detail':scroll,'wheelDelta':scroll});
  418. }
  419. function shiftTranslate(name,shiftValue) {
  420. var rect = document.getElementById(name);
  421. if (null == rect) return;
  422. var remove = rect.parentNode.parentNode;
  423. var children = document.getElementById("Online-List").childNodes;
  424. var removeIndex = -1;
  425. for(var i = 0; i<children.length; ++i) {
  426. var child = children[i];
  427. if (child == remove) removeIndex = i;
  428. if (removeIndex != -1 && i>=removeIndex)
  429. child.setAttribute("transform","translate(0,"+(parseFloat(i)+parseFloat(shiftValue))
  430. *remove.getBBox().height+")");
  431. }
  432. return rect.parentNode.parentNode;
  433. }
  434. function removeOnlineUser(name) {
  435. shiftTranslate(name,-2).remove();
  436. }
  437. function addOnlineUser(name,full_name,insertMode) {
  438. var listElement = document.getElementById("Online-List");
  439. var color = insertMode == "insertTop" ? "red" : "green";
  440. var y = (insertMode == "insertTop") ? "0" : listElement.getBBox().height;
  441. var html = '<g xmlns="http://www.w3.org/2000/svg" height="60" transform="translate(0, '+y+')">' +
  442. '<g xmlns:data="'+name+'"fill="#DBEBED" onmouseover="onlineHoverColor(evt);" onmouseout="onlineHoverOutColor(evt);">' +
  443. ' <rect xmlns:data="'+name+'" fill="#DBEBED" id="'+name+'" x="10" y="0" width="196" height="48" onmouseover="onlineHoverColor(evt);" onmouseout="onlineHoverOutColor(evt);"></rect></g>' +
  444. '<text xmlns:data="'+name+'" onmouseover="onlineHoverColor(evt);" onmouseout="onlineHoverOutColor(evt);" '+
  445. 'font-family="Exo 2" font-size="18" font-weight="normal" line-spacing="18"'+
  446. ' fill="#3B5998">' +
  447. '<tspan xmlns:data="'+name+'" font-weight="normal" fill="'+color+'" x="19" y="22">'+full_name+'</tspan>' +
  448. '<tspan xmlns:data="'+name+'" font-size="14" x="19" y="40">Score: 1043 Pos: 13</tspan></text>'+
  449. '<rect onmouseover="onlineHover(evt);" onmouseout="onlineHoverOut(evt);"'+
  450. ' x="10" y="48" width="196" height="8"></rect></g>';
  451. var element = svg(html);
  452. if (insertMode == "insertTop") {
  453. var firstElement = listElement.firstElementChild;
  454. var first = firstElement.firstElementChild.getAttribute("xmlns:data");
  455. shiftTranslate(first,0);
  456. listElement.insertBefore(element,firstElement);
  457. } else listElement.appendChild(element);
  458. }
  459. chatMessage("1","Maxim2","Joe:\nHello There!".encodeHTML());
  460. chatMessage("2","Maxim2","Alice:\nYou got new Design. Eh?".encodeHTML());
  461. chatMessage("3","Maxim","Maxim So:\nThis was made with pure SVG".encodeHTML());
  462. barHover();
  463. mouseWheelHandler({'detail':-100000,'wheelDelta':-100000});
  464. barHoverOut();