|
What is with the unroll factor and two loops? That is pointless ... running a for loop 600 times isn't what's slow.
Manipulating the DOM can be slow. You might do better to get .innerHTML, do a regex replace for '<option( selected)?' with either '<option' or '<option selected', and then reassign .innerHTML.
|
|
|
|
|
BobJanova wrote: Manipulating the DOM can be slow. You might do better to get .innerHTML, do a
regex replace for '<option( selected)?' with either '<option' or
'<option selected', and then reassign .innerHTML.
Thanks, I'll look into it.
BobJanova wrote: What is with the unroll factor and two loops? That is pointless ... running a
for loop 600 times isn't what's slow.
I'm a c/c++ programmer predominately, force of habit
|
|
|
|
|
Developed a working solution on IE8 though I did run into a select option truncate bug where the first option in innerHTML is removed.
But in the end I developed a workaround for this bug and have a working hack solution which is much much faster, so all is good.
cheers.
|
|
|
|
|
Hi
I hope somebody can help.
Apologies if the code below is not clear ,because this is my first post/query.
Basically i have a javascript function that is executed on the client side using onclientclick in my aspx , html page.
The javascript function "capt(fingerpos)" below invokes the activex objects which is declared in the aspx page in an object tag( see below).It is also registered in the client machine.
All the method calls work correctly , until i need to pass an array ( buf) by reference to the method
CSDCtrlClass.GetMemoryBuffer("BMP", buf);
This always returns an empty array . Ive tried declaring an object (BmpObject) and sending it to the activex method with the same result.
In c#( windows application) this com object works correctly when declaring BmpObject as object ,
and the return value of (buf) is populated by the activex method CSDCtrlClass.GetMemoryBuffer("BMP", buf);
My problem is i cannot understand why this method does not return the buffer/object in javascript , but does work in a normal windows application.
Obviously the handeling of the reference variable( either array or object) is different in javascript. But i have tried many different approaches , the return variable is always the same ( empty or null).
Any suggestions on how to handle this?
The actual return data is just a block of 8 bit bytes( bmp image) when executed in the working windows application.
html code snippet:
<object id="CSDCtrlClass" name="CSDCtrlClass"classid="CLSID:B228B13B-AD31-4523-AD58-5D52553EEC47" width="100" height="100"></object>
<script type ="text/javascript">
function capt(FingPos)
{
var BmpObject = {};
var buf = new Array(200000);
CSDCtrlClass.InitScannerExternal();
CSDCtrlClass.bInitKillScannerExternal = 1;
CSDCtrlClass.bAutoCapture = 1;
CSDCtrlClass.OutputFileMode = 0;
CSDCtrlClass.TransNo = "TranSample";
CSDCtrlClass.FingPos = FingPos;
CSDCtrlClass.OutputSaveFormat= "BMP_RAW_WSQ";
CSDCtrlClass.Capture();
if (CSDCtrlClass.ErrCode == -999)
{
alert("Capture Error:" + CSDCtrlClass.ErrCode);
return false;
}
try
{
CSDCtrlClass.GetMemoryBuffer("BMP", buf);
if (CSDCtrlClass.ErrCode != 0) {
alert("Capture Error:" + CSDCtrlClass.ErrCode);
return false;
}
alert(buf);
CSDCtrlClass.TerminateScannerExternal();
}
catch (err)
{
var txt = "";
txt = "ERROR[" + err.message + "]";
alert(txt);
}
</script>
|
|
|
|
|
Active X for IE
IE knows ID and NAME, but use ID not directly.
CSDCtrlClass. ..... useable only for IE
// +++++ get reference for all browsers
function GetReference(X00)
// X00 string, value of ID or NAME
// returns null in case of error
// returns never undefined
{
var X01=null;
var X02=false;
if((X00!=null)&&(X00!=undefined))
{if(X00.length>0)
{
// +++++
X02=..... // code to check only IE
// +++++ 1. try
if(X02){X01=window[X00];} // only if exactly IE
else{X01=document[X00];} // non IE
if(X01==undefined){X01=null;} // set reference undefined to null
// +++++ 2. try
if(X01==null)
{
X01=document.getElementById(X00);
if(X01==undefined){X01=null;} // set reference undefined to null
if(X01!=null)
{if(X01.id==undefined)
{X01=null;}
}
}
// +++++ 3. try
if(X01==null)
{
X01=document.getElementsByName(X00);
if(X01==undefined){X01=null;} // set reference undefined to null
if(X01!=null)
{if(X01.name==undefined)
{X01=null;}
}
}
}
}
return X01;
}
<object id="CSDCtrlClass" classid="CLSID:B228B13B-AD31-4523-AD58-5D52553EEC47" width="100" height="100">
var PointerOfActiveXObject=GetReference("CSDCtrlClass");
if(PointerOfActiveXObject!=null)
{PointerOfActiveXObject.InitScannerExternal();
// ActiveX-control must support Javascript interface (an HTML-DOM)
// e.g. InitScannerExternal() callable javascript function
// e.g. bInitKillScannerExternal supported javacript property
// for every call of any function of interface use an own try-catch
// try
// {CSDCtrlClass.InitScannerExternal();
// try
// {CSDCtrlClass.bInitKillScannerExternal = 1;}
// catch(e2)
// {...}
// }
// catch(e1)
// {....}
....
}
-------------------------------------------------------------
Using of ClassID see in this forum "Progress Bar 3:33 31 Aug '12 " entry 3:18 4 Sep '12
|
|
|
|
|
var PointerOfActiveXObject=GetReference("CSDCtrlClass");
this has the same result all the methods are working except for the method.
PointerOfActiveXObject.GetMemoryBuffer("BMP", buf);
the 'buf' does not return the bmp byte array it is still empty.
|
|
|
|
|
CSDCtrlClass.GetMemoryBuffer("BMP", buf);
what returns this function ?
var ReturnValue=CSDCtrlClass.GetMemoryBuffer("BMP", buf);
or
var buf = new Array(200000); // e.g. global var
CSDCtrlClass.GetMemoryBuffer("BMP", buf);
do something with buf
-----------------------------------------
var buf = new Array(200000); // empty
// init
var X00=0;
for(X00=0;X00<20000;X00+´+)
{buf[X00]= ....;}
// may be buf must have init values.
CSDCtrlClass.GetMemoryBuffer("BMP", buf); // 'BMP' okay value ?, what is the range of values ?
alert(buf); // means pointer buf
alert(buf[0]; // init value or other value ?
alert(buf.length) // 20000 ?
------------------------------------------
try
{
CSDCtrlClass.GetMemoryBuffer("BMP", buf);
if (CSDCtrlClass.ErrCode != 0) // possible inside of try ?
// ErrorCode may be like an "catch"
{.....} // try catch generally possible ?
}
-------------------------------------------
if (CSDCtrlClass.ErrCode != 0) // call a meber "ErrCode" of control
// so set this call between a try-catch
-------------------------------------------
catch (err) // param err is javascript and not from control
{ ....} // so not CSDCtrlClass.ErrCode
// try catch runs inside of html DOM and parsing of javascript
-------------------------------------------
if (CSDCtrlClass.ErrCode == -999) // CSDCtrlClass.ErrCode must be aviable inside of html DOM
// to compare with value inside of script
// CSDCtrlClass must be an pointer inside of html DOM tree
--------------------------------------------
don't forget: vars inside function are locally
may be control need global vars.
--------------------------------------------
crreate CSDCtrlClass dunymically with createElement() and appendChild()
so you get pointer of html DOM
var X05=document.createElement('object');
var X06=document.body.appendChild(X05);
.....
but Internet Explorer can have special way to create active-x-control dynamically.
--------------------------------------------
ask the developer of actice-x-control: rules of javascript interface of control
|
|
|
|
|
<b>CSDCtrlClass.GetMemoryBuffer("BMP", buf);
what returns this function ?
var ReturnValue=CSDCtrlClass.GetMemoryBuffer("BMP", buf);
or
var buf = new Array(200000); // e.g. global var</b>
THE RETURN VALUE OF THE FUNCTION IS ZERO , WHICH INDICATES THAT THE FUNCTION EXECUTED SUCCESSFULLY.
HOWEVER THE FUNCTION HAS 2 ARGUMENTS 1. "BMP" which is an input string and correct!
2. "buf" which is a return object of binary bytes
This is the array that is empty all the time.
It should be populated a block of binary data
representing a bitmap image( approx 154k), after the function is called.
PS when calling this function in c#( windows application) the 'buf' is declared as Object and passed by reference i.e.
<pre lang="c#">object buf = null;
CSDCtrlClassFPLite.GetMemoryBuffer("BMP", ref buf);</pre>
IT WORKS CORRECTLY AND RETURNS THE BINARY DATA, MY QUESTION IS WHY DOES IT NOT WORK IN JAVASCRIPT FUNCTION, AND HOW SHOULD I DECLARE THE 'buf'.
|
|
|
|
|
Javascript needs references of html DOM, of an active-x-control too.
Javascript data types not the same of c#.
Interface between active-x-c# and javascript needed --> <object ...="">
Internal of active x-control NOT needed for javascript.
So, if buf-array null so array-pointer "undefined".
buf=new array(value) --> define a pointer of array with length value
without init buf have no data type (after first set to value).
object buf = null; --> data type "object" ? like buf = new Object() ?
byte buf=new Byte() .... also not exist in standard javascript.
numObj = new Number(value) is a data type of javascript
control returns byte buf or other type in javascript interface ?
Another example: Flash has predfined interface for javascript --> data type conversion.
----------------------------------------------
IE object number
JScript
Number Object
An object representation of the number data type and placeholder for numeric constants.
numObj = new Number(value)
Arguments
numobj
Required. The variable name to which the Number object is assigned.
value
Required. The numeric value of the Number object being created.
Remarks
JScript creates Number objects as required from numerical values. It is rarely necessary to create Number objects explicitly.
The primary purposes for the Number object are to collect its properties into one object, and to allow numbers to be converted into strings via the toString method.
Properties
MAX_VALUE Property | MIN_VALUE Property | NaN Property | NEGATIVE_INFINITY Property | POSITIVE_INFINITY Property | constructor Property | prototype Property
Methods
toLocaleString Method | toString Method | valueOf Method
----------------------------------------------
IE Object Array
JScript
Array Object
Provides support for creation of arrays of any data type.
arrayObj = new Array()
arrayObj = new Array([size])
arrayObj = new Array([element0[, element1[, ...[, elementN]]]])
Arguments
arrayObj
Required. The variable name to which the Array object is assigned.
size
Optional. The size of the array. As arrays are zero-based, created elements will have indexes from zero to size -1.
element0,...,elementN
Optional. The elements to place in the array. This creates an array with n + 1 elements, and a length of n + 1. Using this syntax, you must supply more than one element.
Remarks
After an array is created, the individual elements of the array can be accessed using [ ] notation, for example:
var my_array = new Array();
for (i = 0; i < 10; i++)
{
my_array[i] = i;
}
x = my_array[4];
Since arrays in Microsoft JScript are zero-based, the last statement in the preceding example accesses the fifth element of the array. That element contains the value 4.
If only one argument is passed to the Array constructor, and the argument is a number, it must be an unsigned 32-bit integer (< approximately four billion). That value then becomes the size of the array. If the value is a number, but is less than zero or is not an integer, a run-time error occurs.
If a single value is passed to the Array constructor, and it is not a number, the length property is set to 1, and the value of the only element becomes the single, passed-in argument.
Notice that JScript arrays are sparse arrays, that is, although you can allocate an array with many elements, only the elements that actually contain data exist. This reduces the amount of memory used by the array.
|
|
|
|
|
im not sure what you are trying to say here..
Javascript needs references of html DOM, of an active-x-control too.
Javascript data types not the same of c#.
Interface between active-x-c# and javascript needed --> <OBJECT ...>
THIS I HAVE DONE, AND METHODS ARE CALLED AND EXECUTED CORRECTLY IN ACTIVEX?
Internal of active x-control NOT needed for javascript.
So, if buf-array null so array-pointer "undefined".
buf=new array(value) --> define a pointer of array with length value
without init buf have no data type (after first set to value).
THIS I HAVE DONE
object buf = null; --> data type "object" ? like buf = new Object() ?
I TRIED THIS , SAME RESULT
byte buf=new Byte() .... also not exist in standard javascript.
UNDERSTOOD
numObj = new Number(value) is a data type of javascript
UNDERSTOOD , THIS WILL NOT WORK BECAUSE MY 'buf' RETURN VALUE IS 154000 BYTES OF DATA?
control returns byte buf or other type in javascript interface ?
NOT SURE WHAT TO DO NEXT??
|
|
|
|
|
i tried this still the same result.
All the methods in the activex object work correctly , it is only not returning the array byte buffer (buf) , which remains empty.
|
|
|
|
|
|
hi manfred
what is the link?
|
|
|
|
|
Sorry just a second!
And I'll post it. I somehow forgot to insert it.
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
All fixed now!
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
Hi
I'm hoping to set up a system similar to Google Adwords that allows
other sites to extact a limited amount of data from my site, and
display it as part of their webpage. Google use a javascript file:
show_ads.js with parameters.
Can anyone explain how the .js file works? In particular how does it
output HTML back to the calling site, and how does it access the
parameters?
|
|
|
|
|
Seriously?
Two identical posts (with different titles) posted just 1 minute apart. I'd love to understand the motive behind such a move.
On a different note, you could probably do worse than visit http://jsbeautifier.org/[^]
You can paste the contents of show_ads.js into the window, hit the button, then see the code de-minified.
The variable names still suck - since they've been squished down to 1 or 2 letters long, but at least it makes it readable now.
If I were doing it, I'd probably save a page to disk that I knew used the file. I would then de-minify the javascript file and save it with a new name. I'd then change the saved-copy of the html so that it referenced the de-minified file.
Now that you have a local copy that references a human-readable file, I'd open it in a browser, place a break-point in the JS file and hit re-load. You should then be able to step-through execution of the code. This may be the easiest way of understanding it since all the variable names screwed-up.
Good luck!
Make it work. Then do it better - Andrei Straut
|
|
|
|
|
Hi
I'm hoping to set up a system similar to Google Adwords that allows
other sites to extact a limited amount of data from my site, and
display it as part of their webpage. Google use a javascript file:
show_ads.js with parameters.
Can anyone explain how the .js file works? In particular how does it
output HTML back to the calling site, and how does it access the
parameters?
|
|
|
|
|
I want to send the data which coming through request object on one tab to other tab.both tabs are on same jsp.how i can do it??
|
|
|
|
|
hello,
Using Javascript, how to access a textbox property in detailsview EditItemTemplate?
thanks
modified 14-Sep-12 7:30am.
|
|
|
|
|
hi
i use this code:
<script type='text/javascript'>
function ValidateFileSize(strFUS) {
var filename = document.getElementById('<%=fuSignature.ClientID%>');
var myFSO = new ActiveXObject("Scripting.FileSystemObject");
var filepath = filename.value;
var thefile = myFSO.getFile(filepath);
var size = thefile.size;
if (size / 1024 < 110)
return true;
alert('the size of file is big');
return false;
}
</script>
this code is work and show me the alert but when i click on ok button in allert box the file uploadbut i want it not be upload.
what should i do?
plz
|
|
|
|
|
you need to call this onSubmit of the form:
<form onsubmit="return ValidateFileSize()">
...
</form>
and the return in there is essential
|
|
|
|
|
oooh , i forgot write return in önsubmit="return ValidateFileSize()"
thanks so much.
|
|
|
|
|
hi ptvc,
you code is ok, you only need to return the function value where you call the function. for example you call it on a button click you would write
<button onclick="return ValidateFileSize();"></button>
|
|
|
|
|
yes, i forgot write return, Thanks
|
|
|
|