Developing Database-resident Help for Customizable Web-based Applications - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

Developing Database-resident Help for Customizable Web-based Applications

Description:

Developing Database-resident Help for Customizable Web-based Applications Scott DeLoach Overview Using a database Storing topics in a database Opening help topics ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 31
Provided by: ScottD70
Category:

less

Transcript and Presenter's Notes

Title: Developing Database-resident Help for Customizable Web-based Applications


1
Developing Database-resident Help for
Customizable Web-based Applications
Scott DeLoach
2
Overview
  • Using a database
  • Storing topics in a database
  • Opening help topics from an application
  • Reading the help from the database
  • Formatting the help
  • Customizing help topics
  • Hiding links based on the user's login
  • Modifying topics on the fly
  • Allowing users to modify and add topics
  • Recommendations and sample system

3
Sample application
sample_login.htm
4
Sample application
page-level help
field-level help
sample_home.htm
5
Storing topics in a database
  • "HlpText" is used to store default topics.
  • "HlpTextCustom" is used to store modified topics.

6
Opening help topics
ASP
lta href"" onClick"openFieldHelp('ProjectNumber'
)"gtltimg src"fieldhelp.gif" width"18"
height"18" border"0"gt lt/agt ltscriptgt function
openFieldHelp(topic) window.open('fieldhelp.asp?
' topic,'helpwin','toolbar0, ?
location0,directories0,status0,menubar0,scroll
bars1, ? resizable0,width600,height400') lt
/scriptgt
7
Turning HTML files into ASP files
ASP
lt_at_ LanguageVBScript gt lt Option Explicit
gt lt!--include file"adovbs.inc"
--gt lthtmlgt ltheadgt lt/headgt ltbodygt
Hello! lt/bodygt lt/htmlgt
defines VBScript constants that make code easier
to read
8
Opening the database
ASP
Dim objConn Set objConn Server.CreateObject("ADO
DB.Connection") objConn.Open "DRIVERMicrosoft
Access Driver (.mdb) DBQ"
Server.MapPath("\db\fieldhelp.mdb") Dim
objRS Set objRS Server.CreateObject("ADODB.Recor
dset") objRS.Open "Tutorial", objConn, , ,
adCmdTable
9
Finding and formatting the help
ASP
Do While Not objRS.EOF If Request.QueryString
objRS("FieldID") Then If objRS("HlpTextCustom")
ltgt "" Then Response.Write "ltbgt"
objRS("FieldLabel") "lt/bgtltbrgt"
objRS("HlpTextCustom") Else Response.Write
"ltbgt" objRS("FieldLabel") "lt/bgtltbrgt "
objRS("HlpText") End If End If objRS.MoveNext Loop
If Request.QueryString objRS("FieldID") Then
If objRS("HlpTextCustom") ltgt "" Then
HlpTextCustom
HlpText
10
Opening help topics
JavaScript
lta href"" onClick"openFieldHelp('ProjectNumber'
)"gtltimg src"fieldhelp.gif" width"18"
height"18" border"0"gt lt/agt ltscriptgt function
openFieldHelp(topic) window.open('fieldhelp.htm?
' topic,'helpwin','toolbar0, ?
location0,directories0,status0,menubar0,scroll
bars1, ? resizable0,width600,height400') lt
/scriptgt
11
Creating a hidden frame (fieldhelp.htm)
JavaScript
ltframeset rows"100," rows""
frameborder"no"gt ltframe src"fieldhelptopic.htm"
name"help"gt ltframe src"fieldhelp.txt"
name"db"gt lt/framesetgt fieldhelp.txt
(comma-delimited version of database) "ProjectNumb
er","Project Number","The number
.","ltbgtNotelt/bgt This number is automatically
generated." "Description","Description","A brief
.", "StartDate","Start Date","When the project
needs to begin.", "CompletionDate","Completion
Date","When the project should end.", .
12
Finding and formatting the help
JavaScript
var topic location.search.substring(1) functio
n getTopic() var allTopics db.document.body.in
nerHTML allTopics allTopics.split("\"") for
(var i0 i lt allTopics.length i) if
(allTopicsi topic) help.document.body.inner
HTML "lth1gt" allTopicsi2 "lt/h1gt" "ltpgt"
allTopicsi4 "lt/pgt" break
13
Hiding links based on the users login
hide this link if the user is not logged in as
admin
sample_help.htm
14
Hiding links based on the users login
ASP
  • Code to hide links(in sample_help.asp)
  • lt
  • If Session("security") "admin" Then
  • Response.Write lta href 'link.htmgtCustomizing
    the applicationlt/agtltbrgt"
  • End If
  • gt

15
Hiding links based on the user's login
JavaScript
  • 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 buttonltinput
    type"button" name"submit" value"Submit"
    onClick"set()"gt

Set_Cookie("security",cookieID,expires)
document.cookie
onClick"set()"
16
Hiding links based on the user's login
JavaScript
  • Code to tag links(in sample_help.htm)
  • lta href"javascriptvoid()" id"admin1"gtCustomizin
    g the applicationlt/agt

17
Hiding links based on the user's login
JavaScript
  • Code to hide links (in sample_help.htm)
  • ltscriptgt
  • var securityunescape(document.cookie)
  • if (security.indexOf('admin') -1)
  • for (var i0 i lt document.links.length i)
  • if (document.linksi.id.indexOf("admin") ! -1)
    document.linksi.innerText ""
  • lt/scriptgt

var securityunescape(document.cookie)
document.linksi.innerText ""
18
Modifying topics on the fly
sample_home.asp
field names need to match between application and
help
sample_help.asp
19
Modifying topics on the fly
ASP
  • Do While Not objRS.EOF
  • Response.Write "ltfont face'Arial'gtltbgt"
    objRS("FieldLabel") "lt/bgtltbrgt"
  • If objRS("HlpTextCustom") ltgt "" Then
  • Response.Write objRS("HlpTextCustom")
    "lt/fontgtlt/pgt"
  • Else
  • If objRS("HlpText") ltgt "" Then
  • Response.Write objRS("HlpText") "lt/fontgtlt/pgt"
  • Else
  • Response.Write "No Help has been written for
    this field.
  • lt/fontgtlt/pgt"
  • End If
  • End If
  • objRS.MoveNext
  • Loop

objRS("FieldLabel")
objRS("HlpTextCustom")
objRS("HlpText")
No Help has been written for this field.
20
Modifying topics on the fly
JavaScript
  • Code to tag application elements(in
    sample_home.htm)
  • ltspan id"projectnumber"gtProject Numberlt/spangt
  • ltinput type"text" name"name_projectnumber"gt

21
Modifying topics on the fly
JavaScript
  • Code to read from application and modify Help
    (in sample_help.htm)
  • var projectnumber "The " (opener.document.all.
    projectnumber.innerText).toLowerCase() "
    ....lt/fontgtlt/pgt"
  • // repeat above for each field on page
  • var form opener.document.forms0
  • for (i 0 i lt form.elements.length-1 i)
  • var elemspan (form.elementsi.name).substr(5)
  • document.write("ltpgtltfont face'Arial, Helvetica,
    sans-serif'gtltbgt" opener.document.allelemspan.i
    nnerText "lt/bgtltbrgt")
  • document.write(eval(elemspan))

(opener.document.all.projectnumber.innerText).toLo
werCase()
chops off name_
22
Allowing 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.
23
Allowing users to modify/add topics
ASP
  • Code to show the Edit button (in fieldhelp.asp)
  • If Session("security") "admin" Then
  • Response.Write "ltform name'form' method'post'
    action'fieldhelpedit.asp?" Request.QueryString
    "'gtltinput type'submit' name'submit'
    value'Edit'gtlt/formgt"

24
Allowing users to modify/add topics
ASP
  • 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 "ltbgt" objRS("FieldLabel")
    "lt/bgtltbrgt"
  • Response.Write "ltform method'post'
    action'fieldhelpupdate.asp?"
    Request.QueryString "'gt"
  • If objRS("HlpTextCustom") ltgt "" Then
  • Response.Write "lttextarea name'helptext'
    cols'60' rows'5'gt" objRS("HlpTextCustom")
    "lt/textareagt"
  • Else
  • Response.Write "lttextarea name'helptext'
    cols'60' rows'5'gt" objRS("HlpText")
    "lt/textareagt"
  • End If

objRS("HlpTextCustom")
objRS("HlpText")
25
Allowing users to modify/add topics
ASP
  • Code to display the Edit form (2 of 2)(in
    fieldhelpedit.asp)
  • Response.Write "ltpgtltinput type'submit'
    name'submit' value'Edit'gt lt/formgt"
  • End If
  • objRS.MoveNext
  • Loop

26
Allowing users to modify/add topics
ASP
  • Code to update the help(in fieldhelpupdate.asp)
  • Do While Not objRS.EOF
  • If Request.QueryString objRS("FieldID") Then
  • If Request.Form("helptext") ltgt "" Then
  • objRS("HlpTextCustom") Request.Form("helptext"
    )
  • objRS.Update
  • End If
  • End If
  • objRS.MoveNext
  • Loop

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

28
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

29
Viewing and downloading the sample files
  • ASP sample files (zipped and live
    demo)http//www3.brinkster.com/userfirst/index.ht
    ml(Brinkster is a free ASP hosting site, so it
    goes down from time to time.)Presentationwww.us
    erfirst.net/present.html
  • Other Demoswww.userfirst.net/tips1.html

30
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
Write a Comment
User Comments (0)
About PowerShow.com