Changeset 12 for src/main/webapp
- Timestamp:
- 04/28/20 12:57:03 (5 years ago)
- Location:
- src/main/webapp
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/webapp/WEB-INF/web.xml
r1 r12 5 5 <web-app> 6 6 <display-name>GeniusWeb Run Server</display-name> 7 8 <filter> 9 <filter-name>CorsFilter</filter-name> 10 <filter-class>org.apache.catalina.filters.CorsFilter</filter-class> 11 <init-param> 12 <param-name>cors.allowed.origins</param-name> 13 <param-value>*</param-value> 14 </init-param> 15 <init-param> 16 <param-name>cors.exposed.headers</param-name> 17 <param-value>Access-Control-Allow-Origin</param-value> 18 </init-param> 19 </filter> 20 <filter-mapping> 21 <filter-name>CorsFilter</filter-name> 22 <url-pattern>/*</url-pattern> 23 </filter-mapping> 7 24 8 25 <servlet> … … 27 44 <servlet-class>geniusweb.runserver.RunNego</servlet-class> 28 45 </servlet> 29 46 30 47 31 48 <servlet-mapping> -
src/main/webapp/newtournament.xhtml
r11 r12 4 4 <title>Profiles and Domains list</title> 5 5 <link rel="stylesheet" type="text/css" href="style.css" /> 6 7 6 </head> 8 7 <body onload="init()"> … … 20 19 <br /> 21 20 <br /> 22 <input type="number" id=" partiespersession" name="tentacles" min="2"23 max="10" value="2" /> Number of parties in each session24 <br /> 25 26 <input type="checkbox" id="reuse parties" /> Pick parties with return27 whencreating sessions21 <input type="number" id="teamspersession" name="tentacles" min="2" 22 max="10" value="2" /> Number of teams in each session 23 <br /> 24 25 <input type="checkbox" id="reuseteams" /> Pick teams with return when 26 creating sessions 28 27 <br /> 29 28 30 29 <br /> 31 30 <div id="box" class="box"> 32 Session Protocol settings <br /> Session Protocol: 33 <select id="protocolselection">31 Session Protocol settings <br /> Session Protocol: <select 32 id="protocolselection" onchange="selectProtocol()"> 34 33 <option value="SAOP">SAOP</option> 35 34 <option value="SHAOP">SHAOP</option> 36 </select> 37 38 <br /> Deadline: <input type="number" id="deadlinevalue" 35 </select> <br /> Deadline: <input type="number" id="deadlinevalue" 39 36 name="deadline" min="1" max="10000" value="10" /> <select 40 37 id="deadlinetype"> … … 46 43 47 44 <div id="box" class="box"> 48 <br /> Domain/Profile Server: <input type="url" name="url" 45 <h3>Profiles</h3> 46 Domain/Profile Server: <input type="url" name="url" 49 47 id="profilesserverurl" value="localhost:8080/profilesserver-1.3.1" 50 48 pattern=".*:[0-9]+/profilesserver" size="30" … … 53 51 <!-- <option>Waiting for profiles server</option> --> 54 52 </select> <br /> <br /> 55 <button onclick="addProfile()">Add</button> 56 Profile: <select id="profileselection"> 57 <!-- <option>Waiting for partiesserver</option> --> 58 </select> 59 Filter: <input type="text" id="filter" value="" maxlength="40" /> 60 53 <!-- first selected profile --> 54 Profile: <select id="profileselection1"> 55 </select> Filter: <input type="text" id="filter1" value="" maxlength="40" /> <br /> 56 <!-- second selected profile --> 57 <div class="onlySHAOP"> 58 COB: <select id="profileselection2"> 59 </select> Filter: <input type="text" id="filter2" value="" maxlength="40" /> 60 <br /> 61 </div> 62 <button onclick="addProfiles()">Add</button> 61 63 <br /> <br /> 62 63 64 <table id="profiles"> 64 65 <thead> … … 75 76 <br /> 76 77 <div id="box" class="box"> 78 <h3>Teams</h3> 77 79 <br /> Parties Server: <input type="url" name="url" 78 80 id="partiesserverurl" value="localhost:8080/partiesserver-1.3.1" 79 81 pattern=".*:[0-9]+/partiesserver" size="30" 80 82 onchange="connectParties()"> </input> <br /> <br /> 83 <!-- party 1 selection --> 81 84 Party: <select id="partyselection"> 82 <!-- <option>Waiting for partiesserver</option> --> 83 </select> <br /> Parameters: { <input type="text" id="parameters" 84 onchange="updateParameters()" value="" maxlength="100" /> } <br /> 85 <button onclick="addParty()">Add</button> 86 85 </select> Parameters: { <input type="text" id="parameters" 86 onchange="getParameters('parameters')" value="" maxlength="100" /> } 87 <br /> 88 <!-- party 2 selection --> 89 <div class="onlySHAOP"> 90 COB: <select id="partyselection2"> 91 </select> Parameters: { <input type="text" id="parameters2" 92 onchange="getParameters('parameters2')" value="" maxlength="100" /> 93 } 94 </div> 95 <br /> 96 97 98 <button onclick="addTeam()">Add</button> 99 87 100 <br /> <br /> 88 101 <table> … … 90 103 <th align="left">Party</th> 91 104 <th align="left">Parameters</th> 105 <th align="left"><div class="onlySHAOP">Compare Bids Party</div></th> 106 <th align="left"><div class="onlySHAOP">Compare Bids Parameters</div></th> 92 107 </thead> 93 <tbody id=" partiesList">94 <tr id=" partiesList">108 <tbody id="teamList"> 109 <tr id="FIXME REMOVE"> 95 110 </tr> 96 111 … … 106 121 <div id="started" style="visibility: hidden"> 107 122 Your tournament started. Click <a href="" id="logref">here</a> to view 108 the log file. <br /> 109 <a href="" id="plotref">show results table.</a>. 123 the log file. <br /> <a href="" id="plotref">show results table.</a>. 110 124 </div> 111 125 … … 113 127 114 128 <script type="application/javascript"> 129 130 131 132 133 134 135 136 115 137 116 138 … … 144 166 var knowndomains={}; 145 167 146 var parties=[];168 var teamslist=[]; 147 169 var profiles=[] 148 // current setting of parameters 149 var parameters = {}; 150 151 170 171 /** 172 called when user changes the protocol. 173 With SHAOP we show COB selectors and COB columns in the tables. 174 */ 175 function selectProtocol() { 176 const isShaop= "SHAOP"==document.getElementById("protocolselection").value; 177 setStyleSheet('.onlySHAOP','{ display: '+(isShaop? '?':'none')+'; }') 178 } 179 180 /** 181 Change style sheet to new value. Nothing happens if there is 182 no style sheet with given classname. 183 @param classname the name of the style definition, eg '.onlySHAOP' 184 @param style the new style for the class. eg '{ max-width: 100px; }' 185 */ 186 function setStyleSheet(classname, style) { 187 for (var cssRulenr=0; cssRulenr< document.styleSheets.length; cssRulenr++) { 188 var cssRule = document.styleSheets[cssRulenr]; 189 // there may be multple CSS definitions, check each. 190 var rules = cssRule.cssRules; 191 for (var rulenr=0; rulenr<rules.length; rulenr++) { 192 var rule = rules[rulenr]; 193 if ('selectorText' in rule && rule.selectorText==classname) { 194 cssRule.deleteRule(rulenr); 195 cssRule.insertRule(classname+ " "+style, rulenr); 196 } 197 } 198 } 199 } 200 152 201 /** 153 202 Refresh known domains using given profilesserver URL. … … 233 282 } 234 283 235 284 /** 285 @param parties a new list of parties available on the parties server 286 */ 236 287 function updateParties(parties) { 237 var combobox = document.getElementById("partyselection"); 288 updatePartyCombo(document.getElementById("partyselection"), parties, 'shaop'); 289 updatePartyCombo(document.getElementById("partyselection2"), parties, 'comparebids'); 290 } 291 292 /** 293 put the available parties in the party comboboxes. 294 @param combobox a document <select> element 295 @param parties a dict of party information coming from the partiesserver 296 @param select a string that may be a substring of the part names. 297 @return the combobox value that contains 'select' as substring, or undefined 298 */ 299 function updatePartyCombo(combobox, parties, select) { 300 var selection=undefined; 238 301 combobox.options.length=0; 239 302 for (var party in parties) { 240 303 var option = document.createElement('option'); 241 304 option.text = option.value = parties[party].uri; 305 if (option.text.includes(select) ) option.selected=true; 242 306 combobox.add(option, 0); 243 307 } 308 return selection; 244 309 } 245 310 246 311 247 312 248 313 /** 249 updates parameters field to match the given text. 314 @param elementname eg "parameters", the ID of the element in the <input> element 315 @return the JSON parsed object, or {} if empty or parsing fails. 250 316 */ 251 function updateParameters() {252 var text="{"+document.getElementById( "parameters").value+"}";317 function getParameters(elementname) { 318 var text="{"+document.getElementById(elementname).value+"}"; 253 319 try { 254 parameters=JSON.parse(text);320 return JSON.parse(text); 255 321 } catch(e) { 256 alert("Parameters can not be parsed. "+e); 257 return; 322 alert("Parameters can not be parsed. Make sure you write correct JSON here."+e); 258 323 } 259 } 324 return {}; 325 } 260 326 261 327 /** … … 269 335 if (domaincombobox.options.length==0) return; // fixme clean profiles options? 270 336 var domain = domaincombobox.options[domaincombobox.selectedIndex].value; 271 272 var profilecombo = document.getElementById("profileselection"); 337 updateProfiles(knowndomains[domain]) 338 } 339 340 function updateProfiles(profileslist) { 341 updateProfileCombo(document.getElementById("profileselection1"),profileslist); 342 updateProfileCombo(document.getElementById("profileselection2"),profileslist); 343 } 344 345 /** 346 @param combobox the <select> element that should be udpated 347 @param profileslist the list of profile names to be put in the combbo 348 */ 349 function updateProfileCombo(profilecombo, profileslist) { 273 350 profilecombo.options.length=0; 274 for (var profile in knowndomains[domain]) {351 for (var profile in profileslist) { 275 352 var option = document.createElement('option'); 276 option.text = option.value = knowndomains[domain][profile];353 option.text = option.value = profileslist[profile]; 277 354 profilecombo.add(option, 0); 278 355 } 279 356 } 280 357 358 281 359 /** 282 360 Called when user clicks "Add" 283 361 */ 284 function add Party() {362 function addTeam() { 285 363 var partycombo = document.getElementById("partyselection"); 364 var partycombo2 = document.getElementById("partyselection2"); 365 var param = getParameters("parameters"); 366 var param2 = getParameters("parameters2"); 367 286 368 287 369 if (partycombo.options.length==0) { … … 289 371 return; 290 372 } 291 parties.push({"partyref":partycombo.options[partycombo.selectedIndex].value, "parameters":parameters}) 292 updatePartyTable(); 293 } 294 295 /** updates the party table, to match the #partyprofiles list. */ 296 function updatePartyTable() { 297 var table = document.getElementById("partiesList"); 373 var team = []; 374 team.push({"partyref":partycombo.options[partycombo.selectedIndex].value, "parameters":param}); 375 team.push({"partyref":partycombo2.options[partycombo2.selectedIndex].value, "parameters":param2}); 376 377 teamslist.push(team); 378 updateTeamsTable(); 379 } 380 381 /** updates the teams table, to match the #partyprofiles list. */ 382 function updateTeamsTable() { 383 var table = document.getElementById("teamList"); 298 384 table.innerHTML = ""; // clear table 299 for ( var party in parties) {385 for ( const team of teamslist) { 300 386 var row = table.insertRow(-1); 301 var cell1 = row.insertCell(-1); 302 var cell2 = row.insertCell(-1); 303 cell1.innerHTML = parties[party]["partyref"]; 304 cell2.innerHTML = JSON.stringify(parties[party]["parameters"]); 305 } 306 307 } 308 309 /** 310 Called when user clicks "Add" to add a profile 311 */ 312 function addProfile() { 313 var profilecombo = document.getElementById("profileselection"); 314 387 for (const col in team) { 388 const party = team[col] 389 var cell1 = row.insertCell(-1); 390 var cell2 = row.insertCell(-1); 391 cell1.innerHTML = party["partyref"]; 392 cell2.innerHTML = JSON.stringify(party["parameters"]); 393 if (col>0) { 394 cell1.className = cell2.className = "onlySHAOP"; 395 } 396 397 } 398 } 399 400 selectProtocol(); // HACK we need to KEEP onlySHAOP elements hidden 401 } 402 403 /** 404 @param profilenr the profile nr, 1 for normal , 2 for cob profile 405 */ 406 function getProfile(profilenr) { 407 var profilecombo = document.getElementById("profileselection"+profilenr); 315 408 if (profilecombo.options.length==0) { 316 409 alert("Please set domain/profile server and select a domain and a profile"); 317 return;318 } 319 var filteroptions = document.getElementById("filter" ).value;410 throw "blabla"; 411 } 412 var filteroptions = document.getElementById("filter"+profilenr).value; 320 413 if (filteroptions!="") { 321 414 filteroptions="?"+filteroptions; 322 415 } 323 416 324 profiles.push(profilecombo.options[profilecombo.selectedIndex].value + filteroptions) 417 //return profilecombo.options[profilecombo.selectedIndex].value + filteroptions 418 return profilecombo.value + filteroptions 419 } 420 421 /** 422 Called when user clicks "Add" to add a profile set 423 */ 424 function addProfiles() { 425 profiles.push([getProfile(1), getProfile(2)]); 325 426 updateProfileTable(); // what, MVC? 326 427 } … … 330 431 var table = document.getElementById("profilesList"); 331 432 table.innerHTML = ""; // clear table 332 for ( var profile inprofiles) {433 for ( const profileset of profiles) { 333 434 var row = table.insertRow(-1); 334 var cell1 = row.insertCell(-1); 335 cell1.innerHTML = profiles[profile]; 336 } 337 435 for (var col in profileset) { 436 var profile = profileset[col]; 437 var cell1 = row.insertCell(-1); 438 cell1.innerHTML = profile; 439 if (col>0) cell1.className = "onlySHAOP" 440 } 441 } 442 selectProtocol(); // HACK we need to KEEP onlySHAOP elements hidden 338 443 } 339 444 … … 366 471 */ 367 472 function start() { 368 var npersession = document.getElementById("partiespersession").value;369 370 if ( parties.length < npersession || npersession <2) {371 alert("At least "+npersession+" parties are needed.");473 const npersession = document.getElementById("teamspersession").value; 474 475 if (teamslist.length < npersession) { 476 alert("At least "+npersession+" teams are needed."); 372 477 return; 373 478 } 374 479 375 480 if (profiles.length < npersession) { 376 alert("At least "+npersession+" profiles are needed.");481 alert("At least "+npersession+" profilesets are needed."); 377 482 return; 378 483 } … … 396 501 397 502 /** 398 @return a json request package containing a AllPermutationsSettings 503 @return a json request package containing a AllPermutationsSettings. 504 It assumes that global vars parties and sessionSettings have been set properly. 399 505 */ 400 506 function makeRequest() { 507 const npersession = document.getElementById("teamspersession").value; 508 const reuseTeams = document.getElementById("reuseteams").checked; 509 const protocolcombobox = document.getElementById("protocolselection"); 510 const protocol = protocolcombobox.options[protocolcombobox.selectedIndex].value; 511 const header=protocol+"Settings"; 512 401 513 var deadline={}; 402 varvalue = document.getElementById("deadlinevalue").value;403 vardtypecombo = document.getElementById("deadlinetype");514 const value = document.getElementById("deadlinevalue").value; 515 const dtypecombo = document.getElementById("deadlinetype"); 404 516 if (dtypecombo.options[dtypecombo.selectedIndex].value=="TIME") { 405 517 deadline["deadlinetime"] = { "durationms": 1000*value}; … … 408 520 deadline["deadlinerounds"] = {"rounds": value, "durationms": 10000}; 409 521 } 410 var reuseParties = document.getElementById("reuseparties").checked; 411 412 var protocolcombobox = document.getElementById("protocolselection"); 413 var protocol = protocolcombobox.options[protocolcombobox.selectedIndex].value; 414 var header=protocol+"Settings"; 415 522 416 523 // create S(H)AOPSettings. [header] is a weird ECMA script workaround for javascript issue. 417 var sessionSettings = { [header]:{"participants":[],"deadline":deadline}}; 418 return JSON.stringify({"AllPermutationsSettings":{"parties":parties,"profiles":profiles,"reuseParties":reuseParties,"partiesPerSession":2,"sessionsettings":sessionSettings}}); 524 const sessionSettings = { [header]:{"participants":[],"deadline":deadline}}; 525 526 var teamsFull = []; 527 for (const team of teamslist) { 528 if (protocol=="SAOP") // only first member of team is used. 529 teamsFull.push({"Team":[team[0]]}); 530 else 531 teamsFull.push({"Team":team}); 532 } 533 var profilesFull = [] ; 534 for (const profileset of profiles) { 535 if (protocol=="SAOP") // only first member of team is used. 536 profilesFull.push({"ProfileList":[profileset[0]]}); 537 else 538 profilesFull.push({"ProfileList":profileset}); 539 } 540 541 return JSON.stringify({"AllPermutationsSettings":{"teams":teamsFull,"profileslists":profilesFull, 542 "reuseTeams":reuseTeams,"teamsPerSession":npersession,"sessionsettings":sessionSettings}}); 419 543 } 420 544 … … 423 547 */ 424 548 function init() { 425 document.getElementById("partiesserverurl").value =window.location.hostname+":8080/partiesserver-1. 3.1";426 document.getElementById("profilesserverurl").value =window.location.hostname+":8080/profilesserver-1. 3.1";427 428 549 document.getElementById("partiesserverurl").value =window.location.hostname+":8080/partiesserver-1.4.0"; 550 document.getElementById("profilesserverurl").value =window.location.hostname+":8080/profilesserver-1.4.0"; 551 552 selectProtocol(); 429 553 connectDomain(); 430 554 connectParties(); … … 438 562 439 563 564 565 566 567 568 569 570 571 440 572 </script> 441 573 -
src/main/webapp/style.css
r8 r12 19 19 border: 1px solid black; 20 20 } 21 22 /* Used for elements that are visible only if SHAOP protocol selected. 23 This css is programmatically changed when protocol changes */ 24 .onlySHAOP { } -
src/main/webapp/utilstable.xhtml
r9 r12 78 78 Called when the page opens. 79 79 */ 80 function connect() {80 function init() { 81 81 82 82 var id=document.location.search; … … 124 124 } 125 125 126 getAllProfiles(json, json['toursettings']['AllPermutationsSettings']['profiles']); 126 // collect all profiles from all profileslists 127 var profiles= []; 128 for (const profilelist of json['toursettings']['AllPermutationsSettings']['profileslists']) { 129 profiles = profiles.concat(profilelist['ProfileList']); 130 } 131 getAllProfiles(json, profiles); 127 132 } 128 133 … … 369 374 370 375 371 372 373 </script>374 375 376 377 378 379 <script type="application/javascript">380 381 382 376 383 377 <![CDATA[ … … 393 387 noscripts[i].parentNode.removeChild(noscripts[i]); 394 388 } 395 connect();389 init(); 396 390 397 391 }, false); … … 399 393 400 394 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 395 </script> 418 396
Note:
See TracChangeset
for help on using the changeset viewer.