-
Notifications
You must be signed in to change notification settings - Fork 12
/
list.php
210 lines (191 loc) · 6.92 KB
/
list.php
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
<?php view::layout('layout')?>
<?php
function file_ico($item){
$ext = strtolower(pathinfo($item['name'], PATHINFO_EXTENSION));
if(in_array($ext,['bmp','jpg','jpeg','png','gif'])){
return "image";
}
if(in_array($ext,['mp4','mkv','webm','avi','mpg', 'mpeg', 'rm', 'rmvb', 'mov', 'wmv', 'mkv', 'asf'])){
return "ondemand_video";
}
if(in_array($ext,['ogg','mp3','wav'])){
return "audiotrack";
}
return "insert_drive_file";
}
?>
<?php view::begin('content');?>
<div class="mdui-container-fluid">
<?php if($head):?>
<div class="mdui-typo" style="padding: 20px;">
<?php e($head);?>
</div>
<?php endif;?>
<style>
.thumb .th{
display: none;
}
.thumb .mdui-text-right{
display: none;
}
.thumb .mdui-list-item a ,.thumb .mdui-list-item {
width:217px;
height: 230px;
float: left;
margin: 10px 10px !important;
}
.thumb .mdui-col-xs-12,.thumb .mdui-col-sm-7{
width:100% !important;
height:230px;
}
.thumb .mdui-list-item .mdui-icon{
font-size:100px;
display: block;
margin-top: 40px;
color: #7ab5ef;
}
.thumb .mdui-list-item span{
float: left;
display: block;
text-align: center;
width:100%;
position: absolute;
top: 180px;
}
</style>
<div class="nexmoe-item">
<div class="mdui-row">
<ul class="mdui-list">
<li class="mdui-list-item th">
<div class="mdui-col-xs-12 mdui-col-sm-7">文件 <i class="mdui-icon material-icons icon-sort" data-sort="name" data-order="downward">expand_more</i></div>
<div class="mdui-col-sm-3 mdui-text-right">修改时间 <i class="mdui-icon material-icons icon-sort" data-sort="date" data-order="downward">expand_more</i></div>
<div class="mdui-col-sm-2 mdui-text-right">大小 <i class="mdui-icon material-icons icon-sort" data-sort="size" data-order="downward">expand_more</i></div>
</li>
<?php if($path != '/'):?>
<li class="mdui-list-item mdui-ripple">
<a href="<?php echo get_absolute_path($root.$path.'../');?>">
<div class="mdui-col-xs-12 mdui-col-sm-7">
<i class="mdui-icon material-icons">arrow_upward</i>
..
</div>
<div class="mdui-col-sm-3 mdui-text-right"></div>
<div class="mdui-col-sm-2 mdui-text-right"></div>
</a>
</li>
<?php endif;?>
<?php foreach((array)$items as $item):?>
<?php if(!empty($item['folder'])):?>
<li class="mdui-list-item mdui-ripple">
<a href="<?php echo get_absolute_path($root.$path.rawurlencode($item['name']));?>">
<div class="mdui-col-xs-12 mdui-col-sm-7 mdui-text-truncate">
<i class="mdui-icon material-icons">folder_open</i>
<span><?php e($item['name']);?></span>
</div>
<div class="mdui-col-sm-3 mdui-text-right"><?php echo date("Y-m-d H:i:s", $item['lastModifiedDateTime']);?></div>
<div class="mdui-col-sm-2 mdui-text-right"><?php echo onedrive::human_filesize($item['size']);?></div>
</a>
</li>
<?php else:?>
<li class="mdui-list-item file mdui-ripple">
<a href="<?php echo get_absolute_path($root.$path).rawurlencode($item['name']);?>" target="_blank">
<div class="mdui-col-xs-12 mdui-col-sm-7 mdui-text-truncate">
<i class="mdui-icon material-icons"><?php echo file_ico($item);?></i>
<span><?php e($item['name']);?></span>
</div>
<div class="mdui-col-sm-3 mdui-text-right"><?php echo date("Y-m-d H:i:s", $item['lastModifiedDateTime']);?></div>
<div class="mdui-col-sm-2 mdui-text-right"><?php echo onedrive::human_filesize($item['size']);?></div>
</a>
</li>
<?php endif;?>
<?php endforeach;?>
</ul>
</div>
</div>
<?php if($readme):?>
<div class="mdui-typo mdui-shadow-3" style="padding: 20px;margin: 20px; 0">
<div class="mdui-chip">
<span class="mdui-chip-icon"><i class="mdui-icon material-icons">face</i></span>
<span class="mdui-chip-title">README.md</span>
</div>
<?php e($readme);?>
</div>
<?php endif;?>
</div>
<script>
$ = mdui.JQ;
$.fn.extend({
sortElements: function (comparator, getSortable) {
getSortable = getSortable || function () { return this; };
var placements = this.map(function () {
var sortElement = getSortable.call(this),
parentNode = sortElement.parentNode,
nextSibling = parentNode.insertBefore(
document.createTextNode(''),
sortElement.nextSibling
);
return function () {
parentNode.insertBefore(this, nextSibling);
parentNode.removeChild(nextSibling);
};
});
return [].sort.call(this, comparator).each(function (i) {
placements[i].call(getSortable.call(this));
});
}
});
function downall() {
let dl_link_list = Array.from(document.querySelectorAll("li a"))
.map(x => x.href) // 所有list中的链接
.filter(x => x.slice(-1) != "/"); // 筛选出非文件夹的文件下载链接
let blob = new Blob([dl_link_list.join("\r\n")], {
type: 'text/plain'
}); // 构造Blog对象
let a = document.createElement('a'); // 伪造一个a对象
a.href = window.URL.createObjectURL(blob); // 构造href属性为Blob对象生成的链接
a.download = "folder_download_link.txt"; // 文件名称,你可以根据你的需要构造
a.click() // 模拟点击
a.remove();
}
function thumb(){
if($('.mdui-fab i').text() == "apps"){
$('.mdui-fab i').text("format_list_bulleted");
$('.nexmoe-item').removeClass('thumb');
$('.nexmoe-item .mdui-icon').show();
$('.nexmoe-item .mdui-list-item').css("background","");
}else{
$('.mdui-fab i').text("apps");
$('.nexmoe-item').addClass('thumb');
$('.mdui-col-xs-12 i.mdui-icon').each(function(){
if($(this).text() == "image" || $(this).text() == "ondemand_video"){
var href = $(this).parent().parent().attr('href');
var thumb =(href.indexOf('?') == -1)?'?t=220':'&t=220';
$(this).hide();
$(this).parent().parent().parent().css("background","url("+href+thumb+") no-repeat center top");
}
});
}
}
$(function(){
$('.file a').each(function(){
$(this).on('click', function () {
var form = $('<form target=_blank method=post></form>').attr('action', $(this).attr('href')).get(0);
$(document.body).append(form);
form.submit();
$(form).remove();
return false;
});
});
$('.icon-sort').on('click', function () {
let sort_type = $(this).attr("data-sort"), sort_order = $(this).attr("data-order");
let sort_order_to = (sort_order === "less") ? "more" : "less";
$('li[data-sort]').sortElements(function (a, b) {
let data_a = $(a).attr("data-sort-" + sort_type), data_b = $(b).attr("data-sort-" + sort_type);
let rt = data_a.localeCompare(data_b, undefined, {numeric: true});
return (sort_order === "more") ? 0-rt : rt;
});
$(this).attr("data-order", sort_order_to).text("expand_" + sort_order_to);
});
});
</script>
<a href="javascript:thumb();" class="mdui-fab mdui-fab-fixed mdui-ripple mdui-color-theme-accent"><i class="mdui-icon material-icons">format_list_bulleted</i></a>
<?php view::end('content');?>