2013-10-05 08:16:04 -04:00
|
|
|
define(function(require) {
|
|
|
|
'use strict';
|
|
|
|
|
2013-12-03 07:15:10 -05:00
|
|
|
var appController = require('js/app-controller'),
|
|
|
|
angular = require('angular'),
|
|
|
|
crypto, keychain;
|
2013-10-05 08:16:04 -04:00
|
|
|
|
|
|
|
//
|
|
|
|
// Controller
|
|
|
|
//
|
|
|
|
|
2013-11-08 16:05:08 -05:00
|
|
|
var ReadCtrl = function($scope) {
|
2013-12-03 07:15:10 -05:00
|
|
|
crypto = appController._crypto;
|
|
|
|
keychain = appController._keychain;
|
|
|
|
|
2013-12-04 05:50:20 -05:00
|
|
|
// set default value so that the popover height is correct on init
|
|
|
|
$scope.fingerprint = 'XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX';
|
|
|
|
|
2013-11-08 16:05:08 -05:00
|
|
|
$scope.state.read = {
|
|
|
|
open: false,
|
|
|
|
toggle: function(to) {
|
|
|
|
this.open = to;
|
|
|
|
}
|
|
|
|
};
|
2013-11-18 13:53:31 -05:00
|
|
|
|
|
|
|
$scope.lineEmpty = function(line) {
|
|
|
|
return line.replace(/>/g, '').trim().length === 0;
|
|
|
|
};
|
2013-12-03 07:15:10 -05:00
|
|
|
|
|
|
|
$scope.getFingerprint = function(address) {
|
|
|
|
keychain.getReceiverPublicKey(address, function(err, pubkey) {
|
|
|
|
var fpr = crypto.getFingerprint(pubkey.publicKey);
|
|
|
|
var formatted = fpr.slice(0, 4) + ' ' + fpr.slice(4, 8) + ' ' + fpr.slice(8, 12) + ' ' + fpr.slice(12, 16) + ' ' + fpr.slice(16, 20) + ' ' + fpr.slice(20, 24) + ' ' + fpr.slice(24, 28) + ' ' + fpr.slice(28, 32) + ' ' + fpr.slice(32, 36) + ' ' + fpr.slice(36);
|
|
|
|
|
|
|
|
$scope.fingerprint = formatted;
|
|
|
|
$scope.$apply();
|
|
|
|
});
|
|
|
|
};
|
2013-11-08 16:05:08 -05:00
|
|
|
};
|
2013-10-05 08:16:04 -04:00
|
|
|
|
|
|
|
//
|
|
|
|
// Directives
|
|
|
|
//
|
|
|
|
|
|
|
|
var ngModule = angular.module('read', []);
|
|
|
|
ngModule.directive('frameLoad', function() {
|
|
|
|
return function(scope, elm) {
|
|
|
|
elm.bind('load', function() {
|
|
|
|
var frame = elm[0];
|
|
|
|
frame.height = frame.contentWindow.document.body.scrollHeight + 'px';
|
|
|
|
});
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
return ReadCtrl;
|
|
|
|
});
|