Wednesday, March 25, 2009

Creating a Bookmark Icon for Your Domino Website

We all see those little icons next to your Favorite/Bookmark websites in your browser. Pretty cool, huh?

Here are the steps to make your own Bookmark Icon for your Domino website/application.

1. Create your graphic/logo and don't worry about the 16 x 16 pixel limit
2. Open this website:
http://www.html-kit.com/favicon/
3. This website will allow you to upload your graphic and it will size it to the 16 x 16 pixel limit
4. Follow the instructions to upload your graphic
5. When the "shrunk" graphic appears, follow the instructions on the screen and download the .zip file that is created.
6. Extract the "favicon.ico" file from the zip file
7. Open your database in Domino Designer
8. Add this .ico file to the Shared Resource > Files
9. Add the following code to each Form's HTML Head Content (NOTE: Replace the "[]" with "<>" --- blog would not post with the "<>", thought it was actual HTML):
"[link rel=\"shortcut icon\" href=\"/" + @WebDbName + "/favicon.ico?OpenFileResource\"]"
10. Test it out!

I have tested this in IE 6x and Firefox 3.0.x, using Domino Designer 7.x and it works fine.

What about adding to the Shared Resources > Images?
Glad you asked that... In Domino Designer 7 (and 6 and 5), you can only add .jpg, .gif, or .bmp types. So, add to the File Resources and you get the end result you wanted.

Hope this helps...

Tuesday, February 17, 2009

Determining the Week of the Year

I was recently asked to create a time tracking application. One of the issues I ran into was determining what week number of the year it was when creating the timesheet.

There is no @Week in formula language and no Week function in LotusScript. There were a couple ideas in JavaScript, but wanted to put it into LotusScript.

So, I came up with the idea of passing a date, formatted as a string, and finding which week it fell in.

Here is the function:

Function atWeek(weekDate As String) As Integer

Dim checkDate As NotesDateTime
Dim firstADate As NotesDateTime
Dim beginWeek As NotesDateTime
Dim endWeek As NotesDateTime
Dim message As String
Dim currentYear As String
Dim firstDay As String
Dim dayOfWeek As Integer
Dim addDays As Integer
Dim x As Integer
Dim dayCounter As Integer
Dim monthCounter As Integer

'Set the globals...
Const months = 12
Const weeks = 53 '365 Days / 7 Days a week = 52.14
Const weekdays = 7
Const dayOne = "01/01/"
currentYear = Year(Today)
firstDay = dayOne & currentYear

'Set the dates...
Set checkDate = New NotesDateTime(weekDate)
Set firstDate = New NotesDateTime(firstDay)

'Get the first week...
dayOfWeek = Weekday(firstDay)
addDays = weekdays - dayOfWeek

'Set the begin/end dates...
Set beginWeek = New NotesDateTime(firstDate.DateOnly)
'Increase the date...
firstDate.AdjustDay(addDays)
Set endWeek = New NotesDateTime(firstDate.DateOnly)

'Let's see if the date falls between first week...
If beginWeek.LSLocalTime <= checkDate.LSLocalTime Then If endWeek.LSLocalTime => checkDate.LSLocalTime Then
'We have a winner...
atWeek = 1
Exit Function
End If
End If

'We have the first week, let's get the next...
'Start with the second week, since we have the first week...
For x = 2 To weeks
'Increase the dates...
endWeek.AdjustDay(1)
Set beginWeek = New NotesDateTime(endWeek.DateOnly)
endWeek.AdjustDay(6)
Set endWeek = New NotesDateTime(endWeek.DateOnly)
'Let's see if the date falls between...
If beginWeek.LSLocalTime <= checkDate.LSLocalTime Then If endWeek.LSLocalTime => checkDate.LSLocalTime Then
'We have a winner...
atWeek = x
Exit Function
End If
End If
Next

End Function


Yes, I know I have 53 as the total weeks, but to do this based on a calendar year, there are 53 weeks. If you run 12/31/2009 through this function, 53 is returned.

It's a good little function, hopefully it will help you.