Skip to content

Commit

Permalink
Progress
Browse files Browse the repository at this point in the history
  • Loading branch information
orweinberger committed Mar 13, 2015
1 parent d44aaf4 commit bfe87fb
Show file tree
Hide file tree
Showing 11 changed files with 54,200 additions and 16,152 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@
"watchify": "^2.4.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"
}
}
},
"cordovaPlugins": []
}
4 changes: 4 additions & 0 deletions www/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,8 @@

.children {
display: inline-block;
}

#qrcode img {
margin:0 auto;
}
3 changes: 3 additions & 0 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
<script src="js/pockets.bundle.js"></script>

<!-- cordova script (this will be a 404 during development) -->
<script src="js/ng-cordova.min.js"></script>
<script src="cordova.js"></script>

<!-- your app's js -->
<script src="js/qrcode.min.js"></script>
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/services.js"></script>
<script src="js/directives.js"></script>
</head>
<body ng-app="starter">
<!--
Expand Down
2 changes: 1 addition & 1 deletion www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// the 2nd parameter is an array of 'requires'
// 'starter.services' is found in services.js
// 'starter.controllers' is found in controllers.js
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'starter.directives', 'ngCordova'])

.run(function ($ionicPlatform) {
$ionicPlatform.ready(function () {
Expand Down
44 changes: 38 additions & 6 deletions www/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ angular.module('starter.controllers', [])
}

$scope.pockets = result;
console.log(result);
}).error(function (err) {
if (err)
throw err;
Expand All @@ -124,7 +125,7 @@ angular.module('starter.controllers', [])
else
$state.go('tab.pocket-details', {pocketName: pocketName});
};
$scope.pocketHold = function(pocketName) {
$scope.pocketHold = function (pocketName) {
var myPopup = $ionicPopup.alert({
template: "<div>Delete?</div>",
scope: $scope,
Expand All @@ -133,15 +134,15 @@ angular.module('starter.controllers', [])
{
text: '<b>Delete</b>',
type: 'button-positive',
onTap: function() {
onTap: function () {
return true
}
}
]
});
myPopup.then(function(res) {
myPopup.then(function (res) {
if (res) {
engine.pockets.delete({name: pocketName}).then(function() {
engine.pockets.delete({name: pocketName}).then(function () {

});
}
Expand Down Expand Up @@ -227,8 +228,39 @@ angular.module('starter.controllers', [])
});
};
})
.controller('pocketDetailsCtrl', function ($scope, $state, $stateParams) {

.controller('pocketDetailsCtrl', function ($scope, $state, $ionicPopup, $stateParams, $cordovaBarcodeScanner) {
engine.pockets.get({name: $stateParams.pocketName}).then(function (result) {
$scope.pockets = result;
$scope.$digest();
});
$scope.scanQR = function () {
$cordovaBarcodeScanner.scan().then(function (imageData) {
$scope.toAddress = imageData.text;
}, function (error) {
console.log("An error happened -> " + error);
});
};
$scope.spendDialog = function () {
$scope.data = {};
var myPopup = $ionicPopup.show({
template: '<label class="item item-input">' +
'<span class="input-label">Amount</span>' +
'<input ng-model="data.amount" type="number" placeholder="0.01">' +
'</label>' +
'<br><div ng-click="scanQR()">Scan</div><br><button class="btn btn-danger">Send</button>',
title: 'Info',
scope: $scope,
buttons: [
{
text: '<b>OK</b>',
type: 'button-positive'
}
]
});
myPopup.then(function (res) {
console.log($scope.pockets.name, $scope.toAddress, $scope.amount);
});
};
})
.controller('DashCtrl', function ($scope) {
})
Expand Down
18 changes: 18 additions & 0 deletions www/js/directives.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
angular.module('starter.directives', [])
.directive('qrcode', function () {
function link(scope, element, attrs) {
var handled = false;
scope.$watch(function() {
if (scope.pockets && !handled) {
handled = true;
new QRCode(document.getElementById("qrcode"), scope.pockets.wallet.address);
}
});
}
return {
restrict: 'E',
template: '<div id="qrcode"></div>',
link: link,
scope: "="
};
});
9 changes: 9 additions & 0 deletions www/js/ng-cordova.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit bfe87fb

Please sign in to comment.