Commit ae4363a6 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

added links

parent 50f4889d
...@@ -9,6 +9,7 @@ Copyright (C) 2014 Elphel, Inc. ...@@ -9,6 +9,7 @@ Copyright (C) 2014 Elphel, Inc.
var path_local = "local"; var path_local = "local";
var path_remote = "https://raw.githubusercontent.com/Elphel/elens/master"; var path_remote = "https://raw.githubusercontent.com/Elphel/elens/master";
var path_remote_browse = "https://github.com/Elphel/elens";
var pattern_local = "local: "; var pattern_local = "local: ";
var pattern_remote = "github: "; var pattern_remote = "github: ";
...@@ -42,7 +43,7 @@ function save_design(){ ...@@ -42,7 +43,7 @@ function save_design(){
xml += "\t\t</back>\n"; xml += "\t\t</back>\n";
xml += "\t</element>\n"; xml += "\t</element>\n";
}); });
xml += "</Document>" xml += "</Document>";
postSettings($("#file_to_save").val(), "save", xml); postSettings($("#file_to_save").val(), "save", xml);
} }
...@@ -66,9 +67,11 @@ function parse_save_response(text) { ...@@ -66,9 +67,11 @@ function parse_save_response(text) {
jquery_list("load_designs_list","Load",load_design); jquery_list("load_designs_list","Load",load_design);
} }
function getDesign(file,path) { function getDesign(f,p) {
//set globals
createLink(f,p);
$.ajax({ $.ajax({
url: "files.php?file="+file+"&cmd=read&path="+path, url: "files.php?file="+f+"&cmd=read&path="+p,
type: "GET", type: "GET",
async: false, async: false,
complete: function(response){ complete: function(response){
...@@ -113,8 +116,17 @@ function restore_design(text){ ...@@ -113,8 +116,17 @@ function restore_design(text){
$(this).find("back").find("a3").text(), $(this).find("back").find("a3").text(),
$(this).find("back").find("a4").text() $(this).find("back").find("a4").text()
); );
}); });
}
function createLink(f,p){
} var string = "<a href='";
\ No newline at end of file string+= window.location.href.substr(0,window.location.href.lastIndexOf('?'));
string+="?file="+f;
string+="&path="+p;
string+="'>Permanent Link</a>";
$("#link").html(string);
string = "<a href='files.php?file="+f+"&path="+p+"'>Download XML</a>";
$("#link_dl").html(string);
}
...@@ -12,7 +12,7 @@ if (isset($_GET['file'])) $file = $_GET['file']; ...@@ -12,7 +12,7 @@ if (isset($_GET['file'])) $file = $_GET['file'];
else die("-1"); else die("-1");
if (isset($_GET['cmd'])) $cmd = $_GET['cmd']; if (isset($_GET['cmd'])) $cmd = $_GET['cmd'];
else die("-2"); else $cmd = "read";
if (isset($_GET['path'])) $default_path = $_GET['path']; if (isset($_GET['path'])) $default_path = $_GET['path'];
else die("-3"); else die("-3");
......
...@@ -69,7 +69,13 @@ input{ ...@@ -69,7 +69,13 @@ input{
#ray_draw_div{ #ray_draw_div{
position: absolute; position: absolute;
left:1010px; left:1010px;
top:74px; top:122px;
}
#links{
position: absolute;
left:1014;
top:74px;
} }
.remove_button{ .remove_button{
......
...@@ -79,5 +79,17 @@ Copyright (C) 2014 Elphel, Inc. ...@@ -79,5 +79,17 @@ Copyright (C) 2014 Elphel, Inc.
</tr> </tr>
</table> </table>
</div> </div>
<div id="links">
<table style="border:0px">
<tr>
<td width=120 style="text-align:left"><div id="link_local"></div></td>
<td width=120 style="text-align:left"><div id="link_remote"></div></td>
</tr>
<tr>
<td width=120 style="text-align:left"><div id="link"></div></td>
<td width=120 style="text-align:left"><div id="link_dl"></div></td>
</tr>
</table>
</div>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -23,6 +23,9 @@ var selected_elements = Array(); ...@@ -23,6 +23,9 @@ var selected_elements = Array();
var epsilon = 0.0001; var epsilon = 0.0001;
var epsilon2 = 0.0001; var epsilon2 = 0.0001;
var file = "";
var path = "";
$(function(){ $(function(){
yO = $("#cnv1").height()/2; yO = $("#cnv1").height()/2;
console.log("Drawing axii"); console.log("Drawing axii");
...@@ -37,6 +40,11 @@ $(function(){ ...@@ -37,6 +40,11 @@ $(function(){
if (cnv_div.addEventListener) cnv_div.addEventListener('DOMMouseScroll', wheelEvent, false); if (cnv_div.addEventListener) cnv_div.addEventListener('DOMMouseScroll', wheelEvent, false);
cnv_div.onmousewheel = wheelEvent; cnv_div.onmousewheel = wheelEvent;
parseURL();
if (file!=""&&path!="") {
getDesign(file,path);
}
//ray_draw(0,0,0); //ray_draw(0,0,0);
}); });
...@@ -117,10 +125,10 @@ function array_update_entries(){ ...@@ -117,10 +125,10 @@ function array_update_entries(){
if (e[i].front.h>0) { if (e[i].front.h>0) {
tmp = find_optical_power(e[i]) tmp = find_optical_power(e[i])
total_power+= tmp; total_power+= tmp;
console.log("Optical power of element #"+i+" is "+tmp+" diopters"); //console.log("Optical power of element #"+i+" is "+tmp+" diopters");
} }
} }
console.log("Total optical power is "+total_power); //console.log("Total optical power is "+total_power);
table_update_all(); table_update_all();
} }
...@@ -945,10 +953,20 @@ function find_optical_power(element){ ...@@ -945,10 +953,20 @@ function find_optical_power(element){
var d = +element.t; var d = +element.t;
var inv_f = (n-1)*(1/r1-1/r2+(n-1)*d/n/(r1*r2)); var inv_f = (n-1)*(1/r1-1/r2+(n-1)*d/n/(r1*r2));
var f = 1/inv_f; var f = 1/inv_f;
console.log("f = "+f+" mm"); //console.log("f = "+f+" mm");
return inv_f*1000; return inv_f*1000;
} }
function parseURL() {
var parameters=location.href.replace(/\?/ig,"&").split("&");
for (var i=0;i<parameters.length;i++) parameters[i]=parameters[i].split("=");
for (var i=1;i<parameters.length;i++) {
switch (parameters[i][0]) {
case "file": file = parameters[i][1];break;
case "path": path = parameters[i][1];break;
}
}
}
var Glass = { var Glass = {
"BAF51" : {n:1.652242,B1:1.51503623,B2:0.153621958,B3:1.15427909,C1:0.00942734715,C2:0.04308265,C3:124.889868},//barium flint "BAF51" : {n:1.652242,B1:1.51503623,B2:0.153621958,B3:1.15427909,C1:0.00942734715,C2:0.04308265,C3:124.889868},//barium flint
......
...@@ -71,6 +71,9 @@ function get_designs_list(element_id) { ...@@ -71,6 +71,9 @@ function get_designs_list(element_id) {
list = "<div class='list_view'><ul></ul></div>"; list = "<div class='list_view'><ul></ul></div>";
} }
$("#"+element_id).html(list); $("#"+element_id).html(list);
//create links
$("#link_local").html("<a href='"+path_local+"'>Local files</a>");
$("#link_remote").html("<a href='"+path_remote_browse+"'>Remote files</a>");
} }
function wheelEvent_list(event){ function wheelEvent_list(event){
......
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