- Timestamp:
- Jan 10, 2017 3:37:39 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/htdocs/js/common.js
r65160 r65227 50 50 } 51 51 } 52 return false; 53 } 54 55 /** 56 * Checks if @a oMemmber is present in aoArray. 57 * 58 * @returns true/false. 59 * @param aoArray The array to check. 60 * @param oMember The member to check for. 61 */ 62 function isMemberOfArray(aoArray, oMember) 63 { 64 var i; 65 for (i = 0; i < aoArray.length; i++) 66 if (aoArray[i] == oMember) 67 return true; 52 68 return false; 53 69 } … … 199 215 } 200 216 217 /** 218 * Adds the given sorting options to the URL and reloads. 219 * 220 * This will preserve previous sorting columns except for those 221 * given in @a aiColumns. 222 * 223 * @param sParam Sorting parameter. 224 * @param aiColumns Array of sorting columns. 225 */ 226 function ahrefActionSortByColumns(sParam, aiColumns) 227 { 228 var sWhere = window.location.href; 229 230 var offHash = sWhere.indexOf('#'); 231 if (offHash < 0) 232 offHash = sWhere.length; 233 234 var offQm = sWhere.indexOf('?'); 235 if (offQm > offHash) 236 offQm = -1; 237 238 var sNew = ''; 239 if (offQm > 0) 240 sNew = sWhere.substring(0, offQm); 241 242 sNew += '?' + sParam + '=' + aiColumns[0]; 243 var i; 244 for (i = 1; i < aiColumns.length; i++) 245 sNew += '&' + sParam + '=' + aiColumns[i]; 246 247 if (offQm >= 0 && offQm + 1 < offHash) 248 { 249 var sArgs = '&' + sWhere.substring(offQm + 1, offHash); 250 var off = 0; 251 while (off < sArgs.length) 252 { 253 var offMatch = sArgs.indexOf('&' + sParam + '=', off); 254 if (offMatch >= 0) 255 { 256 if (off < offMatch) 257 sNew += sArgs.substring(off, offMatch); 258 259 var offValue = offMatch + 1 + sParam.length + 1; 260 offEnd = sArgs.indexOf('&', offValue); 261 if (offEnd < 0) 262 offEnd = sArgs.length; 263 264 var iColumn = parseInt(sArgs.substring(offValue, offEnd)); 265 if (!isMemberOfArray(aiColumns, iColumn) && !isMemberOfArray(aiColumns, -iColumn)) 266 sNew += sArgs.substring(off, offEnd); 267 268 off = offEnd; 269 } 270 else 271 { 272 sNew += sArgs.substring(off); 273 break; 274 } 275 } 276 } 277 278 if (offHash < sWhere.length) 279 sNew = sWhere.substr(offHash); 280 281 window.location.href = sNew; 282 } 201 283 202 284 /**
Note:
See TracChangeset
for help on using the changeset viewer.