- Timestamp:
- 2010-11-10T16:01:41+13:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js
r23298 r23312 3 3 4 4 var initialised_iframe = "false"; 5 6 function createFormatStatement() 7 { 8 9 var formatStatement = document.getElementById('formatStatement'); 10 console.log(formatStatement); 11 if(formatStatement.hasChildNodes()) 12 { 13 var formatstring = traverse(formatStatement, ""); 14 console.log(formatstring); 15 16 // var children = $(formatStatement).children('div'); 17 // for(var i=0; i < children.length; i++) 18 // traverse(children[i], formatstring) 19 20 /* 21 var children = formatStatement.childNodes; //[]getChildNodes(); 22 var current; 23 for(var i = 0; i < formatStatement.childNodes.length; i++) 24 { 25 current = formatStatement.childNodes[i]; 26 //console.log(current.nodeName); 27 //console.log(current.nodeType); 28 if(current.nodeName=='DIV') 29 { 30 //console.log(current); 31 //console.log(current.className); 32 var gsf = find_class(current); 33 console.log(gsf); 34 } 35 } 36 */ 37 } 38 } 39 40 function traverse(node, formatstring) 41 { 42 //console.log("node=("+node.nodeName+","+node.nodeType+")"); 43 44 if(node.nodeName=='DIV') 45 { 46 console.log("Found a div" +node.nodeName+","+node.nodeType); 47 formatstring = formatstring + find_class(node); 48 console.log(formatstring); 49 } 50 51 var children = $(node).children(); 52 for(var i=0; i < children.length; i++) 53 formatstring = formatstring + traverse(children[i], formatstring); 54 55 return formatstring; 56 } 57 58 59 /* 60 console.log("node=("+node.nodeName+","+node.nodeType+")"); 61 62 if(node.children.length == 0) //hasChildNodes()) 63 { 64 console.log("No children so return"); 65 return ""; 66 } 67 68 if(node.nodeName=='DIV') 69 { 70 console.log("Found a div"); 71 formatstring = formatstring + find_class(node); 72 } 73 74 for(var i = 0; i < node.children.length; i++) 75 return recursiveTraverse(node.children[i], formatstring); 76 77 78 return formatstring; 79 } 80 */ 81 82 function find_class(current) 83 { 84 var classes = current.className.split(' '); 85 var none = ""; 86 for(var i = 0; i < classes.length; i++) 87 { 88 switch(classes[i]) 89 { 90 case 'gsf_template': 91 return create_gsf_template(current); 92 default: 93 { 94 console.log("Class not found"); 95 return none; 96 } 97 } 98 } 99 } 100 101 function create_gsf_template(current) 102 { 103 // find match text which is an input with class match 104 var match = $(current).find('.match')[0].value; 105 console.log(match); 106 107 // find mode text which is an input with class mode 108 var mode = $(current).find('.mode')[0].value; 109 console.log(mode); 110 111 // "<gsf:template match=\"classifierNode\" mode=\"horizontal\">" 112 var gsf = "<gsf:template match=\"" + match + "\""; 113 if(mode != "vertical") 114 gsf = gsf + " mode=\"" + mode + "\""; 115 gsf = gsf + ">"; 116 117 return gsf; 118 119 } 120 5 121 /* 6 122 $("#iframe").ready(function(){ … … 107 223 a = preview_html.substring(0,end_index); 108 224 b = preview_html.substring(end_index); 109 preview_html = a.concat("&excerptid= gs_content", b);225 preview_html = a.concat("&excerptid=results", b); 110 226 console.log(preview_html); 111 start_index = end_index + "&excerptid= gs_content\">".length;227 start_index = end_index + "&excerptid=results\">".length; 112 228 } 113 229 } 230 231 // Split the html code in to three parts 232 var first_index = preview_html.indexOf("<ul id=\"results\""); 233 console.log("First index is "+first_index); 234 var second_index = preview_html.indexOf("</ul>", first_index) + "</ul>".length; 235 console.log("Second index is "+second_index); 236 237 var first_half = preview_html.substring(0, first_index); 238 var iframe_code = preview_html.substring(first_index, second_index); 239 var second_half = preview_html.substring(second_index); 240 241 //$('#my_categories').innerHTML = first_half.concat(second_half); 242 document.getElementById("my_categories").innerHTML = first_half.concat(second_half); 114 243 115 244 // Put the content in the iframe … … 119 248 console.log(preview_html); 120 249 iframe_document.open(); 121 iframe_document.writeln( preview_html); //.concat("&excerptid=gs_content"));250 iframe_document.writeln(iframe_code); //.concat("&excerptid=gs_content")); 122 251 iframe_document.close(); 123 252 initialised_iframe = "true";
Note:
See TracChangeset
for help on using the changeset viewer.