h5ai/src/_h5ai/client/js/inc/ext/peer5.js
2015-04-27 01:53:34 +02:00

41 lines
950 B
JavaScript

modulejs.define('ext/peer5', ['_', '$', 'core/settings'], function (_, $, allsettings) {
var settings = _.extend({
enabled: false,
id: 'z142i5n5qypq4cxr'
}, allsettings.peer5);
function init() {
if (!settings.enabled) {
return;
}
var peer5js = '//api.peer5.com/peer5.js?id=' + settings.id;
// load peer5 with caching
$.ajax({
url: peer5js,
dataType: 'script',
cache: true
});
// attach to file items, once the DOM is ready
$(function () {
$('body').on('click', '.item.file > a', function (ev) {
if (window.peer5) {
ev.preventDefault();
var url = ev.currentTarget.href;
window.peer5.download(url);
return false;
}
});
});
}
init();
});