function initTable(){ tableBuffer = new ContentBuffer(); // main view prefs collection tableprefs = { pid: pid, Event: "all", Years: 1, SortBy: 0, SortDirection: "DESC", FirstRow: 0 }; loadTableData(); } function loadTableData(row){ if(parseInt(row) > -1) { tableprefs.FirstRow = row; }; //tableBuffer.abortRequests(); tableBuffer.load({ url: "resources/asp/getBufferedInsiders.asp", method: "post", contentType: "text/javascript", postdata: { securityID: securityID, pid: tableprefs.pid, Event: tableprefs.Event, Years: tableprefs.Years, SortBy: sortCols[tableprefs.SortBy], SortDirection: tableprefs.SortDirection, FirstRow: tableprefs.FirstRow, callback: "updateTable" }, debug: true }); } function isVal(val){ if (val != -32768){ return true; } return false; } function removeElements(elems){ for (var del, x=0; x < elems.length; x++){ del = document.getElementsByTagName(elems[x]); for (var d=del.length-1; d >= 0; d--){ del[d].parentNode.removeChild(del[d]); } } } function updateTable(data, pagination){ if (pid != "0" && data.length > 0 && data[0].name){ document.getElementById("tabHeadContent").innerHTML = "Insider Activity for " + data[0].name; } if (pagination){ document.getElementById("pageWrap").innerHTML = pagination; } // create new table var oTable = document.getElementById("insidersTable"); var oTHead = document.getElementById("iTableHead"); var oTBody = document.getElementById("iTableBody"); if (oTHead){ for (var x=oTHead.childNodes.length - 1; x >= 0; x--){ oTHead.removeChild(oTHead.childNodes[x]); } } else { oTHead = oTable.appendChild(document.createElement("THEAD", {id: "iTableHead"})); } if (oTBody){ for (var x=oTBody.childNodes.length - 1; x >= 0; x--){ oTBody.removeChild(oTBody.childNodes[x]); } } else { oTBody = oTable.appendChild(document.createElement("TBODY", {id: "iTableBody"})); } oRow = oTHead.appendChild(document.createElement("TR")); // create header for (var oCell, sortImgHtm, htm, i = 0; i < heading.length; i++){ // don't show name or buy/sell on drilldown if (pid != "0" && (i == 1 || i == 2)){ continue; } oCell = document.createElement("TH"); sortImgHtm = ((tableprefs.SortBy == i)?"":""); htm = '' + heading[i] + ''; oCell.setAttribute('column', i); oCell.onclick = sortColumn; // padding oCell.className = "col" + i; /* if (i == 0){ oCell.style.paddingLeft = "5px" } if (i == 5){ oCell.style.paddingLeft = "0px" } if (i == 1){ oCell.style.paddingRight = "10px" } // alignment if (i == 2 || i == 5 || i == 6 || i == 7 || i == 8){ oCell.style.textAlign = "right" htm = sortImgHtm + htm; } else { htm += sortImgHtm; } */ htm += sortImgHtm; if (tableprefs.SortBy == i){oCell.style.backgroundColor = "#f2f1f0"} oCell.innerHTML = htm; oRow.appendChild(oCell); } /* j1[0].cl="Directors"; j1[0].desc="Sale"; j1[0].date=38418; j1[0].dateNice="Mar 07, 2005"; j1[0].high=18.46; j1[0].buy=-32768; j1[0].sell=12; j1[0].low=18.25; j1[0].val=143630053.23; j1[0].name="MORGRIDGE JOHN P"; j1[0].num="7,840,761"; j1[0].type="I"; j1[0].pid=11065; j1[0].tot=65689700; */ // create data rows for (var oCell, typeClass, row=0; row < data.length; row++){ oRow = document.createElement("TR"); oRow.style.backgroundColor = (row % 2 == 0)?"#F2F2F2":"FFFFFF" oRow.setAttribute("msdate",data[row].date) oRow.setAttribute("tranType",data[row].desc) oTBody.appendChild(oRow); // transaction date oCell = document.createElement("TD"); oCell.innerHTML = data[row].dateNice; //oCell.style.textAlign = "left"; //oCell.style.paddingLeft = "5px" oCell.className = ((row % 2 == 0)?"odd":"even") + ((tableprefs.SortBy == 0)?"Sort":"") + " col0"; oRow.appendChild(oCell); if (pid == "0"){ // name / title oCell = document.createElement("TD"); oCell.innerHTML = "" + data[row].name + "
" + data[row].cl + ""; //oCell.style.textAlign = "left"; //oCell.style.paddingRight = "10px" oCell.className = ((row % 2 == 0)?"odd":"even") + ((tableprefs.SortBy == 1)?"Sort":"") + " col1"; //oCell.style.whiteSpace = "nowrap" oRow.appendChild(oCell); // insiders score oCell = document.createElement("TD"); oCell.innerHTML = data[row].buy + "/" + data[row].sell; oCell.className = ((row % 2 == 0)?"odd":"even") + ((tableprefs.SortBy == 2)?"Sort":"") + " col2"; } oRow.appendChild(oCell); // transaction type if(data[row].desc == "Stock Gift"){ typeClass = "stockGift"; } else if(data[row].desc == "Award of Stock Options"){ typeClass = "optionsAward"; } else{ typeClass = (/sale/i.test(data[row].desc)?"down":"up"); } oCell = document.createElement("TD"); oCell.innerHTML = "" + data[row].desc + ""; //oCell.style.textAlign = "left"; oCell.className = ((row % 2 == 0)?"odd":"even") + ((tableprefs.SortBy == 3)?"Sort":"") + " col3"; oRow.appendChild(oCell); // ownership type oCell = document.createElement("TD"); oCell.innerHTML = data[row].type; //oCell.style.textAlign = "left"; oCell.className = ((row % 2 == 0)?"odd":"even") + ((tableprefs.SortBy == 4)?"Sort":"") + " col4"; oRow.appendChild(oCell); // mkt value oCell = document.createElement("TD"); oCell.innerHTML = data[row].val; //oCell.style.paddingLeft = "0px" oCell.className = ((row % 2 == 0)?"odd":"even") + ((tableprefs.SortBy == 5)?"Sort":"") + " col5"; oRow.appendChild(oCell); // shares oCell = document.createElement("TD"); oCell.innerHTML = data[row].num; oCell.className = ((row % 2 == 0)?"odd":"even") + ((tableprefs.SortBy == 6)?"Sort":"") + " col6"; oRow.appendChild(oCell); // price range oCell = document.createElement("TD"); oCell.innerHTML = (data[row].low != "--" || data[row].high != "--")?data[row].low + "-" + data[row].high:"--"; oCell.className = ((row % 2 == 0)?"odd":"even") + ((tableprefs.SortBy == 7)?"Sort":"") + " col7"; oRow.appendChild(oCell); // total holdings oCell = document.createElement("TD"); oCell.innerHTML = data[row].tot; oCell.className = ((row % 2 == 0)?"odd":"even") + ((tableprefs.SortBy == 8)?"Sort":"") + " col8"; oRow.appendChild(oCell); } if (data.length == 0){ oRow = document.createElement("TR"); oTBody.appendChild(oRow); // error message oCell = document.createElement("TD"); oCell.innerHTML = "No data found"; oCell.style.textAlign = "center"; oCell.style.verticalAlign = "middle"; oCell.style.height = "50px"; oCell.setAttribute("colspan", "9"); oRow.appendChild(oCell); } } /* PersonID pass 0 for all or specific for individual Event = (all = all, a=Award, b=Purchase, g=Gift, s=Sale, x=Exercise) Years = 1 = 1 Year, 2 = 2 Years, etc SortBy = (Date, Transaction, Price, Insiders, MarketValue, Ownership, Shares, Total, BuyScore, SellScore) SortDirection = ASC, DESC FirstRow = WHat row to start on NumRows = # of rows to return starting at FirstRow */ var sortCols = ["Date", "Insiders", "SellScore", "Transaction", "Ownership", "MarketValue", "Shares", "Price", "Total"]; var heading = ["Transaction Date", "Insiders/Title", "Buy/Sell
Insider Score", "Transaction
Type", "Ownership
Type", "Market Value", "Shares", "Price Range", "Total Holdings"]; function sortColumn(event){ // called when user clicks a column header. var e = event || window.event || false; var srcElement = false; if (e){ srcElement = getSrcElement(e); } var column = ((srcElement)?srcElement.getAttribute("column"):0); var oldColumn = tableprefs.SortBy; if (oldColumn != column){ // new column selected tableprefs.SortBy = column; tableprefs.SortDirection = "DESC"; } else { // same column selected tableprefs.SortDirection = (tableprefs.SortDirection == "ASC")?"DESC":"ASC"; } loadTableData(); } var tabEvents = ["all","b","s","x","p","g","a"] function selectEvent(tabId){ // called when user selects a tab from the charts module. var type = tabEvents[tabId.replace("tab","")]; if(typeof tableprefs == "undefined"){ return; } tableprefs.FirstRow = 0; tableprefs.Event = type; loadTableData(); } addEvent(window, "load", initTable);