Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
optical-design-viewer
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
optical-design-viewer
Commits
a2244eb2
Commit
a2244eb2
authored
Jun 24, 2014
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+Loading design files from github
parent
43a1273b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
20 deletions
+49
-20
files.js
files.js
+9
-3
files.php
files.php
+2
-1
get_remote_designs_list.php
get_remote_designs_list.php
+10
-6
list.js
list.js
+28
-10
No files found.
files.js
View file @
a2244eb2
...
@@ -7,6 +7,11 @@ LICENSE: AGPL, see http://www.gnu.org/licenses/agpl.txt
...
@@ -7,6 +7,11 @@ LICENSE: AGPL, see http://www.gnu.org/licenses/agpl.txt
Copyright (C) 2014 Elphel, Inc.
Copyright (C) 2014 Elphel, Inc.
*/
*/
var
path_local
=
"local"
;
var
path_remote
=
"https://raw.githubusercontent.com/Elphel/elens/master"
;
var
pattern_local
=
"local: "
;
var
pattern_remote
=
"github: "
;
function
save_design
(){
function
save_design
(){
console
.
log
(
"save_design(): "
+
$
(
"#file_to_save"
).
val
());
console
.
log
(
"save_design(): "
+
$
(
"#file_to_save"
).
val
());
var
xml
=
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>
\n
<Document>
\n
"
;
var
xml
=
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>
\n
<Document>
\n
"
;
...
@@ -43,7 +48,7 @@ function save_design(){
...
@@ -43,7 +48,7 @@ function save_design(){
function
postSettings
(
file
,
cmd
,
xml
)
{
function
postSettings
(
file
,
cmd
,
xml
)
{
$
.
ajax
({
$
.
ajax
({
url
:
"files.php?file="
+
file
+
"&cmd="
+
cmd
,
url
:
"files.php?file="
+
file
+
"&cmd="
+
cmd
+
"&path="
+
path_local
,
type
:
"POST"
,
type
:
"POST"
,
dataType
:
"xml"
,
dataType
:
"xml"
,
data
:
xml
,
data
:
xml
,
...
@@ -56,13 +61,14 @@ function postSettings(file, cmd, xml) {
...
@@ -56,13 +61,14 @@ function postSettings(file, cmd, xml) {
function
parse_save_response
(
text
)
{
function
parse_save_response
(
text
)
{
//$("#test").html(text);
//$("#test").html(text);
//reload list
//reload list
designs
=
Array
();
get_designs_list
(
"load_designs_list"
);
get_designs_list
(
"load_designs_list"
);
jquery_list
(
"load_designs_list"
,
"Load"
,
load_design
);
jquery_list
(
"load_designs_list"
,
"Load"
,
load_design
);
}
}
function
getDesign
(
file
)
{
function
getDesign
(
file
,
path
)
{
$
.
ajax
({
$
.
ajax
({
url
:
"files.php?file="
+
file
+
"&cmd=read
"
,
url
:
"files.php?file="
+
file
+
"&cmd=read
&path="
+
path
,
type
:
"GET"
,
type
:
"GET"
,
async
:
false
,
async
:
false
,
complete
:
function
(
response
){
complete
:
function
(
response
){
...
...
files.php
View file @
a2244eb2
...
@@ -14,7 +14,8 @@ else die("-1");
...
@@ -14,7 +14,8 @@ else die("-1");
if
(
isset
(
$_GET
[
'cmd'
]))
$cmd
=
$_GET
[
'cmd'
];
if
(
isset
(
$_GET
[
'cmd'
]))
$cmd
=
$_GET
[
'cmd'
];
else
die
(
"-2"
);
else
die
(
"-2"
);
$default_path
=
"local"
;
if
(
isset
(
$_GET
[
'path'
]))
$default_path
=
$_GET
[
'path'
];
else
die
(
"-3"
);
if
(
$cmd
==
"save"
)
{
if
(
$cmd
==
"save"
)
{
file_put_contents
(
"
$default_path
/
$file
"
,
file_get_contents
(
"php://input"
));
file_put_contents
(
"
$default_path
/
$file
"
,
file_get_contents
(
"php://input"
));
...
...
get_remote_designs_list.php
View file @
a2244eb2
<?php
<?php
/*
/*
FILE NAME : get_designs_list.php
FILE NAME : get_
remote_
designs_list.php
DESCRIPTION: optical design
DESCRIPTION: optical design
REVISION: 1.00
REVISION: 1.00
AUTHOR: Oleg Dzhimiev <oleg@elphel.com>
AUTHOR: Oleg Dzhimiev <oleg@elphel.com>
...
@@ -10,17 +10,21 @@ Copyright (C) 2014 Elphel, Inc.
...
@@ -10,17 +10,21 @@ Copyright (C) 2014 Elphel, Inc.
//$res_xml = file_get_contents("sensors/sensors.xml");
//$res_xml = file_get_contents("sensors/sensors.xml");
$path
=
"local"
;
$path
=
"https://github.com/Elphel/elens"
;
$contents
=
file_get_contents
(
$path
);
$regexp
=
'#<a[^>]*href="([^"]*)"[^>]*title=".*.xml"#'
;
$files
=
Array
();
if
(
preg_match_all
(
$regexp
,
$contents
,
$matches
,
PREG_SET_ORDER
))
{
foreach
(
$matches
as
$match
)
{
$files
[]
=
basename
(
$match
[
1
]);
}
}
$res_xml
=
"<?xml version='1.0'?>
\n
"
;
$res_xml
=
"<?xml version='1.0'?>
\n
"
;
$res_xml
.=
"<Document>
\n
"
;
$res_xml
.=
"<Document>
\n
"
;
$files
=
scandir
(
$path
);
foreach
(
$files
as
$file
){
foreach
(
$files
as
$file
){
if
(
is_file
(
"
$path
/
$file
"
))
{
$res_xml
.=
"
\t
<file>
$file
</file>
\n
"
;
$res_xml
.=
"
\t
<file>
$file
</file>
\n
"
;
}
}
}
$res_xml
.=
"</Document>"
;
$res_xml
.=
"</Document>"
;
...
...
list.js
View file @
a2244eb2
...
@@ -12,27 +12,37 @@ $(function(){
...
@@ -12,27 +12,37 @@ $(function(){
function
load_design
(
src
,
i
){
function
load_design
(
src
,
i
){
console
.
log
(
"Loading lens design: "
+
designs
[
i
]);
console
.
log
(
"Loading lens design: "
+
designs
[
i
]);
getDesign
(
designs
[
i
]);
var
path
=
""
;
var
file
=
""
;
if
(
designs
[
i
].
indexOf
(
pattern_remote
)
!=-
1
){
path
=
path_remote
;
file
=
designs
[
i
].
replace
(
pattern_remote
,
""
);
}
else
{
path
=
path_local
;
file
=
designs
[
i
].
replace
(
pattern_local
,
""
);
}
getDesign
(
file
,
path
);
}
}
function
get_designs_list_sync
(
some_folder
,
type
)
{
function
get_designs_list_sync
(
url
,
prefix
)
{
$
.
ajax
({
$
.
ajax
({
url
:
"./get_designs_list.php"
,
//url: "./get_designs_list.php",
url
:
url
,
async
:
false
,
async
:
false
,
dataType
:
"xml"
,
dataType
:
"xml"
,
success
:
function
(
data
){
fill_designs_list
(
data
.
getElementsByTagName
(
"file"
));}
success
:
function
(
data
){
fill_designs_list
(
data
.
getElementsByTagName
(
"file"
)
,
prefix
);}
});
});
}
}
var
designs
=
Array
();
var
designs
=
Array
();
function
fill_designs_list
(
designs_list
){
function
fill_designs_list
(
designs_list
,
prefix
){
designs
=
Array
();
for
(
var
i
=
0
;
i
<
designs_list
.
length
;
i
++
){
for
(
var
i
=
0
;
i
<
designs_list
.
length
;
i
++
){
var
tmp
=
designs_list
[
i
];
var
tmp
=
designs_list
[
i
];
if
(
tmp
.
length
!=
0
)
{
if
(
tmp
.
length
!=
0
)
{
if
(
typeof
(
tmp
.
childNodes
[
0
])
!=
'undefined'
)
designs
[
i
]
=
tmp
.
childNodes
[
0
].
nodeValue
;
if
(
typeof
(
tmp
.
childNodes
[
0
])
!=
'undefined'
)
designs
.
push
(
prefix
+
tmp
.
childNodes
[
0
].
nodeValue
)
;
else
designs
[
i
]
=
""
;
else
designs
.
push
=
""
;
}
}
}
}
}
}
...
@@ -41,13 +51,21 @@ function get_designs_list(element_id) {
...
@@ -41,13 +51,21 @@ function get_designs_list(element_id) {
var
some_folder
=
""
;
var
some_folder
=
""
;
var
folder_list
=
""
;
var
folder_list
=
""
;
if
(
some_folder
!=
"Load"
)
{
if
(
some_folder
!=
"Load"
)
{
get_designs_list_sync
();
//get local list
get_designs_list_sync
(
"./get_designs_list.php"
,
"local: "
);
//get remote list from elphel's github
var
list
=
"<div class='list_view'><ul>"
;
var
list
=
"<div class='list_view'><ul>"
;
for
(
var
i
=
0
;
i
<
designs
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
designs
.
length
;
i
++
)
{
list
=
list
+
"<li>"
+
designs
[
i
]
+
"</li>"
;
list
=
list
+
"<li>"
+
designs
[
i
]
+
"</li>"
;
}
}
get_designs_list_sync
(
"./get_remote_designs_list.php"
,
"github: "
);
for
(
var
j
=
i
;
j
<
designs
.
length
;
j
++
)
{
list
=
list
+
"<li>"
+
designs
[
j
]
+
"</li>"
;
}
list
=
list
+
"</ul></div>"
;
list
=
list
+
"</ul></div>"
;
}
else
{
}
else
{
list
=
"<div class='list_view'><ul></ul></div>"
;
list
=
"<div class='list_view'><ul></ul></div>"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment