-
-
Save scottgwald/9284272 to your computer and use it in GitHub Desktop.
[wearscript] card tree example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html style="width:100%; height:100%; overflow:hidden"> | |
<body style="width:100%; height:100%; overflow:hidden; margin:0"> | |
<script> | |
function server() { | |
WS.displayCardTree(); | |
var select = function () {WS.say('select')}; | |
var tap = function () {}; | |
var select = function (n) {return function () {WS.say('select ' + n);WS.log('select ' + n)}}; | |
var log = function (n) {return function () {WS.log('log ' + n)}}; | |
var tap = function (n) {return function () {WS.say('tap ' + n);WS.log('tap ' + n)}}; | |
var tree = new WS.Cards(); | |
var subtree = new WS.Cards(); | |
subtree.add('No Listeners', 's0'); | |
subtree.add('Select', 's1', select('s1')); | |
subtree.add('Select + Tap', 's2', select('s2'), tap('s2')); | |
subtree.add('Menu', 's3', 'Tap', tap('s3'), 'Log', log('s3')); | |
subtree.add('Select + Menu', 's4', select('s4'), 'Tap', tap('s4'), 'Log', log('s4')); | |
subtree.add('Select + Tap + Menu', 's5', select('s5'), tap('s5'), 'Tap', tap('s5'), 'Log', log('s5')); | |
tree.add('No Listeners', '0'); | |
tree.add('Select', '1', select(1)); | |
tree.add('Select + Tap', '2', select(2), tap(2)); | |
tree.add('Menu', '3', 'Tap', tap(3), 'Log', log(3)); | |
tree.add('Select + Menu', '4', select(4), 'Tap', tap(4), 'Log', log(4)); | |
tree.add('Select + Tap + Menu', '5', select(5), tap(5), 'Tap', tap(5), 'Log', log(5)); | |
tree.add('Subtree', '6', subtree); | |
tree.add('Subtree + Select', '7', select(7), subtree); | |
tree.add('Subtree + Select + Tap', '8', select(8), tap(8), subtree); | |
WS.log(JSON.stringify(tree)); | |
WS.cardTree(tree); | |
} | |
function main() { | |
if (WS.scriptVersion(1)) return; | |
WS.serverConnect('{{WSUrl}}', 'server'); | |
} | |
window.onload = main; | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Card Tree Example" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment