" +
"" +
results[i].Name +
" | " +
"" +
results[i].OfficeAddress +
" | " +
"" +
results[i].OfficeCity +
" | " +
"" +
results[i].OfficeState +
" | " +
"" +
results[i].OfficeZip +
" | " +
"" +
results[i].MailingAddress +
" | " +
"" +
results[i].MailingCity +
" | " +
"" +
results[i].MailingState +
" | " +
"" +
results[i].MailingZip +
" | " +
"" +
results[i].SuperintendentFirstName + " " + results[i].SuperintendentLastName +
" | " +
"" +
results[i].SuperintendentFirstName +
" | " +
"" +
results[i].SuperintendentLastName +
" | " +
"" +
results[i].SuperintendentEmail +
" | " +
"" +
adminAsst +
" | " +
"" +
adminAsstEmail +
" | " +
"" +
(results[i].Website != null ? "" : "") +
" | " +
"" +
(results[i].OfficePhone != null ? "" + results[i].OfficePhone + "" : "") +
" | " +
"" +
(results[i].OfficeFax != null && results[i].OfficeFax.length > 0 ? "" + formatPhoneNumber(results[i].OfficeFax) + "" : "") +
" | " +
"
");
adminAsst = "";
adminAsstEmail = "";
}
$(".directoryOption:not(.selected)").each(function () {
var tt = $(this).data(target);
$(tt).addClass(hidden)
});
};
function formatPhoneNumber(phoneNumber) {
phoneNumber = phoneNumber.trimRight();
if (phoneNumber != null && phoneNumber.length == 10) {
return phoneNumber.slice(0, 3) + "-" + phoneNumber.slice(3, 6) + "-" + phoneNumber.slice(6);
}
else if (phoneNumber != null && phoneNumber.length == 7) {
return phoneNumber.slice(0, 3) + "-" + phoneNumber.slice(3);
}
else {
return phoneNumber;
}
};
function exportTableToCSV($table, filename) {
var $rows = $table.find('table.directory tr:has(th),tr.directoryItem:not(.hidden)'),
// Temporary delimiter characters unlikely to be typed by keyboard
// This is to avoid accidentally splitting the actual contents
tmpColDelim = String.fromCharCode(11), // vertical tab character
tmpRowDelim = String.fromCharCode(0), // null character
// actual delimiter characters for CSV format
colDelim = '","',
rowDelim = '"\r\n"',
// Grab text from table into CSV formatted string
csv = '"' + $rows.map(function (i, row) {
var $row = $(row), $cols = $row.find('td:not(.hidden),th:not(.hidden)');
return $cols.map(function (j, col) {
var $col = $(col), text = $col.text();
return text.replace(/"/g, '""'); // escape double quotes
}).get().join(tmpColDelim);
}).get().join(tmpRowDelim)
.split(tmpRowDelim).join(rowDelim)
.split(tmpColDelim).join(colDelim) + '"',
// Data URI
csvData = 'data:application/csv;charset=utf-8,' + encodeURIComponent(csv);
//console.log(csv);
if (window.navigator.msSaveBlob) { // IE 10+
//alert('IE' + csv);
window.navigator.msSaveOrOpenBlob(new Blob([csv], { type: "text/plain;charset=utf-8;" }), filename)
}
else {
$(this).attr({ 'download': filename, 'href': csvData, 'target': '_blank' });
}
};