0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-24 01:57:56 +01:00

started with file manager / viewer

This commit is contained in:
Rick Companje 2014-12-09 21:13:39 +01:00
parent c6b6a3c448
commit 58b930cefa
3 changed files with 152 additions and 0 deletions

26
www/viewer/css/style.css Normal file
View File

@ -0,0 +1,26 @@
body {
font-family: Abel, Arial;
-webkit-user-select: none; /* webkit (safari, chrome) browsers */
-moz-user-select: none; /* mozilla browsers */
-khtml-user-select: none; /* webkit (konqueror) browsers */
-ms-user-select: none; /* IE10+ */
}
div.item {
width:300px;
height:260px;
border:1px solid black;
display: inline-block;
overflow: hidden;
background-color: white;
margin-right: 5px;
}
div.item.selected {
background-color: #7cf;
}
div.item input[type='checkbox'] {
position: absolute;
}

22
www/viewer/index.html Normal file
View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<title>Doodle3D</title>
<link href="css/style.css" rel="stylesheet" media="screen">
</head>
<body>
Actions:
<button onclick="selectAll()">Select all</button>
<button onclick="deselectAll()">Deselect all</button>
<button onclick="deleteSelectedSketches()">Delete</button>
<hr>
<form>
<div id="svgContainer"></div>
</form>
<script src="../js/libs/jquery-1-9-1.min.js"></script>
<script src="js/main.js"></script>
</body>
</html>

104
www/viewer/js/main.js Normal file
View File

@ -0,0 +1,104 @@
var api = 'http://10.0.0.40/d3dapi/sketch/';
$.get(api+'list', function(data) { //?id=00003
if (data.status=='success') {
var list = data.data.list;
loadSketch(list, function() {
console.log('done');
});
}
// numSketches = data.data.number_of_sketches;
// loadSketch(1,function() {
// console.log('done');
// });
});
function loadSketch(list,cb) {
// console.log('loadSketch',list.length);
var item = list.pop();
console.log(item);
if (list.length>0) {
loadSketch(list,function() {
cb();
})
}
// if (num<=numSketches) {
// $.get(api+'?id='+num, function(data) {
// if (data.status=='success') {
// console.log('loaded',num)
// addItem(num,data.data.data);
// } else {
// console.log('failed to load',num)
// }
// loadSketch(num+1,function() {
// cb();
// });
// });
// // cb();
// } else {
// cb();
// }
// } else {
// console.log('test')
// cb();
// }
}
function addItem(num,svgData) {
var path = svgData.split('d="')[1].split('"')[0];
var item = $('<div class="item" data="'+num+'">');
var svg = '<svg viewBox="0 0 640 540"><path fill="none" stroke="black" stroke-width="2" d="'+path+'"></path></svg>';
item.click(function() {
$(this).toggleClass('selected');
})
item.append(svg);
$('#svgContainer').append(item);
//''+num+'</div>');
}
function deleteSelectedSketches() {
if (confirm('Do you want to delete '+$('.item.selected').length+' drawings?')) {
$('.item.selected').each(function() {
var id = $(this).attr('data');
$.post(api+'delete'+id, {id:id}, function(data) {
console.log(data);
});
})
$('.item.selected').fadeOut();
}
}
function deleteSketch(num) {
//var selectedItems = $("input[type=checkbox]:checked");
// console.log('deleteSketch',num)
//confirm('Are you sure?'+selectedItems.length);
}
function selectAll() {
$('.item').addClass('selected');
}
function deselectAll() {
$('.item').removeClass('selected');
}