--- a/server.py +++ b/server.py @@ -90,7 +90,9 @@ del(i['_id']) ret[y] = i y = y + 1 - return render_template('blank.html', content = ret, flag = request.args['flag']) + + return render_template('blank.html', content = ret, flag =\ + request.args['flag']) @app.route('/submit', methods=['POST']) --- a/static/text-annotation.js +++ b/static/text-annotation.js @@ -51,17 +51,21 @@ backdrop: false, }); $('.well a').click(function(event){ - if($(event.currentTarget).text().search('#')){ + $('.highlight').removeClass('highlight'); + if($(event.currentTarget).text().search('#') >= 0) { len = $(event.currentTarget).text().split('#').length; - xpath = $(event.currentTarget).text().split('#')[len-1]; + var xpath = $(event.currentTarget).text().split('#')[len-1]; } - else - xpath = $(event.currentTarget).text(); + else { + var xpath = $(event.currentTarget).text(); + } var nodes = document.evaluate(xpath, document, null, XPathResult.ANY_TYPE,null); result = nodes.iterateNext(); while(result){ $(result).addClass("highlight"); - result = nodes.iterateNext(); + if(nodes.iterateNext) { + result = nodes.iterateNext(); + } } }); }); --- a/templates/blank.html +++ b/templates/blank.html @@ -1,5 +1,4 @@ - {% if flag == '1' %} {% for obj in content %}
@@ -21,6 +20,4 @@
{% endfor %} {% endif %} - -