Documentation

Folder Add-Ins App

Example
The below image and follow-up html data represents an example of a folder app add-in, that upon file item selection changes, will then perform various math calculations.
App start page
<!DOCTYPE html>
<head>

<style>

body {
	color: black;
	background-color: #F8F8F8;
	margin: 0px 0px 0px 0px;
	font-family:Segoe UI;
	font-size:14px
	text-align:center;
	vertical-align:middle;
}

.title {
	
	text-align:right;
	color: blue;
	background-color: #F8F8F8;
	font-family:Segoe UI;
	font-size:10px
	vertical-align:middle;
}


</style>

</head>

<body>

<div style="text-align:center">
<div style="margin-top:5px">
<span id="column_name" class="column_name">Column Name</span>
</div>

<table style="margin-left:auto;margin-right:auto" border="0" cellpadding="4" cellspacing="4">
<tr><td class="title">Count:</td><td id="Count"> </td></tr>
<tr><td class="title">Sum:</td><td id="Total"> </td></tr>
<tr><td class="title">Avg:</td><td id="Avg"> </td></tr>
<tr><td class="title">Min:</td><td id="Min"> </td></tr>
<tr><td class="title">Max:</td><td id="Max"> </td></tr>
</table>
</div>

<div id="Msg"></div>

</body>

<script>

// Catch and display Javascript errors
window.onerror = function(errorMsg, url, lineNumber) {

	alert('Error:\n' + '\n\nScript:\n' + url + '\n\nLine:' + lineNumber);
}

function calcSelected() {
	
	//
	var SelectedColumnName = JConnect.getVisibleColumnName(JConnect.getSelectedColumnIndex());
	document.getElementById("column_name").innerHTML = SelectedColumnName;
	
	//
	var SelectedRows = JConnect.getSelectedRows();
	
	//
	var FolderFile;
	var obj;
	var Total = 0;
	var Average = 0;
	var Max = null;
	var Min = null;
	var SelectedValue;
	
	//
	for (a=0;a<SelectedRows.length;a++) {
		
		//
		FolderFile = JConnect.getFolderFile(SelectedRows[a]);
		obj = JSON.parse(FolderFile);
		SelectedValue = parseFloat(obj[SelectedColumnName].value);
		
		if ( isNaN(SelectedValue) ) { 
			continue;
		}
		
		//
		Total += SelectedValue;
		
		// Min
		if ( Min == null ) {
			Min = SelectedValue;
		} else if ( SelectedValue < Min ) {
			Min = SelectedValue;
		}
		
		// Max
		if ( Max == null ) {
			Max = SelectedValue;
		} else if ( SelectedValue > Max ) {
			Max = SelectedValue;
		}
		
	}

	document.getElementById("Count").innerHTML = SelectedRows.length;
	document.getElementById("Max").innerHTML = Max;
	document.getElementById("Min").innerHTML = Min;
	document.getElementById("Total").innerHTML = Total;
	document.getElementById("Avg").innerHTML = (Total / SelectedRows.length);
}


// Interoperate methods auto called by IntelliCabinet
function jconnectFolderDataChanged() {
	calcSelected();
}

function jconnectFolderSelectionChanged() {
	calcSelected();
}

// Intial calculation
calcSelected();

</script>

</html>