📄 正在查看:admin/view/default/plugin_index.htm
大小:6,747 字节 · 修改:2014-01-24 01:15:24 · 行数:197
1{inc:header.htm}
2
3<div class="m">
4 <div class="head">
5 <dl>
6 <dd class="on">{$_title}</dd>
7 <dd>在线获取</dd>
8 </dl>
9 </div>
10 <div class="p c2">
11 <div class="cc" id="plugin">
12 {if:empty($plugins[enable]) && empty($plugins[disable]) && empty($plugins[not_install])}
13 <div class="sky warning bnote" style="margin-top:8px"><i></i><b>暂无插件</b></div>
14 {else}
15
16 {loop:$plugins[enable] $v $k}
17 <div class="plu cf">
18 <div class="plu_l">
19 <p class="plu_ico"{if:isset($v['is_show'])} style="background:url(../{$core}/plugin/{$k}/show.jpg)"{/if}></p>
20 </div>
21 <div class="plu_c">
22 <p class="plu_cont plu_b">{$v[name]}({$k})</p>
23 <p class="plu_bottom" plugin="{$k}" version="{$v[version]}">
24 <a class="but2 disabled">停用</a>
25 {if:!empty($v['setting'])}<a class="but2" href="javascript:parent.oneTab('{$v[setting]}');">设置</a>{/if}
26 </p>
27 </div>
28 <div class="plu_r">
29 <p class="plu_cont plu_i">{$v[brief]}</p>
30 <p class="plu_bottom"><b>版本号:{$v[version]}</b> <b>作者: <a href="{$v[authorurl]}" target="_blank">{$v[author]}</a></b> <b>最近更新:{$v[update]}</b></p>
31 </div>
32 </div>
33 {/loop}
34
35 {loop:$plugins[disable] $v $k}
36 <div class="plu cf">
37 <div class="plu_l">
38 <p class="plu_ico"{if:isset($v['is_show'])} style="background:url(../{$core}/plugin/{$k}/show.jpg)"{/if}></p>
39 </div>
40 <div class="plu_c">
41 <p class="plu_cont plu_b">{$v[name]}({$k})</p>
42 <p class="plu_bottom" plugin="{$k}" version="{$v[version]}">
43 {if:!empty($v['setting']) && !empty($v['setting_ok'])}
44 <a class="but2" href="javascript:parent.oneTab('{$v[setting]}');">设置</a>
45 {else}
46 <a class="but2 enable">启用</a>
47 {/if}
48 <a class="but2 del">删除</a>
49 </p>
50 </div>
51 <div class="plu_r">
52 <p class="plu_cont plu_i">{$v[brief]}</p>
53 <p class="plu_bottom"><b>版本号:{$v[version]}</b> <b>作者: <a href="{$v[authorurl]}" target="_blank">{$v[author]}</a></b> <b>最近更新:{$v[update]}</b></p>
54 </div>
55 </div>
56 {/loop}
57
58 {loop:$plugins[not_install] $v $k}
59 <div class="plu cf">
60 <div class="plu_l">
61 <p class="plu_ico"{if:isset($v['is_show'])} style="background:url(../{$core}/plugin/{$k}/show.jpg)"{/if}></p>
62 </div>
63 <div class="plu_c">
64 <p class="plu_cont plu_b">{$v[name]}({$k})</p>
65 <p class="plu_bottom" plugin="{$k}" version="{$v[version]}">
66 <a class="but2 install">安装</a>
67 <a class="but2 del">删除</a>
68 </p>
69 </div>
70 <div class="plu_r">
71 <p class="plu_cont plu_i">{$v[brief]}</p>
72 <p class="plu_bottom"><b>版本号:{$v[version]}</b> <b>作者: <a href="{$v[authorurl]}" target="_blank">{$v[author]}</a></b> <b>最近更新:{$v[update]}</b></p>
73 </div>
74 </div>
75 {/loop}
76
77 {/if}
78 </div>
79 <div class="cc un" id="twcms_app">
80 <div class="sky warning bnote"><i></i><b>玩命加载中<font id="loading">...</font></b></div>
81 </div>
82 </div>
83</div>
84<script type="text/javascript">
85setPlurWidth();
86$(window).resize(setPlurWidth);
87$("#plugin .plu_c .plu_bottom a").each(function() {
88 if(!this.href) this.href = "javascript:;";
89});
90
91//检测插件是否需要升级
92setTimeout(function() {
93 var plu_arr = new Array();
94 $("#plugin>.plu>.plu_c>.plu_bottom").each(function(i) {
95 if(i >= 20) return;
96 plu_arr[i] = $(this).attr("plugin") + "-" + $(this).attr("version");
97 });
98 $.getScript("http://www.twcms.com/app/?go=plugin_upgrade&s="+plu_arr.join(","));
99}, 1000)
100
101//停用
102$(".disabled").click(function(){
103 twAjax.postd("index.php?u=plugin-disabled-ajax-1", {"dir" : $(this).parent().attr("plugin")}, function(data){
104 twAjax.alert(data);
105 if(window.twData.err==0) setTimeout(function(){window.location.reload();}, 1000);
106 });
107});
108
109//启用
110$(".enable").click(function(){
111 enable($(this).parent().attr("plugin"));
112});
113
114//安装
115$(".install").click(function(){
116 twAjax.postd("index.php?u=plugin-install-ajax-1", {"dir" : $(this).parent().attr("plugin")}, function(data){
117 twAjax.alert(data);
118 if(window.twData.err==0) setTimeout(function(){window.location.reload();}, 1000);
119 });
120});
121
122//删除
123$(".del").click(function(){
124 var dir = $(this).parent().attr("plugin");
125 twAjax.confirm("删除不可恢复,确定删除“<font color='red'>"+$(this).parent().parent().children(".plu_b").html()+"</font>”?", function(){
126 twAjax.postd("index.php?u=plugin-delete-ajax-1", {"dir" : dir}, function(data){
127 window.twErr = true;
128 twAjax.alert(data);
129 $(".ajaxtips u").click(function(){window.location.reload();});
130 if(window.twData.err==0) setTimeout(function(){window.location.reload();}, 1000);
131 });
132 });
133});
134
135//加载效果
136var int;
137function loading() {
138 var dot = '';
139 int = setInterval(function(){
140 dot += '.';
141 if(dot.length > 6) dot = '.';
142 $("#loading").html(dot);
143 }, 50);
144}
145
146//在线获取
147$(".head dd:eq(1)").one("click", function() {
148 loading();
149 $.getScript("http://www.twcms.com/app/?go=plugin");
150});
151
152//在线安装
153function install_plugin(dir) {
154 twAjax.confirm("玩命下载 <font color='red'>"+dir+"</font> 中<font id='loading'>......</font>", function(){});
155 loading();
156 $("#okA").remove();
157
158 $.getScript("index.php?u=plugin-install_plugin-dir-" + dir, function(){
159 clearInterval(int);
160 if(typeof err == 'number' && !err && $("#install_enable").length == 0) {
161 $("#noA").after('<a id="install_enable" class="but3" href="javascript:;">启用</a>');
162 $("#install_enable").click(function() { enable(dir); });
163 }
164 //只要在线安装过都重新加载一下
165 $(".head dd:eq(0)").click(function(){ window.location.reload(); });
166 });
167}
168
169//在线升级
170function upgrade(dir) {
171 twAjax.confirm("玩命下载 <font color='red'>"+dir+"</font> 中<font id='loading'>......</font>", function(){});
172 loading();
173 $("#okA").remove();
174
175 $.getScript("index.php?u=plugin-upgrade-dir-" + dir, function(){
176 clearInterval(int);
177 $("#noA").html("我知道了");
178 setTimeout(function(){window.location.reload();}, 2000);
179 });
180}
181
182//设置插件展示宽度 PS: CSS3 时代的到来就可以不使用这么笨的方法了
183function setPlurWidth() {
184 $(".plu_r").width(Math.max(500, $(".plu:visible").width() - $(".plu_l:visible").outerWidth(true) - $(".plu_c:visible").outerWidth(true) - 15));
185}
186
187//启用
188function enable(dir) {
189 twAjax.postd("index.php?u=plugin-enable-ajax-1", {"dir" : dir}, function(data){
190 twAjax.alert(data);
191 if(window.twData.err==0) setTimeout(function(){window.location.reload();}, 1000);
192 });
193}
194</script>
195</body>
196</html>
197