Created
May 15, 2012 22:51
-
-
Save ekashida/2705760 to your computer and use it in GitHub Desktop.
app creation/deletion without cl
This file contains hidden or 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
| iframe { | |
| display: block; | |
| } |
This file contains hidden or 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
| <ul> | |
| <li><label>URL <input id="url" type="text" value="http://search.yahoo.com"></label></li> | |
| <li><label><input id="manual" type="checkbox"> Do not automate</label></li> | |
| <li><button id="start">Start</button></li> | |
| <li><button id="end">End</button></li> | |
| </ul> |
This file contains hidden or 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
| YUI({filter: 'debug', combine: false}).use('node', function (Y) { | |
| var body = Y.one('body'), | |
| start = Y.one('#start'), | |
| end = Y.one('#end'), | |
| urlField = Y.one('#url'), | |
| manual = Y.one('#manual'), | |
| automate, | |
| url, | |
| flag, | |
| iframe; | |
| function create () { | |
| if (flag && url) { | |
| iframe = Y.Node.create('<iframe>'); | |
| if (automate) { | |
| iframe.on('load', function () { | |
| setTimeout(function () { | |
| destroy(); | |
| }, 0); | |
| }); | |
| } | |
| iframe.set('src', url); | |
| body.append(iframe); | |
| } | |
| } | |
| function destroy () { | |
| iframe.remove(true); | |
| iframe = null; | |
| create(url); | |
| } | |
| start.on('click', function () { | |
| urlField.set('disabled', true); | |
| manual.set('disabled', true); | |
| flag = true; | |
| url = urlField.get('value'); | |
| automate = !manual.get('checked'); | |
| create(); | |
| }); | |
| end.on('click', function () { | |
| flag = false; | |
| destroy(); | |
| urlField.set('disabled', false); | |
| manual.set('disabled', false); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment