mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-06-08 02:24:39 -04:00
41 lines
950 B
JavaScript
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();
|
|
});
|