Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0006341 [Resin] tweak always 04-13-20 12:29 05-05-20 14:53
Reporter stbu View Status public  
Assigned To ferg
Priority normal Resolution fixed Platform
Status closed   OS
Projection none   OS Version
ETA none Fixed in Version 4.0.65 Product Version 4.0.64
  Product Build
Summary 0006341: Show sessions in Resin Admin web-app even when host + web-app contains '.' or '/'
Description I would like to suggest a small tweak in the jQuery selectors in $RESIN_HOME/doc/admin/sessions.php and $RESIN_HOME/doc/admin/WEB-INF/php/sessions.page because jQuery is not happy when the selector contains meta-characters like a period '.' or forward slash '/'. But both of these characters can be part of virtual-hostnames and web-apps in Caucho Resin.

There will be no "click" event on the anchor tag "show sessions" and nothing will happen because the showLink variable will not contain the supposed DOM element through the jQuery selector.

<image see Google Groups link below>


Let's have a look at the generated HTML code from the /resin-admin web-app in the "sessions" page:

<div class='refresh-sessions'><a class='refresh-sessions' id='sessions-refresh-resin-doc'>show sessions</a></div><div id='sessions-list-resin-doc'></div><script language="javascript">
  var showLink = $("#sessions-refresh-resin-doc");
  showLink.click(function(context, event)
   {
    var parent = showLink.parent();

    var sessionsDiv = $(this).parent().next();

    var link ="sessions.php?s=0&host=&webapp=/resin-doc&manager-suffix=resin-doc";

    $(this).text('refresh sessions');

    sessionsDiv.load(link);
  });
</script></div>

This works perfectly fine. The jQuery selector in line 0000002 ($("#sessions-refresh-resin-doc")) will be able to select the anchor tag from line 0000001.



However, if the hostname's id is for example "www.example.com" and the web-app's context path is for example "/webapp/javadoc" then the generated HTML for the sessions page is:

<div class='refresh-sessions'><a class='refresh-sessions' id='sessions-refresh-www.example.comwebapp/javadoc'>show sessions</a></div><div id='sessions-list-www.example.comwebapp/javadoc'></div><script language="javascript">
  var showLink = $("#sessions-refresh-www.example.comwebapp/javadoc");
  showLink.click(function(context, event)
   {
    var parent = showLink.parent();

    var sessionsDiv = $(this).parent().next();

    var link ="sessions.php?s=0&host=www.example.com&webapp=/webapp/javadoc&manager-suffix=www.example.comwebapp/javadoc";

    $(this).text('refresh sessions');

    sessionsDiv.load(link);
  });

</script></div>


Now, the jQuery selector will not work. From the web-app's context-path the beginning '/' is removed, but this is not enough. Also the periods from the hostname and the other '/' in the context-path are disturbing jQuery.



See also:
https://stackoverflow.com/questions/9930577/jquery-dot-in-id-selector/9930611 [^]
https://api.jquery.com/category/selectors/ [^]


I would like to suggest the following very small fixes (here a diff based on Resin-Pro-4.0.64):

diff -r doc/admin_original/WEB-INF/php/sessions.page doc/admin/WEB-INF/php/sessions.page
182c182
< var showLink = $("#sessions-refresh-${manager_suffix}");
---
> var showLink = $('a[id="sessions-refresh-${manager_suffix}"]');


diff -r doc/admin_original/sessions.php doc/admin/sessions.php
73c73
< echo ("var table = $('#${session_table_id}');\n");
---
> echo ("var table = $('table[id=\"${session_table_id}\"]');\n");


I have applied the jQuery selector alternative with the tag and id= so that it does not matter when these contains periods and forward slashes. It was one of the alternative answers from StackOverflow and it works.
Beside the sessions.page I have also had to make the same tweak in the sessions.php so that the JSON data will be displayed in the table.

This will generate the following functioning HTML code:

<div class='refresh-sessions'><a class='refresh-sessions' id='sessions-refresh-www.example.comwebapp/javadoc'>show sessions</a></div><div id='sessions-list-www.example.comwebapp/javadoc'></div><script language="javascript">
  var showLink = $('a[id="sessions-refresh-www.example.comwebapp/javadoc"]');
  showLink.click(function(context, event)
   {
    var parent = showLink.parent();

    var sessionsDiv = $(this).parent().next();

    var link ="sessions.php?s=0&host=www.example.com&webapp=/webapp/javadoc&manager-suffix=www.example.comwebapp/javadoc";

    $(this).text('refresh sessions');

    sessionsDiv.load(link);
  });

</script></div>




Another suggestion:

At the moment in the "show sessions" table the time shown in the columns "Creation Tim", "Access Time", "Last UseTime" are not showing leading zeros. So the human readable time of 10:04:09 will be shown as "10:4:9".
I would suggest to add a utility function (here called pad) to the resin-admin.js which will prepend a "0" if the value passed to the function is less than 10.
That utility function should then be added to the existing formatDate function:

diff -r doc/admin_original/resin-admin.js doc/admin/resin-admin.js
224a225,231
> function pad(val) {
> if (val < 10)
> return '0' + val;
> else
> return val;
> }
>
233,235c240,242
< result = date.getFullYear() + "-" + (date.getMonth() + 1 ) + "-"
< + date.getDate() + " " + date.getHours() + ":"
< + date.getMinutes() + ":" + date.getSeconds();
---
> result = date.getFullYear() + "-" + pad((date.getMonth() + 1 )) + "-"
> + pad(date.getDate()) + " " + pad(date.getHours()) + ":"
> + pad(date.getMinutes()) + ":" + pad(date.getSeconds());
238c245
< result = date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
---
> result = pad(date.getHours()) + ":" + pad(date.getMinutes()) + ":" + pad(date.getSeconds());

Steps To Reproduce
Additional Information See also:
https://groups.google.com/forum/#!topic/caucho-resin/73lh2StnotM [^]
Attached Files

- Relationships

There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
04-13-20 12:29 stbu New Issue
04-13-20 12:29 stbu Issue Monitored: stbu
05-05-20 14:53 ferg Assigned To  => ferg
05-05-20 14:53 ferg Status new => closed
05-05-20 14:53 ferg Resolution open => fixed
05-05-20 14:53 ferg Fixed in Version  => 4.0.65


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
30 total queries executed.
27 unique queries executed.
Powered by Mantis Bugtracker