Commit d1dac3f5e8f3851008633b4be364efdd5a782df2

For Hyd Demo
 Some changes. Please check diff.
fetch.py
(0 / 153)
  
1from flask import Flask
2from flask import request
3from flask import render_template
4from flask import make_response
5from flask import jsonify
6import logging
7from logging import FileHandler
8import pymongo
9import os
10import lxml.html
11import urllib2
12import StringIO
13import json
14
15app = Flask(__name__)
16
17
18@app.route('/', methods=['GET'])
19def index():
20 if request.args.has_key('url'):
21 return render_template('index.html', url=request.args['url'])
22 else:
23 return render_template('index.html')
24
25
26@app.route('/fetch', methods=['GET'])
27def fetch():
28 connection = pymongo.Connection()
29 db = connection['mural']
30 collection = db['data']
31 ret = {}
32 x = 0
33 resource = "default"
34 if request.args.has_key('uri'):
35 resource = request.args['uri']
36 for i in collection.find({'uri':resource}):
37 del(i['_id'])
38 ret[x] = i
39 x = x + 1
40 if len(ret) == 0:
41 ret['error'] = "Sorry! No re-treats for you."
42 return jsonify(ret)
43
44
45@app.route('/search', methods=['GET'])
46def search():
47 connection = pymongo.Connection()
48 db = connection['mural']
49 collection = db['data']
50 y = 0
51 ret = {}
52 keywords_dict = json.loads(request.args['data'])
53 keywords = json.loads(keywords_dict)['data']
54 for i in collection.find():
55 for keyword in keywords:
56 print keyword
57 try:
58 if keyword in i['nodes']:
59 del(i['_id'])
60 ret[y] = i
61 y = y + 1
62 except:
63 pass
64 return render_template('blank.html', content = ret)
65
66
67@app.route('/submit', methods=['POST'])
68def submit():
69 c = pymongo.Connection()
70 db = c['mural']
71 coll = db['data']
72 requestData = json.loads(request.form['data'])
73 try:
74 for i in requestData:
75 coll.insert(i)
76 response = make_response()
77 response.headers['Access-Control-Allow-Origin'] = '*'
78 response.status = '200 OK'
79 response.status_code = 200
80 return response
81 except:
82 response = make_response()
83 response.status = "500"
84 response.data = "Your post could not be saved. Try posting again."
85 return response
86
87@app.route('/web', methods=['GET'])
88def web():
89 return render_template('web.html')
90
91@app.route('/SWeeText', methods=['GET'])
92def SWeeText():
93 if request.args.has_key('url'):
94 myhandler1 = urllib2.Request(request.args['url'], headers={'User-Agent': "Mozilla/5.0(X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11"})
95 a = urllib2.urlopen(myhandler1)
96 page = a.read()
97 a.close()
98 try:
99 page = unicode(page, 'utf-8')
100 except UnicodeDecodeError:
101 pass
102 root = lxml.html.parse(StringIO.StringIO(page)).getroot()
103 root.make_links_absolute(request.args['url'], resolve_base_href = True)
104
105 # inject the JS toolbar to annotate text
106 script = root.makeelement('script')
107 script.set('src', 'static/text-annotation.js')
108 tree = root.makeelement('script')
109 tree.set('src', 'static/tree.js')
110 bs_js = root.makeelement('script')
111 bs_js.set('src', 'static/bootstrap.js')
112 jq = root.makeelement('script')
113 jq.set('src', 'static/jquery-1.9.1.min.js')
114 jit = root.makeelement('script')
115 jit.set('src', 'static/jit.js')
116 us = root.makeelement('script')
117 us.set('src', 'static/underscore-min-1.4.4.js')
118
119 link = root.makeelement('link')
120 link.set('href', 'static/text-annotation.css')
121 link.set('type', 'text/css')
122 link.set('rel', 'stylesheet')
123 bs = root.makeelement('link')
124 bs.set('href', 'static/bootstrap.css')
125 bs.set('type', 'text/css')
126 bs.set('rel', 'stylesheet')
127 tree_css = root.makeelement('link')
128 tree_css.set('href', 'static/tree.css')
129 tree_css.set('type', 'text/css')
130 tree_css.set('rel', 'stylesheet')
131
132 root.body.append(jq)
133 root.body.append(bs_js)
134 root.body.append(jit)
135 root.body.append(us)
136 root.body.append(tree)
137 root.body.append(script)
138
139 root.head.append(bs)
140 root.head.append(link)
141 root.head.append(tree_css)
142
143 return lxml.html.tostring(root)
144
145
146#Log the errors, don't depend on apache to log it for you.
147 fil = FileHandler(os.path.join(os.path.dirname(__file__), 'logme'),mode='a')
148 fil.setLevel(logging.ERROR)
149 app.logger.addHandler(fil)
150
151
152if __name__ == "__main__":
153 app.run(debug=True, host='0.0.0.0')
server.py
(164 / 0)
  
1from flask import Flask
2from flask import request
3from flask import render_template
4from flask import make_response
5from flask import jsonify
6import logging
7from logging import FileHandler
8import pymongo
9import os
10import lxml.html
11import urllib2
12import StringIO
13import json
14
15app = Flask(__name__)
16
17
18@app.route('/', methods=['GET'])
19def index():
20 if request.args.has_key('url'):
21 return render_template('index.html', url=request.args['url'])
22 else:
23 return render_template('index.html')
24
25
26@app.route('/fetch', methods=['GET'])
27def fetch():
28 connection = pymongo.Connection()
29 db = connection['mural']
30 collection = db['data']
31 ret = {}
32 x = 0
33 resource = "default"
34 if request.args.has_key('uri'):
35 resource = request.args['uri']
36 for i in collection.find({'uri':resource}):
37 del(i['_id'])
38 ret[x] = i
39 x = x + 1
40 if len(ret) == 0:
41 ret['error'] = "Sorry! No re-treats for you."
42 return jsonify(ret)
43
44
45@app.route('/search', methods=['GET'])
46def search():
47 connection = pymongo.Connection()
48 db = connection['mural']
49 collection = db['data']
50 y = 0
51 ret = {}
52 keywords_dict = json.loads(request.args['data'])
53 keywords = json.loads(keywords_dict)['data']
54 for i in collection.find():
55 for keyword in keywords:
56 print keyword
57 try:
58 if keyword in i['nodes']:
59 del(i['_id'])
60 ret[y] = i
61 y = y + 1
62 except:
63 pass
64 return render_template('blank.html', content = ret)
65
66
67@app.route('/submit', methods=['POST'])
68def submit():
69 c = pymongo.Connection()
70 db = c['mural']
71 coll = db['data']
72 requestData = json.loads(request.form['data'])
73 try:
74 for i in requestData:
75 coll.insert(i)
76 response = make_response()
77 response.headers['Access-Control-Allow-Origin'] = '*'
78 response.status = '200 OK'
79 response.status_code = 200
80 return response
81 except:
82 response = make_response()
83 response.status = "500"
84 response.data = "Your post could not be saved. Try posting again."
85 return response
86
87@app.route('/web', methods=['GET'])
88def web():
89 return render_template('web.html')
90
91@app.route('/SWeeText', methods=['GET'])
92def SWeeText():
93 if request.args.has_key('url'):
94 # Log -- comment them
95 print "Got URL " + request.args['url'] + " .. Fetching and Parsing.."
96 myhandler1 = urllib2.Request(request.args['url'], headers={'User-Agent': "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:20.0) Gecko/20100101 Firefox/20.0"})
97 a = urllib2.urlopen(myhandler1)
98 page = a.read()
99 a.close()
100 try:
101 page = unicode(page, 'utf-8')
102 except UnicodeDecodeError:
103 pass
104 root = lxml.html.parse(StringIO.StringIO(page)).getroot()
105 root.make_links_absolute(request.args['url'], resolve_base_href = True)
106 # Log -- comment them
107 print "Page parsed.. Preparing to send.."
108
109 # inject the JS toolbar to annotate text
110 jq = root.makeelement('script')
111 jq.set('src', 'static/jquery-1.9.1.min.js')
112
113 script = root.makeelement('script')
114 script.set('src', 'static/text-annotation.js')
115
116 tree = root.makeelement('script')
117 tree.set('src', 'static/tree.js')
118
119 bs_js = root.makeelement('script')
120 bs_js.set('src', 'static/bootstrap.js')
121
122 jit = root.makeelement('script')
123 jit.set('src', 'static/jit.js')
124
125 us = root.makeelement('script')
126 us.set('src', 'static/underscore-min-1.4.4.js')
127
128 link = root.makeelement('link')
129 link.set('href', 'static/text-annotation.css')
130 link.set('type', 'text/css')
131 link.set('rel', 'stylesheet')
132
133 bs = root.makeelement('link')
134 bs.set('href', 'static/bootstrap.css')
135 bs.set('type', 'text/css')
136 bs.set('rel', 'stylesheet')
137
138 tree_css = root.makeelement('link')
139 tree_css.set('href', 'static/tree.css')
140 tree_css.set('type', 'text/css')
141 tree_css.set('rel', 'stylesheet')
142
143 root.head.append(bs)
144 root.head.append(link)
145 root.head.append(tree_css)
146
147 root.head.append(jq)
148 root.head.append(bs_js)
149 root.head.append(jit)
150 root.head.append(us)
151 root.head.append(tree)
152 root.head.append(script)
153
154 return lxml.html.tostring(root)
155
156
157#Log the errors, don't depend on apache to log it for you.
158 fil = FileHandler(os.path.join(os.path.dirname(__file__), 'logme'),mode='a')
159 fil.setLevel(logging.ERROR)
160 app.logger.addHandler(fil)
161
162
163if __name__ == "__main__":
164 app.run(debug=True, host='0.0.0.0')
  
1[{
2"adjacencies" :[{"nodeTo" :"ShivaPurana",
3"nodeFrom":"GirijaKalyanaStory",
4"data":{"$color":"blue"}}] ,
5"data":{"$color":"white","$type":"ellipse",
6"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"GirijaKalyanaStory","name":"GirijaKalyanaStory"
7},{
8"adjacencies" :[{"nodeTo" :"GirijaKalyanaStory",
9"nodeFrom":"ShivaPurana",
10"data":{"$color":"blue"}}] ,
11"data":{"$color":"white","$type":"ellipse",
12"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"ShivaPurana","name":"ShivaPurana"
13},{
14"adjacencies" :[{"nodeTo" :"Pampapathi",
15"nodeFrom":"GirijaKalyanaStory",
16"data":{"$color":"blue"}}] ,
17"data":{"$color":"white","$type":"ellipse",
18"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"GirijaKalyanaStory","name":"GirijaKalyanaStory"
19},{
20"adjacencies" :[{"nodeTo" :"Hampamma",
21"nodeFrom":"GirijaKalyanaStory",
22"data":{"$color":"blue"}}] ,
23"data":{"$color":"white","$type":"ellipse",
24"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"GirijaKalyanaStory","name":"GirijaKalyanaStory"
25},{
26"adjacencies" :[{"nodeTo" :"Daksha",
27"nodeFrom":"GirijaKalyanaStory",
28"data":{"$color":"blue"}}] ,
29"data":{"$color":"white","$type":"ellipse",
30"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"GirijaKalyanaStory","name":"GirijaKalyanaStory"
31},{
32"adjacencies" :[{"nodeTo" :"GirijaKalyanaMural",
33"nodeFrom":"GirijaKalyanaStory",
34"data":{"$color":"blue"}}] ,
35"data":{"$color":"white","$type":"ellipse",
36"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"GirijaKalyanaStory","name":"GirijaKalyanaStory"
37},{
38"adjacencies" :[{"nodeTo" :"PalaPuja",
39"nodeFrom":"GirijaKalyanaStory",
40"data":{"$color":"blue"}}] ,
41"data":{"$color":"white","$type":"ellipse",
42"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"GirijaKalyanaStory","name":"GirijaKalyanaStory"
43},{
44"adjacencies" :[{"nodeTo" :"KalyanUtsav",
45"nodeFrom":"GirijaKalyanaStory",
46"data":{"$color":"blue"}}] ,
47"data":{"$color":"white","$type":"ellipse",
48"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"GirijaKalyanaStory","name":"GirijaKalyanaStory"
49},{
50"adjacencies" :[{"nodeTo" :"PampapathiEg1",
51"nodeFrom":"Pampapathi",
52"data":{"$color":"blue"}}] ,
53"data":{"$color":"lightgray","$type":"rectangle",
54"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"Pampapathi","name":"Pampapathi"
55},{
56"adjacencies" :[{"nodeTo" :"PampapathiEg2",
57"nodeFrom":"Pampapathi",
58"data":{"$color":"blue"}}] ,
59"data":{"$color":"lightgray","$type":"rectangle",
60"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"Pampapathi","name":"Pampapathi"
61},{
62"adjacencies" :[{"nodeTo" :"Snake",
63"nodeFrom":"Pampapathi",
64"data":{"$color":"blue"}}] ,
65"data":{"$color":"lightgray","$type":"rectangle",
66"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"Pampapathi","name":"Pampapathi"
67},{
68"adjacencies" :[{"nodeTo" :"Nandi",
69"nodeFrom":"Pampapathi",
70"data":{"$color":"blue"}}] ,
71"data":{"$color":"lightgray","$type":"rectangle",
72"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"Pampapathi","name":"Pampapathi"
73},{
74"adjacencies" :[{"nodeTo" :"Hampamma",
75"nodeFrom":"Pampapathi",
76"data":{"$color":"black"}}] ,
77"data":{"$color":"lightgray","$type":"rectangle",
78"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"Pampapathi","name":"Pampapathi"
79},{
80"adjacencies" :[{"nodeTo" :"GirijaKalyanaStory",
81"nodeFrom":"Pampapathi",
82"data":{"$color":"blue"}}] ,
83"data":{"$color":"lightgray","$type":"rectangle",
84"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"Pampapathi","name":"Pampapathi"
85},{
86"adjacencies" :[{"nodeTo" :"Pampapathi",
87"nodeFrom":"Hampamma",
88"data":{"$color":"black"}}] ,
89"data":{"$color":"lightgray","$type":"rectangle",
90"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"Hampamma","name":"Hampamma"
91},{
92"adjacencies" :[{"nodeTo" :"Daksha",
93"nodeFrom":"Hampamma",
94"data":{"$color":"black"}}] ,
95"data":{"$color":"lightgray","$type":"rectangle",
96"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"Hampamma","name":"Hampamma"
97},{
98"adjacencies" :[{"nodeTo" :"GirijaKalyanaStory",
99"nodeFrom":"Hampamma",
100"data":{"$color":"blue"}}] ,
101"data":{"$color":"lightgray","$type":"rectangle",
102"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"Hampamma","name":"Hampamma"
103},{
104"adjacencies" :[{"nodeTo" :"Hampamma",
105"nodeFrom":"Daksha",
106"data":{"$color":"black"}}] ,
107"data":{"$color":"lightgray","$type":"rectangle",
108"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"Daksha","name":"Daksha"
109},{
110"adjacencies" :[{"nodeTo" :"GirijaKalyanaStory",
111"nodeFrom":"Daksha",
112"data":{"$color":"blue"}}] ,
113"data":{"$color":"lightgray","$type":"rectangle",
114"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"Daksha","name":"Daksha"
115},{
116"adjacencies" :[{"nodeTo" :"GirijaKalyanaEg",
117"nodeFrom":"GirijaKalyanaMural",
118"data":{"$color":"blue"}}] ,
119"data":{"$color":"white","$type":"ellipse",
120"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"GirijaKalyanaMural","name":"GirijaKalyanaMural"
121},{
122"adjacencies" :[{"nodeTo" :"Anklet",
123"nodeFrom":"GirijaKalyanaMural",
124"data":{"$color":"blue"}}] ,
125"data":{"$color":"white","$type":"ellipse",
126"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"GirijaKalyanaMural","name":"GirijaKalyanaMural"
127},{
128"adjacencies" :[{"nodeTo" :"Pampapathi",
129"nodeFrom":"GirijaKalyanaMural",
130"data":{"$color":"blue"}}] ,
131"data":{"$color":"white","$type":"ellipse",
132"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"GirijaKalyanaMural","name":"GirijaKalyanaMural"
133},{
134"adjacencies" :[{"nodeTo" :"Hampamma",
135"nodeFrom":"GirijaKalyanaMural",
136"data":{"$color":"blue"}}] ,
137"data":{"$color":"white","$type":"ellipse",
138"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"GirijaKalyanaMural","name":"GirijaKalyanaMural"
139},{
140"adjacencies" :[{"nodeTo" :"Daksha",
141"nodeFrom":"GirijaKalyanaMural",
142"data":{"$color":"blue"}}] ,
143"data":{"$color":"white","$type":"ellipse",
144"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"GirijaKalyanaMural","name":"GirijaKalyanaMural"
145},{
146"adjacencies" :[{"nodeTo" :"GirijaKalyanaStory",
147"nodeFrom":"GirijaKalyanaMural",
148"data":{"$color":"blue"}}] ,
149"data":{"$color":"white","$type":"ellipse",
150"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"GirijaKalyanaMural","name":"GirijaKalyanaMural"
151},{
152"adjacencies" :[{"nodeTo" :"KalyanaMantapa",
153"nodeFrom":"GirijaKalyanaMural",
154"data":{"$color":"blue"}}] ,
155"data":{"$color":"white","$type":"ellipse",
156"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"GirijaKalyanaMural","name":"GirijaKalyanaMural"
157},{
158"adjacencies" :[{"nodeTo" :"VijaynagaraTradition",
159"nodeFrom":"GirijaKalyanaMural",
160"data":{"$color":"blue"}}] ,
161"data":{"$color":"white","$type":"ellipse",
162"$label-color":"black","$label-size":"20","$nodecDir":""},"id":"GirijaKalyanaMural","name":"GirijaKalyanaMural"
163},{
164"adjacencies" :[{"nodeTo" :"NandiEg",
165"nodeFrom":"Nandi",
166 "data":{"$color":"blue"}}] ,
167"data":{"$color":"lightgray","$type":"rectangle",
168"$label-color":"black","$label-size":"20","$nodeDir":""},"id":"Nandi","name":"Nandi"
169}]
  
11#annotate-bar {
2 position: absolute;
2 position: fixed;
3 width: 80%;
34 top: 1px;
4 left: 35%;
5 width: 180px;
6 height: 35px;
7 margin: auto;
8 border: 1px solid black;
9 background-color: #F0F0F0;
10 border-radius: 3px;
11 opacity: 0.9;
12 z-index: 1000;
13 padding: 3px 10px;
145}
15#anno-btn {
16 margin: 0 5px;
17 opacity: 1;
18}
19#publish {
20 opacity:1;
21 margin: 0 5px;
22}
236#sweeted {
24 opacity: 1;
257 z-index: 1000 !important;
268 display: none;
27 width: 400px !important;
28 font-style: bold !important;
299 font-size: 16px;
10 width: 100%;
11}
12.alert {
13 margin: auto;
14 width: 700px;
15 box-shadow: 3px 3px 3px #468847;
3016}
  
3232 nodes[i].addEventListener('mouseout', onHoverOut);
3333 }
3434 }
35 //$(document).mouseover(onHover);
36 //$(document).mouseout(onHoverOut);
3537 };
3638 var removeSelect = function() {
3739 var nodes = document.getElementsByTagName('*');
4545 nodes[i].removeEventListener('mouseout', onHoverOut);
4646 }
4747 }
48 //$(document).unbind('mouseover', onHover);
49 //$(document).unbind('mouseout', onHoverOut);
4850 };
4951 var toolbar_template = function() {
50 return '<div class="toolbar"><button class="btn" id="anno-btn" onclick="initSelect();">'+
51 'Annotate</button> <button class="btn" id="publish">Publish</button></div>' +
52 '<div class="alert alert-error" id="sweeted"><button type="button" class="close" data-dismiss="alert">&times;</button><div id="sweet"></div></div>'+
53 '<div id="posted" class="alert alert-success" style="display: none; width: 300px; margin: auto;"><button type="button" class="close" data-dismiss="alert">&times;</button><b>Success!</b> </div><div id="fail-posting" class="alert alert-error" style="display: none; width: 300px; margin: auto;"><button type="button" class="close" data-dismiss="alert">&times;</button><b>Error!</b> Something went wrong. Could not post.</div>';
52 return '<div class="navbar">'+
53 '<div class="navbar-inner"> <ul class="nav">'+
54 '<li><a class="brand" href="#"> IDH-SWeeTer Annotation </a></li>' +
55 '<li><a></a></li>'+
56 '<li><a></a></li>'+
57 '<li><button class="btn" id="anno-btn" onclick="initSelect();">Annotate</button></li>' +
58 '<li><a></a></li>'+
59 '<li><button class="btn" id="publish">Publish</button></li>' +
60 '</ul></div></div>' +
61 '<div id="sweeted"></div> <div id="posted"></div> <div id="fail-posting"></div>';
5462 };
63
5564 var modal_template = function() {
5665 return '<div id="annotation-tree" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <div id="myModalLabel"> <h3>Annotation attributes</h3> <small>Select attributes for annotation</small> </div> </div> <div class="modal-body"> <div id="stats"> <div id="node-info"></div> <div id="selected-nodes"></div> </div> <div id="infovis"></div> <div id="status"></div> </div> <div class="modal-footer"> <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button> <button class="btn btn-primary" onclick="closeAnnotationTree();">Save changes</button> </div> </div>';
5766 };
8484 elem.removeEventListener('click', onClick);
8585 };
8686 var onClick = function(event) {
87 console.log(event);
88 //$(event).preventDefault();
87 //console.log(event);
88 //event.stopImmediatePropagation();
8989 event.stopPropagation();
90 var elem = event.currentTarget;
90 event.preventDefault();
91 var elem = event.target;
9192 elem.style.border = 'none';
9293 elem.style.boxShadow = '';
9394 //console.log('clicked', elem);
100100 return false;
101101 };
102102
103
104var DOM = {
105 getXpath : function (element)
106 {
107 var str = '';
108 var currentNode = element;
109 var path = '';
110 var index = -1;
111
112 if (currentNode.nodeName != "#text")
113 {
114 path = DOM.makePath(currentNode);
115 }
116 else
117 {
118 path = DOM.makePath(currentNode.parentNode);
119 }
120
121
122 return path;
103 // Object containing methods to find out xpath of an
104 // element
105 var DOM = {
106 getXpath: function(element) {
107 var str = '';
108 var currentNode = element;
109 var path = '';
110 var index = -1;
111 if (currentNode.nodeName != "#text") {
112 path = DOM.makePath(currentNode);
113 }
114 else {
115 path = DOM.makePath(currentNode.parentNode);
116 }
117 return path;
123118 },
124 getElementIdx : function getElementIdx(elt)
125 {
126 var count = 1;
127 for (var sib = elt.previousSibling; sib ; sib = sib.previousSibling)
128 {
129 if(sib.nodeType == 1 && sib.tagName == elt.tagName)count++
130 }
131
132 return count;
119 getElementIdx: function(elt) {
120 var count = 1;
121 for (var sib = elt.previousSibling; sib ; sib = sib.previousSibling) {
122 if(sib.nodeType == 1 && sib.tagName == elt.tagName) {
123 count++;
124 }
125 }
126 return count;
133127 },
134
135 makePath : function makePath(elt){
136 var path = '';
137 for (; elt && elt.nodeType == 1; elt = elt.parentNode)
138 {
139 if(elt.id == "")
140 {
141 idx = DOM.getElementIdx(elt);
142 xname = elt.tagName;
143 if (idx > 1)
144 xname += "[" + idx + "]";
145 path = "/" + xname + path;
146 }
147 else
148 {
149 path = "//*[@id='"+elt.id+"']"+path;
150 break;
151 }
152 }
153 return path;
128 makePath: function(elt) {
129 var path = '';
130 for (; elt && elt.nodeType == 1; elt = elt.parentNode) {
131 if(elt.id == "") {
132 idx = DOM.getElementIdx(elt);
133 xname = elt.tagName;
134 if (idx > 1) {
135 xname += "[" + idx + "]";
136 }
137 path = "/" + xname + path;
138 }
139 else {
140 path = "//*[@id='"+elt.id+"']"+path;
141 break;
142 }
143 }
144 return path;
154145 },
155 settextContent : function(element, content){
156 $(element).html(content);
146 settextContent: function(element, content) {
147 $(element).html(content);
157148 },
158 gettextContent:function(element)
159 {
160 return $(element).html();
161 },
162};
149 gettextContent: function(element) {
150 return $(element).html();
151 }
152 };
163153})();
164154var config = {
165155 'postTweetUrl':'http://localhost:5001',
  
4343 return;
4444 }
4545 console.log('Loading ontology file');
46 var url = 'static/graphs/Hampi_GirijaKalyana.json'
46 var url = 'static/graphs/GirijaKalyanaStory.json'
4747 $.ajax({
4848 type: 'GET',
4949 url: url,
204204 $('#fail-posting').show();
205205 }
206206 });*/
207 $('#posted').show();
207 //$('#posted').html(posted_template());
208 //$('#posted').show();
208209 var swts = '';
209210 for(var i in sweet.swts) {
210211 var data = sweet.swts[i];
221221 swts += swt + '\n';
222222 }
223223 console.log(swts);
224 $('#sweeted').html(sweeted_template(swts));
224225 $('#sweeted').show();
225 $('#sweet').html(swts);
226226 sweet.swts = [];
227227 },
228228 error: function() {
229 //$('#fail-posting').show();
229 $('#fail-posting').html(fail_posting_template());
230 $('#fail-posting').show();
230231 }
231232 });
232233 }
233234};
234235
236var sweeted_template = function(msg) {
237 return '<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">&times;</button><div>' + msg + '</div></div>';
238 };
239 var posted_template = function() {
240 return '<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">&times;</button><b>Success!</b> </div>';
241 };
242 var fail_posting_template = function() {
243 return '<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">&times;</button><b>Error!</b> Something went wrong. Could not post.</div>';
244 };
245
235246function closeAnnotationTree() {
236247 $('#annotation-tree').modal('hide');
237248 $('#infovis').html('');
257257 injectInto: 'infovis',
258258 Navigation: {
259259 enable: true,
260 //panning: 'avoid nodes',
260 panning: 'avoid nodes',
261261 zooming: 10
262262 },
263263 Node: {
  
33<head>
44 <meta charset="utf-8">
55 <meta http-equiv='imagetoolbar' content='no'/>
6 <title> Lepakshi Mural Annotation </title>
6 <title> IDH-SWeeTer Annotation </title>
77 <link rel="stylesheet" type="text/css" href="static/bootstrap.css"></link>
88 <link rel="stylesheet" type="text/css" href="static/tree.css"></link>
99 <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
2424
2525 <div class="navbar">
2626 <div class="navbar-inner">
27 <a class="brand" href="#">Lepakshi Mural</a>
27 <a class="brand" href="#"> IDH-SWeeTer Annotation </a>
2828 <ul class="nav">
2929 <li class="active"><a href="#">Home</a></li>
3030 <li><a></a></li>
5050
5151 <div id="notification">
5252 </div>
53 <div id="posted" class="alert alert-success" style="display: none; width: 300px; margin: auto;">
54 <button type="button" class="close" data-dismiss="alert">&times;</button>
55 <b>Success!</b> Post successfully posted.
56 </div>
57 <div id="fail-posting" class="alert alert-error" style="display: none; width: 300px; margin: auto;">
58 <button type="button" class="close" data-dismiss="alert">&times;</button>
59 <b>Error!</b> Something went wrong. Could not post.
60 </div>
53 <div id="sweeted"></div>
54 <div id="posted"></div>
55 <div id="fail-posting"></div>
6156
6257 <!--div class="btn-group">
6358 <button onclick="handler.trigger();" class="btn btn-small">Mural</button>
  
33<head>
44 <meta charset="utf-8">
55 <meta http-equiv='imagetoolbar' content='no'/>
6 <title> Text Annotation </title>
6 <title> Web Annotation </title>
77 <link rel="stylesheet" type="text/css" href="static/bootstrap.css"></link>
8 <script type="text/javascript" src="static/jquery-1.9.1.min.js"></script>
89 <script type="text/javascript" src="static/bootstrap.js"></script>
10 <style type="text/css">
11 .container {
12 margin-top: 30px;
13 }
14 </style>
915</head>
1016 <body>
11 <div class="fluid-container">
12 <div class="explain lead"> Text annotation of Hampi related content using the IDH Mowl</div>
17 <div class="container">
18 <div class="explain lead"> IDH-SWeeTer Annotation for Web Pages </div>
1319 <div class="input span9">
14 Enter URL to annotate: <input id="url" type="text" placeholder="http://hampi.co.in">
20 Enter URL to annotate: <input id="url" type="text" placeholder="http://vijayanagara.in">
1521 <button class="btn" onclick="loadURL();"> Load </button>
1622 </div>
1723 </div>
1824 <script>
1925 function loadURL() {
2026 var url = document.getElementById('url').value;
27 if(!url) {
28 url = 'http://vijayanagara.in';
29 }
2130 if(!url.match(/http/)) {
2231 url = 'http://' + url;
2332 }