/** * Throughout, whitespace is defined as one of the characters * "\t" TAB \u0009 * "\n" LF \u000A * "\r" CR \u000D * " " SPC \u0020 * * This does not use Javascript's "\s" because that includes non-breaking * spaces (and also some other characters). */ /** * Determine whether a node's text content is entirely whitespace. * * @param nod A node implementing the |CharacterData| interface (i.e., * a |Text|, |Comment|, or |CDATASection| node * @return True if all of the text content of |nod| is whitespace, * otherwise false. */ function is_all_ws( nod ) { // Use ECMA-262 Edition 3 String and RegExp features return !(/[^\t\n\r ]/.test(nod.data)); } /** * Determine if a node should be ignored by the iterator functions. * * @param nod An object implementing the DOM1 |Node| interface. * @return true if the node is: * 1) A |Text| node that is all whitespace * 2) A |Comment| node * and otherwise false. */ function is_ignorable( nod ) { return ( nod.nodeType == 8) || // A comment node ( (nod.nodeType == 3) && is_all_ws(nod) ); // a text node, all ws } /** * Version of |previousSibling| that skips nodes that are entirely * whitespace or comments. (Normally |previousSibling| is a property * of all DOM nodes that gives the sibling node, the node that is * a child of the same parent, that occurs immediately before the * reference node.) * * @param sib The reference node. * @return Either: * 1) The closest previous sibling to |sib| that is not * ignorable according to |is_ignorable|, or * 2) null if no such node exists. */ function node_before( sib ) { while ((sib = sib.previousSibling)) { if (!is_ignorable(sib)) return sib; } return null; } /** * Version of |nextSibling| that skips nodes that are entirely * whitespace or comments. * * @param sib The reference node. * @return Either: * 1) The closest next sibling to |sib| that is not * ignorable according to |is_ignorable|, or * 2) null if no such node exists. */ function node_after( sib ) { while ((sib = sib.nextSibling)) { if (!is_ignorable(sib)) return sib; } return null; } /** * Version of |lastChild| that skips nodes that are entirely * whitespace or comments. (Normally |lastChild| is a property * of all DOM nodes that gives the last of the nodes contained * directly in the reference node.) * * @param sib The reference node. * @return Either: * 1) The last child of |sib| that is not * ignorable according to |is_ignorable|, or * 2) null if no such node exists. */ function last_child( par ) { var res=par.lastChild; while (res) { if (!is_ignorable(res)) return res; res = res.previousSibling; } return null; } /** * Version of |firstChild| that skips nodes that are entirely * whitespace and comments. * * @param sib The reference node. * @return Either: * 1) The first child of |sib| that is not * ignorable according to |is_ignorable|, or * 2) null if no such node exists. */ function first_child( par ) { var res=par.firstChild; while (res) { if (!is_ignorable(res)) return res; res = res.nextSibling; } return null; } /** * Version of |data| that doesn't include whitespace at the beginning * and end and normalizes all whitespace to a single space. (Normally * |data| is a property of text nodes that gives the text of the node.) * * @param txt The text node whose data should be returned * @return A string giving the contents of the text node with * whitespace collapsed. */ function data_of( txt ) { var data = txt.data; // Use ECMA-262 Edition 3 String and RegExp features data = data.replace(/[\t\n\r ]+/g, " "); if (data.charAt(0) == " ") data = data.substring(1, data.length); if (data.charAt(data.length - 1) == " ") data = data.substring(0, data.length - 1); return data; } function recol(listName, movingcol, tocol) { var itocol = parseInt(tocol) ; var imovingcol = parseInt(movingcol) ; if (itocol == imovingcol) { return 0;} var oTable = document.getElementById(listName); // if (oTable == null) { // return; // } // logMessage("imovingcol: " + imovingcol + " itocol: " + itocol); var nodes = ""; var node = first_child(oTable); while (node != null) { nodes += "Tag: " + node.tagName + " ID: " + node.id + " children: " + node.childNodes.length + " parent: " + node.parentNode.tagName + "\n"; node = node_after(node); } // alert(nodes); var row = first_child(oTable); var rowCount = 0; while (row != null) { // logMessage("rowCount: " + rowCount); var fstTDNode = row.childNodes[itocol]; // alert(listName + " rowCount: " + rowCount + " \nID: " + row.ID + " \nrowTag: " + row.tagName + " \ncell: " + (fstTDNode == null ? "is null" : fstTDNode.tagName)); if (fstTDNode != null) { var parent = fstTDNode.parentNode; var parentID = parent.ID; if (parentID == null) { parentID = ""; } // alert(parent.childNodes[3].childNodes[1].textContent); if (parentID.indexOf("Operations") == -1) { var curTDNode = row.childNodes[imovingcol]; // if (curTDNode == null) { // alert("curTDNode is null. row: " + row); // } if (curTDNode != null) { if (itocol < imovingcol) { row.insertBefore(curTDNode, fstTDNode); } else { var fstTDNode = row.childNodes[itocol]; var curTDNode = row.childNodes[imovingcol]; DOMNode_insertAfter(curTDNode, fstTDNode); } var j = 0; var childNode = first_child(row); while (childNode != null) { childNode.colF = j; childNode = node_after(childNode); } } } } else { // alert("fstTDNode is null"); } row = node_after(row); if (row == null) { // alert("row is null"); } rowCount ++; } } function DOMNode_insertAfter(newChild,refChild) //Post condition: if childNodes[n] is refChild, than childNodes[n+1] is newChild. { if (refChild == null) { alert("refChild: " + refChild); } var parentx=refChild.parentNode; if(parentx.lastChild==refChild) { return parentx.appendChild(newChild);} else {return parentx.insertBefore(newChild,refChild.nextSibling);} } var x, y, z, col, fromcol; //window.onload = init; z = 0 ; // 0 = button not pressed down; No Mouse-Moved Layer col = -9 ; // destination column where MouseUp occurs fromcol = -9 ; // source column where MouseDown Occurs function tableReordderInit() { if (window.Event) { document.captureEvents(Event.MOUSEMOVE); } document.onmousemove = getXY; } function getXY(e) { x = (window.Event) ? e.pageX : event.clientX; y = (window.Event) ? e.pageY : event.clientY; try { lay1 = document.getElementById("lay1"); if (lay1 != null) { if (lay1.style.display == "") { lay1.style.top = y + 9 + "px"; lay1.style.left = x + 4 + "px"; } } } catch (e) { } } function logMessage(message) { document.getElementById("debugOutput").innerHTML = document.getElementById("debugOutput").innerHTML + "
" + message; } /* function BlurHead() { document.getElementById("hid_list1_order").focus(); } */ function MOV(el) { if (z == 1) { el.style.backgroundColor='#CCDDFF'; } } function MOT(el) { el.style.backgroundColor='#E3E3E3'; } function MDN(el) { try { z = 1; index = getParentIndex(el); if (index != -1) { fromcol = index; var colNode = first_child(el); if (colNode != null) { var colName = colNode.nodeValue; if (colName == null) { colName = colNode.text; } if (colName != "undefined" && colName != null) { var lay1 = document.getElementById("lay1"); lay1.innerHTML = colName; if (z == 1) { lay1.style.display = ''; lay1.style.left = x + 4 + "px"; lay1.style.top = y + 9 + "px"; } } } } } catch (e) { } } function bodyMUP() { try { z = 0; lay1 = document.getElementById("lay1"); lay1.style.display = 'none'; } catch (e) { } } function MUP(el, objectIDName, propertiesTable) { if (z == 1) { col = getParentIndex(el); first = true; for (i = 0; i < POsObjectIDNames.length; i ++) { var value = POsObjectIDNames[i]; if (value.indexOf(propertiesTable) != -1) { if (fromcol != col) { recol("Body" + value, fromcol, col); recol("Head" + value, fromcol, col); if (first) { var op = {}; url = replaceAll(document.URL, "&", "^^^"); op["url"] = url; //alert("url: " + url); op["fromcol"] = fromcol; op["tocol"] = col; op["Title"] = objectIDName; op["propertiesTable"] = propertiesTable; clientSideInclude("debugOutput", "GET", "/cc/reports/ColumnOrderRecordMove.jsp", toQueryString(op), document.URL, true, false); } first = false; } } } } z = 0; try { lay1 = document.getElementById("lay1"); lay1.style.display = 'none'; } catch (e) { } } function replaceAll(src, find, replaceWith) { while (src.indexOf(find) != -1) { src = src.replace(find, replaceWith); } return src; } function addTableGroup(objectIDName) { POsObjectIDNames[POsObjectIDNames.length] = objectIDName; } var POsObjectIDNames = new Array(); function getParentIndex(el) { var parent = el.parentNode; if (parent != null) { var i = 0; for (i = 0; i < parent.childNodes.length; i ++) { var node = parent.childNodes[i]; if (node == el) { return i; } } } return -1; }