thingspeak/public/assets/application.js
2014-06-26 22:45:44 -04:00

2 lines
53 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function reloadCharts(){return-1===navigator.userAgent.toLowerCase().indexOf("firefox")?!1:($('.ui-widget-content [aria-expanded="false"]').find("iframe").each(function(){var e=$(this).attr("src");-1!==e.indexOf("charts")&&($(this).hide(),$(this).attr("src",e),$(this).show())}),void 0)}function openDialogCenter(e){e.dialog("open");var t=getDimensions(e.parent());e.dialog({position:[t[0],t[1]]})}function getDimensions(e){var t=new Array(2);return t[0]=$(window).width()/2-e.width()/2,t[1]=$(window).height()/2-e.height()/2,t}function updateChart(e,t,n,r,a,i){var n=n,r=r,o=$("#iframe"+e).attr("default_src");o||(o=$("#iframe"+e).attr("src")),src=o.split("?")[0],("bar"===$("#type_"+e).val()||"column"===$("#type_"+e).val())&&0==$("#timescale_"+e).val().length&&0==$("#average_"+e).val().length&&0==$("#median_"+e).val().length&&0==$("#sum_"+e).val().length&&$("#timescale_"+e).val(30);var s=[];$(".chart_options"+e).each(function(){var e=$(this).val(),t=$(this).attr("id"),n=t.split("_")[0];e.length>0&&s.push([n,e])});for(var l="";s.length>0;){var c=s.pop();"width"==c[0]&&(n=parseInt(c[1])),"height"==c[0]&&(r=parseInt(c[1])),("type"!=c[0]||"line"!=c[1])&&(l+="&"+c[0]+"="+encodeURIComponent(c[1]))}l.length>0&&(src+="?"+l.substring(1)),t&&e>0&&i?$.update("/channels/"+a+"/charts/"+e,{newOptions:{options:l}}):t&&e>0&&$.update("/channels/"+a+"/charts/"+e,{options:l}),$("#embed"+e).val('<iframe width="'+n+'" height="'+r+'" style="border: 1px solid #cccccc;" src="'+src+'"></iframe>'),$("#iframe"+e).attr("src",src),$("#iframe"+e).attr("width",n),$("#iframe"+e).attr("height",r)}function updateSelectValues(){selectedValue=$(this).val(),$(".mutuallyexclusive"+index).each(function(){$(this).val("")}),$(this).val(selectedValue)}function setupChartForm(e){return function(t,n){n.length>0&&$("#"+n.split("=")[0]+"_"+e).val(decodeURIComponent(n.split("=")[1]))}}function setupColumns(e,t){$(sortColumnSetup(e,t)),$(".column").disableSelection()}function createWindowsWithData(e,t,n,r){for(var a in e){for(var i in e[a])var o=i;if(e[a].chart_window&&(s=e[a].chart_window),e[a].plugin_window&&(s=e[a].plugin_window),e[a].portlet_window&&(s=e[a].portlet_window),"undefined"==s)var s=e[a].portlet_window?e[a].portlet_window:e[a].chart_window;colId=s.col,title=s.title;var l=s.html;if(e[a].chart_window){var c=s.id;$("body").append("<div id='chartConfig"+c+"'></div>")}var d=addWindow(r,colId,s.id,o,title,l);d.each(decoratePortlet(t)),d.find(".ui-toggle").click(uiToggleClick),d.find(".ui-view").click(uiViewClick(n)),d.find(".ui-edit").click(uiEditClick(n)),d.find(".ui-close").click(uiCloseClick(n))}}function addWindow(e,t,n,r,a,i){if($("#"+e+"_dialog"+t).append('<div class="portlet ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" id="portlet_'+n+'"><div class="portlet-header wtype wtype-'+r+' ui-widget-header ui-corner-all">'+a+'</div><div class="portlet-content">'+i+"</div>"),$("#portlet_"+n).length>1)throw"Portlet count doesn't match what's expected";return $("#portlet_"+n)}function sortColumnSetup(e,t){$(".column").sortable({opacity:.6,helper:function(){return $("<div class='ui-widget-header'>Drop to re-position</div>")},connectWith:".column",update:updatePortletPositions(e,t)})}function getPortletArray(e){var t=new Array,n=e.split("&");for(i in n)val=n[i].split("=")[1],t.push(val);return t}function uiToggleClick(){$(this).toggleClass("ui-icon-minusthick").toggleClass("ui-icon-plusthick"),$(this).parents(".portlet:first").find(".portlet-content").toggle()}!function(e,t){e.rails!==t&&e.error("jquery-ujs has already been loaded!");var n,r=e(document);e.rails=n={linkClickSelector:"a[data-confirm], a[data-method], a[data-remote], a[data-disable-with]",buttonClickSelector:"button[data-remote]",inputChangeSelector:"select[data-remote], input[data-remote], textarea[data-remote]",formSubmitSelector:"form",formInputClickSelector:"form input[type=submit], form input[type=image], form button[type=submit], form button:not([type])",disableSelector:"input[data-disable-with], button[data-disable-with], textarea[data-disable-with]",enableSelector:"input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled",requiredInputSelector:"input[name][required]:not([disabled]),textarea[name][required]:not([disabled])",fileInputSelector:"input[type=file]",linkDisableSelector:"a[data-disable-with]",CSRFProtection:function(t){var n=e('meta[name="csrf-token"]').attr("content");n&&t.setRequestHeader("X-CSRF-Token",n)},fire:function(t,n,r){var a=e.Event(n);return t.trigger(a,r),a.result!==!1},confirm:function(e){return confirm(e)},ajax:function(t){return e.ajax(t)},href:function(e){return e.attr("href")},handleRemote:function(r){var a,i,o,s,l,c,d,u;if(n.fire(r,"ajax:before")){if(s=r.data("cross-domain"),l=s===t?null:s,c=r.data("with-credentials")||null,d=r.data("type")||e.ajaxSettings&&e.ajaxSettings.dataType,r.is("form")){a=r.attr("method"),i=r.attr("action"),o=r.serializeArray();var f=r.data("ujs:submit-button");f&&(o.push(f),r.data("ujs:submit-button",null))}else r.is(n.inputChangeSelector)?(a=r.data("method"),i=r.data("url"),o=r.serialize(),r.data("params")&&(o=o+"&"+r.data("params"))):r.is(n.buttonClickSelector)?(a=r.data("method")||"get",i=r.data("url"),o=r.serialize(),r.data("params")&&(o=o+"&"+r.data("params"))):(a=r.data("method"),i=n.href(r),o=r.data("params")||null);u={type:a||"GET",data:o,dataType:d,beforeSend:function(e,a){return a.dataType===t&&e.setRequestHeader("accept","*/*;q=0.5, "+a.accepts.script),n.fire(r,"ajax:beforeSend",[e,a])},success:function(e,t,n){r.trigger("ajax:success",[e,t,n])},complete:function(e,t){r.trigger("ajax:complete",[e,t])},error:function(e,t,n){r.trigger("ajax:error",[e,t,n])},crossDomain:l},c&&(u.xhrFields={withCredentials:c}),i&&(u.url=i);var h=n.ajax(u);return r.trigger("ajax:send",h),h}return!1},handleMethod:function(r){var a=n.href(r),i=r.data("method"),o=r.attr("target"),s=e("meta[name=csrf-token]").attr("content"),l=e("meta[name=csrf-param]").attr("content"),c=e('<form method="post" action="'+a+'"></form>'),d='<input name="_method" value="'+i+'" type="hidden" />';l!==t&&s!==t&&(d+='<input name="'+l+'" value="'+s+'" type="hidden" />'),o&&c.attr("target",o),c.hide().append(d).appendTo("body"),c.submit()},disableFormElements:function(t){t.find(n.disableSelector).each(function(){var t=e(this),n=t.is("button")?"html":"val";t.data("ujs:enable-with",t[n]()),t[n](t.data("disable-with")),t.prop("disabled",!0)})},enableFormElements:function(t){t.find(n.enableSelector).each(function(){var t=e(this),n=t.is("button")?"html":"val";t.data("ujs:enable-with")&&t[n](t.data("ujs:enable-with")),t.prop("disabled",!1)})},allowAction:function(e){var t,r=e.data("confirm"),a=!1;return r?(n.fire(e,"confirm")&&(a=n.confirm(r),t=n.fire(e,"confirm:complete",[a])),a&&t):!0},blankInputs:function(t,n,r){var a,i,o=e(),s=n||"input,textarea",l=t.find(s);return l.each(function(){if(a=e(this),i=a.is("input[type=checkbox],input[type=radio]")?a.is(":checked"):a.val(),!i==!r){if(a.is("input[type=radio]")&&l.filter('input[type=radio]:checked[name="'+a.attr("name")+'"]').length)return!0;o=o.add(a)}}),o.length?o:!1},nonBlankInputs:function(e,t){return n.blankInputs(e,t,!0)},stopEverything:function(t){return e(t.target).trigger("ujs:everythingStopped"),t.stopImmediatePropagation(),!1},disableElement:function(e){e.data("ujs:enable-with",e.html()),e.html(e.data("disable-with")),e.bind("click.railsDisable",function(e){return n.stopEverything(e)})},enableElement:function(e){e.data("ujs:enable-with")!==t&&(e.html(e.data("ujs:enable-with")),e.removeData("ujs:enable-with")),e.unbind("click.railsDisable")}},n.fire(r,"rails:attachBindings")&&(e.ajaxPrefilter(function(e,t,r){e.crossDomain||n.CSRFProtection(r)}),r.delegate(n.linkDisableSelector,"ajax:complete",function(){n.enableElement(e(this))}),r.delegate(n.linkClickSelector,"click.rails",function(r){var a=e(this),i=a.data("method"),o=a.data("params");if(!n.allowAction(a))return n.stopEverything(r);if(a.is(n.linkDisableSelector)&&n.disableElement(a),a.data("remote")!==t){if(!(!r.metaKey&&!r.ctrlKey||i&&"GET"!==i||o))return!0;var s=n.handleRemote(a);return s===!1?n.enableElement(a):s.error(function(){n.enableElement(a)}),!1}return a.data("method")?(n.handleMethod(a),!1):void 0}),r.delegate(n.buttonClickSelector,"click.rails",function(t){var r=e(this);return n.allowAction(r)?(n.handleRemote(r),!1):n.stopEverything(t)}),r.delegate(n.inputChangeSelector,"change.rails",function(t){var r=e(this);return n.allowAction(r)?(n.handleRemote(r),!1):n.stopEverything(t)}),r.delegate(n.formSubmitSelector,"submit.rails",function(r){var a=e(this),i=a.data("remote")!==t,o=n.blankInputs(a,n.requiredInputSelector),s=n.nonBlankInputs(a,n.fileInputSelector);if(!n.allowAction(a))return n.stopEverything(r);if(o&&a.attr("novalidate")==t&&n.fire(a,"ajax:aborted:required",[o]))return n.stopEverything(r);if(i){if(s){setTimeout(function(){n.disableFormElements(a)},13);var l=n.fire(a,"ajax:aborted:file",[s]);return l||setTimeout(function(){n.enableFormElements(a)},13),l}return n.handleRemote(a),!1}setTimeout(function(){n.disableFormElements(a)},13)}),r.delegate(n.formInputClickSelector,"click.rails",function(t){var r=e(this);if(!n.allowAction(r))return n.stopEverything(t);var a=r.attr("name"),i=a?{name:a,value:r.val()}:null;r.closest("form").data("ujs:submit-button",i)}),r.delegate(n.formSubmitSelector,"ajax:beforeSend.rails",function(t){this==t.target&&n.disableFormElements(e(this))}),r.delegate(n.formSubmitSelector,"ajax:complete.rails",function(t){this==t.target&&n.enableFormElements(e(this))}),e(function(){var t=e("meta[name=csrf-token]").attr("content"),n=e("meta[name=csrf-param]").attr("content");e('form input[name="'+n+'"]').val(t)}))}(jQuery),function(e){e.cookie=function(t,n,r){if(arguments.length>1&&(!/Object/.test(Object.prototype.toString.call(n))||null===n||void 0===n)){if(r=e.extend({},r),(null===n||void 0===n)&&(r.expires=-1),"number"==typeof r.expires){var a=r.expires,i=r.expires=new Date;i.setDate(i.getDate()+a)}return n=String(n),document.cookie=[encodeURIComponent(t),"=",r.raw?n:encodeURIComponent(n),r.expires?"; expires="+r.expires.toUTCString():"",r.path?"; path="+r.path:"",r.domain?"; domain="+r.domain:"",r.secure?"; secure":""].join("")}r=n||{};for(var o,s=r.raw?function(e){return e}:decodeURIComponent,l=document.cookie.split("; "),c=0;o=l[c]&&l[c].split("=");c++)if(s(o[0])===t)return s(o[1]||"");return null}}(jQuery);var createWindows=function(e,t,n){return function(r){createWindowsWithData(r,e,t,n)}},updatePortletPositions=function(e,t){return function(){if(e){var n=$(this).sortable("serialize");colId=$(this).attr("id").charAt($(this).attr("id").length-1),portletArray=getPortletArray(n),jsonResult={col:colId,positions:portletArray},portletArray.length>0&&$.ajax({type:"PUT",url:"../channels/"+t+"/windows",data:{_method:"PUT",page:JSON.stringify(jsonResult)},dataType:"json"})}}},decoratePortlet=function(e){return function(){var t=$(this).find(".portlet-header");return t.append("<span id='commentBtn' class='ui-view ui-icon ui-icon-comment'></span>"),thisObject=$(this),"true"==e?(thisObject.find(".wtype").prepend("<span id='minusBtn' class='ui-toggle ui-icon ui-icon-minusthick'></span>"),thisObject.find(".wtype-chart_window").append("<span id='pencilBtn' class='ui-edit ui-icon ui-icon-pencil'></span>"),thisObject.find(".wtype").append("<span id='closeBtn' class='ui-close ui-icon ui-icon-close'></span>"),thisObject.find(".portlet-header").css("cursor","move")):$(".column").sortable({disabled:!0}),$(this).attr("id")}},uiEditClick=function(e){return function(){var t=$(this).parents(".portlet:first").attr("id").substring(8),n="";$("#chartConfig"+t).load("/channels/"+e+"/charts/"+t+"/edit",function(){n=$("#chartOptions"+t).html(),"undefined"!=n&&n.length>2&&$.each(n.split("&amp;"),setupChartForm(t)),$("#button"+t).click(function(){updateChart(t,!0,450,250,e,!0),$("#chartConfig"+t).dialog("close")})}).dialog({title:"Chart Options",modal:!0,resizable:!1,width:500,dialogClass:"dev-info-dialog"})}},uiViewClick=function(e){return function(){var t=$(this).parents(".portlet:first").find(".portlet-content").offset().left,n=$(this).parents(".portlet:first").find(".portlet-content").offset().top,r=$(this).parents(".portlet:first").attr("id").substring(8);$("body").append('<div id="iframepopup'+r+'" style="display:none"><div id="iframeinner'+r+'"style="font-size:1.2em;overflow:auto;height:115px;background-color:white"></div></div>'),$.get("/channels/"+e+"/windows/"+r+"/iframe",function(e){var t=e.replace(/id=\"iframe[0-9]?[0-9]?[0-9]?[0-9]?[0-9]?[0-9]?[0-9]?[0-9]?[0-9]?[0-9]?\"/,"");$("#iframeinner"+r).text(t)}),$("#iframepopup"+r).dialog({resizable:!1,width:"300px",position:[t+200,n-200],title:"Chart Iframe",dialogClass:"dev-info-dialog"})}},uiCloseClick=function(e){return function(){var t=$(this).parents(".portlet:first").attr("id").substring(8),n=$(this).parents(".portlet:first");$.update("/channels/"+e+"/windows/"+t+"/hide",function(){n.hide("drop",function(){n.remove()})})}};!function(e){function t(){var t=n(this);return isNaN(t.datetime)||e(this).text(r(t.datetime)),this}function n(t){if(t=e(t),!t.data("timeago")){t.data("timeago",{datetime:i.datetime(t)});var n=e.trim(t.text());n.length>0&&t.attr("title",n)}return t.data("timeago")}function r(e){return i.inWords(a(e))}function a(e){return(new Date).getTime()-e.getTime()}e.timeago=function(t){return t instanceof Date?r(t):"string"==typeof t?r(e.timeago.parse(t)):r(e.timeago.datetime(t))};var i=e.timeago;e.extend(e.timeago,{settings:{refreshMillis:6e4,allowFuture:!1,strings:{prefixAgo:null,prefixFromNow:null,suffixAgo:"ago",suffixFromNow:"from now",seconds:"less than a minute",minute:"about a minute",minutes:"%d minutes",hour:"about an hour",hours:"about %d hours",day:"a day",days:"%d days",month:"about a month",months:"%d months",year:"about a year",years:"%d years",numbers:[]}},inWords:function(t){function n(n,a){var i=e.isFunction(n)?n(a,t):n,o=r.numbers&&r.numbers[a]||a;return i.replace(/%d/i,o)}var r=this.settings.strings,a=r.prefixAgo,i=r.suffixAgo;this.settings.allowFuture&&(0>t&&(a=r.prefixFromNow,i=r.suffixFromNow),t=Math.abs(t));var o=t/1e3,s=o/60,l=s/60,c=l/24,d=c/365,u=45>o&&n(r.seconds,Math.round(o))||90>o&&n(r.minute,1)||45>s&&n(r.minutes,Math.round(s))||90>s&&n(r.hour,1)||24>l&&n(r.hours,Math.round(l))||48>l&&n(r.day,1)||30>c&&n(r.days,Math.floor(c))||60>c&&n(r.month,1)||365>c&&n(r.months,Math.floor(c/30))||2>d&&n(r.year,1)||n(r.years,Math.floor(d));return e.trim([a,u,i].join(" "))},parse:function(t){var n=e.trim(t);return n=n.replace(/\.\d\d\d+/,""),n=n.replace(/-/,"/").replace(/-/,"/"),n=n.replace(/T/," ").replace(/Z/," UTC"),n=n.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"),new Date(n)},datetime:function(t){var n="time"===e(t).get(0).tagName.toLowerCase(),r=n?e(t).attr("datetime"):e(t).attr("title");return i.parse(r)}}),e.fn.timeago=function(){var e=this;e.each(t);var n=i.settings;return n.refreshMillis>0&&setInterval(function(){e.each(t)},n.refreshMillis),e},document.createElement("abbr"),document.createElement("time")}(jQuery),function($){$.extend({tablesorter:new function(){function benchmark(e,t){log(e+","+((new Date).getTime()-t.getTime())+"ms")}function log(e){"undefined"!=typeof console&&"undefined"!=typeof console.debug?console.log(e):alert(e)}function buildParserCache(e,t){if(e.config.debug)var n="";if(0!=e.tBodies.length){var r=e.tBodies[0].rows;if(r[0])for(var a=[],i=r[0].cells,o=i.length,s=0;o>s;s++){var l=!1;$.metadata&&$(t[s]).metadata()&&$(t[s]).metadata().sorter?l=getParserById($(t[s]).metadata().sorter):e.config.headers[s]&&e.config.headers[s].sorter&&(l=getParserById(e.config.headers[s].sorter)),l||(l=detectParserForColumn(e,r,-1,s)),e.config.debug&&(n+="column:"+s+" parser:"+l.id+"\n"),a.push(l)}return e.config.debug&&log(n),a}}function detectParserForColumn(e,t,n,r){for(var a=parsers.length,i=!1,o=!1,s=!0;""==o&&s;)n++,t[n]?(i=getNodeFromRowAndCellIndex(t,n,r),o=trimAndGetNodeText(e.config,i),e.config.debug&&log("Checking if value was empty on row:"+n)):s=!1;for(var l=1;a>l;l++)if(parsers[l].is(o,e,i))return parsers[l];return parsers[0]}function getNodeFromRowAndCellIndex(e,t,n){return e[t].cells[n]}function trimAndGetNodeText(e,t){return $.trim(getElementText(e,t))}function getParserById(e){for(var t=parsers.length,n=0;t>n;n++)if(parsers[n].id.toLowerCase()==e.toLowerCase())return parsers[n];return!1}function buildCache(e){if(e.config.debug)var t=new Date;for(var n=e.tBodies[0]&&e.tBodies[0].rows.length||0,r=e.tBodies[0].rows[0]&&e.tBodies[0].rows[0].cells.length||0,a=e.config.parsers,i={row:[],normalized:[]},o=0;n>o;++o){var s=$(e.tBodies[0].rows[o]),l=[];if(s.hasClass(e.config.cssChildRow))i.row[i.row.length-1]=i.row[i.row.length-1].add(s);else{i.row.push(s);for(var c=0;r>c;++c)l.push(a[c].format(getElementText(e.config,s[0].cells[c]),e,s[0].cells[c]));l.push(i.normalized.length),i.normalized.push(l),l=null}}return e.config.debug&&benchmark("Building cache for "+n+" rows:",t),i}function getElementText(e,t){var n="";return t?(e.supportsTextContent||(e.supportsTextContent=t.textContent||!1),n="simple"==e.textExtraction?e.supportsTextContent?t.textContent:t.childNodes[0]&&t.childNodes[0].hasChildNodes()?t.childNodes[0].innerHTML:t.innerHTML:"function"==typeof e.textExtraction?e.textExtraction(t):$(t).text()):""}function appendToTable(e,t){if(e.config.debug)var n=new Date;for(var r=t,a=r.row,i=r.normalized,o=i.length,s=i[0].length-1,l=$(e.tBodies[0]),c=[],d=0;o>d;d++){var u=i[d][s];if(c.push(a[u]),!e.config.appender)for(var f=a[u].length,h=0;f>h;h++)l[0].appendChild(a[u][h])}e.config.appender&&e.config.appender(e,c),c=null,e.config.debug&&benchmark("Rebuilt table:",n),applyWidget(e),setTimeout(function(){$(e).trigger("sortEnd")},0)}function buildHeaders(e){if(e.config.debug)var t=new Date;var n=($.metadata?!0:!1,computeTableHeaderCellIndexes(e));return $tableHeaders=$(e.config.selectorHeaders,e).each(function(t){if(this.column=n[this.parentNode.rowIndex+"-"+this.cellIndex],this.order=formatSortingOrder(e.config.sortInitialOrder),this.count=this.order,(checkHeaderMetadata(this)||checkHeaderOptions(e,t))&&(this.sortDisabled=!0),checkHeaderOptionsSortingLocked(e,t)&&(this.order=this.lockedOrder=checkHeaderOptionsSortingLocked(e,t)),!this.sortDisabled){var r=$(this).addClass(e.config.cssHeader);e.config.onRenderHeader&&e.config.onRenderHeader.apply(r)}e.config.headerList[t]=this}),e.config.debug&&(benchmark("Built headers:",t),log($tableHeaders)),$tableHeaders}function computeTableHeaderCellIndexes(e){for(var t=[],n={},r=e.getElementsByTagName("THEAD")[0],a=r.getElementsByTagName("TR"),i=0;i<a.length;i++)for(var o=a[i].cells,s=0;s<o.length;s++){var l,c=o[s],d=c.parentNode.rowIndex,u=d+"-"+c.cellIndex,f=c.rowSpan||1,h=c.colSpan||1;"undefined"==typeof t[d]&&(t[d]=[]);for(var p=0;p<t[d].length+1;p++)if("undefined"==typeof t[d][p]){l=p;break}n[u]=l;for(var p=d;d+f>p;p++){"undefined"==typeof t[p]&&(t[p]=[]);for(var m=t[p],g=l;l+h>g;g++)m[g]="x"}}return n}function checkCellColSpan(e,t,n){for(var r=[],a=e.tHead.rows,i=a[n].cells,o=0;o<i.length;o++){var s=i[o];s.colSpan>1?r=r.concat(checkCellColSpan(e,headerArr,n++)):(1==e.tHead.length||s.rowSpan>1||!a[n+1])&&r.push(s)}return r}function checkHeaderMetadata(e){return $.metadata&&$(e).metadata().sorter===!1?!0:!1}function checkHeaderOptions(e,t){return e.config.headers[t]&&e.config.headers[t].sorter===!1?!0:!1}function checkHeaderOptionsSortingLocked(e,t){return e.config.headers[t]&&e.config.headers[t].lockedOrder?e.config.headers[t].lockedOrder:!1}function applyWidget(e){for(var t=e.config.widgets,n=t.length,r=0;n>r;r++)getWidgetById(t[r]).format(e)}function getWidgetById(e){for(var t=widgets.length,n=0;t>n;n++)if(widgets[n].id.toLowerCase()==e.toLowerCase())return widgets[n]}function formatSortingOrder(e){return"Number"!=typeof e?"desc"==e.toLowerCase()?1:0:1==e?1:0}function isValueInArray(e,t){for(var n=t.length,r=0;n>r;r++)if(t[r][0]==e)return!0;return!1}function setHeadersCss(e,t,n,r){t.removeClass(r[0]).removeClass(r[1]);var a=[];t.each(function(){this.sortDisabled||(a[this.column]=$(this))});for(var i=n.length,o=0;i>o;o++)a[n[o][0]].addClass(r[n[o][1]])}function fixColumnWidth(e){var t=e.config;if(t.widthFixed){var n=$("<colgroup>");$("tr:first td",e.tBodies[0]).each(function(){n.append($("<col>").css("width",$(this).width()))}),$(e).prepend(n)}}function updateHeaderSortCount(e,t){for(var n=e.config,r=t.length,a=0;r>a;a++){var i=t[a],o=n.headerList[i[0]];o.count=i[1],o.count++}}function multisort(table,sortList,cache){if(table.config.debug)var sortTime=new Date;for(var dynamicExp="var sortWrapper = function(a,b) {",l=sortList.length,i=0;l>i;i++){var c=sortList[i][0],order=sortList[i][1],s="text"==table.config.parsers[c].type?0==order?makeSortFunction("text","asc",c):makeSortFunction("text","desc",c):0==order?makeSortFunction("numeric","asc",c):makeSortFunction("numeric","desc",c),e="e"+i;dynamicExp+="var "+e+" = "+s,dynamicExp+="if("+e+") { return "+e+"; } ",dynamicExp+="else { "}var orgOrderCol=cache.normalized[0].length-1;dynamicExp+="return a["+orgOrderCol+"]-b["+orgOrderCol+"];";for(var i=0;l>i;i++)dynamicExp+="}; ";return dynamicExp+="return 0; ",dynamicExp+="}; ",table.config.debug&&benchmark("Evaling expression:"+dynamicExp,new Date),eval(dynamicExp),cache.normalized.sort(sortWrapper),table.config.debug&&benchmark("Sorting on "+sortList.toString()+" and dir "+order+" time:",sortTime),cache}function makeSortFunction(e,t,n){var r="a["+n+"]",a="b["+n+"]";return"text"==e&&"asc"==t?"("+r+" == "+a+" ? 0 : ("+r+" === null ? Number.POSITIVE_INFINITY : ("+a+" === null ? Number.NEGATIVE_INFINITY : ("+r+" < "+a+") ? -1 : 1 )));":"text"==e&&"desc"==t?"("+r+" == "+a+" ? 0 : ("+r+" === null ? Number.POSITIVE_INFINITY : ("+a+" === null ? Number.NEGATIVE_INFINITY : ("+a+" < "+r+") ? -1 : 1 )));":"numeric"==e&&"asc"==t?"("+r+" === null && "+a+" === null) ? 0 :("+r+" === null ? Number.POSITIVE_INFINITY : ("+a+" === null ? Number.NEGATIVE_INFINITY : "+r+" - "+a+"));":"numeric"==e&&"desc"==t?"("+r+" === null && "+a+" === null) ? 0 :("+r+" === null ? Number.POSITIVE_INFINITY : ("+a+" === null ? Number.NEGATIVE_INFINITY : "+a+" - "+r+"));":void 0}function makeSortText(e){return"((a["+e+"] < b["+e+"]) ? -1 : ((a["+e+"] > b["+e+"]) ? 1 : 0));"}function makeSortTextDesc(e){return"((b["+e+"] < a["+e+"]) ? -1 : ((b["+e+"] > a["+e+"]) ? 1 : 0));"}function makeSortNumeric(e){return"a["+e+"]-b["+e+"];"}function makeSortNumericDesc(e){return"b["+e+"]-a["+e+"];"}function sortText(e,t){return table.config.sortLocaleCompare?e.localeCompare(t):t>e?-1:e>t?1:0}function sortTextDesc(e,t){return table.config.sortLocaleCompare?t.localeCompare(e):e>t?-1:t>e?1:0}function sortNumeric(e,t){return e-t}function sortNumericDesc(e,t){return t-e}function getCachedSortType(e,t){return e[t].type}var parsers=[],widgets=[];this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",cssChildRow:"expand-child",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,sortLocaleCompare:!0,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:!1,cancelSelection:!0,sortList:[],headerList:[],dateFormat:"us",decimal:"/.|,/g",onRenderHeader:null,selectorHeaders:"thead th",debug:!1},this.benchmark=benchmark,this.construct=function(e){return this.each(function(){if(this.tHead&&this.tBodies){var t,n,r,a;this.config={},a=$.extend(this.config,$.tablesorter.defaults,e),t=$(this),$.data(this,"tablesorter",a),n=buildHeaders(this),this.config.parsers=buildParserCache(this,n),r=buildCache(this);var i=[a.cssDesc,a.cssAsc];fixColumnWidth(this),n.click(function(e){var o=t[0].tBodies[0]&&t[0].tBodies[0].rows.length||0;if(!this.sortDisabled&&o>0){t.trigger("sortStart");var s=($(this),this.column);if(this.order=this.count++%2,this.lockedOrder&&(this.order=this.lockedOrder),e[a.sortMultiSortKey])if(isValueInArray(s,a.sortList))for(var l=0;l<a.sortList.length;l++){var c=a.sortList[l],d=a.headerList[c[0]];c[0]==s&&(d.count=c[1],d.count++,c[1]=d.count%2)}else a.sortList.push([s,this.order]);else{if(a.sortList=[],null!=a.sortForce)for(var u=a.sortForce,l=0;l<u.length;l++)u[l][0]!=s&&a.sortList.push(u[l]);a.sortList.push([s,this.order])}return setTimeout(function(){setHeadersCss(t[0],n,a.sortList,i),appendToTable(t[0],multisort(t[0],a.sortList,r))},1),!1}}).mousedown(function(){return a.cancelSelection?(this.onselectstart=function(){return!1},!1):void 0}),t.bind("update",function(){var e=this;setTimeout(function(){e.config.parsers=buildParserCache(e,n),r=buildCache(e)},1)}).bind("updateCell",function(e,t){var n=this.config,a=[t.parentNode.rowIndex-1,t.cellIndex];r.normalized[a[0]][a[1]]=n.parsers[a[1]].format(getElementText(n,t),t)}).bind("sorton",function(e,t){$(this).trigger("sortStart"),a.sortList=t;var o=a.sortList;updateHeaderSortCount(this,o),setHeadersCss(this,n,o,i),appendToTable(this,multisort(this,o,r))}).bind("appendCache",function(){appendToTable(this,r)}).bind("applyWidgetId",function(e,t){getWidgetById(t).format(this)}).bind("applyWidgets",function(){applyWidget(this)}),$.metadata&&$(this).metadata()&&$(this).metadata().sortlist&&(a.sortList=$(this).metadata().sortlist),a.sortList.length>0&&t.trigger("sorton",[a.sortList]),applyWidget(this)}})},this.addParser=function(e){for(var t=parsers.length,n=!0,r=0;t>r;r++)parsers[r].id.toLowerCase()==e.id.toLowerCase()&&(n=!1);n&&parsers.push(e)},this.addWidget=function(e){widgets.push(e)},this.formatFloat=function(e){var t=parseFloat(e);return isNaN(t)?0:t},this.formatInt=function(e){var t=parseInt(e);return isNaN(t)?0:t},this.isDigit=function(e){return/^[-+]?\d*$/.test($.trim(e.replace(/[,.']/g,"")))},this.clearTableBody=function(e){function t(){for(;this.firstChild;)this.removeChild(this.firstChild)}$.browser.msie?t.apply(e.tBodies[0]):e.tBodies[0].innerHTML=""}}}),$.fn.extend({tablesorter:$.tablesorter.construct});var ts=$.tablesorter;ts.addParser({id:"text",is:function(){return!0},format:function(e){return $.trim(e.toLocaleLowerCase())},type:"text"}),ts.addParser({id:"digit",is:function(e,t){var n=t.config;return $.tablesorter.isDigit(e,n)},format:function(e){return $.tablesorter.formatFloat(e)},type:"numeric"}),ts.addParser({id:"currency",is:function(e){return/^[£$€?.]/.test(e)},format:function(e){return $.tablesorter.formatFloat(e.replace(new RegExp(/[£$€]/g),""))},type:"numeric"}),ts.addParser({id:"ipAddress",is:function(e){return/^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(e)},format:function(e){for(var t=e.split("."),n="",r=t.length,a=0;r>a;a++){var i=t[a];n+=2==i.length?"0"+i:i}return $.tablesorter.formatFloat(n)},type:"numeric"}),ts.addParser({id:"url",is:function(e){return/^(https?|ftp|file):\/\/$/.test(e)},format:function(e){return jQuery.trim(e.replace(new RegExp(/(https?|ftp|file):\/\//),""))},type:"text"}),ts.addParser({id:"isoDate",is:function(e){return/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(e)},format:function(e){return $.tablesorter.formatFloat(""!=e?new Date(e.replace(new RegExp(/-/g),"/")).getTime():"0")},type:"numeric"}),ts.addParser({id:"percent",is:function(e){return/\%$/.test($.trim(e))},format:function(e){return $.tablesorter.formatFloat(e.replace(new RegExp(/%/g),""))},type:"numeric"}),ts.addParser({id:"usLongDate",is:function(e){return e.match(new RegExp(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/))},format:function(e){return $.tablesorter.formatFloat(new Date(e).getTime())},type:"numeric"}),ts.addParser({id:"shortDate",is:function(e){return/\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(e)},format:function(e,t){var n=t.config;return e=e.replace(/\-/g,"/"),"us"==n.dateFormat?e=e.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$1/$2"):"uk"==n.dateFormat?e=e.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$2/$1"):("dd/mm/yy"==n.dateFormat||"dd-mm-yy"==n.dateFormat)&&(e=e.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/,"$1/$2/$3")),$.tablesorter.formatFloat(new Date(e).getTime())},type:"numeric"}),ts.addParser({id:"time",is:function(e){return/^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(e)},format:function(e){return $.tablesorter.formatFloat(new Date("2000/01/01 "+e).getTime())},type:"numeric"}),ts.addParser({id:"metadata",is:function(){return!1},format:function(e,t,n){var r=t.config,a=r.parserMetadataName?r.parserMetadataName:"sortValue";return $(n).metadata()[a]},type:"numeric"}),ts.addWidget({id:"zebra",format:function(e){if(e.config.debug)var t=new Date;var n,r,a=-1;$("tr:visible",e.tBodies[0]).each(function(){n=$(this),n.hasClass(e.config.cssChildRow)||a++,r=a%2==0,n.removeClass(e.config.widgetZebra.css[r?0:1]).addClass(e.config.widgetZebra.css[r?1:0])}),e.config.debug&&$.tablesorter.benchmark("Applying Zebra widget",t)}})}(jQuery),function(e){window.NestedFormEvents=function(){this.addFields=e.proxy(this.addFields,this),this.removeFields=e.proxy(this.removeFields,this)},NestedFormEvents.prototype={addFields:function(t){var n=t.currentTarget,r=e(n).data("association"),a=e("#"+e(n).data("blueprint-id")),i=a.data("blueprint"),o=(e(n).closest(".fields").closestChild("input, textarea, select").eq(0).attr("name")||"").replace(new RegExp("[[a-z_]+]$"),"");if(o)for(var s=o.match(/[a-z_]+_attributes(?=\]\[(new_)?\d+\])/g)||[],l=o.match(/[0-9]+/g)||[],c=0;c<s.length;c++)l[c]&&(i=i.replace(new RegExp("(_"+s[c]+")_.+?_","g"),"$1_"+l[c]+"_"),i=i.replace(new RegExp("(\\["+s[c]+"\\])\\[.+?\\]","g"),"$1["+l[c]+"]"));var d=new RegExp("new_"+r,"g"),u=this.newId();i=e.trim(i.replace(d,u));var f=this.insertFields(i,r,n);return f.trigger({type:"nested:fieldAdded",field:f}).trigger({type:"nested:fieldAdded:"+r,field:f}),!1},newId:function(){return(new Date).getTime()},insertFields:function(t,n,r){var a=e(r).data("target");return a?e(t).appendTo(e(a)):e(t).insertBefore(r)},removeFields:function(t){var n=e(t.currentTarget),r=n.data("association"),a=n.prev("input[type=hidden]");a.val("1");var i=n.closest(".fields");return i.hide(),i.trigger({type:"nested:fieldRemoved",field:i}).trigger({type:"nested:fieldRemoved:"+r,field:i}),!1}},window.nestedFormEvents=new NestedFormEvents,e(document).delegate("form a.add_nested_fields","click",nestedFormEvents.addFields).delegate("form a.remove_nested_fields","click",nestedFormEvents.removeFields)}(jQuery),function(e){e.fn.closestChild=function(t){if(t&&""!=t){var n=[];for(n.push(this);n.length>0;)for(var r=n.shift(),a=r.children(),i=0;i<a.length;++i){var o=e(a[i]);if(o.is(t))return o;n.push(o)}}return e()}}(jQuery);var wloc=window.location.toString();-1!==wloc.indexOf("api")&&wloc.indexOf("api")<10&&-1===wloc.indexOf("charts")&&-1===wloc.indexOf("plugins")&&(window.location=wloc.replace("api","www")),function(e){function t(t,r,a,i){l={dataType:"json"},1===arguments.length&&"string"!=typeof arguments[0]?(l=e.extend(l,t),"url"in l&&"data"in l&&n(l.url,l.data)):(e.isFunction(r)&&(i=a,a=r,r=null),t=n(t,r),l=e.extend(l,{url:t,data:r,success:a,error:i}))}function n(e,t){var n,r,a;for(n in t)a=t[n],r=e.replace("{"+n+"}",a),r!=e&&(e=r,delete t[n]);return e}function r(t){return t.type=t.type||"GET","string"!=typeof t.data&&null!=t.data&&(t.data=e.param(t.data)),t.data=t.data||"",e.restSetup.csrf&&!e.isEmptyObject(e.restSetup.csrf)&&(/^(get)$/i.test(t.type)||/(authenticity_token=)/i.test(t.data)||(t.data+=(t.data?"&":"")+e.restSetup.csrfParam+"="+$restSetup.csrfToken)),/^(get|post)$/i.test(t.type)||(t.data+=(t.data?"&":"")+e.restSetup.methodParam+"="+t.type.toLowerCase(),t.type="POST"),c.call(this,t)}function a(){return t.apply(this,arguments),e.extend(l,{type:"GET"}),e.ajax(l)}function i(){return t.apply(this,arguments),e.extend(l,{type:"POST"}),e.ajax(l)}function o(){return t.apply(this,arguments),e.extend(l,{type:"PUT"}),e.ajax(l)}function s(){return t.apply(this,arguments),e.extend(l,{type:"DELETE"}),e.ajax(l)}e.restSetup={methodParam:"_method"},e(document).ready(function(){e.extend(e.restSetup,{csrfParam:e("meta[name=csrf-param]").attr("content"),csrfToken:e("meta[name=csrf-token]").attr("content")})});var l,c=e.ajax;e.extend({ajax:r,read:a,create:i,update:o,destroy:s})}(jQuery),function(e){function t(e,t,a){var i=e.scrollTop;e.setSelectionRange?n(e,t,a):document.selection&&r(e,t,a),e.scrollTop=i}function n(e,t,n){var r=e.selectionStart,a=e.selectionEnd;if(r==a)t?" "==e.value.substring(r-n.tabString.length,r)?(e.value=e.value.substring(0,r-n.tabString.length)+e.value.substring(r),e.focus(),e.setSelectionRange(r-n.tabString.length,r-n.tabString.length)):" "==e.value.substring(r,r+n.tabString.length)&&(e.value=e.value.substring(0,r)+e.value.substring(r+n.tabString.length),e.focus(),e.setSelectionRange(r,r)):(e.value=e.value.substring(0,r)+n.tabString+e.value.substring(r),e.focus(),e.setSelectionRange(r+n.tabString.length,r+n.tabString.length));
else{var i=e.value.split("\n"),o=new Array,s=0,l=0;for(var c in i)l=s+i[c].length,o.push({start:s,end:l,selected:r>=s&&l>r||l>=a&&a>s||s>r&&a>l}),s=l+1;var d=0;for(var c in o)if(o[c].selected){var u=o[c].start+d;t&&n.tabString==e.value.substring(u,u+n.tabString.length)?(e.value=e.value.substring(0,u)+e.value.substring(u+n.tabString.length),d-=n.tabString.length):t||(e.value=e.value.substring(0,u)+n.tabString+e.value.substring(u),d+=n.tabString.length)}e.focus();var f=r+(d>0?n.tabString.length:0>d?-n.tabString.length:0),h=a+d;e.setSelectionRange(f,h)}}function r(t,n,r){var a=document.selection.createRange();if(t==a.parentElement())if(""==a.text)if(n){var i=a.getBookmark();a.moveStart("character",-r.tabString.length),r.tabString==a.text?a.text="":(a.moveToBookmark(i),a.moveEnd("character",r.tabString.length),r.tabString==a.text&&(a.text="")),a.collapse(!0),a.select()}else a.text=r.tabString,a.collapse(!1),a.select();else{var o=a.text,s=o.length,l=o.split("\r\n"),c=document.body.createTextRange();c.moveToElementText(t),c.setEndPoint("EndToStart",a);var d=c.text,u=d.split("\r\n"),f=d.length,h=document.body.createTextRange();h.moveToElementText(t),h.setEndPoint("StartToEnd",a);var p=h.text,m=document.body.createTextRange();m.moveToElementText(t),m.setEndPoint("StartToEnd",c);var g=m.text,b=e(t).html();e("#r3").text(f+" + "+s+" + "+p.length+" = "+b.length),f+g.length<b.length?(u.push(""),f+=2,n&&r.tabString==l[0].substring(0,r.tabString.length)?l[0]=l[0].substring(r.tabString.length):n||(l[0]=r.tabString+l[0])):n&&r.tabString==u[u.length-1].substring(0,r.tabString.length)?u[u.length-1]=u[u.length-1].substring(r.tabString.length):n||(u[u.length-1]=r.tabString+u[u.length-1]);for(var v=1;v<l.length;v++)n&&r.tabString==l[v].substring(0,r.tabString.length)?l[v]=l[v].substring(r.tabString.length):n||(l[v]=r.tabString+l[v]);1==u.length&&0==f&&(n&&r.tabString==l[0].substring(0,r.tabString.length)?l[0]=l[0].substring(r.tabString.length):n||(l[0]=r.tabString+l[0])),f+s+p.length<b.length&&(l.push(""),s+=2),c.text=u.join("\r\n"),a.text=l.join("\r\n");var y=document.body.createTextRange();y.moveToElementText(t),f>0?y.setEndPoint("StartToEnd",c):y.setEndPoint("StartToStart",c),y.setEndPoint("EndToEnd",a),y.select()}}e.fn.tabby=function(n){var r=e.extend({},e.fn.tabby.defaults,n),a=e.fn.tabby.pressed;return this.each(function(){$this=e(this);var n=e.meta?e.extend({},r,$this.data()):r;$this.bind("keydown",function(r){var i=e.fn.tabby.catch_kc(r);return 16==i&&(a.shft=!0),17==i&&(a.ctrl=!0,setTimeout("$.fn.tabby.pressed.ctrl = false;",1e3)),18==i&&(a.alt=!0,setTimeout("$.fn.tabby.pressed.alt = false;",1e3)),9!=i||a.ctrl||a.alt?void 0:(r.preventDefault,a.last=i,setTimeout("$.fn.tabby.pressed.last = null;",0),t(e(r.target).get(0),a.shft,n),!1)}).bind("keyup",function(t){16==e.fn.tabby.catch_kc(t)&&(a.shft=!1)}).bind("blur",function(t){9==a.last&&e(t.target).one("focus",function(){a.last=null}).get(0).focus()})})},e.fn.tabby.catch_kc=function(e){return e.keyCode?e.keyCode:e.charCode?e.charCode:e.which},e.fn.tabby.pressed={shft:!1,ctrl:!1,alt:!1,last:null},e.fn.tabby.defaults={tabString:String.fromCharCode(9)}}(jQuery),function(e,t,n){var r={required:"The %s field is required.",matches:"The %s field does not match the %s field.",valid_email:"The %s field must contain a valid email address.",min_length:"The %s field must be at least %s characters in length.",max_length:"The %s field must not exceed %s characters in length.",exact_length:"The %s field must be exactly %s characters in length.",greater_than:"The %s field must contain a number greater than %s.",less_than:"The %s field must contain a number less than %s.",alpha:"The %s field must only contain alphabetical characters.",alpha_numeric:"The %s field must only contain alpha-numeric characters.",alpha_dash:"The %s field must only contain alpha-numeric characters, underscores, and dashes.",numeric:"The %s field must contain only numbers.",integer:"The %s field must contain an integer."},a=function(){},i=/^(.+)\[(.+)\]$/,o=/^[0-9]+$/,s=/^\-?[0-9]+$/,l=/^\-?[0-9]*\.?[0-9]+$/,c=/^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,6}$/i,d=/^[a-z]+$/i,u=/^[a-z0-9]+$/i,f=/^[a-z0-9_-]+$/i,h=function(e,n,r){for(this.callback=r||a,this.errors=[],this.fields={},this.form=t.forms[e]||{},this.messages={},this.handlers={},e=0,r=n.length;r>e;e++){var i=n[e];i.name&&i.rules&&(this.fields[i.name]={name:i.name,display:i.display||i.name,rules:i.rules,type:null,value:null,checked:null})}this.form.onsubmit=function(e){return function(t){try{return e._validateForm(t)}catch(n){}}}(this)};h.prototype.setMessage=function(e,t){return this.messages[e]=t,this},h.prototype.registerCallback=function(e,t){return e&&"string"==typeof e&&t&&"function"==typeof t&&(this.handlers[e]=t),this},h.prototype._validateForm=function(e){this.errors=[];for(var t in this.fields)if(this.fields.hasOwnProperty(t)){var r=this.fields[t]||{},a=this.form[r.name];a&&a!==n&&(r.type=a.type,r.value=a.value,r.checked=a.checked),this._validateField(r)}if("function"==typeof this.callback&&this.callback(this.errors,e),this.errors.length>0){if(!e||!e.preventDefault)return!1;e.preventDefault()}return!0},h.prototype._validateField=function(e){var t=e.rules.split("|");if(-1!==e.rules.indexOf("required")||e.value&&""!==e.value&&e.value!==n)for(var a=0,o=t.length;o>a;a++){var s=t[a],l=null,c=!1;if((parts=i.exec(s))&&(s=parts[1],l=parts[2]),"function"==typeof this._hooks[s]?this._hooks[s].apply(this,[e,l])||(c=!0):"callback_"===s.substring(0,9)&&(s=s.substring(9,s.length),"function"==typeof this.handlers[s]&&this.handlers[s].apply(this,[e.value])===!1&&(c=!0)),c){(t=this.messages[s]||r[s])?(e=t.replace("%s",e.display),l&&(e=e.replace("%s",this.fields[l]?this.fields[l].display:l)),this.errors.push(e)):this.errors.push("An error has occurred with the "+e.display+" field.");break}}},h.prototype._hooks={required:function(e){var t=e.value;return"checkbox"===e.type?e.checked===!0:null!==t&&""!==t},matches:function(e,t){return(el=this.form[t])?e.value===el.value:!1},valid_email:function(e){return c.test(e.value)},min_length:function(e,t){return o.test(t)?e.value.length>=t:!1},max_length:function(e,t){return o.test(t)?e.value.length<=t:!1},exact_length:function(e,t){return o.test(t)?e.value.length==t:!1},greater_than:function(e,t){return l.test(e.value)?parseFloat(e.value)>parseFloat(t):!1},less_than:function(e,t){return l.test(e.value)?parseFloat(e.value)<parseFloat(t):!1},alpha:function(e){return d.test(e.value)},alpha_numeric:function(e){return u.test(e.value)},alpha_dash:function(e){return f.test(e.value)},numeric:function(e){return l.test(e.value)},integer:function(e){return s.test(e.value)}},e.FormValidator=h}(window,document),$(function(){$("div.progressbar").each(function(){var e=this;$(e).progressbar({value:parseInt($(e).attr("rel"))})})}),$(window).load(function(){$.fn.affix&&(setTimeout(function(){$("#bootstrap-sidebar").affix()},100),$(document.body).scrollspy({target:"#leftcol",offset:300}),$("#bootstrap-sidebar li a[href^='#']").on("click",function(e){e.preventDefault();var t=this.hash;$("html, body").animate({scrollTop:$(this.hash).offset().top-90},300,function(){window.location.hash=t})}))});var q=null;window.PR_SHOULD_USE_CONTINUATION=!0,function(){function e(e){function t(e){var t=e.charCodeAt(0);if(92!==t)return t;var n=e.charAt(1);return(t=u[n])?t:n>="0"&&"7">=n?parseInt(e.substring(1),8):"u"===n||"x"===n?parseInt(e.substring(2),16):e.charCodeAt(1)}function n(e){return 32>e?(16>e?"\\x0":"\\x")+e.toString(16):(e=String.fromCharCode(e),("\\"===e||"-"===e||"["===e||"]"===e)&&(e="\\"+e),e)}function r(e){for(var r=e.substring(1,e.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),e=[],a=[],i="^"===r[0],o=i?1:0,s=r.length;s>o;++o){var l=r[o];if(/\\[bdsw]/i.test(l))e.push(l);else{var c,l=t(l);s>o+2&&"-"===r[o+1]?(c=t(r[o+2]),o+=2):c=l,a.push([l,c]),65>c||l>122||(65>c||l>90||a.push([32|Math.max(65,l),32|Math.min(c,90)]),97>c||l>122||a.push([-33&Math.max(97,l),-33&Math.min(c,122)]))}}for(a.sort(function(e,t){return e[0]-t[0]||t[1]-e[1]}),r=[],l=[0/0,0/0],o=0;o<a.length;++o)s=a[o],s[0]<=l[1]+1?l[1]=Math.max(l[1],s[1]):r.push(l=s);for(a=["["],i&&a.push("^"),a.push.apply(a,e),o=0;o<r.length;++o)s=r[o],a.push(n(s[0])),s[1]>s[0]&&(s[1]+1>s[0]&&a.push("-"),a.push(n(s[1])));return a.push("]"),a.join("")}function a(e){for(var t=e.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),n=t.length,a=[],s=0,l=0;n>s;++s){var c=t[s];"("===c?++l:"\\"===c.charAt(0)&&(c=+c.substring(1))&&l>=c&&(a[c]=-1)}for(s=1;s<a.length;++s)-1===a[s]&&(a[s]=++i);for(l=s=0;n>s;++s)c=t[s],"("===c?(++l,void 0===a[l]&&(t[s]="(?:")):"\\"===c.charAt(0)&&(c=+c.substring(1))&&l>=c&&(t[s]="\\"+a[l]);for(l=s=0;n>s;++s)"^"===t[s]&&"^"!==t[s+1]&&(t[s]="");if(e.ignoreCase&&o)for(s=0;n>s;++s)c=t[s],e=c.charAt(0),c.length>=2&&"["===e?t[s]=r(c):"\\"!==e&&(t[s]=c.replace(/[A-Za-z]/g,function(e){return e=e.charCodeAt(0),"["+String.fromCharCode(-33&e,32|e)+"]"}));return t.join("")}for(var i=0,o=!1,s=!1,l=0,c=e.length;c>l;++l){var d=e[l];if(d.ignoreCase)s=!0;else if(/[a-z]/i.test(d.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){o=!0,s=!1;break}}for(var u={b:8,t:9,n:10,v:11,f:12,r:13},f=[],l=0,c=e.length;c>l;++l){if(d=e[l],d.global||d.multiline)throw Error(""+d);f.push("(?:"+a(d)+")")}return RegExp(f.join("|"),s?"gi":"g")}function t(e){function t(e){switch(e.nodeType){case 1:if(r.test(e.className))break;for(var n=e.firstChild;n;n=n.nextSibling)t(n);n=e.nodeName,("BR"===n||"LI"===n)&&(a[s]="\n",o[s<<1]=i++,o[s++<<1|1]=e);break;case 3:case 4:n=e.nodeValue,n.length&&(n=l?n.replace(/\r\n?/g,"\n"):n.replace(/[\t\n\r ]+/g," "),a[s]=n,o[s<<1]=i,i+=n.length,o[s++<<1|1]=e)}}var n,r=/(?:^|\s)nocode(?:\s|$)/,a=[],i=0,o=[],s=0;e.currentStyle?n=e.currentStyle.whiteSpace:window.getComputedStyle&&(n=document.defaultView.getComputedStyle(e,q).getPropertyValue("white-space"));var l=n&&"pre"===n.substring(0,3);return t(e),{a:a.join("").replace(/\n$/,""),c:o}}function n(e,t,n,r){t&&(e={a:t,d:e},n(e),r.push.apply(r,e.e))}function r(t,r){function a(e){for(var t=e.d,c=[t,"pln"],d=0,u=e.a.match(i)||[],f={},h=0,p=u.length;p>h;++h){var m,g=u[h],b=f[g],v=void 0;if("string"==typeof b)m=!1;else{var y=o[g.charAt(0)];if(y)v=g.match(y[1]),b=y[0];else{for(m=0;l>m;++m)if(y=r[m],v=g.match(y[1])){b=y[0];break}v||(b="pln")}!(m=b.length>=5&&"lang-"===b.substring(0,5))||v&&"string"==typeof v[1]||(m=!1,b="src"),m||(f[g]=b)}if(y=d,d+=g.length,m){m=v[1];var w=g.indexOf(m),x=w+m.length;v[2]&&(x=g.length-v[2].length,w=x-m.length),b=b.substring(5),n(t+y,g.substring(0,w),a,c),n(t+y+w,m,s(b,m),c),n(t+y+x,g.substring(x),a,c)}else c.push(t+y,b)}e.e=c}var i,o={};!function(){for(var n=t.concat(r),a=[],s={},l=0,c=n.length;c>l;++l){var d=n[l],u=d[3];if(u)for(var f=u.length;--f>=0;)o[u.charAt(f)]=d;d=d[1],u=""+d,s.hasOwnProperty(u)||(a.push(d),s[u]=q)}a.push(/[\S\s]/),i=e(a)}();var l=r.length;return a}function a(e){var t=[],n=[];e.tripleQuotedStrings?t.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):e.multiLineStrings?t.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,q,"'\"`"]):t.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]),e.verbatimStrings&&n.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var a=e.hashComments;return a&&(e.cStyleComments?(a>1?t.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):t.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),n.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):t.push(["com",/^#[^\n\r]*/,q,"#"])),e.cStyleComments&&(n.push(["com",/^\/\/[^\n\r]*/,q]),n.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q])),e.regexLiterals&&n.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]),(a=e.types)&&n.push(["typ",a]),e=(""+e.keywords).replace(/^ | $/g,""),e.length&&n.push(["kwd",RegExp("^(?:"+e.replace(/[\s,]+/g,"|")+")\\b"),q]),t.push(["pln",/^\s+/,q," \r\n  "]),n.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]),r(t,n)}function i(e,t){function n(e){switch(e.nodeType){case 1:if(i.test(e.className))break;if("BR"===e.nodeName)r(e),e.parentNode&&e.parentNode.removeChild(e);else for(e=e.firstChild;e;e=e.nextSibling)n(e);break;case 3:case 4:if(l){var t=e.nodeValue,a=t.match(o);if(a){var c=t.substring(0,a.index);e.nodeValue=c,(t=t.substring(a.index+a[0].length))&&e.parentNode.insertBefore(s.createTextNode(t),e.nextSibling),r(e),c||e.parentNode.removeChild(e)}}}}function r(e){function t(e,n){var r=n?e.cloneNode(!1):e,a=e.parentNode;if(a){var a=t(a,1),i=e.nextSibling;a.appendChild(r);for(var o=i;o;o=i)i=o.nextSibling,a.appendChild(o)}return r}for(;!e.nextSibling;)if(e=e.parentNode,!e)return;for(var n,e=t(e.nextSibling,0);(n=e.parentNode)&&1===n.nodeType;)e=n;c.push(e)}var a,i=/(?:^|\s)nocode(?:\s|$)/,o=/\r\n?|\n/,s=e.ownerDocument;e.currentStyle?a=e.currentStyle.whiteSpace:window.getComputedStyle&&(a=s.defaultView.getComputedStyle(e,q).getPropertyValue("white-space"));var l=a&&"pre"===a.substring(0,3);for(a=s.createElement("LI");e.firstChild;)a.appendChild(e.firstChild);for(var c=[a],d=0;d<c.length;++d)n(c[d]);t===(0|t)&&c[0].setAttribute("value",t);var u=s.createElement("OL");u.className="linenums";for(var f=Math.max(0,t-1|0)||0,d=0,h=c.length;h>d;++d)a=c[d],a.className="L"+(d+f)%10,a.firstChild||a.appendChild(s.createTextNode(" ")),u.appendChild(a);e.appendChild(u)}function o(e,t){for(var n=t.length;--n>=0;){var r=t[n];y.hasOwnProperty(r)?window.console&&console.warn("cannot override language handler %s",r):y[r]=e}}function s(e,t){return e&&y.hasOwnProperty(e)||(e=/^\s*</.test(t)?"default-markup":"default-code"),y[e]}function l(e){var n=e.g;try{var r=t(e.h),a=r.a;e.a=a,e.c=r.c,e.d=0,s(n,a)(e);var i=/\bMSIE\b/.test(navigator.userAgent),n=/\n/g,o=e.a,l=o.length,r=0,c=e.c,d=c.length,a=0,u=e.e,f=u.length,e=0;u[f]=l;var h,p;for(p=h=0;f>p;)u[p]!==u[p+2]?(u[h++]=u[p++],u[h++]=u[p++]):p+=2;for(f=h,p=h=0;f>p;){for(var m=u[p],g=u[p+1],b=p+2;f>=b+2&&u[b+1]===g;)b+=2;u[h++]=m,u[h++]=g,p=b}for(u.length=h;d>a;){var v,y=c[a+2]||l,w=u[e+2]||l,b=Math.min(y,w),x=c[a+1];if(1!==x.nodeType&&(v=o.substring(r,b))){i&&(v=v.replace(n,"\r")),x.nodeValue=v;var S=x.ownerDocument,$=S.createElement("SPAN");$.className=u[e+1];var C=x.parentNode;C.replaceChild($,x),$.appendChild(x),y>r&&(c[a+1]=x=S.createTextNode(o.substring(b,y)),C.insertBefore(x,$.nextSibling))}r=b,r>=y&&(a+=2),r>=w&&(e+=2)}}catch(k){"console"in window&&console.log(k&&k.stack?k.stack:k)}}var c=["break,continue,do,else,for,if,return,while"],d=[[c,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],u=[d,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],f=[d,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],h=[f,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],d=[d,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],p=[c,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],m=[c,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],c=[c,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],g=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,b=/\S/,v=a({keywords:[u,h,d,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+p,m,c],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),y={};o(v,["default-code"]),o(r([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]),o(r([["pln",/^\s+/,q," \r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]),o(r([],[["atv",/^[\S\s]+/]]),["uq.val"]),o(a({keywords:u,hashComments:!0,cStyleComments:!0,types:g}),["c","cc","cpp","cxx","cyc","m"]),o(a({keywords:"null,true,false"}),["json"]),o(a({keywords:h,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:g}),["cs"]),o(a({keywords:f,cStyleComments:!0}),["java"]),o(a({keywords:c,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]),o(a({keywords:p,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py"]),o(a({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]),o(a({keywords:m,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]),o(a({keywords:d,cStyleComments:!0,regexLiterals:!0}),["js"]),o(a({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),o(r([],[["str",/^[\S\s]+/]]),["regex"]),window.prettyPrintOne=function(e,t,n){var r=document.createElement("PRE");return r.innerHTML=e,n&&i(r,n),l({g:t,i:n,h:r}),r.innerHTML},window.prettyPrint=function(e){function t(){for(var n=window.PR_SHOULD_USE_CONTINUATION?c.now()+250:1/0;u<r.length&&c.now()<n;u++){var a=r[u],o=a.className;if(o.indexOf("prettyprint")>=0){var s,h,o=o.match(f);if(h=!o){h=a;for(var p=void 0,m=h.firstChild;m;m=m.nextSibling)var g=m.nodeType,p=1===g?p?h:m:3===g?b.test(m.nodeValue)?h:p:p;h=(s=p===h?void 0:p)&&"CODE"===s.tagName}for(h&&(o=s.className.match(f)),o&&(o=o[1]),h=!1,p=a.parentNode;p;p=p.parentNode)if(("pre"===p.tagName||"code"===p.tagName||"xmp"===p.tagName)&&p.className&&p.className.indexOf("prettyprint")>=0){h=!0;break}h||((h=(h=a.className.match(/\blinenums\b(?::(\d+))?/))?h[1]&&h[1].length?+h[1]:!0:!1)&&i(a,h),d={g:o,h:a,i:h},l(d))}}u<r.length?setTimeout(t,250):e&&e()}for(var n=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],r=[],a=0;a<n.length;++a)for(var o=0,s=n[a].length;s>o;++o)r.push(n[a][o]);var n=q,c=Date;c.now||(c={now:function(){return+new Date}});var d,u=0,f=/\blang(?:uage)?-([\w.]+)(?!\S)/;t()},window.PR={createSimpleLexer:r,registerLangHandler:o,sourceDecorator:a,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}}(),!function(e){e(function(){window.prettyPrint&&prettyPrint()})}(window.jQuery),$(document).ready(function(){$(".response").click(function(){var e=$(this).data("response_type");$(".response").removeClass("active"),$(".response-"+e).addClass("active"),$(".format").hide(),$(".format-"+e).show()})}),$(document).ready(function(){$(".flash").length>0&&($(".flash").on("click",function(){$(this).hide("slow")}),setTimeout(function(){$(".flash").length>0&&$(".flash").hide("slow")},15e3)),$("#talkback_command_add").click(function(){$(this).hide(),$("#talkback_command_add_form").removeClass("hide")}),$("#contact_link").click(function(){$("#contact_form").toggle()})});