From 41d2b5f23503acf0080a5a26e8069ec079e87689 Mon Sep 17 00:00:00 2001 From: Marcos Nils Date: Wed, 4 Jan 2017 18:43:06 +0200 Subject: [PATCH] Add instance name to hash in URL (#77) Fixes #7 --- www/assets/app.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/www/assets/app.js b/www/assets/app.js index c2f54ce..e6015dc 100644 --- a/www/assets/app.js +++ b/www/assets/app.js @@ -164,9 +164,10 @@ $scope.instances.push(instance); $scope.idx[instance.name] = instance; } - if ($scope.instances.length) { - $scope.showInstance($scope.instances[0]); - } + + // If instance is passed in URL, select it + let inst = $scope.idx[$location.hash()]; + if (inst) $scope.showInstance(inst); }, function(response) { if (response.status == 404) { document.write('session not found'); @@ -183,6 +184,7 @@ $scope.showInstance = function(instance) { $scope.selectedInstance = instance; + $location.hash(instance.name); if (!instance.creatingTerminal) { if (!instance.term) { $timeout(function() { @@ -287,8 +289,8 @@ } } }]) - - .config(['$mdIconProvider', function($mdIconProvider) { - $mdIconProvider.defaultIconSet('../assets/social-icons.svg', 24); - }]); + .config(['$mdIconProvider', '$locationProvider', function($mdIconProvider, $locationProvider) { + $locationProvider.html5Mode({enabled: true, requireBase: false}); + $mdIconProvider.defaultIconSet('../assets/social-icons.svg', 24); + }]); })();