From e25599b5a0c74847bd43ef83972a38cb8ef6d66c Mon Sep 17 00:00:00 2001 From: Jonathan Hornung Date: Tue, 26 Jan 2016 11:39:43 +0100 Subject: [PATCH] feature(aping-helpers.js): added new helper function: getDifference() --- bower.json | 2 +- dist/aping.js | 17 ++++++++++++++++- dist/aping.min.js | 4 ++-- package.json | 2 +- src/aping-helpers.js | 15 +++++++++++++++ 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/bower.json b/bower.json index cd6dba0..c2d0c37 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "apiNG", - "version": "1.0.8", + "version": "1.0.9", "homepage": "https://github.com/JohnnyTheTank/apiNG", "authors": [ "Jonathan Hornung " diff --git a/dist/aping.js b/dist/aping.js index 39d5e12..feb854b 100644 --- a/dist/aping.js +++ b/dist/aping.js @@ -1,6 +1,6 @@ /** @name: aping - @version: 1.0.8 (26-01-2016) + @version: 1.0.9 (26-01-2016) @author: Jonathan Hornung @url: https://github.com/JohnnyTheTank/apiNG @license: MIT @@ -270,6 +270,21 @@ angular.module('jtt_aping').service('apingTimeHelper', function () { return this.parseRequestsFromAttributes(_string, _platform, _appSettings); }; + /** + * returns the difference between two integers + * + * @param _int1 {number} + * @param _int2 {number} + * @returns {number} + */ + this.getDifference = function (_int1, _int2) { + if (_int1 > _int2) { + return _int1 - _int2; + } else { + return _int2 - _int1; + } + }; + /** * Parse JSON from Attributes and create requests * diff --git a/dist/aping.min.js b/dist/aping.min.js index 6bf6226..94c04fe 100644 --- a/dist/aping.min.js +++ b/dist/aping.min.js @@ -1,8 +1,8 @@ /** @name: aping - @version: 1.0.8 (26-01-2016) + @version: 1.0.9 (26-01-2016) @author: Jonathan Hornung @url: https://github.com/JohnnyTheTank/apiNG @license: MIT */ -"use strict";angular.module("jtt_aping",["jtt_aping_jsonloader","jtt_aping_ng_array"]),angular.module("jtt_aping").config(["$provide",function(a){a.value("apingDefaultSettings",{apingApiKeys:{}})}]).value("apingResults",{}).directive("aping",["apingResults","apingDefaultSettings","apingUtilityHelper","$templateRequest","$compile",function(a,b,c,d,e){return{restrict:"E",transclude:!0,template:"",scope:{model:"@",getNativeData:"@",items:"@",maxItems:"@",orderBy:"@",orderReverse:"@",templateUrl:"@",payloadJson:"@",removeDoubles:"@",valueName:"@"},link:function(a,c,f,g,h){function i(b){angular.isDefined(b)&&"$NONE"!==b?d(b).then(function(b){var d=angular.element(b);c.empty().append(d),e(d)(a)}):h(a,function(a,b){c.append(a),e(a)(b)})}var j=a.templateUrl;a.$watch("templateUrl",function(){i(a.templateUrl)}),angular.isUndefined(j)&&angular.isDefined(b.templateUrl)&&(j=b.templateUrl,i(j))},controller:["$scope",function(d){d.results=[],d.payload=d.payloadJson?c.replaceSingleQuotesAndParseJson(d.payloadJson):{},this.getAppSettings=function(){var a,c,e,f,g,h,i;return i=angular.isDefined(d.valueName)?d.valueName:void 0,a=angular.isDefined(d.items)?d.items:angular.isDefined(b.items)?b.items:void 0,c=angular.isDefined(d.maxItems)?d.maxItems:angular.isDefined(b.maxItems)?b.maxItems:void 0,e=angular.isDefined(d.getNativeData)?d.getNativeData:angular.isDefined(b.getNativeData)?b.getNativeData:!1,c=angular.isDefined(d.maxItems)?d.maxItems:angular.isDefined(b.maxItems)?b.maxItems:void 0,g=angular.isDefined(d.orderBy)?d.orderBy:angular.isDefined(b.orderBy)?b.orderBy:void 0,f=angular.isDefined(d.orderReverse)?d.orderReverse:angular.isDefined(b.orderReverse)?b.orderReverse:!1,h=angular.isDefined(d.removeDoubles)?d.removeDoubles:angular.isDefined(b.removeDoubles)?b.removeDoubles:!1,{model:d.model||b.model||"native",getNativeData:e,items:a,maxItems:c,orderBy:g,orderReverse:f,removeDoubles:h,valueName:i}},this.concatToResults=function(b){d.results=d.results.concat(b);var e=this.getAppSettings();(e.removeDoubles===!0||"true"===e.removeDoubles)&&(d.results=c.removeDuplicateObjectsFromArray(d.results,e.orderBy===!1||"false"===e.orderBy||"$NONE"===e.orderBy)),angular.isDefined(e.orderBy)&&e.orderBy!==!1&&"false"!==e.orderBy&&"$NONE"!==e.orderBy&&("$RANDOM"===e.orderBy?d.results=c.shuffleArray(d.results):(d.results.sort(c.sortArrayByProperty(e.orderBy)),(e.orderReverse===!0||"true"===e.orderReverse)&&d.results.reverse())),e.maxItems>-1&&d.results.length>e.maxItems&&(d.results=d.results.splice(0,e.maxItems)),angular.isDefined(e.valueName)&&(a[e.valueName]=d.results),d.$broadcast("apiNG.resultMerged")},this.apply=function(){d.$apply()}}]}}]),angular.module("jtt_aping").service("apingTimeHelper",function(){this.getTimestampFromDateString=function(a,b,c){if((angular.isUndefined(b)||isNaN(b))&&(b=1),(angular.isUndefined(c)||isNaN(c))&&(c=0),"string"==typeof a){var d=a.split(/[^0-9]/);try{return parseInt(Math.round(new Date(d[0],d[1]-1,d[2],d[3],d[4],d[5])/1e3*b)+c,10)}catch(e){return 0}}return 0}}).service("apingUtilityHelper",["apingInputObjects","apingDefaultSettings",function(a,b){this.getApiCredentials=function(a,c){return b.apingApiKeys&&b.apingApiKeys[a]?b.apingApiKeys[a][Math.floor(Math.random()*b.apingApiKeys[a].length)][c]:!1},this.parseJsonFromAttributes=function(a,b,c){return this.parseRequestsFromAttributes(a,b,c)},this.parseRequestsFromAttributes=function(b,c,d){if("string"!=typeof b||!b)return[];var e=[],f=this.replaceSingleQuotesAndParseJson(b);return angular.forEach(f,function(b,f){b.platform=c,d&&(angular.isUndefined(b.items)&&angular.isDefined(d.items)&&(b.items=d.items),angular.isUndefined(b.model)&&angular.isDefined(d.model)&&(b.model=d.model));var g=a.getNew("request",b);e.push(g)}),e},this.replaceSingleQuotesAndParseJson=function(a){return $.parseJSON(a.replace(/'/g,'"'))},this.sortArrayByProperty=function(a){var b=1;return"-"===a[0]&&(b=-1,a=a.substr(1)),function(c,d){var e=c[a]d[a]?1:0;return e*b}},this.shuffleArray=function(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},this.removeDuplicateObjectsFromArray=function(a,b){var c=[],d="apingStringified",e="apingTempOrder";if(1===a.length)return a;$.each(a,function(a,f){f.$$hashKey=void 0,f[d]=JSON.stringify(f),b===!0&&(f[e]=a),c.push(f)}),c.sort(this.sortArrayByProperty(d));var f,g=[];return $.each(c,function(a,b){angular.isDefined(f)?angular.isDefined(b[d])&&b[d]!==f&&g.push(b):g.push(b),f=b[d],b[d]=void 0}),b===!0&&(c.sort(this.sortArrayByProperty(e)),$.each(c,function(a,b){b[e]=void 0})),g},this.getTextFromHtml=function(a){return a=a.replace(/<br ?\/\>|<br ?\/&rt;|\
/g," "),a=a.replace(/<(?:.|\n)*?>/gm,"")},this.getFirstImageFromHtml=function(a){var b=/]+src="([^">]+)/g;return b.exec(a)},this.parseParametersFromUrl=function(a){var b={};return"string"==typeof a&&(b=JSON.parse('{"'+decodeURI(a.replace(/&/g,'","').replace(/=/g,'":"'))+'"}')),b}}]),angular.module("jtt_aping").service("apingInputObjects",["apingDefaultSettings",function(a){this.getNew=function(b,c){var d={};switch(b){case"request":d=$.extend(!0,{model:a.model,items:a.items},c)}return d}}]),angular.module("jtt_aping").service("apingModels",[function(){this.getNew=function(a,b){var c={};switch(a){case"social":c={platform:b,blog_name:void 0,blog_id:void 0,blog_link:void 0,type:void 0,timestamp:void 0,date_time:void 0,post_url:void 0,intern_id:void 0,text:void 0,caption:void 0,img_url:void 0,thumb_url:void 0,native_url:void 0,source:void 0,likes:void 0,shares:void 0,comments:void 0,position:void 0};break;case"video":c={platform:b,blog_name:void 0,blog_id:void 0,blog_link:void 0,timestamp:void 0,date_time:void 0,post_url:void 0,intern_id:void 0,caption:void 0,text:void 0,img_url:void 0,thumb_url:void 0,native_url:void 0,source:void 0,markup:void 0,duration:void 0,width:void 0,height:void 0,comments:void 0,likes:void 0,shares:void 0,position:void 0};break;case"image":c={platform:b,blog_name:void 0,blog_id:void 0,blog_link:void 0,timestamp:void 0,date_time:void 0,post_url:void 0,intern_id:void 0,text:void 0,caption:void 0,thumb_url:void 0,thumb_width:void 0,thumb_height:void 0,img_url:void 0,img_width:void 0,img_height:void 0,native_url:void 0,native_width:void 0,native_height:void 0,source:void 0,likes:void 0,shares:void 0,comments:void 0,position:void 0};break;case"event":c={platform:b,artist_name:void 0,artist_id:void 0,artist_link:void 0,start_timestamp:void 0,start_date_time:void 0,end_timestamp:void 0,end_date_time:void 0,event_url:void 0,ticket_url:void 0,sold_out:void 0,intern_id:void 0,text:void 0,caption:void 0,img_url:void 0,place_name:void 0,city:void 0,country:void 0,latitude:void 0,longitude:void 0,street:void 0,zip:void 0,source:void 0};break;case"repo":c={platform:b,owner_name:void 0,owner_id:void 0,owner_link:void 0,owner_img_url:void 0,name:void 0,id:void 0,fullname:void 0,description:void 0,url:void 0,homepage:void 0,language:void 0,clone_url:void 0,git_url:void 0,ssh_url:void 0,svn_url:void 0,isFork:void 0,openIssues:void 0,watchers:void 0,stargazers:void 0,forks:void 0,created_timestamp:void 0,created_date_time:void 0,updated_timestamp:void 0,updated_date_time:void 0,pushed_timestamp:void 0,pushed_date_time:void 0};break;case"activity":c={platform:b,body:void 0,actor_name:void 0,actor_id:void 0,actor_url:void 0,actor_img_url:void 0,actor_type:void 0,action_name:void 0,action_message:void 0,action_id:void 0,action_url:void 0,action_img:void 0,action_type:void 0,object_name:void 0,object_id:void 0,object_img:void 0,object_url:void 0,object_type:void 0,context:void 0,timestamp:void 0,date_time:void 0};break;case"weather":c={platform:b,weather_code:void 0,weather_caption:void 0,weather_text:void 0,weather_icon_name:void 0,weather_icon_url:void 0,temp:void 0,pressure:void 0,humidity:void 0,temp_min:void 0,temp_max:void 0,sea_level:void 0,grnd_level:void 0,wind_speed:void 0,wind_deg:void 0,rain_duration:void 0,rain_volume:void 0,clouds:void 0,timestamp:void 0,date_time:void 0,sunrise_timestamp:void 0,sunrise_date_time:void 0,sunset_timestamp:void 0,sunset_date_time:void 0,loc_city:void 0,loc_city_id:void 0,loc_country:void 0,loc_lat:void 0,loc_lng:void 0,loc_zip:void 0}}return c}}]),angular.module("jtt_aping_jsonloader",[]),angular.module("jtt_aping_jsonloader").directive("apingJsonloader",["apingUtilityHelper","jsonloaderFactory",function(a,b){return{require:"?aping",restrict:"A",replace:"false",link:function(c,d,e,f){var g=f.getAppSettings(),h=a.parseJsonFromAttributes(e.apingJsonloader,"jsonloader",g);h.forEach(function(a){if(a.path){var c={path:a.path};if(a.format&&"jsonp"===a.format.toLowerCase()?c.format="jsonp":c.format="json",a.callback&&(c.callback=a.callback),"jsonp"!==a.format||a.callback||(c.callback="JSON_CALLBACK"),angular.isDefined(a.items)?c.count=a.items:c.count=g.items,0===c.count||"0"===c.count)return!1;(c.count<0||isNaN(c.count))&&(c.count=void 0),b.getJsonData(c).then(function(b){var c=[];if(b.data){var d=b.data;angular.isDefined(a.resultProperty)&&(d=b.data[a.resultProperty]),b.data.constructor!==Array?c.push(d):a.items<0||angular.isDefined(a.items)?c=d:angular.forEach(d,function(b,d){d0&&e.concatToResults(d)}})}}}]); \ No newline at end of file +"use strict";angular.module("jtt_aping",["jtt_aping_jsonloader","jtt_aping_ng_array"]),angular.module("jtt_aping").config(["$provide",function(a){a.value("apingDefaultSettings",{apingApiKeys:{}})}]).value("apingResults",{}).directive("aping",["apingResults","apingDefaultSettings","apingUtilityHelper","$templateRequest","$compile",function(a,b,c,d,e){return{restrict:"E",transclude:!0,template:"",scope:{model:"@",getNativeData:"@",items:"@",maxItems:"@",orderBy:"@",orderReverse:"@",templateUrl:"@",payloadJson:"@",removeDoubles:"@",valueName:"@"},link:function(a,c,f,g,h){function i(b){angular.isDefined(b)&&"$NONE"!==b?d(b).then(function(b){var d=angular.element(b);c.empty().append(d),e(d)(a)}):h(a,function(a,b){c.append(a),e(a)(b)})}var j=a.templateUrl;a.$watch("templateUrl",function(){i(a.templateUrl)}),angular.isUndefined(j)&&angular.isDefined(b.templateUrl)&&(j=b.templateUrl,i(j))},controller:["$scope",function(d){d.results=[],d.payload=d.payloadJson?c.replaceSingleQuotesAndParseJson(d.payloadJson):{},this.getAppSettings=function(){var a,c,e,f,g,h,i;return i=angular.isDefined(d.valueName)?d.valueName:void 0,a=angular.isDefined(d.items)?d.items:angular.isDefined(b.items)?b.items:void 0,c=angular.isDefined(d.maxItems)?d.maxItems:angular.isDefined(b.maxItems)?b.maxItems:void 0,e=angular.isDefined(d.getNativeData)?d.getNativeData:angular.isDefined(b.getNativeData)?b.getNativeData:!1,c=angular.isDefined(d.maxItems)?d.maxItems:angular.isDefined(b.maxItems)?b.maxItems:void 0,g=angular.isDefined(d.orderBy)?d.orderBy:angular.isDefined(b.orderBy)?b.orderBy:void 0,f=angular.isDefined(d.orderReverse)?d.orderReverse:angular.isDefined(b.orderReverse)?b.orderReverse:!1,h=angular.isDefined(d.removeDoubles)?d.removeDoubles:angular.isDefined(b.removeDoubles)?b.removeDoubles:!1,{model:d.model||b.model||"native",getNativeData:e,items:a,maxItems:c,orderBy:g,orderReverse:f,removeDoubles:h,valueName:i}},this.concatToResults=function(b){d.results=d.results.concat(b);var e=this.getAppSettings();(e.removeDoubles===!0||"true"===e.removeDoubles)&&(d.results=c.removeDuplicateObjectsFromArray(d.results,e.orderBy===!1||"false"===e.orderBy||"$NONE"===e.orderBy)),angular.isDefined(e.orderBy)&&e.orderBy!==!1&&"false"!==e.orderBy&&"$NONE"!==e.orderBy&&("$RANDOM"===e.orderBy?d.results=c.shuffleArray(d.results):(d.results.sort(c.sortArrayByProperty(e.orderBy)),(e.orderReverse===!0||"true"===e.orderReverse)&&d.results.reverse())),e.maxItems>-1&&d.results.length>e.maxItems&&(d.results=d.results.splice(0,e.maxItems)),angular.isDefined(e.valueName)&&(a[e.valueName]=d.results),d.$broadcast("apiNG.resultMerged")},this.apply=function(){d.$apply()}}]}}]),angular.module("jtt_aping").service("apingTimeHelper",function(){this.getTimestampFromDateString=function(a,b,c){if((angular.isUndefined(b)||isNaN(b))&&(b=1),(angular.isUndefined(c)||isNaN(c))&&(c=0),"string"==typeof a){var d=a.split(/[^0-9]/);try{return parseInt(Math.round(new Date(d[0],d[1]-1,d[2],d[3],d[4],d[5])/1e3*b)+c,10)}catch(e){return 0}}return 0}}).service("apingUtilityHelper",["apingInputObjects","apingDefaultSettings",function(a,b){this.getApiCredentials=function(a,c){return b.apingApiKeys&&b.apingApiKeys[a]?b.apingApiKeys[a][Math.floor(Math.random()*b.apingApiKeys[a].length)][c]:!1},this.parseJsonFromAttributes=function(a,b,c){return this.parseRequestsFromAttributes(a,b,c)},this.getDifference=function(a,b){return a>b?a-b:b-a},this.parseRequestsFromAttributes=function(b,c,d){if("string"!=typeof b||!b)return[];var e=[],f=this.replaceSingleQuotesAndParseJson(b);return angular.forEach(f,function(b,f){b.platform=c,d&&(angular.isUndefined(b.items)&&angular.isDefined(d.items)&&(b.items=d.items),angular.isUndefined(b.model)&&angular.isDefined(d.model)&&(b.model=d.model));var g=a.getNew("request",b);e.push(g)}),e},this.replaceSingleQuotesAndParseJson=function(a){return $.parseJSON(a.replace(/'/g,'"'))},this.sortArrayByProperty=function(a){var b=1;return"-"===a[0]&&(b=-1,a=a.substr(1)),function(c,d){var e=c[a]d[a]?1:0;return e*b}},this.shuffleArray=function(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},this.removeDuplicateObjectsFromArray=function(a,b){var c=[],d="apingStringified",e="apingTempOrder";if(1===a.length)return a;$.each(a,function(a,f){f.$$hashKey=void 0,f[d]=JSON.stringify(f),b===!0&&(f[e]=a),c.push(f)}),c.sort(this.sortArrayByProperty(d));var f,g=[];return $.each(c,function(a,b){angular.isDefined(f)?angular.isDefined(b[d])&&b[d]!==f&&g.push(b):g.push(b),f=b[d],b[d]=void 0}),b===!0&&(c.sort(this.sortArrayByProperty(e)),$.each(c,function(a,b){b[e]=void 0})),g},this.getTextFromHtml=function(a){return a=a.replace(/<br ?\/\>|<br ?\/&rt;|\
/g," "),a=a.replace(/<(?:.|\n)*?>/gm,"")},this.getFirstImageFromHtml=function(a){var b=/]+src="([^">]+)/g;return b.exec(a)},this.parseParametersFromUrl=function(a){var b={};return"string"==typeof a&&(b=JSON.parse('{"'+decodeURI(a.replace(/&/g,'","').replace(/=/g,'":"'))+'"}')),b}}]),angular.module("jtt_aping").service("apingInputObjects",["apingDefaultSettings",function(a){this.getNew=function(b,c){var d={};switch(b){case"request":d=$.extend(!0,{model:a.model,items:a.items},c)}return d}}]),angular.module("jtt_aping").service("apingModels",[function(){this.getNew=function(a,b){var c={};switch(a){case"social":c={platform:b,blog_name:void 0,blog_id:void 0,blog_link:void 0,type:void 0,timestamp:void 0,date_time:void 0,post_url:void 0,intern_id:void 0,text:void 0,caption:void 0,img_url:void 0,thumb_url:void 0,native_url:void 0,source:void 0,likes:void 0,shares:void 0,comments:void 0,position:void 0};break;case"video":c={platform:b,blog_name:void 0,blog_id:void 0,blog_link:void 0,timestamp:void 0,date_time:void 0,post_url:void 0,intern_id:void 0,caption:void 0,text:void 0,img_url:void 0,thumb_url:void 0,native_url:void 0,source:void 0,markup:void 0,duration:void 0,width:void 0,height:void 0,comments:void 0,likes:void 0,shares:void 0,position:void 0};break;case"image":c={platform:b,blog_name:void 0,blog_id:void 0,blog_link:void 0,timestamp:void 0,date_time:void 0,post_url:void 0,intern_id:void 0,text:void 0,caption:void 0,thumb_url:void 0,thumb_width:void 0,thumb_height:void 0,img_url:void 0,img_width:void 0,img_height:void 0,native_url:void 0,native_width:void 0,native_height:void 0,source:void 0,likes:void 0,shares:void 0,comments:void 0,position:void 0};break;case"event":c={platform:b,artist_name:void 0,artist_id:void 0,artist_link:void 0,start_timestamp:void 0,start_date_time:void 0,end_timestamp:void 0,end_date_time:void 0,event_url:void 0,ticket_url:void 0,sold_out:void 0,intern_id:void 0,text:void 0,caption:void 0,img_url:void 0,place_name:void 0,city:void 0,country:void 0,latitude:void 0,longitude:void 0,street:void 0,zip:void 0,source:void 0};break;case"repo":c={platform:b,owner_name:void 0,owner_id:void 0,owner_link:void 0,owner_img_url:void 0,name:void 0,id:void 0,fullname:void 0,description:void 0,url:void 0,homepage:void 0,language:void 0,clone_url:void 0,git_url:void 0,ssh_url:void 0,svn_url:void 0,isFork:void 0,openIssues:void 0,watchers:void 0,stargazers:void 0,forks:void 0,created_timestamp:void 0,created_date_time:void 0,updated_timestamp:void 0,updated_date_time:void 0,pushed_timestamp:void 0,pushed_date_time:void 0};break;case"activity":c={platform:b,body:void 0,actor_name:void 0,actor_id:void 0,actor_url:void 0,actor_img_url:void 0,actor_type:void 0,action_name:void 0,action_message:void 0,action_id:void 0,action_url:void 0,action_img:void 0,action_type:void 0,object_name:void 0,object_id:void 0,object_img:void 0,object_url:void 0,object_type:void 0,context:void 0,timestamp:void 0,date_time:void 0};break;case"weather":c={platform:b,weather_code:void 0,weather_caption:void 0,weather_text:void 0,weather_icon_name:void 0,weather_icon_url:void 0,temp:void 0,pressure:void 0,humidity:void 0,temp_min:void 0,temp_max:void 0,sea_level:void 0,grnd_level:void 0,wind_speed:void 0,wind_deg:void 0,rain_duration:void 0,rain_volume:void 0,clouds:void 0,timestamp:void 0,date_time:void 0,sunrise_timestamp:void 0,sunrise_date_time:void 0,sunset_timestamp:void 0,sunset_date_time:void 0,loc_city:void 0,loc_city_id:void 0,loc_country:void 0,loc_lat:void 0,loc_lng:void 0,loc_zip:void 0}}return c}}]),angular.module("jtt_aping_jsonloader",[]),angular.module("jtt_aping_jsonloader").directive("apingJsonloader",["apingUtilityHelper","jsonloaderFactory",function(a,b){return{require:"?aping",restrict:"A",replace:"false",link:function(c,d,e,f){var g=f.getAppSettings(),h=a.parseJsonFromAttributes(e.apingJsonloader,"jsonloader",g);h.forEach(function(a){if(a.path){var c={path:a.path};if(a.format&&"jsonp"===a.format.toLowerCase()?c.format="jsonp":c.format="json",a.callback&&(c.callback=a.callback),"jsonp"!==a.format||a.callback||(c.callback="JSON_CALLBACK"),angular.isDefined(a.items)?c.count=a.items:c.count=g.items,0===c.count||"0"===c.count)return!1;(c.count<0||isNaN(c.count))&&(c.count=void 0),b.getJsonData(c).then(function(b){var c=[];if(b.data){var d=b.data;angular.isDefined(a.resultProperty)&&(d=b.data[a.resultProperty]),b.data.constructor!==Array?c.push(d):a.items<0||angular.isDefined(a.items)?c=d:angular.forEach(d,function(b,d){d0&&e.concatToResults(d)}})}}}]); \ No newline at end of file diff --git a/package.json b/package.json index f0b4d43..e54a9fa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aping", - "version": "1.0.8", + "version": "1.0.9", "description": "apiNG is an AngularJS directive that enables you to receive, aggregate, limit, order and display data from one or more sources. The complete setup is dead simple, just by adding data-attributes to your html", "main": "dist/aping.min.js", "scripts": { diff --git a/src/aping-helpers.js b/src/aping-helpers.js index a334ca7..d483a79 100644 --- a/src/aping-helpers.js +++ b/src/aping-helpers.js @@ -61,6 +61,21 @@ angular.module('jtt_aping').service('apingTimeHelper', function () { return this.parseRequestsFromAttributes(_string, _platform, _appSettings); }; + /** + * returns the difference between two integers + * + * @param _int1 {number} + * @param _int2 {number} + * @returns {number} + */ + this.getDifference = function (_int1, _int2) { + if (_int1 > _int2) { + return _int1 - _int2; + } else { + return _int2 - _int1; + } + }; + /** * Parse JSON from Attributes and create requests *