MView works only with inline "mol" param (PC, fire

User 4b927cdefb

08-04-2010 09:36:53

Hy,


We have a problem with MarvinView under Firefox browser version 3.6.2.


If we try to load a molecule from an URL, we get a MolformatException, saying: "Cannot recognize format(?)". But if we load the molecule inline, it works correctly! The files are escaped in both case.


Loading the same mol file from an URL works in any other browsers, including the older versions of Firefox!

ChemAxon 990acf0dec

08-04-2010 12:35:05

Hi Norbi,


Thanks for the report; we will investigate it. In the meantime please note that there are several issues with java applets in general under FF 3.6.2, e.g.:


- http://support.mozilla.com/no/forum/1/628699


- https://support.mozilla.com/en-US/forum/1/638145


 


We will inform you here if we discovered the source of the problem.


Cheers,


Akos

User 4b927cdefb

08-04-2010 13:11:20

Ok, thank you!

User 8201cee929

08-04-2010 13:37:40

Hello,


We have further question regarding marvin view. The following code works fine:



         marvin_jvm = "builtin";
         mview_begin("java/marvin", 200, 200, true);
         mview_param("mol",
"\n Accord 0929031628\n\n 32 36 0 0 0 0 0 0 0 0 1
V2000\n75LWybMW60\nLMJW3cLW70\nSaIW4jDW70\nwnMW3cLW60\nbYHWhlGW60\nNBJWqcFW60\npjFW3cLW60\nbYHWybMW60\novFWqcFW60\nhcOWybMW60\njWGW4jDW60\nSQQW3cLW60\n75LWiZOW80\nLMJWJeJW60\n2xDWybMW60\nbYHWRfIW60\nwnMWJeJW60\nSQQWJeJW60\nhcOWRfIW60\n2xDWiZOW90\npjFWJeJW60\n3sDWn-FW60\nEDSWybMW60\nu8FWGDCW60\nGDCW3cLW60\nEDSWRfIW60\n2xDWRfIW60\nDUCWzXEW60\n0yTW3cLW60\n93DWDeCW60\nGDCWJeJW60\n0yTWJeJW60\n20101\n30601\n40101\n50G01\n60502\n70801\n80201\n90501\nA0402\nB0902\nC0A01\nD0102\nE0201\nF0701\nG0E01\nH0401\nI0J01\nJ0H02\nK0F01\nL0702\nM0901\nN0C01\nO0B01\nP0F02\nQ0I01\nR0L01\nS0M02\nT0N02\nU0S01\nV0R02\nW0Q02\nC0I02\nT0W01\n30B01\nP0V01\nU0O02\nM
END\n");
         mview_end();




although, if we want to get molecule from URL, we got the same error message. The content on the URL is exactly same as in the previous code ('\n' replaced by '\\n'). We tryed escapeChar parameter of marvin, but it didn't help. Should it be working like this or in case of URL this 'one line form' doesn't work.



         marvin_jvm = "builtin";
         mview_begin("java/marvin", 200, 200, true);
         mview_param("mol",
"get_molecule.php?substance_id={$general_data.substance_id}");
         mview_end();


I am little bit afraid of sending '\n' character via http, I would prefer this escaped form ('\n' replaced by '\\n') if it is supported.


I hope I was clear.

Thanks


Gabor

 

 

 

ChemAxon 7c2d26e5cf

08-04-2010 16:48:08

Please see the attached JSP code. It demonstrates how to convert molecule string before pass it to JavaScript. As you see, you don't have to escape special characters of mol string if you embed it into a html form but you have to do it when you embed it into JavaScript.


In the below example JavaScript retrieves the molecule parameter from the http request's header and convert it to the proper format to feed it with JavaScript (mview_param(...)). The implementation of convertForJavaScript method is also embedded into the JSP code. If you use asp or php, you have to do the same conversion.


<%@page import="java.io.*"%>
<%!
static String replaceString(String input, String query, String replacement) {
    StringBuffer sb = new StringBuffer();
    int from=0;
    int pos;
    while((pos = input.indexOf(query, from)) >= 0) {
        if(pos > from) {
            sb.append(input.substring(from,pos));
        }
        sb.append(replacement);
        from = pos+query.length();
    }
    if(input.length() > from)
        sb.append(input.substring(from,input.length()));
    return sb.toString();
}

/**
 * Converts a string to a format that can be used as a
 * value of JavaScript variable in an HTML page.
 * Converts line separators to UNIX style and replaces
 * new line characters with a backslash and an "n"
 * character.
 * @param input original string containing line terminators
 * @return the modified string.
 */
public static String convertForJavaScript(String input) {
    String value = input;
    //Converting Windows style string to UNIX style
    value = replaceString(value, "\r\n", "\n");
    //Converting Macintosh style string to UNIX style
    value = replaceString(value, "\r", "\n");
    //Converting special characters
    value = replaceString(value, "\\", "\\\\");
    value = replaceString(value, "\n", "\\n");
    value = replaceString(value, "\"", "\\\"");
    value = replaceString(value, "'", "\\'");
    return value;
}

%>

...

    <%
    String molstr = request.getParameter("molecule");
    String jmolstr = "";
    if(molstr != null) {
        jmolstr = convertForJavaScript(molstr);
    }
    %>
    <center>
    <p>
    <script language="JavaScript1.1" src="../../marvin.js"></script>
    <script language="JavaScript1.1">
    mview_begin("../..",300,300);
    mview_param("mol","<%= jmolstr %>");
    mview_end();
    </script>
    </p>
    <form>
    <textarea cols=70 rows=20><%=molstr%></textarea>
    </form>
    </center>