Disclaimer |
Instructions for implementing a javascript/xslt user criteria saver for ENCompass. Use at your own risk. TCC is not responsible for damage or problems caused by the use of these scripts. No warranties or guarantees of any kind are implied or assumed. |
ENCompass 3.5 User Criteria Saver |
Version 3.5 Scripts by Jim Robinson Tarrant County College South Campus 5301 Campus Dr. Fort Worth, TX 76119 (817) 515-4310 Copyright 2005, Tarrant County College ("TCC"). All rights reserved. For use with the ENCompass 3.5 product by Endeavor Systems, Inc. "ENCompass" is a trademark of Endeavor Information Systems, Inc. Purpose: Javascript and XSLT scripts allow user input to be retained in search forms when clicking the + or - buttons in childbrowse.xsl or childbrowseadvanced.xsl No warranties or guarantees of any kind or implied. use at your own risk. It works for us, so we thought we'd share... ;-) By using this software the USER indicates that he or she has read, understood and and will comply with the following: TCC hereby grants USER permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee, provided that:
|
These scripts are meant to be used with the ENCompass product by Endeavor Information Systems, Inc.™
ENCompass has a nasty habit of losing all data input by a user if the "+" or "-" signs are used
to open or close a collection. For example, if a user decided to perform a Subject Keyword search
for "Navajo" OR "Hopi" As a Phrase returning 50 hits per page and entered this criteria,
then decided to open a collection to choose a particular database to search, the
user would have to re-enter "Subject Keyword", "Navajo", "Hopi", "As A Phrase", "NOT" and 50 hits
per page (assuming none of these drop downs were the default).
The javascripts enclosed in encompass_criteria3.5.zip are meant to preserve the user's criteria when a collection hierarchy button ("+" or "-") is clicked. The scripts automatically check a child if the parent was checked when the parent was opened. All user choices are maintained. For example, if a parent is checked and a child of this parent is un-checked by the user, then a second collection is opened or closed, the integrity of the user's choice for the former collections remains intact. |
Instructions |
(by default, the html directory for ENCompass 3.5 is located at /m1/encompass/yourcollection/tomcat/default/context/logicrouter/html) These are the javascripts that do all the work. <script LANGUAGE="JavaScript1.2" type="text/javascript"> document.write("<script LANGUAGE='JavaScript1.2' SRC='/html/validate.js'><\/script>"); </script> Below it, add this line: <script type="text/javascript" src="/html/tcc.js"/> This allows the javascripts to be used from childbrowse.xsl <script type="text/javascript" src="/html/validate.js"/> <script type="text/javascript" src="/html/getcheck.js"/> Below it, add this line: <script type="text/javascript" src="/html/tcc.js"/> This allows the javascripts to be used from childbrowseadvanced.xsl </body> ABOVE the </body> tag, add: <script language="Javascript"> setChecks(); removeHierCookie(); </script> This reads the cookies once the page has loaded and sets the input fields based on the cookies. <img src="/images/mns.gif" alt="collapse thread" border="1" class="hidden"/> and
<img src="/images/pls.gif" alt="collapse thread" border="1" class="hidden"/>DO NOT change the instance under <xsl:template name="DoChildGroupLogic"> The first instance is under <xsl:template name="DoThreadLogic"> The second instance is under <xsl:template name="DoPubThreadLogic"> Replace them to read: <img src="/images/mns.gif" alt="collapse thread" border="1" class="hidden" onclick="getChecks()"/> <xsl:call-template name="FormatHierCookies"> <xsl:with-param name="hier_val" select="@hier"/> <xsl:with-param name="object_id"> <xsl:value-of select="*[name()=$object_ID]"/> </xsl:with-param> </xsl:call-template> and <img src="/images/pls.gif" alt="collapse thread" border="1" class="hidden" onclick="getChecks()"/> <xsl:call-template name="FormatHierCookies"> <xsl:with-param name="hier_val" select="@hier"/> <xsl:with-param name="object_id"> <xsl:value-of select="*[name()=$object_ID]"/> </xsl:with-param> </xsl:call-template> This runs the scripts when the user clicks a "+" or "-" that collects all the current data and stores it in a cookie. <!-- ############################################################################ --> <xsl:template name="FormatHier"> <xsl:param name="hier_val"/> <script language="javascript">jsIndent("<xsl:value-of select="$hier_val"/>")</script> </xsl:template> <!-- ############################################################################ --> Below this, add: <xsl:template name="FormatHierCookies"> <xsl:param name="hier_val"/> <xsl:param name="object_id"/> <script language="javascript">hierCookie("<xsl:value-of select="$hier_val"/>", "<xsl:value-of select="$object_id"/>")</script> </xsl:template> <!-- ############################################################################ --> This takes information sent from the xsl:call-template added in step 6 above and calls a javascript that creates a cookie with hierarchy information. That should do it for saving criteria when users click the "+" and "-" buttons.
|
How It Works |
When the user clicks a "+" or "-" to open or close a collection, the getChecks() javascript and the FormatHierCookies.xsl template are called. These scripts gather the values of each input field, checkbox, and hierarchy name and value and create name-value strings, which it stores as cookies on the user's browser. The page then reloads with the altered state of the collection (open or closed.) After the page loads (or near the end of the load), the setChecks() javascript is called. This script reads and parses the cookies, then sets all the values to the state before the page refreshed. With these scripts, we can also set default values for the user's first visit to the page. We can also make it easy for the user to set every checkbox, to clear every checkbox, and to reset the forms to the default states. |
Troubleshooting |
Questions can be sent to Jim Robinson at Tarrant County College, but the help I can provide is limited due to time constraints and lack of access to your system for debugging... ;-) Some hints about debugging javascripts:
|