summaryrefslogtreecommitdiff
path: root/www/js/NewsCtrl.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js/NewsCtrl.js')
-rw-r--r--www/js/NewsCtrl.js120
1 files changed, 59 insertions, 61 deletions
diff --git a/www/js/NewsCtrl.js b/www/js/NewsCtrl.js
index b914b32a..294f0a98 100644
--- a/www/js/NewsCtrl.js
+++ b/www/js/NewsCtrl.js
@@ -2,28 +2,32 @@
/* jslint browser: true*/
/* global cordova,StatusBar,angular,console,moment*/
-angular.module('zmApp.controllers').controller('zmApp.NewsCtrl', ['$scope', '$rootScope', '$ionicModal', 'ZMDataModel','$ionicSideMenuDelegate', '$ionicHistory', '$state', '$http', 'zm', function ($scope, $rootScope, $ionicModal, ZMDataModel,$ionicSideMenuDelegate, $ionicHistory, $state, $http, zm) {
-$scope.openMenu = function () {
- $ionicSideMenuDelegate.toggleLeft();
- };
+angular.module('zmApp.controllers').controller('zmApp.NewsCtrl', ['$scope', '$rootScope', '$ionicModal', 'ZMDataModel', '$ionicSideMenuDelegate', '$ionicHistory', '$state', '$http', 'zm', function ($scope, $rootScope, $ionicModal, ZMDataModel, $ionicSideMenuDelegate, $ionicHistory, $state, $http, zm) {
+ $scope.openMenu = function () {
+ $ionicSideMenuDelegate.toggleLeft();
+ };
//----------------------------------------------------------------
// Alarm notification handling
//----------------------------------------------------------------
- $scope.handleAlarms = function()
- {
- $rootScope.isAlarm=!$rootScope.isAlarm;
- if (!$rootScope.isAlarm)
- {
- $rootScope.alarmCount="0";
- $ionicHistory.nextViewOptions({disableBack: true});
- $state.go("events", {"id": 0}, { reload: true });
+ $scope.handleAlarms = function () {
+ $rootScope.isAlarm = !$rootScope.isAlarm;
+ if (!$rootScope.isAlarm) {
+ $rootScope.alarmCount = "0";
+ $ionicHistory.nextViewOptions({
+ disableBack: true
+ });
+ $state.go("events", {
+ "id": 0
+ }, {
+ reload: true
+ });
}
};
- //-------------------------------------------------------------------------
+ //-------------------------------------------------------------------------
// Lets make sure we set screen dim properly as we enter
// The problem is we enter other states before we leave previous states
// from a callback perspective in ionic, so we really can't predictably
@@ -31,14 +35,13 @@ $scope.openMenu = function () {
// state, that effectively overwrites current view power management needs
//------------------------------------------------------------------------
$scope.$on('$ionicView.enter', function () {
- // console.log("**VIEW ** News Ctrl Entered");
+ // console.log("**VIEW ** News Ctrl Entered");
ZMDataModel.setAwake(false);
-
-
+
+
});
-
- $scope.isUnread = function(itemdate)
- {
+
+ $scope.isUnread = function (itemdate) {
var lastDate = ZMDataModel.getLatestBlogPostChecked();
//get("latestBlogPostChecked");
if (!lastDate) return true;
@@ -46,61 +49,56 @@ $scope.openMenu = function () {
var mItemDate = moment(itemdate);
//var unread = mItemDate.diff(mLastDate) >0) ? true:false;
//console.log (unread);
- return (mItemDate.diff(mLastDate) >0) ? true:false;
-
-
+ return (mItemDate.diff(mLastDate) > 0) ? true : false;
+
+
};
-
- $scope.loadPost = function (item, itemdate)
- {
+
+ $scope.loadPost = function (item, itemdate) {
var lastDate =
- ZMDataModel.getLatestBlogPostChecked(); //zmStorageService.get("latestBlogPostChecked");
-
-
- if (!lastDate)
- {
- ZMDataModel.zmDebug ("First time checking blog posts, I see");
+ ZMDataModel.getLatestBlogPostChecked(); //zmStorageService.get("latestBlogPostChecked");
+
+
+ if (!lastDate) {
+ ZMDataModel.zmDebug("First time checking blog posts, I see");
ZMDataModel.setLatestBlogPostChecked(itemdate);
//zmStorageService.set("latestBlogPostChecked", itemdate);
- }
-
- else
- {
- ZMDataModel.zmDebug ("last post checked is " + lastDate);
- ZMDataModel.zmDebug ("current post dated is " + itemdate);
-
+ } else {
+ ZMDataModel.zmDebug("last post checked is " + lastDate);
+ ZMDataModel.zmDebug("current post dated is " + itemdate);
+
var mLastDate = moment(lastDate);
var mItemDate = moment(itemdate);
- if (mItemDate.diff(mLastDate) >0)
- {
- ZMDataModel.zmDebug ("Updating lastDate to this post");
-
- ZMDataModel.setLatestBlogPostChecked(itemdate); //zmStorageService.set("latestBlogPostChecked", itemdate);
-
- if (itemdate == $scope.newsItems[0].date)
- {
+ if (mItemDate.diff(mLastDate) > 0) {
+ ZMDataModel.zmDebug("Updating lastDate to this post");
+
+ ZMDataModel.setLatestBlogPostChecked(itemdate); //zmStorageService.set("latestBlogPostChecked", itemdate);
+
+ if (itemdate == $scope.newsItems[0].date) {
// we are reading the latest post
- $rootScope.newBlogPost="";
+ $rootScope.newBlogPost = "";
}
}
-
+
}
- window.open(item, '_blank', 'location=yes');
+ window.open(item, '_blank', 'location=yes');
return false;
};
-
- $scope.newsItems=[];
-
- $http.get (zm.blogUrl)
- .success (function(data)
- {
+
+ $scope.newsItems = [];
+
+ $http.get(zm.blogUrl)
+ .success(function (data) {
//console.log ("Here2");
- // console.log (JSON.stringify(data));
- for (var i=0; i<data.length; i++)
- {
- $scope.newsItems.push({title:data[i].title, url:data[i].url, date:data[i].date});
+ // console.log (JSON.stringify(data));
+ for (var i = 0; i < data.length; i++) {
+ $scope.newsItems.push({
+ title: data[i].title,
+ url: data[i].url,
+ date: data[i].date
+ });
}
-
+
});
-}]);
+}]); \ No newline at end of file