Skip to content

Commit

Permalink
[JS] Add dynamic Erase and Install button instead of install
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaya-Cout committed Sep 21, 2023
1 parent ca93103 commit 2e515b8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h6 class="my-0">{{file.name}}</h6>
</div>
</div>

<button class="btn btn-primary btn-lg btn-block" ng-click="upload()" translate="INSTALL"></button>
<button class="btn btn-primary btn-lg btn-block" ng-click="upload()">{{ installText | translate }}</button>
</div>

<div class="col-md-8 order-md-1">
Expand Down
27 changes: 25 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,32 @@ angular.module('nwas', ['ngSanitize', 'pascalprecht.translate']).controller('mai
$scope.selectedApps = [];
$scope.customFiles = [];
$scope.webUSB = typeof navigator.usb !== 'undefined';
$scope.installText = "ERASE"

$scope.reload = function reload() {
document.location.reload();
}

function reloadInstallText() {
if($scope.selectedApps.length > 0 || $scope.customFiles.length > 0 || $scope.wallpaper != null) {
$scope.installText = "ERASE_AND_INSTALL";
} else {
$scope.installText = "ERASE";
}
}

$scope.$watch('selectedApps', function() {
reloadInstallText();
}, true);

$scope.$watch('customFiles', function() {
reloadInstallText();
}, true);

$scope.$watch('wallpaper', function() {
reloadInstallText();
}, true);

$scope.addApplication = function addApplication(app) {
if($scope.selectedApps.indexOf(app) < 0) {
$scope.selectedApps.push(app);
Expand Down Expand Up @@ -485,7 +506,8 @@ angular.module('nwas', ['ngSanitize', 'pascalprecht.translate']).controller('mai
SELECTED_APPLICATIONS: 'Selected applications',
REMOVE: 'Remove',
CUSTOM_FILE: 'Custom file',
INSTALL: 'Install',
ERASE: 'Erase',
ERASE_AND_INSTALL: 'Erase and install',
WALLPAPER: "Wallpaper",
WALLPAPER_FILE: 'Image file',
AVAILABLE_APPLICATIONS: 'Available applications',
Expand Down Expand Up @@ -519,7 +541,8 @@ angular.module('nwas', ['ngSanitize', 'pascalprecht.translate']).controller('mai
SELECTED_APPLICATIONS: 'Applications sélectionnées',
REMOVE: 'Supprimer',
CUSTOM_FILE: 'Fichier local',
INSTALL: 'Installer',
ERASE: 'Effacer',
ERASE_AND_INSTALL: 'Effacer et installer',
WALLPAPER: 'Fond d\'écran',
WALLPAPER_FILE: 'Fichier image',
AVAILABLE_APPLICATIONS: 'Applications disponibles',
Expand Down

0 comments on commit 2e515b8

Please sign in to comment.