Developing Customizable and Databaseresident Help - PowerPoint PPT Presentation

1 / 55
About This Presentation
Title:

Developing Customizable and Databaseresident Help

Description:

Developing Customizable and Database-resident Help. Scott DeLoach. We ... Hiding topics that do not apply to the user's job ... If objRS('Custom') 'N' Then ... – PowerPoint PPT presentation

Number of Views:66
Avg rating:3.0/5.0
Slides: 56
Provided by: scottd3
Category:

less

Transcript and Presenter's Notes

Title: Developing Customizable and Databaseresident Help


1
Developing Customizable and Database-resident Help
Scott DeLoach
2
Session Overview
  • We will discuss how to provide
  • personalized
  • secure
  • flexible
  • annotated
  • Help using JavaScript and ASP
  • ASP only.

3
Sampleapplication
4
sample_login.htm
5
sample_home.htm
6
JavaScriptexamples
7
JavaScripts advantages over ASP
3
  • Does not require a database
  • Does not require IIS (runs on the client)
  • Better learning resources

8
Personal HelpRecognizing users
3
  • How to
  • Hide topics that do not apply to the users job
  • Remember completed sections
  • Remember user settings

9
Hiding topics that do not apply to the users job
sample_tutorial.htm
Show admin tutorials if the user logs in as
admin
10
Hiding topics that do not apply to the users job
4
  • Code to write the cookie (in sample_login.htm)
  • var today new Date()
  • var expires new Date(today.getTime() (60
    86400000))
  • function set()
  • var cookieID document.form.name.value
  • Set_Cookie("security",cookieID,expires)
  • function Set_Cookie(name,value,expires)
  • document.cookie name "" value "" "
    path/" ((expiresnull) ? "" " expires"
    expires.toGMTString())
  • code for the Submit buttontype"button" name"submit" value"Submit"
    onClick"set()"

Number of days to store the cookie
11
Hiding topics that do not apply to the users job
1
  • Code to read the cookie (in sample_tutorial.htm)
  • var cookiecheckunescape(document.cookie)
  • if (cookiecheck.indexOf('admin') ! -1)
  • document.write('sans-serif"Admin tutorials
    How to
    customize the application')

12
Remembering completed sections
sample_tutorial.htm
Show check if the user has completed the section
13
Remembering completed sections
2
  • Code to write to the cookie (in
    sample_tutoriallogin3.htm)
  • var today new Date()
  • var expires new Date(today.getTime() (60
    86400000))
  • function Set_Cookie(name,value,expires)
  • document.cookie name "" value "" "
    path/" ((expiresnull) ? "" " expires"
    expires.toGMTString())
  • s)"

Number of days to store the cookie
14
Remembering completed sections
2
  • Code to read the cookie (in sample_tutorial.htm)
  • var cookiecheckunescape(document.cookie)
  • if (cookiecheck.indexOf('checklogin') ! -1)
    document.images'checklogin'.src "check.gif"
  • code for the imagewidth"15" height"15" name"checklogin"

15
Remembering user settings
sample_tutorial.htm
Remember and use selected size
16
Remembering user settings
1
  • Code to open the tutorial (in sample_home.htm)
  • var securityunescape(document.cookie)
  • function opentutorial()
  • var w600 var h400
  • if (security.indexOf('big') ! -1) w800 h600
  • window.open('sample_tutorial.htm','tutorialwin','t
    oolbar0,location0,directories0,status1,menubar
    0,scrollbars0,resizable1,width' w
    ',height' h)

17
Remembering user settings
2
  • Code to resize the tutorial (in
    sample_tutorial.htm)
  • function checksize()
  • var securityunescape(document.cookie)
  • if (security.indexOf('big') ! -1)
    window.resizeTo(800,600)
  • if (security.indexOf('big') -1)
    window.resizeTo(600,400)

18
Remembering user settings
2
  • Code to store the new size(in sample_tutorial.htm
    )
  • function changesize(size)
  • var today new Date()
  • var expires new Date(today.getTime() (60
    86400000))
  • if (size "big")
  • document.cookie "tutorialsizebig" " path/"
    ((expiresnull) ? "" " expires"
    expires.toGMTString())
  • window.resizeTo(800,600)
  • if (size "normal")
  • document.cookie "tutorialsizenormal" "
    path/" ((expiresnull) ? "" " expires"
    expires.toGMTString())
  • window.resizeTo(600,400)

Number of days to store the cookie
19
Secure HelpLimiting access to topics logins
Hide this link if the user is not logged in as
admin
sample_help.htm
20
Hiding Links
1
  • Code to tag links(in sample_help.htm)
  • Customizin
    g the application

21
Hiding Links
2
  • Code to hide links (in sample_help.htm)
  • var securityunescape(document.cookie)
  • if (security.indexOf('admin') -1)
  • for (var i0 i
  • if (document.linksi.id.indexOf("admin") ! -1)
    document.linksi.innerText ""

22
Flexible HelpModifying topics on the fly
sample_home.htm
Field names need to match between application and
Help
sample_help.htm
23
Modifying topics on the fly
  • Code to tag application elements(in
    sample_home.htm)
  • Project Number

24
Modifying topics on the fly
2
  • Code to read from application and modify Help
    (in sample_help.htm)
  • var projectnumber "The " (opener.document.all.
    projectnumber.innerText).toLowerCase() "
    ...."
  • // repeat above for each field on page
  • var form opener.document.forms0
  • for (i 0 i
  • var elemspan (form.elementsi.name).substr(5)
  • document.write("sans-serif'" opener.document.allelemspan.i
    nnerText "

    ")
  • document.write(eval(elemspan))

chops off name_
25
ASPexamples
26
ASPs advantages over JavaScript
  • More secure
  • Database approach more powerful
  • Can reduce browser requirements
  • Does not require cookies for data storage

27
Personal HelpRecognizing users
  • How to
  • Hide topics that do not apply to the users job
  • Remember completed sections
  • Remember user settings

28
Hiding topics that do not apply to the users job
sample_tutorial.asp
Show admin tutorials if the user logs in as
admin
29
Hiding topics that do not apply to the users job
2
  • Code to request the users login(in
    sample_login.asp)
  • action"sample_home.asp"
  • value"Submit"
  • Code to store the users login(in
    sample_home.asp)

30
Hiding topics that do not apply to the users job
2
  • Code to show/hide topics based on the login(in
    sample_tutorial.asp)
  • If objRS("ID") Session("security") Then
  • If objRS("Custom") "N" Then
  • Response.Write "face'Arial, Helvetica, sans-serif'href'sample_tutorialcustom1.asp'How to
    customize the application
  • End If
  • End If

31
Remembering completed sections
sample_tutorial.asp
Show checks if the user has completed the section
32
Remembering completed sections
users database (users.mdb)
Key Y (yes) user is authorized to view the
section N (no) user is not authorized to view
the section C (complete) user has completed the
section
33
Remembering completed sections
3
  • Code to open the database (in sample_tutoriallogi
    n3.asp)
  • Dim objConn
  • Set objConn Server.CreateObject("ADODB.Connectio
    n")
  • objConn.Open "DRIVERMicrosoft Access Driver
    (.mdb) DBQ" Server.MapPath("\userfirstdemos\
    db\users.mdb")
  • Dim objRS
  • Set objRS Server.CreateObject("ADODB.Recordset")
  • objRS.Open "Tutorial", objConn, ,
    adLockOptimistic, adCmdTable

34
Remembering completed sections
  • Code to write to and close the database (in
    sample_tutoriallogin3.asp)
  • Do While Not objRS.EOF
  • If objRS("ID") Session("security") Then
  • objRS("login") "C"
  • objRS.Update
  • End If
  • objRS.MoveNext
  • Loop
  • objRS.Close
  • Set objRS Nothing
  • objConn.Close
  • Set objConn Nothing

35
Remembering completed sections
2
  • Code to mark completed sections(in
    sample_tutorial.asp)
  • If objRS("login") "N" Then
  • If objRS("login") "C" Then
  • Response.Write "src'check.gif' width'15' height'15'"
  • Else
  • Response.Write "src'nocheck.gif' width'15'
    height'15'"
  • End If
  • End If

36
Remembering user settings
sample_tutorial.asp
Remember and use selected size
37
Remembering user settings
Help database (fieldhelp.mdb)
Note HlpText is used to store
defaults. HlpTextCustom is used to store
modified Help topics.
38
Remembering user settings
3
  • Code to set the window size(in
    sample_tutorial.asp)
  • big
  • ...
  • If Request.QueryString "big" Then
  • Do While Not objRS.EOF
  • If objRS("ID") Session("security") Then
    objRS("size") "big"
  • Response.Write "Call
    window.resizeTo(800, 600)"
  • objRS.MoveNext
  • Loop
  • End If

39
Remembering user settings
2
  • Code to change the window size(in
    sample_tutorial.asp)
  • If Request.QueryString "" Then
  • Do While Not objRS.EOF
  • If objRS("ID") Session("security") Then
  • If objRS("size") "big" Then Response.Write
    "Call
    window.resizeTo(800, 600)"
  • If objRS("size") "normal" Then Response.Write
    "Call
    window.resizeTo(600, 400)"
  • End If
  • objRS.MoveNext
  • Loop
  • End If

40
Secure HelpLimiting access to topics
Hide this link if the user is not logged in as
admin
sample_help.htm
41
Hiding Links
1
  • Code to hide links(in sample_help.asp)
  • If Session("security") "admin" Then
  • Response.Write Customizing
    the application
    "
  • End If

42
Flexible HelpModifying topics on the fly
sample_home.asp
Field names need to match between application and
Help
sample_help.asp
43
Modifying topics on the fly(in sample_help.htm)
4
  • Do While Not objRS.EOF
  • Response.Write ""
    objRS("FieldLabel") "

    "
  • If objRS("HlpTextCustom") "" Then
  • Response.Write objRS("HlpTextCustom")
    ""
  • Else
  • If objRS("HlpText") "" Then
  • Response.Write objRS("HlpText") ""
  • Else
  • Response.Write "No Help has been written for
    this
  • field."
  • End If
  • End If
  • objRS.MoveNext
  • Loop

44
Annotated HelpAllowing users to modify/add topics
fieldhelp.asp
fieldhelp_edit.asp
Administrators see the edit button, which they
can use to add or change the field Help topics.
45
Modifying/Adding Help topics
3
  • Code to show field Help (in fieldhelp.asp)
  • Do While Not objRS.EOF
  • If Request.QueryString objRS("FieldID") Then
  • If objRS("HlpTextCustom") "" Then
  • Response.Write "" objRS("FieldLabel")
    "

    " objRS("HlpTextCustom")
  • Else
  • Response.Write "" objRS("FieldLabel")
    "

    " objRS("HlpText")
  • End If
  • End If
  • objRS.MoveNext
  • Loop

46
Modifying/Adding Help topics
3
  • Code to show Edit button (in fieldhelp.asp)
  • If Session("security") "admin" Then _
  • Response.Write "action'fieldhelpedit.asp?" Request.QueryString
    "'value'Edit'"

47
Modifying/Adding Help topics
3
  • Code to display the Edit form (1 of 2)(in
    fieldhelpedit.asp)
  • Do While Not objRS.EOF
  • If Request.QueryString objRS("FieldID") Then
  • Response.Write "" objRS("FieldLabel")
    "

    "
  • Response.Write "action'fieldhelpupdate.asp?"
    Request.QueryString "'"
  • If objRS("HlpTextCustom") "" Then
  • Response.Write "cols'60' rows'5'" objRS("HlpTextCustom")
    ""
  • Else
  • Response.Write "cols'60' rows'5'" objRS("HlpText")
    ""
  • End If

48
Modifying/Adding Help topics
1
  • Code to display the Edit form (2 of 2)(in
    fieldhelpedit.asp)
  • Response.Write "name'submit' value'Edit' "
  • End If
  • objRS.MoveNext
  • Loop

49
Modifying/Adding Help topics
1
  • Code to update the Help(in fieldhelpupdate.asp)
  • Do While Not objRS.EOF
  • If Request.QueryString objRS("FieldID") Then
  • If Request.Form("helptext") "" Then
  • objRS("HlpTextCustom") Request.Form("helptext"
    )
  • objRS.Update
  • End If
  • End If
  • objRS.MoveNext
  • Loop

50
Wrapping Up
51
Viewing and downloading the sample files
  • JavaScript sample files (zipped and
    live)www.userfirst.net/sample_app/index.html
  • ASP sample files (zipped and live)www27.brinkste
    r.com/userfirstdemos/index.html(Brinkster is a
    free ASP hosting site, so it goes down from time
    to time.)Both versions (zipped only)
    www.winwriters.com/ohc02/suppmatl/index.html
  • This presentation and notes about both
    versionswww.userfirst.net/demos/index.html

52
Recommended JavaScript books
  • JavaScript Visual Quickstart GuideTom Negrino
    and Dori Smith
  • Designing with JavaScriptNick Heinle and Bill
    Peña
  • JavaScript Bible and JavaScript
    ExamplesDanny Goodman

53
Recommended VBScript and ASP books
  • Teach Yourself Active Server Pages in 21
    DaysScott Mitchell and James Atkinson
  • VBScript in a NutshellMatt Childs, Paul Lomax,
    Ron Petrusha

54
Questions?
  • Feel free to e-mail me. Or, catch me later at the
    conference!
  • Scott DeLoach
  • Founding Partner, User First Services, Inc.
  • Certified RoboHELP Instructor and Consultant
  • CIW Master Designer404.520.0003
  • scott_at_userfirst.net

55
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com