GSAK (Geocaching Swiss Army Knife)
 

Contents - Index


HTML (function)

HTML(sSection,sOther) : string

You can generate your own custom HTML formats for SplitsScreen, Condensed print, View Offline, and File=>Export=>HTML.

To populate the drop down boxes with the custom formats you need to save a macro with a name starting with "HTML_" (without the quotes) in your GSAK "Macros" folder

The new HTML() function has been purpose built to help you generate these custom HTML pages. You can of course generate your custom HTML pages from scratch, but using the HTML() function will make it a lot easier for users with limited HTML knowledge and don't want to write a lot of macro code.


sSection = The section of HTML code we are generating
sOther = Other options or parameters associated with this section. Currently only the "Clean", "Hints", and "GoogleMap" section uses sOther, but I suspect the existing sections (and new ones) will eventually have options that can be passed using this extra parameter.


I think the best way to get a handle on this is to see a live example. The following macro exactly duplicates the existing GSAK HTML. This is provided for instructional purposes, but you can "Hack" it around to suit your needs - add, remove, move sections as needed.
 

#***************************************
# HTMLName=My new format
# SplitScreen=No
# Export=Yes
# Offline=Yes
# Condensed=No
#***************************************
$h = HTML("Header","")
$h = $h + HTML("TopLine","")
$h = $h + "<br><b> Testing </b>"

$h = $h + "<table align=centre bgcolor='white' border=0 width=100%><tr><td width='40%'>"
$h = $h + HTML("CacheInfo","")
$h = $h + HTML("TravelBugs","")
$h = $h + HTML("DifTer","")
$h = $h + HTML("CustomUrl","")
$h = $h + "</td><td valign='top' align='centre'>"
$h = $h + html("GoogleMap","Y")
$h = $h + "</td></tr></table>"

$h = $h + HTML("ShortDescription","")
$h = $h + "<HR>"
$h = $h + HTML("LongDescription","")
$h = $h + HTML("Children","")
$h = $h + HTML("HintsLink","")
$h = $h + "<HR>"
$h = $h + HTML("LastUpdate","")
$h = $h + "<BR>"
$h = $h + HTML("GSAKNotes","")
$h = $h + HTML("Logs","")
If $_HtmlFormat = "Export"
  $h = $h + HTML("NearBy","")
EndIf
$h = $h + "<HR>"
$h = $h + HTML("Hints","")
$h = $h + HTML("Footer","")
$_HTML = $h


Note: The condensed print is a little different because the idea is to generate one print out for all the waypoints in your current filter.

All other HTML custom formats are for a single cache only and the whole resulting HTML code for each cache is returned in the system variable $_HTML

To cater for a single HTML file of all waypoints (condensed print), there are 3 system variables

$_HtmlHeader - The header part of the HTML, this will be output at the very start of the file, and only output once
$_HtmlBody - This is the output for each individual waypoint
$_HtmlFooter - The Footer part of the HTML, this will be output at the very end of the file, and only output once.

It doesn't matter what order you allocate values to these variables, but you must update each one with something somewhere in the custom macro. For a custom condensed format macro see the example at the very end of this topic.

Now lets break this down step by step:
 

#***************************************
# HTMLName=My new format
# SplitScreen=Yes
# Export=Yes
# Offline=Yes
# Condensed=No
#***************************************


This is the special "prologue" section of a custom HTML macro. It is not required but if not entered your format will have the same name as the macro file and show in all boxes that support custom HTML formats.

HTMLName= Use this to give a meaningful name to custom HTML format you have created. This name will be shown in the various supported drop down boxes.

The other options indicate if the associated drop down box should include this custom HTML format. For example, you might create a custom HTML format for just user notes (see example at end) and it would only make sense to use this format for "Split Screen". If you are populating all the boxes with this format you don't need to include the =Yes lines (that is the default), but doing so will help automatically document your macro.
 

$h = HTML("Header","")


This generates a standard header block of HTML code ready for you to add other HTML data.

For those that really need to know it generates the following HTML code:

<tr><td>}<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Cache name here</title>
<style type='text/css'>
.FullText { font-weight: bold; color: #F00; background-color: #FF0 }
.gsak { font-family: Arial, Times, serif }
</Style>
</head>
<body text="#000000">
<table align=centre bgcolor="white" border=0 width=95% summary="GSAK"><tr><td>
 

$h = $h + HTML("TopLine","")


This generates the GSAK top line:


 

$h = $h + "<br><b> Testing </b><br>"


I just threw this in to show how easy it is to add your own HTML code that doesn't need the HTML() function
 

$h = $h + "<table align=centre bgcolor='white' border=0 width=100%><tr><td width='40%'>"


The default GSAK split screen format displays a Google map to the right of the screen. To get the map in this position we need to create a table. We place all the data we want in the first <td> tag, then we can place the Google map in the second one.
 

$h = $h + HTML("CacheInfo","")

 
This is the top block of information about the cache:
 

 

$h = $h + HTML("TravelBugs","")

 
This generates any travelbug information:


 

$h = $h + HTML("DifTer","")


This generates the Difficuly and Terrain stars:


  

$h = $h + HTML("CustomUrl","")

 
This generates any custom URL links (Tools=>Options=>HTML, but only those preceded by an ! - exclamation mark):


 

$h = $h + "</td><td valign='top' align='centre'>"

 
This finishes our first table <td> tag and begins our second, so that we can now display the Google Map to the right of the screen
 

$h = $h + html("GoogleMap","Y")
$h = $h + "</td></tr></table>"

 
The first line of code inserts our Google Map. The second line of code finishes off our table that we used to position our Google Map.The GoogleMap section supports two parameters in the full syntax of this section is in the form:

html("GoogleMap","Respect,Size")

Respect and size are comma delimited options for this section.

Respect - Must be Y or N. Y = The Google map output will respect the setting you currently have via "Tools=>Options=>HTML". That is, the map will only show when the box is checked. N = The Google map does not respect this setting and will always show regardless. If you do not include this option it defaults to "Y"

Size - This is the height in pixels for the Google map. If you don't provide a value for size then the value via "Tools=>Options=>HTML" is used
 
 
 

$h = $h + HTML("ShortDescription","")

 
This generates the cache short description:
 

$h = $h + HTML("LongDescription","")


This generates the cache long description:
 

$h = $h + HTML("Children","")


This generates the table of Child waypoints if there are any:


 

$h = $h + HTML("HintsLink","")


This generates a link to the actual hints. Done this way so you don't spoil the cache by seeing the hints here, but rather have to click on a link and view them after the logs.


 

$h = $h + HTML("LastUpdate","")


Last update line:


 

$h = $h + HTML("GSAKNotes","")


Any GSAK notes:


 

$h = $h + HTML("Logs","")


The logs:


 

If $_HtmlFormat = "Export"
  $h = $h + "<HR>"
  $h = $h + HTML("NearBy","")
EndIf


Here we have the "Nearby" caches. Note: this is very CPU intensive and is currently only supported when doing File=>Expor=>HTML. Hence why this block is controlled by the IF statement. See notes at end for more information on the system variable $_HtmlFormat


 

$h = $h + HTML("Hints","")


HTML("Hints","") - When the second parameter is blank, GSAK generates code that respects the "Decode hints" setting of the HTML you are generating. It also puts in the hints heading, the name tag, and decrypt key if required. This is the suggested default use of this action. However, if you want to *do your own thing* and have complete control, then set the second parameter to "D" or "E"

HTML("Hints","D") - Simply returns the decoded hint string. There is no other formatting or tags. Use this when all you want is the decoded hint formatted with line breaks.

HTML("Hints","E") - Simply returns the ROT encoded hint string. There is no other formatting or tags. Use this when all you want is the ROT encoded hint formatted with line breaks.


 

$h = $h + HTML("Footer","")


This finishes up your HTML file and closes all tags opened by the $h = HTML("Header","") at the beginning. The actual code generated is:

</td></tr></table></body></html></td></tr></table></body></html>
 

$_HTML = $h


Finally, in order for internal memory to be updated with this HTML code you must set the reserved system variable $_HTML



The system variable $_HTMLFormat has also been included so you can take different action depending on where the code is to be used. This is handy where only minor differences are required to the code depending on where it is used:

SplitScreen - Split screen display
Export - File=>Export=>HTML
Offline - Right mouse click, "View offline in browser"
Condensed - File=>Print

The "Clean" section was not used in the above code but has been provided for low level use of database data in your custom HTML. When placing something like the cache name or placed by in the HTML you should never just use code like :
 

$_HTML = $_HTML + $d_name


The reason being that the cache name could contain characters ("<", ">", "&", etc) that will mean your generated HTML code is invalid. Using "Clean" ensures that such data is correctly encoded. For example & is converted to &amp;

This is automatically done when you use any of the other "sections" as given above. However, if you are generating your own data then you should be using the code like:
 

$_HTML = $_HTML + HTML("Clean",$d_name)


Finally, if you would like to give this a quick test, copy the following code to a file called HTML_GsakNotes.txt in the "Macros" folder of your GSAK install folder.
 

#***************************************
# HTMLName=GSAK Notes
# SplitScreen=Yes
# Export=No
# Offline=No
# Condensed=No
#***************************************

$h = HTML("Header","")
$h = $h + HTML("GSAKNotes","")
$h = $h + HTML("Footer","")
$_HTML = $h


Now start GSAK and you should now have another split screen format to choose from:



Select this format, and it will give you a quick way to review any GSAK notes you have created in the split screen 

Sample condensed custom format to show a summary of caches 2 at a time:

#*********************************************
# HTMLName=Custom condensed x 2
# SplitScreen=No
# Export=No
# Offline=No
# Condensed=Yes
#*******************************************
$_htmlHeader = HTML("Header","")
# if variable does not exist, then this is the first cache
If varexists("$p_" + "CondensedToggle")
  $p_Condensedtot = $p_CondensedTot + 1
  $p_Condensedtoggle = not($p_CondensedToggle)
Else
  $p_CondensedTot = 1
  $p_CondensedToggle = true
EndIf

$h = ""
if $p_CondensedToggle
  $h = $h + "<table align=centre bgcolor='white' border=0 width=100%><tr><td valign='top' width='50%'>"
else
  $h = $h + "<td valign='top' width='50%'>"
endif

$h = $h + HTML("CacheInfo","")
$h = $h + HTML("TravelBugs","")
$h = $h + HTML("DifTer","")
$h = $h + "</td>"

If not($p_CondensedToggle)
  $h = $h + "</tr></table>"
endif

# last cache calcs here
If $p_CondensedTot = $_count

  # finish off table if odd number of caches
  If $p_CondensedToggle
    $h = $h + "<td> </td></tr></table>"
  endif

  $result = RemoveVar("$p_" + "CondensedToggle")
  $p_CondensedTot = 0
EndIf
 

$_HtmlFooter= HTML("Footer","")
$_htmlbody = $h

 
The resulting printout should look something like:



Summary



Copyright 2004-2008 CWE Computer Services  
Privacy Policy Contact