VirtualBox

Ignore:
Timestamp:
May 26, 2016 8:04:05 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
107506
Message:

testmanager: give reason to failures (quick hack, can do prettier later).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testmanager/htdocs/js/common.js

    r56295 r61217  
    2727
    2828
     29/*********************************************************************************************************************************
     30*   Global Variables                                                                                                             *
     31*********************************************************************************************************************************/
     32/** Same as WuiDispatcherBase.ksParamRedirectTo. */
     33var g_ksParamRedirectTo = 'RedirectTo';
     34
    2935
    3036/**
     
    161167{
    162168    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 */
     176function 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);
    163199}
    164200
     
    266302
    267303}
     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 */
     313function 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 */
     327function 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
    268354
    269355
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette