473,785 Members | 2,219 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help Me Understand This

I'd really appreciate it if someone could please help me understand the
code below. The only question I have about c_table() is about the t &&
range( 1 )... line; what does the t && part mean? The range() is a
textRange, so what does the t && mean?

I'm having a hard time figuring out how the range() function works. I
know it returns a textRange, but I'd like to understand how it works.

function c_table( e, v ) {
var t = showModalDialog ( path + 'aiTable.html', v,
'scroll:0;help: 0;status:0;dial ogWidth:378px;d ialogHeight:496 px' );
active();
t && range( 1 ).pasteHTML( t );
}

function range( v ) {
var s = d.selection;
v && ( s.type != 'None' ) && s.clear();
var r = s.createRange() ;
r.parents = [];
if( s.type == 'Control' ) {
r.control = true;
r.parents.push( r.item(0) );
r.parent = r.item(0).paren tElement;
} else {
r.control = false;
r.parent = r.parentElement ();
}
while( r.parent && r.parent.id != 'aiEdit' ) {
r.parents.push( r.parent );
r.parent = r.parent.parent Element;
}
return r;
}

Your help is appreciated.

Trevor

Dec 29 '05 #1
2 1255
A dirty hack... if t is false, range( 1 ).pasteHTML( t ); doesn't
execute. Essentially, the genius who wrote this really meant:

if(t) { range( 1 ).pasteHTML( t );

Dec 29 '05 #2
t && range( 1 ).pasteHTML( t );

&& is the AND op, so, the coder uses short circuit evaluation, its a
shotrhand for

if(t){
range( 1 ).pasteHTML( t );
}

so, he detects that the funcion showModalDialog () returned something,
and if so, he calls pasteHTML
shotr circuit evaluation, as you already know, is used to parse
expressions, so

if( a || b || c || d || f ){do_something( )}

if the JS engine sees that a is trus, it wont even look at b,c,d,f,
because it alreay knows that thats ( a || b || c || d || f ) true,
otoh,

a &&b &&c && xyz()

will execute xyz only when a, b and c are true.

hope it helps.

/f3l
http://www.geocities.com/kyoosho/

Dec 29 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1217
by: rami | last post by:
I have some code which does following thing template<class X, unsigned ID = 0> struct SomeStruct { template<class X> static SomeStruct<X, ID + 1>& SomeFunc(); ... ... ... ...
9
1603
by: Daz | last post by:
Hello hello! I'm trying to finish off putting my design into HTML and I've come across a problem that I can't get my head around. I've got divs floating in two columns, but I'm having problems trying to put in images and floating them left or right. In safari it leaves a gap inbetween two of my divs and the image overlaps the gap, in IE it does the same unti you mouse over the hyperlink in the div, which then hides the gap and puts...
5
3373
by: Y2J | last post by:
I am working through this book on C++ programming, the author is speaking of using linked lists. He gave and example which I found confusing to say the least. So I rewrote the example in a way that I could better understand the concept, he was trying to convey to me. I ran my own example and it crashed and burn "what a surprise!" : (. I ran the authors example out of the book and quess what, it crashed also, : 0. I ran them both on my...
7
1491
by: Mickyd1561 | last post by:
Hey everyone I'm new to this groups thing and thought maybe someone can help me. My problem is that I can't view specific images on only one website. www.baseballu.net is my baseball team's website and after I click "photo albums" on the left of the screen and then click "2006 Baseball U Summer Team Pictures," all of the pictures in the album have that annoying red "x" next to them. I am unable to view the images. Guessing that the...
4
1981
by: phpuser123 | last post by:
I want to submit my form using javascript but the prob I am facing here is when using this method,the form is being submitted irrespective of the return value of onsubmit .My script is ..... <html> <script type="text/javascript"> function chk(){ document.formname.submit(); } </script> <body>
0
9483
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10346
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10157
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10096
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.