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-wikipedia.css" />
10 <link rel="stylesheet" type="text/css" href="mkws-widget-credo.css" />
12 <script type="text/javascript">
14 // target: 'wikimedia_wikipedia_single_result',
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-wikipedia.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>
55 background-color: #bbbbbb;
59 flex-direction: column;
65 header button, #note > input {
68 background-color: #4368a1;
72 border: 1px solid #7492c3;
73 padding: 0.15em 0.25em;
75 header button:hover, header button:active, header button:focus {
76 background-color: #2f5591;
78 #top-bar, #current-bar, #note {
82 justify-content: space-between;
85 background-color: #002868;
89 background-color: #54d8a8;
98 background-color: #7de3be;
99 border-color: #7ed6b6;
103 background-color: #F0AD4E;
104 border-color: #EEA236;
108 #maybe:hover, #maybe:active, #maybe:focus {
109 background-color: #EC971F;
110 border-color: #D58512;
113 background-color: #5CB85C;
114 border-color: #4CAE4C;
118 #yes:hover, #yes:focus, #yes:active {
119 background-color: #449D44;
120 border-color: #398439;
123 background-color: #D9534F;
124 border-color: #D43F3A;
128 #no:hover, #no:focus, #no:active {
129 background-color: #C9302C;
130 border-color: #AC2925;
136 #settings, #judiciary {
141 #results, #query-info {
146 justify-content: flex-end;
155 justify-content: center;
165 justify-content: center;
167 #results-table table {
168 border-collapse: collapse;
171 #results-table td, #results-table th {
172 padding: .25em 1.25em;
175 #results-table tr:first-child {
176 border-bottom: 1px solid black;
179 border-bottom: 1px dotted black;
181 #results-table tr:last-child {
194 <button id="widget-markup-button">Widget</button>
195 <button id="mkws-config-button">MKWS config</button>
196 <button id="queries-button">Queries</button>
200 <button id="results-table-button">Table</button>
201 <button id="results-csv-button">| delimited</button>
206 <header id="current-bar">
207 <span id="judiciary">
208 Relevant to query <span id="query"></span>?
209 <button id="yes" class="judgement">Yes</button>
210 <button id="no" class="judgement">No</button>
211 <button id="maybe" class="judgement">Maybe</button>
213 <span id="query-info">
214 <span id="count"></span>
217 Note: <input type="text"></input>
221 <div id="widget-markup" class="dialog" title="Widget markup">
222 <textarea></textarea>
224 <div id="mkws-config" class="dialog" title="MKWS configuration">
225 <textarea></textarea>
227 <div id="queries" class="dialog" title="Queries">
228 <textarea></textarea>
230 <div id="results-csv" class="dialog" title="| delimited results">
231 <textarea readonly></textarea>
233 <div id="results-table" class="dialog" title="Results as table">
238 <div id="test-subject"></div>
242 (function () { // wrapper
244 this.queries = ["sushi", "wurst", "tea", "latte"];
245 this.widgetMarkup = '<div class="mkws-reference" autosearch="{{query}}">Loading..</div>';
246 if (localStorage.getItem('mkwstest-queries')) {
247 this.queries = JSON.parse(localStorage.getItem('mkwstest-queries'));
249 if (localStorage.getItem('mkwstest-widget-markup')) {
250 this.widgetMarkup = localStorage.getItem('mkwstest-widget-markup');
252 if (localStorage.getItem('mkwstest-mkws-config')) {
253 mkws_config = JSON.parse(localStorage.getItem('mkwstest-mkws-config'));
255 $("#queries > textarea").html(this.queries.join("\n"));
256 $("#widget-markup > textarea").html(this.widgetMarkup);
257 $("#mkws-config > textarea").html(JSON.stringify(mkws_config));
258 mkws.setMkwsConfig(mkws_config);
259 mkws.authenticated = false;
260 mkws.authenticating = false;
264 if (localStorage.getItem('mkwstest-results')) {
265 this.results = JSON.parse(localStorage.getItem('mkwstest-results'));
267 if (localStorage.getItem('mkwstest-next') !== null) {
268 next = parseInt(localStorage.getItem('mkwstest-next'));
273 var showNext = function () {
274 if (next < this.queries.length) {
275 $('#note > input').val("");
276 $('#test-subject').html(this.widgetMarkup.replace("{{query}}", this.queries[next]));
277 $('#query').html('"' + this.queries[next] + '"');
278 localStorage.setItem("mkwstest-next", next);
280 $('#count').html(next + " / " + this.queries.length);
281 mkws.init('#test-subject');
283 $("#results-table").dialog("open");
286 var startEval = function () {
287 $(".dialog").dialog("close");
289 context.results = {};
292 var judge = function (e) {
293 var query = $('#test-subject > div').attr('autosearch');
294 context.results[query] = {judgement: $(this).html(), note: $("#note > input").val() || ""};
295 localStorage.setItem("mkwstest-results", JSON.stringify(context.results));
300 $(".dialog").dialog({
305 open: function(event, ui) {
306 $(this).parent().css('position', 'fixed');
311 var updateMarkup = function () {
312 context.widgetMarkup = $("#widget-markup > textarea").val();
313 localStorage.setItem("mkwstest-widget-markup", context.widgetMarkup);
316 $("#widget-markup-button").click(function () {
317 $("#widget-markup").dialog("open");
319 $("#widget-markup").dialog("option", "buttons", [
320 {text: "Start new evaluation", click: updateMarkup},
321 {text: "Cancel", click: function() { $(this).dialog("close"); }}
324 // MKWS config dialog
325 var updateConfig = function () {
326 mkws.setMkwsConfig(JSON.parse($("#mkws-config > textarea").val()));
327 mkws.authenticated = false;
328 mkws.authenticating = false;
329 localStorage.setItem("mkwstest-mkws-config", $("#mkws-config > textarea").val());
332 $("#mkws-config-button").click(function () {
333 $("#mkws-config").dialog("open");
335 $("#mkws-config").dialog("option", "buttons", [
336 {text: "Start new evaluation", click: updateConfig},
337 {text: "Cancel", click: function() { $(this).dialog("close"); }}
341 var updateQueries = function () {
342 context.queries = $("#queries > textarea").val().split("\n");
343 // ignore empty query values
344 context.queries = $.grep(context.queries, function (query, index) { return query.match(/^\s*\S+/) } );
345 localStorage.setItem("mkwstest-queries", JSON.stringify(context.queries));
348 $("#queries-button").click(function () {
349 $("#queries").dialog("open");
351 $("#queries").dialog("option", "buttons", [
352 {text: "Start new evaluation", click: updateQueries},
353 {text: "Cancel", click: function() { $(this).dialog("close"); }}
357 $("#results-table-button").click(function () {
358 $("#results-table").dialog("open");
360 $("#results-csv-button").click(function () {
361 $("#results-csv").dialog("open");
363 $("#results-table").dialog("option", "open", function () {
364 var html = "<tr><th>Query</th><th>Relevant?</th><th>Note</th><tr>";
365 for (var i = 0; i < context.queries.length; i++) {
366 var q = context.queries[i];
367 var r = context.results;
369 html += "<tr><td>" + q + "</td><td>" + r[q].judgement + "</td><td>" + r[q].note + "</td></tr>\n";
372 $("#results-table > table").html(html);
374 $("#results-csv").dialog("option", "open", function () {
375 var csv = "Query|Relevant?|Note\n";
376 for (var i = 0; i < context.queries.length; i++) {
377 var q = context.queries[i];
378 var r = context.results;
380 csv += [q, r[q].judgement, r[q].note].join("|") + "\n";
383 $("#results-csv > textarea").html(csv);
386 $('button.judgement').click(judge);