Commit 977fb6e3c633cd63606ac5b241dc7e65fa0619e8
1 parent
3d5def44
Exists in
master
Adicionado o Ranking e reorganização do projeto.
Showing
63 changed files
with
840 additions
and
245 deletions
Show diff stats
validador.py
@@ -35,7 +35,7 @@ class Validador: | @@ -35,7 +35,7 @@ class Validador: | ||
35 | def __update_project_info(self, project): | 35 | def __update_project_info(self, project): |
36 | template = self.env.get_template('template.html') | 36 | template = self.env.get_template('template.html') |
37 | project.info['task_presenter'] = template.render(server=self.config['HOST_STATIC_FILES_ENDPOINT'], server_backend=self.config['HOST_ENDPOINT'], app_shortname=self.config['PYBOSSA_APP_SHORT_NAME']) | 37 | project.info['task_presenter'] = template.render(server=self.config['HOST_STATIC_FILES_ENDPOINT'], server_backend=self.config['HOST_ENDPOINT'], app_shortname=self.config['PYBOSSA_APP_SHORT_NAME']) |
38 | - project.info['thumbnail'] = self.config['HOST_STATIC_FILES_ENDPOINT'] + "/img/thumbnail.png" | 38 | + project.info['thumbnail'] = self.config['HOST_STATIC_FILES_ENDPOINT'] + "/assets/img/thumbnail.png" |
39 | project.info['sched'] = "incremental" | 39 | project.info['sched'] = "incremental" |
40 | project.info['published'] = True | 40 | project.info['published'] = True |
41 | project.allow_anonymous_contributors = False | 41 | project.allow_anonymous_contributors = False |
@@ -98,7 +98,6 @@ class Validador: | @@ -98,7 +98,6 @@ class Validador: | ||
98 | task_id = request.form['task_id'] | 98 | task_id = request.form['task_id'] |
99 | project_id = request.form['project_id'] | 99 | project_id = request.form['project_id'] |
100 | sign_name = request.form['sign_name'] | 100 | sign_name = request.form['sign_name'] |
101 | - api_host = self.config['API_HOST'] | ||
102 | api_dbhost = self.config['API_DB_HOST'] | 101 | api_dbhost = self.config['API_DB_HOST'] |
103 | number_of_approval = int(request.form['number_of_approval']) | 102 | number_of_approval = int(request.form['number_of_approval']) |
104 | number_of_avatar_disapproval = int(request.form['number_of_avatar_disapproval']) | 103 | number_of_avatar_disapproval = int(request.form['number_of_avatar_disapproval']) |
view/assets/css/main.css
1 | +@import url("ranking.css"); | ||
2 | + | ||
1 | @font-face { | 3 | @font-face { |
2 | font-family: 'Titillium Web'; | 4 | font-family: 'Titillium Web'; |
3 | - src: url('../fonts/TitilliumWeb-SemiBold.ttf') format('truetype'); | 5 | + src: url('../fonts/titilliumweb/TitilliumWeb-SemiBold.ttf') |
6 | + format('truetype'); | ||
7 | +} | ||
8 | + | ||
9 | +#alert-container { | ||
10 | + padding: 0px; | ||
11 | +} | ||
12 | + | ||
13 | +#alert-container .alert-actions a { | ||
14 | + padding: 10px 15px 10px 0px; | ||
15 | +} | ||
16 | + | ||
17 | +#main-container { | ||
18 | + font-family: 'Titillium Web', sans-serif; | ||
19 | +} | ||
20 | + | ||
21 | +/* Navbar */ | ||
22 | +#validador-navbar { | ||
23 | + padding-top: 10px; | ||
24 | +} | ||
25 | + | ||
26 | +#validador-navbar .ranking-button { | ||
27 | + font-size: 20px; | ||
28 | + font-weight: bold; | ||
4 | } | 29 | } |
5 | 30 | ||
31 | +/* Validador */ | ||
6 | .video-body { | 32 | .video-body { |
7 | height: 338px; | 33 | height: 338px; |
8 | width: 85%; | 34 | width: 85%; |
@@ -19,39 +45,31 @@ | @@ -19,39 +45,31 @@ | ||
19 | margin-right: 0%; | 45 | margin-right: 0%; |
20 | } | 46 | } |
21 | 47 | ||
22 | -/* Sombras */ | ||
23 | .line-separator, .btn-default { | 48 | .line-separator, .btn-default { |
24 | box-shadow: 2px 2px 2px rgba(215, 217, 221, 1.0); | 49 | box-shadow: 2px 2px 2px rgba(215, 217, 221, 1.0); |
25 | -webkit-box-shadow: 2px 2px 2px rgba(215, 217, 221, 1.0); | 50 | -webkit-box-shadow: 2px 2px 2px rgba(215, 217, 221, 1.0); |
26 | -moz-box-shadow: 2px 2px 2px rgba(215, 217, 221, 1.0); | 51 | -moz-box-shadow: 2px 2px 2px rgba(215, 217, 221, 1.0); |
27 | } | 52 | } |
28 | 53 | ||
29 | -/* Fontes */ | ||
30 | -.btn-default, .finish-task-button, .radio-options span, h1, | ||
31 | - h2, h3, h4, h5, h6 { | ||
32 | - font-family: 'Titillium Web', sans-serif; | 54 | +#validador-header { |
55 | + padding-left: 15px; | ||
33 | } | 56 | } |
34 | 57 | ||
35 | -/* Header */ | ||
36 | -#validador-header { | ||
37 | - padding: 1px; | ||
38 | - background: rgba(255, 255, 255, 1.0); | 58 | +#validador-header .validador-question { |
59 | + margin-top: 0px; | ||
39 | } | 60 | } |
40 | 61 | ||
41 | -/* Body */ | ||
42 | .body-container { | 62 | .body-container { |
43 | background: rgba(236, 238, 242, 1.0); | 63 | background: rgba(236, 238, 242, 1.0); |
44 | - padding-bottom: 10px; | 64 | + padding: 0px 0px 10px 0px; |
45 | } | 65 | } |
46 | 66 | ||
47 | -/* Linha */ | ||
48 | .line-separator { | 67 | .line-separator { |
49 | height: 2px; | 68 | height: 2px; |
50 | width: 100%; | 69 | width: 100%; |
51 | background-color: rgba(145, 200, 206, 1.0); | 70 | background-color: rgba(145, 200, 206, 1.0); |
52 | } | 71 | } |
53 | 72 | ||
54 | -/* Texto */ | ||
55 | h1, h2, h3, h4, h5, h6 { | 73 | h1, h2, h3, h4, h5, h6 { |
56 | color: rgba(144, 164, 174, 1.0); | 74 | color: rgba(144, 164, 174, 1.0); |
57 | } | 75 | } |
@@ -74,7 +92,7 @@ h6 { | @@ -74,7 +92,7 @@ h6 { | ||
74 | } | 92 | } |
75 | 93 | ||
76 | #finish-task-container { | 94 | #finish-task-container { |
77 | - padding-right: 40px; | 95 | + padding-right: 15px; |
78 | } | 96 | } |
79 | 97 | ||
80 | .finish-padding-top { | 98 | .finish-padding-top { |
@@ -142,11 +160,11 @@ h6 { | @@ -142,11 +160,11 @@ h6 { | ||
142 | #loading-container { | 160 | #loading-container { |
143 | display: none; | 161 | display: none; |
144 | position: fixed; | 162 | position: fixed; |
145 | - top: 0; | ||
146 | - right: 0; | ||
147 | - bottom: 0; | ||
148 | - left: 0; | ||
149 | - z-index: 1040; | 163 | + top: 0; |
164 | + right: 0; | ||
165 | + bottom: 0; | ||
166 | + left: 0; | ||
167 | + z-index: 1040; | ||
150 | } | 168 | } |
151 | 169 | ||
152 | #loading-container img { | 170 | #loading-container img { |
@@ -0,0 +1,124 @@ | @@ -0,0 +1,124 @@ | ||
1 | +@font-face { | ||
2 | + font-family: 'Roboto'; | ||
3 | + src: url('../fonts/roboto/Roboto-Light.ttf') format('truetype'); | ||
4 | +} | ||
5 | + | ||
6 | +#ranking-container { | ||
7 | + display: none; | ||
8 | + background-color: #ffffff; | ||
9 | + border-radius: 5px; | ||
10 | + -moz-border-radius: 5px; | ||
11 | + -webkit-border-radius: 5px; | ||
12 | + padding-right: 0px; | ||
13 | + overflow: hidden; | ||
14 | + font-family: 'Roboto'; | ||
15 | + padding-left: 15px; | ||
16 | + margin: 10px 15px 5px 15px; | ||
17 | +} | ||
18 | + | ||
19 | +#ranking-info-container { | ||
20 | + padding-left: 0px; | ||
21 | +} | ||
22 | + | ||
23 | +#ranking-info-container .title { | ||
24 | + color: #000000; | ||
25 | + font-size: 50px; | ||
26 | +} | ||
27 | + | ||
28 | +#ranking-info-container .avatar-info { | ||
29 | + text-align: center; | ||
30 | + padding-top: 30px; | ||
31 | +} | ||
32 | + | ||
33 | +#ranking-info-container .avatar-container { | ||
34 | + display: none; | ||
35 | +} | ||
36 | + | ||
37 | +#ranking-info-container .avatar-info img { | ||
38 | + width: 100%; | ||
39 | +} | ||
40 | + | ||
41 | +#ranking-info-container .achievement-info { | ||
42 | + color: #028c12; | ||
43 | +} | ||
44 | + | ||
45 | +#ranking-info-container .progress-container { | ||
46 | + padding-left: 100px; | ||
47 | + margin-top: 10px; | ||
48 | +} | ||
49 | + | ||
50 | +#ranking-info-container .achievements-container { | ||
51 | + position: relative; | ||
52 | + padding: 10px 0px 0px 0px; | ||
53 | + word-wrap: break-word; | ||
54 | +} | ||
55 | + | ||
56 | +#ranking-info-container .progress-label { | ||
57 | + position: absolute; | ||
58 | + left: 0px; | ||
59 | +} | ||
60 | + | ||
61 | +#ranking-info-container .done-tasks { | ||
62 | + color: #84DC76; | ||
63 | +} | ||
64 | + | ||
65 | +#ranking-info-container .total-tasks { | ||
66 | + color: #f0ad4e; | ||
67 | +} | ||
68 | + | ||
69 | +#ranking-info-container .tooltip-inner { | ||
70 | + font-size: 16px; | ||
71 | + max-width: 220px; | ||
72 | +} | ||
73 | + | ||
74 | +#leaderboard-container { | ||
75 | + background-color: #fefcfc; | ||
76 | + padding: 0px; | ||
77 | + min-height: 560px; | ||
78 | +} | ||
79 | + | ||
80 | +#leaderboard-container table { | ||
81 | + margin-bottom: 0px; | ||
82 | +} | ||
83 | + | ||
84 | +#leaderboard-container .table-striped>tbody>tr:nth-of-type(odd) { | ||
85 | + background-color: #f1f2f2; | ||
86 | +} | ||
87 | + | ||
88 | +#leaderboard-container .table-striped>tbody>tr:hover { | ||
89 | + background-color: #e0e0e0; | ||
90 | +} | ||
91 | + | ||
92 | +#leaderboard-container .table-striped>tbody>tr.highlight { | ||
93 | + background-color: #fbefa3; | ||
94 | +} | ||
95 | + | ||
96 | +#leaderboard-container .table-striped>tbody>tr.highlight:hover { | ||
97 | + background-color: #f7e783; | ||
98 | +} | ||
99 | + | ||
100 | +#leaderboard-container th { | ||
101 | + text-align: center; | ||
102 | + border: 0px; | ||
103 | + padding-bottom: 15px; | ||
104 | +} | ||
105 | + | ||
106 | +#leaderboard-container td { | ||
107 | + text-align: center; | ||
108 | + border: 0px; | ||
109 | +} | ||
110 | + | ||
111 | +#leaderboard-container td:nth-of-type(1), #leaderboard-container td:nth-of-type(2) | ||
112 | + { | ||
113 | + width: 75px; | ||
114 | +} | ||
115 | + | ||
116 | +#leaderboard-container td:nth-of-type(2), #leaderboard-container th:nth-of-type(2), | ||
117 | + #leaderboard-container td:nth-of-type(3), #leaderboard-container th:nth-of-type(3) | ||
118 | + { | ||
119 | + text-align: left; | ||
120 | +} | ||
121 | + | ||
122 | +#leaderboard-container th:nth-of-type(3) img { | ||
123 | + padding-left: 20px; | ||
124 | +} | ||
0 | \ No newline at end of file | 125 | \ No newline at end of file |
view/assets/fonts/Helvetica.otf
No preview for this file type
view/assets/fonts/TitilliumWeb-Black.ttf
No preview for this file type
view/assets/fonts/TitilliumWeb-Bold.ttf
No preview for this file type
view/assets/fonts/TitilliumWeb-BoldItalic.ttf
No preview for this file type
view/assets/fonts/TitilliumWeb-ExtraLight.ttf
No preview for this file type
view/assets/fonts/TitilliumWeb-ExtraLightItalic.ttf
No preview for this file type
view/assets/fonts/TitilliumWeb-Italic.ttf
No preview for this file type
view/assets/fonts/TitilliumWeb-Light.ttf
No preview for this file type
view/assets/fonts/TitilliumWeb-LightItalic.ttf
No preview for this file type
view/assets/fonts/TitilliumWeb-Regular.ttf
No preview for this file type
view/assets/fonts/TitilliumWeb-SemiBold.ttf
No preview for this file type
view/assets/fonts/TitilliumWeb-SemiBoldItalic.ttf
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
4.98 KB
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | ||
3 | +<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="100px" height="100px" version="1.1" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd" | ||
4 | +viewBox="0 0 100 100" | ||
5 | + xmlns:xlink="http://www.w3.org/1999/xlink"> | ||
6 | + <defs> | ||
7 | + <style type="text/css"> | ||
8 | + <![CDATA[ | ||
9 | + .fil0 {fill:#5EC7BD;fill-rule:nonzero} | ||
10 | + ]]> | ||
11 | + </style> | ||
12 | + </defs> | ||
13 | + <g id="finish"> | ||
14 | + <metadata id="finish"/> | ||
15 | + <path class="fil0" d="M44 79c-4,4 -10,4 -13,0l-20 -20c-2,-2 -3,-4 -3,-6 0,-3 1,-5 3,-7 3,-3 9,-3 13,0l12 12c0,1 2,1 3,0l37 -37c2,-2 5,-3 7,-3l0 0c2,0 5,1 6,3 2,1 3,4 3,6 0,3 -1,5 -3,7l-45 45z"/> | ||
16 | + </g> | ||
17 | +</svg> |
4.88 KB
78 KB
343 Bytes
338 Bytes
2.07 KB
337 Bytes
1.36 KB
4.08 KB
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | ||
3 | +<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="100px" height="100px" version="1.1" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd" | ||
4 | +viewBox="0 0 100 100" | ||
5 | + xmlns:xlink="http://www.w3.org/1999/xlink"> | ||
6 | + <defs> | ||
7 | + <style type="text/css"> | ||
8 | + <![CDATA[ | ||
9 | + .fil0 {fill:#5EC7BD;fill-rule:nonzero} | ||
10 | + ]]> | ||
11 | + </style> | ||
12 | + </defs> | ||
13 | + <g id="skip"> | ||
14 | + <metadata id="skip"/> | ||
15 | + <path class="fil0" d="M10 24c1,-1 23,-17 45,0 8,6 12,15 13,26l22 0 -34 34 -34 -34 22 0c0,-1 1,-3 1,-4 -2,-29 -19,-26 -35,-22z"/> | ||
16 | + </g> | ||
17 | +</svg> |
34.6 KB
@@ -0,0 +1,145 @@ | @@ -0,0 +1,145 @@ | ||
1 | +/*! | ||
2 | + * JavaScript Cookie v2.0.4 | ||
3 | + * https://github.com/js-cookie/js-cookie | ||
4 | + * | ||
5 | + * Copyright 2006, 2015 Klaus Hartl & Fagner Brack | ||
6 | + * Released under the MIT license | ||
7 | + */ | ||
8 | +(function (factory) { | ||
9 | + if (typeof define === 'function' && define.amd) { | ||
10 | + define(factory); | ||
11 | + } else if (typeof exports === 'object') { | ||
12 | + module.exports = factory(); | ||
13 | + } else { | ||
14 | + var _OldCookies = window.Cookies; | ||
15 | + var api = window.Cookies = factory(); | ||
16 | + api.noConflict = function () { | ||
17 | + window.Cookies = _OldCookies; | ||
18 | + return api; | ||
19 | + }; | ||
20 | + } | ||
21 | +}(function () { | ||
22 | + function extend () { | ||
23 | + var i = 0; | ||
24 | + var result = {}; | ||
25 | + for (; i < arguments.length; i++) { | ||
26 | + var attributes = arguments[ i ]; | ||
27 | + for (var key in attributes) { | ||
28 | + result[key] = attributes[key]; | ||
29 | + } | ||
30 | + } | ||
31 | + return result; | ||
32 | + } | ||
33 | + | ||
34 | + function init (converter) { | ||
35 | + function api (key, value, attributes) { | ||
36 | + var result; | ||
37 | + | ||
38 | + // Write | ||
39 | + | ||
40 | + if (arguments.length > 1) { | ||
41 | + attributes = extend({ | ||
42 | + path: '/' | ||
43 | + }, api.defaults, attributes); | ||
44 | + | ||
45 | + if (typeof attributes.expires === 'number') { | ||
46 | + var expires = new Date(); | ||
47 | + expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5); | ||
48 | + attributes.expires = expires; | ||
49 | + } | ||
50 | + | ||
51 | + try { | ||
52 | + result = JSON.stringify(value); | ||
53 | + if (/^[\{\[]/.test(result)) { | ||
54 | + value = result; | ||
55 | + } | ||
56 | + } catch (e) {} | ||
57 | + | ||
58 | + if (!converter.write) { | ||
59 | + value = encodeURIComponent(String(value)) | ||
60 | + .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent); | ||
61 | + } else { | ||
62 | + value = converter.write(value, key); | ||
63 | + } | ||
64 | + | ||
65 | + key = encodeURIComponent(String(key)); | ||
66 | + key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent); | ||
67 | + key = key.replace(/[\(\)]/g, escape); | ||
68 | + | ||
69 | + return (document.cookie = [ | ||
70 | + key, '=', value, | ||
71 | + attributes.expires && '; expires=' + attributes.expires.toUTCString(), // use expires attribute, max-age is not supported by IE | ||
72 | + attributes.path && '; path=' + attributes.path, | ||
73 | + attributes.domain && '; domain=' + attributes.domain, | ||
74 | + attributes.secure ? '; secure' : '' | ||
75 | + ].join('')); | ||
76 | + } | ||
77 | + | ||
78 | + // Read | ||
79 | + | ||
80 | + if (!key) { | ||
81 | + result = {}; | ||
82 | + } | ||
83 | + | ||
84 | + // To prevent the for loop in the first place assign an empty array | ||
85 | + // in case there are no cookies at all. Also prevents odd result when | ||
86 | + // calling "get()" | ||
87 | + var cookies = document.cookie ? document.cookie.split('; ') : []; | ||
88 | + var rdecode = /(%[0-9A-Z]{2})+/g; | ||
89 | + var i = 0; | ||
90 | + | ||
91 | + for (; i < cookies.length; i++) { | ||
92 | + var parts = cookies[i].split('='); | ||
93 | + var name = parts[0].replace(rdecode, decodeURIComponent); | ||
94 | + var cookie = parts.slice(1).join('='); | ||
95 | + | ||
96 | + if (cookie.charAt(0) === '"') { | ||
97 | + cookie = cookie.slice(1, -1); | ||
98 | + } | ||
99 | + | ||
100 | + try { | ||
101 | + cookie = converter.read ? | ||
102 | + converter.read(cookie, name) : converter(cookie, name) || | ||
103 | + cookie.replace(rdecode, decodeURIComponent); | ||
104 | + | ||
105 | + if (this.json) { | ||
106 | + try { | ||
107 | + cookie = JSON.parse(cookie); | ||
108 | + } catch (e) {} | ||
109 | + } | ||
110 | + | ||
111 | + if (key === name) { | ||
112 | + result = cookie; | ||
113 | + break; | ||
114 | + } | ||
115 | + | ||
116 | + if (!key) { | ||
117 | + result[name] = cookie; | ||
118 | + } | ||
119 | + } catch (e) {} | ||
120 | + } | ||
121 | + | ||
122 | + return result; | ||
123 | + } | ||
124 | + | ||
125 | + api.get = api.set = api; | ||
126 | + api.getJSON = function () { | ||
127 | + return api.apply({ | ||
128 | + json: true | ||
129 | + }, [].slice.call(arguments)); | ||
130 | + }; | ||
131 | + api.defaults = {}; | ||
132 | + | ||
133 | + api.remove = function (key, attributes) { | ||
134 | + api(key, '', extend(attributes, { | ||
135 | + expires: -1 | ||
136 | + })); | ||
137 | + }; | ||
138 | + | ||
139 | + api.withConverter = init; | ||
140 | + | ||
141 | + return api; | ||
142 | + } | ||
143 | + | ||
144 | + return init(function () {}); | ||
145 | +})); |
@@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||
1 | +(function(loadHtmlHelper, $, undefined) { | ||
2 | + | ||
3 | + var baseUrl = ''; | ||
4 | + | ||
5 | + function _preprocessHtml(data) { | ||
6 | + return data.replace(/{{ server }}/g, baseUrl); | ||
7 | + } | ||
8 | + | ||
9 | + loadHtmlHelper.load = function(target, url, callback) { | ||
10 | + var completeUrl = baseUrl + url; | ||
11 | + $.get(completeUrl, function(data) { | ||
12 | + $(target).html(_preprocessHtml(data)); | ||
13 | + callback && callback(); | ||
14 | + }); | ||
15 | + } | ||
16 | + | ||
17 | + loadHtmlHelper.setup = function(url) { | ||
18 | + baseUrl = url; | ||
19 | + }; | ||
20 | + | ||
21 | +}(window.loadHtmlHelper = window.loadHtmlHelper || {}, jQuery)); |
@@ -0,0 +1,44 @@ | @@ -0,0 +1,44 @@ | ||
1 | +(function(pybossaApiHelper, $, undefined) { | ||
2 | + | ||
3 | + var pybossaEndpoint = ''; | ||
4 | + var projectName = ''; | ||
5 | + | ||
6 | + function _getProjectId() { | ||
7 | + return $.ajax({ | ||
8 | + url : pybossaEndpoint + '/api/project?short_name=' + projectName | ||
9 | + }); | ||
10 | + } | ||
11 | + | ||
12 | + function _getUserProgress() { | ||
13 | + return $.ajax({ | ||
14 | + url : pybossaEndpoint + '/api/project/' + projectName + '/userprogress', | ||
15 | + cache : false, | ||
16 | + dataType : 'json' | ||
17 | + }); | ||
18 | + } | ||
19 | + | ||
20 | + function _getAnswers(projectId, userId) { | ||
21 | + return $.ajax({ | ||
22 | + url : pybossaEndpoint + '/api/taskrun?project_id=' + projectId | ||
23 | + + '&user_id=' + userId | ||
24 | + }); | ||
25 | + } | ||
26 | + | ||
27 | + pybossaApiHelper.setup = function(endpoint, name) { | ||
28 | + pybossaEndpoint = endpoint; | ||
29 | + projectName = name; | ||
30 | + } | ||
31 | + | ||
32 | + pybossaApiHelper.getProjectId = function() { | ||
33 | + return _getProjectId(); | ||
34 | + } | ||
35 | + | ||
36 | + pybossaApiHelper.getUserProgress = function() { | ||
37 | + return _getUserProgress(); | ||
38 | + } | ||
39 | + | ||
40 | + pybossaApiHelper.getAnswers = function(projectId, userId) { | ||
41 | + return _getAnswers(projectId, userId); | ||
42 | + } | ||
43 | + | ||
44 | +}(window.pybossaApiHelper = window.pybossaApiHelper || {}, jQuery)); |
@@ -0,0 +1,163 @@ | @@ -0,0 +1,163 @@ | ||
1 | +(function(ranking, $, undefined) { | ||
2 | + | ||
3 | + var NUMBER_OF_TOP_USERS = 10; | ||
4 | + var STARS_MAP = ['', 'gold', 'silver', 'bronze']; | ||
5 | + var baseUrl = ''; | ||
6 | + var pybossaEndpoint = ''; | ||
7 | + var projectName = ''; | ||
8 | + var loggedUser = {}; | ||
9 | + var totalTasks = 0; | ||
10 | + var doneTasks = 0; | ||
11 | + var showingRanking = false; | ||
12 | + var tasksEnded = false; | ||
13 | + | ||
14 | + function _getRankingData(callback) { | ||
15 | + $.ajax({ | ||
16 | + url : pybossaEndpoint + '/api/leaderboard?limit=' | ||
17 | + + NUMBER_OF_TOP_USERS, | ||
18 | + success : function(response) { | ||
19 | + callback(typeof response == 'object' ? response[projectName] | ||
20 | + : ''); | ||
21 | + }, | ||
22 | + error : function(xhr, textStatus, error) { | ||
23 | + alert(xhr.responseText); | ||
24 | + } | ||
25 | + }); | ||
26 | + } | ||
27 | + | ||
28 | + function _processRankingRow(rowData) { | ||
29 | + var rank = rowData.rank; | ||
30 | + if (rank < 0) { | ||
31 | + return ''; | ||
32 | + } | ||
33 | + var starHTML = ''; | ||
34 | + if (rank > 0 && rank < 4) { | ||
35 | + starHTML = '<img src="' + baseUrl + '/assets/img/ranking/' | ||
36 | + + STARS_MAP[rank] + '-star-icon.png">'; | ||
37 | + } | ||
38 | + var trHTML = '<tr>'; | ||
39 | + if (rowData.name === loggedUser.name) { | ||
40 | + trHTML = '<tr class="warning">'; | ||
41 | + loggedUser.rank = rowData.rank; | ||
42 | + } | ||
43 | + rank = rank == 0 ? '-' : rank + '.'; | ||
44 | + return trHTML + '<td>' + starHTML + '</td><td>' + rank | ||
45 | + + '</td><td><a href="/pybossa/account/' + rowData.name | ||
46 | + + '/" target="_blank">' + rowData.fullname + '</a></td><td>' | ||
47 | + + rowData.score + '</td></tr>'; | ||
48 | + } | ||
49 | + | ||
50 | + function _updateRanking() { | ||
51 | + _getRankingData(function(data) { | ||
52 | + if (data === '') | ||
53 | + return; | ||
54 | + | ||
55 | + var rowsHTML = ''; | ||
56 | + for (var i = 0; i < data.length; i++) { | ||
57 | + rowsHTML += _processRankingRow(data[i]); | ||
58 | + } | ||
59 | + $('#leaderboard-container tbody').html(rowsHTML); | ||
60 | + $('#ranking-info-container .rank-position').html(loggedUser.rank); | ||
61 | + $('#ranking-info-container .username').html(loggedUser.fullName); | ||
62 | + if (loggedUser.avatarUrl != '') { | ||
63 | + $('#ranking-info-container .avatar-container img').attr('src', | ||
64 | + loggedUser.avatarUrl); | ||
65 | + $('#ranking-info-container .avatar-placeholder').hide(); | ||
66 | + $('#ranking-info-container .avatar-container').show(); | ||
67 | + } | ||
68 | + if (loggedUser.rank === 0) { | ||
69 | + $('#ranking-info-container .rank-position-container').hide(); | ||
70 | + } | ||
71 | + _updateProgress(); | ||
72 | + }); | ||
73 | + } | ||
74 | + | ||
75 | + function _getUserData() { | ||
76 | + return $.ajax({ | ||
77 | + url : pybossaEndpoint + '/api/user?name=' + loggedUser.name | ||
78 | + }); | ||
79 | + } | ||
80 | + | ||
81 | + function _getAvatarUrl(data) { | ||
82 | + return !data || typeof data.avatar === 'undefined' || typeof data.container === 'undefined' ? | ||
83 | + '' : pybossaEndpoint + '/uploads/' + data.container + '/' + data.avatar; | ||
84 | + } | ||
85 | + | ||
86 | + function _updateProgress() { | ||
87 | + pybossaApiHelper | ||
88 | + .getUserProgress() | ||
89 | + .done( | ||
90 | + function(response) { | ||
91 | + totalTasks = response.total; | ||
92 | + doneTasks = response.done; | ||
93 | + var percentage = (doneTasks / totalTasks) * 100; | ||
94 | + $('#ranking-info-container .progress-bar').attr( | ||
95 | + 'aria-valuenow', percentage).css('width', | ||
96 | + percentage + '%'); | ||
97 | + $('#ranking-container [data-toggle="tooltip"]') | ||
98 | + .tooltip( | ||
99 | + { | ||
100 | + title : '<strong><span class="done-tasks">' | ||
101 | + + doneTasks | ||
102 | + + '</span> / <span class="total-tasks">' | ||
103 | + + totalTasks | ||
104 | + + '</span> sinais ensinados.</strong>', | ||
105 | + placement : 'bottom', | ||
106 | + trigger : 'manual' | ||
107 | + }); | ||
108 | + }); | ||
109 | + } | ||
110 | + | ||
111 | + function _loadRankingData() { | ||
112 | + _getUserData().done(function(response) { | ||
113 | + if (typeof response == 'undefined' || response.length < 1) { | ||
114 | + return; | ||
115 | + } | ||
116 | + loggedUser.fullName = response[0].fullname; | ||
117 | + loggedUser.avatarUrl = _getAvatarUrl(response[0].info); | ||
118 | + _updateRanking(); | ||
119 | + }); | ||
120 | + } | ||
121 | + | ||
122 | + function _showRanking() { | ||
123 | + $('#validador-container').hide(); | ||
124 | + $('#ranking-container').show(); | ||
125 | + $('#validador-navbar .ranking-button').html("Voltar"); | ||
126 | + if (doneTasks > 0) { | ||
127 | + $('#ranking-container [data-toggle="tooltip"]').tooltip('show'); | ||
128 | + } | ||
129 | + showingRanking = true; | ||
130 | + } | ||
131 | + | ||
132 | + function _hideRanking() { | ||
133 | + $('#ranking-container').hide(); | ||
134 | + $('#validador-navbar .ranking-button').html("Ver Ranking"); | ||
135 | + showingRanking = false; | ||
136 | + | ||
137 | + if (!tasksEnded) { | ||
138 | + $('#validador-container').show(); | ||
139 | + } | ||
140 | + } | ||
141 | + | ||
142 | + ranking.toggle = function() { | ||
143 | + if (showingRanking) { | ||
144 | + _hideRanking(); | ||
145 | + } else { | ||
146 | + _showRanking(); | ||
147 | + } | ||
148 | + }; | ||
149 | + | ||
150 | + ranking.tasksEnded = function() { | ||
151 | + tasksEnded = true; | ||
152 | + }; | ||
153 | + | ||
154 | + ranking.setup = function(serverUrl, endpoint, name, user) { | ||
155 | + baseUrl = serverUrl; | ||
156 | + pybossaEndpoint = endpoint; | ||
157 | + projectName = name; | ||
158 | + loggedUser.name = user; | ||
159 | + loadHtmlHelper.load('#ranking-container', '/assets/templates/ranking/ranking.html', | ||
160 | + _loadRankingData); | ||
161 | + }; | ||
162 | + | ||
163 | +}(window.ranking = window.ranking || {}, jQuery)); |
view/assets/js/validador.js
1 | (function(validador, $, undefined) { | 1 | (function(validador, $, undefined) { |
2 | 2 | ||
3 | - var videos_url = ""; | ||
4 | - var base_url = ""; | ||
5 | - var server_backend_url = ''; | ||
6 | - var current_task_id = -1; | 3 | + var baseUrl = ''; |
4 | + var serverBackendUrl = ''; | ||
5 | + var videosUrl = ''; | ||
6 | + var pybossaEndpoint = ''; | ||
7 | + var projectName = ''; | ||
8 | + var currentTaskId = -1; | ||
9 | + | ||
10 | + function _getLoggedUser() { | ||
11 | + var pybossaRememberToken = Cookies.get('remember_token'); | ||
12 | + var splittedTokenId = pybossaRememberToken.split('|'); | ||
13 | + return splittedTokenId.length > 0 ? splittedTokenId[0] : 'anonymous'; | ||
14 | + } | ||
7 | 15 | ||
8 | function _disableFinishButton() { | 16 | function _disableFinishButton() { |
9 | - $("#finish-button").off("click"); | ||
10 | - $("#finish-button").removeClass("enabled-button"); | ||
11 | - $("#finish-button").addClass("disabled-button"); | 17 | + $('#finish-button').off('click'); |
18 | + $('#finish-button').removeClass('enabled-button'); | ||
19 | + $('#finish-button').addClass('disabled-button'); | ||
12 | } | 20 | } |
13 | 21 | ||
14 | function _enableFinishButton(task, deferred) { | 22 | function _enableFinishButton(task, deferred) { |
15 | - $("#finish-button").removeClass("disabled-button"); | ||
16 | - $("#finish-button").addClass("enabled-button"); | ||
17 | - $("#finish-button").off("click").on("click", function() { | 23 | + $('#finish-button').removeClass('disabled-button'); |
24 | + $('#finish-button').addClass('enabled-button'); | ||
25 | + $('#finish-button').off('click').on('click', function() { | ||
18 | _readAnswer(task, deferred, false); | 26 | _readAnswer(task, deferred, false); |
19 | }); | 27 | }); |
20 | } | 28 | } |
21 | 29 | ||
22 | function _hideCommentAvatar() { | 30 | function _hideCommentAvatar() { |
23 | - $("#comment-avatar").hide(); | ||
24 | - $("#finish-task-container").removeClass("finish-padding-top-adjust"); | 31 | + $('#comment-avatar').hide(); |
32 | + $('#finish-task-container').removeClass('finish-padding-top-adjust'); | ||
25 | } | 33 | } |
26 | 34 | ||
27 | function _hideCommentRef() { | 35 | function _hideCommentRef() { |
28 | - $("#comment-ref").hide(); | 36 | + $('#comment-ref').hide(); |
29 | } | 37 | } |
30 | 38 | ||
31 | function resetComments() { | 39 | function resetComments() { |
32 | - $("#comment-avatar textarea").val("") | ||
33 | - $("#comment-ref textarea").val(""); | 40 | + $('#comment-avatar textarea').val('') |
41 | + $('#comment-ref textarea').val(''); | ||
34 | _hideCommentAvatar(); | 42 | _hideCommentAvatar(); |
35 | _hideCommentRef(); | 43 | _hideCommentRef(); |
36 | } | 44 | } |
37 | 45 | ||
38 | function _enableLoading() { | 46 | function _enableLoading() { |
39 | - $("#loading-container").show(); | ||
40 | - $("#main-container").addClass("mask"); | 47 | + $('#loading-container').show(); |
48 | + $('#main-container').addClass('mask'); | ||
41 | } | 49 | } |
42 | 50 | ||
43 | function _disableLoading() { | 51 | function _disableLoading() { |
44 | - $("#loading-container").hide(); | ||
45 | - $("#main-container").removeClass("mask"); | 52 | + $('#loading-container').hide(); |
53 | + $('#main-container').removeClass('mask'); | ||
46 | } | 54 | } |
47 | 55 | ||
48 | function _handleAvatarRadioClick(el, task, deferred) { | 56 | function _handleAvatarRadioClick(el, task, deferred) { |
49 | - var is_incorrect_button = $(el).val() == "INCORRECT"; | ||
50 | - if (is_incorrect_button) { | 57 | + var isIncorrectButton = $(el).val() == 'INCORRECT'; |
58 | + if (isIncorrectButton) { | ||
51 | _hideCommentRef(); | 59 | _hideCommentRef(); |
52 | - $("#comment-avatar").show(); | ||
53 | - $("#finish-task-container").addClass("finish-padding-top-adjust"); | 60 | + $('#comment-avatar').show(); |
61 | + $('#finish-task-container').addClass('finish-padding-top-adjust'); | ||
54 | } else { | 62 | } else { |
55 | _hideCommentAvatar(); | 63 | _hideCommentAvatar(); |
56 | } | 64 | } |
57 | - var isRefChecked = $("#ref-radio-answers input[type=radio]").is( | ||
58 | - ":checked"); | 65 | + var isRefChecked = $('#ref-radio-answers input[type=radio]').is( |
66 | + ':checked'); | ||
59 | if (isRefChecked) { | 67 | if (isRefChecked) { |
60 | _enableFinishButton(task, deferred); | 68 | _enableFinishButton(task, deferred); |
61 | } else { | 69 | } else { |
@@ -64,23 +72,24 @@ | @@ -64,23 +72,24 @@ | ||
64 | } | 72 | } |
65 | 73 | ||
66 | function _handleRefRadioClick(el, task, deferred) { | 74 | function _handleRefRadioClick(el, task, deferred) { |
67 | - var is_incorrect_button = $(el).val() == "INCORRECT"; | ||
68 | - if (is_incorrect_button) { | ||
69 | - $("#incorrect-avatar-button").prop("checked", true); | ||
70 | - $("#comment-ref").show(); | 75 | + var isIncorrectButton = $(el).val() == 'INCORRECT'; |
76 | + if (isIncorrectButton) { | ||
77 | + $('#incorrect-avatar-button').prop('checked', true); | ||
78 | + $('#comment-ref').show(); | ||
71 | _hideCommentAvatar(); | 79 | _hideCommentAvatar(); |
72 | } else { | 80 | } else { |
73 | - var is_avatar_disabled = $("#avatar-radio-answers input[type=radio]").is(":disabled"); | ||
74 | - if (is_avatar_disabled) { | ||
75 | - $("#incorrect-avatar-button").prop("checked", false); | 81 | + var isAvatarDisabled = $('#avatar-radio-answers input[type=radio]') |
82 | + .is(':disabled'); | ||
83 | + if (isAvatarDisabled) { | ||
84 | + $('#incorrect-avatar-button').prop('checked', false); | ||
76 | } | 85 | } |
77 | _hideCommentRef(); | 86 | _hideCommentRef(); |
78 | } | 87 | } |
79 | - $("#avatar-radio-answers input[type=radio]").prop("disabled", | ||
80 | - is_incorrect_button); | ||
81 | - var is_avatar_checked = $("#avatar-radio-answers input[type=radio]").is( | ||
82 | - ":checked"); | ||
83 | - if (is_avatar_checked) { | 88 | + $('#avatar-radio-answers input[type=radio]').prop('disabled', |
89 | + isIncorrectButton); | ||
90 | + var isAvatarChecked = $('#avatar-radio-answers input[type=radio]').is( | ||
91 | + ':checked'); | ||
92 | + if (isAvatarChecked) { | ||
84 | _enableFinishButton(task, deferred); | 93 | _enableFinishButton(task, deferred); |
85 | } else { | 94 | } else { |
86 | _disableFinishButton(); | 95 | _disableFinishButton(); |
@@ -90,69 +99,68 @@ | @@ -90,69 +99,68 @@ | ||
90 | function _setupGUI(task, deferred) { | 99 | function _setupGUI(task, deferred) { |
91 | resetComments(); | 100 | resetComments(); |
92 | _disableFinishButton(); | 101 | _disableFinishButton(); |
93 | - $("#avatar-radio-answers input[type=radio]").prop("disabled", false); | ||
94 | - $("#avatar-radio-answers input[type=radio]").prop("checked", false); | ||
95 | - $("#ref-radio-answers input[type=radio]").prop("checked", false); | ||
96 | - $("#avatar-radio-answers input[type=radio]").off("click").on("click", | 102 | + $('#avatar-radio-answers input[type=radio]').prop('disabled', false); |
103 | + $('#avatar-radio-answers input[type=radio]').prop('checked', false); | ||
104 | + $('#ref-radio-answers input[type=radio]').prop('checked', false); | ||
105 | + $('#avatar-radio-answers input[type=radio]').off('click').on('click', | ||
97 | function() { | 106 | function() { |
98 | _handleAvatarRadioClick(this, task, deferred); | 107 | _handleAvatarRadioClick(this, task, deferred); |
99 | }); | 108 | }); |
100 | - $("#ref-radio-answers input[type=radio]").off("click").on("click", | 109 | + $('#ref-radio-answers input[type=radio]').off('click').on('click', |
101 | function() { | 110 | function() { |
102 | _handleRefRadioClick(this, task, deferred); | 111 | _handleRefRadioClick(this, task, deferred); |
103 | }); | 112 | }); |
104 | - $("#skip-button").off("click").on("click", function() { | 113 | + $('#skip-button').off('click').on('click', function() { |
105 | _readAnswer(task, deferred, true); | 114 | _readAnswer(task, deferred, true); |
106 | }); | 115 | }); |
107 | } | 116 | } |
108 | 117 | ||
109 | - function _readAnswer(task, deferred, has_skipped) { | ||
110 | - var status = ""; | ||
111 | - var avatar_answer = $("#avatar-radio-answers input[type=radio]:checked") | ||
112 | - .val(); | ||
113 | - var ref_answer = $("#ref-radio-answers input[type=radio]:checked") | 118 | + function _readAnswer(task, deferred, hasSkipped) { |
119 | + var status = ''; | ||
120 | + var avatarAnswer = $('#avatar-radio-answers input[type=radio]:checked') | ||
114 | .val(); | 121 | .val(); |
115 | - if (has_skipped) { | ||
116 | - status = "SKIPPED"; | ||
117 | - } else if (ref_answer == "INCORRECT") { | ||
118 | - status = "REF_DISAPPROVED"; | ||
119 | - } else if (avatar_answer == "INCORRECT") { | ||
120 | - status = "AVATAR_DISAPPROVED"; | 122 | + var refAnswer = $('#ref-radio-answers input[type=radio]:checked').val(); |
123 | + if (hasSkipped) { | ||
124 | + status = 'SKIPPED'; | ||
125 | + } else if (refAnswer == 'INCORRECT') { | ||
126 | + status = 'REF_DISAPPROVED'; | ||
127 | + } else if (avatarAnswer == 'INCORRECT') { | ||
128 | + status = 'AVATAR_DISAPPROVED'; | ||
121 | } else { | 129 | } else { |
122 | - status = "AVATAR_APPROVED"; | 130 | + status = 'AVATAR_APPROVED'; |
123 | } | 131 | } |
124 | - _submitAnswer(task, deferred, status, has_skipped); | 132 | + _submitAnswer(task, deferred, status, hasSkipped); |
125 | } | 133 | } |
126 | 134 | ||
127 | function _createAnswer(task, status) { | 135 | function _createAnswer(task, status) { |
128 | var answer = {}; | 136 | var answer = {}; |
129 | - var last_answer = task.info.last_answer; | ||
130 | - var hasLastAnswer = typeof last_answer != "undefined"; | 137 | + var lastAnswer = task.info.last_answer; |
138 | + var hasLastAnswer = typeof lastAnswer != 'undefined'; | ||
131 | if (hasLastAnswer) { | 139 | if (hasLastAnswer) { |
132 | - answer = last_answer; | 140 | + answer = lastAnswer; |
133 | } else { | 141 | } else { |
134 | answer = { | 142 | answer = { |
135 | - "number_of_approval" : 0, | ||
136 | - "number_of_avatar_disapproval" : 0, | ||
137 | - "number_of_ref_disapproval" : 0 | 143 | + 'number_of_approval' : 0, |
144 | + 'number_of_avatar_disapproval' : 0, | ||
145 | + 'number_of_ref_disapproval' : 0 | ||
138 | }; | 146 | }; |
139 | } | 147 | } |
140 | - answer["status"] = status; | ||
141 | - answer["comment_avatar"] = ""; | ||
142 | - answer["comment_ref"] = ""; | ||
143 | - if (status == "AVATAR_APPROVED") { | ||
144 | - answer["number_of_approval"] = answer.number_of_approval + 1; | ||
145 | - } else if (status == "AVATAR_DISAPPROVED") { | ||
146 | - answer["number_of_avatar_disapproval"] = answer.number_of_avatar_disapproval + 1; | ||
147 | - var comment_avatar = $("#comment-avatar textarea").val(); | ||
148 | - if (comment_avatar.trim() != "") { | ||
149 | - answer["comment_avatar"] = comment_avatar; | 148 | + answer['status'] = status; |
149 | + answer['comment_avatar'] = ''; | ||
150 | + answer['comment_ref'] = ''; | ||
151 | + if (status == 'AVATAR_APPROVED') { | ||
152 | + answer['number_of_approval'] = answer.number_of_approval + 1; | ||
153 | + } else if (status == 'AVATAR_DISAPPROVED') { | ||
154 | + answer['number_of_avatar_disapproval'] = answer.number_of_avatar_disapproval + 1; | ||
155 | + var commentAvatar = $('#comment-avatar textarea').val(); | ||
156 | + if (commentAvatar.trim() != '') { | ||
157 | + answer['comment_avatar'] = commentAvatar; | ||
150 | } | 158 | } |
151 | - } else if (status == "REF_DISAPPROVED") { | ||
152 | - answer["number_of_ref_disapproval"] = answer.number_of_ref_disapproval + 1; | ||
153 | - var comment_ref = $("#comment-ref textarea").val(); | ||
154 | - if (comment_ref.trim() != "") { | ||
155 | - answer["comment_ref"] = comment_ref; | 159 | + } else if (status == 'REF_DISAPPROVED') { |
160 | + answer['number_of_ref_disapproval'] = answer.number_of_ref_disapproval + 1; | ||
161 | + var comment_ref = $('#comment-ref textarea').val(); | ||
162 | + if (comment_ref.trim() != '') { | ||
163 | + answer['comment_ref'] = comment_ref; | ||
156 | } | 164 | } |
157 | } | 165 | } |
158 | return answer; | 166 | return answer; |
@@ -162,21 +170,21 @@ | @@ -162,21 +170,21 @@ | ||
162 | _enableLoading(); | 170 | _enableLoading(); |
163 | $ | 171 | $ |
164 | .ajax({ | 172 | .ajax({ |
165 | - type : "POST", | ||
166 | - url : server_backend_url + "/finish_task", | 173 | + type : 'POST', |
174 | + url : serverBackendUrl + '/finish_task', | ||
167 | data : { | 175 | data : { |
168 | - "task_id" : task.id, | ||
169 | - "project_id" : task.project_id, | ||
170 | - "sign_name" : task.info.sign_name, | ||
171 | - "number_of_approval" : answer.number_of_approval, | ||
172 | - "number_of_avatar_disapproval" : answer.number_of_avatar_disapproval, | ||
173 | - "number_of_ref_disapproval" : answer.number_of_ref_disapproval | 176 | + 'task_id' : task.id, |
177 | + 'project_id' : task.project_id, | ||
178 | + 'sign_name' : task.info.sign_name, | ||
179 | + 'number_of_approval' : answer.number_of_approval, | ||
180 | + 'number_of_avatar_disapproval' : answer.number_of_avatar_disapproval, | ||
181 | + 'number_of_ref_disapproval' : answer.number_of_ref_disapproval | ||
174 | }, | 182 | }, |
175 | success : function(response) { | 183 | success : function(response) { |
176 | pybossa.saveTask(task.id, answer).done(function() { | 184 | pybossa.saveTask(task.id, answer).done(function() { |
177 | _disableLoading(); | 185 | _disableLoading(); |
178 | - $("#success").fadeIn(500); | ||
179 | - $("#main-container").hide(); | 186 | + $('#success').fadeIn(500); |
187 | + $('#validador-container').hide(); | ||
180 | setTimeout(function() { | 188 | setTimeout(function() { |
181 | deferred.resolve(); | 189 | deferred.resolve(); |
182 | }, 2000); | 190 | }, 2000); |
@@ -187,12 +195,11 @@ | @@ -187,12 +195,11 @@ | ||
187 | alert(xhr.responseText); | 195 | alert(xhr.responseText); |
188 | } | 196 | } |
189 | }); | 197 | }); |
190 | - | ||
191 | } | 198 | } |
192 | 199 | ||
193 | - function _submitAnswer(task, deferred, status, has_skipped) { | 200 | + function _submitAnswer(task, deferred, status, hasSkipped) { |
194 | var answer = _createAnswer(task, status); | 201 | var answer = _createAnswer(task, status); |
195 | - if (has_skipped) { | 202 | + if (hasSkipped) { |
196 | _saveAnswer(task, deferred, answer); | 203 | _saveAnswer(task, deferred, answer); |
197 | } else { | 204 | } else { |
198 | _finishTask(task, deferred, answer); | 205 | _finishTask(task, deferred, answer); |
@@ -201,8 +208,8 @@ | @@ -201,8 +208,8 @@ | ||
201 | 208 | ||
202 | function _saveAnswer(task, deferred, answer) { | 209 | function _saveAnswer(task, deferred, answer) { |
203 | pybossa.saveTask(task.id, answer).done(function() { | 210 | pybossa.saveTask(task.id, answer).done(function() { |
204 | - $("#success").fadeIn(500); | ||
205 | - $("#main-container").hide(); | 211 | + $('#success').fadeIn(500); |
212 | + $('#validador-container').hide(); | ||
206 | setTimeout(function() { | 213 | setTimeout(function() { |
207 | deferred.resolve(); | 214 | deferred.resolve(); |
208 | }, 2000); | 215 | }, 2000); |
@@ -210,39 +217,49 @@ | @@ -210,39 +217,49 @@ | ||
210 | } | 217 | } |
211 | 218 | ||
212 | function _loadTaskInfo(task) { | 219 | function _loadTaskInfo(task) { |
213 | - current_task_id = task.id; | ||
214 | - var sign_name = task.info.sign_name; | ||
215 | - var avatar_vid_link = videos_url + sign_name + "_AVATAR.webm"; | ||
216 | - var ref_vid_link = videos_url + sign_name + "_REF.webm"; | ||
217 | - $(".sign-label").text(sign_name); | ||
218 | - $("#avatar-video").attr("src", avatar_vid_link); | ||
219 | - $("#ref-video").attr("src", ref_vid_link); | 220 | + currentTaskId = task.id; |
221 | + var signName = task.info.sign_name; | ||
222 | + var avatarVidLink = videosUrl + signName + '_AVATAR.webm'; | ||
223 | + var refVidLink = videosUrl + signName + '_REF.webm'; | ||
224 | + $('.sign-label').text(signName); | ||
225 | + $('#avatar-video').attr('src', avatarVidLink); | ||
226 | + $('#ref-video').attr('src', refVidLink); | ||
227 | + } | ||
228 | + | ||
229 | + function _loadMainComponents() { | ||
230 | + pybossaApiHelper.setup(pybossaEndpoint, projectName); | ||
231 | + loadHtmlHelper.setup(baseUrl); | ||
232 | + ranking.setup(baseUrl, pybossaEndpoint, projectName, _getLoggedUser()); | ||
220 | } | 233 | } |
221 | 234 | ||
222 | pybossa.presentTask(function(task, deferred) { | 235 | pybossa.presentTask(function(task, deferred) { |
223 | - if (!$.isEmptyObject(task) && current_task_id != task.id) { | 236 | + _loadMainComponents(); |
237 | + if (!$.isEmptyObject(task) && currentTaskId != task.id) { | ||
224 | _loadTaskInfo(task); | 238 | _loadTaskInfo(task); |
225 | _setupGUI(task, deferred); | 239 | _setupGUI(task, deferred); |
226 | - $("#success").hide(); | ||
227 | - $("#main-container").fadeIn(500); | 240 | + $('#success').hide(); |
241 | + $('#validador-container').fadeIn(500); | ||
228 | } else { | 242 | } else { |
229 | - $("#main-container").hide(); | ||
230 | - $("#finish").fadeIn(500); | 243 | + $('#validador-container').hide(); |
244 | + $('#finish').fadeIn(500); | ||
245 | + ranking.tasksEnded(); | ||
231 | } | 246 | } |
232 | }); | 247 | }); |
233 | 248 | ||
234 | // Private methods | 249 | // Private methods |
235 | function _run(projectname) { | 250 | function _run(projectname) { |
236 | - pybossa.setEndpoint("/pybossa"); | 251 | + pybossa.setEndpoint(pybossaEndpoint); |
237 | pybossa.run(projectname); | 252 | pybossa.run(projectname); |
238 | } | 253 | } |
239 | 254 | ||
240 | // Public methods | 255 | // Public methods |
241 | - validador.run = function(serverhost, serverbackend, projectname) { | ||
242 | - base_url = serverhost; | ||
243 | - server_backend_url = serverbackend; | ||
244 | - videos_url = base_url + "/videos/"; | ||
245 | - _run(projectname); | 256 | + validador.run = function(serverhost, serverbackend, projname) { |
257 | + baseUrl = serverhost; | ||
258 | + serverBackendUrl = serverbackend; | ||
259 | + videosUrl = baseUrl + '/videos/'; | ||
260 | + pybossaEndpoint = '/pybossa'; | ||
261 | + projectName = projname; | ||
262 | + _run(projectName); | ||
246 | }; | 263 | }; |
247 | 264 | ||
248 | }(window.validador = window.validador || {}, jQuery)); | 265 | }(window.validador = window.validador || {}, jQuery)); |
249 | \ No newline at end of file | 266 | \ No newline at end of file |
@@ -0,0 +1,47 @@ | @@ -0,0 +1,47 @@ | ||
1 | +<div id="ranking-info-container" class="col-sm-4"> | ||
2 | + <div class="title">WikiRanking</div> | ||
3 | + <div>Lorem Ipsum é apenas uma simulação de texto da indústria | ||
4 | + tipográfica e de impressos, e vem sendo utilizado desde o século XVI.</div> | ||
5 | + <div class="avatar-info col-sm-12"> | ||
6 | + <div class="avatar-placeholder col-sm-6 col-sm-offset-3"> | ||
7 | + <img src="{{ server }}/assets/img/ranking/user-shape.png"> | ||
8 | + </div> | ||
9 | + <div class="avatar-container col-sm-8 col-sm-offset-2"> | ||
10 | + <img src=""> | ||
11 | + </div> | ||
12 | + <div class="col-sm-12"> | ||
13 | + <div class="username"></div> | ||
14 | + <div class="rank-position-container"> | ||
15 | + <strong><span class="rank-position"></span>º Posição</strong> | ||
16 | + </div> | ||
17 | + </div> | ||
18 | + </div> | ||
19 | + <div class="achievements-container col-sm-12"> | ||
20 | + <div class="progress-container col-sm-12"> | ||
21 | + <div class="progress"> | ||
22 | + <div class="progress-bar" role="progressbar" aria-valuenow="0" | ||
23 | + aria-valuemin="0" aria-valuemax="100" data-toggle="tooltip" | ||
24 | + data-html="true"></div> | ||
25 | + </div> | ||
26 | + </div> | ||
27 | + <div class="progress-label"> | ||
28 | + <span><strong>Progresso:</strong></span> | ||
29 | + </div> | ||
30 | + </div> | ||
31 | +</div> | ||
32 | +<div id="leaderboard-container" class="col-sm-8"> | ||
33 | + <table class="table table-striped table-hover"> | ||
34 | + <thead> | ||
35 | + <tr> | ||
36 | + <th></th> | ||
37 | + <th>#</th> | ||
38 | + <th><img src="{{ server }}/assets/img/ranking/trophy-icon.png"> | ||
39 | + <div>Membro</div></th> | ||
40 | + <th><img src="{{ server }}/assets/img/ranking/signs-icon.png"> | ||
41 | + <div>Sinais</div></th> | ||
42 | + </tr> | ||
43 | + </thead> | ||
44 | + <tbody> | ||
45 | + </tbody> | ||
46 | + </table> | ||
47 | +</div> | ||
0 | \ No newline at end of file | 48 | \ No newline at end of file |
view/img/correct.png
4.98 KB
view/img/finish.svg
@@ -1,17 +0,0 @@ | @@ -1,17 +0,0 @@ | ||
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | ||
3 | -<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="100px" height="100px" version="1.1" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd" | ||
4 | -viewBox="0 0 100 100" | ||
5 | - xmlns:xlink="http://www.w3.org/1999/xlink"> | ||
6 | - <defs> | ||
7 | - <style type="text/css"> | ||
8 | - <![CDATA[ | ||
9 | - .fil0 {fill:#5EC7BD;fill-rule:nonzero} | ||
10 | - ]]> | ||
11 | - </style> | ||
12 | - </defs> | ||
13 | - <g id="finish"> | ||
14 | - <metadata id="finish"/> | ||
15 | - <path class="fil0" d="M44 79c-4,4 -10,4 -13,0l-20 -20c-2,-2 -3,-4 -3,-6 0,-3 1,-5 3,-7 3,-3 9,-3 13,0l12 12c0,1 2,1 3,0l37 -37c2,-2 5,-3 7,-3l0 0c2,0 5,1 6,3 2,1 3,4 3,6 0,3 -1,5 -3,7l-45 45z"/> | ||
16 | - </g> | ||
17 | -</svg> |
view/img/incorrect.png
4.88 KB
view/img/loading.gif
78 KB
view/img/skip.svg
@@ -1,17 +0,0 @@ | @@ -1,17 +0,0 @@ | ||
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | ||
3 | -<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="100px" height="100px" version="1.1" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd" | ||
4 | -viewBox="0 0 100 100" | ||
5 | - xmlns:xlink="http://www.w3.org/1999/xlink"> | ||
6 | - <defs> | ||
7 | - <style type="text/css"> | ||
8 | - <![CDATA[ | ||
9 | - .fil0 {fill:#5EC7BD;fill-rule:nonzero} | ||
10 | - ]]> | ||
11 | - </style> | ||
12 | - </defs> | ||
13 | - <g id="skip"> | ||
14 | - <metadata id="skip"/> | ||
15 | - <path class="fil0" d="M10 24c1,-1 23,-17 45,0 8,6 12,15 13,26l22 0 -34 34 -34 -34 22 0c0,-1 1,-3 1,-4 -2,-29 -19,-26 -35,-22z"/> | ||
16 | - </g> | ||
17 | -</svg> |
view/img/thumbnail.png
34.6 KB
view/template.html
1 | <link rel="stylesheet" href="{{ server }}/assets/css/main.css"> | 1 | <link rel="stylesheet" href="{{ server }}/assets/css/main.css"> |
2 | 2 | ||
3 | +<script src="{{ server }}/assets/js/external-libs/js.cookie.js"></script> | ||
4 | +<script src="{{ server }}/assets/js/helpers/pybossa-api-helper.js"></script> | ||
5 | +<script src="{{ server }}/assets/js/helpers/load-html-helper.js"></script> | ||
6 | +<script src="{{ server }}/assets/js/ranking.js"></script> | ||
3 | <script src="{{ server }}/assets/js/validador.js"></script> | 7 | <script src="{{ server }}/assets/js/validador.js"></script> |
4 | 8 | ||
5 | -<div class="row"> | ||
6 | - <div id="success" class="alert alert-success" style="display: none;"> | ||
7 | - <strong>Parabéns!</strong> <span>Tarefa concluída.</span> | ||
8 | - </div> | ||
9 | - <div id="finish" class="alert alert-success" style="display: none;"> | ||
10 | - <strong>Parabéns!</strong> <span> Você completou todas as | ||
11 | - tarefas disponíveis! </span> <br /> | ||
12 | - <div class="alert-actions"> | ||
13 | - <a class="btn small" href="/">Voltar</a> <a class="btn small" | ||
14 | - href="/pybossa/project">ou, olhar outros projetos.</a> | 9 | +<div id="alert-container" class="container"> |
10 | + <div class="row"> | ||
11 | + <div id="success" class="alert alert-success" style="display: none;"> | ||
12 | + <a class="close" data-dismiss="alert" href="#">×</a> <strong>Parabéns!</strong> | ||
13 | + <span>Tarefa concluída.</span> | ||
14 | + </div> | ||
15 | + <div id="finish" class="alert alert-success" style="display: none;"> | ||
16 | + <a class="close" data-dismiss="alert" href="#">×</a> <strong>Que | ||
17 | + pena,</strong> <span> não há mais tarefas disponíveis! </span> <br /> | ||
18 | + <div class="alert-actions"> | ||
19 | + <a class="btn small" href="/">Voltar</a> <a class="btn small" | ||
20 | + href="/pybossa/project">ou, olhar outros projetos.</a> | ||
21 | + </div> | ||
15 | </div> | 22 | </div> |
16 | </div> | 23 | </div> |
17 | </div> | 24 | </div> |
18 | <div id="loading-container"> | 25 | <div id="loading-container"> |
19 | - <img src="{{ server }}/img/loading.gif"> | 26 | + <img src="{{ server }}/assets/img/loading.gif"> |
20 | </div> | 27 | </div> |
21 | -<div id="main-container" class="container"> | ||
22 | - <div id="validador-header"> | ||
23 | - <h2> | ||
24 | - A animação do sinal "<span class="sign-label"></span>" está correta? | ||
25 | - </h2> | 28 | +<div id="main-container" class="container body-container"> |
29 | + <div id="validador-navbar" class="row"> | ||
30 | + <div class="col-sm-12"> | ||
31 | + <div class="btn btn-warning ranking-button pull-right" | ||
32 | + onclick="ranking.toggle()">Ver Ranking</div> | ||
33 | + </div> | ||
26 | </div> | 34 | </div> |
27 | - <div class="line-separator"></div> | ||
28 | - <div id="corretor-container" class="row body-container"> | ||
29 | - <div id="avatar-container" class="col-sm-6 video-container"> | ||
30 | - <div class="row"> | ||
31 | - <h6> | ||
32 | - ANIMAÇÃO "<span class="sign-label"></span>": | ||
33 | - </h6> | ||
34 | - </div> | ||
35 | - <div class="row"> | ||
36 | - <video id="avatar-video" src="" preload="metadata" | ||
37 | - class="video-body" autoplay loop controls> | ||
38 | - <source type="video/webm"> | ||
39 | - </video> | ||
40 | - </div> | ||
41 | - <div id="avatar-radio-answers" class="row radio-options"> | ||
42 | - <div class="correct-answer-container""> | ||
43 | - <span class="correct-answer-label">ESTÁ CORRETO</span><img | ||
44 | - class="icon" src="{{ server }}/img/correct.png"></img><input | ||
45 | - value="CORRECT" type="radio" name="avatar-answers"> | 35 | + <div id="validador-container" class="row"> |
36 | + <div id="validador-header"> | ||
37 | + <h2 class="validador-question"> | ||
38 | + A animação do sinal "<span class="sign-label"></span>" está correta? | ||
39 | + </h2> | ||
40 | + </div> | ||
41 | + <div class="line-separator"></div> | ||
42 | + <div class="row"> | ||
43 | + <div id="avatar-container" class="col-sm-6 video-container"> | ||
44 | + <div class="row"> | ||
45 | + <h6> | ||
46 | + ANIMAÇÃO "<span class="sign-label"></span>": | ||
47 | + </h6> | ||
46 | </div> | 48 | </div> |
47 | - <div> | ||
48 | - <span class="incorrect-answer-label">ESTÁ ERRADO</span><img | ||
49 | - class="icon" src="{{ server }}/img/incorrect.png"></img><input | ||
50 | - id="incorrect-avatar-button" value="INCORRECT" type="radio" | ||
51 | - name="avatar-answers"> | 49 | + <div class="row"> |
50 | + <video id="avatar-video" src="" preload="metadata" | ||
51 | + class="video-body" autoplay loop controls> | ||
52 | + <source type="video/webm"> | ||
53 | + </video> | ||
52 | </div> | 54 | </div> |
53 | - </div> | ||
54 | - <div id="comment-avatar" class="form-group"> | ||
55 | - <h6>ENVIAR COMENTÁRIO SOBRE A ANIMAÇÃO:</h6> | ||
56 | - <textarea class="form-control" rows="2"></textarea> | ||
57 | - </div> | ||
58 | - </div> | ||
59 | - <div id="ref-container" class="col-sm-6 video-container"> | ||
60 | - <div class="row"> | ||
61 | - <h6> | ||
62 | - VÍDEO DE REFERÊNCIA “<span class="sign-label"></span>”: | ||
63 | - </h6> | ||
64 | - </div> | ||
65 | - <div class="row"> | ||
66 | - <video id="ref-video" src="" preload="metadata" class="video-body" | ||
67 | - autoplay loop controls> | ||
68 | - <source type="video/webm"> | ||
69 | - </video> | ||
70 | - </div> | ||
71 | - <div id="ref-radio-answers" class="row radio-options"> | ||
72 | - <div class="correct-answer-container""> | ||
73 | - <span class="correct-answer-label">ESTÁ CORRETO</span><img | ||
74 | - class="icon" src="{{ server }}/img/correct.png"></img><input | ||
75 | - value="CORRECT" type="radio" name="ref-answers"> | 55 | + <div id="avatar-radio-answers" class="row radio-options"> |
56 | + <div class="correct-answer-container""> | ||
57 | + <span class="correct-answer-label">ESTÁ CORRETO</span><img | ||
58 | + class="icon" src="{{ server }}/assets/img/correct.png"></img><input | ||
59 | + value="CORRECT" type="radio" name="avatar-answers"> | ||
60 | + </div> | ||
61 | + <div> | ||
62 | + <span class="incorrect-answer-label">ESTÁ ERRADO</span><img | ||
63 | + class="icon" src="{{ server }}/assets/img/incorrect.png"></img><input | ||
64 | + id="incorrect-avatar-button" value="INCORRECT" type="radio" | ||
65 | + name="avatar-answers"> | ||
66 | + </div> | ||
76 | </div> | 67 | </div> |
77 | - <div> | ||
78 | - <span class="incorrect-answer-label">ESTÁ ERRADO</span><img | ||
79 | - class="icon" src="{{ server }}/img/incorrect.png"></img><input | ||
80 | - id="incorrect-ref-button" value="INCORRECT" type="radio" | ||
81 | - name="ref-answers"> | 68 | + <div id="comment-avatar" class="form-group"> |
69 | + <h6>ENVIAR COMENTÁRIO SOBRE A ANIMAÇÃO:</h6> | ||
70 | + <textarea class="form-control" rows="2"></textarea> | ||
82 | </div> | 71 | </div> |
83 | </div> | 72 | </div> |
84 | - <div id="comment-ref" class="form-group"> | ||
85 | - <h6>ENVIAR COMENTÁRIO SOBRE O VÍDEO DE REFERÊNCIA:</h6> | ||
86 | - <textarea class="form-control" rows="2"></textarea> | ||
87 | - </div> | ||
88 | - <div id="finish-task-container" class="row finish-padding-top"> | ||
89 | - <div id="finish-button" class="finish-task-button enabled-button"> | ||
90 | - <span id="finish-button-text">ENVIAR ANÁLISE E FINALIZAR</span><img | ||
91 | - class="icon" src="{{ server }}/img/finish.svg"></img> | 73 | + <div id="ref-container" class="col-sm-6 video-container"> |
74 | + <div class="row"> | ||
75 | + <h6> | ||
76 | + VÍDEO DE REFERÊNCIA “<span class="sign-label"></span>”: | ||
77 | + </h6> | ||
78 | + </div> | ||
79 | + <div class="row"> | ||
80 | + <video id="ref-video" src="" preload="metadata" class="video-body" | ||
81 | + autoplay loop controls> | ||
82 | + <source type="video/webm"> | ||
83 | + </video> | ||
84 | + </div> | ||
85 | + <div id="ref-radio-answers" class="row radio-options"> | ||
86 | + <div class="correct-answer-container""> | ||
87 | + <span class="correct-answer-label">ESTÁ CORRETO</span><img | ||
88 | + class="icon" src="{{ server }}/assets/img/correct.png"></img><input | ||
89 | + value="CORRECT" type="radio" name="ref-answers"> | ||
90 | + </div> | ||
91 | + <div> | ||
92 | + <span class="incorrect-answer-label">ESTÁ ERRADO</span><img | ||
93 | + class="icon" src="{{ server }}/assets/img/incorrect.png"></img><input | ||
94 | + id="incorrect-ref-button" value="INCORRECT" type="radio" | ||
95 | + name="ref-answers"> | ||
96 | + </div> | ||
97 | + </div> | ||
98 | + <div id="comment-ref" class="form-group"> | ||
99 | + <h6>ENVIAR COMENTÁRIO SOBRE O VÍDEO DE REFERÊNCIA:</h6> | ||
100 | + <textarea class="form-control" rows="2"></textarea> | ||
92 | </div> | 101 | </div> |
93 | - <div id="skip-button" class="finish-task-button enabled-button"> | ||
94 | - PULAR<img class="icon" src="{{ server }}/img/skip.svg"></img> | 102 | + <div id="finish-task-container" class="row finish-padding-top"> |
103 | + <div id="finish-button" class="finish-task-button enabled-button"> | ||
104 | + <span id="finish-button-text">ENVIAR ANÁLISE E FINALIZAR</span><img | ||
105 | + class="icon" src="{{ server }}/assets/img/finish.svg"></img> | ||
106 | + </div> | ||
107 | + <div id="skip-button" class="finish-task-button enabled-button"> | ||
108 | + PULAR<img class="icon" src="{{ server }}/assets/img/skip.svg"></img> | ||
109 | + </div> | ||
95 | </div> | 110 | </div> |
96 | </div> | 111 | </div> |
97 | </div> | 112 | </div> |
98 | </div> | 113 | </div> |
114 | + <div id="ranking-container" class="row"></div> | ||
99 | </div> | 115 | </div> |
100 | 116 | ||
101 | <script type="text/javascript"> | 117 | <script type="text/javascript"> |
102 | - validador.run("{{ server }}", "{{ server_backend }}", "{{ app_shortname }}"); | 118 | + validador |
119 | + .run("{{ server }}", "{{ server_backend }}", "{{ app_shortname }}"); | ||
103 | </script> | 120 | </script> |