Wednesday, July 18, 2007

Change double click behaviour on SSGD application

This post contains information for administrators who present the browser based webtop (version 4.x and higher) to their users and the users are using Internet Explorer.
(If someone can make this work for other browsers as well I will be very happy to recieve that sollution)

When a users starts an application from a normal Windows Desktop he/she needs to double click the application icon. I have seen many users doing the same (double click) with the application icon on the SSGD webtop. Since the double click is not implemented on the webtop the browser treads this behaviour as clicking the link twice and therefor SSGD will try to start the application twice.

Looking a bit deeper into SSGD the click on an application icon results in a signal to the tcc.exe to start a new application session. When the tcc.exe has started the application session it will give a signal back to the webtop refresh the application list. This step normally takes one to two seconds. When during those one or two seconds an other click on the icon occurs a new signal is given to the tcc.exe. This second click may not be valid when the limit of applications for this application has been reached. This will result in an error 'Error - Launch failed'.

I have been searching for a sollution and found a simple sollution. But this sollution only works for Internet Explorer. (I have tested this with Mozilla as well, but Mozilla treads javascript a bit different.)

A small adaption of the webtop can be made to disable the application link after it has been clicked and enable it again when the application list has been refreshed.
This adaption can be done by changing one single file: webtop.jsp

The changes below will change the behaviour of the webtop in the following manner:
When a users starts an application the webtop will not allow the users to start/resume/suspend the same application again until the webtop application list has been refreshed.
It will still be possible to start multiple different applications.

The file location of webtop.jsp can differ between different SSGD versions. For SSGD version 4.3 the location is:

/opt/tarantella/webserver/tomcat/5.0.28_axis1.2/webapps/sgd/webtops/standard/webtop

The location for version 4.2 is:
/opt/tarantella/webserver/tomcat/5.0.28_axis1.2final_jk1.2.8/webapps/sgd/webtops/standard/locale=en-us/webtop/


Changes in javasctript of the webtop.jsp are:

add array link_active_names (contains the already started applications
add variable link_counter = 0 (contains the number of applications in the array)
Add function ActivateLink(..) (being called when an application starts)
Change function OnKeyPress(..) (return false when the application has already been started)

Changes have to be made on all the function calls (8 times) to OnKeyPress(..). The name of the applcation link has to be added as the first parameter.
Changes have to be made on the application links which start a new application (4 times). The OnClick events must also call the ActivateLink() function.

The actual code for these changes are:

Replace the function OnKeyPress in the webtop.jsp

var link_counter = 0;
var link_active_names = new Array();
function ActivateLink( linkname )

link_active_names[link_counter] = linkname;
link_counter = link_counter + 1;
}
function OnKeyPress( linkname, event, url, target, toggleTarget, resumeOpt, toggleResumeOpt )
{
var newurl;

var disable_link = 0;
for (i=0;i<link_active_names.length;i++)
if (link_active_names[i] == linkname)
{
disable_link = 1;
}


if (disable_link==0) {
if (window.event)
{
ctrl = window.event.ctrlKey;
shift = window.event.shiftKey;
}
else if (event)
{
ctrl = event.ctrlKey;
shift = event.shiftKey;
}
else
{
ctrl = false;
shift = false;
}

if (ctrl && shift)
{
newurl=url+"&toggledisplay=true&forceauthentication=true"+toggleResumeOpt;
window.open(newurl, toggleTarget);
}
else if (ctrl)
{
newurl=url+"&toggledisplay=true"+toggleResumeOpt;
window.open(newurl, toggleTarget);
}
else if (shift)
{
newurl=url+"&forceauthentication=true"+resumeOpt;
window.open(newurl, target);
}
else
{
return true;
}
}

if (window.event)
{
window.event.returnValue=false;
}
else if (event)
{
event.returnValue=false;
event.cancelBubble=true;
}

return false;
}


All the function calls changes in the webtop.jsp are shown via a diff between the old 4.3 version of the webtop.jsp and the changed webtop.jsp:

294c312
< <a onclick="OnKeyPress(event, '<%= launchUrl %>', '<%= target %>', '<%= toggleTarget %>', '<%= resumeOpt %>', '<%= toggleResumeOpt %>')" href="<%= launchUrl + resumeOpt %>" target="<%= target %>" title="<%= toolTip %>"><img src="<%= getIconGif(icon) %>" alt="<%= displayname %>" border="0" width="20" height="20"></a>
---
> <a onclick="OnKeyPress('<%= displayname %>', event, '<%= launchUrl %>', '<%= target %>', '<%= toggleTarget %>', '<%= resumeOpt %>', '<%= toggleResumeOpt %>');ActivateLink('<%= displayname %>');" href="<%= launchUrl + resumeOpt %>" target="<%= target %>" title="<%= toolTip %>"><img src="<%= getIconGif(icon) %>" alt="<%= displayname %>" border="0" width="20" height="20"></a>
336c354
< <a onclick="OnKeyPress(event, '<%= launchUrl %>', '<%= target %>', '<%= toggleTarget %>', '<%= resumeOpt %>', '<%= toggleResumeOpt %>')" href="<%= launchUrl + resumeOpt %>" target="<%= target %>" title="<%= toolTip %>"><%= displayname %></a></p>
---
> <a onclick="OnKeyPress('<%= displayname %>', event, '<%= launchUrl %>', '<%= target %>', '<%= toggleTarget %>', '<%= resumeOpt %>', '<%= toggleResumeOpt %>');ActivateLink('<%= displayname %>');" href="<%= launchUrl + resumeOpt %>" target="<%= target %>" title="<%= toolTip %>"><%= displayname %></a></p>
471c489
< <a onclick="OnKeyPress(event, '<%= resumeUrl %>', '<%= target %>', '<%= toggleTarget %>', '', '')" href="<%= resumeUrl %>" target="<%= target %>">Session <%= i.toString(sess_no++)%></a>
---
> <a onclick="OnKeyPress('<%= displayname %>', event, '<%= resumeUrl %>', '<%= target %>', '<%= toggleTarget %>', '', '')" href="<%= resumeUrl %>" target="<%= target %>">Session <%= i.toString(sess_no++)%></a>
488c506
< <a onclick="OnKeyPress(event, '<%= resumeUrl %>', '<%= target %>', '<%= toggleTarget %>', '', '')" href="<%= resumeUrl %>" target="<%= target %>"><img src="<%= getWebtopGif("play.gif")%>" alt="<%=getWebtopString("I0_AltResume")%>" title="<%=getWebtopString("I0_AltResume")%>" width="12" height="10" hspace="2" border="0" align="absmiddle" id="Resume"></a>
---
> <a onclick="OnKeyPress('<%= displayname %>', event, '<%= resumeUrl %>', '<%= target %>', '<%= toggleTarget %>', '', '')" href="<%= resumeUrl %>" target="<%= target %>"><img src="<%= getWebtopGif("play.gif")%>" alt="<%=getWebtopString("I0_AltResume")%>" title="<%=getWebtopString("I0_AltResume")%>" width="12" height="10" hspace="2" border="0" align="absmiddle" id="Resume"></a>
568c586
< <a onclick="OnKeyPress(event, '<%= launchUrl %>', '<%= target %>', '<%= toggleTarget %>', '<%= resumeOpt %>', '<%= toggleResumeOpt %>')" href="<%= launchUrl + resumeOpt %>" target="<%= target %>" title="<%= toolTip %>"><img src="<%= getIconGif(icon) %>" alt="<%= displayname %>" border="0" width="20" height="20"></a>
---
> <a onclick="OnKeyPress('<%= displayname %>', event, '<%= launchUrl %>', '<%= target %>', '<%= toggleTarget %>', '<%= resumeOpt %>', '<%= toggleResumeOpt %>');ActivateLink('<%= displayname %>');" href="<%= launchUrl + resumeOpt %>" target="<%= target %>" title="<%= toolTip %>"><img src="<%= getIconGif(icon) %>" alt="<%= displayname %>" border="0" width="20" height="20"></a>
610c628
< <a onclick="OnKeyPress(event, '<%= launchUrl %>', '<%= target %>', '<%= toggleTarget %>', '<%= resumeOpt %>', '<%= toggleResumeOpt %>')" href="<%= launchUrl + resumeOpt %>" target="<%= target %>" title="<%= toolTip %>"><%= displayname %></a></p>
---
> <a onclick="OnKeyPress('<%= displayname %>', event, '<%= launchUrl %>', '<%= target %>', '<%= toggleTarget %>', '<%= resumeOpt %>', '<%= toggleResumeOpt %>');ActivateLink('<%= displayname %>');" href="<%= launchUrl + resumeOpt %>" target="<%= target %>" title="<%= toolTip %>"><%= displayname %></a></p>
695c713
< <a onclick="OnKeyPress(event, '<%= resumeUrl %>', '<%= target %>', '<%= toggleTarget %>', '', '')" href="<%= resumeUrl %>" target="<%= target %>">Session <%= i.toString(sess_no++)%></a>
---
> <a onclick="OnKeyPress('<%= displayname %>', event, '<%= resumeUrl %>', '<%= target %>', '<%= toggleTarget %>', '', '')" href="<%= resumeUrl %>" target="<%= target %>">Session <%= i.toString(sess_no++)%></a>
712c730
< <a onclick="OnKeyPress(event, '<%= resumeUrl %>', '<%= target %>', '<%= toggleTarget %>', '', '')" href="<%= resumeUrl %>" target="<%= target %>"><img src="<%= getWebtopGif("play.gif")%>" alt="<%=getWebtopString("I0_AltResume")%>" title="<%=getWebtopString("I0_AltResume")%>" width="12" height="10" hspace="2" border="0" align="absmiddle" id="Resume"></a>
---
> <a onclick="OnKeyPress('<%= displayname %>', event, '<%= resumeUrl %>', '<%= target %>', '<%= toggleTarget %>', '', '')" href="<%= resumeUrl %>" target="<%= target %>"><img src="<%= getWebtopGif("play.gif")%>" alt="<%=getWebtopString("I0_AltResume")%>" title="<%=getWebtopString("I0_AltResume")%>" width="12" height="10" hspace="2" border="0" align="absmiddle" id="Resume"></a>

No comments: