<script type="text/javascript">
//generic function to get selector
function g(selector){
var method=selector.substr(0,1)=='.'?'getElementsByClassName':'getElementById';
return document[method](selector.substr(1));
}
//output all photoes
var data=data;
function addPhotoes(){
var template=g("#wrap").innerHTML;
var html=[];
for(var s=0; s<data.length;s++){
var _html=template
.replace('{{index}}',s)
.replace('{{img}}',data[s].img)
.replace('{{caption}}',data[s].caption)
.replace('{{desc}}',data[s].desc);
html.push(_html);
}
g("#wrap").innerHTML=html.join("");
//rsort(1);
}
addPhotoes();
//sort photoes
function rsort(n){
var photo-center=g("#photo_" + n);
photo-center.className+=" photo-center";
}
</script>
rsort里面的photo-center变量不能这么写,改成photo_center