forked from OpenNHP/opennhp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathduoshuo.js
More file actions
41 lines (32 loc) · 831 Bytes
/
Copy pathduoshuo.js
File metadata and controls
41 lines (32 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
var $ = require('jquery');
var UI = require('../../../js/core');
function duoshuoInit() {
var $dsThread = $('.ds-thread');
var dsShortName = $dsThread.parent('[data-am-widget="duoshuo"]').
attr('data-ds-short-name');
var dsSrc = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//static.duoshuo.com/embed.js';
if (!$dsThread.length || !dsShortName) {
return;
}
window.duoshuoQuery = {
short_name: dsShortName
};
// 已经有多说脚本
if ($('script[src="' + dsSrc + '"]').length) {
return;
}
var $dsJS = $('<script>', {
async: true,
type: 'text/javascript',
src: dsSrc,
charset: 'utf-8'
});
$('body').append($dsJS);
}
$(window).on('load', duoshuoInit);
module.exports = UI.duoshuo = {
VERSION: '2.0.1',
init: duoshuoInit
};