Commit b480ea74 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

page for selecting models

parent 827d0e58
$(function(){
var url = 'select.php';
$.ajax({
url: url,
success: function(response){
List = response;
parse_list(response);
}
});
});
function parse_list(res){
$(res).find("set").each(function(){
var name = $(this).attr("name");
var mlist = $("<ul>",{id:"s_"+name});
$("#content").append("<h3>"+name+"</h3>").append(mlist);
$(this).find("model").each(function(){
var mname = $(this).attr("name");
var item = [
'<li>',
' <a href=\'viewer.html?basepath=models/_all/'+name+'&path='+mname+'\'>'+mname+'</a>',
'</li>'
].join('\n');
mlist.append($(item));
});
});
}
\ No newline at end of file
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>x3d models index</title>
<!-- build:css css/index.css -->
<!-- bower:css -->
<!-- endbower -->
<link rel='stylesheet' type='text/css' href='js/leaflet/leaflet.css'></link>
<link rel='stylesheet' type='text/css' href='js/select.css'></link>
<!-- endbuild -->
<!-- build:js js/index.js -->
<!-- bower:js -->
<script src='bower_components/jquery/dist/jquery.js'></script>
<!-- endbower -->
<script type='text/javascript' src='js/jquery-ui/jquery-ui.js'></script>
<script type='text/javascript' src='js/select.js'></script>
<!-- endbuild -->
</head>
<body>
<div id="content">
</div>
</body>
</html>
<?php
$base = "models/_all";
$showall = false;
if (isset($_GET['showall'])){
$showall = true;
}
$series = selective_scandir($base,false);
$res = "";
foreach($series as $set){
$models_path = "$base/$set";
$models = selective_scandir($models_path,$showall);
$res .= "<set name='$set'>\n";
foreach($models as $model){
$res .= "\t<model name='$model'>\n";
$res .= "\t</model>\n";
}
$res .= "</set>\n";
}
return_xml($res);
//functions
function selective_scandir($path,$showall){
$results = Array();
$contents = scandir($path);
foreach($contents as $item){
if ($item!='.'&&$item!='..'&&is_dir("$path/$item")){
if ($showall){
array_push($results,$item);
}else{
if (($item[0]!=".")&&($item[0]!="_")){
array_push($results,$item);
}
}
}
}
return $results;
}
function return_xml($str){
$str = "<?xml version='1.0' standalone='yes'?>\n<Document>\n$str</Document>";
header("Content-Type: text/xml");
header("Content-Length: ".strlen($str)."\n");
header("Pragma: no-cache\n");
printf($str);
}
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment