| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- /* megascript */
- _WIN.tx = {};
- function each(a, f) {
- for (var i = 0, l = a.length; i < l; i++) f(a[i]);
- }
- _WIN.installHyperscript = function(namespace, oDocument) {
- each('a big blockquote br b center code dd dl dt div em font form h1 h2 h3 h4 h5 h6 hr img iframe input i li ol option pre p script select small span strike strong style sub sup table tbody td textarea tr ul u'.split(' '),
- function(label) {
- namespace[label]=function(){
- var tag=oDocument.createElement(label);
- each(arguments, function(arg){
- if(arg.nodeType) {
- tag.appendChild(arg);
- } else if(typeof arg=='string' || typeof arg=='number') {
- if(label == "textarea") {
- if($tx.msie) {
- tag.value+=arg;
- } else {
- tag.text+=arg;
- }
- } else {
- tag.innerHTML+=arg;
- }
- } else if(typeof arg=='array') {
- for(var i=0; i<arg.length; i++) {
- tag.appendChild(arg[i]);
- }
- } else {
- for(var attr in arg) {
- if(attr=='style') {
- for(var sty in arg[attr]) {
- if((sty == 'float' || sty == 'cssFloat')) {
- tag[attr][tag[attr].styleFloat === _UNDEFINED ? 'cssFloat' : 'styleFloat'] = arg[attr][sty];
- } else {
- tag[attr][sty]=arg[attr][sty];
- }
- }
- } else if(["more", "less", "longDesc"].contains(attr)) { // custom attributes
- if (tag.setAttribute) {
- tag.setAttribute(attr, arg[attr]);
- }
- } else if (["colSpan", "rowSpan", "cellPadding", "cellSpacing"].contains(attr)) { // nonstandard attributes
- if (tag.setAttribute) {
- tag.setAttribute(attr, arg[attr]);
- }
- } else {
- if (arg[attr]) {
- tag[attr] = arg[attr];
- }
- }
- }
- }
- });
- return tag;
- };
- });
- };
- installHyperscript(_WIN.tx, _DOC);
|