metanohi/prestatic/extra.js

43 lines
1.3 KiB
JavaScript

/*
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) {
document.orig_write = document.write
var content = ''
document.write = function(msg) {
content += msg + '\n';
}
var done = function() {
document.write = document.orig_write;
elem.innerHTML = content;
}
ns = document.createElement('script');
ns.type = 'text/javascript';
ns.src = url;
ns.onload = function() {
done();
}
ns.onreadystatechange= function() {
if (this.readyState == 'complete')
done();
}
document.body.appendChild(ns);
};
add_fsf_widget = function(associate_id) {
fsf_widget_size = 'normal';
fsf_associate_id = associate_id + '';
add_external_script('http://www.fsf.org/graphics/widget/global/widget.js',
document.getElementById('fsfextern'));
};