2016-09-06 05:43:56 +02:00
|
|
|
|
angular
|
|
|
|
|
.module('bit.vault')
|
|
|
|
|
|
2016-09-13 04:37:59 +02:00
|
|
|
|
.controller('vaultViewSiteController', function ($scope, $state, $stateParams, siteService, cipherService, tldjs, toastr) {
|
2016-09-13 01:48:36 +02:00
|
|
|
|
var returnScrollY = $stateParams.returnScrollY;
|
|
|
|
|
|
2016-09-06 06:22:47 +02:00
|
|
|
|
$scope.site = null;
|
2016-09-09 04:23:56 +02:00
|
|
|
|
siteService.get($stateParams.siteId, function (site) {
|
2016-09-06 06:22:47 +02:00
|
|
|
|
cipherService.decryptSite(site).then(function (model) {
|
|
|
|
|
$scope.site = model;
|
2016-09-11 05:50:51 +02:00
|
|
|
|
|
|
|
|
|
if (model.password) {
|
|
|
|
|
var maskedPassword = '';
|
|
|
|
|
for (var i = 0; i < model.password.length; i++) {
|
|
|
|
|
maskedPassword += '•';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$scope.site.maskedPassword = maskedPassword;
|
|
|
|
|
}
|
2016-09-13 04:37:59 +02:00
|
|
|
|
|
|
|
|
|
if (model.uri) {
|
|
|
|
|
$scope.site.showLaunch = model.uri.startsWith('http://') || model.uri.startsWith('https://');
|
|
|
|
|
var domain = tldjs.getDomain(model.uri);
|
|
|
|
|
if (domain) {
|
|
|
|
|
$scope.site.website = domain;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$scope.site.website = model.uri;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$scope.site.showLaunch = false;
|
|
|
|
|
}
|
2016-09-06 06:22:47 +02:00
|
|
|
|
});
|
|
|
|
|
});
|
2016-09-13 01:48:36 +02:00
|
|
|
|
|
|
|
|
|
$scope.close = function () {
|
|
|
|
|
$state.go('tabs.vault', { animation: 'out-slide-down', scrollY: returnScrollY || 0 });
|
|
|
|
|
};
|
2016-09-13 04:37:59 +02:00
|
|
|
|
|
|
|
|
|
$scope.launchWebsite = function (site) {
|
|
|
|
|
if (site.showLaunch) {
|
|
|
|
|
chrome.tabs.create({ url: site.uri });
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.clipboardError = function (e, password) {
|
|
|
|
|
toastr.info('Your web browser does not support easy clipboard copying. Copy it manually instead.');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.clipboardSuccess = function (e, type) {
|
|
|
|
|
e.clearSelection();
|
|
|
|
|
toastr.info(type + ' copied!');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.showPassword = false;
|
|
|
|
|
$scope.togglePassword = function () {
|
|
|
|
|
$scope.showPassword = !$scope.showPassword;
|
|
|
|
|
};
|
2016-09-06 05:43:56 +02:00
|
|
|
|
});
|