Commit 10b11592ab7fa534355c937aef89087b042d9c90

  • avatar
  • arvind
  • Wed Jul 10 17:17:45 IST 2013
UI changes
  Highlight the element in text annotation when the related xpath is clicked.
	Fixing keywords for search API for consistency with old data.
server.py
(1 / 2)
  
9090 del(i['_id'])
9191 ret[y] = i
9292 y = y + 1
93
94 return render_template('blank.html', content = ret)
93 return render_template('blank.html', content = ret, flag = request.args['flag'])
9594
9695
9796@app.route('/submit', methods=['POST'])
  
1var config = {
2 'indexer':'http://127.0.0.1:5000'
3}
  
6262{
6363 for(var i in ans.ans)
6464 {
65 if(feature.geometry.bounds['left'] == ans.ans[i]['left'] && feature.geometry.bounds['right'] == ans.ans[i]['right'] && feature.geometry.bounds['top'] == ans.ans[i]['top'] && feature.geometry.bounds['bottom'] == ans.ans[i]['bottom'])
66 {
65 // if(feature.geometry.bounds['left'] == ans.ans[i]['left'] && feature.geometry.bounds['right'] == ans.ans[i]['right'] && feature.geometry.bounds['top'] == ans.ans[i]['top'] && feature.geometry.bounds['bottom'] == ans.ans[i]['bottom'])
66 // {
6767 str = {};
6868 if(ans.ans[i]['character'])
6969 str['character'] = ans.ans[i]['character'];
7272 str['material'] = ans.ans[i]['material'];
7373 // str['jewellery'] = ans.ans[i]['jewellery']
7474 }
75
75 if(ans.ans[i]["how"])
76 {
7677 z = new OpenLayers.Popup.FramedCloud(
7778 "test",
7879 feature.geometry.getBounds().getCenterLonLat(),
7980 new OpenLayers.Size(640,480),
80 '<iframe src='+config.indexer+"/search?data="+JSON.stringify({'nodes': ans.ans[i]["nodes"]})+" ></iframe>",null,true);
81 '<iframe src='+config.indexer+"/search?flag=0&data="+JSON.stringify({'nodes': ans.ans[i]["how"]})+" ></iframe>",null,true);
82 }
83 else
84 {
85 z = new OpenLayers.Popup.FramedCloud(
86 "test",
87 feature.geometry.getBounds().getCenterLonLat(),
88 new OpenLayers.Size(640,480),
89 '<iframe src='+config.indexer+"/search?flag=0&data="+JSON.stringify({'nodes': ans.ans[i]["nodes"]})+" ></iframe>",null,true);
90
91 }
92
8193 feature.popup = z;
8294 z.panMapIfOutOfView = true;
8395 map.addPopup(z);
8496 break;
85 }
86 else{
87 if(i == ans.count-1)
88 {
89 z = new OpenLayers.Popup.FramedCloud(
90 "test",
91 feature.geometry.getBounds().getCenterLonLat(),
92 new OpenLayers.Size(640,480),
93 '<iframe width="480" height="360" src="http://www.youtube.com/embed/WwNUnmZ_aww" frameborder="0" allowfullscreen></iframe>',null,true);
94 feature.popup = z;
95 z.panMapIfOutOfView = true;
96 map.addPopup(z);
97 }
98 }
97 //}
98 //else{
99 // if(i == ans.count-1)
100 // {
101 // z = new OpenLayers.Popup.FramedCloud(
102 // "test",
103 // feature.geometry.getBounds().getCenterLonLat(),
104 // new OpenLayers.Size(640,480),
105 // '<iframe width="480" height="360" src="http://www.youtube.com/embed/WwNUnmZ_aww" frameborder="0" allowfullscreen></iframe>',null,true);
106 // feature.popup = z;
107 // z.panMapIfOutOfView = true;
108 // map.addPopup(z);
109 // }
110 //}
99111 }
100112
101113}
196196 $.get(config.indexer+"/fetch",{uri:"default"} , function(data){
197197 if (data != undefined)
198198 {
199 console.log(data);
199200 ans.ans = data;
200201 for(var i in ans.ans)
201202 {
329329}
330330function makeBoxes(x)
331331{
332
332 if(x.left)
333 {
333334 bounds = new OpenLayers.Bounds(x['left'], x['bottom'], x['right'], x['top']);
334335 box = new OpenLayers.Feature.Vector(bounds.toGeometry());
335336 box3.addFeatures(box);
336337 addLabel(x['left'],x['top'],x['name']);
338 }
339 else if(x.where)
340 {
341 position = JSON.parse(x.where.split("#")[1]);
342 console.log(position);
343 bounds = new OpenLayers.Bounds(position[2], position[1], position[3], position[0]);
344 box = new OpenLayers.Feature.Vector(bounds.toGeometry());
345 box3.addFeatures(box);
346 addLabel(position[2],position[0],x['name']);
347
348 }
337349}
338350// function onmouse(data){
339351// console.log(data);
496496 myJSON = [];
497497 });
498498 });
499}
500var config = {
501 'postTweetUrl':'http://demo.swtr.us/add',
502 'indexer':'http://folkhampi.openrun.net/mural-annotation'
503499}
  
1818 width: 500px;
1919 margin: -250px 0 0 28%;
2020}
21.highlight{
22background-color: rgba(255, 212, 0, 0.6);
23
24}
  
1414 modal.id = 'modal-wrap';
1515 document.body.appendChild(modal);
1616 modal.innerHTML = modal_template();
17 $('#publish').click(function() {
17 $("#list-anno").on("hidden", function(){
18 $(".well a").off("click");
19 $(".highlight").removeClass("highlight");
20
21 })
22 $('#publish').click(function() {
1823 sweet.publish();
1924 });
2025 };
4242 };
4343 window.listAnno = function() { // list annotations of current page
4444 console.log('listing annotations');
45 $.get(config.indexer + '/search?data=' +
45
46 $.get(config.indexer + '/search?flag=1&data=' +
4647 JSON.stringify({'where': window.location.search.split('url=')[1]}),
4748 function(data) {
4849 //console.log(data);
5151 $('#list-anno').modal({
5252 backdrop: false,
5353 });
54 $('.well a').click(function(event){
55 xpath = $(event.currentTarget).text().split('#')[1];
56 var nodes = document.evaluate(xpath, document, null, XPathResult.ANY_TYPE,null);
57 result = nodes.iterateNext();
58 while(result){
59 $(result).addClass("highlight");
60 result = nodes.iterateNext();
61 }
62 });
5463 });
5564 };
5665
  
1<!doctype html>
2<body>
3{% if flag == '1' %}
14{% for obj in content %}
25<div class="well">
3{% for key in content[obj].keys() %}
4 <p><b>{{ key }}</b>: {{ content[obj][key] }}</p>
6 {% for key in content[obj].keys() %}
7 {% if key == "where" or key == "xpath" %}
8 <p><b>{{ key }}</b>:<a href="#"> {{ content[obj][key] }}</a></p>
9 {% else %}
10 <p><b>{{ key }}</b>: {{ content[obj][key] }}</p>
11 {% endif %}
12 {% endfor %}
13</div>
514{% endfor %}
15{% else %}
16{% for obj in content %}
17<div class="well">
18 {% for key in content[obj].keys() %}
19 <p><b>{{ key }}</b>: {{ content[obj][key] }}</p>
20 {% endfor %}
621</div>
722{% endfor %}
23{% endif %}
24</body>
25</html>
  
1414 <script type="text/javascript" src="static/tree.js"></script>
1515 <script type="text/javascript" src="static/myVector.js"></script>
1616 <script type="text/javascript" src="static/bootstrap.js"></script>
17 <script type="text/javascript" src="{{ url_for('static',filename='config.js') }}"></script>
1718</head>
1819{% if url %}
1920 <body onload='init({{ url|string|safe }});'>