var transition = {pid: '', port: '8080' }; // BERT Protocol var players = ["Gabrielo","Mustafa","Alina","Me"]; function statsRow(start_name,i,games) { var start_score = 200; var name = template_engine( '{this.body}',{ x: start_name, y: 180+25*i, body: games[i].value[0][0] + " — " + games[i].value[0][1]}); var element1 = svg(name); document.getElementById('Stat-Right').appendChild(element1); } function handle_web_socket(body) { // console.log(dec(body).value[0][0].value); switch (dec(body).value[0][0].value) { case 'stats_event': document.getElementById('Player-Statistics').style.display = ''; var games = dec(body).value[0][2]; var reveals = dec(body).value[0][3]; var protocol = dec(body).value[0][4]; removeChilds(document.getElementById('Stat-Left')); removeChilds(document.getElementById('Stat-Right')); for (var i=0;i'; slot.parentNode.replaceChild(svg(html),slot); } function rand(lo,hi) { return Math.floor((Math.random()*hi)+lo); } function loadScene() { reload("Kakaranet-Scene.svg", "Refined"); for (var i=1;i<16;i++) { empty_card(i,2); empty_card(i,1); } //drawSampleCards(); } function findPlace() { for (var y=1;y<3;y++) for (var x=1;x<15;x++) { var e = document.getElementById(slotName(x,y)); if (e.childElementCount == 0) { var pos = e.attributes['id'].value.split("-")[1].split(","); console.log("Free"); console.log(pos[0]); console.log(pos[1]); return { y: pos[0], x: pos[1] }; } } } function findCardOnTable(c,v) { console.log("Find Card " + c + " " + v); for (var y=1;y<3;y++) for (var x=1;x<15;x++) { var e = document.getElementById(slotName(x,y)); if (e.childElementCount > 0) { var value = e.lastChild.textContent; var col = color.indexOf(e.lastChild.attributes['fill'].value) + 1; console.log(col + " " + value); if (c == col && v == value) return { 'x': x, 'y': y }; } } console.log("Card Not Found"); return ""; } function loadAppend(file, animation, name) { loadFile(file, function() { var slot = document.getElementById(name); var r = template_engine(localStorage.getItem(file),{'name': animation}); document.getElementById(name).appendChild(svg(r)); }); } function loadAnimationForButton(a, b) { return loadAppend('templates/ButtonAnimation.svg', a, b); } // TODO: Rollout Monadic Chain here loadFile('templates/Card.svg', function() { loadFile('Kakaranet-Scene.svg', function() { loadScene(); var a = [{button: "Create", pathes: ["CreateShow", "CreateHide"]}, {button: "Play", pathes: ["PlayShow", "PlayHide"]}]; for (var y=0;y'); document.getElementsByTagName('defs').item(0).appendChild(clipPath); document.getElementById("Online-Scroll").setAttribute("clip-path","url(#myClip)"); document.getElementById('Player-Statistics').style.display = 'none'; // onRightMenuDown(); }); }); var removeChilds = function (node) { var last; while (last = node.lastChild) node.removeChild(last); }; function onPlayerInfo(evt) { ws.send(enc(tuple(atom('client'), tuple(atom('stats_action'),bin(document.user),atom('game_okey'))))); } function onPlayerInfoClose(evt) { document.getElementById('Player-Statistics').style.display = 'none'; } function onRightMenu(evt) { localStorage.clear(); ["PlayShow","CreateShow"].map(function (x) { document.getElementById(x+"-Motion").beginElement(); }); } function onRightMenuDown(evt) { ["PlayHide","CreateHide"].map(function (x) { document.getElementById(x+"-Motion").beginElement(); }); } // SVG Samples for svg.htm /* loadFile('templates/Mustafa-Persona.svg', null, "Mustafa-Persona-Sample"); loadFile('templates/Mustafa-Selection.svg', null, "Mustafa-Selection-Sample"); document.getElementById("MustafaSelection").addEventListener('click', function() { var style = document.getElementById("Mustafa-Selection-Sample").style; if (style.display == 'none') style.display = 'block'; else style.display = 'none'; }); */ function slotName1(x,y) { return "1Slot-"+y+","+x; } function drawSampleCards() { slotName = slotName1; for (var i=1;i<15;i++) { place_card(i,rand(1,2),rand(1,4),rand(1,13)); } slotName = slotNameDef; } var scrollSensitivity = 0.2; function mouseWheelHandler(e) { var evt = window.event || e; var scroll = evt.detail ? evt.detail * scrollSensitivity : evt.wheelDelta * scrollSensitivity; var ori = document.getElementById("Clip-Path").getAttribute("y"); ori = parseFloat(scroll) + parseFloat(ori); document.getElementById("Clip-Path").setAttribute("y",parseFloat(ori)); document.getElementById("Online-Scroll").setAttribute("transform", "translate(0,"+(parseFloat(ori))+")"); document.getElementById("Online-Scroll").setAttribute("y", -parseFloat(ori)); console.log(ori); return true; }