- Timestamp:
- 2011-12-16T13:42:28+13:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/oran/js/format_util.js
r24900 r24907 2 2 console.log("Loading format_util.js\n"); 3 3 4 / / Ensures that a change to a text field is remembered4 /* Ensures that a change to a text field is remembered */ 5 5 function onTextChange(item, text) 6 6 { … … 9 9 } 10 10 11 / / Ensures that a change to a select field is remembered11 /* Ensures that a change to a select field is remembered */ 12 12 function onSelectChange(item) 13 13 { … … 24 24 } 25 25 26 27 /* Get substring */ 26 28 function getSubstring(str, first, last) 27 29 { … … 34 36 var substring = str.substring(first_index, last_index); 35 37 36 console.log(substring);37 38 38 return substring; 39 39 } … … 41 41 function getXSLT(classname) 42 42 { 43 console.log("*** Function getXSLT ***"); 43 44 var myurl = document.URL; 44 45 45 //var collection_name = getSubstring(myurl, "&c", "&");46 46 var document_id = getSubstring(myurl, "&d", "&"); 47 47 var document_type = getSubstring(myurl, "&dt", "&"); 48 var prev_action = getSubstring(myurl, "&p.a", "&"); 49 console.log("Prev action: "+ prev_action); 50 var prev_service = getSubstring(myurl, "&p.s", "&"); 51 console.log("Prev service: "+ prev_service); 52 53 //var post_url = "http://localhost:8383/greenstone3/dev?a=d&c=" + collection_name + "&d=" + document_id + "&dt=" + document_type + "&p.a=" + prev_action + "&p.s=" + prev_service + "&o=skinandlib"; 48 54 49 var post_url = host_info.pre_URL +"?a=d&c=" + host_info.collection_name + "&d=" + document_id + "&dt=" + document_type + "&o=skinandlib"; 55 50 56 $.post(post_url, {data: classname}, function(data) { 57 console.log("Success, we have received data"); 58 console.log(data); 51 $.post(post_url, function(data) { 52 console.log("Success, we have received the XSLT for the relevant page part"); 59 53 classname = "." + classname; 60 console.log(classname);61 var content = $(data).find(classname);62 console.log(content.innerXHTML());63 console.log(content.xml());64 console.log(content);54 /* There seemed to be a problem with MIME types for the data received from the post. */ 55 /* The best fix for now is to set the data type to text and then reparse as xml */ 56 xml = $.parseXML(data); 57 var content = $( xml ).find(classname); 58 /* The xml() function is provided by jquery.xml.js (included by formatmanager.xsl) */ 65 59 $("#XSLTcode").val(content.xml()); 66 }, ' xml');60 }, 'text'); 67 61 } 68 62 … … 162 156 CURRENT_SELECT_VALUE = ""; //global - gets set by ui.draggable 163 157 164 console.log(gs.xsltParams.interface_name);165 console.log(gs.collectionMetadata.httpPath);166 console.log(document.URL);167 158 var r = /(https?:\/\/)?([\da-z\.-]+):(\d+)\/([\da-z]+)\/([\da-z]+)\?.*&c=([\da-z\.-]+).*/; 168 159 var s = document.URL; … … 184 175 host_info.pre_URL = "http://" + host_info.host_name + ":" + host_info.port + "/" + host_info.library + "/" + host_info.servlet; 185 176 console.log("Pre URL: " + host_info.pre_URL); 186 187 /*188 var collection = "";189 190 var regex = new RegExp("[?&]c=");191 var matches = regex.exec(document.URL);192 if(matches != null)193 {194 var startIndex = matches.index;195 var endIndex = document.URL.indexOf("&", startIndex + 1);196 197 if(endIndex == -1)198 {199 endIndex = document.URL.length;200 }201 202 collection = document.URL.substring(startIndex, endIndex);203 }204 */205 177 206 178 /*
Note:
See TracChangeset
for help on using the changeset viewer.