Thread: [Aimmath-developers] RE: AiM Community: Re: Works with all browsers
Brought to you by:
gustav_delius,
npstrick
From: Greg G. <gr...@ma...> - 2003-07-18 03:30:05
Attachments:
browserdet.zip
|
On Wed, 16 Jul 2003, Gustav W Delius wrote: > I would certainly like to look at what you have done. Where do I look? Dear Gustav and everyone, What I've done is a bit half-baked and it's been about a month since I've done any work on it ... so I'll explain the components and what I changed (the java script stuff really needs to be added in automatically via a .mpl file, but I haven't looked at that yet). The components are in the attached .zip file which expands to the following hierarchy: ROOT/ index.html Uindex.html WEB-INF/ java/ Alice.java Maple.java tth/ TtH.java * Firstly, the idea is that there be two variants of the index.html page. The default uses symbol font but has a javascript function to redirect to the other variant Uindex.html. o You will observe two extra javascript functions: Trim and BrowserDetector in the head of index.html o Inside the <form ...> ... </form> tags you will find <input type="hidden" name="Browser" value="IE"> in index.html and <input type="hidden" name="Browser" value="Unicode"> in Uindex.html. * Alice.java is supposed to grab the value of "Browser" and pass it down to subsequent webpages that the student visits, like the various "Command"s are. You will notice on lines 595 - 599: maple.exec("`aim/Main`(" + commandargs + "):\n", // "", " -u", // (alicereq.browser.equals("IE") ? "" : " -u"), webOutput); If everything was working the commented out line, line 598 would be used instead of line 597 (line 597 causes the option " -u" (Unicode) to be always passed to tth). The commented out line, line 596 instead of line 597 would pass "" (for symbol font) always. * Maple.java is modified essentially for the adjustment in TtH.java. * MaplePool.java was not changed and so is not included. * TtH.java is modified so that its exec method accepts an extra argument tthOpt which is either "" (for IE (symbol font) browsers) or " -u" (for Unicode browsers) The java script browser detection part works; the java code compiles, but subsequent webpages visited don't get the value of "Browser" passed down. Can anyone see what I might be doing wrong? Any hints about how to get the java code to write out info. as it's going would be helpful too. My main problem is I don't know enough java ... I'm better at C etc. Also, if someone can see a way of doing it without having two separate index.html variants that would be good too. If we can the rudimentary detection working, we can beef this up further to print messages like: Internet Explorer 5: Your browser has a bug that `flattens' multiple levels of indices, e.g. e^(x^2) will appear as e^(x2). Please upgrade to at least Internet Explorer 6 ... and we can detect for Netscape 4 on windows and make it use symbol font, and warn that Netscape 4 on UNIX requires some special configuration, and then we can look at other browsers like safari, opera and konqueror and decide if the Unicode option is the correct one etc. Regards, Greg |
From: Manolis M. <ma...@ma...> - 2003-07-18 09:58:53
|
> * Alice.java is supposed to grab the value of "Browser" and pass it down > to subsequent webpages that the student visits, like the various > "Command"s are. > The java script browser detection part works; the java code compiles, but > subsequent webpages visited don't get the value of "Browser" passed down. > Can anyone see what I might be doing wrong? Subsequent calls to Alice servlet do not contain the hidden vbariable that you passed the first time >Any hints about how to get the > java code to write out info. as it's going would be helpful too. My main > problem is I don't know enough java ... I'm better at C etc. One solution is to keep on passing a hidden parameter broswer to every page but I don't like solutions like these. A better solution is to use the session functionality that Tomcat has. I am sorry I can't demonstrate since I am away but I tried it on my laptop's AIM and seems it works : initially we can do the following somewhere before the maple.exec: Session session = request.getSession(); session.setAttribute("browser", alicereq.browser); that sets the browser attribute of the user session (we need to conduct some tests to test if session exists with request.getSession(true) etc. but this is trivial) and then maple.exec("`aim/Main`(" + commandargs + "):\n", // "", " -u", ((String)session.getAttribute("browser").equals("IE") ? "" : " -u"), webOutput); > Also, if someone can see a way of doing it without having two separate > index.html variants that would be good too. the two pages are OK to have ... but if it is a matter of only setting the hidden variable Broswer then you can do it programmatically with JavaScript. For this you can set a function onSubmit that is called before actually submitting and sets the hidden value (I can do this at the end of the month if you want so stick with the two pages for the moment) > ... and we can detect for Netscape 4 on windows and make it use symbol > font, and warn that Netscape 4 on UNIX requires some special > configuration, and then we can look at other browsers like safari, opera > and konqueror and decide if the Unicode option is the correct one etc. and hopefully later by detecting Mozilla we can finally use MathML and Mozilla's native rendering which is great !! Manolis |