1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-20 07:40:57 +02:00
bitwarden-browser/src/popup/app/vault/vaultViewSiteController.js

61 lines
2.0 KiB
JavaScript
Raw Normal View History

2016-09-06 05:43:56 +02:00
angular
.module('bit.vault')
.controller('vaultViewSiteController', function ($scope, $state, $stateParams, siteService, cipherService, tldjs, toastr) {
var returnScrollY = $stateParams.returnScrollY;
$scope.site = null;
2016-09-09 04:23:56 +02:00
siteService.get($stateParams.siteId, function (site) {
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;
}
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;
}
});
});
$scope.close = function () {
$state.go('tabs.vault', { animation: 'out-slide-down', scrollY: returnScrollY || 0 });
};
$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
});