eBook authors eBook Software - create and publish your own ebooks
Create your own eBooks
Learn How To Create, Publish & Market E-Books
E-Book Creation Software
Add sophisticated multimedia to your E-Books
Create E-Book covers in minutes
E-Book Marketing & Promotion made easy
Search engine for E-Books
Interviews with eBook authors
Tools for building better eBooks
Archived Message:

JavaScript and Activ Script

jefftilt I asked this question of Sunil via email and thought I would transfer to the BB as a threat and let him contunue working on v5.

I have a JavaScript script menu tree I would like to use as an ebook table of contents. Some of the pages in the ebook will be locked. I am attempting to use the preprocessor to expand the {iscorrectpassword} activ variable to indicate which pages are initially locked and then show them as available once a key is entered. Is ther a way to preprocess JavaScript (more accurately a .js parameter file for a script).

His response was:

You can't preprocess .js files

I believe this work round *may* work - name your js files as .html or .htm, and link like that (don't forget to take em out table of contents)

A slightly more complicated, but probably better solution is in the JavaScript code is to use the window.external commands, like window.external.ActivGet - see our Help for details
Best Regards
Sunil Tanna

I have read the documentation and don't have a clue how to proceed using the 'better solution' of windows.external.

What I am attempting to duplicate in the .js file is what would be accomplishe in HTML by: <IMG Src="icon[={iscorrectpassword}].gif>. Code could be forwarded if that would help

Thanks in advance for any of the programmers in the group!

Posted on: 4:06 am on November 22, 2003
Alaska Jeff -

Does your TOC info have to be in a .js file?  That would work if you had the script embedded in the html page.

 I suspect that you want to insert that TOC into every page, no?  Hence, the .js file?

 Here's one convoluted trick:  your startup page tests for, and writes another small .js file that contains the iscorrectpassword value, as a JavaScript variable.

You reference that variable when you document.write your TOC from your .js file.   You need to include a .js file inside a .js file, but it can be done.

Basically, the additional code in your .js file looks something like this:

document.write("<SCR" + "IPT LANGUAGE='Java" + "Script' SRC='pwvalue.js'></SC" + "RIPT>" ) ;

then, you continue building your TOC with that value.

Clear as mud?  Lemme know.

best -

Posted on: 8:49 pm on November 22, 2003
jefftilt Roger;

Thank you for taking an interest in my challenge. From your post it is clear I have not done a good job explaining my situation. I am attempting to use a commercial JavaScript Tree Menu as the TOC/navigation structure in an ebook. The TOC appears in one frame and loads the ebook pages into another frame. Like many of the commerical tree scripts it has 4 files. The first describes the nodes including all the parent/child relationships, the link to be executed when the node is clicked and the icons to display for each node (nodes.js). The second file describes a series of "appearance parameters" (format.js). The script is contained in a third file .js file (tree.js). there is also a CSS file.

The challenge is to change the name of the .gif file in the nodes.js file so when it is used by the tree.js file it shows if a page is locked or not, duplicating the effect of the HTML statement: <IMG Src="icon[={iscorrectpassword}].gif> with icon0.gif showing a locked page and icon1.gif showing an available page.

With the preprocessor's abilty to detect if the correct password has been entered, and being automatically executed when the correct password is entered guaranteeing a change in the {iscorrectpassword} activ variable, it seems a natual to use it. The challenge is the preprocessor will not process a .js file. I had already tried renaming the .js file with an .html extension before emailing Sunil but have not been able to get it to work.

My current idea is to have a nodes.htlm version of the nodes.js file the preprocessor would process, then  simply copy the .html file to a file with the .js extension overwriting any previously existing file. However I am just beginning to play with the idea and have no idea if it can be made to work or not.

If you (or anyone else) would have the time and interest in helping me solve this I can zip up some files and email them to you so you can look at some code. I am a new author and do not have lots of money to spend but I also realize people's time has a value. Let me know if and on what basis you would be willing to take a look at this for me. My email address should now be displayed in my sig line and you are welcome to contact me privately if you feel it more apprpriate.

Posted on: 10:16 pm on November 22, 2003
Alaska Jeff -

 So, what remains to be answered, was how to "continue building your TOC with that value."  It's a bit easier since you're using frames.

  After you set the precompiler to that page that includes the TOC .js pages, and get the iscorrectpassword value assigned to a JavaScript variable, edit your nodes.js to add that extra bit of code behind the gif image.

 That will depend on how it's built.  Usually, it's a long string, pieced together with variables and the '+' symbol.  You can find the .gif file, and perhaps slip in an extra variable, like so:

... + "<IMG Src='icon" + iscorrectpassword + ".gif'> " +  ...

you code may use arrays or something else to build the links, in which case you'll need to look at those a little more.  It's harder to say, then.  I would have to look at it.

best -

Posted on: 2:21 am on November 23, 2003
EBookCompiler Just to explain the window.external.ActivGet idea (sorry this is sort of out of sequence)

In JavaScript, something like

var s ;
s = window.external.ActivGet('{iscorrectpassword}') ;
alert(s) ;

You should see 0 or 1 in the alert box

Posted on: 10:12 pm on November 27, 2003

List All Archived Forums

Copyright © 2000-2018, Answers 2000 Limited.

With any business, it is up to the individual owner of said business to ensure the success of the business. You may make more or less than any sample figures or results that might be quoted on our web sites or other publications. All business involves risk, and many businesses do not succeed. Further, Answers 2000 Limited does NOT represent that any particular individual or business is typical, or that any results or experiences achieved by any particular individual/business is necessarily typical.

Disclosure: Our company's websites' content (including this website's content) includes advertisements for our own company's websites, products, and services, and for other organization's websites, products, and services. In the case of links to other organization's websites, our company may receive a payment, (1) if you purchase products or services, or (2) if you sign-up for third party offers, after following links from this website. Unless specifically otherwise stated, information about other organization's products and services, is based on information provided by that organization, the product/service vendor, and/or publicly available information - and should not be taken to mean that we have used the product/service in question. Additionally, our company's websites contain some adverts which we are paid to display, but whose content is not selected by us, such as Google AdSense ads. For more detailed information, please see Advertising/Endorsements Disclosures

Our sites use cookies, some of which may already be set on your computer. Use of our site constitutes consent for this. For details, please see Privacy.

Click privacy for information about our company's privacy, data collection and data retention policies, and your rights.

Contact Us    About and Terms Of Use    Privacy    Advertising/Endorsements Disclosures