Skip to content

Instantly share code, notes, and snippets.

@pkrumins
Created August 28, 2011 09:30
Show Gist options
  • Save pkrumins/1176472 to your computer and use it in GitHub Desktop.
Save pkrumins/1176472 to your computer and use it in GitHub Desktop.
var $ = require('jquery-browserify');
$(window).ready(function () {
if (!window.navigator.userAgent.match(/chrome|chromium/i)) {
$('<div>')
.addClass('alert')
.append(
$('<img>').attr('src', '/img/chrome.png'),
$('<div>').text(
"You don't appear to be using chrome, "
+ "so this app might not work."
)
)
.prependTo(document.body)
.hide()
.slideDown(400)
;
}
var nko_button = '<iframe src="http://nodeknockout.com/iframe/replicants" frameborder=0 scrolling=no allowtransparency=true width=115 height=25></iframe>';
var div = $('<div>').append(nko_button);
var iframe = $('<iframe>')
.attr({
src : 'about:blank',
width : 800,
height : 300
})
.hide()
.insertBefore($('#example0'))
;
var loading = $('<div>')
.addClass('loading')
.text('loading')
.hide()
.insertBefore($('#example0'))
;
$('#run').click(function () {
var src = $('#source').val();
loading.fadeIn(100);
var i = 0;
var iv = setInterval(function () {
loading.text('loading.' + Array(i++ % 3 + 1).join('.'))
}, 500);
iframe
.attr('src', '/frame/' + escape(src))
.attr('height', src.split('\n').length * 20 * 0.87 + 80)
.slideDown(400)
.load(function () {
clearInterval(iv);
loading.fadeOut(800);
})
;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment