<script type=
"text/javascript"
>
$(
function
(){
var
_gogo;
var
start_btn = $(
"#start"
);
start_btn.click(
function
(){
time=0;
$.getJSON('/oa/
public
/index.php/staffinfo/question/getdata/',
function
(json){
if
(json){
var
obj =
eval
(json);
var
len = obj['ids'].length;
_gogo = setInterval(
function
(){
var
numrand = getRandomArrayElements(obj['ids'],5);
var
text='';
time+=1;
for
(
var
i=0;i<numrand.length;i++)
{
text+='<span
class
=
"realname"
style=
"margin-left: 25%;float: left;color: 2a475c;"
>'+obj['question'][numrand[i]]['realname']+'</span><span
class
=
"phone"
style=
"margin-right: 25%; float: right;color: orangered;"
> '+obj['question'][numrand[i]]['phone']+
"</span><br><br>"
}
$(
"#roll"
).html(text);
if
(time>500){
clearInterval(_gogo);
}
},1);
start_btn.hide();
$(
"#content"
).css('display','');
}
else
{
$(
"#roll"
).html('系统找不到数据源,请先导入数据。');
}
});
});
});
function
getRandomArrayElements(arr,
count
) {
var
shuffled = arr.slice(0), i = arr.length, min = i -
count
, temp, index;
while
(i-- > min) {
index = Math.
floor
((i + 1) * Math.random());
temp = shuffled[index];
shuffled[index] = shuffled[i];
shuffled[i] = temp;
}
return
shuffled.slice(min);
}
</script>