5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6 <title>MKWS demo: Reference & Credo, and popup widget, development</title>
7 <link rel="stylesheet" type="text/css" href="tools/htdocs/mkws.css" />
8 <link rel="stylesheet" type="text/css" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css" />
9 <link rel="stylesheet" type="text/css" href="mkws-widget-reference.css" />
10 <link rel="stylesheet" type="text/css" href="mkws-widget-credo.css" />
11 <link rel="stylesheet" type="text/css" href="mkws-widget-ru.css" />
13 <script type="text/javascript">
15 sp_auth_credentials: "mkwstest/mkwstest"
19 <script type="text/javascript" src="tools/htdocs/jquery-1.10.0.min.js"></script>
20 <script type="text/javascript" src="//code.jquery.com/ui/1.11.2/jquery-ui.min.js"></script>
22 <script type="text/javascript" src="tools/htdocs/pz2.js"></script>
23 <script type="text/javascript" src="tools/htdocs/handlebars-v2.0.0.js"></script>
24 <script type="text/javascript" src="tools/htdocs/jquery.json-2.4.js"></script>
25 <script type="text/javascript" src="tools/htdocs/jsnlog.min.js"></script>
27 <script type="text/javascript" src="src/mkws-handlebars.js"></script>
28 <script type="text/javascript" src="src/mkws-core.js"></script>
29 <script type="text/javascript" src="src/mkws-team.js"></script>
30 <script type="text/javascript" src="src/mkws-filter.js"></script>
31 <script type="text/javascript" src="src/mkws-widget.js"></script>
32 <script type="text/javascript" src="src/mkws-widget-main.js"></script>
33 <script type="text/javascript" src="src/mkws-widget-facets.js"></script>
34 <script type="text/javascript" src="src/mkws-widget-authname.js"></script>
35 <script type="text/javascript" src="src/mkws-widget-categories.js"></script>
36 <script type="text/javascript" src="src/mkws-widget-log.js"></script>
37 <script type="text/javascript" src="src/mkws-widget-record.js"></script>
38 <script type="text/javascript" src="src/mkws-widget-reference.js"></script>
39 <script type="text/javascript" src="src/mkws-widget-builder.js"></script>
40 <script type="text/javascript" src="src/mkws-templates.js"></script>
41 <script type="text/javascript" src="src/mkws-popup.js"></script>
43 <script type="text/javascript" src="mkws-widget-credo.js"></script>
44 <script type="text/javascript" src="mkws-widget-ru.js"></script>
56 background-color: #888892;
60 flex-direction: column;
66 #top-bar, #current-bar {
70 justify-content: space-between;
73 background-color: #002868;
77 background-color: #54d8a8;
83 background-color: #4368a1;
87 border: 1px solid #7492c3;
88 padding: 0.1em 0.15em;
90 header button:hover, header button:active, header button:focus {
91 background-color: #2f5591;
94 background-color: #F0AD4E;
95 border-color: #EEA236;
99 #maybe:hover, #maybe:active, #maybe:focus {
100 background-color: #EC971F;
101 border-color: #D58512;
104 background-color: #5CB85C;
105 border-color: #4CAE4C;
109 #yes:hover, #yes:focus, #yes:active {
110 background-color: #449D44;
111 border-color: #398439;
114 background-color: #D9534F;
115 border-color: #D43F3A;
119 #no:hover, #no:focus, #no:active {
120 background-color: #C9302C;
121 border-color: #AC2925;
127 #settings, #judiciary {
132 #results, #query-info {
137 justify-content: flex-end;
146 justify-content: center;
158 <button id="widget-markup-button">Widget</button>
159 <button id="queries-button">Queries</button>
163 <button id="results-table-button">Table</button>
164 <button id="results-csv-button">| delimited</button>
169 <header id="current-bar">
170 <span id="judiciary">
171 Relevant to query <span id="query"></span>?
172 <button id="yes" class="judgement">Yes</button>
173 <button id="no" class="judgement">No</button>
174 <button id="maybe" class="judgement">Maybe</button>
176 <span id="query-info">
177 <span id="count"></span>
181 <div id="widget-markup" class="dialog" title="Widget markup">
182 <textarea></textarea>
184 <div id="queries" class="dialog" title="Queries">
185 <textarea></textarea>
187 <div id="results-csv" class="dialog" title="| delimited results">
188 <textarea readonly></textarea>
190 <div id="results-table" class="dialog" title="Results as table">
195 <div id="test-subject"></div>
199 (function () { // wrapper
201 this.queries = ["sushi", "wurst", "berlin", "hammer", "bristol", "copenhagen", "tea", "latte"];
202 $("#queries > textarea").html(this.queries.join("\n"));
203 this.widgetMarkup = '<div class="mkws-reference" autosearch="{{query}}">Loading..</div>';
204 $("#widget-markup > textarea").html(this.widgetMarkup);
210 var showNext = function () {
211 if (next < this.queries.length) {
212 $('#test-subject').html(this.widgetMarkup.replace("{{query}}", this.queries[next]));
213 $('#query').html('"' + this.queries[next] + '"');
215 $('#count').html(next + " / " + this.queries.length);
216 mkws.init('#test-subject');
219 var startEval = function () {
220 $(".dialog").dialog("close");
222 context.results = {};
225 var judge = function (e) {
226 var query = $('#test-subject > div').attr('autosearch');
227 context.results[query] = {judgement: $(this).html()};
232 $(".dialog").dialog({
237 open: function(event, ui) {
238 $(this).parent().css('position', 'fixed');
243 var updateMarkup = function () {
244 context.widgetMarkup = $("#widget-markup > textarea").val();
247 $("#widget-markup-button").click(function () {
248 $("#widget-markup").dialog("open");
250 $("#widget-markup").dialog("option", "buttons", [
251 {text: "Start new evaluation", click: updateMarkup},
252 {text: "Cancel", click: function() { $(this).dialog("close"); }}
256 var updateQueries = function () {
257 context.queries = $("#queries > textarea").val().split("\n");
260 $("#queries-button").click(function () {
261 $("#queries").dialog("open");
263 $("#queries").dialog("option", "buttons", [
264 {text: "Start new evaluation", click: updateQueries},
265 {text: "Cancel", click: function() { $(this).dialog("close"); }}
269 $("#results-table-button").click(function () {
270 $("#results-table").dialog("open");
272 $("#results-csv-button").click(function () {
273 $("#results-csv").dialog("open");
275 $("#results-table").dialog("option", "open", function () {
276 var html = "<tr><th>Query</th><th>Relevant?</th><tr>";
277 for (var i = 0; i < context.queries.length; i++) {
278 var q = context.queries[i];
279 var r = context.results;
281 html += "<tr><td>" + q + "</td><td>" + r[q].judgement + "</td></tr>\n";
284 $("#results-table > table").html(html);
286 $("#results-csv").dialog("option", "open", function () {
287 var csv = "Query|Relevant?\n";
288 for (var i = 0; i < context.queries.length; i++) {
289 var q = context.queries[i];
290 var r = context.results;
292 csv += [q, r[q].judgement].join("|") + "\n";
295 $("#results-csv > textarea").html(csv);
298 $('button.judgement').click(judge);