forked from binux/lixian.xunlei
/
share.html
218 lines (202 loc) · 8.45 KB
/
share.html
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
{% extends front.html %}
{% block title %}{{ options.site_name }} - {{ task.taskname }} - 迅雷离线下载分享{% end %}
{% block desc %}{% if task.tags %}TAGS:{{ ", ".join(task.tags) }}{% end %} UP主:{{ not task.invalid and email2name(task.creator) or "unknow" }}{% end %}
{% block more_head %}
<link rel="canonical" href="{{ request.protocol }}://{{ request.host }}/share/{{ task.id }}" />
{% end %}
{% block info %}
{% if handler.installed_userjs() %}
{% raw modules.TagList() %}
{% else %}
{% include info.html %}
{% end %}
<a class="goback" href="/"><div id="goback-button"><- 回到首页</div></a>
{% end %}
{% block list %}
<!--<div class="cross-cookie hidden" data-site="{{ options.cross_cookie_url }}" data-cookie="{{ cookie }}" data-version="{{ options.cross_cookie_version }}"></div>-->
<span class="infohash" style="float: right;">Hash: {{ task.cid }}</span>
<ul class="task-list">
<li class="push-top"></li>
<li class="share-task-item">
{% if task.status in ('waiting', 'downloading') %}
<div class="process-bar {{ task.status }}" style="width: {{ 100-task.process }}%"></div>
{% end %}
<div class="share-tname">{{ task.taskname }}</div>
<div class="info">
<span class="date">{{ task.createtime.strftime("%Y-%m-%d") }}</span>
<span class="file-size">{{ format_size(task.size) }}</span>
</div>
<div class="ext-info">
{% if task.status == "finished" %}
<div id="share-button" class="task-button">
<a href="/share/{{ task.id }}" target="_blank"><div>分享</div></a>
<div id="share-links" class="more-links" style="display: none;">
<a href="javascript:share_google();" title="分享到 Google+"><div class="task-button">Google+</div></a>
<a href="javascript:share_twitter();" title="分享到 Twitter+"><div class="task-button">Twitter</div></a>
<a href="javascript:share_sina();" title="分享到 新浪微博"><div class="task-button">新浪微博</div></a>
<a href="javascript:share_qq();" title="分享到 腾讯微博"><div class="task-button">腾讯微博</div></a>
<a href="javascript:share_douban();" title="分享到 豆瓣"><div class="task-button">豆瓣</div></a>
</div>
</div>
<div id="batch-button" class="task-button">
<div>批量下载</div>
<div id="batch-links" class="more-links" style="display: none;">
<!--<a href="#" onclick="copy_links(); return false;"><div class="task-button">copy</div></a>-->
<a href="#link-text" id="wget-button"><div class="task-button">wget</div></a>
<a href="#link-text" id="aria2-button"><div class="task-button">aria2 x6</div></a>
<a href="/export/{{ url_escape(options.site_name) }}_idm_{{ task.id }}_{{ url_escape(task.taskname.replace(" ", "_")) }}.ef2"><div class="task-button">IDM 导出</div></a>
</div>
</div>
{% else %}
<div class="task-button">
<a href="/share/{{ task.id }}" target="_blank"><div>{{ format_status(task.status) }}</div></a>
</div>
{% end %}
<span class="uploader">UP主: {{ not task.invalid and email2name(task.creator) or "unknow" }}</span>
{% if task.tags %}
<span class="tags">TAGS: {% raw modules.TagsModule(task.tags) %}</span>
{% end %}
</div>
<div class="clearfix"></div>
</li>
{% for file in files %}
<li class="file-item">
{% if file.status in ('waiting', 'downloading') %}
<div class="process-bar {{ file.status }}" style="width: {{ 100-file.process }}%"></div>
{% end %}
{% if file.lixian_url %}
<a class="file-title" href="{{ file.lixian_url }}" target="_blank" title="{{ file.title }}"><div class="tname"><span class="p1">{{ len(file.title) > 15 and file.title[:-15] or file.title }}</span><span class="p2">{{ len(file.title) > 15 and file.title[-15:] or "" }}</span></div></a>
{% else %}
<div class="tname"><span class="p1">{{ len(file.title) > 15 and file.title[:-15] or file.title }}</span><span class="p2">{{ len(file.title) > 15 and file.title[-15:] or "" }}</span></div>
{% end %}
<div class="info"><span class="file-size">{{ format_size(file.size) }}</span></div>
<div class="clearfix"></div>
</li>
{% end %}
<li class="push-bottom"></li>
</ul>
<div class="hidden"><textarea id="link-text" style="width: 700px; height: 320px;"> </textarea></div>
<div class="hidden">
<a href="#disabled_cross_cookie" id="disable-helper"></a>
<div id="disabled_cross_cookie">
<dl>
<dd>您已经禁用或尚未安装跨站Cookie脚本,无法使用浏览器直接下载。</dd>
<dt>
<ul>
<li><a href="javascript:$.fancybox.close();">好吧,我使用批量下载功能下载</a></li>
<li><a href="{{ options.cross_userscript }}" target="_blank">我要使用浏览器直接下载资源</a></li>
</ul>
</dt>
</dl>
</div>
</div>
{% end %}
{% block foot %}
<script>
function _gc(name) {
return document.getElementsByClassName(name);
}
var OnResize = function() {
var tnames = _gc("tname");
for(var i=0; i<tnames.length; i++) {
var tname = tnames[i];
if (tnames[i].offsetWidth-200 < tnames[i].firstChild.offsetWidth) {
tnames[i].lastChild.setAttribute("style", "right: 0;");
} else {
tnames[i].lastChild.removeAttribute("style");
}
}
}
OnResize();
window.onresize = OnResize;
$("#batch-button").hover(function() {
$("#batch-links").show();
}, function() {
$("#batch-links").hide();
});
$("#share-button").hover(function() {
$("#share-links").show();
}, function() {
$("#share-links").hide();
});
var alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
function escape_command(str) {
var result = "";
for (var i = 0; i < str.length; i++) {
if (alpha.indexOf(str[i]) == -1)
result += "\\"+str[i];
else
result += str[i];
}
return result;
}
function get_links() {
var result = [];
$.each($("a.file-title"), function(i, n) {
n = $(n);
result.push({url: n.attr("href"), title: n.text()});
});
return result;
}
function get_cookie() {
return "{{ cookie }}".split(";")[0];
}
function copy_links() {
var str = "";
$.each(get_links(), function(i, n) {
str += n.url+"\n";
});
$("#link-text").text(str);
}
function wget_links() {
var str = "";
var cookie = get_cookie();
$.each(get_links(), function(i, n) {
str += "wget -c -O "+escape_command(n.title)+" --header 'Cookie:"+cookie+";' '"+n.url+"'\n";
});
$("#link-text").text(str);
}
function multiple_server_fix(url) {
return "'"+url.replace("gdl", "'{gdl,dl.{f,g,h,i,twin}}'")+"'";
}
function aria2_links() {
var str = "";
var cookie = get_cookie();
$.each(get_links(), function(i, n) {
str += "aria2c -c -s6 -x5 -j30 --out "+escape_command(n.title)+" --header 'Cookie:"+cookie+";' "+multiple_server_fix(n.url)+"\n";
});
$("#link-text").text(str);
}
var w=480;
var h=480;
var x=Number((window.screen.width-w)/2);
var y=Number((window.screen.height-h)/2);
var share_url = {% raw json_encode(request.protocol+"//"+request.host+"/share/"+str(task.id)) %};
var share_title = {% raw json_encode(task.taskname+u" - 迅雷离线下载分享 - "+options.site_name) %};
function share_google() {
window.open("https://plusone.google.com/_/+1/confirm?url="+share_url+"&title="+share_title,"","width="+w+",height="+h+",left="+x+",top="+y+",scrollbars=no");
}
function share_twitter() {
window.open("https://twitter.com/intent/tweet?source=webclient&text="+share_title+"&url="+share_url,"","width="+w+",height="+h+",left="+x+",top="+y+",scrollbars=no");
}
function share_sina() {
window.open("http://v.t.sina.com.cn/share/share.php?url="+share_url+"&title="+share_title,"","width="+w+",height="+h+",left="+x+",top="+y+",scrollbars=no");
}
function share_qq() {
window.open("http://v.t.qq.com/share/share.php?url="+share_url+"&title="+share_title,"","width="+w+",height="+h+",left="+x+",top="+y+",scrollbars=no");
}
function share_douban() {
window.open("http://www.douban.com/recommend/?url="+share_url+"&title="+share_title,"","width="+w+",height="+h+",left="+x+",top="+y+",scrollbars=no");
}
$("#wget-button").fancybox({onStart: wget_links});
$("#aria2-button").fancybox({onStart: aria2_links});
$("#disable-helper").fancybox();
{% if handler.disabled_userjs() %}
$("a.file-title").click(function() {
$("#disable-helper").click();
return false;
});
{% end %}
{% include xss.js %}
</script>
{% end %}