Commit d1dac3f5e8f3851008633b4be364efdd5a782df2
For Hyd Demo
Some changes. Please check diff.
| | | | 1 | from flask import Flask | | from flask import Flask |
---|
2 | from flask import request | | from flask import request |
---|
3 | from flask import render_template | | from flask import render_template |
---|
4 | from flask import make_response | | from flask import make_response |
---|
5 | from flask import jsonify | | from flask import jsonify |
---|
6 | import logging | | import logging |
---|
7 | from logging import FileHandler | | from logging import FileHandler |
---|
8 | import pymongo | | import pymongo |
---|
9 | import os | | import os |
---|
10 | import lxml.html | | import lxml.html |
---|
11 | import urllib2 | | import urllib2 |
---|
12 | import StringIO | | import StringIO |
---|
13 | import json | | import json |
---|
14 | | | |
---|
15 | app = Flask(__name__) | | app = Flask(__name__) |
---|
16 | | | |
---|
17 | | | |
---|
18 | @app.route('/', methods=['GET']) | | @app.route('/', methods=['GET']) |
---|
19 | def index(): | | def index(): |
---|
20 | if request.args.has_key('url'): | | if request.args.has_key('url'): |
---|
21 | return render_template('index.html', url=request.args['url']) | | return render_template('index.html', url=request.args['url']) |
---|
22 | else: | | else: |
---|
23 | return render_template('index.html') | | return render_template('index.html') |
---|
24 | | | |
---|
25 | | | |
---|
26 | @app.route('/fetch', methods=['GET']) | | @app.route('/fetch', methods=['GET']) |
---|
27 | def fetch(): | | def fetch(): |
---|
28 | connection = pymongo.Connection() | | connection = pymongo.Connection() |
---|
29 | db = connection['mural'] | | db = connection['mural'] |
---|
30 | collection = db['data'] | | collection = db['data'] |
---|
31 | ret = {} | | ret = {} |
---|
32 | x = 0 | | x = 0 |
---|
33 | resource = "default" | | resource = "default" |
---|
34 | if request.args.has_key('uri'): | | if request.args.has_key('uri'): |
---|
35 | resource = request.args['uri'] | | resource = request.args['uri'] |
---|
36 | for i in collection.find({'uri':resource}): | | for i in collection.find({'uri':resource}): |
---|
37 | del(i['_id']) | | del(i['_id']) |
---|
38 | ret[x] = i | | ret[x] = i |
---|
39 | x = x + 1 | | x = x + 1 |
---|
40 | if len(ret) == 0: | | if len(ret) == 0: |
---|
41 | ret['error'] = "Sorry! No re-treats for you." | | ret['error'] = "Sorry! No re-treats for you." |
---|
42 | return jsonify(ret) | | return jsonify(ret) |
---|
43 | | | |
---|
44 | | | |
---|
45 | @app.route('/search', methods=['GET']) | | @app.route('/search', methods=['GET']) |
---|
46 | def search(): | | def search(): |
---|
47 | connection = pymongo.Connection() | | connection = pymongo.Connection() |
---|
48 | db = connection['mural'] | | db = connection['mural'] |
---|
49 | collection = db['data'] | | collection = db['data'] |
---|
50 | y = 0 | | y = 0 |
---|
51 | ret = {} | | ret = {} |
---|
52 | keywords_dict = json.loads(request.args['data']) | | keywords_dict = json.loads(request.args['data']) |
---|
53 | keywords = json.loads(keywords_dict)['data'] | | keywords = json.loads(keywords_dict)['data'] |
---|
54 | for i in collection.find(): | | for i in collection.find(): |
---|
55 | for keyword in keywords: | | for keyword in keywords: |
---|
56 | print keyword | | print keyword |
---|
57 | try: | | try: |
---|
58 | if keyword in i['nodes']: | | if keyword in i['nodes']: |
---|
59 | del(i['_id']) | | del(i['_id']) |
---|
60 | ret[y] = i | | ret[y] = i |
---|
61 | y = y + 1 | | y = y + 1 |
---|
62 | except: | | except: |
---|
63 | pass | | pass |
---|
64 | return render_template('blank.html', content = ret) | | return render_template('blank.html', content = ret) |
---|
65 | | | |
---|
66 | | | |
---|
67 | @app.route('/submit', methods=['POST']) | | @app.route('/submit', methods=['POST']) |
---|
68 | def submit(): | | def submit(): |
---|
69 | c = pymongo.Connection() | | c = pymongo.Connection() |
---|
70 | db = c['mural'] | | db = c['mural'] |
---|
71 | coll = db['data'] | | coll = db['data'] |
---|
72 | requestData = json.loads(request.form['data']) | | requestData = json.loads(request.form['data']) |
---|
73 | try: | | try: |
---|
74 | for i in requestData: | | for i in requestData: |
---|
75 | coll.insert(i) | | coll.insert(i) |
---|
76 | response = make_response() | | response = make_response() |
---|
77 | response.headers['Access-Control-Allow-Origin'] = '*' | | response.headers['Access-Control-Allow-Origin'] = '*' |
---|
78 | response.status = '200 OK' | | response.status = '200 OK' |
---|
79 | response.status_code = 200 | | response.status_code = 200 |
---|
80 | return response | | return response |
---|
81 | except: | | except: |
---|
82 | response = make_response() | | response = make_response() |
---|
83 | response.status = "500" | | response.status = "500" |
---|
84 | response.data = "Your post could not be saved. Try posting again." | | response.data = "Your post could not be saved. Try posting again." |
---|
85 | return response | | return response |
---|
86 | | | |
---|
87 | @app.route('/web', methods=['GET']) | | @app.route('/web', methods=['GET']) |
---|
88 | def web(): | | def web(): |
---|
89 | return render_template('web.html') | | return render_template('web.html') |
---|
90 | | | |
---|
91 | @app.route('/SWeeText', methods=['GET']) | | @app.route('/SWeeText', methods=['GET']) |
---|
92 | def SWeeText(): | | def SWeeText(): |
---|
93 | if request.args.has_key('url'): | | 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"}) | | 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) | | a = urllib2.urlopen(myhandler1) |
---|
96 | page = a.read() | | page = a.read() |
---|
97 | a.close() | | a.close() |
---|
98 | try: | | try: |
---|
99 | page = unicode(page, 'utf-8') | | page = unicode(page, 'utf-8') |
---|
100 | except UnicodeDecodeError: | | except UnicodeDecodeError: |
---|
101 | pass | | pass |
---|
102 | root = lxml.html.parse(StringIO.StringIO(page)).getroot() | | root = lxml.html.parse(StringIO.StringIO(page)).getroot() |
---|
103 | root.make_links_absolute(request.args['url'], resolve_base_href = True) | | root.make_links_absolute(request.args['url'], resolve_base_href = True) |
---|
104 | | | |
---|
105 | # inject the JS toolbar to annotate text | | # inject the JS toolbar to annotate text |
---|
106 | script = root.makeelement('script') | | script = root.makeelement('script') |
---|
107 | script.set('src', 'static/text-annotation.js') | | script.set('src', 'static/text-annotation.js') |
---|
108 | tree = root.makeelement('script') | | tree = root.makeelement('script') |
---|
109 | tree.set('src', 'static/tree.js') | | tree.set('src', 'static/tree.js') |
---|
110 | bs_js = root.makeelement('script') | | bs_js = root.makeelement('script') |
---|
111 | bs_js.set('src', 'static/bootstrap.js') | | bs_js.set('src', 'static/bootstrap.js') |
---|
112 | jq = root.makeelement('script') | | jq = root.makeelement('script') |
---|
113 | jq.set('src', 'static/jquery-1.9.1.min.js') | | jq.set('src', 'static/jquery-1.9.1.min.js') |
---|
114 | jit = root.makeelement('script') | | jit = root.makeelement('script') |
---|
115 | jit.set('src', 'static/jit.js') | | jit.set('src', 'static/jit.js') |
---|
116 | us = root.makeelement('script') | | us = root.makeelement('script') |
---|
117 | us.set('src', 'static/underscore-min-1.4.4.js') | | us.set('src', 'static/underscore-min-1.4.4.js') |
---|
118 | | | |
---|
119 | link = root.makeelement('link') | | link = root.makeelement('link') |
---|
120 | link.set('href', 'static/text-annotation.css') | | link.set('href', 'static/text-annotation.css') |
---|
121 | link.set('type', 'text/css') | | link.set('type', 'text/css') |
---|
122 | link.set('rel', 'stylesheet') | | link.set('rel', 'stylesheet') |
---|
123 | bs = root.makeelement('link') | | bs = root.makeelement('link') |
---|
124 | bs.set('href', 'static/bootstrap.css') | | bs.set('href', 'static/bootstrap.css') |
---|
125 | bs.set('type', 'text/css') | | bs.set('type', 'text/css') |
---|
126 | bs.set('rel', 'stylesheet') | | bs.set('rel', 'stylesheet') |
---|
127 | tree_css = root.makeelement('link') | | tree_css = root.makeelement('link') |
---|
128 | tree_css.set('href', 'static/tree.css') | | tree_css.set('href', 'static/tree.css') |
---|
129 | tree_css.set('type', 'text/css') | | tree_css.set('type', 'text/css') |
---|
130 | tree_css.set('rel', 'stylesheet') | | tree_css.set('rel', 'stylesheet') |
---|
131 | | | |
---|
132 | root.body.append(jq) | | root.body.append(jq) |
---|
133 | root.body.append(bs_js) | | root.body.append(bs_js) |
---|
134 | root.body.append(jit) | | root.body.append(jit) |
---|
135 | root.body.append(us) | | root.body.append(us) |
---|
136 | root.body.append(tree) | | root.body.append(tree) |
---|
137 | root.body.append(script) | | root.body.append(script) |
---|
138 | | | |
---|
139 | root.head.append(bs) | | root.head.append(bs) |
---|
140 | root.head.append(link) | | root.head.append(link) |
---|
141 | root.head.append(tree_css) | | root.head.append(tree_css) |
---|
142 | | | |
---|
143 | return lxml.html.tostring(root) | | return lxml.html.tostring(root) |
---|
144 | | | |
---|
145 | | | |
---|
146 | #Log the errors, don't depend on apache to log it for you. | | #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') | | fil = FileHandler(os.path.join(os.path.dirname(__file__), 'logme'),mode='a') |
---|
148 | fil.setLevel(logging.ERROR) | | fil.setLevel(logging.ERROR) |
---|
149 | app.logger.addHandler(fil) | | app.logger.addHandler(fil) |
---|
150 | | | |
---|
151 | | | |
---|
152 | if __name__ == "__main__": | | if __name__ == "__main__": |
---|
153 | app.run(debug=True, host='0.0.0.0') | | app.run(debug=True, host='0.0.0.0') |
---|
| | | | | | 1 | from flask import Flask |
---|
| | 2 | from flask import request |
---|
| | 3 | from flask import render_template |
---|
| | 4 | from flask import make_response |
---|
| | 5 | from flask import jsonify |
---|
| | 6 | import logging |
---|
| | 7 | from logging import FileHandler |
---|
| | 8 | import pymongo |
---|
| | 9 | import os |
---|
| | 10 | import lxml.html |
---|
| | 11 | import urllib2 |
---|
| | 12 | import StringIO |
---|
| | 13 | import json |
---|
| | 14 | |
---|
| | 15 | app = Flask(__name__) |
---|
| | 16 | |
---|
| | 17 | |
---|
| | 18 | @app.route('/', methods=['GET']) |
---|
| | 19 | def 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']) |
---|
| | 27 | def 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']) |
---|
| | 46 | def 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']) |
---|
| | 68 | def 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']) |
---|
| | 88 | def web(): |
---|
| | 89 | return render_template('web.html') |
---|
| | 90 | |
---|
| | 91 | @app.route('/SWeeText', methods=['GET']) |
---|
| | 92 | def 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 | |
---|
| | 163 | if __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 | }] |
---|
| | | | 1 | #annotate-bar { | 1 | #annotate-bar { |
---|
2 | position: absolute; | | position: absolute; |
---|
| | 2 | position: fixed; | | | 3 | width: 80%; |
---|
3 | top: 1px; | 4 | top: 1px; |
---|
4 | left: 35%; | | left: 35%; |
---|
5 | width: 180px; | | width: 180px; |
---|
6 | height: 35px; | | height: 35px; |
---|
7 | margin: auto; | | margin: auto; |
---|
8 | border: 1px solid black; | | border: 1px solid black; |
---|
9 | background-color: #F0F0F0; | | background-color: #F0F0F0; |
---|
10 | border-radius: 3px; | | border-radius: 3px; |
---|
11 | opacity: 0.9; | | opacity: 0.9; |
---|
12 | z-index: 1000; | | z-index: 1000; |
---|
13 | padding: 3px 10px; | | padding: 3px 10px; |
---|
14 | } | 5 | } |
---|
15 | #anno-btn { | | #anno-btn { |
---|
16 | margin: 0 5px; | | margin: 0 5px; |
---|
17 | opacity: 1; | | opacity: 1; |
---|
18 | } | | } |
---|
19 | #publish { | | #publish { |
---|
20 | opacity:1; | | opacity:1; |
---|
21 | margin: 0 5px; | | margin: 0 5px; |
---|
22 | } | | } |
---|
23 | #sweeted { | 6 | #sweeted { |
---|
24 | opacity: 1; | | opacity: 1; |
---|
25 | z-index: 1000 !important; | 7 | z-index: 1000 !important; |
---|
26 | display: none; | 8 | display: none; |
---|
27 | width: 400px !important; | | width: 400px !important; |
---|
28 | font-style: bold !important; | | font-style: bold !important; |
---|
29 | font-size: 16px; | 9 | font-size: 16px; |
---|
| | 10 | width: 100%; |
---|
| | 11 | } |
---|
| | 12 | .alert { |
---|
| | 13 | margin: auto; |
---|
| | 14 | width: 700px; |
---|
| | 15 | box-shadow: 3px 3px 3px #468847; |
---|
30 | } | 16 | } |
---|
| | | | 32 | nodes[i].addEventListener('mouseout', onHoverOut); | 32 | nodes[i].addEventListener('mouseout', onHoverOut); |
---|
33 | } | 33 | } |
---|
34 | } | 34 | } |
---|
| | 35 | //$(document).mouseover(onHover); |
---|
| | 36 | //$(document).mouseout(onHoverOut); |
---|
35 | }; | 37 | }; |
---|
36 | var removeSelect = function() { | 38 | var removeSelect = function() { |
---|
37 | var nodes = document.getElementsByTagName('*'); | 39 | var nodes = document.getElementsByTagName('*'); |
---|
… | | … | |
---|
45 | nodes[i].removeEventListener('mouseout', onHoverOut); | 45 | nodes[i].removeEventListener('mouseout', onHoverOut); |
---|
46 | } | 46 | } |
---|
47 | } | 47 | } |
---|
| | 48 | //$(document).unbind('mouseover', onHover); |
---|
| | 49 | //$(document).unbind('mouseout', onHoverOut); |
---|
48 | }; | 50 | }; |
---|
49 | var toolbar_template = function() { | 51 | var toolbar_template = function() { |
---|
50 | return '<div class="toolbar"><button class="btn" id="anno-btn" onclick="initSelect();">'+ | | return '<div class="toolbar"><button class="btn" id="anno-btn" onclick="initSelect();">'+ |
---|
51 | 'Annotate</button> <button class="btn" id="publish">Publish</button></div>' + | | '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">×</button><div id="sweet"></div></div>'+ | | '<div class="alert alert-error" id="sweeted"><button type="button" class="close" data-dismiss="alert">×</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">×</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">×</button><b>Error!</b> Something went wrong. Could not post.</div>'; | | '<div id="posted" class="alert alert-success" style="display: none; width: 300px; margin: auto;"><button type="button" class="close" data-dismiss="alert">×</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">×</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>'; |
---|
54 | }; | 62 | }; |
---|
| | 63 | |
---|
55 | var modal_template = function() { | 64 | var modal_template = function() { |
---|
56 | 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>'; | 65 | 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>'; |
---|
57 | }; | 66 | }; |
---|
… | | … | |
---|
84 | elem.removeEventListener('click', onClick); | 84 | elem.removeEventListener('click', onClick); |
---|
85 | }; | 85 | }; |
---|
86 | var onClick = function(event) { | 86 | var onClick = function(event) { |
---|
87 | console.log(event); | | console.log(event); |
---|
88 | //$(event).preventDefault(); | | //$(event).preventDefault(); |
---|
| | 87 | //console.log(event); | | | 88 | //event.stopImmediatePropagation(); |
---|
89 | event.stopPropagation(); | 89 | event.stopPropagation(); |
---|
90 | var elem = event.currentTarget; | | var elem = event.currentTarget; |
---|
| | 90 | event.preventDefault(); | | | 91 | var elem = event.target; |
---|
91 | elem.style.border = 'none'; | 92 | elem.style.border = 'none'; |
---|
92 | elem.style.boxShadow = ''; | 93 | elem.style.boxShadow = ''; |
---|
93 | //console.log('clicked', elem); | 94 | //console.log('clicked', elem); |
---|
… | | … | |
---|
100 | return false; | 100 | return false; |
---|
101 | }; | 101 | }; |
---|
102 | | 102 | |
---|
103 | | | |
---|
104 | var DOM = { | | var DOM = { |
---|
105 | getXpath : function (element) | | getXpath : function (element) |
---|
106 | { | | { |
---|
107 | var str = ''; | | var str = ''; |
---|
108 | var currentNode = element; | | var currentNode = element; |
---|
109 | var path = ''; | | var path = ''; |
---|
110 | var index = -1; | | var index = -1; |
---|
111 | | | |
---|
112 | if (currentNode.nodeName != "#text") | | if (currentNode.nodeName != "#text") |
---|
113 | { | | { |
---|
114 | path = DOM.makePath(currentNode); | | path = DOM.makePath(currentNode); |
---|
115 | } | | } |
---|
116 | else | | else |
---|
117 | { | | { |
---|
118 | path = DOM.makePath(currentNode.parentNode); | | path = DOM.makePath(currentNode.parentNode); |
---|
119 | } | | } |
---|
120 | | | |
---|
121 | | | |
---|
122 | return path; | | 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; |
---|
123 | }, | 118 | }, |
---|
124 | getElementIdx : function getElementIdx(elt) | | getElementIdx : function getElementIdx(elt) |
---|
125 | { | | { |
---|
126 | var count = 1; | | var count = 1; |
---|
127 | for (var sib = elt.previousSibling; sib ; sib = sib.previousSibling) | | for (var sib = elt.previousSibling; sib ; sib = sib.previousSibling) |
---|
128 | { | | { |
---|
129 | if(sib.nodeType == 1 && sib.tagName == elt.tagName)count++ | | if(sib.nodeType == 1 && sib.tagName == elt.tagName)count++ |
---|
130 | } | | } |
---|
131 | | | |
---|
132 | return count; | | 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; |
---|
133 | }, | 127 | }, |
---|
134 | | | |
---|
135 | makePath : function makePath(elt){ | | makePath : function makePath(elt){ |
---|
136 | var path = ''; | | var path = ''; |
---|
137 | for (; elt && elt.nodeType == 1; elt = elt.parentNode) | | for (; elt && elt.nodeType == 1; elt = elt.parentNode) |
---|
138 | { | | { |
---|
139 | if(elt.id == "") | | if(elt.id == "") |
---|
140 | { | | { |
---|
141 | idx = DOM.getElementIdx(elt); | | idx = DOM.getElementIdx(elt); |
---|
142 | xname = elt.tagName; | | xname = elt.tagName; |
---|
143 | if (idx > 1) | | if (idx > 1) |
---|
144 | xname += "[" + idx + "]"; | | xname += "[" + idx + "]"; |
---|
145 | path = "/" + xname + path; | | path = "/" + xname + path; |
---|
146 | } | | } |
---|
147 | else | | else |
---|
148 | { | | { |
---|
149 | path = "//*[@id='"+elt.id+"']"+path; | | path = "//*[@id='"+elt.id+"']"+path; |
---|
150 | break; | | break; |
---|
151 | } | | } |
---|
152 | } | | } |
---|
153 | return path; | | 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; |
---|
154 | }, | 145 | }, |
---|
155 | settextContent : function(element, content){ | | settextContent : function(element, content){ |
---|
156 | $(element).html(content); | | $(element).html(content); |
---|
| | 146 | settextContent: function(element, content) { | | | 147 | $(element).html(content); |
---|
157 | }, | 148 | }, |
---|
158 | gettextContent:function(element) | | gettextContent:function(element) |
---|
159 | { | | { |
---|
160 | return $(element).html(); | | return $(element).html(); |
---|
161 | }, | | }, |
---|
162 | }; | | }; |
---|
| | 149 | gettextContent: function(element) { | | | 150 | return $(element).html(); |
---|
| | 151 | } |
---|
| | 152 | }; |
---|
163 | })(); | 153 | })(); |
---|
164 | var config = { | 154 | var config = { |
---|
165 | 'postTweetUrl':'http://localhost:5001', | 155 | 'postTweetUrl':'http://localhost:5001', |
---|
| | | | 43 | return; | 43 | return; |
---|
44 | } | 44 | } |
---|
45 | console.log('Loading ontology file'); | 45 | console.log('Loading ontology file'); |
---|
46 | var url = 'static/graphs/Hampi_GirijaKalyana.json' | | var url = 'static/graphs/Hampi_GirijaKalyana.json' |
---|
| | 46 | var url = 'static/graphs/GirijaKalyanaStory.json' | 47 | $.ajax({ | 47 | $.ajax({ |
---|
48 | type: 'GET', | 48 | type: 'GET', |
---|
49 | url: url, | 49 | url: url, |
---|
… | | … | |
---|
204 | $('#fail-posting').show(); | 204 | $('#fail-posting').show(); |
---|
205 | } | 205 | } |
---|
206 | });*/ | 206 | });*/ |
---|
207 | $('#posted').show(); | | $('#posted').show(); |
---|
| | 207 | //$('#posted').html(posted_template()); | | | 208 | //$('#posted').show(); |
---|
208 | var swts = ''; | 209 | var swts = ''; |
---|
209 | for(var i in sweet.swts) { | 210 | for(var i in sweet.swts) { |
---|
210 | var data = sweet.swts[i]; | 211 | var data = sweet.swts[i]; |
---|
… | | … | |
---|
221 | swts += swt + '\n'; | 221 | swts += swt + '\n'; |
---|
222 | } | 222 | } |
---|
223 | console.log(swts); | 223 | console.log(swts); |
---|
| | 224 | $('#sweeted').html(sweeted_template(swts)); |
---|
224 | $('#sweeted').show(); | 225 | $('#sweeted').show(); |
---|
225 | $('#sweet').html(swts); | | $('#sweet').html(swts); |
---|
226 | sweet.swts = []; | 226 | sweet.swts = []; |
---|
227 | }, | 227 | }, |
---|
228 | error: function() { | 228 | error: function() { |
---|
229 | //$('#fail-posting').show(); | | //$('#fail-posting').show(); |
---|
| | 229 | $('#fail-posting').html(fail_posting_template()); | | | 230 | $('#fail-posting').show(); |
---|
230 | } | 231 | } |
---|
231 | }); | 232 | }); |
---|
232 | } | 233 | } |
---|
233 | }; | 234 | }; |
---|
234 | | 235 | |
---|
| | 236 | var sweeted_template = function(msg) { |
---|
| | 237 | return '<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</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">×</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">×</button><b>Error!</b> Something went wrong. Could not post.</div>'; |
---|
| | 244 | }; |
---|
| | 245 | |
---|
235 | function closeAnnotationTree() { | 246 | function closeAnnotationTree() { |
---|
236 | $('#annotation-tree').modal('hide'); | 247 | $('#annotation-tree').modal('hide'); |
---|
237 | $('#infovis').html(''); | 248 | $('#infovis').html(''); |
---|
… | | … | |
---|
257 | injectInto: 'infovis', | 257 | injectInto: 'infovis', |
---|
258 | Navigation: { | 258 | Navigation: { |
---|
259 | enable: true, | 259 | enable: true, |
---|
260 | //panning: 'avoid nodes', | | //panning: 'avoid nodes', |
---|
| | 260 | panning: 'avoid nodes', | 261 | zooming: 10 | 261 | zooming: 10 |
---|
262 | }, | 262 | }, |
---|
263 | Node: { | 263 | Node: { |
---|
| | | | 3 | <head> | 3 | <head> |
---|
4 | <meta charset="utf-8"> | 4 | <meta charset="utf-8"> |
---|
5 | <meta http-equiv='imagetoolbar' content='no'/> | 5 | <meta http-equiv='imagetoolbar' content='no'/> |
---|
6 | <title> Lepakshi Mural Annotation </title> | | <title> Lepakshi Mural Annotation </title> |
---|
| | 6 | <title> IDH-SWeeTer Annotation </title> | 7 | <link rel="stylesheet" type="text/css" href="static/bootstrap.css"></link> | 7 | <link rel="stylesheet" type="text/css" href="static/bootstrap.css"></link> |
---|
8 | <link rel="stylesheet" type="text/css" href="static/tree.css"></link> | 8 | <link rel="stylesheet" type="text/css" href="static/tree.css"></link> |
---|
9 | <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script> | 9 | <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script> |
---|
… | | … | |
---|
24 | | 24 | |
---|
25 | <div class="navbar"> | 25 | <div class="navbar"> |
---|
26 | <div class="navbar-inner"> | 26 | <div class="navbar-inner"> |
---|
27 | <a class="brand" href="#">Lepakshi Mural</a> | | <a class="brand" href="#">Lepakshi Mural</a> |
---|
| | 27 | <a class="brand" href="#"> IDH-SWeeTer Annotation </a> | 28 | <ul class="nav"> | 28 | <ul class="nav"> |
---|
29 | <li class="active"><a href="#">Home</a></li> | 29 | <li class="active"><a href="#">Home</a></li> |
---|
30 | <li><a></a></li> | 30 | <li><a></a></li> |
---|
… | | … | |
---|
50 | | 50 | |
---|
51 | <div id="notification"> | 51 | <div id="notification"> |
---|
52 | </div> | 52 | </div> |
---|
53 | <div id="posted" class="alert alert-success" style="display: none; width: 300px; margin: auto;"> | | <div id="posted" class="alert alert-success" style="display: none; width: 300px; margin: auto;"> |
---|
54 | <button type="button" class="close" data-dismiss="alert">×</button> | | <button type="button" class="close" data-dismiss="alert">×</button> |
---|
55 | <b>Success!</b> Post successfully posted. | | <b>Success!</b> Post successfully posted. |
---|
56 | </div> | | </div> |
---|
57 | <div id="fail-posting" class="alert alert-error" style="display: none; width: 300px; margin: auto;"> | | <div id="fail-posting" class="alert alert-error" style="display: none; width: 300px; margin: auto;"> |
---|
58 | <button type="button" class="close" data-dismiss="alert">×</button> | | <button type="button" class="close" data-dismiss="alert">×</button> |
---|
59 | <b>Error!</b> Something went wrong. Could not post. | | <b>Error!</b> Something went wrong. Could not post. |
---|
60 | </div> | | </div> |
---|
| | 53 | <div id="sweeted"></div> | | | 54 | <div id="posted"></div> |
---|
| | 55 | <div id="fail-posting"></div> |
---|
61 | | 56 | |
---|
62 | <!--div class="btn-group"> | 57 | <!--div class="btn-group"> |
---|
63 | <button onclick="handler.trigger();" class="btn btn-small">Mural</button> | 58 | <button onclick="handler.trigger();" class="btn btn-small">Mural</button> |
---|
| | | | 3 | <head> | 3 | <head> |
---|
4 | <meta charset="utf-8"> | 4 | <meta charset="utf-8"> |
---|
5 | <meta http-equiv='imagetoolbar' content='no'/> | 5 | <meta http-equiv='imagetoolbar' content='no'/> |
---|
6 | <title> Text Annotation </title> | | <title> Text Annotation </title> |
---|
| | 6 | <title> Web Annotation </title> | 7 | <link rel="stylesheet" type="text/css" href="static/bootstrap.css"></link> | 7 | <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> |
---|
8 | <script type="text/javascript" src="static/bootstrap.js"></script> | 9 | <script type="text/javascript" src="static/bootstrap.js"></script> |
---|
| | 10 | <style type="text/css"> |
---|
| | 11 | .container { |
---|
| | 12 | margin-top: 30px; |
---|
| | 13 | } |
---|
| | 14 | </style> |
---|
9 | </head> | 15 | </head> |
---|
10 | <body> | 16 | <body> |
---|
11 | <div class="fluid-container"> | | <div class="fluid-container"> |
---|
12 | <div class="explain lead"> Text annotation of Hampi related content using the IDH Mowl</div> | | <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> |
---|
13 | <div class="input span9"> | 19 | <div class="input span9"> |
---|
14 | Enter URL to annotate: <input id="url" type="text" placeholder="http://hampi.co.in"> | | 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"> | 15 | <button class="btn" onclick="loadURL();"> Load </button> | 21 | <button class="btn" onclick="loadURL();"> Load </button> |
---|
16 | </div> | 22 | </div> |
---|
17 | </div> | 23 | </div> |
---|
18 | <script> | 24 | <script> |
---|
19 | function loadURL() { | 25 | function loadURL() { |
---|
20 | var url = document.getElementById('url').value; | 26 | var url = document.getElementById('url').value; |
---|
| | 27 | if(!url) { |
---|
| | 28 | url = 'http://vijayanagara.in'; |
---|
| | 29 | } |
---|
21 | if(!url.match(/http/)) { | 30 | if(!url.match(/http/)) { |
---|
22 | url = 'http://' + url; | 31 | url = 'http://' + url; |
---|
23 | } | 32 | } |
---|