mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2025-06-11 01:13:18 +02:00
manage sketches and file manager
This commit is contained in:
@ -6,14 +6,14 @@
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a href="?"><img src="../img/logo/doodle3d.png" height="25"></a><br>
|
||||
<img src="../img/logo/doodle3d.png" height="25">
|
||||
<hr>
|
||||
<button id="btnSelectAll">Select all</button>
|
||||
<button id="btnDeselectAll">Deselect all</button>
|
||||
<button id="btnDelete">Delete</button>
|
||||
<button id="btnDownload">Download</button> <!-- <a id="link" href="#">Download</a> -->
|
||||
|
||||
<form id="frmUpload" action="#"><button id="btnUpload">Upload</button><input id="uploads" type="file" accept="image/svg+xml" multiple/></form>
|
||||
<form id="frmUpload"><button id="btnUpload">Upload</button><input id="uploads" type="file" accept="image/svg+xml" multiple/></form>
|
||||
|
||||
<span id="txtInfo"></span>
|
||||
|
@ -1,31 +1,40 @@
|
||||
var api = 'http://10.0.0.40/d3dapi/sketch/';
|
||||
/*
|
||||
* This file is part of the Doodle3D project (http://doodle3d.com).
|
||||
*
|
||||
* Copyright (c) 2014, Doodle3D
|
||||
* This software is licensed under the terms of the GNU GPL v2 or later.
|
||||
* See file LICENSE.txt or visit http://www.gnu.org/licenses/gpl.html for full license details.
|
||||
*/
|
||||
|
||||
// http://stackoverflow.com/questions/1403888/get-url-parameter-with-jquery
|
||||
function getURLParameter(name) {
|
||||
return decodeURI((new RegExp('[&?]'+name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]);
|
||||
}
|
||||
|
||||
var wifiboxURL = "";
|
||||
|
||||
if (getURLParameter("r") != "null") wifiboxURL = 'http://192.168.5.1';
|
||||
if (getURLParameter("wifiboxURL") != "null") wifiboxURL = getURLParameter("wifiboxURL");
|
||||
|
||||
var api = wifiboxURL+'/d3dapi/sketch/';
|
||||
|
||||
$("#btnDelete").click(deleteSelectedSketches);
|
||||
$("#btnSelectAll").click(selectAll);
|
||||
$("#btnDeselectAll").click(deselectAll);
|
||||
// $("#btnUpload").click(upload);
|
||||
$("#uploads").change(upload);
|
||||
$("#btnDownload").click(download);
|
||||
|
||||
$("#btnUpload").click(function() {
|
||||
console.log('trigger')
|
||||
$("#btnUpload").click(function(e) {
|
||||
e.preventDefault();
|
||||
$("#uploads").trigger('click');
|
||||
});
|
||||
|
||||
// $("a").on("click", function () {
|
||||
// var d = new Date().toISOString().slice(0, 19).replace(/-/g, "");
|
||||
// $(this).attr("href", "data:application/octet-stream;"+encodeURIComponent("test")).attr("download", "file-" + d + ".svg");
|
||||
// });
|
||||
|
||||
|
||||
var isBusy = true;
|
||||
// var statusMessage = "";
|
||||
|
||||
// updateFreeSpace();
|
||||
updateButtonStates();
|
||||
|
||||
$.get(api+'list', function(data) { //?id=00003
|
||||
|
||||
|
||||
if (data.status=='success') {
|
||||
var list = data.data.list;
|
||||
// list.reverse();
|
||||
@ -38,7 +47,6 @@ $.get(api+'list', function(data) { //?id=00003
|
||||
console.log('done');
|
||||
isBusy = false;
|
||||
updateFreeSpace();
|
||||
//updateStatusMessage('loading '+list.length+' sketches...');
|
||||
updateButtonStates();
|
||||
});
|
||||
|
||||
@ -46,6 +54,9 @@ $.get(api+'list', function(data) { //?id=00003
|
||||
console.log('failure',data)
|
||||
}
|
||||
|
||||
}).fail(function(status) {
|
||||
alert("Error ("+status.status+") connecting to "+api+'list');
|
||||
console.log(status);
|
||||
});
|
||||
|
||||
function loadSketch(list,cb) {
|
||||
@ -77,7 +88,7 @@ function addItem(id,svgData,doPrepend) {
|
||||
else if (svgData.indexOf("CDATA")==-1) path = "";
|
||||
else path = svgData.split('d="')[1].split('"')[0];
|
||||
|
||||
var item = $('<div class="item" data="'+id+'">');
|
||||
var item = $('<div class="item" data="'+id+'" title="'+id+'">');
|
||||
var svg = '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 640 540"><path fill="none" stroke="black" stroke-width="2" d="'+path+'"></path></svg>';
|
||||
|
||||
item.click(function() {
|
||||
@ -170,7 +181,6 @@ function uploadFile(files, index, next) {
|
||||
//process file
|
||||
var svg = convertSvg(evt.target.result);
|
||||
|
||||
// setTimeout(function() {
|
||||
$.post(api, {data:svg}, function(data) {
|
||||
if (data.status=='success') {
|
||||
var id = data.data.id;
|
||||
@ -183,11 +193,8 @@ function uploadFile(files, index, next) {
|
||||
} else {
|
||||
next(); //no more files, call back
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
// },500);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -237,7 +244,11 @@ function convertSvg(svg) {
|
||||
var re = /([a-zA-Z])\s?([0-9]{1,}) ([0-9]{1,})/g;
|
||||
svg = svg.replace(re,"$1$2,$3");
|
||||
re = /<\/svg>/g;
|
||||
return svg.replace(re,"<!--<![CDATA[d3d-keys {\"height\":5,\"outlineShape\":\"none\",\"twist\":0}]]>-->\n</svg>");
|
||||
svg = svg.replace(re,"<!--<![CDATA[d3d-keys {\"height\":5,\"outlineShape\":\"none\",\"twist\":0}]]>-->\n</svg>");
|
||||
|
||||
svg = svg.replace("M0,0 ",""); //RC: hack
|
||||
|
||||
return svg;
|
||||
}
|
||||
|
||||
function download() {
|
@ -173,14 +173,20 @@
|
||||
<small id="updateInfo"></small>
|
||||
</fieldset>
|
||||
|
||||
<fieldset id="debugPanel">
|
||||
<legend>Debug</legend>
|
||||
<input type="button" onclick="settingsWindow.downloadlogs()" name="downloadlogs" value="Download logs" class="button" id="downloadlogs"/>
|
||||
<fieldset id="extraPanel">
|
||||
<legend>Sketches</legend>
|
||||
<input type="button" onclick="settingsWindow.openFileManager()" name="btnFileMgr" value="Open FileManager" class="button" id="btnFileMgr"/>
|
||||
<input type="button" onclick="settingsWindow.downloadGcode()" name="downloadGcode" value="Download GCODE" class="button" id="downloadGcode"/>
|
||||
<input type="button" onclick="settingsWindow.downloadSvg()" name="downloadSvg" value="Download SVG" class="button" id="downloadSvg"/>
|
||||
</fieldset>
|
||||
|
||||
<fieldset id="restorePanel">
|
||||
</fieldset>
|
||||
|
||||
<fieldset id="debugPanel">
|
||||
<legend>Debug</legend>
|
||||
<input type="button" onclick="settingsWindow.downloadlogs()" name="downloadlogs" value="Download logs" class="button" id="downloadlogs"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<fieldset id="restorePanel">
|
||||
<legend>Restore</legend>
|
||||
<input type="button" name="restoresettings" value="Restore settings to defaults" class="button" id="restoreSettings"/>
|
||||
<span id="restoreState"></span>
|
||||
|
Reference in New Issue
Block a user