thingspeak/public/assets/application-2ed742652fb31d3ebe34470275a2cc0c.js

2 lines
62 KiB
JavaScript
Raw Normal View History

2014-07-23 19:45:15 +02:00
function reloadCharts(){return-1===navigator.userAgent.toLowerCase().indexOf("firefox")?!1:($('.ui-widget-content [aria-expanded="false"]').find("iframe").each(function(){var t=$(this).attr("src");-1!==t.indexOf("charts")&&($(this).hide(),$(this).attr("src",t),$(this).show())}),void 0)}function openDialogCenter(t){t.dialog("open");var e=getDimensions(t.parent());t.dialog({position:[e[0],e[1]]})}function getDimensions(t){var e=new Array(2);return e[0]=$(window).width()/2-t.width()/2,e[1]=$(window).height()/2-t.height()/2,e}function updateChart(t,e,n,r,a,i){var n=n,r=r,o=$("#iframe"+t).attr("default_src");o||(o=$("#iframe"+t).attr("src")),src=o.split("?")[0],("bar"===$("#type_"+t).val()||"column"===$("#type_"+t).val())&&0==$("#timescale_"+t).val().length&&0==$("#average_"+t).val().length&&0==$("#median_"+t).val().length&&0==$("#sum_"+t).val().length&&$("#timescale_"+t).val(30);var s=[];$(".chart_options"+t).each(function(){var t=$(this).val(),e=$(this).attr("id"),n=e.split("_")[0];t.length>0&&s.push([n,t])});for(var l="";s.length>0;){var u=s.pop();"width"==u[0]&&(n=parseInt(u[1])),"height"==u[0]&&(r=parseInt(u[1])),("type"!=u[0]||"line"!=u[1])&&(l+="&"+u[0]+"="+encodeURIComponent(u[1]))}l.length>0&&(src+="?"+l.substring(1)),e&&t>0&&i?$.update("/channels/"+a+"/charts/"+t,{newOptions:{options:l}}):e&&t>0&&$.update("/channels/"+a+"/charts/"+t,{options:l}),$("#embed"+t).val('<iframe width="'+n+'" height="'+r+'" style="border: 1px solid #cccccc;" src="'+src+'"></iframe>'),$("#iframe"+t).attr("src",src),$("#iframe"+t).attr("width",n),$("#iframe"+t).attr("height",r)}function updateSelectValues(){selectedValue=$(this).val(),$(".mutuallyexclusive"+index).each(function(){$(this).val("")}),$(this).val(selectedValue)}function setupChartForm(t){return function(e,n){n.length>0&&$("#"+n.split("=")[0]+"_"+t).val(decodeURIComponent(n.split("=")[1]))}}function setupColumns(t,e){$(sortColumnSetup(t,e)),$(".column").disableSelection()}function createWindowsWithData(t,e,n,r){for(var a in t){var i=t[a].window,o=i.window_type;colId=i.col,title=i.title;var s=i.html;"chart"===i.window_type&&$("body").append("<div id='chartConfig"+i.id+"'></div>");var l=addWindow(r,colId,i.id,o,title,s);l.each(decoratePortlet(e)),l.find(".ui-toggle").click(uiToggleClick),l.find(".ui-view").click(uiViewClick(n)),l.find(".ui-edit").click(uiEditClick(n)),l.find(".ui-close").click(uiCloseClick(n))}}function addWindow(t,e,n,r,a,i){if($("#"+t+"_dialog"+e).append('<div class="portlet ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" id="portlet_'+n+'"><div class="portlet-header window_type window_type-'+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(t,e){$(".column").sortable({opacity:.6,helper:function(){return $("<div class='ui-widget-header'>Drop to re-position</div>")},connectWith:".column",update:updatePortletPositions(t,e)})}function getPortletArray(t){var e=new Array,n=t.split("&");for(i in n)val=n[i].split("=")[1],e.push(val);return e}function uiToggleClick(){$(this).toggleClass("ui-icon-minusthick").toggleClass("ui-icon-plusthick"),$(this).parents(".portlet:first").find(".portlet-content").toggle()}!function(t,e){t.rails!==e&&t.error("jquery-ujs has already been loaded!");var n,r=t(document);t.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])",
fixColumnWidth(this),n.click(function(t){var o=e[0].tBodies[0]&&e[0].tBodies[0].rows.length||0;if(!this.sortDisabled&&o>0){e.trigger("sortStart");var s=($(this),this.column);if(this.order=this.count++%2,this.lockedOrder&&(this.order=this.lockedOrder),t[a.sortMultiSortKey])if(isValueInArray(s,a.sortList))for(var l=0;l<a.sortList.length;l++){var u=a.sortList[l],c=a.headerList[u[0]];u[0]==s&&(c.count=u[1],c.count++,u[1]=c.count%2)}else a.sortList.push([s,this.order]);else{if(a.sortList=[],null!=a.sortForce)for(var d=a.sortForce,l=0;l<d.length;l++)d[l][0]!=s&&a.sortList.push(d[l]);a.sortList.push([s,this.order])}return setTimeout(function(){setHeadersCss(e[0],n,a.sortList,i),appendToTable(e[0],multisort(e[0],a.sortList,r))},1),!1}}).mousedown(function(){return a.cancelSelection?(this.onselectstart=function(){return!1},!1):void 0}),e.bind("update",function(){var t=this;setTimeout(function(){t.config.parsers=buildParserCache(t,n),r=buildCache(t)},1)}).bind("updateCell",function(t,e){var n=this.config,a=[e.parentNode.rowIndex-1,e.cellIndex];r.normalized[a[0]][a[1]]=n.parsers[a[1]].format(getElementText(n,e),e)}).bind("sorton",function(t,e){$(this).trigger("sortStart"),a.sortList=e;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(t,e){getWidgetById(e).format(this)}).bind("applyWidgets",function(){applyWidget(this)}),$.metadata&&$(this).metadata()&&$(this).metadata().sortlist&&(a.sortList=$(this).metadata().sortlist),a.sortList.length>0&&e.trigger("sorton",[a.sortList]),applyWidget(this)}})},this.addParser=function(t){for(var e=parsers.length,n=!0,r=0;e>r;r++)parsers[r].id.toLowerCase()==t.id.toLowerCase()&&(n=!1);n&&parsers.push(t)},this.addWidget=function(t){widgets.push(t)},this.formatFloat=function(t){var e=parseFloat(t);return isNaN(e)?0:e},this.formatInt=function(t){var e=parseInt(t);return isNaN(e)?0:e},this.isDigit=function(t){return/^[-+]?\d*$/.test($.trim(t.replace(/[,.']/g,"")))},this.clearTableBody=function(t){function e(){for(;this.firstChild;)this.removeChild(this.firstChild)}$.browser.msie?e.apply(t.tBodies[0]):t.tBodies[0].innerHTML=""}}}),$.fn.extend({tablesorter:$.tablesorter.construct});var ts=$.tablesorter;ts.addParser({id:"text",is:function(){return!0},format:function(t){return $.trim(t.toLocaleLowerCase())},type:"text"}),ts.addParser({id:"digit",is:function(t,e){var n=e.config;return $.tablesorter.isDigit(t,n)},format:function(t){return $.tablesorter.formatFloat(t)},type:"numeric"}),ts.addParser({id:"currency",is:function(t){return/^[£$€?.]/.test(t)},format:function(t){return $.tablesorter.formatFloat(t.replace(new RegExp(/[£$€]/g),""))},type:"numeric"}),ts.addParser({id:"ipAddress",is:function(t){return/^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(t)},format:function(t){for(var e=t.split("."),n="",r=e.length,a=0;r>a;a++){var i=e[a];n+=2==i.length?"0"+i:i}return $.tablesorter.formatFloat(n)},type:"numeric"}),ts.addParser({id:"url",is:function(t){return/^(https?|ftp|file):\/\/$/.test(t)},format:function(t){return jQuery.trim(t.replace(new RegExp(/(https?|ftp|file):\/\//),""))},type:"text"}),ts.addParser({id:"isoDate",is:function(t){return/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(t)},format:function(t){return $.tablesorter.formatFloat(""!=t?new Date(t.replace(new RegExp(/-/g),"/")).getTime():"0")},type:"numeric"}),ts.addParser({id:"percent",is:function(t){return/\%$/.test($.trim(t))},format:function(t){return $.tablesorter.formatFloat(t.replace(new RegExp(/%/g),""))},type:"numeric"}),ts.addParser({id:"usLongDate",is:function(t){return t.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(t){return $.tablesorter.formatFloat(new Date(t).getTime())},type:"numeric"}),ts.addParser({id:"shortDate",is:function(t){return/\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(t)},format:function(t,e){var n=e.config;return t=t.replace(/\-/g,"/"),"us"==n.dateFormat?t=t.