Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[bioontology-support] Bug in form_complete.js widgets

Lewis John McGibbney lewis2 at stanford.edu
Tue May 7 14:36:11 PDT 2013


Hi All,

I noticed what I suspect to be a bug in the above file located here [0].
I get an error from within Firebug stating that definition.replace is not a function. 
I tracked this down to line 261 of the JavaScript [0], where we attempt to do some regular expression replacement on the var defintion. The var represents string definitions associated with individual phrases/concepts from ontologies.

var definition = (typeof data.definitions === 'undefined') ? "" : data.definitions;
        def_link.parent().html(truncateText(decodeURIComponent(definition.replace(/\+/g, " "))));

The error "$var.replace is not a function" usually arises when we attempt to do regex replacement on something which is not of type String... which also seems to be the case here.

I made a quick fix/hack as follows

        var definition = (typeof data.definitions === 'undefined') ? "" : data.definitions;
        var str_definition = definition.toString();
        //if(typeof definition != "string")
        //  throw new Error('var definition needs to be of type =String=');
        def_link.parent().html(truncateText(decodeURIComponent(str_definition.replace(/\+/g, " "))));

The commented out lines can be removed as they were only for debugging purposes.
This now works for me and I am able to get the definitions for some given ontology concept, however I must admit I am reasonably new to JavaScript and creating a new variable "str_definition" which is simply a cast of defintion.toString() is maybe not the cleanest and most elegant way to do this.

Would be nice to see a proper fix and if this could be pushed into the available code.

Best 
LEwis     

[0] http://bioportal.bioontology.org/javascripts/widgets/form_complete.js
[1] http://www.bioontology.org/wiki/index.php/NCBO_Widgets#Term-selection_field_on_a_form
Dr. Lewis John McGibbney
Post Doctoral Research Scholar
Engineering Informatics Group
Civil and Environmental Engineering
Room 279, Jerry Yang and Akiko Yamazaki Environment and Energy Building (Y2E2)
473 Via Ortega
Stanford University
Stanford, CA 94305-4020
web      | http://stanford.edu/people/lewis2
Linkedin | http://linkedin.com/in/lmcgibbney
Phone    | +1(408).757.2791
Skype    | lewis.john.mcgibbney




More information about the bioontology-support mailing list