Changeset 27713
- Timestamp:
- 2013-06-27T16:52:08+12:00 (11 years ago)
- Location:
- main/trunk/greenstone3/web/interfaces/default/js
- Files:
-
- 1 added
- 3 edited
- 9 moved
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/js/debug_scripts.js
r27256 r27713 122 122 var _currentMatch; 123 123 var _currentNamespace; 124 var _currentXPath; 124 125 var _isVisualEditor = true; 125 126 … … 322 323 if(_currentName && _currentName.length > 0){parameters["s1.name"] = _currentName;} 323 324 if(_currentMatch && _currentMatch.length > 0){parameters["s1.match"] = _currentMatch;} 325 if(_currentXPath && _currentXPath.length > 0){parameters["s1.xpath"] = _currentXPath} 324 326 325 327 _saveButton.button("option", "disabled", true); … … 610 612 var templateListStart = templateResponse.indexOf("<templateList>") + "<templateList>".length; 611 613 var templateListEnd = templateResponse.indexOf("</templateList>"); 614 615 if(templateListStart == "<templateList>".length - 1) 616 { 617 return; 618 } 619 612 620 var templateListString = templateResponse.substring(templateListStart, templateListEnd).replace(/"/g, "\""); 613 621 var templateList = eval(templateListString); … … 625 633 var name = templateList[i].name; 626 634 var match = templateList[i].match; 635 var xpath = templateList[i].xpath; 627 636 628 637 if(name) … … 639 648 _elements.push(infoContainer); 640 649 641 addChangeEventToInfoContainer(infoContainer, filename, location, nodename, namespace, name, match );650 addChangeEventToInfoContainer(infoContainer, filename, location, nodename, namespace, name, match, xpath); 642 651 643 652 if(name && name.length > 0) 644 653 { 645 infoContainer.text(name );654 infoContainer.text(name + ((xpath) ? (" (" + xpath + ")") : "")); 646 655 } 647 656 if(match && match.length > 0) 648 657 { 649 infoContainer.text(match );658 infoContainer.text(match + ((xpath) ? (" (" + xpath + ")") : "")); 650 659 } 651 660 … … 662 671 663 672 //Change the current template in the XML and Visual editor 664 this.changeCurrentTemplate = function(location, filename, nodename, namespace, name, match )673 this.changeCurrentTemplate = function(location, filename, nodename, namespace, name, match, xpath) 665 674 { 666 675 _currentFileName = filename; … … 670 679 _currentName = name; 671 680 _currentMatch = match; 672 681 _currentXPath = xpath; 682 673 683 var responseName = "requestedNameTemplate"; 674 684 675 var url = gs.xsltParams.library_name + "?a=g&rt=r&s=GetXMLTemplateFromFile&s1.fileName=" + filename + "&s1.interfaceName=" + gs.xsltParams.interface_name + "&s1.siteName=" + gs.xsltParams.site_name + "&s1.collectionName=" + gs.cgiParams.c + "&s1.locationName=" + location + "&s1.namespace=" + namespace + "&s1.nodename=" + nodename; 676 if(match && match.length > 0){url += "&s1.match=" + match; responseName = "requestedMatchTemplate";} 677 if(name && name.length > 0){url += "&s1.name=" + name;} 678 679 $.ajax(url) 685 var url = gs.xsltParams.library_name; 686 var params = {"a":"g", "rt":"r", "s":"GetXMLTemplateFromFile", "s1.fileName":filename, "s1.interfaceName":gs.xsltParams.interface_name, "s1.siteName":gs.xsltParams.site_name, "s1.collectionName":gs.cgiParams.c, "s1.locationName":location, "s1.namespace":namespace, "s1.nodename":nodename}; 687 688 if(match && match.length > 0){params["s1.match"] = match; responseName = "requestedMatchTemplate";} 689 if(name && name.length > 0){params["s1.name"] = name;} 690 if(xpath && xpath.length > 0){params["s1.xpath"] = xpath} 691 692 $.post(url, params) 680 693 .success(function(response) 681 694 { … … 748 761 749 762 //Store the function that is called when this template is selected from the list 750 var addChangeEventToInfoContainer = function(infoContainer, filename, location, nodename, namespace, name, match )763 var addChangeEventToInfoContainer = function(infoContainer, filename, location, nodename, namespace, name, match, xpath) 751 764 { 752 765 infoContainer.data("changeFunction", function() 753 766 { 754 _greenbug.changeCurrentTemplate(location, filename, nodename, namespace, name, match );767 _greenbug.changeCurrentTemplate(location, filename, nodename, namespace, name, match, xpath); 755 768 }); 756 769 } … … 864 877 var name = $(this).attr("name"); 865 878 var match = $(this).attr("match"); 879 var xpath = $(this).attr("xpath"); 866 880 867 881 var file = _greenbug.fileNameToLocationAndName(filepath); … … 871 885 _elements.push(infoContainer); 872 886 873 addChangeEventToInfoContainer(infoContainer, file.filename, file.location, nodename, namespace, name, match );887 addChangeEventToInfoContainer(infoContainer, file.filename, file.location, nodename, namespace, name, match, xpath); 874 888 875 889 if(name && name.length > 0) 876 890 { 877 infoContainer.text(name );891 infoContainer.text(name + ((xpath) ? (" (" + xpath + ")") : "")); 878 892 } 879 893 if(match && match.length > 0) 880 894 { 881 infoContainer.text(match );895 infoContainer.text(match + ((xpath) ? (" (" + xpath + ")") : "")); 882 896 } 883 897 -
main/trunk/greenstone3/web/interfaces/default/js/javascript-global-functions.js
r26431 r27713 1 var SUCCESS = 1; 2 var ACCEPTED = 2; 3 var ERROR = 3; 4 var CONTINUING = 10; 5 var COMPLETED = 11; 6 var HALTED = 12; 7 1 8 gs.functions = new Array(); 2 9 … … 93 100 } 94 101 102 gs.functions.checkForErrors = function(xml) 103 { 104 var errorElems = xml.getElementsByTagName("error"); 105 106 if(errorElems && errorElems.length > 0) 107 { 108 var errorString = gs.text.dse.error_saving_changes + ": "; 109 for(var i = 0; i < errorElems.length; i++) 110 { 111 errorString += " " + errorElems.item(i).firstChild.nodeValue; 112 } 113 alert(errorString); 114 return true; 115 } 116 return false; //No errors 117 } 118 119 gs.functions.validateXML = function(txt) 120 { 121 // code for IE 122 if (window.ActiveXObject) 123 { 124 var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 125 xmlDoc.async = "false"; 126 xmlDoc.loadXML(document.all(txt).value); 127 128 if(xmlDoc.parseError.errorCode!=0) 129 { 130 txt = dse.error_code + ": " + xmlDoc.parseError.errorCode + "\n"; 131 txt = txt + dse.error_reason + ": " + xmlDoc.parseError.reason; 132 txt = txt + dse.error_line + ": " + xmlDoc.parseError.line; 133 console.log(txt); 134 return null; 135 } 136 137 return xmlDoc; 138 } 139 // code for Mozilla, Firefox, Opera, etc. 140 else if (document.implementation.createDocument) 141 { 142 var parser = new DOMParser(); 143 var xmlDoc = parser.parseFromString(txt,"text/xml"); 144 145 if (xmlDoc.getElementsByTagName("parsererror").length > 0) 146 { 147 console.log(gs.text.dse.xml_error); 148 return null; 149 } 150 151 return xmlDoc; 152 } 153 else 154 { 155 console.log(gs.text.dse.browse_cannot_validate_xml); 156 } 157 return null; 158 } 159 95 160 gs.functions.buildCollections = function(collections, finalFunction) 96 161 { … … 105 170 { 106 171 var ajax = new gs.functions.ajaxRequest(); 107 ajax.open("GET", _baseURL+ "?a=g&rt=r&ro=1&s=BuildCollection&s1.collection=" + collections[counter]);172 ajax.open("GET", gs.xsltParams.library_name + "?a=g&rt=r&ro=1&s=BuildCollection&s1.collection=" + collections[counter]); 108 173 ajax.onreadystatechange = function() 109 174 { … … 111 176 { 112 177 var text = ajax.responseText; 113 var xml = validateXML(text);114 115 if(!xml || checkForErrors(xml))178 var xml = gs.functions.validateXML(text); 179 180 if(!xml || gs.functions.checkForErrors(xml)) 116 181 { 117 182 console.log("Could not build collection -> " + collections[counter] + ", aborting"); … … 122 187 var pid = status.getAttribute("pid"); 123 188 124 startCheckLoop(pid, "BuildCollection", function()189 gs.functions.startCheckLoop(pid, "BuildCollection", function() 125 190 { 126 191 var localAjax = new gs.functions.ajaxRequest(); 127 localAjax.open("GET", _baseURL+ "?a=g&rt=r&ro=1&s=ActivateCollection&s1.collection=" + collections[counter], true);192 localAjax.open("GET", gs.xsltParams.library_name + "?a=g&rt=r&ro=1&s=ActivateCollection&s1.collection=" + collections[counter], true); 128 193 localAjax.onreadystatechange = function() 129 194 { … … 131 196 { 132 197 var localText = localAjax.responseText; 133 var localXML = validateXML(localText);198 var localXML = gs.functions.validateXML(localText); 134 199 135 if(!xml || checkForErrors(xml))200 if(!xml || gs.functions.checkForErrors(xml)) 136 201 { 137 202 console.log("Could not activate collection -> " + collections[counter] + ", aborting"); … … 143 208 { 144 209 var localPID = localStatus.getAttribute("pid"); 145 startCheckLoop(localPID, "ActivateCollection", function()210 gs.functions.startCheckLoop(localPID, "ActivateCollection", function() 146 211 { 147 if (++counter == _collections.length)212 if (++counter == collections.length) 148 213 { 149 214 //Run this function once we are done building all the collections … … 167 232 } 168 233 169 function startCheckLoop(pid, serverFunction, callbackFunction)234 gs.functions.startCheckLoop = function(pid, serverFunction, callbackFunction) 170 235 { 171 236 var ajaxFunction = function() 172 237 { 173 238 var ajax = new gs.functions.ajaxRequest(); 174 ajax.open("GET", _baseURL+ "?a=g&rt=s&ro=1&s=" + serverFunction + "&s1.pid=" + pid, true);239 ajax.open("GET", gs.xsltParams.library_name + "?a=g&rt=s&ro=1&s=" + serverFunction + "&s1.pid=" + pid, true); 175 240 ajax.onreadystatechange = function() 176 241 { … … 178 243 { 179 244 var text = ajax.responseText; 180 var xml = validateXML(text);245 var xml = gs.functions.validateXML(text); 181 246 182 if(!xml || checkForErrors(xml))247 if(!xml || gs.functions.checkForErrors(xml)) 183 248 { 184 249 console.log("Could not check status of " + serverFunction + ", there was an error in the XML, aborting"); -
main/trunk/greenstone3/web/interfaces/default/js/visual-xml-editor.js
r27256 r27713 1151 1151 { 1152 1152 var url = gs.xsltParams.library_name + "?a=g&rt=r&s=ResolveCallTemplate&s1.interfaceName=" + gs.xsltParams.interface_name + "&s1.siteName=" + gs.xsltParams.site_name + "&s1.collectionName=" + gs.cgiParams.c + "&s1.fileName=" + _fileName + "&s1.templateName=" + _xmlNode.getAttribute("name"); 1153 $.ajax(url)1154 .success(function(response)1153 1154 var successFunction = function(response) 1155 1155 { 1156 1156 var startIndex = response.indexOf("<requestedTemplate>") + ("<requestedTemplate>").length; … … 1171 1171 _greenbug.changeCurrentTemplate("interface", "gslib.xsl", "template", "xsl", _xmlNode.getAttribute("name"), null); 1172 1172 } 1173 }); 1173 } 1174 1175 var errorFunction = function() 1176 { 1177 $.ajax(url).success(successFunction).error(errorFunction); 1178 } 1179 1180 $.ajax(url).success(successFunction).error(errorFunction); 1174 1181 } 1175 1182
Note:
See TracChangeset
for help on using the changeset viewer.