[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

05/28/2001 at 04:04PM PDT, ID: 20125746
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.2

JavaScript library functionality in R4.x and R5

Asked by stamp in Lotus Notes

Tags: atttext

Hello experts,

this is a knowlidge sharing topic.
All this stuff is solely my ideas nowhere else found on the net. So use it or let it (or give me points ;-))

First I have to describe the problem...
Before Rnext there are different places in design elements to place JavaScript code. The best place to deposit functions is the "JS Header" event on the form. This is not bad, but the big disadvantage is, that if you have some hundred lines of JavaScript code in this place the code is sent again and again to the browser with every browser request. No caching is done. Also if you have same functions on multiple forms you have to update all the forms when somethings is to change in JavaScript code. You can of corse place the code into the data/domino/html directory, but than you loose this fine design distribution and replication feature. You have to care about the JavaScript dataset names on the file system.

So wath would be the solution. I think, some sort of JavaScript libraries in the application databse.nsf.

For R5 this is solved easyly. Create a page. Call it best: "HeaderPage.js"
Mark in the page base property tab the checkbox: Treat page contents as HTML
Place now in this page all the JavaScript code you like to distribute to all forms.
Instead of placing the JavaScript code into forms "JS Header" events place this formula into forms "HTML Head Content" event:
"<SCRIPT  LANGUAGE='JavaScript' SRC='/"+@Subset(@DbName;-1)+"/HeaderPage.js' ></SCRIPT>"

That was all. Now you can maintain your JavaScript code in the page and use it in twenty or more forms...

Wath to do in R4.x?
No problems...
Define a form for maintaining JavaScript code. In this form define multiple fields to be able to split your JavaScript code into multiple JavaScript file attachements. When creating a document with this form, than should the text of every field containing javascript code start with this string: </SCRIPT>
If you like to maintain css in the same form, than the field content css should start with this string: </STYLE>
For every field on the form you will get one attachment into the document.
Place into forms Postsave event this code:
Sub Postsave(Source As Notesuidocument)
  Dim doc As NotesDocument
  Set doc = Source.Document
  Forall i In doc.Items
    If (i.Type = TEXT) Then
      If (Ucase$(Left$(i.text,7)) = "<SCRIPT") Then
        Call AttachIncludeFile(doc, i.Name & ".js" , i.Text, "</SCRIPT>")
      Elseif (Ucase$(Left$(i.text,6)) = "<STYLE") Then
        Call AttachIncludeFile(doc, i.Name & ".css" , i.Text, "</STYLE>")
      End If
    End If
  End Forall
  Call doc.Save(True,False)
End Sub

And this additional function:
Sub AttachIncludeFile(doc As NotesDocument, Byval IncludeName As String, Byval IncludeText As String,  Byval IncludeEndTag As String)
  Dim attName As String
  Dim attText As String
  Dim txtStart As Integer
  Dim txtLen As Integer
  Dim fileName As String
  Dim fileNum As Integer
  Dim rtitem As NotesRichTextItem
  Dim object As NotesEmbeddedObject
  Set rtitem = doc.GetFirstItem( "Body" )
  If Not (rtitem Is Nothing) Then
    If ( rtitem.Type = RICHTEXT ) Then
      Set object = rtitem.GetEmbeddedObject( IncludeName)
      If Not (object Is Nothing) Then
        Call object.Remove
      End If
    End If
  Else
    Set rtitem = New NotesRichTextItem( doc, "Body" )
  End If
  txtStart = Instr(IncludeText,">")+1
  txtLen =  Instr(Ucase$(IncludeText), IncludeEndTag) - txtStart
  If (txtStart > 0) Then
    attText = Mid$(IncludeText, txtStart, txtLen)
    fileNum = Freefile()
    fileName = "C:\temp\" & IncludeName
    Open fileName For Output As fileNum
    Print #fileNum, attText
    Close fileNum
    Set object = rtitem.EmbedObject( EMBED_ATTACHMENT, "", fileName, fileName)
    Kill fileName
  End If
End Sub

The Postasave event and the AttachIncludeFile creates for every field either a js or a css attachment with the contenets of the field.
So you need only a view where you can lookup this document to access the attachments. As experts you know that this view has to be sorted in the first column.
When you have this, you can define in every form where you like to use this JavaScript attachments following formula:
path := "\'/"+@LeftBack(@Subset(@DbName;-1);"/")+"/config.nsf/FileLookup/JavaScriptFunctions/$FILE/";
cssPref := "<link rel=stylesheet type=\'text/css\' href="+path;
jsPref := "<SCRIPT  LANGUAGE=\'JavaScript\' SRC=" +path;
jsSuff := "\' ></SCRIPT>";
cssPref+"formcss.css\'>"+
jsPref+"navigate.js"+jsSuff+
jsPref+"workflow.js"+jsSuff+
jsPref+"all.js"+jsSuff

This example is showing how to acces the JavaScript attachments in a config.nsf database with a view FileLookup where the document is sorted as "JavaScriptFunctions"
From there are fetched four attachments to the form. Again, this is done only one time by the browser. Afterwards are the attachments fetched from browsers cache.

So, that is all.

I hope somebody can have any use of this.

Regards,
stamp
[+][-]05/29/01 12:50 AM, ID: 6131808

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/29/01 09:59 AM, ID: 6133819

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/29/01 11:30 AM, ID: 6134200

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/29/01 11:52 PM, ID: 6135983

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/13/03 11:23 AM, ID: 8519063

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Lotus Notes
Tags: atttext
Sign Up Now!
Solution Provided By: SpideyMod
Participating Experts: 3
Solution Grade: B
 
 
[+][-]05/13/03 11:53 AM, ID: 8519303

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91