//ugly IE workaround for plotly
if (typeof Uint8ClampedArray == 'undefined'){
//just define it as a regular array
Uint8ClampedArray = function(){return []};
}
function sqlEscape(str) {
str = JSON.stringify(str);
/*str = str.replace(/[\0\x08\x09\x1a\n\r"'\\\%]/g, function (char) {
switch (char) {
case "\0":
return "\\0";
case "\x08":
return "\\b";
case "\x09":
return "\\t";
case "\x1a":
return "\\z";
case "\n":
return "\\n";
case "\r":
return "\\r";
case "\"":
case "\\":
case "%":
return "";
}
});*/
str = str.replace(/'/g, "''")
str = str.replace(/"/g, "'");
str = str.replace(/[[\]]/g,'');
return str;
}
//
function msieversion() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) // If Internet Explorer, return true
{
return true;
}
return false;
}
function JSONToCSVConvertor(JSONData, fileName, ShowLabel) {
var arrData = typeof JSONData != 'object' ? JSON.parse(JSONData) : JSONData;
var CSV = '';
if (ShowLabel) {
var row = "";
for (var index in arrData[0]) {
row += index + ',';
}
row = row.slice(0, -1);
CSV += row + '\r\n';
}
for (var i = 0; i < arrData.length; i++) {
var row = "";
for (var index in arrData[i]) {
var arrValue = arrData[i][index] == null ? "" : '"' + arrData[i][index] + '"';
row += arrValue + ',';
}
row.slice(0, row.length - 1);
CSV += row + '\r\n';
}
if (CSV == '') {
growl.error("Invalid data");
return;
}
if(msieversion()){
IEExportFrame.document.open("text/csv", "replace");
IEExportFrame.charset = "utf-8";
IEExportFrame.document.write('sep=,\r\n' + CSV);
IEExportFrame.document.close();
IEExportFrame.focus()
IEExportFrame.document.execCommand('SaveAs', true, fileName + '.txt');
} else {
var uri = 'data:application/csv;charset=utf-8,' + escape(CSV);
link = document.createElement("a");
link.href = uri;
link.style = "visibility:hidden";
link.download = fileName + ".csv";
document.body.appendChild(link);
link.click();
}
}
var link;
// FixWorkspace() - Adjusts the scrollable area for SP.
function FixWorkspace() {
// if you are using a header that is affixed to the top (i.e. SharePoint Ribbon) put the ID or class here to change the workspace height accordingly.
var header = '#authWrapper';
var width = $(window).width();
var height;
if ($(header).is(":visible") && $(header).length) {
height = $(window).height() - $(header).height();
} else {
height = $(window).height();
}
$('#s4-workspace').width(width).height(height);
$('#dataTables_wrapper').width(width);
}
$(document).ready(function() {
FixWorkspace();
});
var utilResize;
$(window).resize(function() {
clearTimeout(utilResize);
utilResize = setTimeout(function(){
FixWorkspace();
StickyHeader();
}, 500);
});
function generateUUID(){
var d = new Date().getTime();
if(window.performance && typeof window.performance.now === "function"){
d += performance.now(); //use high-precision timer if available
}
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = (d + Math.random()*16)%16 | 0;
d = Math.floor(d/16);
return (c=='x' ? r : (r&0x3|0x8)).toString(16);
});
return uuid;
}
// Make headers sticky on page, so not hidden when scrolling.
var sticky;
function StickyHeader()
{
if ($("#resultsWindow tbody").first().offset() != null)
{
if ($("#resultsWindow tbody").first().offset().top < $("#s4-workspace").offset().top)
{
if (sticky != null)
{
$(sticky).remove();
}
sticky = $("#resultsWindow thead").first().clone(true,true).insertAfter($("#resultsWindow thead").first());
sticky.attr("style","position: fixed; border: 1px solid grey; background-color: white; box-shadow: 0 0 6px -2px black;");
sticky.css("top",$("#s4-workspace").offset().top);
sticky.css("z-index",1); // pull in front of expander elements
sticky.css("width",$("#resultsWindow tbody").first().css("width"));
$(sticky).on('resize', function (e) {
e.stopPropagation();
});
//adjust width to match columns
var itr = 0;
$("#resultsWindow tr:nth-child(1)").children("th").each(function() {
itr++;
if ($(this).css("display") != "none") // filter out hidden columns
{
$(sticky).find("th:nth-child("+itr+")").css("width",$(this).css("width"));
}
});
sticky.show();
} else
{
if (sticky != null)
{
sticky.hide();
}
}
}
}
$("#s4-workspace").on("scroll",StickyHeader);
/*!
* JavaScript Cookie v2.2.0
* https://github.com/js-cookie/js-cookie
*
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
* Released under the MIT license
*/
;(function (factory) {
var registeredInModuleLoader = false;
if (typeof define === 'function' && define.amd) {
define(factory);
registeredInModuleLoader = true;
}
if (typeof exports === 'object') {
module.exports = factory();
registeredInModuleLoader = true;
}
if (!registeredInModuleLoader) {
var OldCookies = window.Cookies;
var api = window.Cookies = factory();
api.noConflict = function () {
window.Cookies = OldCookies;
return api;
};
}
}(function () {
function extend () {
var i = 0;
var result = {};
for (; i < arguments.length; i++) {
var attributes = arguments[ i ];
for (var key in attributes) {
result[key] = attributes[key];
}
}
return result;
}
function init (converter) {
function api (key, value, attributes) {
var result;
if (typeof document === 'undefined') {
return;
}
// Write
if (arguments.length > 1) {
attributes = extend({
path: '/'
}, api.defaults, attributes);
if (typeof attributes.expires === 'number') {
var expires = new Date();
expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
attributes.expires = expires;
}
// We're using "expires" because "max-age" is not supported by IE
attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
try {
result = JSON.stringify(value);
if (/^[\{\[]/.test(result)) {
value = result;
}
} catch (e) {}
if (!converter.write) {
value = encodeURIComponent(String(value))
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
} else {
value = converter.write(value, key);
}
key = encodeURIComponent(String(key));
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
key = key.replace(/[\(\)]/g, escape);
var stringifiedAttributes = '';
for (var attributeName in attributes) {
if (!attributes[attributeName]) {
continue;
}
stringifiedAttributes += '; ' + attributeName;
if (attributes[attributeName] === true) {
continue;
}
stringifiedAttributes += '=' + attributes[attributeName];
}
return (document.cookie = key + '=' + value + stringifiedAttributes);
}
// Read
if (!key) {
result = {};
}
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling "get()"
var cookies = document.cookie ? document.cookie.split('; ') : [];
var rdecode = /(%[0-9A-Z]{2})+/g;
var i = 0;
for (; i < cookies.length; i++) {
var parts = cookies[i].split('=');
var cookie = parts.slice(1).join('=');
if (!this.json && cookie.charAt(0) === '"') {
cookie = cookie.slice(1, -1);
}
try {
var name = parts[0].replace(rdecode, decodeURIComponent);
cookie = converter.read ?
converter.read(cookie, name) : converter(cookie, name) ||
cookie.replace(rdecode, decodeURIComponent);
if (this.json) {
try {
cookie = JSON.parse(cookie);
} catch (e) {}
}
if (key === name) {
result = cookie;
break;
}
if (!key) {
result[name] = cookie;
}
} catch (e) {}
}
return result;
}
api.set = api;
api.get = function (key) {
return api.call(api, key);
};
api.getJSON = function () {
return api.apply({
json: true
}, [].slice.call(arguments));
};
api.defaults = {};
api.remove = function (key, attributes) {
api(key, '', extend(attributes, {
expires: -1
}));
};
api.withConverter = init;
return api;
}
return init(function () {});
}));
function FormatPath(url)
{
if (url != null)
{
url = url.replace("&","and").replace("/","");
if (url.toLowerCase().indexOf(".pdf")<0)
url = url + ".pdf";
}
return url;
}
// Build HTML for review popups.
function GetReviewStatus(reviewData, docName)
{
if (reviewData != null)
{
if (reviewData.responseXML)
{
var customHtml = "";
$(reviewData.responseXML).SPFilterNode("z:row").each(function() {
if ($(this).attr("ows_LinkFilename") != null)
{
if ($(this).attr("ows_LinkFilename") == docName)
{
usable = "";
notUsable = "";
screenLevel = "";
if ($(this).attr("ows_UsableCivil") != null)
{
usable += "Civil: ";
usable += Truncate($(this).attr("ows_UsableCivil"), 100);
usable += "
";
}
if ($(this).attr("ows_UsableEnv") != null)
{
usable += "Environmental: ";
usable += Truncate($(this).attr("ows_UsableEnv"), 100);
usable += "
";
}
if ($(this).attr("ows_UsableGeo") != null)
{
usable += "Geotechnical: ";
usable += Truncate($(this).attr("ows_UsableGeo"), 100);
usable += "
";
}
if ($(this).attr("ows_UsableHydro") != null)
{
usable += "Hydrogeological: ";
usable += Truncate($(this).attr("ows_UsableHydro"), 100);
usable += "
";
}
if ($(this).attr("ows_UsableQuality") != null)
{
usable += "Quality: ";
usable += Truncate($(this).attr("ows_UsableQuality"), 100);
usable += "
";
}
if ($(this).attr("ows_UsableRisk") != null)
{
usable += "Risk/NRDA: ";
usable += Truncate($(this).attr("ows_UsableRisk"), 100);
usable += "
";
}
if ($(this).attr("ows_NotUsableCivil") != null)
{
notUsable += "Civil: ";
notUsable += Truncate($(this).attr("ows_NotUsableCivil"), 100);
notUsable += "
";
}
if ($(this).attr("ows_NotUsableEnv") != null)
{
notUsable += "Environmental: ";
notUsable += Truncate($(this).attr("ows_NotUsableEnv"), 100);
notUsable += "
";
}
if ($(this).attr("ows_NotUsableGeo") != null)
{
notUsable += "Geotechnical: ";
notUsable += Truncate($(this).attr("ows_NotUsableGeo"), 100);
notUsable += "
";
}
if ($(this).attr("ows_NotUsableHydro") != null)
{
notUsable += "Hydrogeological: ";
notUsable += Truncate($(this).attr("ows_NotUsableHydro"), 100);
notUsable += "
";
}
if ($(this).attr("ows_NotUsableQuality") != null)
{
notUsable += "Quality: ";
notUsable += Truncate($(this).attr("ows_NotUsableQuality"), 100);
notUsable += "
";
}
if ($(this).attr("ows_NotUsableRisk") != null)
{
notUsable += "Risk/NRDA: ";
notUsable += Truncate($(this).attr("ows_NotUsableRisk"), 100);
notUsable += "
";
}
if ($(this).attr("ows_ScreeningCivil") != null)
{
screenLevel += "Civil: ";
screenLevel += Truncate($(this).attr("ows_ScreeningCivil"), 100);
screenLevel += "
";
}
if ($(this).attr("ows_ScreeningEnv") != null)
{
screenLevel += "Environmental: ";
screenLevel += Truncate($(this).attr("ows_ScreeningEnv"), 100);
screenLevel += "
";
}
if ($(this).attr("ows_ScreeningGeo") != null)
{
screenLevel += "Geotechnical: ";
screenLevel += Truncate($(this).attr("ows_ScreeningGeo"), 100);
screenLevel += "
";
}
if ($(this).attr("ows_ScreeningHydro") != null)
{
screenLevel += "Hydrogeological: ";
screenLevel += Truncate($(this).attr("ows_ScreeningHydro"), 100);
screenLevel += "
";
}
if ($(this).attr("ows_ScreeningQuality") != null)
{
screenLevel += "Quality: ";
screenLevel += Truncate($(this).attr("ows_ScreeningQuality"), 100);
screenLevel += "
";
}
if ($(this).attr("ows_ScreeningRisk") != null)
{
screenLevel += "Risk/NRDA: ";
screenLevel += Truncate($(this).attr("ows_ScreeningRisk"), 100);
screenLevel += "
";
}
if (usable.length > 0)
customHtml += "