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" />
12 <script type="text/javascript">
14 sp_auth_credentials: "mkwstest/mkwstest"
18 <script type="text/javascript" src="tools/htdocs/jquery-1.10.0.min.js"></script>
19 <script type="text/javascript" src="//code.jquery.com/ui/1.11.2/jquery-ui.min.js"></script>
21 <script type="text/javascript" src="tools/htdocs/pz2.js"></script>
22 <script type="text/javascript" src="tools/htdocs/handlebars-v2.0.0.js"></script>
23 <script type="text/javascript" src="tools/htdocs/jquery.json-2.4.js"></script>
24 <script type="text/javascript" src="tools/htdocs/jsnlog.min.js"></script>
26 <script type="text/javascript" src="src/mkws-handlebars.js"></script>
27 <script type="text/javascript" src="src/mkws-core.js"></script>
28 <script type="text/javascript" src="src/mkws-team.js"></script>
29 <script type="text/javascript" src="src/mkws-filter.js"></script>
30 <script type="text/javascript" src="src/mkws-widget.js"></script>
31 <script type="text/javascript" src="src/mkws-widget-main.js"></script>
32 <script type="text/javascript" src="src/mkws-widget-facets.js"></script>
33 <script type="text/javascript" src="src/mkws-widget-authname.js"></script>
34 <script type="text/javascript" src="src/mkws-widget-categories.js"></script>
35 <script type="text/javascript" src="src/mkws-widget-log.js"></script>
36 <script type="text/javascript" src="src/mkws-widget-record.js"></script>
37 <script type="text/javascript" src="src/mkws-widget-reference.js"></script>
38 <script type="text/javascript" src="src/mkws-widget-builder.js"></script>
39 <script type="text/javascript" src="src/mkws-templates.js"></script>
40 <script type="text/javascript" src="src/mkws-popup.js"></script>
42 <script type="text/javascript" src="mkws-widget-credo.js"></script>
54 background-color: #bbbbbb;
58 flex-direction: column;
64 #top-bar, #current-bar {
68 justify-content: space-between;
71 background-color: #002868;
75 background-color: #54d8a8;
81 background-color: #4368a1;
85 border: 1px solid #7492c3;
86 padding: 0.15em 0.25em;
88 header button:hover, header button:active, header button:focus {
89 background-color: #2f5591;
92 background-color: #F0AD4E;
93 border-color: #EEA236;
97 #maybe:hover, #maybe:active, #maybe:focus {
98 background-color: #EC971F;
99 border-color: #D58512;
102 background-color: #5CB85C;
103 border-color: #4CAE4C;
107 #yes:hover, #yes:focus, #yes:active {
108 background-color: #449D44;
109 border-color: #398439;
112 background-color: #D9534F;
113 border-color: #D43F3A;
117 #no:hover, #no:focus, #no:active {
118 background-color: #C9302C;
119 border-color: #AC2925;
125 #settings, #judiciary {
130 #results, #query-info {
135 justify-content: flex-end;
144 justify-content: center;
154 justify-content: center;
156 #results-table table {
157 border-collapse: collapse;
160 #results-table td, #results-table th {
161 padding: .25em 1.25em;
164 #results-table tr:first-child {
165 border-bottom: 1px solid black;
168 border-bottom: 1px dotted black;
170 #results-table tr:last-child {
183 <button id="widget-markup-button">Widget</button>
184 <button id="queries-button">Queries</button>
188 <button id="results-table-button">Table</button>
189 <button id="results-csv-button">| delimited</button>
194 <header id="current-bar">
195 <span id="judiciary">
196 Relevant to query <span id="query"></span>?
197 <button id="yes" class="judgement">Yes</button>
198 <button id="no" class="judgement">No</button>
199 <button id="maybe" class="judgement">Maybe</button>
201 <span id="query-info">
202 <span id="count"></span>
206 <div id="widget-markup" class="dialog" title="Widget markup">
207 <textarea></textarea>
209 <div id="queries" class="dialog" title="Queries">
210 <textarea></textarea>
212 <div id="results-csv" class="dialog" title="| delimited results">
213 <textarea readonly></textarea>
215 <div id="results-table" class="dialog" title="Results as table">
220 <div id="test-subject"></div>
224 (function () { // wrapper
226 this.queries = ["sushi", "wurst", "berlin", "hammer", "bristol", "copenhagen", "tea", "latte"];
227 this.widgetMarkup = '<div class="mkws-reference" autosearch="{{query}}">Loading..</div>';
228 if (localStorage.getItem('mkwstest-queries')) {
229 this.queries = JSON.parse(localStorage.getItem('mkwstest-queries'));
231 if (localStorage.getItem('mkwstest-widget-markup')) {
232 this.widgetMarkup = localStorage.getItem('mkwstest-widget-markup');
234 $("#queries > textarea").html(this.queries.join("\n"));
235 $("#widget-markup > textarea").html(this.widgetMarkup);
239 if (localStorage.getItem('mkwstest-results')) {
240 this.results = JSON.parse(localStorage.getItem('mkwstest-results'));
242 if (localStorage.getItem('mkwstest-next') !== null) {
243 next = parseInt(localStorage.getItem('mkwstest-next'));
248 var showNext = function () {
249 if (next < this.queries.length) {
250 $('#test-subject').html(this.widgetMarkup.replace("{{query}}", this.queries[next]));
251 $('#query').html('"' + this.queries[next] + '"');
252 localStorage.setItem("mkwstest-next", next);
254 $('#count').html(next + " / " + this.queries.length);
255 mkws.init('#test-subject');
257 $("#results-table").dialog("open");
260 var startEval = function () {
261 $(".dialog").dialog("close");
263 context.results = {};
266 var judge = function (e) {
267 var query = $('#test-subject > div').attr('autosearch');
268 context.results[query] = {judgement: $(this).html()};
269 localStorage.setItem("mkwstest-results", JSON.stringify(context.results));
274 $(".dialog").dialog({
279 open: function(event, ui) {
280 $(this).parent().css('position', 'fixed');
285 var updateMarkup = function () {
286 context.widgetMarkup = $("#widget-markup > textarea").val();
287 localStorage.setItem("mkwstest-widget-markup", context.widgetMarkup);
290 $("#widget-markup-button").click(function () {
291 $("#widget-markup").dialog("open");
293 $("#widget-markup").dialog("option", "buttons", [
294 {text: "Start new evaluation", click: updateMarkup},
295 {text: "Cancel", click: function() { $(this).dialog("close"); }}
299 var updateQueries = function () {
300 context.queries = $("#queries > textarea").val().split("\n");
301 localStorage.setItem("mkwstest-queries", JSON.stringify(context.queries));
304 $("#queries-button").click(function () {
305 $("#queries").dialog("open");
307 $("#queries").dialog("option", "buttons", [
308 {text: "Start new evaluation", click: updateQueries},
309 {text: "Cancel", click: function() { $(this).dialog("close"); }}
313 $("#results-table-button").click(function () {
314 $("#results-table").dialog("open");
316 $("#results-csv-button").click(function () {
317 $("#results-csv").dialog("open");
319 $("#results-table").dialog("option", "open", function () {
320 var html = "<tr><th>Query</th><th>Relevant?</th><tr>";
321 for (var i = 0; i < context.queries.length; i++) {
322 var q = context.queries[i];
323 var r = context.results;
325 html += "<tr><td>" + q + "</td><td>" + r[q].judgement + "</td></tr>\n";
328 $("#results-table > table").html(html);
330 $("#results-csv").dialog("option", "open", function () {
331 var csv = "Query|Relevant?\n";
332 for (var i = 0; i < context.queries.length; i++) {
333 var q = context.queries[i];
334 var r = context.results;
336 csv += [q, r[q].judgement].join("|") + "\n";
339 $("#results-csv > textarea").html(csv);
342 $('button.judgement').click(judge);