Sounds eminently sensible.

Anyone else got any comments?


On 8/15/07, Nathan Jones <[EMAIL PROTECTED]> wrote:
>
> When I've come up on this in the past, we had two constants files that
> we manually kept in sync. one for C# and one for JS. A comment in each
> file reminding the devs to keep the other up to date usually did the
> trick.
>
> On 8/15/07, Derek Lakin <[EMAIL PROTECTED]> wrote:
> > I'm currently working my way through the admin pages, starting with
> > reinstating the ShowCache.aspx page. In the ShowPage.aspx.cs file, there
> are
> > some constants defined that form the root of the ID for a list of
> elements.
> > These constants are then reused to create some JavaScript that works on
> the
> > same list of elements, like this:
> >
> >
> >
> > private const string keyPrefix = "keyRow";
> > private const string keyDataPrefix = "keyData";
> >
> > private void ShowKeys()
> > {
> >     WriteFilterScript();
> >     Response.Write( "<p>Search for key: <input id=\"Filter\"
> > onkeyup=\"javascript:FilterChanged()\"
> > length=\"60\"/></p>");
> >      int id = 0;
> >     ArrayList keys = new ArrayList();
> >     keys.AddRange(FlexWikiWebApplication.Cache.Keys);
> >     keys.Sort();
> >     Response.Write("<table cellpadding=\"2\" cellspacing=\"2\"
> > class=\"TableClass\">" );
> >     Response.Write("<tr>\r\n<td><b>Cache Key</b></td>");
> >     Response.Write( "<td><b>Cache Item Type</b></td>\r\n<tr>");
> >     foreach (string key in keys)
> >     {
> >         Response.Write(string.Format( "<tr id=\"{0}{1}\">",
> >         keyPrefix, id));
> >         Response.Write(string.Format(
> >              "<td class=\"{0}\"><span id=\"{1}{2}\">{3}</span></td>",
> >             (((id & 1) == 0) ? "SearchOddRow" : "SearchEvenRow"),
> > keyDataPrefix, id, key));
> >         Response.Write( string.Format(
> >             "<td class=\"{0}\"><span>{1}</span></td>",
> >              (((id & 1) == 0) ? "SearchOddRow" : "SearchEvenRow"),
> >              FlexWikiWebApplication.Cache[key].GetType().ToString()));
> >         Response.Write("</tr>");
> >         id++;
> >     }
> >
> >     Response.Write("</table>");
> > }
> >
> > The WriteFilterScript method looks like this:
> >
> > private void WriteFilterScript()
> > {
> >     Response.Write( "<script language=\"javascript\">");
> >     Response.Write(@"
> > function FilterChanged()
> > {
> >     var filter = filterControl.value;
> >     var id = 0;
> >     while (true)
> >     {
> >         var keyDataPrefix = """ + keyDataPrefix + @""" + id;
> >         var keyPrefix = """ + keyPrefix + @""" + id;
> >         var valueElement = document.getElementById(keyDataPrefix);
> >         if (valueElement == null)
> >             break;
> >          var show = true;
> >         var test = """";
> >         try {
> >             if (!valueElement.textContent)
> >                  test = """" +
> > valueElement.innerText.toUpperCase();
> >             else
> >                 test = """" +
> > valueElement.textContent.toUpperCase();
> >          } catch (e) {
> >             test = """" +
> > valueElement.innerText.toUpperCase ();
> >         }
> >         if (filter != """" && test.indexOf(filter.toUpperCase ()) < 0)
> >             show = false;
> >         var styleString = show ? """" : ""none"";
> >         var keyPrefixElement = document.getElementById(keyPrefix);
> >         keyPrefixElement.style.display = styleString;
> >         id++;
> >     }
> > }
> > ");
> >
> > Personally, I'd rather see this JS in an external file that can be
> cached by
> > the server and cleans up the CS file, but that would require repeating
> the
> > constants somewhere else. Does anyone have any opinions one way or
> another
> > about the benefits of external JS and whether it outweighs having the
> > constants in a single place?
> >
> -------------------------------------------------------------------------
> > This SF.net email is sponsored by: Splunk Inc.
> > Still grepping through log files to find problems?  Stop.
> > Now Search log events and configuration files using AJAX and a browser.
> > Download your FREE copy of Splunk now >>  http://get.splunk.com/
> > _______________________________________________
> > Flexwiki-users mailing list
> > Flexwiki-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/flexwiki-users
> >
> >
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >>  http://get.splunk.com/
> _______________________________________________
> Flexwiki-users mailing list
> Flexwiki-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/flexwiki-users
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Flexwiki-users mailing list
Flexwiki-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flexwiki-users

Reply via email to