-
Notifications
You must be signed in to change notification settings - Fork 0
/
huashu-detail.js
128 lines (104 loc) · 2.94 KB
/
huashu-detail.js
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
function loadScript(url, callback) {
var script = document.createElement("script");
script.type ="text/javascript";
// IE
if (script.readyState) {
script.onreadystatechange = function () {
if (script.readyState =="loaded"|| script.readyState =="complete") {
script.onreadystatechange = null;
callback();
}
};
} else { // others
script.onload = function () {
callback();
};
}
script.src = url;
document.body.appendChild(script);
}
function is_youku(url) {
var urlReg = /(?:id_)(.*)(?:.html)/,
urlReg2 = /(?:v_playlist\/f)(.*)(?:o1p\d.html)/,
urlReg3 = /(?:youku.com\/embed\/)(.*)/,
match = false;
//prefix = 'http://v.youku.com/player/getPlayList/VideoIDS/';
if (urlReg.test(url)) {
match = urlReg.exec(url);
} else if (urlReg2.test(url)) {
match = urlReg2.exec(url);
} else if (urlReg3.test(url)) {
match = urlReg3.exec(url);
} else {
return false;
}
if (match.length === 2) {
return match[1];
} else {
return false;
}
}
function getInfo(){
//var video = $("#video");
var host = window.location.protocol +"//"+ window.location.host;
if(window.location.port != '') {
host += ":"+window.location.port;
}
// var url = video.attr("src");
// var youku = is_youku(url);
// if(youku) {
// url = "http://v.youku.com/v_show/id_" + youku + ".html";
// }
//http://apiontime.wasu.cn/Auth/getVideoUrl?id=7802353
//&key=f2e31a413d6263cfe7a341675bafff53
//&url=aHR0cDovL3dhcHZvZC1hbC53YXN1LmNuL3Bjc2FuMTIvbWFtcy92b2QvMjAxNjA4LzExLzE2LzIwMTYwODExMTYxNzI3NzM2MWUzMDMxM2JfZGE0OTYxMDQuZmx2
//&type=jsonp
if(videoInfo.url.substr(0,4) == 'http') {
var info ={
isok: true,
url: videoInfo.url,
type:'detail',
};
console.log(info);
if (typeof(WebViewBridgeAndroid) != "undefined" && WebViewBridgeAndroid) {
WebViewBridgeAndroid.send(JSON.stringify(info));
// $("#info").text(JSON.stringify(e));
} else {
console.log("no WebViewBridgeAndroid");
}
return;
}
var ts =+ (new Date);
var url = 'http://apiontime.wasu.cn/Auth/getVideoUrl?id=' + videoInfo.vid +'&key='+videoInfo.key+'&type=jsonp&url='+videoInfo.url+ '&_=' + ts;
$.ajax({
url: url,
dataType: 'JSONP',
success: function(param) {
console.log(param);
var info ={
isok: true,
url: param,
type:'detail',
};
console.log(info);
if (typeof(WebViewBridgeAndroid) != "undefined" && WebViewBridgeAndroid) {
WebViewBridgeAndroid.send(JSON.stringify(info));
// $("#info").text(JSON.stringify(e));
} else {
console.log("no WebViewBridgeAndroid");
}
},
error: function(param) {
console.log(param);
if (typeof(WebViewBridgeAndroid) != "undefined" && WebViewBridgeAndroid) {
WebViewBridgeAndroid.send(JSON.stringify({type:'detail',isok:false,}));
// $("#info").text(JSON.stringify(e));
} else {
console.log("no WebViewBridgeAndroid");
}
}
});
}
loadScript("http://leapar.github.io/jquery.min.js", function () {
getInfo();
});