wisemapping-open-source/core-js/src/main/javascript/Utils.js

64 lines
2.0 KiB
JavaScript
Raw Normal View History

2012-09-14 02:18:00 +02:00
/*
* Copyright [2011] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
2009-07-09 22:06:08 +02:00
*/
2011-09-05 02:32:29 +02:00
core.Utils = {
2009-06-07 20:59:43 +02:00
};
core.Utils.innerXML = function(/*Node*/node) {
// summary:
// Implementation of MS's innerXML function.
if ($defined(node.innerXML)) {
2009-06-07 20:59:43 +02:00
return node.innerXML;
// string
} else if ($defined(node.xml)) {
2009-06-07 20:59:43 +02:00
return node.xml;
// string
} else if ($defined(XMLSerializer)) {
2009-06-07 20:59:43 +02:00
return (new XMLSerializer()).serializeToString(node);
// string
}
};
core.Utils.createDocument = function() {
// summary:
// cross-browser implementation of creating an XML document object.
var doc = null;
var _document = window.document;
if ($defined(window.ActiveXObject)) {
2009-06-07 20:59:43 +02:00
var prefixes = [ "MSXML2", "Microsoft", "MSXML", "MSXML3" ];
for (var i = 0; i < prefixes.length; i++) {
try {
doc = new ActiveXObject(prefixes[i] + ".XMLDOM");
} catch(e) { /* squelch */
}
2012-05-27 23:15:46 +02:00
2009-06-07 20:59:43 +02:00
if ($defined(doc)) {
2009-06-07 20:59:43 +02:00
break;
}
}
} else if ((_document.implementation) &&
(_document.implementation.createDocument)) {
2009-06-07 20:59:43 +02:00
doc = _document.implementation.createDocument("", "", null);
}
return doc;
// DOMDocument
};