Update of /cvsroot/dynapi/dynapi2x/src/dynapi
In directory usw-pr-cvs1:/tmp/cvs-serv15575/src/dynapi

Added Files:
        debug.html debug.js functions.js library.html library.js 
Log Message:
Initial Import == 2.9

--- NEW FILE ---
<title>DynAPI Debugger</title>
<script>

var dynapi = window.opener.dynapi;

function handleError(msg, url, lno) {
        dynapi.debug.error(msg, "Debugger", lno);
};

this.onload = function() {
        if (dynapi._debugBuffer) {
                dynapi.debug.print(dynapi._debugBuffer);
                dynapi._debugBuffer = '';
        }
}

if (!dynapi.ua.ns6) self.onerror = handleError;

</script>
<style type="text/css">
</style>
<body bgcolor="#D4D0C8" leftmargin=10 topmargin=10">

<script>
var str='<form name=debugform><font face="'+(dynapi.ua.mac?'Monaco':'Courier')+'" 
size="1">'+
        '<table cellspacing=0 cellpadding=0 border=0><tr><td colspan=2>'+
        '<textarea name="print" cols="'+(dynapi.ua.mac? (dynapi.ua.ie?42:42) :40)+'" 
rows="'+(dynapi.ua.ie?12:13)+'" wrap="off"></textarea><br>'+
        '<input type=text name="stat" size="'+(dynapi.ua.mac? (dynapi.ua.ie?44:46) 
:42)+'" '+(dynapi.ua.ie?'style="font-family:Monaco;"':'')+' value="DynAPI 
'+dynapi.version+'"/><br>'+
        '<textarea name="eval" cols="'+(dynapi.ua.mac? (dynapi.ua.ie?42:42) :40)+'" 
rows="'+(dynapi.ua.ie?7:8)+'" wrap="off"></textarea><br>'+
        '</td></tr><tr>'+
        '<td><input type=button value="Evaluate" 
onclick="window.opener.DynAPI.debug.evaluate(this.form.eval.value)"></td>'+
        '<td align=right><input type="button" value="Clear" 
onclick="{this.form.print.value=\'\'; this.form.stat.value=\'\'; 
this.form.eval.value=\'\';}"></td></tr></table>'+
        '</font></form>';
document.open();
document.write(str);
document.close();

</script>
</body>
--- NEW FILE ---
/*
        DynAPI Distribution
        Debugger

        The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
*/

function Debugger() {
        this.inherit('DynObject');
        this.win = null;
}
dynapi.setPrototype('Debugger','DynObject');
Debugger.prototype.isLoaded = function() {return (this.win && 
this.win.document.debugform)};
Debugger.prototype.status = function(str) {
        if (this.isLoaded()) {
                for (var i=1;i<arguments.length;i++) {
                        str += ', '+arguments[i];
                }
                this.win.document.debugform.stat.value = str;
        };
};
Debugger.prototype.inspect = function(obj,showFunctions) {
        this.print('Inspecting:');
        var v;
        for (var i in obj) {
                if (obj[i]==null) v = "null";
                else if (typeof(obj[i])=='function') {
                        if (showFunctions==false) continue;
                        else v = '[Function]';
                }
                else if (typeof(obj[i])=='object' && obj[i].length) v = 'Array 
['+obj[i]+']';
                else if (typeof(obj[i])=='object') v = '[Object]';
                else v = obj[i];
                this.print('    '+i+' = '+v);
        }
};
Debugger.prototype.print = function(s) {
        if (this.isLoaded()) {
                for (var i=1;i<arguments.length;i++) {  // accommodate print(v1,v2,v3)
                        s += ', '+arguments[i];
                }
                this.win.document.debugform.print.value += s +'\n';
        }
        else {
                if (!dynapi._debugBuffer) dynapi._debugBuffer = s;
                else dynapi._debugBuffer += '\n'+s;
        }
};
Debugger.prototype.error = function(msg, url, lno) {
        if (url && url.indexOf(dynapi.documentPath)==0) {
                url = url.substring(dynapi.documentPath.length);
        }
        this.print('Error:'+ (lno? ' Line '+lno : '') +' ['+url+']\n       '+msg);
};
Debugger.prototype.evaluate = function(str) {
        window.eval(str);
};
Debugger.prototype.setEvaluate = function(str) {
        if (this.isLoaded()) this.win.document.debugform.eval.value = str
};
Debugger.prototype.open = function() {
        var p = dynapi.library.path;
        if (!this.isLoaded() && p) {
                var url = dynapi.documentPath+p+'debug.html#';
                var w = dynapi.ua.mac? (dynapi.ua.ie?330:300) : 360;
                var h = dynapi.ua.mac? (dynapi.ua.ie?405:365) : dynapi.ua.ie? 420:465;
                this.win = 
window.open(url,'debugwin','width='+w+',height='+h+',scrollbars=no,status=no,toolbar=no,resizable=no');
                /*if (dynapi.ua.ns4) {  // move the debug window to the right edge?
                        var f = dynapi.frame;
                        var ns4 = dynapi.ua.ns4;
                        var sX = ns4? f.screenX : f.screenLeft;
                        var sY = ns4? f.screenY : f.screenTop;
                        var sW = ns4? f.outerWidth : 100;
                        if (sX!=null && sY!=null && sW!=null) 
this.win.moveTo(sX+sW,sY);
                }*/
                this.win.focus();
                if (dynapi._debugBuffer) {
                        dynapi.debug.print(dynapi._debugBuffer);
                        dynapi._debugBuffer = '';
                }
                dynapi.frame.onerror = function(msg, url, lno) {
                        dynapi.debug.error(msg, url, lno);
                };
        }
};
Debugger.prototype.close = function() {
        if (this.isLoaded()) {
                this.win.close();
                this.win = null;
        }
};
dynapi.debug = new Debugger();
dynapi.debug.open();

/*dynapi.onUnload(function() {
        dynapi.debug.close();  // close the debug window on unload
});*/

--- NEW FILE ---
/*
        DynAPI Distribution
        dynapi.functions extension
        
        The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
*/

dynapi.functions.DecToHex = function(val){
        lo=val%16;
        val-=lo;
        lo+=48;
        if (lo>57) lo+=7;
        hi=val/16;
        hi+=48;
        if (hi>57) hi+=7;
        return String.fromCharCode(hi,lo);
};
dynapi.functions.getColor = function(r,g,b) { 
        return 
'#'+dynapi.functions.DecToHex(r)+dynapi.functions.DecToHex(g)+dynapi.functions.DecToHex(b);
};
dynapi.functions.createRedPal = function(pal) {
        var r=g=b=0;
        for (var i=0; i<256; i++){
                pal[i]=dynapi.functions.getColor(r,g,b);
                r+=8;
                if (r>255) { r=255; g+=6; b+=2; }
                if (g>255) { g=255; b+=2; }
                if (b>255) { b=255; }
        }
};
dynapi.functions.createGrayPal = function(pal) {
        var r=0;
        for (var i=0; i<256; i++){
                pal[i]=dynapi.functions.getColor(r,r,r);
                r+=4;
                if (r>255) { r=255; }
        }
};
dynapi.functions.createBluePal = function(pal){
        var r=g=b=0;
        for (var i=0; i<256; i++){
                pal[i]=dynapi.functions.getColor(r,g,b);
                b+=6;
                if (b>255) { b=255; g+=2; }
                if (g>255) { g=255; r+=2; }
        }
};
dynapi.functions.createGreenPal = function(pal) {
        var r=g=b=0;
        for (var i=0; i<256; i++){
                pal[i]=dynapi.functions.getColor(r,g,b);
                g+=6;
                if (g>255) { g=255; b+=2; }
                if (b>255) { b=255; r+=2; }
        }
};
dynapi.functions.radianToDegree = function(radian) {
        return radian*180/Math.PI
};
dynapi.functions.degreeToRadian = function(degree) {
        return degree*Math.PI/180
};
dynapi.functions.sintable = function(lsin) {
        for (var i=0; i<361; i+=1) lsin[i]=Math.sin((i/180)*Math.PI);
};
dynapi.functions.costable = function(lcos) {
        for (var i=0; i<361; i+=1) lcos[i]=Math.cos((i/180)*Math.PI);
};
--- NEW FILE ---
<script>
dynapi.library._handleLoad(this);
</script>
--- NEW FILE ---
/*
        DynAPI Distribution
        Dynamic Loading extension to dynapi.library

        The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
*/

DynAPILibrary.prototype.a = function() {alert('hi')};

// begin loading the object
DynAPILibrary.prototype.load = function(n,fn) {
        var list = this._queue(n,null,arguments[2]);
        //return dynapi.debug.print('going to load: '+list);
        if (list.length) {
                var s,src;
                for (var i=0;i<list.length;i++) {
                        src = list[i];
                        s = this.scripts[list[i]];
                        if (i==list.length-1 && fn!=null) s.fn = fn;
                        this.loadList[this.loadList.length] = src;
                }
                this._load();
        }
        else if (fn) fn();
};

// reload the object
DynAPILibrary.prototype.reload = function(n,fn,force) {
        var s = this.objects[n];
        if (s) {
                s.loaded = false;
                this.load(n,fn,force);
        }
};

// load a script that is not added to the library
DynAPILibrary.prototype.loadScript = function(src,fn) {
        if (!this.scripts[src]) {
                var n = 'unnamed'+this._c++;
                s = this.add(n,src);  // generate a name for the script
                s.unnamed = true;
                s.fn = null;
                s.dep = [];
                this.load(n,fn);
        }
};

// inserts the script element into the page
DynAPILibrary.prototype._load = function() {
        if (this.busy) return; // dynapi.debug.print('Library Warning: busy');
        else {
                if (this.loadIndex<this.loadList.length-1) {
                        this.busy = true;
                        this.loadIndex++;
                        var src = this.loadList[this.loadIndex];
                        //if (!confirm('load: '+src+' ?')) return;
                        var rsrc = src + '?'+Math.random();     // random ensures 
cached files are not loaded
                        var s = this.scripts[src];
                        if (dynapi.ua.ns4) {
                                // delete the constructors
                                for (var j=0;j<s.objects.length;j++) {
                                        var n = s.objects[j];
                                        if (dynapi.frame[n]) {
                                                dynapi.frame[n] = null;
                                                if (s.pkg) dynapi.frame[s.pkg+'.'+n] = 
null;
                                        }
                                }
                                this.elm.src = dynapi._path+'library.html?js='+src;
                        }
                        else if (dynapi.ua.ie && (dynapi.v==4 || dynapi.ua.mac)) {
                                
dynapi.frame.document.body.insertAdjacentHTML('beforeEnd','<script 
language="javascript" src="'+rsrc+'" defer><\/script>');
                                this._export(src);
                        }
                        else {
                                var elm = s.elm = 
dynapi.frame.document.createElement('script');
                                elm.src = rsrc;
                                elm.type = 'text/javascript';
                                elm.defer = true;
                                if (dynapi.ua.ie) {
                                        elm.C = 0;
                                        var o = this;
                                        elm.onreadystatechange = function() {
                                                elm.C++;
                                                if (elm.C==2) {  // use 2nd 
statechange for onload
                                                        o._export(src);
                                                }
                                        }
                                }
                                
dynapi.frame.document.getElementsByTagName('head')[0].appendChild(elm);
                                
                                // I could not find way to know when the script is 
complete in Moz v0.9.3
                                if (dynapi.ua.ns6) 
setTimeout(this+'._export("'+src+'")',100);
                        }
                }
        }
};

// executed after a script is finished loading, run main() functions
DynAPILibrary.prototype._export = function(src) {
        var src = this.loadList[this.loadIndex];
        var s = this.scripts[src];
        if (s) {
                this._register(s);
                
                // run main() if available
                if (!dynapi.ua.ns4 && typeof(main)=="function") {
                        main();
                        main = null;
                }
                
                if (dynapi.ua.ns4) {
                        if (typeof(this.elm.main)=="function") {
                                this.elm.main();
                                this.elm.main = null;
                        }
                        // check global main after elm.main
                        else if (typeof(main)=="function") {
                                main();
                                main = null;
                        }
                        // clear out all functions in the layer's scope
                        for (var i in this.elm[name]) {
                                if (typeof(this.elm[i])=="function") {
                                        delete this.elm[i];
                                }
                        }
                }
                this.busy = false;

                // load next file
                this._load();
        }
        else return alert('Library Error: unknown script '+src);
};

// registers the script as loaded, exports the objects
DynAPILibrary.prototype._register = function(s) {
        //dynapi.debug.print('loaded "'+s.src+'"');
        s.loaded = true;
        s.queued = false;
        if (!s.unnamed) {
                var n,found;
                // loop through each object that the script contains
                for (var i=0;i<s.objects.length;i++) {
                        found = false;
                        n = s.objects[i];
                        
                        // scope local objects in the layer to the DynAPI frame
                        if (dynapi.ua.ns4 && this.elm && 
typeof(this.elm[n])=="function") {
                                dynapi.frame[n] = this.elm[n];
                                found = true;
                        }
                        else if (typeof(dynapi.frame[n])=="function" || 
typeof(dynapi.frame[n])=="object") found = true;
                        else if (n.indexOf('.')>0) {
                                var ns = n.split('.'), o = dynapi.frame, b = false;
                                for (var j=0;j<ns.length;j++) {
                                        o = o[ns[j]];
                                }
                                if (typeof(o)=="function" || typeof(o)=="object") 
found = true;
                        }
                        else if (typeof(dynapi[n])=="object") found = true;
                        
                        if (found) {
                                if (s.pkg) {
                                        // make package link eg dynapi.api.DynLayer
                                        if (s.pkg!="dynapi") this.packages[s.pkg][n] = 
dynapi.frame[n];
                                        n = s.pkg+'.'+n;
                                }
                                dynapi.debug.print('loaded ['+n+']');
                        }
                        else {
                                dynapi.debug.print('Library Error: could not find 
['+n+']');
                        }
                }
        }
        // run handler if available
        if (s.fn) {
                s.fn();
                delete s.fn;
        }
};

// called from /lib/dynapi/library.html to write the <script>, NS4 only
DynAPILibrary.prototype._handleLoad = function(elm) {
        var args = dynapi.functions.getURLArguments(elm.src);
        var js = args["js"];
        if (js) {
                if (js.indexOf('http')!=0) {
                        var l = dynapi.frame.document.location;
                        if (js.substr(0,1)=='/') js = l.port+'//'+host+src;
                        else js = dynapi.documentPath+js;
                }
                //if (!confirm('write '+js+' ?')) return dynapi.library._export(js);
                elm.document.write('<script language="JavaScript" 
src="'+js+'?r'+Math.random()+'"><\/script>');
                elm.document.close();
                elm.onload = function() {
                        dynapi.library._export(js);
                }
        }
};

// inserts the layer for NS4, register included scripts
DynAPILibrary.prototype._create = function() {
        // ensure a previous main function is wiped out
        if (typeof(main)=="function") main = null;
                
        // register objects from scripts included by dynapi.library.include() or 
manually
        var s;
        for (var i in this.scripts) {
                s = this.scripts[i];
                if (s.loaded || (s.objects[0] && dynapi.frame[s.objects[0]])) 
this._register(s);
        }
        
        // create NS4 layer to load scripts into
        if (dynapi.ua.ns4) this.elm = new Layer(0, dynapi.frame);
        this.busy = false;
        
        if (this.loadList.length) {
                var s = this.scripts[this.loadList[this.loadList.length-1]];
                s.fn = function() {
                        setTimeout('dynapi._onLoad()',1);
                }
                this._load();
        }
        else setTimeout('dynapi._onLoad()',1);
};


_______________________________________________
Dynapi-CVS mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dynapi-cvs

Reply via email to