Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
207 additions
and
34 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
(function(){ | ||
'use strict'; | ||
|
||
// FIXME: This feedback is important and useful, but using it this way violates | ||
// our localization principle: All user-visible text should be in HTML text, | ||
// not attributes, CSS, or JavaScript. Once the messages have stabilized, move them | ||
// to hidden HTML elements and refer to them by name so they can be localized. | ||
var feedbackElem = document.querySelector('.feedback'); | ||
function message(color, text){ | ||
if (feebackElem){ | ||
feedbackElem.style.color = color; | ||
feedbackElem.value = text; | ||
} | ||
} | ||
|
||
function error(text){ | ||
message('red', text); | ||
} | ||
|
||
function warn(text){ | ||
message('orange', text); | ||
} | ||
|
||
function info(text){ | ||
message('#333', text); | ||
} | ||
|
||
// Documentation for modal dialogs: https://github.com/kylepaulsen/NanoModal | ||
|
||
Event.on('.do-run', 'ui:click', null, startScript); | ||
Event.on('.do-stop', 'ui:click', null, stopScript); | ||
|
||
function startScript(evt){ | ||
// Do any necessary cleanup (e.g., clear event handlers). | ||
stopScript(evt); | ||
runtime.resetStage(); | ||
evt.target.blur(); | ||
runtime.getStage().focus(); | ||
preload().whenLoaded(runScript); | ||
} | ||
|
||
function stopScript(evt){ | ||
runtime.stopEventLoop(); | ||
evt.target.blur(); | ||
runtime.getStage().focus() | ||
runtime.clear(); | ||
} | ||
|
||
function preload() { | ||
return assets.load({ | ||
'wb-contains wb-expression[isAsset=true]': assets.loadMedia, | ||
'wb-contains wb-expression[script^="geolocation."]': | ||
assets.waitFor('locationchanged', util.geolocation.startTrackingLocation), | ||
'wb-contains wb-expression[script="motion.tiltDirection"]': | ||
assets.waitFor('motionchanged', util.motion.startTrackingMotion) | ||
}); | ||
} | ||
|
||
function runScript(){ | ||
var globalScope = {}; | ||
runtime.startEventLoop(); | ||
dom.findAll('wb-workspace > wb-contains > *').forEach(function(block){ | ||
if (block.run){ | ||
block.run(globalScope); | ||
} | ||
}); | ||
} | ||
|
||
Event.on(document.body, 'dragging:touchstart', null, Event.trackPointerDown); | ||
Event.on(document.body, 'dragging:touchmove', null, Event.trackPointerPosition); | ||
Event.on(document.body, 'dragging:touchend', null, Event.trackPointerUp); | ||
Event.on(document.body, 'dragging:mousedown', null, Event.trackPointerDown); | ||
Event.on(document.body, 'dragging:mousemove', null, Event.trackPointerPosition); | ||
Event.on(window, 'input:keydown', null, Event.handleKeyDown); | ||
Event.on(window, 'input:keyup', null, Event.handleKeyUp); | ||
|
||
Event.on(window, 'ui:load', null, preload); | ||
Event.on(window, 'ui:script-load', null, preload); | ||
Event.on(window, 'ui:asset-load', null, runScript); | ||
|
||
window.app = { | ||
message: message, | ||
error: error, | ||
warn: warn, | ||
info: info | ||
}; | ||
|
||
})(); |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"> | ||
<title>Waterbear Play</title> | ||
<link rel="stylesheet" href="css/reset.css" /> | ||
<link rel="stylesheet" href="css/widget.css" /> | ||
<link rel="stylesheet" href="css/block.css" /> | ||
<link rel="stylesheet" href="css/app.css" /> | ||
<script src="lib/prefixfree.min.js"></script> | ||
<script type="text/javascript"> | ||
<!-- Google Analytics --> | ||
var _gaq = _gaq || []; | ||
_gaq.push(['_setAccount', 'UA-58671174-1']); | ||
_gaq.push(['_trackPageview']); | ||
|
||
(function() { | ||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; | ||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; | ||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); | ||
})(); | ||
|
||
</script> | ||
</head> | ||
<body> | ||
<header> | ||
<a href="index.html"><img src="images/logo/waterbear_icon_logo.svg" /></a> | ||
<h1>Waterbear Play</h1> | ||
</header> | ||
<wb-workspace style="display:none"> | ||
<header>Workspace</header> | ||
<output class="feedback"></output> | ||
<wb-contains></wb-contains> | ||
</wb-workspace> | ||
<wb-playground> | ||
<div class="menu"> | ||
<button class="do-run" onclick="_gaq.push(['_trackEvent', 'Actions', 'run']);">Run</button> | ||
<button class="do-stop" onclick="_gaq.push(['_trackEvent', 'Action', 'stop']);">Stop</button> | ||
</div> | ||
<canvas></canvas> | ||
</wb-playground> | ||
<svg class="sekrit-svg"><text class="resize-tester"></text></svg> | ||
<script src="lib/ajax.js"></script> | ||
<script src="lib/document-register-element.js"></script><!-- polyfill for custom elements --> | ||
<script src="lib/sound.js"></script> | ||
<script src="lib/nanomodal.js"></script> | ||
<script src="js/util.js"></script> | ||
<script src="js/event.js"></script> | ||
<script src="js/runtime.js"></script> | ||
<script src="js/dom.js"></script> | ||
<script src="js/block.js"></script> | ||
<script src="js/app_play.js"></script> | ||
<script src="js/file.js"></script> | ||
<script src="js/queryparams.js"></script> | ||
|
||
</body> | ||
</html> |