fixes
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 28 Jun 2006 15:57:40 +0000 (15:57 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 28 Jun 2006 15:57:40 +0000 (15:57 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@4816 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/cat/marcedit.js
Open-ILS/xul/staff_client/server/cat/marcedit.xul

index 9147c95..1624caa 100644 (file)
@@ -1,3 +1,5 @@
+var xmlDeclaration = /^<\?xml version[^>]+?>/;
+
 var serializer = new XMLSerializer();
 var marcns = new Namespace("http://www.loc.gov/MARC21/slim");
 var gw = new Namespace("http://opensrf.org/-/namespaces/gateway/v1");
@@ -9,6 +11,60 @@ var current_focus;
 var _record_type;
 var bib_data;
 
+var xml_record;
+
+function my_init() {
+       try {
+               // Fake xulG for standalone...
+               try {
+                       window.xulG.record;
+               } catch (e) {
+                       window.xulG = {};
+                       window.xulG.record = {};
+                       window.xulG.save = {};
+
+                       window.xulG.save.label = 'Save Record';
+                       window.xulG.save.func = function (r) { alert(r); }
+
+                       var cgi = new CGI();
+                       var _rid = cgi.param('record');
+                       if (_rid) {
+                               window.xulG.record.url = '/opac/extras/supercat/retrieve/marcxml/record/' + _rid;
+                       }
+               }
+               // End faking part...
+
+               document.getElementById('save-button').setAttribute('label', window.xulG.save.label);
+               document.getElementById('save-button').setAttribute('oncommand', 'window.xulG.save.func(xml_record.toXMLString())');
+
+               if (window.xulG.record.url) {
+                       var req =  new XMLHttpRequest();
+                       req.open('GET',window.xulG.record.url,false);
+                       req.send(null);
+                       window.xulG.record.marc = req.responseText.replace(xmlDeclaration, '');
+               }
+
+               xml_record = new XML( window.xulG.record.marc );
+               xml_record = xml_record..record[0];
+
+               // Get the tooltip xml all async like
+               req =  new XMLHttpRequest();
+               req.open('GET','marcedit-tooltips.xml',true);
+               req.onreadystatechange = function () {
+                       if (req.readyState == 4) {
+                               bib_data = new XML( req.responseText.replace(xmlDeclaration, '') );
+                               genToolTips();
+                       }
+               }
+               req.send(null);
+
+               loadRecord(xml_record);
+       } catch(E) {
+               alert('FIXME, MARC Editor: ' + E);
+       }
+}
+
+
 function createComplexHTMLElement (e, attrs, objects, text) {
        var l = document.createElementNS('http://www.w3.org/1999/xhtml',e);
 
index 5b6caae..2275462 100644 (file)
@@ -2,7 +2,7 @@
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
 <?xml-stylesheet href="marcedit.css" type="text/css"?>
 
-<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:xhtml="http://www.w3.org/1999/xhtml" onload="try{my_init();loadRecord(xml_record);}catch(E){alert('FIXME: '+E);}">
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:xhtml="http://www.w3.org/1999/xhtml" onload="my_init()">
 
 <script src="marcedit.js" type="application/x-javascript; e4x=1"/>
 <script src="/opac/common/js/CGI.js" type="application/x-javascript; e4x=1"/>
        </popup>
 </popupset>
 
-<script type="application/x-javascript; e4x=1"><![CDATA[
-
-var xml_record;
-
-function my_init() {
-       try {
-               // Fake xulG for standalone...
-               try {
-                       window.xulG.record;
-               } catch (e) {
-                       window.xulG = {};
-                       window.xulG.record = {};
-                       window.xulG.save = {};
-
-                       window.xulG.save.label = 'Save Record';
-                       window.xulG.save.func = function (r) { alert(r); }
-
-                       var cgi = new CGI();
-                       var _rid = cgi.param('record');
-                       if (_rid) {
-                               window.xulG.record.url = '/opac/extras/supercat/retrieve/marcxml/record/' + _rid;
-                       }
-               }
-               // End faking part...
-
-               document.getElementById('save-button').setAttribute('label', window.xulG.save.label);
-               document.getElementById('save-button').setAttribute('oncommand', 'window.xulG.save.func(xml_record.toXMLString())');
-
-               if (window.xulG.record.url) {
-                       var req =  new XMLHttpRequest();
-                       req.open('GET',window.xulG.record.url,false);
-                       req.send(null);
-                       window.xulG.record.marc = req.responseText
-               }
-
-               xml_record = new XML( window.xulG.record.marc );
-
-               // Get the tooltip xml all async like
-               req =  new XMLHttpRequest();
-               req.open('GET','marcedit-tooltips.xml',true);
-               req.onreadystatechange = function () {
-                       if (req.readyState == 4) {
-                               bib_data = new XML( req.responseText );
-                               genToolTips();
-                       }
-               }
-               req.send(null);
-       } catch(E) {
-               alert('FIXME, MARC Editor: ' + E);
-       }
-}
-
-]]></script>
-
 </window>