You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
information-system/application/views/bootstrap/cache_url.php

87 lines
2.5 KiB
PHP

<script language="javascript">
function batch_update_cache(url, index) {
var msg_obj="#cache" + index;
$(msg_obj).html("\u7a0d\u7b49...");
$.ajax({
type: "post",
dataType: "json",
url: "/info.php/information/update_cache/",
data: {
"cache_url": url
},
success: function(data, textStatus) {
for (var key in data) {
if (data[key].name == "ok") {
$(msg_obj).html(data[key].value)
} else {
$(msg_obj).html(data[key].value)
}
}
create_cache_data(++index);
},
error: function() {
$( msg_obj).html("<a href='javascript:void(0);' onclick='create_cache_data("+index+");' >发生错误,请重试</a>");
create_cache_data(++index);
}
})
}
function create_cache_data(index){
if ($('#cache_url' + index).length > 0) {
if ($('#cache' + index).html() != '\u66f4\u65b0\u9759\u6001\u9875\u9762\u6210\u529f\uff01') {
url=$('#cache_url' + index).html();
setTimeout("batch_update_cache('"+url+"',"+index+")",5000);
}
}
}
//$(document).ready(function() {
//batch_update_cache($('#cache_url1').html(),1);
//});
</script>
<div class="row-fluid">
<div class="span1">
</div>
<div class="span10">
<table class="table table-striped">
<thead>
<tr>
<th class="span1">#</th>
<th class="span9">URL</th>
<th class="span2">更新进度</th>
</tr>
</thead>
<tbody>
<?php
$i=0;
foreach ($all_information as $key => $info) {
if ($info->ic_status == 1 && !empty($info->ic_url)) {
$i++;
?>
<tr>
<td><?php echo $i; ?></td>
<td id="cache_url<?php echo $i; ?>" name="cache_url<?php echo $i ; ?>" class="cache_url"><?php echo $info->ic_url; ?></a></td>
<td id="cache<?php echo $i ; ?>" name="cache<?php echo $i ; ?>"><i class="icon-refresh"></i></td>
</tr>
<?php }
} ?>
</tbody>
</table>
</div>
<div class="span1">
<a href="javascript:void(0);" class="btn btn-danger" onclick="batch_update_cache($('#cache_url1').html(),1);">开始更新</a>
</div>
</div>