1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-10 11:15:01 -05:00
mail/src/js/controller/read.js

56 lines
1.7 KiB
JavaScript
Raw Normal View History

define(function(require) {
'use strict';
var appController = require('js/app-controller'),
angular = require('angular'),
crypto, keychain;
//
// Controller
//
var ReadCtrl = function($scope) {
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';
$scope.state.read = {
open: false,
toggle: function(to) {
this.open = to;
}
};
$scope.lineEmpty = function(line) {
return line.replace(/>/g, '').trim().length === 0;
};
$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();
});
};
};
//
// 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;
});