mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged DEV\EXTENSIONS to HEAD
svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/DEV/EXTENSIONS@4865 svn://svn.alfresco.com:3691/alfresco/BRANCHES/DEV/EXTENSIONS@4866 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/DEV/EXTENSIONS@4872 svn://svn.alfresco.com:3691/alfresco/BRANCHES/DEV/EXTENSIONS@4884 . Dave and Gavin's search work git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4899 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// Alfresco AJAX support library
|
||||
// Alfresco JavaScript support library
|
||||
// Gavin Cornwell 14-07-2006
|
||||
//
|
||||
|
||||
@@ -53,3 +53,146 @@ function getContextPath()
|
||||
|
||||
return _alfContextPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a single child element with the given tag
|
||||
* name from the given parent. If more than one tag
|
||||
* exists the first one is returned, if none exist null
|
||||
* is returned.
|
||||
*/
|
||||
function getElementByTagName(elParent, tagName)
|
||||
{
|
||||
var el = null;
|
||||
|
||||
if (elParent != null && tagName != null)
|
||||
{
|
||||
var elems = elParent.getElementsByTagName(tagName);
|
||||
if (elems != null && elems.length > 0)
|
||||
{
|
||||
el = elems[0];
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a single child element with the given tag
|
||||
* name and namespace from the given parent.
|
||||
* If more than one tag exists the first one is returned,
|
||||
* if none exist null is returned.
|
||||
*/
|
||||
function getElementByTagNameNS(elParent, nsUri, nsPrefix, tagName)
|
||||
{
|
||||
var el = null;
|
||||
|
||||
if (elParent != null && tagName != null)
|
||||
{
|
||||
var elems = null;
|
||||
|
||||
if (elParent.getElementsByTagNameNS)
|
||||
{
|
||||
elems = elParent.getElementsByTagNameNS(nsUri, tagName);
|
||||
}
|
||||
else
|
||||
{
|
||||
elems = elParent.getElementsByTagName(nsPrefix + ":" + tagName);
|
||||
}
|
||||
|
||||
if (elems != null && elems.length > 0)
|
||||
{
|
||||
el = elems[0];
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text of the given DOM element object
|
||||
*/
|
||||
function getElementText(el)
|
||||
{
|
||||
var txt = null;
|
||||
|
||||
if (el.text != undefined)
|
||||
{
|
||||
// get text using IE specific property
|
||||
txt = el.text;
|
||||
}
|
||||
else
|
||||
{
|
||||
// use the W3C textContent property
|
||||
txt = el.textContent;
|
||||
}
|
||||
|
||||
return txt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text content of a single child element
|
||||
* with the given tag name from the given parent.
|
||||
* If more than one tag exists the text of the first one
|
||||
* is returned, if none exist null is returned.
|
||||
*/
|
||||
function getElementTextByTagName(elParent, tagName)
|
||||
{
|
||||
var txt = null;
|
||||
|
||||
var el = getElementByTagName(elParent, tagName);
|
||||
if (el != null)
|
||||
{
|
||||
txt = getElementText(el);
|
||||
}
|
||||
|
||||
return txt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text a single child element with the given tag
|
||||
* name and namespace from the given parent.
|
||||
* If more than one tag exists the text of the first one is returned,
|
||||
* if none exist null is returned.
|
||||
*/
|
||||
function getElementTextByTagNameNS(elParent, nsUri, nsPrefix, tagName)
|
||||
{
|
||||
var txt = null;
|
||||
|
||||
var el = getElementByTagNameNS(elParent, nsUri, nsPrefix, tagName);
|
||||
if (el != null)
|
||||
{
|
||||
txt = getElementText(el);
|
||||
}
|
||||
|
||||
return txt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a message to a debug log window.
|
||||
*
|
||||
* Example taken from http://ajaxcookbook.org/javascript-debug-log
|
||||
*/
|
||||
function log(message)
|
||||
{
|
||||
if (!log.window_ || log.window_.closed)
|
||||
{
|
||||
var win = window.open("", null, "width=400,height=200," +
|
||||
"scrollbars=yes,resizable=yes,status=no," +
|
||||
"location=no,menubar=no,toolbar=no");
|
||||
if (!win) return;
|
||||
var doc = win.document;
|
||||
doc.write("<html><head><title>Debug Log</title></head>" +
|
||||
"<body></body></html>");
|
||||
doc.close();
|
||||
log.window_ = win;
|
||||
}
|
||||
|
||||
var logLine = log.window_.document.createElement("div");
|
||||
logLine.appendChild(log.window_.document.createTextNode(message));
|
||||
log.window_.document.body.appendChild(logLine);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user