thingspeak/public/assets/application-94481c0d15f8b1ca26f566b42f35fde4.js

2 lines
59 KiB
JavaScript
Raw Normal View History

2014-06-30 19:16:22 +02:00
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-disab
},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 h=this.insertFields(i,r,n);return h.trigger({type:"nested:fieldAdded",field:h}).trigger({type:"nested:fieldAdded:"+r,field:h}),!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