Fix atob error, add url params
This commit is contained in:
parent
fa0b2f6142
commit
e35f2ab4d6
27
index.html
27
index.html
@ -12,6 +12,7 @@
|
||||
<meta http-equiv="x-dns-prefetch-control" content="off">
|
||||
<!-- https://w3c.github.io/manifest/ && https://developer.mozilla.org/en-US/docs/Web/Manifest -->
|
||||
<link rel="manifest" href="webapp.manifest.json">
|
||||
<base href="/">
|
||||
<title ng-bind-template="{{ notificationStatus }}Glowing Bear {{ pageTitle}}"></title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha256-916EbMg70RQy9LHiGkXzG8hSg9EdNy97GazNG/aiY1w=" crossorigin="anonymous" />
|
||||
<link rel="shortcut icon" sizes="128x128" href="assets/img/glowing_bear_128x128.png">
|
||||
@ -230,7 +231,10 @@ chown -R <strong>username</strong>:<strong>username</strong> ~<strong>username</
|
||||
</p>
|
||||
<h3>Setting a custom path</h3>
|
||||
<p>
|
||||
To connect to the weechat relay service we connect using a URL. A typical URL consists of 4 parts. <code>{scheme}://{host}:{port}/{path}</code>. The path can be changed by enterying the relay's full URL (except the scheme).
|
||||
The hostname field can be used to set a custom path. Or a URL parameter can be used see section 'URL Parameters'.
|
||||
</p>
|
||||
<p>
|
||||
To connect to the weechat relay service we connect using a URL. A typical URL consists of 4 parts. <code>{scheme}://{host}:{port}/{path}</code>. The path can be changed by entering the relay's full URL (except the scheme).
|
||||
</p>
|
||||
<ul>
|
||||
<li><b>scheme</b>: The scheme must never be input. The scheme is "ws" if TLS isn't used and it is "wss" if TLS is used.</li>
|
||||
@ -263,6 +267,27 @@ chown -R <strong>username</strong>:<strong>username</strong> ~<strong>username</
|
||||
<li><span class="text-danger">2001:db8:85a3::8a2e:370:7334</span> (must wrap IPv6 address in square brackets)</li>
|
||||
<li><span class="text-danger">2001:db8:85a3::8a2e:370:7334:8000</span> (must wrap IPv6 address in square brackets)</li>
|
||||
</ul>
|
||||
<h3>URL Parameters</h3>
|
||||
<p>
|
||||
Parameters can be passed in the URL to prefill the fields. This can be useful when you have multiple relays and want to use bookmarks to manage them.
|
||||
We do not recommend passing the password in this was as it will be visible in plain text and stored in the bookmark but it is possible. Special characters should be <a href="https://www.w3schools.com/tags/ref_urlencode.asp">URL encoded</a>.
|
||||
</p>
|
||||
<p>
|
||||
If we want just the path for example: <code>https://glowing-bear.org/?path=weechat2</code>
|
||||
</p>
|
||||
<p>
|
||||
An example: <code>https://glowing-bear.org/?host=my.domain.com&port=8000&password=hunter2&autoconnect=true</code>
|
||||
</p>
|
||||
<p>
|
||||
Available parameters:
|
||||
<ul>
|
||||
<li>host</li>
|
||||
<li>port</li>
|
||||
<li>path</li>
|
||||
<li>password</li>
|
||||
<li>autoconnect</li>
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -8,9 +8,12 @@ document.addEventListener("deviceready", function () {
|
||||
}
|
||||
}, false);
|
||||
|
||||
var weechat = angular.module('weechat', ['ngRoute', 'localStorage', 'weechatModels', 'bufferResume', 'plugins', 'IrcUtils', 'ngSanitize', 'ngWebsockets', 'ngTouch'], ['$compileProvider', function($compileProvider) {
|
||||
var weechat = angular.module('weechat', ['ngRoute', 'localStorage', 'weechatModels', 'bufferResume', 'plugins', 'IrcUtils', 'ngSanitize', 'ngWebsockets', 'ngTouch'], ['$compileProvider', '$locationProvider', function($compileProvider, $locationProvider) {
|
||||
// hacky way to be able to find out if we're in debug mode
|
||||
weechat.compileProvider = $compileProvider;
|
||||
|
||||
//remove hashbang from url
|
||||
$locationProvider.html5Mode(true).hashPrefix('');
|
||||
}]);
|
||||
weechat.config(['$compileProvider', function ($compileProvider) {
|
||||
// hack to determine whether we're executing the tests
|
||||
@ -19,8 +22,8 @@ weechat.config(['$compileProvider', function ($compileProvider) {
|
||||
}
|
||||
}]);
|
||||
|
||||
weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', '$log', 'models', 'bufferResume', 'connection', 'notifications', 'utils', 'settings',
|
||||
function ($rootScope, $scope, $store, $timeout, $log, models, bufferResume, connection, notifications, utils, settings)
|
||||
weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout','$location', '$log', 'models', 'bufferResume', 'connection', 'notifications', 'utils', 'settings',
|
||||
function ($rootScope, $scope, $store, $timeout, $location, $log, models, bufferResume, connection, notifications, utils, settings)
|
||||
{
|
||||
|
||||
window.openBuffer = function(channel) {
|
||||
@ -699,6 +702,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||
};
|
||||
|
||||
$scope.connect = function() {
|
||||
|
||||
notifications.requestNotificationPermission();
|
||||
$rootScope.sslError = false;
|
||||
$rootScope.securityError = false;
|
||||
@ -973,14 +977,15 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.parseHost();
|
||||
|
||||
//Fill in url parameters, they take precedence over the stored settings, but store them
|
||||
if($location.search().host) { $scope.settings.host = $location.search().host; $scope.settings.hostField = $location.search().host;}
|
||||
if($location.search().port) { $scope.settings.port = parseInt($location.search().port);}
|
||||
if($location.search().path) { $scope.settings.path = $location.search().path;}
|
||||
if($location.search().password) { $scope.settings.password = $location.search().password;}
|
||||
if($location.search().autoconnect) { $scope.settings.autoconnect = $location.search().autoconnect === 'true';}
|
||||
|
||||
if (window.location.hash) {
|
||||
var rawStr = atob(window.location.hash.substring(1));
|
||||
window.location.hash = "";
|
||||
var spl = rawStr.split(":");
|
||||
settings.host = spl[0];
|
||||
settings.port = parseInt(spl[1]);
|
||||
var password = spl[2];
|
||||
var ssl = spl.length > 3;
|
||||
notifications.requestNotificationPermission();
|
||||
$rootScope.sslError = false;
|
||||
$rootScope.securityError = false;
|
||||
@ -988,7 +993,6 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||
$rootScope.bufferBottom = true;
|
||||
$scope.connectbutton = 'Connecting';
|
||||
$scope.connectbuttonicon = 'glyphicon-chevron-right';
|
||||
$scope.parseHost();
|
||||
connection.connect(settings.host, settings.port, settings.path, password, ssl);
|
||||
}
|
||||
};
|
||||
@ -1000,6 +1004,10 @@ weechat.config(['$routeProvider',
|
||||
$routeProvider.when('/', {
|
||||
templateUrl: 'index.html',
|
||||
controller: 'WeechatCtrl'
|
||||
})
|
||||
//for legacy reasons redirect the /#! to /
|
||||
.otherwise({
|
||||
redirectTo: '/'
|
||||
});
|
||||
}
|
||||
]);
|
||||
|
Loading…
Reference in New Issue
Block a user