diff --git a/dist/aping.js b/dist/aping.js index d59f31e..f617ebf 100644 --- a/dist/aping.js +++ b/dist/aping.js @@ -54,57 +54,57 @@ var apingApp = angular.module('jtt_aping', ['jtt_aping_jsonloader', 'jtt_aping_n var orderBy; var removeDoubles; - if (typeof $scope.items !== "undefined") { + if (angular.isDefined($scope.items)) { items = $scope.items; - } else if (typeof apingDefaultSettings.items !== "undefined") { + } else if (angular.isDefined(apingDefaultSettings.items)) { items = apingDefaultSettings.items; } else { items = undefined; } - if (typeof $scope.maxItems !== "undefined") { + if (angular.isDefined($scope.maxItems)) { maxItems = $scope.maxItems; - } else if (typeof apingDefaultSettings.maxItems !== "undefined") { + } else if (angular.isDefined(apingDefaultSettings.maxItems)) { maxItems = apingDefaultSettings.maxItems; } else { maxItems = undefined; } - if (typeof $scope.getNativeData !== "undefined") { + if (angular.isDefined($scope.getNativeData)) { getNativeData = $scope.getNativeData; - } else if (typeof apingDefaultSettings.getNativeData !== "undefined") { + } else if (angular.isDefined(apingDefaultSettings.getNativeData)) { getNativeData = apingDefaultSettings.getNativeData; } else { getNativeData = false; } - if (typeof $scope.maxItems !== "undefined") { + if (angular.isDefined($scope.maxItems)) { maxItems = $scope.maxItems; - } else if (typeof apingDefaultSettings.maxItems !== "undefined") { + } else if (angular.isDefined(apingDefaultSettings.maxItems)) { maxItems = apingDefaultSettings.maxItems; } else { maxItems = undefined; } - if (typeof $scope.orderBy !== "undefined") { + if (angular.isDefined($scope.orderBy)) { orderBy = $scope.orderBy; - } else if (typeof apingDefaultSettings.orderBy !== "undefined") { + } else if (angular.isDefined(apingDefaultSettings.orderBy)) { orderBy = apingDefaultSettings.orderBy; } else { - orderBy = "undefined"; + orderBy = undefined; } - if (typeof $scope.orderReverse !== "undefined") { + if (angular.isDefined($scope.orderReverse)) { orderReverse = $scope.orderReverse; - } else if (typeof apingDefaultSettings.orderReverse !== "undefined") { + } else if (angular.isDefined(apingDefaultSettings.orderReverse)) { orderReverse = apingDefaultSettings.orderReverse; } else { orderReverse = false; } - if (typeof $scope.removeDoubles !== "undefined") { + if (angular.isDefined($scope.removeDoubles)) { removeDoubles = $scope.removeDoubles; - } else if (typeof apingDefaultSettings.removeDoubles !== "undefined") { + } else if (angular.isDefined(apingDefaultSettings.removeDoubles)) { removeDoubles = apingDefaultSettings.removeDoubles; } else { removeDoubles = false; @@ -135,7 +135,7 @@ var apingApp = angular.module('jtt_aping', ['jtt_aping_jsonloader', 'jtt_aping_n $scope.results = apingUtilityHelper.removeDuplicateObjectsFromArray($scope.results, (appSettings.orderBy === false || appSettings.orderBy === "false" || appSettings.orderBy === "$NONE")); } - if (appSettings.orderBy !== "undefined" && appSettings.orderBy !== false && appSettings.orderBy !== "false" && appSettings.orderBy !== "$NONE") { + if (angular.isDefined(appSettings.orderBy) && appSettings.orderBy !== false && appSettings.orderBy !== "false" && appSettings.orderBy !== "$NONE") { if (appSettings.orderBy === "$RANDOM") { $scope.results = apingUtilityHelper.shuffleArray($scope.results); } else { @@ -169,11 +169,11 @@ angular.module('jtt_aping').service('apingTimeHelper', function () { * @returns {Number} */ this.getTimestampFromDateString = function (_string, _multiplier, _add) { - if (typeof _multiplier === "undefined" || isNaN(_multiplier)) { + if (angular.isUndefined(_multiplier) || isNaN(_multiplier)) { _multiplier = 1; } - if (typeof _add === "undefined" || isNaN(_add)) { + if (angular.isUndefined(_add) || isNaN(_add)) { _add = 0; } @@ -242,10 +242,10 @@ angular.module('jtt_aping').service('apingTimeHelper', function () { value.platform = _platform; if (_appSettings) { - if (typeof value.items === "undefined" && typeof _appSettings.items !== "undefined") { + if (angular.isUndefined(value.items) && angular.isDefined(_appSettings.items)) { value.items = _appSettings.items; } - if (typeof value.model === "undefined" && typeof _appSettings.model !== "undefined") { + if (angular.isUndefined(value.model) && angular.isDefined(_appSettings.model)) { value.model = _appSettings.model; } } @@ -336,8 +336,8 @@ angular.module('jtt_aping').service('apingTimeHelper', function () { var reducedArray = []; $.each(sortedArray, function (secondIndex, secondValue) { - if (typeof lastValue !== "undefined") { - if (typeof secondValue[stringifyPropertyName] !== "undefined" && secondValue[stringifyPropertyName] !== lastValue) { + if (angular.isDefined(lastValue)) { + if (angular.isDefined(secondValue[stringifyPropertyName]) && secondValue[stringifyPropertyName] !== lastValue) { reducedArray.push(secondValue); } } else { @@ -683,7 +683,7 @@ angular.module("jtt_aping_jsonloader", []) requestObject.callback = 'JSON_CALLBACK'; } - if(typeof request.items !== "undefined") { + if(angular.isDefined(request.items)) { requestObject.count = request.items; } else { requestObject.count = appSettings.items; @@ -706,14 +706,14 @@ angular.module("jtt_aping_jsonloader", []) var results = _data.data; - if(typeof request.resultProperty !== "undefined") { + if(angular.isDefined(request.resultProperty)) { results = _data.data[request.resultProperty]; } if (_data.data.constructor !== Array) { resultArray.push(results); } else { - if (request.items < 0 || typeof request.items === "undefined" ) { + if (request.items < 0 || angular.isDefined(request.items) ) { resultArray = results; } else { angular.forEach(results, function (value, key) { @@ -772,7 +772,7 @@ angular.module("jtt_aping_ng_array", []) var requestObject = {}; - if(typeof request.items !== "undefined") { + if(angular.isDefined(request.items)) { requestObject.count = request.items; } else { requestObject.count = appSettings.items; @@ -790,7 +790,7 @@ angular.module("jtt_aping_ng_array", []) var resultArray = []; if (scope[request.name].constructor === Array) { - if (requestObject.items < 0 || typeof requestObject.items === "undefined") { + if (requestObject.items < 0 || angular.isUndefined(requestObject.items)) { resultArray = scope[request.name]; } else { angular.forEach(scope[request.name], function (value, key) { diff --git a/dist/aping.min.js b/dist/aping.min.js index 8d2347f..7867e70 100644 --- a/dist/aping.min.js +++ b/dist/aping.min.js @@ -5,4 +5,4 @@ @url: https://github.com/JohnnyTheTank/apiNG @license: MIT */ -"use strict";var apingApp=angular.module("jtt_aping",["jtt_aping_jsonloader","jtt_aping_ng_array"]).config(["$provide",function(a){a.value("apingDefaultSettings",{apingApiKeys:{}})}]).directive("aping",["apingDefaultSettings","apingUtilityHelper","$templateRequest","$compile",function(a,b,c,d){return{restrict:"E",replace:"false",scope:{model:"@",getNativeData:"@",items:"@",maxItems:"@",orderBy:"@",orderReverse:"@",templateUrl:"@",payloadJson:"@",removeDoubles:"@"},link:function(b,e,f){c(b.templateUrl||a.templateUrl).then(function(a){var c=angular.element(a);e.append(c),d(c)(b)})},controller:["$scope",function(c){c.results=[],c.payload=c.payloadJson?b.replaceSingleQuotesAndParseJson(c.payloadJson):{},this.getAppSettings=function(){var b,d,e,f,g,h;return b="undefined"!=typeof c.items?c.items:"undefined"!=typeof a.items?a.items:void 0,d="undefined"!=typeof c.maxItems?c.maxItems:"undefined"!=typeof a.maxItems?a.maxItems:void 0,e="undefined"!=typeof c.getNativeData?c.getNativeData:"undefined"!=typeof a.getNativeData?a.getNativeData:!1,d="undefined"!=typeof c.maxItems?c.maxItems:"undefined"!=typeof a.maxItems?a.maxItems:void 0,g="undefined"!=typeof c.orderBy?c.orderBy:"undefined"!=typeof a.orderBy?a.orderBy:"undefined",f="undefined"!=typeof c.orderReverse?c.orderReverse:"undefined"!=typeof a.orderReverse?a.orderReverse:!1,h="undefined"!=typeof c.removeDoubles?c.removeDoubles:"undefined"!=typeof a.removeDoubles?a.removeDoubles:!1,{model:c.model||a.model||"native",getNativeData:e,items:b,maxItems:d,orderBy:g,orderReverse:f,removeDoubles:h}},this.concatToResults=function(a){c.results=c.results.concat(a);var d=this.getAppSettings();(d.removeDoubles===!0||"true"===d.removeDoubles)&&(c.results=b.removeDuplicateObjectsFromArray(c.results,d.orderBy===!1||"false"===d.orderBy||"$NONE"===d.orderBy)),"undefined"!==d.orderBy&&d.orderBy!==!1&&"false"!==d.orderBy&&"$NONE"!==d.orderBy&&("$RANDOM"===d.orderBy?c.results=b.shuffleArray(c.results):(c.results.sort(b.sortArrayByProperty(d.orderBy)),(d.orderReverse===!0||"true"===d.orderReverse)&&c.results.reverse())),d.maxItems>-1&&c.results.length>d.maxItems&&(c.results=c.results.splice(0,d.maxItems)),c.$broadcast("apiNG.resultMerged")},this.apply=function(){c.$apply()}}]}}]);angular.module("jtt_aping").service("apingTimeHelper",function(){this.getTimestampFromDateString=function(a,b,c){if(("undefined"==typeof b||isNaN(b))&&(b=1),("undefined"==typeof 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&&("undefined"==typeof b.items&&"undefined"!=typeof d.items&&(b.items=d.items),"undefined"==typeof b.model&&"undefined"!=typeof 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){"undefined"!=typeof f?"undefined"!=typeof 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,source:void 0,likes:void 0,shares:void 0,comments:void 0,position:void 0};break;case"video":c={platform:void 0,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,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",[]).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&&"jsonp"===a.format?c.callback=a.callback:c.callback="JSON_CALLBACK","undefined"!=typeof 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;"undefined"!=typeof a.resultProperty&&(d=b.data[a.resultProperty]),b.data.constructor!==Array?c.push(d):a.items<0||"undefined"==typeof a.items?c=d:angular.forEach(d,function(b,d){d0&&e.concatToResults(d)}})}}}]); \ No newline at end of file +"use strict";var apingApp=angular.module("jtt_aping",["jtt_aping_jsonloader","jtt_aping_ng_array"]).config(["$provide",function(a){a.value("apingDefaultSettings",{apingApiKeys:{}})}]).directive("aping",["apingDefaultSettings","apingUtilityHelper","$templateRequest","$compile",function(a,b,c,d){return{restrict:"E",replace:"false",scope:{model:"@",getNativeData:"@",items:"@",maxItems:"@",orderBy:"@",orderReverse:"@",templateUrl:"@",payloadJson:"@",removeDoubles:"@"},link:function(b,e,f){c(b.templateUrl||a.templateUrl).then(function(a){var c=angular.element(a);e.append(c),d(c)(b)})},controller:["$scope",function(c){c.results=[],c.payload=c.payloadJson?b.replaceSingleQuotesAndParseJson(c.payloadJson):{},this.getAppSettings=function(){var b,d,e,f,g,h;return b=angular.isDefined(c.items)?c.items:angular.isDefined(a.items)?a.items:void 0,d=angular.isDefined(c.maxItems)?c.maxItems:angular.isDefined(a.maxItems)?a.maxItems:void 0,e=angular.isDefined(c.getNativeData)?c.getNativeData:angular.isDefined(a.getNativeData)?a.getNativeData:!1,d=angular.isDefined(c.maxItems)?c.maxItems:angular.isDefined(a.maxItems)?a.maxItems:void 0,g=angular.isDefined(c.orderBy)?c.orderBy:angular.isDefined(a.orderBy)?a.orderBy:void 0,f=angular.isDefined(c.orderReverse)?c.orderReverse:angular.isDefined(a.orderReverse)?a.orderReverse:!1,h=angular.isDefined(c.removeDoubles)?c.removeDoubles:angular.isDefined(a.removeDoubles)?a.removeDoubles:!1,{model:c.model||a.model||"native",getNativeData:e,items:b,maxItems:d,orderBy:g,orderReverse:f,removeDoubles:h}},this.concatToResults=function(a){c.results=c.results.concat(a);var d=this.getAppSettings();(d.removeDoubles===!0||"true"===d.removeDoubles)&&(c.results=b.removeDuplicateObjectsFromArray(c.results,d.orderBy===!1||"false"===d.orderBy||"$NONE"===d.orderBy)),angular.isDefined(d.orderBy)&&d.orderBy!==!1&&"false"!==d.orderBy&&"$NONE"!==d.orderBy&&("$RANDOM"===d.orderBy?c.results=b.shuffleArray(c.results):(c.results.sort(b.sortArrayByProperty(d.orderBy)),(d.orderReverse===!0||"true"===d.orderReverse)&&c.results.reverse())),d.maxItems>-1&&c.results.length>d.maxItems&&(c.results=c.results.splice(0,d.maxItems)),c.$broadcast("apiNG.resultMerged")},this.apply=function(){c.$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,source:void 0,likes:void 0,shares:void 0,comments:void 0,position:void 0};break;case"video":c={platform:void 0,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,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",[]).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&&"jsonp"===a.format?c.callback=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/src/aping-directive.js b/src/aping-directive.js index b848ee9..5ca4794 100644 --- a/src/aping-directive.js +++ b/src/aping-directive.js @@ -47,57 +47,57 @@ var apingApp = angular.module('jtt_aping', ['jtt_aping_jsonloader', 'jtt_aping_n var orderBy; var removeDoubles; - if (typeof $scope.items !== "undefined") { + if (angular.isDefined($scope.items)) { items = $scope.items; - } else if (typeof apingDefaultSettings.items !== "undefined") { + } else if (angular.isDefined(apingDefaultSettings.items)) { items = apingDefaultSettings.items; } else { items = undefined; } - if (typeof $scope.maxItems !== "undefined") { + if (angular.isDefined($scope.maxItems)) { maxItems = $scope.maxItems; - } else if (typeof apingDefaultSettings.maxItems !== "undefined") { + } else if (angular.isDefined(apingDefaultSettings.maxItems)) { maxItems = apingDefaultSettings.maxItems; } else { maxItems = undefined; } - if (typeof $scope.getNativeData !== "undefined") { + if (angular.isDefined($scope.getNativeData)) { getNativeData = $scope.getNativeData; - } else if (typeof apingDefaultSettings.getNativeData !== "undefined") { + } else if (angular.isDefined(apingDefaultSettings.getNativeData)) { getNativeData = apingDefaultSettings.getNativeData; } else { getNativeData = false; } - if (typeof $scope.maxItems !== "undefined") { + if (angular.isDefined($scope.maxItems)) { maxItems = $scope.maxItems; - } else if (typeof apingDefaultSettings.maxItems !== "undefined") { + } else if (angular.isDefined(apingDefaultSettings.maxItems)) { maxItems = apingDefaultSettings.maxItems; } else { maxItems = undefined; } - if (typeof $scope.orderBy !== "undefined") { + if (angular.isDefined($scope.orderBy)) { orderBy = $scope.orderBy; - } else if (typeof apingDefaultSettings.orderBy !== "undefined") { + } else if (angular.isDefined(apingDefaultSettings.orderBy)) { orderBy = apingDefaultSettings.orderBy; } else { - orderBy = "undefined"; + orderBy = undefined; } - if (typeof $scope.orderReverse !== "undefined") { + if (angular.isDefined($scope.orderReverse)) { orderReverse = $scope.orderReverse; - } else if (typeof apingDefaultSettings.orderReverse !== "undefined") { + } else if (angular.isDefined(apingDefaultSettings.orderReverse)) { orderReverse = apingDefaultSettings.orderReverse; } else { orderReverse = false; } - if (typeof $scope.removeDoubles !== "undefined") { + if (angular.isDefined($scope.removeDoubles)) { removeDoubles = $scope.removeDoubles; - } else if (typeof apingDefaultSettings.removeDoubles !== "undefined") { + } else if (angular.isDefined(apingDefaultSettings.removeDoubles)) { removeDoubles = apingDefaultSettings.removeDoubles; } else { removeDoubles = false; @@ -128,7 +128,7 @@ var apingApp = angular.module('jtt_aping', ['jtt_aping_jsonloader', 'jtt_aping_n $scope.results = apingUtilityHelper.removeDuplicateObjectsFromArray($scope.results, (appSettings.orderBy === false || appSettings.orderBy === "false" || appSettings.orderBy === "$NONE")); } - if (appSettings.orderBy !== "undefined" && appSettings.orderBy !== false && appSettings.orderBy !== "false" && appSettings.orderBy !== "$NONE") { + if (angular.isDefined(appSettings.orderBy) && appSettings.orderBy !== false && appSettings.orderBy !== "false" && appSettings.orderBy !== "$NONE") { if (appSettings.orderBy === "$RANDOM") { $scope.results = apingUtilityHelper.shuffleArray($scope.results); } else { diff --git a/src/aping-helpers.js b/src/aping-helpers.js index 3124143..a334ca7 100644 --- a/src/aping-helpers.js +++ b/src/aping-helpers.js @@ -11,11 +11,11 @@ angular.module('jtt_aping').service('apingTimeHelper', function () { * @returns {Number} */ this.getTimestampFromDateString = function (_string, _multiplier, _add) { - if (typeof _multiplier === "undefined" || isNaN(_multiplier)) { + if (angular.isUndefined(_multiplier) || isNaN(_multiplier)) { _multiplier = 1; } - if (typeof _add === "undefined" || isNaN(_add)) { + if (angular.isUndefined(_add) || isNaN(_add)) { _add = 0; } @@ -84,10 +84,10 @@ angular.module('jtt_aping').service('apingTimeHelper', function () { value.platform = _platform; if (_appSettings) { - if (typeof value.items === "undefined" && typeof _appSettings.items !== "undefined") { + if (angular.isUndefined(value.items) && angular.isDefined(_appSettings.items)) { value.items = _appSettings.items; } - if (typeof value.model === "undefined" && typeof _appSettings.model !== "undefined") { + if (angular.isUndefined(value.model) && angular.isDefined(_appSettings.model)) { value.model = _appSettings.model; } } @@ -178,8 +178,8 @@ angular.module('jtt_aping').service('apingTimeHelper', function () { var reducedArray = []; $.each(sortedArray, function (secondIndex, secondValue) { - if (typeof lastValue !== "undefined") { - if (typeof secondValue[stringifyPropertyName] !== "undefined" && secondValue[stringifyPropertyName] !== lastValue) { + if (angular.isDefined(lastValue)) { + if (angular.isDefined(secondValue[stringifyPropertyName]) && secondValue[stringifyPropertyName] !== lastValue) { reducedArray.push(secondValue); } } else { diff --git a/src/aping-jsonloader-directive.js b/src/aping-jsonloader-directive.js index d346d9c..d55517c 100644 --- a/src/aping-jsonloader-directive.js +++ b/src/aping-jsonloader-directive.js @@ -31,7 +31,7 @@ angular.module("jtt_aping_jsonloader", []) requestObject.callback = 'JSON_CALLBACK'; } - if(typeof request.items !== "undefined") { + if(angular.isDefined(request.items)) { requestObject.count = request.items; } else { requestObject.count = appSettings.items; @@ -54,14 +54,14 @@ angular.module("jtt_aping_jsonloader", []) var results = _data.data; - if(typeof request.resultProperty !== "undefined") { + if(angular.isDefined(request.resultProperty)) { results = _data.data[request.resultProperty]; } if (_data.data.constructor !== Array) { resultArray.push(results); } else { - if (request.items < 0 || typeof request.items === "undefined" ) { + if (request.items < 0 || angular.isDefined(request.items) ) { resultArray = results; } else { angular.forEach(results, function (value, key) { diff --git a/src/aping-ng-array-directive.js b/src/aping-ng-array-directive.js index d6277d3..a0a212f 100644 --- a/src/aping-ng-array-directive.js +++ b/src/aping-ng-array-directive.js @@ -17,7 +17,7 @@ angular.module("jtt_aping_ng_array", []) var requestObject = {}; - if(typeof request.items !== "undefined") { + if(angular.isDefined(request.items)) { requestObject.count = request.items; } else { requestObject.count = appSettings.items; @@ -35,7 +35,7 @@ angular.module("jtt_aping_ng_array", []) var resultArray = []; if (scope[request.name].constructor === Array) { - if (requestObject.items < 0 || typeof requestObject.items === "undefined") { + if (requestObject.items < 0 || angular.isUndefined(requestObject.items)) { resultArray = scope[request.name]; } else { angular.forEach(scope[request.name], function (value, key) {