Changeset 61217 in vbox for trunk/src/VBox/ValidationKit/testmanager/htdocs
- Timestamp:
- May 26, 2016 8:04:05 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 107506
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/htdocs/js/common.js
r56295 r61217 27 27 28 28 29 /********************************************************************************************************************************* 30 * Global Variables * 31 *********************************************************************************************************************************/ 32 /** Same as WuiDispatcherBase.ksParamRedirectTo. */ 33 var g_ksParamRedirectTo = 'RedirectTo'; 34 29 35 30 36 /** … … 161 167 { 162 168 return getUnscaledElementWidth(document.getElementById(sElementId)); 169 } 170 171 /** 172 * Gets the part of the URL needed for a RedirectTo parameter. 173 * 174 * @returns URL string. 175 */ 176 function getCurrentBrowerUrlPartForRedirectTo() 177 { 178 var sWhere = window.location.href; 179 var offTmp; 180 var offPathKeep; 181 182 /* Find the end of that URL 'path' component. */ 183 var offPathEnd = sWhere.indexOf('?'); 184 if (offPathEnd < 0) 185 offPathEnd = sWhere.indexOf('#'); 186 if (offPathEnd < 0) 187 offPathEnd = sWhere.length; 188 189 /* Go backwards from the end of the and find the start of the last component. */ 190 offPathKeep = sWhere.lastIndexOf("/", offPathEnd); 191 offTmp = sWhere.lastIndexOf(":", offPathEnd); 192 if (offPathKeep < offTmp) 193 offPathKeep = offTmp; 194 offTmp = sWhere.lastIndexOf("\\", offPathEnd); 195 if (offPathKeep < offTmp) 196 offPathKeep = offTmp; 197 198 return sWhere.substring(offPathKeep + 1); 163 199 } 164 200 … … 266 302 267 303 } 304 305 /** 306 * Adds the RedirecTo field with the current URL to the form. 307 * 308 * This is a 'onsubmit' action. 309 * 310 * @returns Returns success indicator (true/false). 311 * @param oForm The form being submitted. 312 */ 313 function addRedirectToInputFieldWithCurrentUrl(oForm) 314 { 315 /* Constant used here is duplicated in WuiDispatcherBase.ksParamRedirectTo */ 316 return addHiddenInputFieldToForm(oForm, 'RedirectTo', getCurrentBrowerUrlPartForRedirectTo(), null); 317 } 318 319 /** 320 * Adds the RedirecTo parameter to the href of the given anchor. 321 * 322 * This is a 'onclick' action. 323 * 324 * @returns Returns success indicator (true/false). 325 * @param oAnchor The anchor element being clicked on. 326 */ 327 function addRedirectToAnchorHref(oAnchor) 328 { 329 var sRedirectToParam = g_ksParamRedirectTo + '=' + encodeURIComponent(getCurrentBrowerUrlPartForRedirectTo()); 330 var sHref = oAnchor.href; 331 if (sHref.indexOf(sRedirectToParam) < 0) 332 { 333 var sHash; 334 var offHash = sHref.indexOf('#'); 335 if (offHash >= 0) 336 sHash = sHref.substring(offHash); 337 else 338 { 339 sHash = ''; 340 offHash = sHref.length; 341 } 342 sHref = sHref.substring(0, offHash) 343 if (sHref.indexOf('?') >= 0) 344 sHref += '&'; 345 else 346 sHref += '?'; 347 sHref += sRedirectToParam; 348 sHref += sHash; 349 oAnchor.href = sHref; 350 } 351 return true; 352 } 353 268 354 269 355
Note:
See TracChangeset
for help on using the changeset viewer.