Browse Source

Convert newlines to Unix

master
parent
commit
2600c8887d
3 changed files with 294 additions and 294 deletions
  1. +56
    -56
      dice/index.html
  2. +82
    -82
      dice/main.js
  3. +156
    -156
      teal.js

+ 56
- 56
dice/index.html View File

@ -1,56 +1,56 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="keywords" content="DnD, dangeon and dragons, roleplay, dice, roller, 3D, RPG, wargame"/>
<meta name="description" content="Online 3D dice roller"/>
<title>teal 3d dice roller</title>
<style type="text/css">@import "../main.css";</style>
<style type="text/css">@import "dice.css";</style>
</head>
<body class="svg" style="margin: 0">
<div class="control_panel">
<h6><img src="../favicon.ico" style="vertical-align: middle"></img> <a href="..">teal</a> dice</h6>
<p id="loading_text">Loading libraries, please wait a bit...</p>
<p id="info_text"><a href="http://www.teall.info/2014/01/online-3d-dice-roller.html">More info and help</a></p>
<p id="info_text"><a href="/mdice">Multiplayer version</a></p>
</div>
<div id="info_div" style="display: none">
<div class="center_field">
<span id="label"></span>
</div>
<div class="center_field">
<div class="bottom_field">
<span id="labelhelp">click to continue or tap and drag again</span>
</div>
</div>
</div>
<div id="selector_div" style="display: none">
<div class="center_field">
<div id="sethelp">
choose your dice set by clicking the dices or by direct input of notation,<br/>
tap and drag on free space of screen or hit throw button to roll
</div>
</div>
<div class="center_field">
<input type="text" id="set" value="4d6"></input><br/>
<button id="clear">clear</button>
<button style="margin-left: 0.6em" id="throw">throw</button>
</div>
</div>
<div id="canvas"></div>
<script src="../libs/three.min.js"></script>
<script src="../libs/cannon.min.js"></script>
<script type="text/javascript" src="../teal.js"></script>
<script type="text/javascript" src="dice.js"></script>
<script type="text/javascript" src="main.js"></script>
<script type="text/javascript" defer="defer">
diceInitialize(document.body, window.innerWidth - 1, window.innerHeight - 1);
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="keywords" content="DnD, dangeon and dragons, roleplay, dice, roller, 3D, RPG, wargame"/>
<meta name="description" content="Online 3D dice roller"/>
<title>teal 3d dice roller</title>
<style type="text/css">@import "../main.css";</style>
<style type="text/css">@import "dice.css";</style>
</head>
<body class="svg" style="margin: 0">
<div class="control_panel">
<h6><img src="../favicon.ico" style="vertical-align: middle"></img> <a href="..">teal</a> dice</h6>
<p id="loading_text">Loading libraries, please wait a bit...</p>
<p id="info_text"><a href="http://www.teall.info/2014/01/online-3d-dice-roller.html">More info and help</a></p>
<p id="info_text"><a href="/mdice">Multiplayer version</a></p>
</div>
<div id="info_div" style="display: none">
<div class="center_field">
<span id="label"></span>
</div>
<div class="center_field">
<div class="bottom_field">
<span id="labelhelp">click to continue or tap and drag again</span>
</div>
</div>
</div>
<div id="selector_div" style="display: none">
<div class="center_field">
<div id="sethelp">
choose your dice set by clicking the dices or by direct input of notation,<br/>
tap and drag on free space of screen or hit throw button to roll
</div>
</div>
<div class="center_field">
<input type="text" id="set" value="4d6"></input><br/>
<button id="clear">clear</button>
<button style="margin-left: 0.6em" id="throw">throw</button>
</div>
</div>
<div id="canvas"></div>
<script src="../libs/three.min.js"></script>
<script src="../libs/cannon.min.js"></script>
<script type="text/javascript" src="../teal.js"></script>
<script type="text/javascript" src="dice.js"></script>
<script type="text/javascript" src="main.js"></script>
<script type="text/javascript" defer="defer">
diceInitialize(document.body, window.innerWidth - 1, window.innerHeight - 1);
</script>
</body>
</html>

+ 82
- 82
dice/main.js View File

@ -1,82 +1,82 @@
"use strict";
function diceInitialize(container, w, h) {
$t.remove($t.id('loading_text'));
var canvas = $t.id('canvas');
canvas.style.width = w + 'px';
canvas.style.height = h + 'px';
var label = $t.id('label');
var set = $t.id('set');
var selectorDiv = $t.id('selector_div');
var infoDiv = $t.id('info_div');
onSetChange();
function onSetChange(ev) { set.style.width = set.value.length + 3 + 'ex'; }
$t.bind(set, 'keyup', onSetChange);
$t.bind(set, 'mousedown', function(ev) { ev.stopPropagation(); });
$t.bind(set, 'mouseup', function(ev) { ev.stopPropagation(); });
$t.bind(set, 'focus', function(ev) { $t.set(container, { class: '' }); });
$t.bind(set, 'blur', function(ev) { $t.set(container, { class: 'svg' }); });
$t.bind($t.id('clear'), ['mouseup', 'touchend', 'touchcancel'], function(ev) {
ev.stopPropagation();
set.value = '0';
onSetChange();
});
var box = new $t.dice.dieBox(canvas);
function showSelector() {
infoDiv.style.display = 'none';
selectorDiv.style.display = 'inline-block';
box.drawSelector();
}
function beforeRoll(vectors) {
infoDiv.style.display = 'none';
selectorDiv.style.display = 'none';
}
function notationGetter() {
return $t.dice.parseNotation(set.value);
}
function afterRoll(notation, result) {
var res = result.join(' ');
if (notation.constant) res += ' +' + notation.constant;
if (result.length > 1) res += ' = ' +
(result.reduce(function(s, a) { return s + a; }) + notation.constant);
label.innerHTML = res;
infoDiv.style.display = 'inline-block';
}
box.bindMouse(container, notationGetter, beforeRoll, afterRoll);
box.bindThrow($t.id('throw'), notationGetter, beforeRoll, afterRoll);
$t.bind(container, ['mouseup', 'touchend', 'touchcancel'], function(ev) {
if (selectorDiv.style.display == 'none') {
if (!box.rolling) showSelector();
box.rolling = false;
return;
}
var name = box.searchDieByMouse(ev);
if (name != undefined) {
var notation = $t.dice.parseNotation(set.value);
notation.set.push(name);
set.value = $t.dice.stringifyNotation(notation);
onSetChange();
}
});
var params = $t.getUrlParams();
if (params.notation) {
set.value = params.notation;
}
if (params.roll) {
$t.raiseEvent($t.id('throw'), 'mouseup');
}
else {
showSelector();
}
}
"use strict";
function diceInitialize(container, w, h) {
$t.remove($t.id('loading_text'));
var canvas = $t.id('canvas');
canvas.style.width = w + 'px';
canvas.style.height = h + 'px';
var label = $t.id('label');
var set = $t.id('set');
var selectorDiv = $t.id('selector_div');
var infoDiv = $t.id('info_div');
onSetChange();
function onSetChange(ev) { set.style.width = set.value.length + 3 + 'ex'; }
$t.bind(set, 'keyup', onSetChange);
$t.bind(set, 'mousedown', function(ev) { ev.stopPropagation(); });
$t.bind(set, 'mouseup', function(ev) { ev.stopPropagation(); });
$t.bind(set, 'focus', function(ev) { $t.set(container, { class: '' }); });
$t.bind(set, 'blur', function(ev) { $t.set(container, { class: 'svg' }); });
$t.bind($t.id('clear'), ['mouseup', 'touchend', 'touchcancel'], function(ev) {
ev.stopPropagation();
set.value = '0';
onSetChange();
});
var box = new $t.dice.dieBox(canvas);
function showSelector() {
infoDiv.style.display = 'none';
selectorDiv.style.display = 'inline-block';
box.drawSelector();
}
function beforeRoll(vectors) {
infoDiv.style.display = 'none';
selectorDiv.style.display = 'none';
}
function notationGetter() {
return $t.dice.parseNotation(set.value);
}
function afterRoll(notation, result) {
var res = result.join(' ');
if (notation.constant) res += ' +' + notation.constant;
if (result.length > 1) res += ' = ' +
(result.reduce(function(s, a) { return s + a; }) + notation.constant);
label.innerHTML = res;
infoDiv.style.display = 'inline-block';
}
box.bindMouse(container, notationGetter, beforeRoll, afterRoll);
box.bindThrow($t.id('throw'), notationGetter, beforeRoll, afterRoll);
$t.bind(container, ['mouseup', 'touchend', 'touchcancel'], function(ev) {
if (selectorDiv.style.display == 'none') {
if (!box.rolling) showSelector();
box.rolling = false;
return;
}
var name = box.searchDieByMouse(ev);
if (name != undefined) {
var notation = $t.dice.parseNotation(set.value);
notation.set.push(name);
set.value = $t.dice.stringifyNotation(notation);
onSetChange();
}
});
var params = $t.getUrlParams();
if (params.notation) {
set.value = params.notation;
}
if (params.roll) {
$t.raiseEvent($t.id('throw'), 'mouseup');
}
else {
showSelector();
}
}

+ 156
- 156
teal.js View File

@ -1,156 +1,156 @@
"use strict";
window.teal = {};
window.$t = window.teal;
teal.copyto = function(obj, res) {
if (obj == null || typeof obj !== 'object') return obj;
if (obj instanceof Array) {
for (var i = obj.length - 1; i >= 0; --i)
res[i] = $t.copy(obj[i]);
}
else {
for (var i in obj) {
if (obj.hasOwnProperty(i))
res[i] = $t.copy(obj[i]);
}
}
return res;
}
teal.copy = function(obj) {
if (!obj) return obj;
return teal.copyto(obj, new obj.constructor());
}
teal.element = function(name, props, place) {
var dom = document.createElement(name);
for (var i in props) dom.setAttribute(i, props[i]);
if (place) place.appendChild(dom);
return dom;
}
teal.id = function(id) {
return document.getElementById(id);
}
teal.set = function(sel, props) {
for (var i in props) sel.setAttribute(i, props[i]);
return sel;
}
teal.clas = function(sel, oldclass, newclass) {
var oc = oldclass ? oldclass.split(/\s+/) : [],
nc = newclass ? newclass.split(/\s+/) : [],
classes = (sel.getAttribute('class') || '').split(/\s+/);
for (var i in oc) {
var ind = classes.indexOf(oc[i]);
if (ind >= 0) classes.splice(ind, 1);
}
for (var i in nc) {
if (classes.indexOf(nc[i]) < 0) classes.push(nc[i]);
}
sel.setAttribute('class', classes.join(' '));
}
teal.empty = function(sel) {
if (sel.childNodes)
while (sel.childNodes.length)
sel.removeChild(sel.firstChild);
}
teal.remove = function(sel) {
if (sel) {
if (sel.parentNode) sel.parentNode.removeChild(sel);
else for (var i = sel.length - 1; i >= 0; --i)
sel[i].parentNode.removeChild(sel[i]);
}
}
teal.bind = function(sel, eventname, func, bubble) {
if (eventname.constructor === Array) {
for (var i in eventname)
sel.addEventListener(eventname[i], func, bubble ? bubble : false);
}
else
sel.addEventListener(eventname, func, bubble ? bubble : false);
}
teal.unbind = function(sel, eventname, func, bubble) {
if (eventname.constructor === Array) {
for (var i in eventname)
sel.removeEventListener(eventname[i], func, bubble ? bubble : false);
}
else
sel.removeEventListener(eventname, func, bubble ? bubble : false);
}
teal.one = function(sel, eventname, func, bubble) {
var oneFunc = function(e) {
func(e);
teal.unbind(sel, eventname, oneFunc, bubble);
};
teal.bind(sel, eventname, oneFunc, bubble);
}
teal.raiseEvent = function(sel, eventname, bubble, cancelable) {
var evt = document.createEvent('UIEvents');
evt.initEvent(eventname, bubble == undefined ? true : bubble,
cancelable == undefined ? true : cancelable);
sel.dispatchEvent(evt);
}
if (navigator.appName == 'Microsoft Internet Explorer') {
teal.getElementsByClass = function(classes, node) {
var node = node || document,
list = node.getElementsByTagName('*'),
cl = classes.split(/\s+/),
result = [];
for (var i = list.length - 1; i >= 0; --i) {
for (var j = cl.length - 1; j >= 0; --j) {
var clas = list[i].getAttribute('class');
if (clas && clas.search('\\b' + cl[j] + '\\b') != -1) {
result.push(list[i]);
break;
}
}
}
return result;
}
}
else {
teal.getElementsByClass = function(classes, node) {
return (node || document).getElementsByClassName(classes);
}
}
teal.rpc = function(params, resp) {
var ajax = new XMLHttpRequest(), ret;
ajax.open("post", 'f', resp ? true : false);
ajax.onreadystatechange = function() {
if (ajax.readyState == 4) {
if (resp) resp(JSON.parse(ajax.responseText));
else ret = JSON.parse(ajax.responseText);
}
};
ajax.send(JSON.stringify(params));
return ret;
}
teal.uuid = function() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
teal.getUrlParams = function() {
var params = window.location.search.substring(1).split("&");
var res = {};
for (var i in params) {
var keyvalue = params[i].split("=");
res[keyvalue[0]] = decodeURI(keyvalue[1]);
}
return res;
}
"use strict";
window.teal = {};
window.$t = window.teal;
teal.copyto = function(obj, res) {
if (obj == null || typeof obj !== 'object') return obj;
if (obj instanceof Array) {
for (var i = obj.length - 1; i >= 0; --i)
res[i] = $t.copy(obj[i]);
}
else {
for (var i in obj) {
if (obj.hasOwnProperty(i))
res[i] = $t.copy(obj[i]);
}
}
return res;
}
teal.copy = function(obj) {
if (!obj) return obj;
return teal.copyto(obj, new obj.constructor());
}
teal.element = function(name, props, place) {
var dom = document.createElement(name);
for (var i in props) dom.setAttribute(i, props[i]);
if (place) place.appendChild(dom);
return dom;
}
teal.id = function(id) {
return document.getElementById(id);
}
teal.set = function(sel, props) {
for (var i in props) sel.setAttribute(i, props[i]);
return sel;
}
teal.clas = function(sel, oldclass, newclass) {
var oc = oldclass ? oldclass.split(/\s+/) : [],
nc = newclass ? newclass.split(/\s+/) : [],
classes = (sel.getAttribute('class') || '').split(/\s+/);
for (var i in oc) {
var ind = classes.indexOf(oc[i]);
if (ind >= 0) classes.splice(ind, 1);
}
for (var i in nc) {
if (classes.indexOf(nc[i]) < 0) classes.push(nc[i]);
}
sel.setAttribute('class', classes.join(' '));
}
teal.empty = function(sel) {
if (sel.childNodes)
while (sel.childNodes.length)
sel.removeChild(sel.firstChild);
}
teal.remove = function(sel) {
if (sel) {
if (sel.parentNode) sel.parentNode.removeChild(sel);
else for (var i = sel.length - 1; i >= 0; --i)
sel[i].parentNode.removeChild(sel[i]);
}
}
teal.bind = function(sel, eventname, func, bubble) {
if (eventname.constructor === Array) {
for (var i in eventname)
sel.addEventListener(eventname[i], func, bubble ? bubble : false);
}
else
sel.addEventListener(eventname, func, bubble ? bubble : false);
}
teal.unbind = function(sel, eventname, func, bubble) {
if (eventname.constructor === Array) {
for (var i in eventname)
sel.removeEventListener(eventname[i], func, bubble ? bubble : false);
}
else
sel.removeEventListener(eventname, func, bubble ? bubble : false);
}
teal.one = function(sel, eventname, func, bubble) {
var oneFunc = function(e) {
func(e);
teal.unbind(sel, eventname, oneFunc, bubble);
};
teal.bind(sel, eventname, oneFunc, bubble);
}
teal.raiseEvent = function(sel, eventname, bubble, cancelable) {
var evt = document.createEvent('UIEvents');
evt.initEvent(eventname, bubble == undefined ? true : bubble,
cancelable == undefined ? true : cancelable);
sel.dispatchEvent(evt);
}
if (navigator.appName == 'Microsoft Internet Explorer') {
teal.getElementsByClass = function(classes, node) {
var node = node || document,
list = node.getElementsByTagName('*'),
cl = classes.split(/\s+/),
result = [];
for (var i = list.length - 1; i >= 0; --i) {
for (var j = cl.length - 1; j >= 0; --j) {
var clas = list[i].getAttribute('class');
if (clas && clas.search('\\b' + cl[j] + '\\b') != -1) {
result.push(list[i]);
break;
}
}
}
return result;
}
}
else {
teal.getElementsByClass = function(classes, node) {
return (node || document).getElementsByClassName(classes);
}
}
teal.rpc = function(params, resp) {
var ajax = new XMLHttpRequest(), ret;
ajax.open("post", 'f', resp ? true : false);
ajax.onreadystatechange = function() {
if (ajax.readyState == 4) {
if (resp) resp(JSON.parse(ajax.responseText));
else ret = JSON.parse(ajax.responseText);
}
};
ajax.send(JSON.stringify(params));
return ret;
}
teal.uuid = function() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
teal.getUrlParams = function() {
var params = window.location.search.substring(1).split("&");
var res = {};
for (var i in params) {
var keyvalue = params[i].split("=");
res[keyvalue[0]] = decodeURI(keyvalue[1]);
}
return res;
}

Loading…
Cancel
Save