angular.module('starter', ['ionic', 'ionic.contrib.frostedGlass'])

.controller('PageCtrl', function ($scope, $ionicFrostedDelegate, $ionicScrollDelegate, $rootScope) {
  var messageOptions = [
    {
      content: '<p>Wow, this is really something huh?</p>'
    },
    {
      content: '<p>Yea, it\'s pretty sweet</p>'
    },
    {
      content: '<p>I think I like Ionic more than I like ice cream!</p>'
    },
    {
      content: '<p>Gee wiz, this is something special.</p>'
    },
    {
      content: '<img src="data:image/jpeg;base64,[encoded data, 13536 characters]" alt=""/>'
    },
    {
      content: '<p>Is this magic?</p>'
    },
    {
      content: '<p>Am I dreaming?</p>'
    },
    {
      content: '<img src="data:image/jpeg;base64,[encoded data, 13120 characters]" alt=""/>'
    },
    {
      content: '<p>Am I dreaming?</p>'
    },
    {
      content: '<p>Yea, it\'s pretty sweet</p>'
    },
    {
      content: '<p>I think I like Ionic more than I like ice cream!</p>'
    },
  ];

  var messageIter = 0;
  $scope.messages = messageOptions.slice(0, messageOptions.length);

  $scope.add = function () {
    var nextMessage = messageOptions[messageIter++ % messageOptions.length];
    $scope.messages.push(angular.extend({}, nextMessage));

    // Update the scroll area and tell the frosted glass to redraw itself
    $ionicFrostedDelegate.update();
    $ionicScrollDelegate.scrollBottom(true);
  };
});