libs: remove unused KSysGuard scripts

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-08-01 00:46:12 +03:00
parent 318f3eba38
commit 3408f0c695
8 changed files with 0 additions and 1129 deletions

View file

@ -11,5 +11,3 @@ if(ENABLE_TESTING)
add_subdirectory( tests )
endif()
install(DIRECTORY scripts/ DESTINATION ${KDE4_DATA_INSTALL_DIR}/ksysguard/scripts)

View file

@ -1,40 +0,0 @@
To create a script:
* Make a folder here with any name
* Inside create a file with any name, ending .desktop, looking like:
[Desktop Entry]
Name=What's this process...
Comment=General information about this program
X-KDE-ServiceTypes=KSysGuard/Script
Type=Service
You will now get the Name in a context menu when right clicking on a process. This can be translated by doing Name[gr]= etc.
* Create a main.js file containing javascript code. This code will be run when the user choses the context menu entry.
* There are the following functions:
filecontent = readFile("/proc/blah")
exists = fileExists("/proc/blah")
setHtml("<html><b>Hi!</b>");
* For a quick and simple GUI, you can just call "setHtml" which will create a dialog box with a webkit browser. Subsequent calls to setHtml will replace the html in the same browser widget.
* If you create a GUI using designer, save the file in the same folder. Any file ending .ui will be made accessible to the script, with the variable name
being the filename, with "." replaced with "_".
e.g. A file called "dialog.ui" with a textbox called 'textBox' can be used like:
dialog_ui.textBox.text = "Hello";
dialog_ui.show();
* The following variables are also available to use, with their values set to the process selected:
process.pid
process.ppid
process.name
process.fullname
process.command

View file

@ -1,71 +0,0 @@
function getElementsByTagNames(list,obj) {
if (!obj) var obj = document;
var tagNames = list.split(',');
var resultArray = new Array();
for (var i=0;i<tagNames.length;i++) {
var tags = obj.getElementsByTagName(tagNames[i]);
for (var j=0;j<tags.length;j++) {
resultArray.push(tags[j]);
}
}
var testNode = resultArray[0];
if (!testNode) return [];
if (testNode.sourceIndex) {
resultArray.sort(function (a,b) {
return a.sourceIndex - b.sourceIndex;
});
}
else if (testNode.compareDocumentPosition) {
resultArray.sort(function (a,b) {
return 3 - (a.compareDocumentPosition(b) & 6);
});
}
return resultArray;
}
function createTOC() {
var y = document.getElementById('innertoc');
var a = y.appendChild(document.createElement('span'));
a.id = 'contentheader';
var z = y.appendChild(document.createElement('div'));
var toBeTOCced = getElementsByTagNames('h2,h3');
if (toBeTOCced.length < 2) return false;
for (var i=0;i<toBeTOCced.length;i++) {
var tmp = document.createElement('a');
tmp.innerHTML = toBeTOCced[i].innerHTML;
tmp.className = 'page';
z.appendChild(tmp);
if (toBeTOCced[i].nodeName == 'H3')
tmp.className += ' indent';
if (toBeTOCced[i].nodeName == 'H4')
tmp.className += ' extraindent';
var headerId = toBeTOCced[i].id || 'link' + i;
tmp.href = '#' + headerId;
toBeTOCced[i].id = headerId;
if (toBeTOCced[i].nodeName == 'H1') {
tmp.innerHTML = 'Top';
tmp.href = '#top';
toBeTOCced[i].id = 'top';
}
}
return y;
}
function showFullDetailsTable() {
var table = document.getElementById('fullDetails');
table.style.display = 'block';
var link = document.getElementById('showFullDetailsLink');
link.style.display = 'none';
}
function showFullLibrarySummary(tbodyId, aId) {
var tbody = document.getElementById(tbodyId);
if(tbody.style.display == 'none') {
//show it again
tbody.style.display = '';
document.getElementById(aId).innerHTML = 'hide';
} else {
tbody.style.display = 'none';
document.getElementById(aId).innerHTML = 'more';
}
}

View file

@ -1,80 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
<script language="javascript" src="helper.js" language="javascript" type="text/javascript"></script>
<script language="javascript" src="sorttable.js" language="javascript" type="text/javascript"></script>
<script language="javascript" src="main.js" language="javascript" type="text/javascript"></script>
</head>
<body>
<div id="innertoc" class="innertoc"></div>
<h1 id="heading"></h1>
<span id="errorMessage" class="errorMessage"></span>
<h2 id="SummaryHeading"></h2>
<span id="processsummary">
<!-- The process X is using approximately Y amount of memory etc !-->
</span>
<h2 id="LibraryUsageHeading"></h2>
<span id="libraryusageintro">
<!-- A short intro to what the tables mean -->
</span>
<br>
<div class="summaryTable">
<table class="librarySummary">
<thead><tr><th colspan="2" id="thPrivate"></th></tr></thead>
<tfoot class="showFullLibrarySummaryLink">
<tr>
<td colspan="2">
<a id="linkPrivate" href="javascript:showFullLibrarySummary('tbodyPrivateHidden', 'linkPrivate')"></a>
</td>
</tr>
</tfoot>
<tbody id="tbodyPrivate">
</tbody>
<tbody id="tbodyPrivateHidden" style="display:none">
</tbody>
</table>
</div>
<div class="summaryTable" id="summaryTableShared">
<table class="librarySummary">
<thead><tr><th colspan="2" id="thShared"></th></tr></thead>
<tfoot class="showFullLibrarySummaryLink">
<tr>
<td colspan="2">
<a id="linkShared" href="javascript:showFullLibrarySummary('tbodySharedHidden', 'linkShared')"></a>
</td>
</tr>
</tfoot>
<tbody id="tbodyShared">
</tbody>
<tbody id="tbodySharedHidden" style="display:none">
</tbody>
</table>
</div>
<div style="clear:both">
<h2 id="TotalsHeading"></h2>
<div class="totalTable">
<table>
<tbody id="totalTableBody">
</tbody>
</table>
</div>
</div>
<div class="fullDetails">
<h2 id="FullDetailsHeading"></h2>
<div id="fullDetailsSummary">
<!-- A short chatty description of what the full details is -->
</div>
<table class="sortable fullDetails" id="fullDetails">
<!-- Large table of memory details -->
</table>
<br>
<a href="javascript:showFullDetailsTable();" id="showFullDetailsLink"></a>
<br>
<br>
</div>
<script language="javascript">translate(); createTOC(); refresh(); </script>
</body>
</html>

View file

@ -1,280 +0,0 @@
"use strict";
var sizeKeys; /* The keys which contain a size - e.g. Size, Pss, Rss etc */
var kernelPageSize; /* The size of the kernel page size. -1 if it's not the same for all. */
var mmuPageSize; /* The size of the mmu page size. -1 if it's not the same for all. */
function removeItem(items, item) {
var i = 0;
while (i < items.length) {
if (items[i] === item) {
items.splice(i, 1);
break;
} else {
i++;
}
}
return items;
}
function readSmapsFile() {
if( !window.process.fileExists("/proc/" + window.process.pid + "/smaps" ) ) {
if( window.process.fileExists("/proc/" + window.process.pid ) ) { //Check that it's not just a timing issue - the process might have already ended
document.getElementById('errorMessage').innerHTML = "<h1>Sorry</h1>Your system is not currently supported (/proc/"+window.process.pid+"/smaps was not found)";
}
return;
}
var smaps = window.process.readFile("/proc/" + window.process.pid + "/smaps");
if(!smaps) {
if( window.process.fileExists("/proc/" + window.process.pid ) ) { //Check that it's not just a timing issue - the process might have already ended
document.getElementById('errorMessage').innerHTML = "<h1>Sorry</h1>You do not have permissions to read detailed memory information about this process (/proc/"+window.process.pid+"/smaps could not be read)";
}
return;
}
return smaps.split('\n');
}
function parseSmaps() {
var smaps = readSmapsFile();
if(!smaps)
return;
sizeKeys = [];
kernelPageSize = undefined;
mmuPageSize = undefined;
var data = []; /* This is a 0 indexed array */
/* data contains many dataBlocks */
var dataBlock; /* This is a hash table */
var headingRegex = /^([0-9A-Fa-f]+-[0-9A-Fa-f]+) +([^ ]*) +([0-9A-Fa-f]+) +([0-9A-Fa-f]+:[0-9A-Fa-f]+) +(\d+) +(.*)$/;
var lineRegex = /^([^ ]+): +(\d+) kB$/;
for(var i = 0; i < smaps.length; i++) {
var lineMatch = lineRegex.exec(smaps[i]);
var headingMatch;
if(lineMatch) {
var key = lineMatch[1];
dataBlock[ key ] = parseInt(lineMatch[2], 10); /* E.g. dataBlock.Size = 84 */
/* Size - Virtual memory space (useless) */
/* RSS - Includes video card memory etc */
/* PSS - */
/* Shared + Private = RSS, but it's more accurate to instead make Shared = Pss - Private */
if(data.length === 0)
sizeKeys.push(lineMatch[1]);
} else if( (headingMatch = headingRegex.exec(smaps[i])) ) {
if(dataBlock)
data.push(dataBlock);
dataBlock = [];
dataBlock.address = headingMatch[1]; /* Address in address space in the process that it occupies */
dataBlock.perms = headingMatch[2]; /* Read, Write, eXecute, Shared, Private (copy on write) */
dataBlock.offset = headingMatch[3]; /* Offset into the device */
dataBlock.dev = headingMatch[4]; /* Device (major,minor) */
dataBlock.inode = headingMatch[5]; /* inode on the device - 0 means no inode for the memory region - e.g bss */
dataBlock.pathname = headingMatch[6];
}
// ignore unknown lines
}
if(dataBlock)
data.push(dataBlock);
// Add in totals and check page sizes
for(var i = 0; i < data.length; i++) {
data[i].Private = data[i].Private_Clean + data[i].Private_Dirty;
data[i].Shared = data[i].Shared_Clean + data[i].Shared_Dirty;
if(!kernelPageSize)
kernelPageSize = data[i].KernelPageSize;
else if(data[i].KernelPageSize && kernelPageSize !== data[i].KernelPageSize)
kernelPageSize = -1;
if(!mmuPageSize)
mmuPageSize = data[i].MMUPageSize;
else if(data[i].mmuPageSize && mmuPageSize !== data[i].MMUPageSize)
mmuPageSize = -1;
}
if(mmuPageSize !== -1)
removeItem(sizeKeys, 'MMUPageSize');
if(kernelPageSize !== -1)
removeItem(sizeKeys, 'KernelPageSize');
var sizeKeysIncludingCombined = sizeKeys.concat(['Private', 'Shared']);
// Now build up another hash table, collapsing the pathname values
var combinedHash = [];
for(var i = 0; i < data.length; i++) {
var pathname = data[i].pathname;
if(pathname === "") //Count anonymous mappings (mmap to /dev/zero) as part of the heap
pathname = "[heap]";
if(!combinedHash[pathname])
combinedHash[pathname] = [];
for(var j = 0; j < sizeKeysIncludingCombined.length; j++) {
var key = sizeKeysIncludingCombined[j];
if(combinedHash[pathname][key])
combinedHash[pathname][key] += data[i][key];
else
combinedHash[pathname][key] = data[i][key];
}
}
//Convert hash table to an array so that we can sort it
var combined = [];
var i = 0;
for(var key in combinedHash) {
combined[i] = combinedHash[key];
combined[i].pathname = key;
i++;
}
return [data,combined];
}
function calculateTotal(data, info) {
var total = 0;
for(var i = 0; i < data.length; i++) {
total += data[i][info];
}
return total;
}
function formatKB(kb) {
var format = "";
if(kb < 2048) /* less than 2MB, write as just KB */
format = kb.toFixed(1) + " KB";
else if(kb < (1048576)) /* less than 1GB, write in MB */
format = (kb/1024).toFixed(1) + " MB";
else
format = (kb/1048576).toFixed(1) + " GB";
return "<span class=\"memory\" title=\"" + kb.toFixed(0) + " KB\">" + format + "</span>";
}
function formatBytes(b) {
if(b > 2048) /* if more than 2KB, format as KB */
return formatKB(b/1024)
return "<span class=\"memory\" title=\"" + b + " B\">" + b + "</span>";
}
function sortDataByInfo(data, info) {
return data.sort( function(a,b) { return b[info] - a[info]; } );
}
function getHtmlTableForLibrarySummary(data, info, total) {
var sortedData = sortDataByInfo(data, info);
var html = "";
var htmlIsForHiddenTBody = false;
for(var i = 0; i < sortedData.length; i++) {
var value = sortedData[i][info];
if(value === 0)
break; //Do not show libraries with a value of 0 KB
if( i === 5 && sortedData.length > 8) {
document.getElementById('tbody' + info).innerHTML = html;
html = "";
htmlIsForHiddenTBody = true;
}
var pathname = sortedData[i].pathname;
html += "<tr><td class='memory'>" + value + " KB</td><td>" + pathname + "</td></tr>";
}
if(htmlIsForHiddenTBody)
document.getElementById('tbody' + info + 'Hidden').innerHTML = html;
else
document.getElementById('tbody' + info).innerHTML = html;
}
function getHtmlSummary(combined) {
var pss = calculateTotal(combined,'Pss');
var rss = calculateTotal(combined,'Rss');
var private_clean = calculateTotal(combined,'Private_Clean');
var private_dirty = calculateTotal(combined,'Private_Dirty');
var private_total = private_clean + private_dirty;
var shared_clean = calculateTotal(combined,'Shared_Clean');
var shared_dirty = calculateTotal(combined,'Shared_Dirty');
var shared_total = shared_clean + shared_dirty;
var swap = calculateTotal(combined,'Swap');
var html = "";
var total = pss;
if( window.process.pixmapBytes > 0 )
total += (window.process.pixmapBytes / 1024);
html += "The process <b>" + window.process.name.substr(0,20) + "</b> (with pid " + window.process.pid + ") is using approximately " + formatKB(total) + " of memory.<br>";
if( window.process.pixmapBytes > 0 ) {
html += "It is using " + formatKB(private_total) + " privately, " + formatBytes(window.process.pixmapBytes) + " for pixmaps, and a further " + formatKB(shared_total) + " that is, or could be, shared with other programs.<br>";
if(shared_total !== 0)
html += "Dividing up the shared memory between all the processes sharing that memory we get a reduced shared memory usage of " + formatKB(pss - private_total) + ". Adding that to the private and pixmap usage, we get the above mentioned total memory footprint of " + formatKB(total) + ".<br>";
} else {
html += "It is using " + formatKB(private_total) + " privately, and a further " + formatKB(shared_total) + " that is, or could be, shared with other programs.<br>";
if(shared_total !== 0)
html += "Dividing up the shared memory between all the processes sharing that memory we get a reduced shared memory usage of " + formatKB(pss - private_total) + ". Adding that to the private usage, we get the above mentioned total memory footprint of " + formatKB(total) + ".<br>";
}
if( swap !== 0)
html += formatKB(swap) + " is swapped out to disk, probably due to a low amount of available memory left.<br>";
document.getElementById('processsummary').innerHTML = html;
getHtmlTableForLibrarySummary(combined, 'Private', private_total);
getHtmlTableForLibrarySummary(combined, 'Shared', shared_total);
html = "";
if( window.process.pixmapBytes > 0 )
html += "<tr><th class='memory definedWord' title='Memory used for pixmaps and stored by the X server. The pixmaps may be stored entirely on the graphics card, not using any RAM.'>Pixmap</th><td class='memory'>" + (window.process.pixmapBytes/1024).toFixed(0) + " KB</td><td class='comment'>(Might be stored in the graphics card's memory)</td></tr>";
html += "<tr><th class='memory definedWord' title='Memory used only by this process. This can be different from the value shown in the Memory column in the process list because the process list uses an approximation that tends to underestimate this real value.'>Private</th><td class='memory'>" + private_total + " KB</td><td class='comment'>(= " + private_clean + " KB clean + " + private_dirty + " KB dirty)</td></tr>";
html += "<tr><th class='memory definedWord' title='Memory that can be used by multiple processes. This can be different from the value shown in the Shared column in the process list because the process list uses an approximation that tends to overestimate this real value.'>Shared</th><td class='memory'>" + shared_total + " KB</td><td class='comment'>(= " + shared_clean + " KB clean + " + shared_dirty + " KB dirty)</td></tr>";
html += "<tr><th class='memory definedWord' title='Resident Set Size. This is the value shown in /proc/<pid>/status under VmRSS.'>Rss</th><td class='memory'>" + rss + " KB</td><td class='comment'>(= Private + Shared)</td></tr>";
html += "<tr><th class='memory definedWord' title='Proportional Set Size. This is the most useful way to measure memory size.'>Pss</th><td class='memory'>" + pss + " KB</td><td class='comment'>(= Private + Shared/Number of Processes)</td></tr>";
html += "<tr><th class='memory definedWord' title='Memory swapped out to disk, typically because the system ran low of physical memory'>Swap</th><td class='memory'>" + swap + " KB</td></tr>";
document.getElementById('totalTableBody').innerHTML = html;
}
function translate() {
document.getElementById('heading').innerHTML = 'Process ' + window.process.pid + " - " + window.process.name;
document.getElementById('SummaryHeading').innerHTML = 'Summary';
document.getElementById('LibraryUsageHeading').innerHTML = 'Library Usage';
document.getElementById('showFullDetailsLink').innerHTML = 'Show Full Details';
if(window.process.numThreads > 2)
document.getElementById('libraryusageintro').innerHTML = "The memory usage of a process is found by adding up the memory usage of each of its libraries, plus the process's own heap, stack and any other mappings, plus the stack of its " + (window.process.numThreads-1) + " threads.";
else if(window.process.numThreads == 2)
document.getElementById('libraryusageintro').innerHTML = "The memory usage of a process is found by adding up the memory usage of each of its libraries, plus the process's own heap, stack and any other mappings, plus the stack of its one other thread.";
else
document.getElementById('libraryusageintro').innerHTML = "The memory usage of a process is found by adding up the memory usage of each of its libraries, plus the process's own heap, stack and any other mappings.";
document.getElementById('TotalsHeading').innerHTML = "Totals";
document.getElementById('FullDetailsHeading').innerHTML = "Full Details";
document.getElementById('linkPrivate').innerHTML = "more";
document.getElementById('linkShared').innerHTML = "more";
document.getElementById('thPrivate').innerHTML = "Private";
document.getElementById('thShared').innerHTML = "Shared";
}
function refresh() {
try {
document.body.style.cursor = "wait";
document.getElementById('errorMessage').innerHTML = "";
var smapData = parseSmaps();
if(!smapData) {
document.body.style.cursor = "";
return;
}
var data = smapData[0];
var combined = smapData[1];
getHtmlSummary(combined);
var html = "";
html += "Information about the complete virtual space for the process is available, with sortable columns. An empty filename means that it is an <span title='This is a fast way to allocate and clear a block of space. See the mmap(2) man page under MAP_ANONYMOUS' class='definedWord'>anonymous mapping</span>.<br>";
if(kernelPageSize !== -1 && mmuPageSize !== -1 && kernelPageSize === mmuPageSize)
html += "Both the <span class='definedWord' title='Memory Management Unit'>MMU</span> page size and the kernel page size are " + kernelPageSize + " KB.";
else {
if(kernelPageSize !== -1)
html += "The kernel page size is " + kernelPageSize + " KB. ";
if(mmuPageSize !== -1)
html += "The MMU page size is " + mmuPageSize + " KB.";
}
document.getElementById('fullDetailsSummary').innerHTML = html;
html = "<thead><tr><th>Address</th><th>Perm</th>";
for(var i = 0; i < sizeKeys.length; i++)
html += "<th>" + sizeKeys[i].replace('_',' ') + "</th>";
html += "<th align='left'>Filename</th></tr></thead><tbody>";
for(var i = 0; i < data.length; i++) {
html += "<tr><td class='address'>" + data[i].address + "</td><td class='perms'>" + data[i].perms + "</td>";
for(var j = 0; j < sizeKeys.length; j++) {
var value = data[i][sizeKeys[j]];
html += "<td align='right' sorttable_customkey='" + value + "'>" + value + " KB</td>";
}
html += "<td>" + data[i].pathname + "</td></tr>";
}
html += "</tbody>";
document.getElementById('fullDetails').innerHTML = html;
} catch (detectedError) {
document.getElementById('errorMessage').innerHTML = "Sorry, there was an <span class='definedWord' title='" + detectedError.toString().replace("'","\&#39;") + " on line " + detectedError.line + ". Right click and chose inspect for more details, or file a bug on http://bugs.kde.org'>error</span> in the script. The details may not be complete or correct.";
} finally {
document.body.style.cursor = "";
}
}

View file

@ -1,66 +0,0 @@
[Desktop Entry]
Name=Detailed Memory Information
Name[ar]=معلومات مفصلة عن الذاكرة
Name[ast]=Información detallada sobre la memoria
Name[bg]=Подробни данни за паметта
Name[bs]=Detaljni podaci o memoriji
Name[ca]=Informació detallada de la memòria
Name[ca@valencia]=Informació detallada de la memòria
Name[cs]=Podrobné informace o paměti
Name[da]=Detaljeret hukommelsesinformation
Name[de]=Detaillierte Speicherinformationen
Name[el]=Λεπτομερείς πληροφορίες μνήμης
Name[en_GB]=Detailed Memory Information
Name[es]=Información detallada sobre la memoria
Name[et]=Üksikasjalik mäluteave
Name[eu]=Memoriari buruzko informazio xehatua
Name[fi]=Yksityiskohtainen muistinkulutus
Name[fr]=Informations détaillées sur la mémoire
Name[ga]=Faisnéis Mhionsonraithe Chuimhne
Name[gl]=Información detallada da memoria
Name[gu]=િ
Name[he]=פרטי זיכרון מפורטים
Name[hi]=ि
Name[hr]=Detaljne informacije o memoriji
Name[hu]=Részletes memóriainformációk
Name[ia]=Information de memoria detaliate
Name[id]=Informasi Memori Lengkap
Name[is]=Nánari upplýsingar um minnisnotkun
Name[it]=Informazioni dettagliate sulla memoria
Name[ja]=
Name[kk]=Жады туралы жете мәлімет
Name[km]=
Name[kn]=ಿ ಿ ಿಿ
Name[ko]=
Name[lt]=Detali atminties informacija
Name[lv]=Detalizēta atmiņas informācija
Name[mr]= ि
Name[nb]=Detaljert minneinformasjon
Name[nds]=Verwiedert Informatschoon över den Spieker
Name[nl]=Gedetailleerde geheugeninformatie
Name[pa]=
Name[pl]=Szczegółowe informacje o pamięci
Name[pt]=Informações Detalhadas sobre a Memória
Name[pt_BR]=Informações detalhadas da memória
Name[ro]=Informații detaliate despre memorie
Name[ru]=Сведения об использовании памяти
Name[si]=
Name[sk]=Podrobné informácie o pamäti
Name[sl]=Podrobni podatki o pomnilniku
Name[sr]=Детаљни подаци о меморији
Name[sr@ijekavian]=Детаљни подаци о меморији
Name[sr@ijekavianlatin]=Detaljni podaci o memoriji
Name[sr@latin]=Detaljni podaci o memoriji
Name[sv]=Detaljerad minnesinformation
Name[th]=
Name[tr]=Ayrıntılı Bellek Bilgileri
Name[ug]=ئەسلەك ئۇچۇرى تەپسىلاتى
Name[uk]=Докладні відомості щодо пам'яті
Name[vi]=Thông tin b nh chi tiết
Name[wa]=Sipepieuse infôrmåcion sol memwere
Name[x-test]=xxDetailed Memory Informationxx
Name[zh_CN]=
Name[zh_TW]=
X-KDE-ServiceTypes=KSysGuard/Script
Type=Service

View file

@ -1,496 +0,0 @@
/*
SortTable
version 2
7th April 2007
Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/
Instructions:
Download this file
Add <script src="sorttable.js"></script> to your HTML
Add class="sortable" to any table you'd like to make sortable
Click on the headers to sort
Thanks to many, many people for contributions and suggestions.
Licenced as X11: http://www.kryogenix.org/code/browser/licence.html
This basically means: do what you want with it.
*/
var stIsIE = /*@cc_on!@*/false;
sorttable = {
init: function() {
// quit if this function has already been called
if (arguments.callee.done) return;
// flag this function so we don't do the same thing twice
arguments.callee.done = true;
// kill the timer
if (_timer) clearInterval(_timer);
if (!document.createElement || !document.getElementsByTagName) return;
sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;
forEach(document.getElementsByTagName('table'), function(table) {
if (table.className.search(/\bsortable\b/) != -1) {
sorttable.makeSortable(table);
}
});
},
makeSortable: function(table) {
if (table.getElementsByTagName('thead').length == 0) {
if(table.rows.length == 0)
return;
// table doesn't have a tHead. Since it should have, create one and
// put the first table row in it.
the = document.createElement('thead');
the.appendChild(table.rows[0]);
table.insertBefore(the,table.firstChild);
}
// Safari doesn't support table.tHead, sigh
if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0];
if (table.tHead.rows.length != 1) return; // can't cope with two header rows
// Sorttable v1 put rows with a class of "sortbottom" at the bottom (as
// "total" rows, for example). This is B&R, since what you're supposed
// to do is put them in a tfoot. So, if there are sortbottom rows,
// for backwards compatibility, move them to tfoot (creating it if needed).
sortbottomrows = [];
for (var i=0; i<table.rows.length; i++) {
if (table.rows[i].className.search(/\bsortbottom\b/) != -1) {
sortbottomrows[sortbottomrows.length] = table.rows[i];
}
}
if (sortbottomrows) {
if (table.tFoot == null) {
// table doesn't have a tfoot. Create one.
tfo = document.createElement('tfoot');
table.appendChild(tfo);
}
for (var i=0; i<sortbottomrows.length; i++) {
tfo.appendChild(sortbottomrows[i]);
}
delete sortbottomrows;
}
// work through each column and calculate its type
headrow = table.tHead.rows[0].cells;
for (var i=0; i<headrow.length; i++) {
// manually override the type with a sorttable_type attribute
if (!headrow[i].className.match(/\bsorttable_nosort\b/)) { // skip this col
mtch = headrow[i].className.match(/\bsorttable_([a-z0-9]+)\b/);
if (mtch) { override = mtch[1]; }
if (mtch && typeof sorttable["sort_"+override] == 'function') {
headrow[i].sorttable_sortfunction = sorttable["sort_"+override];
} else {
headrow[i].sorttable_sortfunction = sorttable.guessType(table,i);
}
// make it clickable to sort
headrow[i].sorttable_columnindex = i;
headrow[i].sorttable_tbody = table.tBodies[0];
dean_addEvent(headrow[i],"click", function(e) {
if (this.className.search(/\bsorttable_sorted\b/) != -1) {
// if we're already sorted by this column, just
// reverse the table, which is quicker
sorttable.reverse(this.sorttable_tbody);
this.className = this.className.replace('sorttable_sorted',
'sorttable_sorted_reverse');
this.removeChild(document.getElementById('sorttable_sortfwdind'));
sortrevind = document.createElement('span');
sortrevind.id = "sorttable_sortrevind";
sortrevind.innerHTML = stIsIE ? '&nbsp<font face="webdings">5</font>' : '&nbsp;&#x25B4;';
this.appendChild(sortrevind);
return;
}
if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) {
// if we're already sorted by this column in reverse, just
// re-reverse the table, which is quicker
sorttable.reverse(this.sorttable_tbody);
this.className = this.className.replace('sorttable_sorted_reverse',
'sorttable_sorted');
this.removeChild(document.getElementById('sorttable_sortrevind'));
sortfwdind = document.createElement('span');
sortfwdind.id = "sorttable_sortfwdind";
sortfwdind.innerHTML = stIsIE ? '&nbsp<font face="webdings">6</font>' : '&nbsp;&#x25BE;';
this.appendChild(sortfwdind);
return;
}
// remove sorttable_sorted classes
theadrow = this.parentNode;
forEach(theadrow.childNodes, function(cell) {
if (cell.nodeType == 1) { // an element
cell.className = cell.className.replace('sorttable_sorted_reverse','');
cell.className = cell.className.replace('sorttable_sorted','');
}
});
sortfwdind = document.getElementById('sorttable_sortfwdind');
if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); }
sortrevind = document.getElementById('sorttable_sortrevind');
if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); }
this.className += ' sorttable_sorted';
sortfwdind = document.createElement('span');
sortfwdind.id = "sorttable_sortfwdind";
sortfwdind.innerHTML = stIsIE ? '&nbsp<font face="webdings">6</font>' : '&nbsp;&#x25BE;';
this.appendChild(sortfwdind);
// build an array to sort. This is a Schwartzian transform thing,
// i.e., we "decorate" each row with the actual sort key,
// sort based on the sort keys, and then put the rows back in order
// which is a lot faster because you only do getInnerText once per row
row_array = [];
col = this.sorttable_columnindex;
rows = this.sorttable_tbody.rows;
for (var j=0; j<rows.length; j++) {
row_array[row_array.length] = [sorttable.getInnerText(rows[j].cells[col]), rows[j]];
}
/* If you want a stable sort, uncomment the following line */
//sorttable.shaker_sort(row_array, this.sorttable_sortfunction);
/* and comment out this one */
row_array.sort(this.sorttable_sortfunction);
tb = this.sorttable_tbody;
for (var j=0; j<row_array.length; j++) {
tb.appendChild(row_array[j][1]);
}
delete row_array;
});
}
}
},
guessType: function(table, column) {
// guess the type of a column based on its first non-blank row
sortfn = sorttable.sort_alpha;
for (var i=0; i<table.tBodies[0].rows.length; i++) {
text = sorttable.getInnerText(table.tBodies[0].rows[i].cells[column]);
if (text != '') {
if (text.match(/^-?[£$¤]?[\d,.]+%?$/)) {
return sorttable.sort_numeric;
}
// check for a date: dd/mm/yyyy or dd/mm/yy
// can have / or . or - as separator
// can be mm/dd as well
possdate = text.match(sorttable.DATE_RE)
if (possdate) {
// looks like a date
first = parseInt(possdate[1]);
second = parseInt(possdate[2]);
if (first > 12) {
// definitely dd/mm
return sorttable.sort_ddmm;
} else if (second > 12) {
return sorttable.sort_mmdd;
} else {
// looks like a date, but we can't tell which, so assume
// that it's dd/mm (English imperialism!) and keep looking
sortfn = sorttable.sort_ddmm;
}
}
}
}
return sortfn;
},
getInnerText: function(node) {
// gets the text we want to use for sorting for a cell.
// strips leading and trailing whitespace.
// this is *not* a generic getInnerText function; it's special to sorttable.
// for example, you can override the cell text with a customkey attribute.
// it also gets .value for <input> fields.
hasInputs = (typeof node.getElementsByTagName == 'function') &&
node.getElementsByTagName('input').length;
if (node.getAttribute("sorttable_customkey") != null) {
return node.getAttribute("sorttable_customkey");
}
else if (typeof node.textContent != 'undefined' && !hasInputs) {
return node.textContent.replace(/^\s+|\s+$/g, '');
}
else if (typeof node.innerText != 'undefined' && !hasInputs) {
return node.innerText.replace(/^\s+|\s+$/g, '');
}
else if (typeof node.text != 'undefined' && !hasInputs) {
return node.text.replace(/^\s+|\s+$/g, '');
}
else {
switch (node.nodeType) {
case 3:
if (node.nodeName.toLowerCase() == 'input') {
return node.value.replace(/^\s+|\s+$/g, '');
}
case 4:
return node.nodeValue.replace(/^\s+|\s+$/g, '');
break;
case 1:
case 11:
var innerText = '';
for (var i = 0; i < node.childNodes.length; i++) {
innerText += sorttable.getInnerText(node.childNodes[i]);
}
return innerText.replace(/^\s+|\s+$/g, '');
break;
default:
return '';
}
}
},
reverse: function(tbody) {
// reverse the rows in a tbody
newrows = [];
for (var i=0; i<tbody.rows.length; i++) {
newrows[newrows.length] = tbody.rows[i];
}
for (var i=newrows.length-1; i>=0; i--) {
tbody.appendChild(newrows[i]);
}
delete newrows;
},
/* sort functions
each sort function takes two parameters, a and b
you are comparing a[0] and b[0] */
sort_numeric: function(a,b) {
aa = parseFloat(a[0].replace(/[^0-9.-]/g,''));
if (isNaN(aa)) aa = 0;
bb = parseFloat(b[0].replace(/[^0-9.-]/g,''));
if (isNaN(bb)) bb = 0;
return aa-bb;
},
sort_alpha: function(a,b) {
if (a[0]==b[0]) return 0;
if (a[0]<b[0]) return -1;
return 1;
},
sort_ddmm: function(a,b) {
mtch = a[0].match(sorttable.DATE_RE);
y = mtch[3]; m = mtch[2]; d = mtch[1];
if (m.length == 1) m = '0'+m;
if (d.length == 1) d = '0'+d;
dt1 = y+m+d;
mtch = b[0].match(sorttable.DATE_RE);
y = mtch[3]; m = mtch[2]; d = mtch[1];
if (m.length == 1) m = '0'+m;
if (d.length == 1) d = '0'+d;
dt2 = y+m+d;
if (dt1==dt2) return 0;
if (dt1<dt2) return -1;
return 1;
},
sort_mmdd: function(a,b) {
mtch = a[0].match(sorttable.DATE_RE);
y = mtch[3]; d = mtch[2]; m = mtch[1];
if (m.length == 1) m = '0'+m;
if (d.length == 1) d = '0'+d;
dt1 = y+m+d;
mtch = b[0].match(sorttable.DATE_RE);
y = mtch[3]; d = mtch[2]; m = mtch[1];
if (m.length == 1) m = '0'+m;
if (d.length == 1) d = '0'+d;
dt2 = y+m+d;
if (dt1==dt2) return 0;
if (dt1<dt2) return -1;
return 1;
},
shaker_sort: function(list, comp_func) {
// A stable sort function to allow multi-level sorting of data
// see: http://en.wikipedia.org/wiki/Cocktail_sort
// thanks to Joseph Nahmias
var b = 0;
var t = list.length - 1;
var swap = true;
while(swap) {
swap = false;
for(var i = b; i < t; ++i) {
if ( comp_func(list[i], list[i+1]) > 0 ) {
var q = list[i]; list[i] = list[i+1]; list[i+1] = q;
swap = true;
}
} // for
t--;
if (!swap) break;
for(var i = t; i > b; --i) {
if ( comp_func(list[i], list[i-1]) < 0 ) {
var q = list[i]; list[i] = list[i-1]; list[i-1] = q;
swap = true;
}
} // for
b++;
} // while(swap)
}
}
/* ******************************************************************
Supporting functions: bundled here to avoid depending on a library
****************************************************************** */
// Dean Edwards/Matthias Miller/John Resig
/* for Mozilla/Opera9 */
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", sorttable.init, false);
}
/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
var script = document.getElementById("__ie_onload");
script.onreadystatechange = function() {
if (this.readyState == "complete") {
sorttable.init(); // call the onload handler
}
};
/*@end @*/
/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
var _timer = setInterval(function() {
if (/loaded|complete/.test(document.readyState)) {
sorttable.init(); // call the onload handler
}
}, 10);
}
/* for other browsers */
window.onload = sorttable.init;
// written by Dean Edwards, 2005
// with input from Tino Zijdel, Matthias Miller, Diego Perini
// http://dean.edwards.name/weblog/2005/10/add-event/
function dean_addEvent(element, type, handler) {
if (element.addEventListener) {
element.addEventListener(type, handler, false);
} else {
// assign each event handler a unique ID
if (!handler.$$guid) handler.$$guid = dean_addEvent.guid++;
// create a hash table of event types for the element
if (!element.events) element.events = {};
// create a hash table of event handlers for each element/event pair
var handlers = element.events[type];
if (!handlers) {
handlers = element.events[type] = {};
// store the existing event handler (if there is one)
if (element["on" + type]) {
handlers[0] = element["on" + type];
}
}
// store the event handler in the hash table
handlers[handler.$$guid] = handler;
// assign a global event handler to do all the work
element["on" + type] = handleEvent;
}
};
// a counter used to create unique IDs
dean_addEvent.guid = 1;
function removeEvent(element, type, handler) {
if (element.removeEventListener) {
element.removeEventListener(type, handler, false);
} else {
// delete the event handler from the hash table
if (element.events && element.events[type]) {
delete element.events[type][handler.$$guid];
}
}
};
function handleEvent(event) {
var returnValue = true;
// grab the event object (IE uses a global event object)
event = event || fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
// get a reference to the hash table of event handlers
var handlers = this.events[event.type];
// execute each event handler
for (var i in handlers) {
this.$$handleEvent = handlers[i];
if (this.$$handleEvent(event) === false) {
returnValue = false;
}
}
return returnValue;
};
function fixEvent(event) {
// add W3C standard event methods
event.preventDefault = fixEvent.preventDefault;
event.stopPropagation = fixEvent.stopPropagation;
return event;
};
fixEvent.preventDefault = function() {
this.returnValue = false;
};
fixEvent.stopPropagation = function() {
this.cancelBubble = true;
}
// Dean's forEach: http://dean.edwards.name/base/forEach.js
/*
forEach, version 1.0
Copyright 2006, Dean Edwards
License: http://www.opensource.org/licenses/mit-license.php
*/
// array-like enumeration
if (!Array.forEach) { // mozilla already supports this
Array.forEach = function(array, block, context) {
for (var i = 0; i < array.length; i++) {
block.call(context, array[i], i, array);
}
};
}
// generic enumeration
Function.prototype.forEach = function(object, block, context) {
for (var key in object) {
if (typeof this.prototype[key] == "undefined") {
block.call(context, object[key], key, object);
}
}
};
// character enumeration
String.forEach = function(string, block, context) {
Array.forEach(string.split(""), function(chr, index) {
block.call(context, chr, index, string);
});
};
// globally resolve forEach enumeration
var forEach = function(object, block, context) {
if (object) {
var resolve = Object; // default
if (object instanceof Function) {
// functions have a "length" property
resolve = Function;
} else if (object.forEach instanceof Function) {
// the object implements a custom forEach method so use that
object.forEach(block, context);
return;
} else if (typeof object == "string") {
// the object is a string
resolve = String;
} else if (typeof object.length == "number") {
// the object is array-like
resolve = Array;
}
resolve.forEach(object, block, context);
}
};

View file

@ -1,94 +0,0 @@
th {
color: #6D929B;
}
td {
white-space:nowrap;
}
td.address {
color:gray;
font-family: monospace;
}
span.memory {
color:blue;
white-space: nowrap;
cursor:default;
}
table {
border-width:10px;
}
span.perms {
color:gray;
font-family: monospace;
}
td.perms {
font-family: monospace;
}
td.memory, th.memory {
text-align: right;
white-space: nowrap;
}
td.comment {
color:gray;
}
div.innertoc {
float:right;
background-color: #eeeeee;
padding:5px;
}
div.summaryTable {
float:left;
padding:0px;
min-width:48%;
}
thead th {
border-color: gray;
border-style: solid;
border-width: 0px 0px 1px 0px;
}
table {
margin-left: auto;
margin-right: auto;
}
table.sortable th {
cursor:default;
}
tbody.hidden {
display:none;
}
div.fullDetails {
clear:both;
float:left;
}
table.fullDetails {
display:none;
width: 100%;
}
table.librarySummary {
width: 48%;
}
a.page {
display:block;
text-align: right;
}
td {
padding: 0em 0.3em;
}
tfoot.showFullLibrarySummaryLink {
font-size: small;
text-align: right;
}
span.definedWord {
border-bottom: dashed 1px blue;
cursor:help;
}
th.definedWord {
cursor:help;
}
span.errorMessage {
color: red;
}