123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <html>
- <head>
- <meta charset="utf-8"/>
- <link href="synrc.css" type="text/css" rel="stylesheet">
- <link href='http://fonts.googleapis.com/css?family=Exo+2:600' rel='stylesheet' type='text/css'>
- <script type="text/javascript">
- function verticalFlow(evt, dx) {
- console.log("Vertical Flow: " + evt);
- }
- </script>
- </head>
- <body>
- <div class="threecol">
- <div class="left">
- <div class="hints"></div>
- <div class="main">
- <h1>Full SVG Application</h1>
- <br>
- <svg id="Refined" width="900px">Placeholder for SVG Game Scene</svg>
- <code>Refined and Distilled File to download: <a href="Kakaranet-Scene.svg">Kakaranet-Scene.svg</a></code>
- <p><font color=red style="font-weight:bold;">Please make sure your Vector Editor correctly opens this file!</font></p>
- <div style="display: none;" id="history">
- <button id="pluslogin" type="button" data-gapiattached="true">Login</button>
- <label id="nothing"> Google</label></div><label id="gosterge">Gosterge: 1 5</label><br>
- <label id="player1"> Albert Einstein </label><select id="h1"></select>
- <label id="player2"> Marie Curie </label><select id="h2"></select>
- <label id="player3"> Ilya Prigogine </label><select id="h3"></select>
- <label id="player4" style="font-weight: bold; color: red;"> Asena Simsek </label><select id="h4"></select><br>
- <button id="logout" type="button">Logout</button>
- <button id="attach" type="button">Attach</button>
- <button id="join" type="button">Join</button>
- <select id="games_ids"></select>
- <select id="take_src"><option label="Table" value="0">Table</option><option label="Left" value="1">Left</option></select>
- <button id="take" type="button">Take</button>
- <select id="istaka"></select>
- <button id="discard" type="button">Discard</button>
- <button id="reveal" type="button">Reveal</button>
- <button id="saw_okey" type="button">I Saw Okey</button>
- <button id="have_8" type="button">8 Tashes</button>
- <button id="pause" type="button">Pause</button>
- <button id="info" type="button">PlayerInfo</button>
- <div id="n2ostatus"></div>
- <h1>Refined Object Names</h1>
- <code>
- Mustafa-Persona Facebook-Login Have-8-Tashes
- Gabrielo-Persona Online-Users Settings
- Alina-Person Kakaranet-Logo Pause
- Gabrielo-Deck Point-Table
- Alina-Deck Table Create
- Mustafa-Deck Gosterge Play
- Gabrielo-Discard Slot-1,1..15 Promos
- You-Discard Slot-2,1..15 Tournaments
- Alina-Discard Place-Card Okey
- Mustafa-Discard Center-Cards
- You-Deck Detailed-Houses
- Stupid-Cards Sky
- Mustafa-+-Timer Deck-Cards Sun
- You-+-Timer City
- Gabrielo
- Alina
- Right-Menu
- Left-Menu
- </code>
- <h1>SVG Templates and DOM Manipulation</h1>
- Here we using Simple Template Engine in 12 LOC.<br>
- SVG loader with localStorage caching in 9 LOC.<br>
- SVG DOM storing in 3 LOC<br>
- <code>
- function template_engine(html, data) {
- var re = /{([^}]+)?}/g, code = 'var r=[];', cursor = 0;
- var add = function(line,js) {
- js? (code += 'r.push(' + line + ');') :
- (code += line != '' ? 'r.push("' + line.replace(/"/g, '\\"') + '");' : '');
- return add; }
- while(match = re.exec(html)) {
- add(html.slice(cursor, match.index))(match[1],true);
- cursor = match.index + match[0].length; }
- add(html.substr(cursor, html.length - cursor));
- code += 'return r.join("");';
- return new Function(code.replace(/[\r\t\n]/g, '')).apply(data); }
- function reload_cont(cont,name,element) { if (null != cont) (cont)() else reload(name,element); }
- function reload(file, name) { var slot = document.getElementById(name);
- slot.parentNode.replaceChild(svg(localStorage.getItem(file)),slot);}
- function loadFile(name,cont,element) {
- if (localStorage.getItem(name) == null) {
- var client = new XMLHttpRequest();
- client.open('GET', name, true);
- client.onload = function() {
- localStorage.setItem(name,client.responseText);
- reload_cont(cont,name,element); }
- client.send(); }
- else reload_cont(cont,name,element); }
- function svg(html) { return new DOMParser().parseFromString(html, "text/xml").firstChild; }
- </code>
- <h1>The Card</h1>
- <code>
- templates/Card.svg:
- <g xmlns="http://www.w3.org/2000/svg" id="<font color=yellow>{this.name}</font>"
- transform="translate(<font color=yellow>{this.x}</font>,<font color=yellow>{this.y}</font>)">mbership,
- <rect fill="#FFFFFF" x="0" y="0" width="40" height="60" rx="4"/>
- <circle fill="<font color=yellow>{this.suit}</font>" cx="20" cy="43" r="7">
- <animate begin="0" fill="freeze" attributeName="r"
- values="4;5;6;7;8;6;5;4" dur="1s"
- calcMode="linear" repeatCount="indefinite"/></circle>
- <text dx="20" x="0" y="26.4873125"
- font-family="Lucida Grande" font-size="24"
- font-weight="bold" letter-spacing="-2" text-anchor="middle"
- fill="<font color=yellow>{this.suit}</font>"><font color=yellow>{this.value}</font></text>
- </g>
- function card(line,pos,col,v) {
- return template_engine(
- localStorage.getItem("templates/Card.svg"),
- { name: slotName(pos,line),
- suit: color[col-1],
- value: v,
- y: (line-1)*69,
- x: (pos-1)*42 }); }
- <svg id="Scene" width="200px" height="200px" viewBox="0 0 40 60">
- <g xmlns="http://www.w3.org/2000/svg" id="Slot"
- transform="translate(0,0)">
- <rect fill="#FFFFFF" x="0" y="0"
- width="40" height="60" rx="4"/>
- <text dx="20" x="0" y="26.4873125"
- font-family="Lucida Grande" font-size="24"
- font-weight="bold" letter-spacing="-2" text-anchor="middle"
- fill="#CE290F">12</text>
- <circle id="Color-{this.pos}" fill="#CE290F" cx="20" cy="43" r="7">
- <animate begin="0" fill="freeze" attributeName="r"
- values="4;5;6;7;8;6;5;4" dur="1s"
- calcMode="linear" repeatCount="indefinite"/></circle></g></svg>
- </code>
- <h1>Draw Deck</h1>
- <code>
- var color = ['#CE290F','#3B5998','#48AF5E','#FFEC00'];
- var slotName = slotNameDef;
- function slotNameDef(x,y) { return "Slot-"+y+","+x; }
- function place_card(x,y,c,v) {
- var slot = document.getElementById(slotName(x,y));
- slot.parentNode.replaceChild(svg(card(y,x,c,v)),slot); }
- function rand(lo,hi) { return Math.floor((Math.random()*hi)+lo); }
- 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; }
- loadFile('templates/Card.svg', drawSampleCards);
- <svg id="Scene" width="630px" height="200px" viewBox="-3 0 634 130">
- <rect id="Deck" fill="#AF7B58" x=-5 y=-2 width=635 height=133></rect>
- <rect id="Deck" fill="#BC8864" x=-5 y=62 width=635 height=5></rect>
- <g id="1Slot-1,1"/> <g id="1Slot-1,2"/> <g id="1Slot-1,3"/>
- <g id="1Slot-1,4"/> <g id="1Slot-1,5"/> <g id="1Slot-1,6"/>
- <g id="1Slot-1,7"/> <g id="1Slot-1,8"/> <g id="1Slot-1,9"/>
- <g id="1Slot-1,10"/><g id="1Slot-1,11"/><g id="1Slot-1,12"/>
- <g id="1Slot-1,13"/><g id="1Slot-1,14"/><g id="1Slot-1,15"/>
- <g id="1Slot-2,1"/> <g id="1Slot-2,2"/> <g id="1Slot-2,3"/>
- <g id="1Slot-2,4"/> <g id="1Slot-2,5"/> <g id="1Slot-2,6"/>
- <g id="1Slot-2,7"/> <g id="1Slot-2,8"/> <g id="1Slot-2,9"/>
- <g id="1Slot-2,10"/><g id="1Slot-2,11"/><g id="1Slot-2,12"/>
- <g id="1Slot-2,13"/><g id="1Slot-2,14"/><g id="1Slot-2,15"/>
- </svg>
- </code>
- <h1>Mustafa</h1>
- <code>
- > document.getElementById("Mustafa-Persona");
- <svg width="400px" height="400px" viewBox="450 120 150 200">
- <g id="Mustafa-Selection-Sample"/>
- <g id="Mustafa-Persona-Sample"/>
- </svg>
- > document.getElementById("Mustafa-Selection").style.display = "none";
- </code>
- <button id="MustafaSelection" style="font-size:28pt;">Toggle Mustafa Selection</button>
- <script src='svg.js' type='text/javascript' charset='utf-8'></script>
- <code style="font-size: 6pt;">
- <g id="Mustafa-Persona" sketch:type="MSLayerGroup" transform="translate(467.000000, 150.000000)">
- <path d="M135.729,120.296 C118.005,95.269 108.839,85.517 85.519,85.517 L45.641,85.517 C22.321,85.517 11.022,103.055 0.272,120.296
- L135.729,120.296 L135.729,120.296 Z" id="Mustafa-Body" fill="#8DCED7"></path>
- <path d="M52.283,65.674 L48.134,81.099 L62.961,92.715 C62.961,92.715 68.155,92.749 68.329,92.691 C68.505,92.63 82.401,82.215
- 82.401,82.215 L78.093,65.59 L52.283,65.674 L52.283,65.674 Z" id="Mestafa-Neck" fill="#FFD191"></path>
- <path d="M56.035,1.351 C55.251,1.787 55.519,2.374 56.04,2.389 C57.252,2.419 58.102,2.639 58.81,3.7 C59.027,4.136 60.433,8.259 53.572,9.985
- C44.985,11.985 31.101,25.204 40.796,45.629 C41.402,46.905 42.03,48.031 42.676,49.019 C65.907,47.218 68.327,47.042
- 89.399,45.259 C106.855,15.955 69.488,-5.38 56.035,1.351 L56.035,1.351 Z" id="Mustafa-Hair" fill="#3F372E"></path>
- <path d="M88.417,44.449 C88.417,44.312 88.394,44.178 88.365,44.053 C88.288,43.666 88.116,43.387 87.864,43.196 C87.553,42.909 87.148,42.73 86.69,42.73
- L85.381,42.73 C85.263,42.73 85.152,42.752 85.039,42.764 L85.039,40.178 C85.039,29.368 76.272,20.604 65.456,20.604 C54.639,20.604 45.871,29.369
- 45.871,40.178 L45.871,42.739 C45.838,42.739 45.808,42.73 45.772,42.73 C44.099,42.73 42.742,42.844 42.742,44.518 L42.742,53.114 C42.742,54.788
- 44.099,56.141 45.772,56.141 C45.807,56.141 45.837,56.132 45.871,56.132 L45.871,62.719 C45.871,72.543 52.695,79.145 61.763,82.679 C62.161,84.207
- 63.533,85.34 65.189,85.34 C66.759,85.34 68.081,84.313 68.547,82.897 C78.753,79.063 85.038,72.831 85.038,62.719 L85.038,56.108 C85.15,56.118
- 85.262,56.141 85.38,56.141 C87.054,56.141 88.415,54.787 88.415,53.114 L88.415,44.518 C88.415,44.502 88.408,44.498 88.408,44.488 C88.41,44.474
- 88.417,44.462 88.417,44.449 L88.417,44.449 Z" id="Mustafa-Face" fill="#FFE0A5"></path>
- <path d="M62.358,88.807 C62.251,88.775 51.594,85.661 47.004,79.336 C46.652,78.854 46.035,78.639 45.46,78.799 C42.924,79.506 42.006,84.223 42.402,86.014
- C44.687,96.295 58.986,102.323 59.593,102.574 C59.772,102.644 59.957,102.686 60.144,102.686 C60.384,102.686 60.624,102.624 60.839,102.503 C61.22,102.289
- 61.486,101.916 61.557,101.484 L63.378,90.417 C63.496,89.699 63.059,89.006 62.358,88.807 L62.358,88.807 Z" id="Mustafa-Left-Collar" fill="#EFEFEF"></path>
- <path d="M85.984,78.799 C85.408,78.639 84.79,78.854 84.439,79.336 C79.851,85.66 69.2,88.774 69.088,88.807 C68.393,89.006 67.953,89.7 68.067,90.417
- L69.888,101.484 C69.96,101.916 70.223,102.289 70.606,102.503 C70.822,102.624 71.065,102.686 71.308,102.686 C71.492,102.686
- 71.677,102.644 71.854,102.574 C72.458,102.323 86.754,96.296 89.039,86.014 C89.441,84.223 88.521,79.506 85.984,78.799
- L85.984,78.799 Z" id="Mustafa-Right-Collar" fill="#EFEFEF"></path>
- <path d="M45.821,47.087 C45.821,47.087 48.215,47.551 48.588,44.092 C49.207,39.158 47.304,25.716 54.907,27.976 C62.513,30.241 67.131,31.426 72.271,28.758
- C77.406,26.085 80.23,30.547 81.311,33.531 C82.352,36.408 80.573,46.199 85.095,45.786 C85.121,44.68 85.073,43.809 85.116,42.687 C87.802,41.369
- 87.042,36.324 87.118,28.9 C86.626,22.662 83.987,16.503 69.765,16.263 C68.323,16.263 52.084,15.646 48.18,21.195 C44.276,26.742 45.621,35.719
- 45.621,35.719 L45.821,47.087 L45.821,47.087 Z" id="Mustafa-Hair-2" fill="#3F372E"></path>
- <path d="M60.429,52.326 C59.764,52.326 59.226,51.787 59.226,51.122 C59.226,50.295 58.551,49.619 57.72,49.619 C56.89,49.619 56.217,50.295 56.217,51.122
- C56.217,51.787 55.676,52.326 55.014,52.326 C54.347,52.326 53.81,51.787 53.81,51.122 C53.81,48.967 55.563,47.213 57.72,47.213 C59.88,47.213
- 61.634,48.967 61.634,51.122 C61.634,51.787 61.094,52.326 60.429,52.326 L60.429,52.326 Z" id="Mustafa-Left-Eye" fill="#3F372E"></path>
- <path d="M75.899,52.326 C75.231,52.326 74.695,51.787 74.695,51.122 C74.695,50.295 74.021,49.619 73.188,49.619 C72.361,49.619 71.688,50.295 71.688,51.122
- C71.688,51.787 71.146,52.326 70.484,52.326 C69.818,52.326 69.278,51.787 69.278,51.122 C69.278,48.967 71.037,47.213 73.188,47.213 C75.346,47.213
- 77.101,48.967 77.101,51.122 C77.102,51.787 76.559,52.326 75.899,52.326 L75.899,52.326 Z" id="Mustafa-Right-Eye" fill="#3F372E"></path>
- <path d="M76.4456778,62.3565674 C78.1319071,63.7008727 74.4204926,66.9530814 72.7733273,68.0499695 C71.126162,69.1468575 68.0660971,70.5763405
- 65.8852394,70.5763405 C63.7043817,70.5763405 59.6097044,68.9318757 58.3813209,68.0499693 C57.1529374,67.1680629 53.4953577,63.8108791
- 54.8127441,62.3565674 C56.1301305,60.9022556 58.2236035,63.1233233 59.4535298,63.9693678 C60.6834562,64.8154119 63.4038036,66.1736356
- 65.6591608,66.1736357 C67.2722666,66.1736358 69.8272118,65.4283507 71.0461488,64.5069182 C72.2650857,63.5854857 74.7594486,61.012262
- 76.4456778,62.3565674 Z" id="Mustafa-Mouth" fill="#E6BE7C"></path></g>
- </code>
- <h2>Abstract</h2>
- <p>Основна ідея мати чистий SVG фреймворк що усі елементи були однотипними,
- і підхід був уніфікований, кнопки будь якого розміру, форми і які легко
- було би змінити в майбутньому. HTML/CSS підхід в подальшому не даcть
- змогу легко замінити контрольні елементи, карти і таке інше, доведеть
- повністью розбирати CSS елементи і верску. Уявіть що ми захочемо в
- майбутньому просто відкрити SVG у векторному редакторі, перемалювати
- і зберегти з тими самими element ID. У випадку з CSS при зміні дизайну ми
- постійно будемо змушені пестворювати верстку, знову наймати одноразову ручну роботу.
- У випадку з SVG нам доведеться тільки замінити елементи SVG.</P>
- <h2>SVG Integration Process</h2>
- <p>Підхід який пропонується нагадуеє уніфіковану роботу з векторними
- XML елементами, як це є в WPF наприклад. Тут справа не в байтах, в
- інтеграції процессу між дизайнерами, розробниками, верстальниками і
- серверними програмістами. Як наприклад Expression Blend у Microsoft для WPF.
- Саме з цих міркувань була вибрана технологія SVG.</p>
- <h2>SVG DOM Control</h2>
- <p>Інша частина це інтеграція SVG DOM і управління ним на сервері.
- Ми хочемо мати можливість модифікувати SVG DOM з сервера. Для цього
- нам потрібно прозорий та уніфікований підхід до усіх елементів.
- Це дасть нам змогу використовувати підхід як товстого (гра повністю в браузері),
- так і тонкого клієнту (коли стан гри повнітю контролюється сервером).</p>
- <h2>Sample Client</h2>
- <p>Прототип тонкого клієнту на елементах HTML/CSS викладений тут:<p>
- <code><a href="http://srv5.kakaranet.com:8080">http://srv5.kakaranet.com:8080</a></code>
- </div>
- <div class="contents">
- <!--iframe src="contents.htm" frameborder=0 width=340 height=510></iframe-->
- </div>
- </div>
- <script src='../nitrogen/bullet.js' type='text/javascript' charset='utf-8'></script>
- <script src='../nitrogen/n2o.js' type='text/javascript' charset='utf-8'></script>
- <script src='../nitrogen/bert.js' type='text/javascript' charset='utf-8'></script>
- </body>
- </html>
|