thingspeak/public/assets/application-4ac171a3d0c3497168c817f96a7a1529.js

2 lines
64 KiB
JavaScript
Raw Normal View History

2014-10-09 19:25:48 +02:00
function reloadCharts(){return-1===navigator.userAgent.toLowerCase().indexOf("firefox")?!1:void $('.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())})}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])",file
}function makeSortText(t){return"((a["+t+"] < b["+t+"]) ? -1 : ((a["+t+"] > b["+t+"]) ? 1 : 0));"}function makeSortTextDesc(t){return"((b["+t+"] < a["+t+"]) ? -1 : ((b["+t+"] > a["+t+"]) ? 1 : 0));"}function makeSortNumeric(t){return"a["+t+"]-b["+t+"];"}function makeSortNumericDesc(t){return"b["+t+"]-a["+t+"];"}function sortText(t,e){return table.config.sortLocaleCompare?t.localeCompare(e):e>t?-1:t>e?1:0}function sortTextDesc(t,e){return table.config.sortLocaleCompare?e.localeCompare(t):t>e?-1:e>t?1:0}function sortNumeric(t,e){return t-e}function sortNumericDesc(t,e){return e-t}function getCachedSortType(t,e){return t[e].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(t){return this.each(function(){if(this.tHead&&this.tBodies){var e,n,r,a;this.config={},a=$.extend(this.config,$.tablesorter.defaults,t),e=$(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(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/^[\xc2\xa3