Skip to content

Instantly share code, notes, and snippets.

@ekashida
Created May 15, 2012 22:51
Show Gist options
  • Save ekashida/2705760 to your computer and use it in GitHub Desktop.
Save ekashida/2705760 to your computer and use it in GitHub Desktop.
app creation/deletion without cl
iframe {
display: block;
}
<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>
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