Changeset 18 for src/main/webapp/utilstable.xhtml
- Timestamp:
- 09/22/20 16:26:52 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/webapp/utilstable.xhtml
r16 r18 28 28 <tr> 29 29 <th align="center">run nr</th> 30 <th align="center">accepted bid </th>30 <th align="center">accepted bid(s)</th> 31 31 <th align="center">party utility - penalty</th> 32 32 </tr> … … 212 212 } 213 213 214 215 214 /** 215 @return true if object1, object2 are 'deep equal'. That means, 216 if they are dicts then we check that the keys and their values are equal, 217 recursively. 218 */ 219 function deepEqual(object1, object2) { 220 const keys1 = Object.keys(object1); 221 const keys2 = Object.keys(object2); 222 223 if (keys1.length !== keys2.length) { 224 return false; 225 } 226 227 for (const key of keys1) { 228 const val1 = object1[key]; 229 const val2 = object2[key]; 230 const areObjects = isObject(val1) && isObject(val2); 231 if ( 232 areObjects && !deepEqual(val1, val2) || !areObjects && val1 !== val2 233 ) { 234 return false; 235 } 236 } 237 238 return true; 239 } 240 241 function isObject(object) { 242 return object != null && typeof object === 'object'; 243 } 244 245 /** 246 @param list the list to add value to 247 @param value the value to add 248 @return list with the value added, but only if not already in list. 249 Uses deepEqual to check equality of list members 250 */ 251 function addSet(list, value) { 252 for (const v of list) { 253 if (deepEqual(v, value)) 254 return list; 255 } 256 return list.concat(value); 257 } 216 258 217 259 /** … … 219 261 @param nr the row number 220 262 @param result a single json result from the APP results section. 221 Contains participants, agreement and error263 Contains participants, agreements and error 222 264 */ 223 265 function fillRow(row, nr, result) { … … 234 276 } 235 277 236 var agreedbid = result['agreement']; 237 row.insertCell(-1).innerHTML = (agreedbid==null?"none":JSON.stringify(agreedbid['issuevalues'])); 238 if (agreedbid==null) agreedbid = {}; 239 else agreedbid = agreedbid['issuevalues']; 278 // collect unique bids in agreements. 279 var agreements = result['agreements']; 280 var bids = []; 281 for (const pid in agreements) { 282 bids=addSet(bids, agreements[pid]['issuevalues']); 283 } 284 285 286 // a dict, keys are party ids. 287 // FIXME this does not work ok with MOPAC. 288 row.insertCell(-1).innerHTML = JSON.stringify(bids); 289 var agreedbid={}; 290 if (bids.length>0) agreedbid = bids[0]; 240 291 241 292 // fill in the columns. If SHAOP, only the even parties
Note:
See TracChangeset
for help on using the changeset viewer.