// -------------------------------------------------- // FILE: jt_std.js // JavaScript function for general use // (C) 2000 Janne Tuukkanen ( jatu@projannet.port5.com ) // no any kind of warranties or promises; if you use it, you suffer it // free for use, modificate and distribute // function swap(int i,j) // member function for Array objects // swaps items at positions i and j // no error checking function arraySwap(i,j) { var a = this[i]; this[i] = this[j]; this[j] = a; } Array.prototype.swap = arraySwap; function arrayPrintSrc(name) { var aL = this.length; var i = 0; var retStr = new String("var " + name + " = new Array(" + aL + "); "); for(i=0;i "FF" // 0x01 --> "01" function twoCharHex(i) { if (i==0) return "00"; else if (i < 16) return "0" + i.toString(16); return i.toString(16); } // function str2hex(inString) // returns ASCII hex values of characters, // i.e. "AA" --> "4141" function str2hex(inStr) { var l = inStr.length; var i=0; var retStr = new String; for(i=0;i "AA" function hex2str(inStr) { var l = inStr.length; var retStr = new String; var i=0; for(i=0; i>> 8; this.rB[2] = (dW & 0x00FF0000) >>> 16; this.rB[3] = (dW & 0xFF000000) >>> 24; this.toString = bytes2String(this.rB); // returns hex representation of the object } // function dWordInBytesFromString(str) // constructs dWordInBytes from four first characters // of argument function dWordInBytesFromString(str) { var retDw = new dWordInBytes(0); retDw.rB[0] = str.charCodeAt(0); retDw.rB[1] = str.charCodeAt(1); retDw.rB[2] = str.charCodeAt(2); retDw.rB[3] = str.charCodeAt(3); return retDw; } // function dWords2String(dWA) // argument dWA is array of 32-bit dwords // returns concatenated hex representation of // argument dwords // dWords2String(Array(0xFF0A12AA, 0xFF00FF00)) // --> String("FF0A12AAFF00FF00") function dWords2String(dWA) { var i=0; var retStr = new String; var aL = dWA.length; var d = new String; for(i=0;i