http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/3c9a22b4/console/lib/KeyTable.js ---------------------------------------------------------------------- diff --git a/console/lib/KeyTable.js b/console/lib/KeyTable.js new file mode 100644 index 0000000..edcdb8a --- /dev/null +++ b/console/lib/KeyTable.js @@ -0,0 +1,1115 @@ +/* + * File: KeyTable.js + * Version: 1.1.7 + * CVS: $Idj$ + * Description: Keyboard navigation for HTML tables + * Author: Allan Jardine (www.sprymedia.co.uk) + * Created: Fri Mar 13 21:24:02 GMT 2009 + * Modified: $Date$ by $Author$ + * Language: Javascript + * License: GPL v2 or BSD 3 point style + * Project: Just a little bit of fun :-) + * Contact: www.sprymedia.co.uk/contact + * + * Copyright 2009-2011 Allan Jardine, all rights reserved. + * + * This source file is free software, under either the GPL v2 license or a + * BSD style license, available at: + * http://datatables.net/license_gpl2 + * http://datatables.net/license_bsd + */ + + +function KeyTable ( oInit ) +{ + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * API parameters + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + /* + * Variable: block + * Purpose: Flag whether or not KeyTable events should be processed + * Scope: KeyTable - public + */ + this.block = false; + + /* + * Variable: event + * Purpose: Container for all event application methods + * Scope: KeyTable - public + * Notes: This object contains all the public methods for adding and removing events - these + * are dynamically added later on + */ + this.event = { + "remove": {} + }; + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * API methods + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + /* + * Function: fnGetCurrentPosition + * Purpose: Get the currently focused cell's position + * Returns: array int: [ x, y ] + * Inputs: void + */ + this.fnGetCurrentPosition = function () + { + return [ _iOldX, _iOldY ]; + }; + + + /* + * Function: fnGetCurrentData + * Purpose: Get the currently focused cell's data (innerHTML) + * Returns: string: - data requested + * Inputs: void + */ + this.fnGetCurrentData = function () + { + return _nOldFocus.innerHTML; + }; + + + /* + * Function: fnGetCurrentTD + * Purpose: Get the currently focused cell + * Returns: node: - focused element + * Inputs: void + */ + this.fnGetCurrentTD = function () + { + return _nOldFocus; + }; + + + /* + * Function: fnSetPosition + * Purpose: Set the position of the focused cell + * Returns: - + * Inputs: int:x - x coordinate + * int:y - y coordinate + * Notes: Thanks to Rohan Daxini for the basis of this function + */ + this.fnSetPosition = function( x, y ) + { + if ( typeof x == 'object' && x.nodeName ) + { + _fnSetFocus( x ); + } + else + { + _fnSetFocus( _fnCellFromCoords(x, y) ); + } + }; + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Private parameters + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + /* + * Variable: _nBody + * Purpose: Body node of the table - cached for renference + * Scope: KeyTable - private + */ + var _nBody = null; + + /* + * Variable: + * Purpose: + * Scope: KeyTable - private + */ + var _nOldFocus = null; + + /* + * Variable: _iOldX and _iOldY + * Purpose: X and Y coords of the old elemet that was focused on + * Scope: KeyTable - private + */ + var _iOldX = null; + var _iOldY = null; + + /* + * Variable: _that + * Purpose: Scope saving for 'this' after a jQuery event + * Scope: KeyTable - private + */ + var _that = null; + + /* + * Variable: sFocusClass + * Purpose: Class that should be used for focusing on a cell + * Scope: KeyTable - private + */ + var _sFocusClass = "focus"; + + /* + * Variable: _bKeyCapture + * Purpose: Flag for should KeyTable capture key events or not + * Scope: KeyTable - private + */ + var _bKeyCapture = false; + + /* + * Variable: _oaoEvents + * Purpose: Event cache object, one array for each supported event for speed of searching + * Scope: KeyTable - private + */ + var _oaoEvents = { + "action": [], + "esc": [], + "focus": [], + "blur": [] + }; + + /* + * Variable: _oDatatable + * Purpose: DataTables object for if we are actually using a DataTables table + * Scope: KeyTable - private + */ + var _oDatatable = null; + + var _bForm; + var _nInput; + var _bInputFocused = false; + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Private methods + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Key table events + */ + + /* + * Function: _fnEventAddTemplate + * Purpose: Create a function (with closure for sKey) event addition API + * Returns: function: - template function + * Inputs: string:sKey - type of event to detect + */ + function _fnEventAddTemplate( sKey ) + { + /* + * Function: - + * Purpose: API function for adding event to cache + * Returns: - + * Inputs: 1. node:x - target node to add event for + * 2. function:y - callback function to apply + * or + * 1. int:x - x coord. of target cell (can be null for live events) + * 2. int:y - y coord. of target cell (can be null for live events) + * 3. function:z - callback function to apply + * Notes: This function is (interally) overloaded (in as much as javascript allows for + * that) - the target cell can be given by either node or coords. + */ + return function ( x, y, z ) { + if ( (x===null || typeof x == "number") && + (y===null || typeof y == "number") && + typeof z == "function" ) + { + _fnEventAdd( sKey, x, y, z ); + } + else if ( typeof x == "object" && typeof y == "function" ) + { + var aCoords = _fnCoordsFromCell( x ); + _fnEventAdd( sKey, aCoords[0], aCoords[1], y ); + } + else + { + alert( "Unhandable event type was added: x" +x+ " y:" +y+ " z:" +z ); + } + }; + } + + + /* + * Function: _fnEventRemoveTemplate + * Purpose: Create a function (with closure for sKey) event removal API + * Returns: function: - template function + * Inputs: string:sKey - type of event to detect + */ + function _fnEventRemoveTemplate( sKey ) + { + /* + * Function: - + * Purpose: API function for removing event from cache + * Returns: int: - number of events removed + * Inputs: 1. node:x - target node to remove event from + * 2. function:y - callback function to apply + * or + * 1. int:x - x coord. of target cell (can be null for live events) + * 2. int:y - y coord. of target cell (can be null for live events) + * 3. function:z - callback function to remove - optional + * Notes: This function is (interally) overloaded (in as much as javascript allows for + * that) - the target cell can be given by either node or coords and the function + * to remove is optional + */ + return function ( x, y, z ) { + if ( (x===null || typeof arguments[0] == "number") && + (y===null || typeof arguments[1] == "number" ) ) + { + if ( typeof arguments[2] == "function" ) + { + _fnEventRemove( sKey, x, y, z ); + } + else + { + _fnEventRemove( sKey, x, y ); + } + } + else if ( typeof arguments[0] == "object" ) + { + var aCoords = _fnCoordsFromCell( x ); + if ( typeof arguments[1] == "function" ) + { + _fnEventRemove( sKey, aCoords[0], aCoords[1], y ); + } + else + { + _fnEventRemove( sKey, aCoords[0], aCoords[1] ); + } + } + else + { + alert( "Unhandable event type was removed: x" +x+ " y:" +y+ " z:" +z ); + } + }; + } + + /* Use the template functions to add the event API functions */ + for ( var sKey in _oaoEvents ) + { + if ( sKey ) + { + this.event[sKey] = _fnEventAddTemplate( sKey ); + this.event.remove[sKey] = _fnEventRemoveTemplate( sKey ); + } + } + + + /* + * Function: _fnEventAdd + * Purpose: Add an event to the internal cache + * Returns: - + * Inputs: string:sType - type of event to add, given by the available elements in _oaoEvents + * int:x - x-coords to add event to - can be null for "blanket" event + * int:y - y-coords to add event to - can be null for "blanket" event + * function:fn - callback function for when triggered + */ + function _fnEventAdd( sType, x, y, fn ) + { + _oaoEvents[sType].push( { + "x": x, + "y": y, + "fn": fn + } ); + } + + + /* + * Function: _fnEventRemove + * Purpose: Remove an event from the event cache + * Returns: int: - number of matching events removed + * Inputs: string:sType - type of event to look for + * node:nTarget - target table cell + * function:fn - optional - remove this function. If not given all handlers of this + * type will be removed + */ + function _fnEventRemove( sType, x, y, fn ) + { + var iCorrector = 0; + + for ( var i=0, iLen=_oaoEvents[sType].length ; i<iLen-iCorrector ; i++ ) + { + if ( typeof fn != 'undefined' ) + { + if ( _oaoEvents[sType][i-iCorrector].x == x && + _oaoEvents[sType][i-iCorrector].y == y && + _oaoEvents[sType][i-iCorrector].fn == fn ) + { + _oaoEvents[sType].splice( i-iCorrector, 1 ); + iCorrector++; + } + } + else + { + if ( _oaoEvents[sType][i-iCorrector].x == x && + _oaoEvents[sType][i-iCorrector].y == y ) + { + _oaoEvents[sType].splice( i, 1 ); + return 1; + } + } + } + return iCorrector; + } + + + /* + * Function: _fnEventFire + * Purpose: Look thought the events cache and fire off the event of interest + * Returns: int:iFired - number of events fired + * Inputs: string:sType - type of event to look for + * int:x - x coord of cell + * int:y - y coord of ell + * Notes: It might be more efficient to return after the first event has been tirggered, + * but that would mean that only one function of a particular type can be + * subscribed to a particular node. + */ + function _fnEventFire ( sType, x, y ) + { + var iFired = 0; + var aEvents = _oaoEvents[sType]; + for ( var i=0 ; i<aEvents.length ; i++ ) + { + if ( (aEvents[i].x == x && aEvents[i].y == y ) || + (aEvents[i].x === null && aEvents[i].y == y ) || + (aEvents[i].x == x && aEvents[i].y === null ) || + (aEvents[i].x === null && aEvents[i].y === null ) + ) + { + aEvents[i].fn( _fnCellFromCoords(x,y), x, y ); + iFired++; + } + } + return iFired; + } + + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Focus functions + */ + + /* + * Function: _fnSetFocus + * Purpose: Set focus on a node, and remove from an old node if needed + * Returns: - + * Inputs: node:nTarget - node we want to focus on + * bool:bAutoScroll - optional - should we scroll the view port to the display + */ + function _fnSetFocus( nTarget, bAutoScroll ) + { + /* If node already has focus, just ignore this call */ + if ( _nOldFocus == nTarget ) + { + return; + } + + if ( typeof bAutoScroll == 'undefined' ) + { + bAutoScroll = true; + } + + /* Remove old focus (with blur event if needed) */ + if ( _nOldFocus !== null ) + { + _fnRemoveFocus( _nOldFocus ); + } + + /* Add the new class to highlight the focused cell */ + jQuery(nTarget).addClass( _sFocusClass ); + jQuery(nTarget).parent().addClass( _sFocusClass ); + + /* If it's a DataTable then we need to jump the paging to the relevant page */ + var oSettings; + if ( _oDatatable ) + { + oSettings = _oDatatable.fnSettings(); + var cell = _fnFindDtCell( nTarget ); + if (cell === null) { + return; + } + var iRow = cell[1]; + var bKeyCaptureCache = _bKeyCapture; + + /* Page forwards */ + while ( iRow >= oSettings.fnDisplayEnd() ) + { + if ( oSettings._iDisplayLength >= 0 ) + { + /* Make sure we are not over running the display array */ + if ( oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay() ) + { + oSettings._iDisplayStart += oSettings._iDisplayLength; + } + } + else + { + oSettings._iDisplayStart = 0; + } + _oDatatable.oApi._fnCalculateEnd( oSettings ); + } + + /* Page backwards */ + while ( iRow < oSettings._iDisplayStart ) + { + oSettings._iDisplayStart = oSettings._iDisplayLength>=0 ? + oSettings._iDisplayStart - oSettings._iDisplayLength : + 0; + + if ( oSettings._iDisplayStart < 0 ) + { + oSettings._iDisplayStart = 0; + } + _oDatatable.oApi._fnCalculateEnd( oSettings ); + } + + /* Re-draw the table */ + _oDatatable.oApi._fnDraw( oSettings ); + + /* Restore the key capture */ + _bKeyCapture = bKeyCaptureCache; + } + + /* Cache the information that we are interested in */ + var aNewPos = _fnCoordsFromCell( nTarget ); + _nOldFocus = nTarget; + _iOldX = aNewPos[0]; + _iOldY = aNewPos[1]; + + var iViewportHeight, iViewportWidth, iScrollTop, iScrollLeft, iHeight, iWidth, aiPos; + if ( bAutoScroll ) + { + /* Scroll the viewport such that the new cell is fully visible in the rendered window */ + iViewportHeight = document.documentElement.clientHeight; + iViewportWidth = document.documentElement.clientWidth; + iScrollTop = document.body.scrollTop || document.documentElement.scrollTop; + iScrollLeft = document.body.scrollLeft || document.documentElement.scrollLeft; + iHeight = nTarget.offsetHeight; + iWidth = nTarget.offsetWidth; + aiPos = _fnGetPos( nTarget ); + + /* Take account of scrolling in DataTables 1.7 - remove scrolling since that would add to + * the positioning calculation + */ + if ( _oDatatable && typeof oSettings.oScroll != 'undefined' && + (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") ) + { + aiPos[1] -= $(oSettings.nTable.parentNode).scrollTop(); + aiPos[0] -= $(oSettings.nTable.parentNode).scrollLeft(); + } + + /* Correct viewport positioning for vertical scrolling */ + if ( aiPos[1]+iHeight > iScrollTop+iViewportHeight ) + { + /* Displayed element if off the bottom of the viewport */ + _fnSetScrollTop( aiPos[1]+iHeight - iViewportHeight ); + } + else if ( aiPos[1] < iScrollTop ) + { + /* Displayed element if off the top of the viewport */ + _fnSetScrollTop( aiPos[1] ); + } + + /* Correct viewport positioning for horizontal scrolling */ + if ( aiPos[0]+iWidth > iScrollLeft+iViewportWidth ) + { + /* Displayed element is off the bottom of the viewport */ + _fnSetScrollLeft( aiPos[0]+iWidth - iViewportWidth ); + } + else if ( aiPos[0] < iScrollLeft ) + { + /* Displayed element if off the Left of the viewport */ + _fnSetScrollLeft( aiPos[0] ); + } + } + + /* Take account of scrolling in DataTables 1.7 */ + if ( _oDatatable && typeof oSettings.oScroll != 'undefined' && + (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") ) + { + var dtScrollBody = oSettings.nTable.parentNode; + iViewportHeight = dtScrollBody.clientHeight; + iViewportWidth = dtScrollBody.clientWidth; + iScrollTop = dtScrollBody.scrollTop; + iScrollLeft = dtScrollBody.scrollLeft; + iHeight = nTarget.offsetHeight; + iWidth = nTarget.offsetWidth; + + /* Correct for vertical scrolling */ + if ( nTarget.offsetTop + iHeight > iViewportHeight+iScrollTop ) + { + dtScrollBody.scrollTop = (nTarget.offsetTop + iHeight) - iViewportHeight; + } + else if ( nTarget.offsetTop < iScrollTop ) + { + dtScrollBody.scrollTop = nTarget.offsetTop; + } + + /* Correct for horizontal scrolling */ + if ( nTarget.offsetLeft + iWidth > iViewportWidth+iScrollLeft ) + { + dtScrollBody.scrollLeft = (nTarget.offsetLeft + iWidth) - iViewportWidth; + } + else if ( nTarget.offsetLeft < iScrollLeft ) + { + dtScrollBody.scrollLeft = nTarget.offsetLeft; + } + } + + /* Focused - so we want to capture the keys */ + _fnCaptureKeys(); + + /* Fire of the focus event if there is one */ + _fnEventFire( "focus", _iOldX, _iOldY ); + } + + + /* + * Function: _fnBlur + * Purpose: Blur focus from the whole table + * Returns: - + * Inputs: - + */ + function _fnBlur() + { + _fnRemoveFocus( _nOldFocus ); + _iOldX = null; + _iOldY = null; + _nOldFocus = null; + _fnReleaseKeys(); + } + + + /* + * Function: _fnRemoveFocus + * Purpose: Remove focus from a cell and fire any blur events which are attached + * Returns: - + * Inputs: node:nTarget - cell of interest + */ + function _fnRemoveFocus( nTarget ) + { + jQuery(nTarget).removeClass( _sFocusClass ); + jQuery(nTarget).parent().removeClass( _sFocusClass ); + _fnEventFire( "blur", _iOldX, _iOldY ); + } + + + /* + * Function: _fnClick + * Purpose: Focus on the element that has been clicked on by the user + * Returns: - + * Inputs: event:e - click event + */ + function _fnClick ( e ) + { + var nTarget = this; + while ( nTarget.nodeName != "TD" ) + { + nTarget = nTarget.parentNode; + } + + _fnSetFocus( nTarget ); + _fnCaptureKeys(); + } + + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Key events + */ + + /* + * Function: _fnKey + * Purpose: Deal with a key events, be it moving the focus or return etc. + * Returns: bool: - allow browser default action + * Inputs: event:e - key event + */ + function _fnKey ( e ) + { + /* If user or system has blocked KeyTable from doing anything, just ignore this event */ + if ( _that.block || !_bKeyCapture ) + { + return true; + } + + /* If a modifier key is pressed (exapct shift), ignore the event */ + if ( e.metaKey || e.altKey || e.ctrlKey ) + { + return true; + } + var + x, y, + iTableWidth = _nBody.getElementsByTagName('tr')[0].getElementsByTagName('td').length, + iTableHeight; + + /* Get table height and width - done here so as to be dynamic (if table is updated) */ + if ( _oDatatable ) + { + /* + * Locate the current node in the DataTable overriding the old positions - the reason for + * is is that there might have been some DataTables interaction between the last focus and + * now + */ + var oSettings = _oDatatable.fnSettings(); + iTableHeight = oSettings.aiDisplay.length; + + var aDtPos = _fnFindDtCell( _nOldFocus ); + if ( aDtPos === null ) + { + /* If the table has been updated such that the focused cell can't be seen - do nothing */ + return; + } + _iOldX = aDtPos[ 0 ]; + _iOldY = aDtPos[ 1 ]; + } + else + { + iTableHeight = _nBody.getElementsByTagName('tr').length; + } + + /* Capture shift+tab to match the left arrow key */ + var iKey = (e.keyCode == 9 && e.shiftKey) ? -1 : e.keyCode; + + switch( iKey ) + { + case 13: /* return */ + e.preventDefault(); + e.stopPropagation(); + _fnEventFire( "action", _iOldX, _iOldY ); + return true; + + case 27: /* esc */ + if ( !_fnEventFire( "esc", _iOldX, _iOldY ) ) + { + /* Only lose focus if there isn't an escape handler on the cell */ + _fnBlur(); + return; + } + x = _iOldX; + y = _iOldY; + break; + + case -1: + case 37: /* left arrow */ + if ( _iOldX > 0 ) { + x = _iOldX - 1; + y = _iOldY; + } else if ( _iOldY > 0 ) { + x = iTableWidth-1; + y = _iOldY - 1; + } else { + /* at start of table */ + if ( iKey == -1 && _bForm ) + { + /* If we are in a form, return focus to the 'input' element such that tabbing will + * follow correctly in the browser + */ + _bInputFocused = true; + _nInput.focus(); + + /* This timeout is a little nasty - but IE appears to have some asyhnc behaviour for + * focus + */ + setTimeout( function(){ _bInputFocused = false; }, 0 ); + _bKeyCapture = false; + _fnBlur(); + return true; + } + else + { + return false; + } + } + break; + + case 38: /* up arrow */ + if ( _iOldY > 0 ) { + x = _iOldX; + y = _iOldY - 1; + } else { + return false; + } + break; + + case 9: /* tab */ + case 39: /* right arrow */ + if ( _iOldX < iTableWidth-1 ) { + x = _iOldX + 1; + y = _iOldY; + } else if ( _iOldY < iTableHeight-1 ) { + x = 0; + y = _iOldY + 1; + } else { + /* at end of table */ + if ( iKey == 9 && _bForm ) + { + /* If we are in a form, return focus to the 'input' element such that tabbing will + * follow correctly in the browser + */ + _bInputFocused = true; + _nInput.focus(); + + /* This timeout is a little nasty - but IE appears to have some asyhnc behaviour for + * focus + */ + setTimeout( function(){ _bInputFocused = false; }, 0 ); + _bKeyCapture = false; + _fnBlur(); + return true; + } + else + { + return false; + } + } + break; + + case 40: /* down arrow */ + if ( _iOldY < iTableHeight-1 ) { + x = _iOldX; + y = _iOldY + 1; + } else { + return false; + } + break; + + default: /* Nothing we are interested in */ + return true; + } + + _fnSetFocus( _fnCellFromCoords(x, y) ); + return false; + } + + + /* + * Function: _fnCaptureKeys + * Purpose: Start capturing key events for this table + * Returns: - + * Inputs: - + */ + function _fnCaptureKeys( ) + { + if ( !_bKeyCapture ) + { + _bKeyCapture = true; + } + } + + + /* + * Function: _fnReleaseKeys + * Purpose: Stop capturing key events for this table + * Returns: - + * Inputs: - + */ + function _fnReleaseKeys( ) + { + _bKeyCapture = false; + } + + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Support functions + */ + + /* + * Function: _fnCellFromCoords + * Purpose: Calulate the target TD cell from x and y coordinates + * Returns: node: - TD target + * Inputs: int:x - x coordinate + * int:y - y coordinate + */ + function _fnCellFromCoords( x, y ) + { + if ( _oDatatable ) + { + var oSettings = _oDatatable.fnSettings(); + if ( typeof oSettings.aoData[ oSettings.aiDisplay[ y ] ] != 'undefined' ) + { + return oSettings.aoData[ oSettings.aiDisplay[ y ] ].nTr.getElementsByTagName('td')[x]; + } + else + { + return null; + } + } + else + { + return jQuery('tr:eq('+y+')>td:eq('+x+')', _nBody )[0]; + } + } + + + /* + * Function: _fnCoordsFromCell + * Purpose: Calculate the x and y position in a table from a TD cell + * Returns: array[2] int: [x, y] + * Inputs: node:n - TD cell of interest + * Notes: Not actually interested in this for DataTables since it might go out of date + */ + function _fnCoordsFromCell( n ) + { + if ( _oDatatable ) + { + var oSettings = _oDatatable.fnSettings(); + return [ + jQuery('td', n.parentNode).index(n), + jQuery('tr', n.parentNode.parentNode).index(n.parentNode) + oSettings._iDisplayStart + ]; + } + else + { + return [ + jQuery('td', n.parentNode).index(n), + jQuery('tr', n.parentNode.parentNode).index(n.parentNode) + ]; + } + } + + + /* + * Function: _fnSetScrollTop + * Purpose: Set the vertical scrolling position + * Returns: - + * Inputs: int:iPos - scrolltop + * Notes: This is so nasty, but without browser detection you can't tell which you should set + * So on browsers that support both, the scroll top will be set twice. I can live with + * that :-) + */ + function _fnSetScrollTop( iPos ) + { + document.documentElement.scrollTop = iPos; + document.body.scrollTop = iPos; + } + + + /* + * Function: _fnSetScrollLeft + * Purpose: Set the horizontal scrolling position + * Returns: - + * Inputs: int:iPos - scrollleft + */ + function _fnSetScrollLeft( iPos ) + { + document.documentElement.scrollLeft = iPos; + document.body.scrollLeft = iPos; + } + + + /* + * Function: _fnGetPos + * Purpose: Get the position of an object on the rendered page + * Returns: array[2] int: [left, right] + * Inputs: node:obj - element of interest + */ + function _fnGetPos ( obj ) + { + var iLeft = 0; + var iTop = 0; + + if (obj.offsetParent) + { + iLeft = obj.offsetLeft; + iTop = obj.offsetTop; + obj = obj.offsetParent; + while (obj) + { + iLeft += obj.offsetLeft; + iTop += obj.offsetTop; + obj = obj.offsetParent; + } + } + return [iLeft,iTop]; + } + + + /* + * Function: _fnFindDtCell + * Purpose: Get the coords. of a cell from the DataTables internal information + * Returns: array[2] int: [x, y] coords. or null if not found + * Inputs: node:nTarget - the node of interest + */ + function _fnFindDtCell( nTarget ) + { + var oSettings = _oDatatable.fnSettings(); + for ( var i=0, iLen=oSettings.aiDisplay.length ; i<iLen ; i++ ) + { + var nTr = oSettings.aoData[ oSettings.aiDisplay[i] ].nTr; + var nTds = nTr.getElementsByTagName('td'); + for ( var j=0, jLen=nTds.length ; j<jLen ; j++ ) + { + if ( nTds[j] == nTarget ) + { + return [ j, i ]; + } + } + } + return null; + } + + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Initialisation + */ + + /* + * Function: _fnInit + * Purpose: Initialise the KeyTable + * Returns: - + * Inputs: object:oInit - optional - Initalisation object with the following parameters: + * array[2] int:focus - x and y coordinates of the initial target + * or + * node:focus - the node to set initial focus on + * node:table - the table to use, if not given, first table with class 'KeyTable' will be used + * string:focusClass - focusing class to give to table elements + * object:that - focus + * bool:initScroll - scroll the view port on load, default true + * int:tabIndex - the tab index to give the hidden input element + */ + function _fnInit( oInit, that ) + { + /* Save scope */ + _that = that; + + /* Capture undefined initialisation and apply the defaults */ + if ( typeof oInit == 'undefined' ) { + oInit = {}; + } + + if ( typeof oInit.focus == 'undefined' ) { + oInit.focus = [0,0]; + } + + if ( typeof oInit.table == 'undefined' ) { + oInit.table = jQuery('table.KeyTable')[0]; + } else { + $(oInit.table).addClass('KeyTable'); + } + + if ( typeof oInit.focusClass != 'undefined' ) { + _sFocusClass = oInit.focusClass; + } + + if ( typeof oInit.datatable != 'undefined' ) { + _oDatatable = oInit.datatable; + } + + if ( typeof oInit.initScroll == 'undefined' ) { + oInit.initScroll = true; + } + + if ( typeof oInit.form == 'undefined' ) { + oInit.form = false; + } + _bForm = oInit.form; + + /* Cache the tbody node of interest */ + _nBody = oInit.table.getElementsByTagName('tbody')[0]; + + /* If the table is inside a form, then we need a hidden input box which can be used by the + * browser to catch the browser tabbing for our table + */ + if ( _bForm ) + { + var nDiv = document.createElement('div'); + _nInput = document.createElement('input'); + nDiv.style.height = "1px"; /* Opera requires a little something */ + nDiv.style.width = "0px"; + nDiv.style.overflow = "hidden"; + if ( typeof oInit.tabIndex != 'undefined' ) + { + _nInput.tabIndex = oInit.tabIndex; + } + nDiv.appendChild(_nInput); + oInit.table.parentNode.insertBefore( nDiv, oInit.table.nextSibling ); + + jQuery(_nInput).focus( function () { + /* See if we want to 'tab into' the table or out */ + if ( !_bInputFocused ) + { + _bKeyCapture = true; + _bInputFocused = false; + if ( typeof oInit.focus.nodeName != "undefined" ) + { + _fnSetFocus( oInit.focus, oInit.initScroll ); + } + else + { + _fnSetFocus( _fnCellFromCoords( oInit.focus[0], oInit.focus[1]), oInit.initScroll ); + } + + /* Need to interup the thread for this to work */ + setTimeout( function() { _nInput.blur(); }, 0 ); + } + } ); + _bKeyCapture = false; + } + else + { + /* Set the initial focus on the table */ + if ( typeof oInit.focus.nodeName != "undefined" ) + { + _fnSetFocus( oInit.focus, oInit.initScroll ); + } + else + { + _fnSetFocus( _fnCellFromCoords( oInit.focus[0], oInit.focus[1]), oInit.initScroll ); + } + _fnCaptureKeys(); + } + + /* + * Add event listeners + * Well - I hate myself for doing this, but it would appear that key events in browsers are + * a complete mess, particulay when you consider arrow keys, which of course are one of the + * main areas of interest here. So basically for arrow keys, there is no keypress event in + * Safari and IE, while there is in Firefox and Opera. But Firefox and Opera don't repeat the + * keydown event for an arrow key. OUCH. See the following two articles for more: + * http://www.quirksmode.org/dom/events/keys.html + * https://lists.webkit.org/pipermail/webkit-dev/2007-December/002992.html + * http://unixpapa.com/js/key.html + * PPK considers the IE / Safari method correct (good enough for me!) so we (urgh) detect + * Mozilla and Opera and apply keypress for them, while everything else gets keydown. If + * Mozilla or Opera change their implemention in future, this will need to be updated... + * although at the time of writing (14th March 2009) Minefield still uses the 3.0 behaviour. + */ + if ( jQuery.browser.mozilla || jQuery.browser.opera ) + { + jQuery(document).bind( "keypress", _fnKey ); + } + else + { + jQuery(document).bind( "keydown", _fnKey ); + } + + if ( _oDatatable ) + { + jQuery('tbody td', _oDatatable.fnSettings().nTable).live( 'click', _fnClick ); + } + else + { + jQuery('td', _nBody).live( 'click', _fnClick ); + } + + /* Loose table focus when click outside the table */ + jQuery(document).click( function(e) { + var nTarget = e.target; + var bTableClick = false; + while ( nTarget ) + { + if ( nTarget == oInit.table ) + { + bTableClick = true; + break; + } + nTarget = nTarget.parentNode; + } + if ( !bTableClick ) + { + _fnBlur(); + } + } ); + } + + /* Initialise our new object */ + _fnInit( oInit, this ); +}
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/3c9a22b4/console/lib/KeyTable.min.js ---------------------------------------------------------------------- diff --git a/console/lib/KeyTable.min.js b/console/lib/KeyTable.min.js new file mode 100644 index 0000000..6a9c8f4 --- /dev/null +++ b/console/lib/KeyTable.min.js @@ -0,0 +1,27 @@ +/* + * File: KeyTable.min.js + * Version: 1.1.7 + * Author: Allan Jardine (www.sprymedia.co.uk) + * + * Copyright 2009-2011 Allan Jardine, all rights reserved. + * + * This source file is free software, under either the GPL v2 license or a + * BSD (3 point) style license, as supplied with this software. + * + * This source file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details. + */ +function KeyTable(n){function G(a){return function(d,c,j){(null===d||"number"==typeof d)&&(null===c||"number"==typeof c)&&"function"==typeof j?i[a].push({x:d,y:c,fn:j}):"object"==typeof d&&"function"==typeof c?(d=A(d),i[a].push({x:d[0],y:d[1],fn:c})):alert("Unhandable event type was added: x"+d+" y:"+c+" z:"+j)}}function H(a){return function(d,c,j){(null===d||"number"==typeof d)&&(null===c||"number"==typeof c)?"function"==typeof j?w(a,d,c,j):w(a,d,c):"object"==typeof d?(d=A(d),"function"==typeof c? +w(a,d[0],d[1],c):w(a,d[0],d[1])):alert("Unhandable event type was removed: x"+d+" y:"+c+" z:"+j)}}function w(a,d,c,j){for(var b=0,e=0,g=i[a].length;e<g-b;e++)if("undefined"!=typeof j)i[a][e-b].x==d&&(i[a][e-b].y==c&&i[a][e-b].fn==j)&&(i[a].splice(e-b,1),b++);else if(i[a][e-b].x==d&&i[a][e-b].y==c)return i[a].splice(e,1),1;return b}function x(a,d,c){for(var b=0,a=i[a],h=0;h<a.length;h++)if(a[h].x==d&&a[h].y==c||null===a[h].x&&a[h].y==c||a[h].x==d&&null===a[h].y||null===a[h].x&&null===a[h].y)a[h].fn(t(d, +c),d,c),b++;return b}function l(a,d){if(r!=a){"undefined"==typeof d&&(d=!0);null!==r&&B(r);jQuery(a).addClass(u);jQuery(a).parent().addClass(u);var c;if(k){c=k.fnSettings();for(var b=C(a)[1],h=o;b>=c.fnDisplayEnd();)0<=c._iDisplayLength?c._iDisplayStart+c._iDisplayLength<c.fnRecordsDisplay()&&(c._iDisplayStart+=c._iDisplayLength):c._iDisplayStart=0,k.oApi._fnCalculateEnd(c);for(;b<c._iDisplayStart;)c._iDisplayStart=0<=c._iDisplayLength?c._iDisplayStart-c._iDisplayLength:0,0>c._iDisplayStart&&(c._iDisplayStart= +0),k.oApi._fnCalculateEnd(c);k.oApi._fnDraw(c);o=h}b=A(a);r=a;m=b[0];g=b[1];var e,i,l,n,f;if(d){e=document.documentElement.clientHeight;b=document.documentElement.clientWidth;i=document.body.scrollTop||document.documentElement.scrollTop;h=document.body.scrollLeft||document.documentElement.scrollLeft;l=a.offsetHeight;n=a.offsetWidth;f=a;var p=0,q=0;if(f.offsetParent){p=f.offsetLeft;q=f.offsetTop;for(f=f.offsetParent;f;)p+=f.offsetLeft,q+=f.offsetTop,f=f.offsetParent}f=[p,q];if(k&&"undefined"!=typeof c.oScroll&& +(""!==c.oScroll.sX||""!==c.oScroll.sY))f[1]-=$(c.nTable.parentNode).scrollTop(),f[0]-=$(c.nTable.parentNode).scrollLeft();f[1]+l>i+e?(e=f[1]+l-e,document.documentElement.scrollTop=e,document.body.scrollTop=e):f[1]<i&&(e=f[1],document.documentElement.scrollTop=e,document.body.scrollTop=e);f[0]+n>h+b?(b=f[0]+n-b,document.documentElement.scrollLeft=b,document.body.scrollLeft=b):f[0]<h&&(b=f[0],document.documentElement.scrollLeft=b,document.body.scrollLeft=b)}if(k&&"undefined"!=typeof c.oScroll&&(""!== +c.oScroll.sX||""!==c.oScroll.sY))(c=c.nTable.parentNode,e=c.clientHeight,b=c.clientWidth,i=c.scrollTop,h=c.scrollLeft,l=a.offsetHeight,n=a.offsetWidth,a.offsetTop+l>e+i?c.scrollTop=a.offsetTop+l-e:a.offsetTop<i&&(c.scrollTop=a.offsetTop),a.offsetLeft+n>b+h)?c.scrollLeft=a.offsetLeft+n-b:a.offsetLeft<h&&(c.scrollLeft=a.offsetLeft);o||(o=!0);x("focus",m,g)}}function y(){B(r);r=g=m=null;o=!1}function B(a){jQuery(a).removeClass(u);jQuery(a).parent().removeClass(u);x("blur",m,g)}function D(){for(var a= +this;"TD"!=a.nodeName;)a=a.parentNode;l(a);o||(o=!0)}function E(a){if(F.block||!o||a.metaKey||a.altKey||a.ctrlKey)return!0;var b;b=v.getElementsByTagName("tr")[0].getElementsByTagName("td").length;var c;if(k){c=k.fnSettings().aiDisplay.length;var j=C(r);if(null===j)return;m=j[0];g=j[1]}else c=v.getElementsByTagName("tr").length;j=9==a.keyCode&&a.shiftKey?-1:a.keyCode;switch(j){case 13:return a.preventDefault(),a.stopPropagation(),x("action",m,g),!0;case 27:if(!x("esc",m,g)){y();return}a=m;b=g;break; +case -1:case 37:if(0<m)a=m-1,b=g;else if(0<g)a=b-1,b=g-1;else return-1==j&&z?(q=!0,p.focus(),setTimeout(function(){q=!1},0),o=!1,y(),!0):!1;break;case 38:if(0<g)a=m,b=g-1;else return!1;break;case 9:case 39:if(m<b-1)a=m+1,b=g;else if(g<c-1)a=0,b=g+1;else return 9==j&&z?(q=!0,p.focus(),setTimeout(function(){q=!1},0),o=!1,y(),!0):!1;break;case 40:if(g<c-1)a=m,b=g+1;else return!1;break;default:return!0}l(t(a,b));return!1}function t(a,b){if(k){var c=k.fnSettings();return"undefined"!=typeof c.aoData[c.aiDisplay[b]]? +c.aoData[c.aiDisplay[b]].nTr.getElementsByTagName("td")[a]:null}return jQuery("tr:eq("+b+")>td:eq("+a+")",v)[0]}function A(a){if(k){var b=k.fnSettings();return[jQuery("td",a.parentNode).index(a),jQuery("tr",a.parentNode.parentNode).index(a.parentNode)+b._iDisplayStart]}return[jQuery("td",a.parentNode).index(a),jQuery("tr",a.parentNode.parentNode).index(a.parentNode)]}function C(a){for(var b=k.fnSettings(),c=0,g=b.aiDisplay.length;c<g;c++)for(var h=b.aoData[b.aiDisplay[c]].nTr.getElementsByTagName("td"), +e=0,i=h.length;e<i;e++)if(h[e]==a)return[e,c];return null}this.block=!1;this.event={remove:{}};this.fnGetCurrentPosition=function(){return[m,g]};this.fnGetCurrentData=function(){return r.innerHTML};this.fnGetCurrentTD=function(){return r};this.fnSetPosition=function(a,b){"object"==typeof a&&a.nodeName?l(a):l(t(a,b))};var v=null,r=null,m=null,g=null,F=null,u="focus",o=!1,i={action:[],esc:[],focus:[],blur:[]},k=null,z,p,q=!1,s;for(s in i)s&&(this.event[s]=G(s),this.event.remove[s]=H(s));var b=n,F=this; +"undefined"==typeof b&&(b={});"undefined"==typeof b.focus&&(b.focus=[0,0]);"undefined"==typeof b.table?b.table=jQuery("table.KeyTable")[0]:$(b.table).addClass("KeyTable");"undefined"!=typeof b.focusClass&&(u=b.focusClass);"undefined"!=typeof b.datatable&&(k=b.datatable);"undefined"==typeof b.initScroll&&(b.initScroll=!0);"undefined"==typeof b.form&&(b.form=!1);z=b.form;v=b.table.getElementsByTagName("tbody")[0];z?(n=document.createElement("div"),p=document.createElement("input"),n.style.height="1px", +n.style.width="0px",n.style.overflow="hidden","undefined"!=typeof b.tabIndex&&(p.tabIndex=b.tabIndex),n.appendChild(p),b.table.parentNode.insertBefore(n,b.table.nextSibling),jQuery(p).focus(function(){if(!q){o=true;q=false;typeof b.focus.nodeName!="undefined"?l(b.focus,b.initScroll):l(t(b.focus[0],b.focus[1]),b.initScroll);setTimeout(function(){p.blur()},0)}}),o=!1):("undefined"!=typeof b.focus.nodeName?l(b.focus,b.initScroll):l(t(b.focus[0],b.focus[1]),b.initScroll),o||(o=!0));jQuery.browser.mozilla|| +jQuery.browser.opera?jQuery(document).bind("keypress",E):jQuery(document).bind("keydown",E);k?jQuery("tbody td",k.fnSettings().nTable).live("click",D):jQuery("td",v).live("click",D);jQuery(document).click(function(a){for(var a=a.target,d=false;a;){if(a==b.table){d=true;break}a=a.parentNode}d||y()})}; http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/3c9a22b4/console/lib/URI.js ---------------------------------------------------------------------- diff --git a/console/lib/URI.js b/console/lib/URI.js new file mode 100644 index 0000000..9f4a7dd --- /dev/null +++ b/console/lib/URI.js @@ -0,0 +1,85 @@ +/*! URI.js v1.14.0 http://medialize.github.io/URI.js/ */ +/* build contains: IPv6.js, punycode.js, SecondLevelDomains.js, URI.js, URITemplate.js */ +(function(f,m){"object"===typeof exports?module.exports=m():"function"===typeof define&&define.amd?define(m):f.IPv6=m(f)})(this,function(f){var m=f&&f.IPv6;return{best:function(g){g=g.toLowerCase().split(":");var h=g.length,c=8;""===g[0]&&""===g[1]&&""===g[2]?(g.shift(),g.shift()):""===g[0]&&""===g[1]?g.shift():""===g[h-1]&&""===g[h-2]&&g.pop();h=g.length;-1!==g[h-1].indexOf(".")&&(c=7);var l;for(l=0;l<h&&""!==g[l];l++);if(l<c)for(g.splice(l,1,"0000");g.length<c;)g.splice(l,0,"0000");for(l=0;l<c;l++){for(var h= +g[l].split(""),f=0;3>f;f++)if("0"===h[0]&&1<h.length)h.splice(0,1);else break;g[l]=h.join("")}var h=-1,m=f=0,k=-1,u=!1;for(l=0;l<c;l++)u?"0"===g[l]?m+=1:(u=!1,m>f&&(h=k,f=m)):"0"===g[l]&&(u=!0,k=l,m=1);m>f&&(h=k,f=m);1<f&&g.splice(h,f,"");h=g.length;c="";""===g[0]&&(c=":");for(l=0;l<h;l++){c+=g[l];if(l===h-1)break;c+=":"}""===g[h-1]&&(c+=":");return c},noConflict:function(){f.IPv6===this&&(f.IPv6=m);return this}}}); +(function(f){function m(c){throw RangeError(v[c]);}function g(c,a){for(var b=c.length;b--;)c[b]=a(c[b]);return c}function h(c,a){return g(c.split(s),a).join(".")}function c(c){for(var a=[],b=0,d=c.length,p,x;b<d;)p=c.charCodeAt(b++),55296<=p&&56319>=p&&b<d?(x=c.charCodeAt(b++),56320==(x&64512)?a.push(((p&1023)<<10)+(x&1023)+65536):(a.push(p),b--)):a.push(p);return a}function l(c){return g(c,function(a){var b="";65535<a&&(a-=65536,b+=y(a>>>10&1023|55296),a=56320|a&1023);return b+=y(a)}).join("")}function w(c, +a){return c+22+75*(26>c)-((0!=a)<<5)}function r(c,a,b){var d=0;c=b?t(c/700):c>>1;for(c+=t(c/a);455<c;d+=36)c=t(c/35);return t(d+36*c/(c+38))}function k(c){var a=[],b=c.length,d,p=0,x=128,e=72,k,g,f,h,u;k=c.lastIndexOf("-");0>k&&(k=0);for(g=0;g<k;++g)128<=c.charCodeAt(g)&&m("not-basic"),a.push(c.charCodeAt(g));for(k=0<k?k+1:0;k<b;){g=p;d=1;for(f=36;;f+=36){k>=b&&m("invalid-input");h=c.charCodeAt(k++);h=10>h-48?h-22:26>h-65?h-65:26>h-97?h-97:36;(36<=h||h>t((2147483647-p)/d))&&m("overflow");p+=h*d;u= +f<=e?1:f>=e+26?26:f-e;if(h<u)break;h=36-u;d>t(2147483647/h)&&m("overflow");d*=h}d=a.length+1;e=r(p-g,d,0==g);t(p/d)>2147483647-x&&m("overflow");x+=t(p/d);p%=d;a.splice(p++,0,x)}return l(a)}function u(e){var a,b,d,p,x,k,g,h,f,u=[],n,l,q;e=c(e);n=e.length;a=128;b=0;x=72;for(k=0;k<n;++k)f=e[k],128>f&&u.push(y(f));for((d=p=u.length)&&u.push("-");d<n;){g=2147483647;for(k=0;k<n;++k)f=e[k],f>=a&&f<g&&(g=f);l=d+1;g-a>t((2147483647-b)/l)&&m("overflow");b+=(g-a)*l;a=g;for(k=0;k<n;++k)if(f=e[k],f<a&&2147483647< +++b&&m("overflow"),f==a){h=b;for(g=36;;g+=36){f=g<=x?1:g>=x+26?26:g-x;if(h<f)break;q=h-f;h=36-f;u.push(y(w(f+q%h,0)));h=t(q/h)}u.push(y(w(h,0)));x=r(b,l,d==p);b=0;++d}++b;++a}return u.join("")}var A="object"==typeof exports&&exports,B="object"==typeof module&&module&&module.exports==A&&module,z="object"==typeof global&&global;if(z.global===z||z.window===z)f=z;var e,q=/^xn--/,n=/[^ -~]/,s=/\x2E|\u3002|\uFF0E|\uFF61/g,v={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)", +"invalid-input":"Invalid input"},t=Math.floor,y=String.fromCharCode,C;e={version:"1.2.3",ucs2:{decode:c,encode:l},decode:k,encode:u,toASCII:function(c){return h(c,function(a){return n.test(a)?"xn--"+u(a):a})},toUnicode:function(c){return h(c,function(a){return q.test(a)?k(a.slice(4).toLowerCase()):a})}};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return e});else if(A&&!A.nodeType)if(B)B.exports=e;else for(C in e)e.hasOwnProperty(C)&&(A[C]=e[C]);else f.punycode= +e})(this); +(function(f,m){"object"===typeof exports?module.exports=m():"function"===typeof define&&define.amd?define(m):f.SecondLevelDomains=m(f)})(this,function(f){var m=f&&f.SecondLevelDomains,g={list:{ac:" com gov mil net org ",ae:" ac co gov mil name net org pro sch ",af:" com edu gov net org ",al:" com edu gov mil net org ",ao:" co ed gv it og pb ",ar:" com edu gob gov int mil net org tur ",at:" ac co gv or ",au:" asn com csiro edu gov id net org ",ba:" co com edu gov mil net org rs unbi unmo unsa untz unze ",bb:" biz co com edu gov info net org store tv ", +bh:" biz cc com edu gov info net org ",bn:" com edu gov net org ",bo:" com edu gob gov int mil net org tv ",br:" adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ",bs:" com edu gov net org ",bz:" du et om ov rg ",ca:" ab bc mb nb nf nl ns nt nu on pe qc sk yk ",ck:" biz co edu gen gov info net org ", +cn:" ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ",co:" com edu gov mil net nom org ",cr:" ac c co ed fi go or sa ",cy:" ac biz com ekloges gov ltd name net org parliament press pro tm ","do":" art com edu gob gov mil net org sld web ",dz:" art asso com edu gov net org pol ",ec:" com edu fin gov info med mil net org pro ",eg:" com edu eun gov mil name net org sci ",er:" com edu gov ind mil net org rochest w ",es:" com edu gob nom org ", +et:" biz com edu gov info name net org ",fj:" ac biz com info mil name net org pro ",fk:" ac co gov net nom org ",fr:" asso com f gouv nom prd presse tm ",gg:" co net org ",gh:" com edu gov mil org ",gn:" ac com gov net org ",gr:" com edu gov mil net org ",gt:" com edu gob ind mil net org ",gu:" com edu gov net org ",hk:" com edu gov idv net org ",hu:" 2000 agrar bolt casino city co erotica erotika film forum games hotel info ingatlan jogasz konyvelo lakas media news org priv reklam sex shop sport suli szex tm tozsde utazas video ", +id:" ac co go mil net or sch web ",il:" ac co gov idf k12 muni net org ","in":" ac co edu ernet firm gen gov i ind mil net nic org res ",iq:" com edu gov i mil net org ",ir:" ac co dnssec gov i id net org sch ",it:" edu gov ",je:" co net org ",jo:" com edu gov mil name net org sch ",jp:" ac ad co ed go gr lg ne or ",ke:" ac co go info me mobi ne or sc ",kh:" com edu gov mil net org per ",ki:" biz com de edu gov info mob net org tel ",km:" asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ", +kn:" edu gov net org ",kr:" ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ",kw:" com edu gov net org ",ky:" com edu gov net org ",kz:" com edu gov mil net org ",lb:" com edu gov net org ",lk:" assn com edu gov grp hotel int ltd net ngo org sch soc web ",lr:" com edu gov net org ",lv:" asn com conf edu gov id mil net org ",ly:" com edu gov id med net org plc sch ",ma:" ac co gov m net org press ", +mc:" asso tm ",me:" ac co edu gov its net org priv ",mg:" com edu gov mil nom org prd tm ",mk:" com edu gov inf name net org pro ",ml:" com edu gov net org presse ",mn:" edu gov org ",mo:" com edu gov net org ",mt:" com edu gov net org ",mv:" aero biz com coop edu gov info int mil museum name net org pro ",mw:" ac co com coop edu gov int museum net org ",mx:" com edu gob net org ",my:" com edu gov mil name net org sch ",nf:" arts com firm info net other per rec store web ",ng:" biz com edu gov mil mobi name net org sch ", +ni:" ac co com edu gob mil net nom org ",np:" com edu gov mil net org ",nr:" biz com edu gov info net org ",om:" ac biz co com edu gov med mil museum net org pro sch ",pe:" com edu gob mil net nom org sld ",ph:" com edu gov i mil net ngo org ",pk:" biz com edu fam gob gok gon gop gos gov net org web ",pl:" art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ",pr:" ac biz com edu est gov info isla name net org pro prof ", +ps:" com edu gov net org plo sec ",pw:" belau co ed go ne or ",ro:" arts com firm info nom nt org rec store tm www ",rs:" ac co edu gov in org ",sb:" com edu gov net org ",sc:" com edu gov net org ",sh:" co com edu gov net nom org ",sl:" com edu gov net org ",st:" co com consulado edu embaixada gov mil net org principe saotome store ",sv:" com edu gob org red ",sz:" ac co org ",tr:" av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ",tt:" aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ", +tw:" club com ebiz edu game gov idv mil net org ",mu:" ac co com gov net or org ",mz:" ac co edu gov org ",na:" co com ",nz:" ac co cri geek gen govt health iwi maori mil net org parliament school ",pa:" abo ac com edu gob ing med net nom org sld ",pt:" com edu gov int net nome org publ ",py:" com edu gov mil net org ",qa:" com edu gov mil net org ",re:" asso com nom ",ru:" ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tu la tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ", +rw:" ac co com edu gouv gov int mil net ",sa:" com edu gov med net org pub sch ",sd:" com edu gov info med net org tv ",se:" a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ",sg:" com edu gov idn net org per ",sn:" art com edu gouv org perso univ ",sy:" com edu gov mil net news org ",th:" ac co go in mi net or ",tj:" ac biz co com edu go gov info int mil name net nic org test web ",tn:" agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ", +tz:" ac co go ne or ",ua:" biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ",ug:" ac co go ne or org sc ",uk:" ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ", +us:" dni fed isa kids nsn ",uy:" com edu gub mil net org ",ve:" co com edu gob info mil net org web ",vi:" co com k12 net org ",vn:" ac biz com edu gov health info int name net org pro ",ye:" co com gov ltd me net org plc ",yu:" ac co edu gov org ",za:" ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ",zm:" ac co com edu gov net org sch "},has:function(h){var c=h.lastIndexOf(".");if(0>=c||c>=h.length-1)return!1; +var f=h.lastIndexOf(".",c-1);if(0>=f||f>=c-1)return!1;var m=g.list[h.slice(c+1)];return m?0<=m.indexOf(" "+h.slice(f+1,c)+" "):!1},is:function(f){var c=f.lastIndexOf(".");if(0>=c||c>=f.length-1||0<=f.lastIndexOf(".",c-1))return!1;var l=g.list[f.slice(c+1)];return l?0<=l.indexOf(" "+f.slice(0,c)+" "):!1},get:function(f){var c=f.lastIndexOf(".");if(0>=c||c>=f.length-1)return null;var l=f.lastIndexOf(".",c-1);if(0>=l||l>=c-1)return null;var m=g.list[f.slice(c+1)];return!m||0>m.indexOf(" "+f.slice(l+ +1,c)+" ")?null:f.slice(l+1)},noConflict:function(){f.SecondLevelDomains===this&&(f.SecondLevelDomains=m);return this}};return g}); +(function(f,m){"object"===typeof exports?module.exports=m(require("./punycode"),require("./IPv6"),require("./SecondLevelDomains")):"function"===typeof define&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],m):f.URI=m(f.punycode,f.IPv6,f.SecondLevelDomains,f)})(this,function(f,m,g,h){function c(a,b){if(!(this instanceof c))return new c(a,b);void 0===a&&(a="undefined"!==typeof location?location.href+"":"");this.href(a);return void 0!==b?this.absoluteTo(b):this}function l(a){return a.replace(/([.*+?^=!:${}()|[\]\/\\])/g, +"\\$1")}function w(a){return void 0===a?"Undefined":String(Object.prototype.toString.call(a)).slice(8,-1)}function r(a){return"Array"===w(a)}function k(a,b){var d,c;if(r(b)){d=0;for(c=b.length;d<c;d++)if(!k(a,b[d]))return!1;return!0}var e=w(b);d=0;for(c=a.length;d<c;d++)if("RegExp"===e){if("string"===typeof a[d]&&a[d].match(b))return!0}else if(a[d]===b)return!0;return!1}function u(a,b){if(!r(a)||!r(b)||a.length!==b.length)return!1;a.sort();b.sort();for(var d=0,c=a.length;d<c;d++)if(a[d]!==b[d])return!1; +return!0}function A(a){return escape(a)}function B(a){return encodeURIComponent(a).replace(/[!'()*]/g,A).replace(/\*/g,"%2A")}var z=h&&h.URI;c.version="1.14.0";var e=c.prototype,q=Object.prototype.hasOwnProperty;c._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,duplicateQueryParameters:c.duplicateQueryParameters,escapeQuerySpace:c.escapeQuerySpace}};c.duplicateQueryParameters=!1;c.escapeQuerySpace=!0;c.protocol_expression= +/^[a-z][a-z0-9.+-]*$/i;c.idn_expression=/[^a-z0-9\.-]/i;c.punycode_expression=/(xn--)/i;c.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;c.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-F a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/; +c.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u2018\u2019]))/ig;c.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u201e\u2018\u2019]+$/};c.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"};c.invalid_hostname_characters= +/[^a-zA-Z0-9\.-]/;c.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src",audio:"src",video:"src"};c.getDomAttribute=function(a){if(a&&a.nodeName){var b=a.nodeName.toLowerCase();return"input"===b&&"image"!==a.type?void 0:c.domAttributes[b]}};c.encode=B;c.decode=decodeURIComponent;c.iso8859=function(){c.encode=escape;c.decode=unescape};c.unicode=function(){c.encode=B;c.decode= +decodeURIComponent};c.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/ig,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",", +"%3B":";","%3D":"="}}}};c.encodeQuery=function(a,b){var d=c.encode(a+"");void 0===b&&(b=c.escapeQuerySpace);return b?d.replace(/%20/g,"+"):d};c.decodeQuery=function(a,b){a+="";void 0===b&&(b=c.escapeQuerySpace);try{return c.decode(b?a.replace(/\+/g,"%20"):a)}catch(d){return a}};c.recodePath=function(a){a=(a+"").split("/");for(var b=0,d=a.length;b<d;b++)a[b]=c.encodePathSegment(c.decode(a[b]));return a.join("/")};c.decodePath=function(a){a=(a+"").split("/");for(var b=0,d=a.length;b<d;b++)a[b]=c.decodePathSegment(a[b]); +return a.join("/")};var n={encode:"encode",decode:"decode"},s,v=function(a,b){return function(d){try{return c[b](d+"").replace(c.characters[a][b].expression,function(d){return c.characters[a][b].map[d]})}catch(p){return d}}};for(s in n)c[s+"PathSegment"]=v("pathname",n[s]);c.encodeReserved=v("reserved","encode");c.parse=function(a,b){var d;b||(b={});d=a.indexOf("#");-1<d&&(b.fragment=a.substring(d+1)||null,a=a.substring(0,d));d=a.indexOf("?");-1<d&&(b.query=a.substring(d+1)||null,a=a.substring(0, +d));"//"===a.substring(0,2)?(b.protocol=null,a=a.substring(2),a=c.parseAuthority(a,b)):(d=a.indexOf(":"),-1<d&&(b.protocol=a.substring(0,d)||null,b.protocol&&!b.protocol.match(c.protocol_expression)?b.protocol=void 0:"//"===a.substring(d+1,d+3)?(a=a.substring(d+3),a=c.parseAuthority(a,b)):(a=a.substring(d+1),b.urn=!0)));b.path=a;return b};c.parseHost=function(a,b){var d=a.indexOf("/"),c;-1===d&&(d=a.length);"["===a.charAt(0)?(c=a.indexOf("]"),b.hostname=a.substring(1,c)||null,b.port=a.substring(c+ +2,d)||null,"/"===b.port&&(b.port=null)):a.indexOf(":")!==a.lastIndexOf(":")?(b.hostname=a.substring(0,d)||null,b.port=null):(c=a.substring(0,d).split(":"),b.hostname=c[0]||null,b.port=c[1]||null);b.hostname&&"/"!==a.substring(d).charAt(0)&&(d++,a="/"+a);return a.substring(d)||"/"};c.parseAuthority=function(a,b){a=c.parseUserinfo(a,b);return c.parseHost(a,b)};c.parseUserinfo=function(a,b){var d=a.indexOf("/"),p=a.lastIndexOf("@",-1<d?d:a.length-1);-1<p&&(-1===d||p<d)?(d=a.substring(0,p).split(":"), +b.username=d[0]?c.decode(d[0]):null,d.shift(),b.password=d[0]?c.decode(d.join(":")):null,a=a.substring(p+1)):(b.username=null,b.password=null);return a};c.parseQuery=function(a,b){if(!a)return{};a=a.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,"");if(!a)return{};for(var d={},p=a.split("&"),e=p.length,f,k,g=0;g<e;g++)f=p[g].split("="),k=c.decodeQuery(f.shift(),b),f=f.length?c.decodeQuery(f.join("="),b):null,d[k]?("string"===typeof d[k]&&(d[k]=[d[k]]),d[k].push(f)):d[k]=f;return d};c.build=function(a){var b= +"";a.protocol&&(b+=a.protocol+":");a.urn||!b&&!a.hostname||(b+="//");b+=c.buildAuthority(a)||"";"string"===typeof a.path&&("/"!==a.path.charAt(0)&&"string"===typeof a.hostname&&(b+="/"),b+=a.path);"string"===typeof a.query&&a.query&&(b+="?"+a.query);"string"===typeof a.fragment&&a.fragment&&(b+="#"+a.fragment);return b};c.buildHost=function(a){var b="";if(a.hostname)b=c.ip6_expression.test(a.hostname)?b+("["+a.hostname+"]"):b+a.hostname;else return"";a.port&&(b+=":"+a.port);return b};c.buildAuthority= +function(a){return c.buildUserinfo(a)+c.buildHost(a)};c.buildUserinfo=function(a){var b="";a.username&&(b+=c.encode(a.username),a.password&&(b+=":"+c.encode(a.password)),b+="@");return b};c.buildQuery=function(a,b,d){var p="",e,f,k,g;for(f in a)if(q.call(a,f)&&f)if(r(a[f]))for(e={},k=0,g=a[f].length;k<g;k++)void 0!==a[f][k]&&void 0===e[a[f][k]+""]&&(p+="&"+c.buildQueryParameter(f,a[f][k],d),!0!==b&&(e[a[f][k]+""]=!0));else void 0!==a[f]&&(p+="&"+c.buildQueryParameter(f,a[f],d));return p.substring(1)}; +c.buildQueryParameter=function(a,b,d){return c.encodeQuery(a,d)+(null!==b?"="+c.encodeQuery(b,d):"")};c.addQuery=function(a,b,d){if("object"===typeof b)for(var p in b)q.call(b,p)&&c.addQuery(a,p,b[p]);else if("string"===typeof b)void 0===a[b]?a[b]=d:("string"===typeof a[b]&&(a[b]=[a[b]]),r(d)||(d=[d]),a[b]=a[b].concat(d));else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");};c.removeQuery=function(a,b,d){var p;if(r(b))for(d=0,p=b.length;d<p;d++)a[b[d]]=void 0; +else if("object"===typeof b)for(p in b)q.call(b,p)&&c.removeQuery(a,p,b[p]);else if("string"===typeof b)if(void 0!==d)if(a[b]===d)a[b]=void 0;else{if(r(a[b])){p=a[b];var f={},e,k;if(r(d))for(e=0,k=d.length;e<k;e++)f[d[e]]=!0;else f[d]=!0;e=0;for(k=p.length;e<k;e++)void 0!==f[p[e]]&&(p.splice(e,1),k--,e--);a[b]=p}}else a[b]=void 0;else throw new TypeError("URI.addQuery() accepts an object, string as the first parameter");};c.hasQuery=function(a,b,d,p){if("object"===typeof b){for(var e in b)if(q.call(b, +e)&&!c.hasQuery(a,e,b[e]))return!1;return!0}if("string"!==typeof b)throw new TypeError("URI.hasQuery() accepts an object, string as the name parameter");switch(w(d)){case "Undefined":return b in a;case "Boolean":return a=Boolean(r(a[b])?a[b].length:a[b]),d===a;case "Function":return!!d(a[b],b,a);case "Array":return r(a[b])?(p?k:u)(a[b],d):!1;case "RegExp":return r(a[b])?p?k(a[b],d):!1:Boolean(a[b]&&a[b].match(d));case "Number":d=String(d);case "String":return r(a[b])?p?k(a[b],d):!1:a[b]===d;default:throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter"); +}};c.commonPath=function(a,b){var d=Math.min(a.length,b.length),c;for(c=0;c<d;c++)if(a.charAt(c)!==b.charAt(c)){c--;break}if(1>c)return a.charAt(0)===b.charAt(0)&&"/"===a.charAt(0)?"/":"";if("/"!==a.charAt(c)||"/"!==b.charAt(c))c=a.substring(0,c).lastIndexOf("/");return a.substring(0,c+1)};c.withinString=function(a,b,d){d||(d={});var p=d.start||c.findUri.start,e=d.end||c.findUri.end,f=d.trim||c.findUri.trim,k=/[a-z0-9-]=["']?$/i;for(p.lastIndex=0;;){var g=p.exec(a);if(!g)break;g=g.index;if(d.ignoreHtml){var h= +a.slice(Math.max(g-3,0),g);if(h&&k.test(h))continue}var h=g+a.slice(g).search(e),u=a.slice(g,h).replace(f,"");d.ignore&&d.ignore.test(u)||(h=g+u.length,u=b(u,g,h,a),a=a.slice(0,g)+u+a.slice(h),p.lastIndex=g+u.length)}p.lastIndex=0;return a};c.ensureValidHostname=function(a){if(a.match(c.invalid_hostname_characters)){if(!f)throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-] and Punycode.js is not available');if(f.toASCII(a).match(c.invalid_hostname_characters))throw new TypeError('Hostname "'+ +a+'" contains characters other than [A-Z0-9.-]');}};c.noConflict=function(a){if(a)return a={URI:this.noConflict()},h.URITemplate&&"function"===typeof h.URITemplate.noConflict&&(a.URITemplate=h.URITemplate.noConflict()),h.IPv6&&"function"===typeof h.IPv6.noConflict&&(a.IPv6=h.IPv6.noConflict()),h.SecondLevelDomains&&"function"===typeof h.SecondLevelDomains.noConflict&&(a.SecondLevelDomains=h.SecondLevelDomains.noConflict()),a;h.URI===this&&(h.URI=z);return this};e.build=function(a){if(!0===a)this._deferred_build= +!0;else if(void 0===a||this._deferred_build)this._string=c.build(this._parts),this._deferred_build=!1;return this};e.clone=function(){return new c(this)};e.valueOf=e.toString=function(){return this.build(!1)._string};n={protocol:"protocol",username:"username",password:"password",hostname:"hostname",port:"port"};v=function(a){return function(b,d){if(void 0===b)return this._parts[a]||"";this._parts[a]=b||null;this.build(!d);return this}};for(s in n)e[s]=v(n[s]);n={query:"?",fragment:"#"};v=function(a, +b){return function(d,c){if(void 0===d)return this._parts[a]||"";null!==d&&(d+="",d.charAt(0)===b&&(d=d.substring(1)));this._parts[a]=d;this.build(!c);return this}};for(s in n)e[s]=v(s,n[s]);n={search:["?","query"],hash:["#","fragment"]};v=function(a,b){return function(d,c){var e=this[a](d,c);return"string"===typeof e&&e.length?b+e:e}};for(s in n)e[s]=v(n[s][1],n[s][0]);e.pathname=function(a,b){if(void 0===a||!0===a){var d=this._parts.path||(this._parts.hostname?"/":"");return a?c.decodePath(d):d}this._parts.path= +a?c.recodePath(a):"/";this.build(!b);return this};e.path=e.pathname;e.href=function(a,b){var d;if(void 0===a)return this.toString();this._string="";this._parts=c._parts();var e=a instanceof c,f="object"===typeof a&&(a.hostname||a.path||a.pathname);a.nodeName&&(f=c.getDomAttribute(a),a=a[f]||"",f=!1);!e&&f&&void 0!==a.pathname&&(a=a.toString());if("string"===typeof a)this._parts=c.parse(a,this._parts);else if(e||f)for(d in e=e?a._parts:a,e)q.call(this._parts,d)&&(this._parts[d]=e[d]);else throw new TypeError("invalid input"); +this.build(!b);return this};e.is=function(a){var b=!1,d=!1,e=!1,f=!1,k=!1,h=!1,u=!1,n=!this._parts.urn;this._parts.hostname&&(n=!1,d=c.ip4_expression.test(this._parts.hostname),e=c.ip6_expression.test(this._parts.hostname),b=d||e,k=(f=!b)&&g&&g.has(this._parts.hostname),h=f&&c.idn_expression.test(this._parts.hostname),u=f&&c.punycode_expression.test(this._parts.hostname));switch(a.toLowerCase()){case "relative":return n;case "absolute":return!n;case "domain":case "name":return f;case "sld":return k; +case "ip":return b;case "ip4":case "ipv4":case "inet4":return d;case "ip6":case "ipv6":case "inet6":return e;case "idn":return h;case "url":return!this._parts.urn;case "urn":return!!this._parts.urn;case "punycode":return u}return null};var t=e.protocol,y=e.port,C=e.hostname;e.protocol=function(a,b){if(void 0!==a&&a&&(a=a.replace(/:(\/\/)?$/,""),!a.match(c.protocol_expression)))throw new TypeError('Protocol "'+a+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return t.call(this, +a,b)};e.scheme=e.protocol;e.port=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a&&(0===a&&(a=null),a&&(a+="",":"===a.charAt(0)&&(a=a.substring(1)),a.match(/[^0-9]/))))throw new TypeError('Port "'+a+'" contains characters other than [0-9]');return y.call(this,a,b)};e.hostname=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a){var d={};c.parseHost(a,d);a=d.hostname}return C.call(this,a,b)};e.host=function(a,b){if(this._parts.urn)return void 0===a?"":this; +if(void 0===a)return this._parts.hostname?c.buildHost(this._parts):"";c.parseHost(a,this._parts);this.build(!b);return this};e.authority=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?c.buildAuthority(this._parts):"";c.parseAuthority(a,this._parts);this.build(!b);return this};e.userinfo=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.username)return"";var d=c.buildUserinfo(this._parts);return d.substring(0, +d.length-1)}"@"!==a[a.length-1]&&(a+="@");c.parseUserinfo(a,this._parts);this.build(!b);return this};e.resource=function(a,b){var d;if(void 0===a)return this.path()+this.search()+this.hash();d=c.parse(a);this._parts.path=d.path;this._parts.query=d.query;this._parts.fragment=d.fragment;this.build(!b);return this};e.subdomain=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var d=this._parts.hostname.length-this.domain().length- +1;return this._parts.hostname.substring(0,d)||""}d=this._parts.hostname.length-this.domain().length;d=this._parts.hostname.substring(0,d);d=new RegExp("^"+l(d));a&&"."!==a.charAt(a.length-1)&&(a+=".");a&&c.ensureValidHostname(a);this._parts.hostname=this._parts.hostname.replace(d,a);this.build(!b);return this};e.domain=function(a,b){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var d=this._parts.hostname.match(/\./g); +if(d&&2>d.length)return this._parts.hostname;d=this._parts.hostname.length-this.tld(b).length-1;d=this._parts.hostname.lastIndexOf(".",d-1)+1;return this._parts.hostname.substring(d)||""}if(!a)throw new TypeError("cannot set domain empty");c.ensureValidHostname(a);!this._parts.hostname||this.is("IP")?this._parts.hostname=a:(d=new RegExp(l(this.domain())+"$"),this._parts.hostname=this._parts.hostname.replace(d,a));this.build(!b);return this};e.tld=function(a,b){if(this._parts.urn)return void 0===a? +"":this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var d=this._parts.hostname.lastIndexOf("."),d=this._parts.hostname.substring(d+1);return!0!==b&&g&&g.list[d.toLowerCase()]?g.get(this._parts.hostname)||d:d}if(a)if(a.match(/[^a-zA-Z0-9-]/))if(g&&g.is(a))d=new RegExp(l(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(d,a);else throw new TypeError('TLD "'+a+'" contains characters other than [A-Z0-9]');else{if(!this._parts.hostname|| +this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");d=new RegExp(l(this.tld())+"$");this._parts.hostname=this._parts.hostname.replace(d,a)}else throw new TypeError("cannot set TLD empty");this.build(!b);return this};e.directory=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var d=this._parts.path.length-this.filename().length-1,d=this._parts.path.substring(0, +d)||(this._parts.hostname?"/":"");return a?c.decodePath(d):d}d=this._parts.path.length-this.filename().length;d=this._parts.path.substring(0,d);d=new RegExp("^"+l(d));this.is("relative")||(a||(a="/"),"/"!==a.charAt(0)&&(a="/"+a));a&&"/"!==a.charAt(a.length-1)&&(a+="/");a=c.recodePath(a);this._parts.path=this._parts.path.replace(d,a);this.build(!b);return this};e.filename=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return""; +var d=this._parts.path.lastIndexOf("/"),d=this._parts.path.substring(d+1);return a?c.decodePathSegment(d):d}d=!1;"/"===a.charAt(0)&&(a=a.substring(1));a.match(/\.?\//)&&(d=!0);var e=new RegExp(l(this.filename())+"$");a=c.recodePath(a);this._parts.path=this._parts.path.replace(e,a);d?this.normalizePath(b):this.build(!b);return this};e.suffix=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var d=this.filename(), +e=d.lastIndexOf(".");if(-1===e)return"";d=d.substring(e+1);d=/^[a-z0-9%]+$/i.test(d)?d:"";return a?c.decodePathSegment(d):d}"."===a.charAt(0)&&(a=a.substring(1));if(d=this.suffix())e=a?new RegExp(l(d)+"$"):new RegExp(l("."+d)+"$");else{if(!a)return this;this._parts.path+="."+c.recodePath(a)}e&&(a=c.recodePath(a),this._parts.path=this._parts.path.replace(e,a));this.build(!b);return this};e.segment=function(a,b,d){var c=this._parts.urn?":":"/",e=this.path(),f="/"===e.substring(0,1),e=e.split(c);void 0!== +a&&"number"!==typeof a&&(d=b,b=a,a=void 0);if(void 0!==a&&"number"!==typeof a)throw Error('Bad segment "'+a+'", must be 0-based integer');f&&e.shift();0>a&&(a=Math.max(e.length+a,0));if(void 0===b)return void 0===a?e:e[a];if(null===a||void 0===e[a])if(r(b)){e=[];a=0;for(var k=b.length;a<k;a++)if(b[a].length||e.length&&e[e.length-1].length)e.length&&!e[e.length-1].length&&e.pop(),e.push(b[a])}else{if(b||"string"===typeof b)""===e[e.length-1]?e[e.length-1]=b:e.push(b)}else b||"string"===typeof b&&b.length? +e[a]=b:e.splice(a,1);f&&e.unshift("");return this.path(e.join(c),d)};e.segmentCoded=function(a,b,d){var e,f;"number"!==typeof a&&(d=b,b=a,a=void 0);if(void 0===b){a=this.segment(a,b,d);if(r(a))for(e=0,f=a.length;e<f;e++)a[e]=c.decode(a[e]);else a=void 0!==a?c.decode(a):void 0;return a}if(r(b))for(e=0,f=b.length;e<f;e++)b[e]=c.decode(b[e]);else b="string"===typeof b?c.encode(b):b;return this.segment(a,b,d)};var D=e.query;e.query=function(a,b){if(!0===a)return c.parseQuery(this._parts.query,this._parts.escapeQuerySpace); +if("function"===typeof a){var d=c.parseQuery(this._parts.query,this._parts.escapeQuerySpace),e=a.call(this,d);this._parts.query=c.buildQuery(e||d,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);this.build(!b);return this}return void 0!==a&&"string"!==typeof a?(this._parts.query=c.buildQuery(a,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!b),this):D.call(this,a,b)};e.setQuery=function(a,b,d){var e=c.parseQuery(this._parts.query,this._parts.escapeQuerySpace); +if("object"===typeof a)for(var f in a)q.call(a,f)&&(e[f]=a[f]);else if("string"===typeof a)e[a]=void 0!==b?b:null;else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");this._parts.query=c.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(d=b);this.build(!d);return this};e.addQuery=function(a,b,d){var e=c.parseQuery(this._parts.query,this._parts.escapeQuerySpace);c.addQuery(e,a,void 0===b?null:b);this._parts.query= +c.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(d=b);this.build(!d);return this};e.removeQuery=function(a,b,d){var e=c.parseQuery(this._parts.query,this._parts.escapeQuerySpace);c.removeQuery(e,a,b);this._parts.query=c.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(d=b);this.build(!d);return this};e.hasQuery=function(a,b,d){var e=c.parseQuery(this._parts.query,this._parts.escapeQuerySpace); +return c.hasQuery(e,a,b,d)};e.setSearch=e.setQuery;e.addSearch=e.addQuery;e.removeSearch=e.removeQuery;e.hasSearch=e.hasQuery;e.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizeQuery(!1).normalizeFragment(!1).build():this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()};e.normalizeProtocol=function(a){"string"===typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(), +this.build(!a));return this};e.normalizeHostname=function(a){this._parts.hostname&&(this.is("IDN")&&f?this._parts.hostname=f.toASCII(this._parts.hostname):this.is("IPv6")&&m&&(this._parts.hostname=m.best(this._parts.hostname)),this._parts.hostname=this._parts.hostname.toLowerCase(),this.build(!a));return this};e.normalizePort=function(a){"string"===typeof this._parts.protocol&&this._parts.port===c.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!a));return this};e.normalizePath= +function(a){if(this._parts.urn||!this._parts.path||"/"===this._parts.path)return this;var b,d=this._parts.path,e="",f,k;"/"!==d.charAt(0)&&(b=!0,d="/"+d);d=d.replace(/(\/(\.\/)+)|(\/\.$)/g,"/").replace(/\/{2,}/g,"/");b&&(e=d.substring(1).match(/^(\.\.\/)+/)||"")&&(e=e[0]);for(;;){f=d.indexOf("/..");if(-1===f)break;else if(0===f){d=d.substring(3);continue}k=d.substring(0,f).lastIndexOf("/");-1===k&&(k=f);d=d.substring(0,k)+d.substring(f+3)}b&&this.is("relative")&&(d=e+d.substring(1));d=c.recodePath(d); +this._parts.path=d;this.build(!a);return this};e.normalizePathname=e.normalizePath;e.normalizeQuery=function(a){"string"===typeof this._parts.query&&(this._parts.query.length?this.query(c.parseQuery(this._parts.query,this._parts.escapeQuerySpace)):this._parts.query=null,this.build(!a));return this};e.normalizeFragment=function(a){this._parts.fragment||(this._parts.fragment=null,this.build(!a));return this};e.normalizeSearch=e.normalizeQuery;e.normalizeHash=e.normalizeFragment;e.iso8859=function(){var a= +c.encode,b=c.decode;c.encode=escape;c.decode=decodeURIComponent;this.normalize();c.encode=a;c.decode=b;return this};e.unicode=function(){var a=c.encode,b=c.decode;c.encode=B;c.decode=unescape;this.normalize();c.encode=a;c.decode=b;return this};e.readable=function(){var a=this.clone();a.username("").password("").normalize();var b="";a._parts.protocol&&(b+=a._parts.protocol+"://");a._parts.hostname&&(a.is("punycode")&&f?(b+=f.toUnicode(a._parts.hostname),a._parts.port&&(b+=":"+a._parts.port)):b+=a.host()); +a._parts.hostname&&a._parts.path&&"/"!==a._parts.path.charAt(0)&&(b+="/");b+=a.path(!0);if(a._parts.query){for(var d="",e=0,k=a._parts.query.split("&"),g=k.length;e<g;e++){var h=(k[e]||"").split("="),d=d+("&"+c.decodeQuery(h[0],this._parts.escapeQuerySpace).replace(/&/g,"%26"));void 0!==h[1]&&(d+="="+c.decodeQuery(h[1],this._parts.escapeQuerySpace).replace(/&/g,"%26"))}b+="?"+d.substring(1)}return b+=c.decodeQuery(a.hash(),!0)};e.absoluteTo=function(a){var b=this.clone(),d=["protocol","username", +"password","hostname","port"],e,f;if(this._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");a instanceof c||(a=new c(a));b._parts.protocol||(b._parts.protocol=a._parts.protocol);if(this._parts.hostname)return b;for(e=0;f=d[e];e++)b._parts[f]=a._parts[f];b._parts.path?".."===b._parts.path.substring(-2)&&(b._parts.path+="/"):(b._parts.path=a._parts.path,b._parts.query||(b._parts.query=a._parts.query));"/"!==b.path().charAt(0)&&(a=a.directory(),b._parts.path=(a? +a+"/":"")+b._parts.path,b.normalizePath());b.build();return b};e.relativeTo=function(a){var b=this.clone().normalize(),d,e,f,k;if(b._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");a=(new c(a)).normalize();d=b._parts;e=a._parts;f=b.path();k=a.path();if("/"!==f.charAt(0))throw Error("URI is already relative");if("/"!==k.charAt(0))throw Error("Cannot calculate a URI relative to another relative URI");d.protocol===e.protocol&&(d.protocol=null);if(d.username=== +e.username&&d.password===e.password&&null===d.protocol&&null===d.username&&null===d.password&&d.hostname===e.hostname&&d.port===e.port)d.hostname=null,d.port=null;else return b.build();if(f===k)return d.path="",b.build();a=c.commonPath(b.path(),a.path());if(!a)return b.build();e=e.path.substring(a.length).replace(/[^\/]*$/,"").replace(/.*?\//g,"../");d.path=e+d.path.substring(a.length);return b.build()};e.equals=function(a){var b=this.clone();a=new c(a);var d={},e={},f={},k;b.normalize();a.normalize(); +if(b.toString()===a.toString())return!0;d=b.query();e=a.query();b.query("");a.query("");if(b.toString()!==a.toString()||d.length!==e.length)return!1;d=c.parseQuery(d,this._parts.escapeQuerySpace);e=c.parseQuery(e,this._parts.escapeQuerySpace);for(k in d)if(q.call(d,k)){if(!r(d[k])){if(d[k]!==e[k])return!1}else if(!u(d[k],e[k]))return!1;f[k]=!0}for(k in e)if(q.call(e,k)&&!f[k])return!1;return!0};e.duplicateQueryParameters=function(a){this._parts.duplicateQueryParameters=!!a;return this};e.escapeQuerySpace= +function(a){this._parts.escapeQuerySpace=!!a;return this};return c}); +(function(f,m){"object"===typeof exports?module.exports=m(require("./URI")):"function"===typeof define&&define.amd?define(["./URI"],m):f.URITemplate=m(f.URI,f)})(this,function(f,m){function g(c){if(g._cache[c])return g._cache[c];if(!(this instanceof g))return new g(c);this.expression=c;g._cache[c]=this;return this}function h(c){this.data=c;this.cache={}}var c=m&&m.URITemplate,l=Object.prototype.hasOwnProperty,w=g.prototype,r={"":{prefix:"",separator:",",named:!1,empty_name_separator:!1,encode:"encode"}, +"+":{prefix:"",separator:",",named:!1,empty_name_separator:!1,encode:"encodeReserved"},"#":{prefix:"#",separator:",",named:!1,empty_name_separator:!1,encode:"encodeReserved"},".":{prefix:".",separator:".",named:!1,empty_name_separator:!1,encode:"encode"},"/":{prefix:"/",separator:"/",named:!1,empty_name_separator:!1,encode:"encode"},";":{prefix:";",separator:";",named:!0,empty_name_separator:!1,encode:"encode"},"?":{prefix:"?",separator:"&",named:!0,empty_name_separator:!0,encode:"encode"},"&":{prefix:"&", +separator:"&",named:!0,empty_name_separator:!0,encode:"encode"}};g._cache={};g.EXPRESSION_PATTERN=/\{([^a-zA-Z0-9%_]?)([^\}]+)(\}|$)/g;g.VARIABLE_PATTERN=/^([^*:]+)((\*)|:(\d+))?$/;g.VARIABLE_NAME_PATTERN=/[^a-zA-Z0-9%_]/;g.expand=function(c,f){var h=r[c.operator],l=h.named?"Named":"Unnamed",m=c.variables,e=[],q,n,s;for(s=0;n=m[s];s++)q=f.get(n.name),q.val.length?e.push(g["expand"+l](q,h,n.explode,n.explode&&h.separator||",",n.maxlength,n.name)):q.type&&e.push("");return e.length?h.prefix+e.join(h.separator): +""};g.expandNamed=function(c,g,h,l,m,e){var q="",n=g.encode;g=g.empty_name_separator;var s=!c[n].length,v=2===c.type?"":f[n](e),t,r,w;r=0;for(w=c.val.length;r<w;r++)m?(t=f[n](c.val[r][1].substring(0,m)),2===c.type&&(v=f[n](c.val[r][0].substring(0,m)))):s?(t=f[n](c.val[r][1]),2===c.type?(v=f[n](c.val[r][0]),c[n].push([v,t])):c[n].push([void 0,t])):(t=c[n][r][1],2===c.type&&(v=c[n][r][0])),q&&(q+=l),h?q+=v+(g||t?"=":"")+t:(r||(q+=f[n](e)+(g||t?"=":"")),2===c.type&&(q+=v+","),q+=t);return q};g.expandUnnamed= +function(c,g,h,m,l){var e="",q=g.encode;g=g.empty_name_separator;var n=!c[q].length,s,r,t,w;t=0;for(w=c.val.length;t<w;t++)l?r=f[q](c.val[t][1].substring(0,l)):n?(r=f[q](c.val[t][1]),c[q].push([2===c.type?f[q](c.val[t][0]):void 0,r])):r=c[q][t][1],e&&(e+=m),2===c.type&&(s=l?f[q](c.val[t][0].substring(0,l)):c[q][t][0],e+=s,e=h?e+(g||r?"=":""):e+","),e+=r;return e};g.noConflict=function(){m.URITemplate===g&&(m.URITemplate=c);return g};w.expand=function(c){var f="";this.parts&&this.parts.length||this.parse(); +c instanceof h||(c=new h(c));for(var l=0,m=this.parts.length;l<m;l++)f+="string"===typeof this.parts[l]?this.parts[l]:g.expand(this.parts[l],c);return f};w.parse=function(){var c=this.expression,f=g.EXPRESSION_PATTERN,h=g.VARIABLE_PATTERN,l=g.VARIABLE_NAME_PATTERN,m=[],e=0,q,n,s;for(f.lastIndex=0;;){n=f.exec(c);if(null===n){m.push(c.substring(e));break}else m.push(c.substring(e,n.index)),e=n.index+n[0].length;if(!r[n[1]])throw Error('Unknown Operator "'+n[1]+'" in "'+n[0]+'"');if(!n[3])throw Error('Unclosed Expression "'+ +n[0]+'"');q=n[2].split(",");for(var v=0,t=q.length;v<t;v++){s=q[v].match(h);if(null===s)throw Error('Invalid Variable "'+q[v]+'" in "'+n[0]+'"');if(s[1].match(l))throw Error('Invalid Variable Name "'+s[1]+'" in "'+n[0]+'"');q[v]={name:s[1],explode:!!s[3],maxlength:s[4]&&parseInt(s[4],10)}}if(!q.length)throw Error('Expression Missing Variable(s) "'+n[0]+'"');m.push({expression:n[0],operator:n[1],variables:q})}m.length||m.push(c);this.parts=m;return this};h.prototype.get=function(c){var f=this.data, +g={type:0,val:[],encode:[],encodeReserved:[]},h;if(void 0!==this.cache[c])return this.cache[c];this.cache[c]=g;f="[object Function]"===String(Object.prototype.toString.call(f))?f(c):"[object Function]"===String(Object.prototype.toString.call(f[c]))?f[c](c):f[c];if(void 0!==f&&null!==f)if("[object Array]"===String(Object.prototype.toString.call(f))){h=0;for(c=f.length;h<c;h++)void 0!==f[h]&&null!==f[h]&&g.val.push([void 0,String(f[h])]);g.val.length&&(g.type=3)}else if("[object Object]"===String(Object.prototype.toString.call(f))){for(h in f)l.call(f, +h)&&void 0!==f[h]&&null!==f[h]&&g.val.push([h,String(f[h])]);g.val.length&&(g.type=2)}else g.type=1,g.val.push([void 0,String(f)]);return g};f.expand=function(c,h){var l=(new g(c)).expand(h);return new f(l)};return g}); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org