Commits

Yang Zhang  committed 854b08e

fix a bug

  • Participants
  • Parent commits 6f167a5

Comments (0)

Files changed (1)

File static/main.js

     $('#zendict').ScrollTo();
 }
 
+function tolinkWord(word){
+    return word.replace(/ /g,'_').replace(/([(]|[)]|[/]|[-]|['])/g,'');
+}
+
+
+
 function do_suggestion(){
     var word = $('#word_search').val().trim();
     if(word.length <1){
 
 function do_search_word(){
     var word = $('#word_search').val().trim();//.toLowerCase()
-    var linkword = word.replace(/ /g,'_');
+    var linkword = tolinkWord(word);
     if(linkword==""){return;}
     if($("#word_meaning #"+linkword).length == 0){
         constructTabContent(word,null);
 function getWord(word) {
     $.getJSON('/jsonword',{word:word}, function (data) {
         //console.log(data.content);
-        render_template('meaning_template',data.content,word.replace(/ /g,'_'))
+        render_template('meaning_template',data.content,tolinkWord(word));
         $('#word_search').val('');
         
     });
 
 function constructTab(word){
     var template = $('#tab_template').html();
-    var html = Mustache.to_html(template, {spell:word, linkspell:word.replace(/ /g,'_')});
+    var html = Mustache.to_html(template, {spell:word, linkspell:tolinkWord(word)});
     $('#word_chooser_tab').append(html);
 }
 
 function constructTabContent(word,content){
     var template = $('#tab_content_template').html();
-    var html = Mustache.to_html(template, {spell:word.replace(/ /g,'_')});
+    var html = Mustache.to_html(template, {spell:tolinkWord(word)});
     $('#word_meaning').append(html);
     if(content !=null){
         $('#word_meaning #'+word).html(content);