|
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
|
|
|
|
|
Hi, I execute the following code and just get a blank (black) window. The window caption shows but I have not yet gotten the images to load. Please help. (I tried using other images than the ones utilized too). the .py and the images are in the same directory.
background_image_filename='checkmark.jpg'
mouse_image_filename='digestive_bw.png'
import pygame, sys
from pygame.locals import*
from sys import exit
pygame.init()
screen=pygame.display.set_mode((800,800),0,32)
#pygame.display.set_caption("Hello, Howdy, Mate, and Hi there Aus world!")
background=pygame.image.load(background_image_filename).convert()
mouse_cursor=pygame.image.load(mouse_image_filename).convert_alpha()
while True:
for event in pygame.event.get():
if event.type==QUIT:
pygame.quit()
sys.exit()
screen.blit(background,(0,0))
x,y=pygame.mouse.get_pos()
x-=mouse_cursor.get_width() /2
y=-mouse_cursor.get_height() /2
screen.blit(mouse_cursor,(x,y))
pygame.display.update()
|
|
|
|
|
I am using an ActiveX which is refered using <object> tag in my JavaScript code. This javascript is used in a Java based web application. When user browse this page first time, my ActiveX get downloaded from server and installed on client machine. I want to show a progress bar when IE downloading ActiveX. Please suggest what apporach I can use to implement this.
Manish Agarwal
manish.k.agarwal @ gmail DOT com
|
|
|
|
|
The unfortunate thing is that you can't do a true progress bar, because you don't have access to the count of downloaded bytes. What most sites do is to display an animated gif image that acts as a placebo. It makes people feel like something is happening, but gives no true measure of it.
|
|
|
|
|
Thanks for your reply. I was also thinking to do same but looking for somekind of notification when object is fully downloaded and I have to stop the animation.
Manish Agarwal
manish.k.agarwal @ gmail DOT com
|
|
|
|
|
readyState
==========
Retrieves the current state of the object.
Syntax
Scripting [ vState = ] object.readyState
Possible Values
vState Variant that receives one of the following values.uninitialized Object is not initialized with data.
loading Object is loading its data.
loaded Object has finished loading its data.
interactive User can interact with the object even though it is not fully loaded.
complete Object is completely initialized.
The property is read-only. The property has no default value.
Remarks
The states through which an object passes are determined by that object; an object can skip certain states
(for example, interactive) if those states do not apply to that object.
Standards Information
There is no public standard that applies to this property.
Applies To
A, ACRONYM, ADDRESS, APPLET, AREA, B, BASE, BASEFONT, BDO, BGSOUND, BIG, BLOCKQUOTE, BODY, BR, BUTTON,
CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, CUSTOM, DD, DEL, DFN, DIR, DIV, DL, DT, EM, EMBED,
FIELDSET, FONT, FORM, FRAMESET, HEAD, hn, HR, HTML, I, IFRAME, INS, ISINDEX, KBD, LABEL, LEGEND, LI,
LISTING, MAP, MARQUEE, MENU, namespace, nextID, NOBR, NOFRAMES, NOSCRIPT, OL, OPTION, P, PLAINTEXT,
PRE, Q, RT, RUBY, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TEXTAREA, TITLE, TT, U, UL, VAR, XML, XMP
----------------------------------------------------------
[ nState = ] XMLHttpRequest.readyState
Possible Values
nState Integer that receives one of the following values.0 The object has been created, but not initialized (the open method has not been called).
1 The object has been created, but the send method has not been called.
2 The send method has been called, but the status and headers are not yet available.
3 Some data has been received. Calling the responseBody and responseText properties at this state to obtain
partial results will return an error, because status and response headers are not fully available.
4 All the data has been received, and the complete data is available.
The property is read-only. The property has no default value.
Applies To
XMLHttpRequest
|
|
|
|
|
My js looks like as
function fnLoadMyo()
{
window.status="Myo Loading..";
var s = <object classid="clsid:A6S60BCD-BC5E-4088-EFCE-B9EED1D84CB3" id="myo" height="100%" width="100%/">';
document.getElementById('myoSection').innerHTML = s;
alert(myo.readyState);
}
In above alert, I always get 4, irrespective of activex downloaded or registered on client or not.
Manish Agarwal
manish.k.agarwal @ gmail DOT com
|
|
|
|
|
create an activeX object
don't forget
'OBJECT ID="' ... + '"'
+ ' CLASSID="' .... + '"'
+ ' TYPE="' .... + '"'
....
e.g.
"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"; Mediaplayer Class-ID
"application/x-oleobject" type of Class-ID and media
-----------------------------------
create object directly, not with innerHTML.
X12=document.createElement(....);
X13=document.body.appendChild(X12);
try
{
X13.classid=....
X13.type=....
}
catch(e)
{
...
}
or
X12=document.createElement("<object id="..." classid="..."">); // e.g IE
X13=document.body.appendChild(X12);
after that maybe readystate is 4, but
pointer X13 must be !=null and !=undefined
X13.property too e.g. X14.classid
at this point activex exists (installed an callable)
e.g. Mediapalyer and try ..catch
// - - - check MediaPlayer createable, only IE
function checkMediaPlayer()
{
var X00=false;
var X01;
// ----- only if IE exist
// ----- create
X01=document.createElement("OBJECT");
// X01 mus be !=null and !=undefinded
// ----- set object try-catch so no place for readystate
try
{
// attention: activex must be allowed by user
// maybe NOT possible
// X01.classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95";
// X01.type="application/x-oleobject";
// X01.filename= ..... // dummy-wmv 1 sec must exists !
// maybe only that possible
X01.type="application/x-mplayer2"; // EMBED and not activeX
X01.filename= ..... // dummy-wmv 1 sec must exist !
}
catch(e1)
{X00=false;}
// ----- no append to body so no remove from body
if(X00)
{
try{X01.filename='';}
catch(e3){X00=false;}
}
// ----- clear object
X01=null; // no append to body so no remove from body
return X00;
}
|
|
|
|
|
how i do check the checkbox on tablerow by clicking datarow.for example in xampp phpmyadmin
اسلام پیروز است
|
|
|
|
|
You should have a look at line 522 of functions.js
If you right-click a table-row with Chrome or Opera, you can then select Inspect Element.
This will open the Dev Tools console. with the table-row still selected, you can then open the Event Listeners entry in the accordian. When I did this, I saw that the code for handling mouse-clicks on table-rows was to be found on line 522 of functions.js
With that done, one can see that the function basically looks for all any child elements of the row of type 'input' it then does some logic checking before checking/unchecking the checkbox.
Here's the function for reference. (I've marked what was line 522 with *****)
var marked_row = new Array;
function PMA_markRowsInit() {
var rows = document.getElementsByTagName('tr');
for ( var i = 0; i < rows.length; i++ ) {
if ( 'odd' != rows[i].className.substr(0,3) && 'even' != rows[i].className.substr(0,4) ) {
continue;
}
if ( navigator.appName == 'Microsoft Internet Explorer' ) {
rows[i].onmouseover = function() {
this.className += ' hover';
}
rows[i].onmouseout = function() {
this.className = this.className.replace( ' hover', '' );
}
}
if (rows[i].className.search(/noclick/) != -1) {
continue;
}
rows[i].onmousedown = function() {
var unique_id;
var checkbox;
checkbox = this.getElementsByTagName( 'input' )[0];
if ( checkbox && checkbox.type == 'checkbox' ) {
unique_id = checkbox.name + checkbox.value;
} else if ( this.id.length > 0 ) {
unique_id = this.id;
} else {
return;
}
if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
marked_row[unique_id] = true;
} else {
marked_row[unique_id] = false;
}
if ( marked_row[unique_id] ) {
this.className += ' marked';
} else {
this.className = this.className.replace(' marked', '');
}
if ( checkbox && checkbox.disabled == false ) {
checkbox.checked = marked_row[unique_id];
}
}
var labeltag = rows[i].getElementsByTagName('label')[0];
if ( labeltag ) {
labeltag.onclick = function() {
return false;
}
}
var checkbox = rows[i].getElementsByTagName('input')[0];
if ( checkbox ) {
checkbox.onclick = function() {
this.checked = ! this.checked;
}
}
}
}
window.onload=PMA_markRowsInit;
Make it work. Then do it better - Andrei Straut
|
|
|
|
|
Thanks enhzflep !
But How i do it with PHP
اسلام پیروزاست.اسلامنا غالب
|
|
|
|
|
You're welcome.
Well, you can't do it with PHP. That is to say, PHP is only good for performing calculations before outputting to a web-browser.
You can't do it with the keyboard, since the keyboard just allows you to create the page that is then displayed. Well, for the purpose of this discussion, PHP works just like the keyboard, except a little faster.
So, where does that leave you if you want to create a page with PHP and have it behave in the same way?
Well, you simply put the appropriate javascript into a js file. You then link that file to the html output, with a
<script src='......'></script> tag.
You can see from the last line of the code I posted, that the onload function for the document calls a function which attaches an event handler to each of the table-rows in the page.
So, you could put the function into the javascript file.
You can link that file to the output of the PHP
You can call the function either with <body onload='yourInitFunc();'> in the html
or with window.onload = yourInitFunc; in the javascript.
Presumably, you're assembling the page in PHP perl-style, I.e you're using print, printf or echo to output each line of content as you go. In that case, you just output the required tags with a print statement at the appropriate place.
If on the other hand, you're using DOM objects to construct the page - then you'll need to create the script node & set it's src attribute to point to the javascript file.
To be perfectly honest, if I was in your shoes then I'd just make a quick html file that did nothing but try to attach a function to the onclick event of each of the table rows.
Okay, I got bored - have a play around with this. Make it work the way you'd like, then output the file dynamically, instead of with the keyboard (or in your case, copy/paste)
<!doctype html>
<html>
<head>
<script>
function myRowClickFunction()
{
alert('row clicked');
}
function myBtnClicked()
{
alert('btn clicked');
}
function addBtnToRow()
{
td = document.createElement('td');
btnInput = document.createElement('input');
btnInput.setAttribute('value', 'click me');
btnInput.setAttribute('type', 'button');
btnInput.onclick = myBtnClicked;
td.appendChild(btnInput);
this.appendChild(td);
this.onclick = null;
}
function attachEventHandlerToTableRows(functionToAttach)
{
var i, num;
var tableRows = document.getElementsByTagName('tr');
num = tableRows.length;
for (i=0; i<num; i++)
{
tableRows[i].onclick = functionToAttach;
}
}
function myInit()
{
attachEventHandlerToTableRows(myRowClickFunction);
}
</script>
</head>
<body onload='myInit();'>
<table>
<tbody>
<tr><td>This is row 1</td></tr>
<tr><td>This is row 2</td></tr>
<tr><td>This is row 3</td></tr>
<tr><td>This is row 4</td></tr>
<tr><td>This is row 5</td></tr>
</tbody>
</table>
</body>
</html>
Make it work. Then do it better - Andrei Straut
|
|
|
|
|
OKAY my friend!!!
but how i get the row index and if i give a checkbox on first td how i change the checkbox state on tr click ?
i create checkboxes dynamically on webpage with php .
HELP ME!!!!
اسلام پیروزاست.اسلامنا غالب
|
|
|
|
|
If you need the row index, it's a good idea to stash it in the element, e.g.
<table>
<tr><th>... (header row)</tr>
<tr rowid=0><td>... </tr>
<tr rowid=1><td>... </tr>
</table>
(I'm not sure if you can use tBodies[0].rows.indexOf or something like that. I'm not an expert in this regard. But what you usually want is actually a row id which can be tied into the query you are running, and that won't be the same as the index anyway.)
If you know the checkbox is in the same row, though, you don't need the index to adjust it.
function rowOnClickHandler(evt){
var row = evt.target ? evt.target : evt.srcElement;
var checkbox = row.cells[0].getElementsByTagName('INPUT')[0];
checkbox.selected = !checkbox.selected;
}
|
|
|
|
|
Good answer. +5
Make it work. Then do it better - Andrei Straut
|
|
|
|
|
Just like Bob said, the easiest/quickest way to get the index of the clicked row (in case you need the number for something else) is to add an attribute to the TR elements - you can then query this value in your onclick handler.
Drawing on the code I wrote earlier, here's a dynamic solution.
------------------ tblTest.php ----------------------
<!doctype html>
<html>
<head>
<script>
function myRowClickFunction()
{
alert('row clicked');
}
function myBtnClicked()
{
alert('btn clicked');
}
function rowClickedToggleCheckBox()
{
var clickedRow = this;
var checkBox = clickedRow.getElementsByTagName('input')[0];
checkBox.checked = (!checkBox.checked);
alert('Index of clicked row: ' + clickedRow.getAttribute('rowIndex'));
}
function addBtnToRow()
{
td = document.createElement('td');
btnInput = document.createElement('input');
btnInput.setAttribute('value', 'click me');
btnInput.setAttribute('type', 'button');
btnInput.onclick = myBtnClicked;
td.appendChild(btnInput);
this.appendChild(td);
this.onclick = null;
}
function attachEventHandlerToTableRows(functionToAttach)
{
var i, num;
var tableRows = document.getElementsByTagName('tr');
num = tableRows.length;
for (i=0; i<num; i++)
{
tableRows[i].onclick = functionToAttach;
}
}
function myInit()
{
attachEventHandlerToTableRows(rowClickedToggleCheckBox);
}
</script>
</head>
<body onload='myInit();'>
<table>
<tbody>
<?php
for ($i=0; $i<10; $i++)
{
echo "<tr rowIndex='$i'><td><input type='checkbox' id='cb_$i'></td><td>click to toggle checkBox</td></tr>";
}
?>
</tbody>
</table>
</body>
</html>
Make it work. Then do it better - Andrei Straut
|
|
|
|
|
Beautiful! I can think of many places where this would be useful. Bravo on your explanation and great example! Clean, concise, and well documented. I don't usually get to do too much web development, but just spent a week immersed in it adding features to a legacy ASP application. It never fails to amaze me how much can be handled on the clent side. I think you might only be limited by your imagination.
"Go forth into the source" - Neal Morse
|
|
|
|
|