Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Commit [9039ee] Maximize Restore History

+pano_index.html

oleg oleg 2011-10-19

1 2 > >> (Page 1 of 2)
added files/pano_index.css
removed backend/index.html
removed example_readonly.kml
changed backend/db_gui.html
changed files/useful_functions.js
changed files/webgl_subs.js
changed display_kml.php
changed filelist.php
changed map_pano.php
changed map_pano_file.php
changed modify_kml.php
changed pano_db_functions.php
copied backend/button.css -> files/button.css
copied backend/useful_functions.js -> files/pano_index.js
copied example.kml -> kml_files/example_readonly.kml
copied example_mask_all.kml -> kml_files/example_mask_all.kml
copied example_mask_dark.kml -> kml_files/example_mask_dark.kml
copied example_mask_light.kml -> kml_files/example_mask_light.kml
files/pano_index.css Diff Switch to side-by-side view
Loading...
backend/index.html
File was removed.
example_readonly.kml
File was removed.
backend/db_gui.html Diff Switch to side-by-side view
Loading...
files/useful_functions.js Diff Switch to side-by-side view
Loading...
files/webgl_subs.js Diff Switch to side-by-side view
Loading...
display_kml.php Diff Switch to side-by-side view
Loading...
filelist.php Diff Switch to side-by-side view
Loading...
map_pano.php Diff Switch to side-by-side view
Loading...
map_pano_file.php Diff Switch to side-by-side view
Loading...
modify_kml.php Diff Switch to side-by-side view
Loading...
pano_db_functions.php Diff Switch to side-by-side view
Loading...
backend/button.css to files/button.css
File was renamed.
backend/useful_functions.js to files/pano_index.js
--- a/backend/useful_functions.js
+++ b/files/pano_index.js
@@ -1,6 +1,6 @@
 /*!*******************************************************************************
-*! FILE NAME  : useful_functions.js
-*! DESCRIPTION: some common specific xml parsing
+*! FILE NAME  : pano_index.js
+*! DESCRIPTION: get the routes list
 *! Copyright (C) 2011 Elphel, Inc
 *! -----------------------------------------------------------------------------**
 *!  This program is free software: you can redistribute it and/or modify
@@ -25,159 +25,144 @@
 *!
 */
 
-//List:
-//function ObjectToXMLString(obj,tab_str,wrap)
-//function XMLString_CreateNode(prefix,tagname,value)
-//function XMLString_Wrap(prefix,tagname,str)
-//function XMLString_AddXMLHeader(str,root)
-//function XMLString_AddKMLHeader(str,root)
-//function XMLToObject(xml,obj)
-
-//I. Array (multi-D specially formatted associative array) to XML-formatted string
-
-// function ArrayToXMLString(obj,tab_str,wrap){
-//   var add_tab = (wrap=="")? "":"\t";
-//   var disable_wrap = false;
-//   var tmp_str = "";  
-//   var tmp_tmp_str= "";
-//   for (key in obj) {
-//     if (typeof(obj[key])!="object") {
-//         tmp_str += XMLString_CreateNode(tab_str+add_tab,key,obj[key]);
-//     }
-//     else {
-//       if(parseInt(key)==key) disable_wrap = true;
-//       
-//       if(parseInt(key)==key) 
-//           tmp_tmp_str = ArrayToXMLString(obj[key],tab_str,wrap);        
-//       else if ((typeof(obj[key][0])!="object")&&(typeof(obj[key][0])!="undefined")) {
-// 	  tmp_tmp_str = XMLString_CreateNode(tab_str+add_tab,key,obj[key][0]);
-//       }
-//       else 
-// 	  tmp_tmp_str = ArrayToXMLString(obj[key],tab_str+add_tab,key);
-//       
-//       tmp_str += tmp_tmp_str;
-//     }
-//   }
-//   if (!disable_wrap) tmp_str = XMLString_Wrap(tab_str,wrap,tmp_str);
-//   return tmp_str;
-// }
-
-function ArrayToXMLString(obj,tab_str,wrap){
-  var tmp_str = "";
-  for (var i=0;i<obj.length;i++) {
-      tmp_str += ArrayToXMLString_recursive(obj[i],tab_str,wrap);
-  }
-  return tmp_str;
+function postRequest(cmd, xml) { 
+    $.ajax({
+        url: "pano_db_interface.php?cmd="+cmd,
+        type: "POST",
+        dataType: "xml",
+        data: xml,
+	async:false,
+        complete: function(response){parse_response(response.responseXML,cmd);},
+        contentType: "text/xml; charset=\"utf-8\""
+    });
 }
 
-function ArrayToXMLString_recursive(obj,tab_str,wrap){
-  var add_tab = (wrap=="")? "":"\t";
-  var tmp_str = "";  
-  var tmp_tmp_str= "";
-  for (key in obj) {
-    if (typeof(obj[key])!="object") {
-        tmp_str += XMLString_CreateNode(tab_str+add_tab,key,obj[key]);
-    }
-    else {
-      if ((typeof(obj[key][0])!="object")&&(typeof(obj[key][0])!="undefined")) {
-	  tmp_tmp_str = XMLString_CreateNode(tab_str+add_tab,key,obj[key][0]);
-      }
-      else 
-	  tmp_tmp_str = ArrayToXMLString_recursive(obj[key],tab_str+add_tab,key);
-      
-      tmp_str += tmp_tmp_str;
-    }
-  }
-  tmp_str = XMLString_Wrap(tab_str,wrap,tmp_str);
-  return tmp_str;
+function getRequest(rq,callback) { 
+    $.ajax({
+        url: rq,
+        type: "GET",
+// 	async:false,
+        complete: function(response){callback(response.responseText);},
+    });
 }
 
-function XMLString_CreateNode(prefix,tagname,value){
-  return (prefix+"<"+tagname+">"+value+"</"+tagname+">\n");
+var res_arr = Array();
+
+function parse_response(xml,cmd){
+    var result="";
+   
+    res_arr = XMLToArray(xml);
+     
+    if (cmd=="GetRoutesAndKMLs") {
+	//get also KML files
+	var table_str = "<table>\
+<tr>\
+    <th>Route ID</th>\
+    <th>Name</th>\
+    <th>Description</th>\
+    <th>Nodes</th>\
+    <th>KML</th>\
+    <th>Editable</th>\
+</tr>";
+	for (var i=0;i<res_arr.length;i++){
+	    row_color = "rgba(200,200,"+(200+60*(i%2))+",0.2)";
+	    
+	    var tmp_id    = (res_arr[i].ID==undefined)?"":res_arr[i].ID;
+	    var tmp_name  = (res_arr[i].Name==undefined)?"":res_arr[i].Name;
+	    var tmp_descr = (res_arr[i].Description==undefined)?"":res_arr[i].Description;
+	    var tmp_nodes = (res_arr[i].Nodes==undefined)?"":res_arr[i].Nodes;
+	    
+	    var tmp_edit = (res_arr[i].Editable==undefined)?"No":res_arr[i].Editable;
+	    var tmp_kml = tmp_id;
+	  
+	    table_str += "<tr id='r"+i+"' style='background:"+row_color+"' onclick='row_click_handler("+i+")'>\
+<td><a href='webgl_panorama_editor.html?kml="+tmp_id+"'>"+tmp_id+"</a></td>\
+<td><div style='width:150px;'>"+tmp_name+"</div></td>\
+<td><div style='width:250px;'>"+tmp_descr+"</div></td>\
+<td>"+(+tmp_nodes)+"</td>\
+<td><a href='display_kml.php?id="+tmp_id+"'>"+tmp_id+"</a></td>\
+<td>"+tmp_edit+"</td>\
+</tr>";
+	}
+	table_str +="</table>";
+    }
+   
+   $("#route_list").html(table_str);
 }
 
-function XMLString_Wrap(prefix,tagname,str){
-  if (str=="")          return str;
-  else if (tagname=="") return str;
-  else                  return (prefix+"<"+tagname+">\n"+str+prefix+"</"+tagname+">\n");
+//siuda!
+function row_click_handler(i){
+    if   ($("#r"+i).attr('marked')=="true") {
+	$("#r"+i).attr('marked',"false");
+	$("#r"+i).css({background:$("#r"+i).attr('old_color')});
+    }else{
+	$("#r"+i).attr('marked',"true");
+	$("#r"+i).attr('old_color',$("#r"+i).css("background-color"));
+	$("#r"+i).css({background:"rgba(100,200,50,0.8)"});
+	//disable others
+	for (var j=0;j<res_arr.length;j++) {
+	    if (i!=j) {
+		$("#r"+j).css({background:$("#r"+j).attr('old_color')});
+		$("#r"+j).attr('marked',"false");
+	    }
+	}
+    }
 }
 
-function XMLString_AddXMLHeader(str,root){
-  return ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<"+root+">\n"+str+"</"+root+">");
+function create_copy(){
+    found_marked = false;
+    $("#status").val("");
+    for(var i=0;i<res_arr.length;i++){
+	if ($("#r"+i).attr('marked')=="true") {
+	    found_marked = true;
+	    break;
+	}
+    }
+    if (!found_marked) {
+	$("#status").val("Please select one of the routes");
+	return 0;
+    }
+    if ($("#input_fn").val()=="") {
+	$("#status").val("Please enter the copy name");
+	return 0;
+    }
+    
+    if ($("#input_fn").val().substr(-3,3)!="kml") {
+	$("#status").val("Incorrect file extension");
+	return 0;
+    }
+    
+    if($("#input_fn").val().match(/[\<\>!@#\$%^&\*,/]+/i) ) {
+	$("#status").val("Unknown error");
+    }
+    
+    var rq = "copy_kml.php?proto="+res_arr[i].ID+"&kml="+$("#input_fn").val();
+    
+    getRequest(rq,copy_done);
+    
 }
 
-function XMLString_AddKMLHeader(str,root){
-  return ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<kml xmlns=\"http://earth.google.com/kml/2.2\">\n<"+root+">\n"+str+"</"+root+">\n</kml>");
+function copy_done(msg){
+    $("#status").val(msg);
+    postRequest("GetRoutesAndKMLs", "");
 }
 
-//II. XML to Array (same as multi-D associative array)
-// function XMLToArray(xml){
-// 	var tmp = xml.childNodes;
-// 	var obj = new Array();
-// 	for (var i=0;i<tmp.length;i++) {
-// 	      if (tmp[i].nodeType==1) {
-// 		    if (tmp[i].firstChild!=null) { // the node is not empty
-// 			if (obj[tmp[i].nodeName]==undefined) obj[tmp[i].nodeName] = new Array();
-// 			var tmp_len = obj[tmp[i].nodeName].length;
-// 			if (obj[tmp[i].nodeName][tmp_len]==undefined) obj[tmp[i].nodeName][tmp_len] = new Array();
-// 			if ((tmp[i].firstChild.nodeValue==false)||(tmp[i].firstChild.nodeValue==null)) { // has subnodes
-// 			    // recursive iteration
-// 			    obj[tmp[i].nodeName][tmp_len] = XMLToArray(tmp[i]);
-// 			}else{ // assign value
-// 			    obj[tmp[i].nodeName][tmp_len] = tmp[i].firstChild.nodeValue;
-// 			}
-// 		    }
-// 		    //skip empty node, example: <exmpl></exmpl>
-// 		    /*else{ 
-// 			obj[tmp[i].nodeName] = "undefined";
-// 		    }*/
-// 	      }
-// 	}
-// 	return obj;
-// }
-
-function XMLToArray(xml){
-	var tmp = xml.childNodes;
-	var obj = new Array();
-	if (tmp[0].nodeType==1) {
-	    //console.log(tmp[0].nodeName);
-	    tmp = tmp[0].childNodes; // enter top tag
-	    if (tmp[1].nodeType==1) {
-		//console.log(tmp[1].nodeName);
-		tmp = tmp[1].childNodes; // enter top sub-tag
-		for (var i=0;i<tmp.length;i++) {
-		    if (tmp[i].nodeType==1) {
-			var tmp_arr = XMLToArray_recursive(tmp[i]);
-			if (Object.keys(tmp_arr).length!=0) obj[obj.length] = tmp_arr;
-		    }
-		}
-	    }
-	}
-	return obj;
+function xml_create(arr) {
+  var result_str = "";
+  for (var i=0;i<arr.length;i++) {
+    var tmp_str = "";
+    for(key in arr[i]) {
+	tmp_str += XMLString_CreateNode("\t\t",key,arr[i][key]);
+    }
+    result_str += XMLString_Wrap("\t","node",tmp_str);
+  }
+  return XMLString_AddXMLHeader(result_str,"data");
 }
-
-function XMLToArray_recursive(xml){
-	var tmp = xml.childNodes;
-	var obj = new Array();
-	for (var i=0;i<tmp.length;i++) {
-	      if (tmp[i].nodeType==1) {
-		    if (tmp[i].firstChild!=null) { // the node is not empty
-
-			if (obj[tmp[i].nodeName]==undefined) obj[tmp[i].nodeName] = new Array();
-			
-			if ((tmp[i].firstChild.nodeValue==false)||(tmp[i].firstChild.nodeValue==null)) { // has subnodes
-			    // recursive iteration
-			    obj[tmp[i].nodeName] = XMLToArray_recursive(tmp[i]);
-			}else{ // assign value
-			    obj[tmp[i].nodeName] = tmp[i].firstChild.nodeValue;
-			}
-		    }
-		    //skip empty node, example: <exmpl></exmpl>
-		    /*else{ 
-			obj[tmp[i].nodeName] = "undefined";
-		    }*/
-		}
-	}
-	return obj;
+ 
+function kml_create(arr) {
+  var result_str = "";
+  for (var i=0;i<arr.length;i++) {
+      result_str += ArrayToXMLString(arr[i],"\t","PhotoOverlay");
+  }
+  return XMLString_AddKMLHeader(result_str,"Document");
 }
-
1 2 > >> (Page 1 of 2)