metanohi/prestatic/extra.js

45 lines
1.3 KiB
JavaScript
Raw Normal View History

2011-07-08 15:32:28 +02:00
/*
To the extent possible under law, Niels Serup has waived all copyright and
related or neighboring rights to this file. This file is available under the
Creative Commons Zero 1.0 license, see
http://creativecommons.org/publicdomain/zero/1.0/
This JavaScript file contains misc. code snippets designed to add extra
features to a website. Not loading it will not make a website depending on it
stop working.
*/
add_external_document_writing_script = function(url, elem) {
2011-07-14 22:28:37 +02:00
var orig_write, content, done;
orig_write = document.write;
content = ''
2011-07-08 15:32:28 +02:00
document.write = function(msg) {
content += msg + '\n';
}
2011-07-14 22:28:37 +02:00
done = function() {
document.write = orig_write;
2011-07-08 15:32:28 +02:00
elem.innerHTML = content;
}
ns = document.createElement('script');
ns.type = 'text/javascript';
ns.src = url;
ns.onload = function() {
done();
}
2011-07-14 22:28:37 +02:00
ns.onreadystatechange = function() {
2011-07-08 15:32:28 +02:00
if (this.readyState == 'complete')
done();
}
document.body.appendChild(ns);
};
add_fsf_widget = function(associate_id) {
fsf_widget_size = 'normal';
fsf_associate_id = associate_id + '';
2011-07-14 22:28:37 +02:00
add_external_document_writing_script(
'http://www.fsf.org/graphics/widget/global/widget.js',
document.getElementById('fsfextern'));
2011-07-08 15:32:28 +02:00
};