2009/dap/ReSpec.js/js respec.js,1.48,1.49

Update of /sources/public/2009/dap/ReSpec.js/js
In directory hutz:/tmp/cvs-serv28240/js

Modified Files:
	respec.js 
Log Message:
fixed local SHJS; added RFC3490

Index: respec.js
===================================================================
RCS file: /sources/public/2009/dap/ReSpec.js/js/respec.js,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- respec.js	7 Oct 2009 15:44:34 -0000	1.48
+++ respec.js	15 Oct 2009 11:04:38 -0000	1.49
@@ -83,6 +83,7 @@
         "WG-NOTE":  "NOTE",
     },
     
+    isLocal:    false,
     loadAndRun:    function () {
         var scripts = document.querySelectorAll("script[src]");
         var rs, base;
@@ -94,6 +95,7 @@
             }
         }
         this.base = base;
+        if (base.indexOf("file://") == 0) this.isLocal = true;
         
         var loaded = [];
         var deps = ["js/simple-node.js", "js/shortcut.js", "bibref/biblio.js", "js/sh_main.min.js"];
@@ -107,6 +109,29 @@
             sel.setAttribute("class", "remove");
             sel.onload = function (ev) {
                 loaded.push(ev.target.src);
+                if (obj.isLocal && ev.target.src.indexOf("sh_main") > 0) {
+                    // dirty hack to fix local loading of SHJS
+                    this.oldSHLoad = window.sh_load;
+                    window.sh_load = function (language, element, prefix, suffix) {
+                        if (language in sh_requests) {
+                            sh_requests[language].push(element);
+                            return;
+                        }
+                        sh_requests[language] = [element];
+                        var url = prefix + 'sh_' + language + suffix;
+                        var shLang = document.createElement('script');
+                        shLang.type = 'text/javascript';
+                        shLang.src = url;
+                        shLang.setAttribute("class", "remove");
+                        shLang.onload = function (ev) {
+                            var elements = sh_requests[language];
+                            for (var i = 0; i < elements.length; i++) {
+                                sh_highlightElement(elements[i], sh_languages[language]);
+                            }
+                        };
+                        head.appendChild(shLang);
+                    };
+                }
                 if (loaded.length == deps.length) {
                     sn = new berjon.simpleNode({
                         "":     "http://www.w3.org/1999/xhtml",

Received on Thursday, 15 October 2009 11:04:46 UTC