Merge pull request #1096 from AStove/FixAtob
Fix atob error, add url params
This commit is contained in:
commit
f3e97e3ec2
28
index.html
28
index.html
@ -144,7 +144,7 @@
|
||||
Encryption. <strong>Strongly recommended!</strong> Need help? Check below.
|
||||
</label>
|
||||
</div>
|
||||
<div class="checkbox" ng-show="settings.savepassword">
|
||||
<div class="checkbox" ng-show="settings.savepassword || settings.autoconnect">
|
||||
<label class="control-label" for="autoconnect">
|
||||
<input type="checkbox" id="autoconnect" ng-model="settings.autoconnect" ng-disabled="settings.useTotp">
|
||||
Automatically connect
|
||||
@ -230,7 +230,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 +266,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 way as it will be visible in plain text and stored in history/bookmarks 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>
|
||||
|
@ -19,8 +19,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) {
|
||||
@ -698,7 +698,36 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||
$scope.totpInvalid = !/^\d{4,10}$/.test($scope.totp);
|
||||
};
|
||||
|
||||
$scope.parseHash = function() {
|
||||
|
||||
//Fill in url parameters, they take precedence over the stored settings, but store them
|
||||
var params = {};
|
||||
$location.$$hash.split('&').map(function(val) {
|
||||
var segs = val.split('=');
|
||||
params[segs[0]] = segs[1];
|
||||
});
|
||||
if (params.host) {
|
||||
$scope.settings.host = params.host;
|
||||
$scope.settings.hostField = params.host;
|
||||
}
|
||||
if (params.port) {
|
||||
$scope.settings.port = parseInt(params.port);
|
||||
}
|
||||
if (params.path) {
|
||||
$scope.settings.path = params.path;
|
||||
$scope.settings.hostField = $scope.settings.host + ":" + $scope.settings.port + "/" + $scope.settings.path;
|
||||
}
|
||||
if (params.password) {
|
||||
$scope.password = params.password;
|
||||
}
|
||||
if (params.autoconnect) {
|
||||
$scope.settings.autoconnect = params.autoconnect === 'true';
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$scope.connect = function() {
|
||||
|
||||
notifications.requestNotificationPermission();
|
||||
$rootScope.sslError = false;
|
||||
$rootScope.securityError = false;
|
||||
@ -971,36 +1000,29 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||
}
|
||||
};
|
||||
|
||||
window.onhashchange = function() {
|
||||
$scope.parseHash();
|
||||
};
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.parseHost();
|
||||
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;
|
||||
$rootScope.errorMessage = false;
|
||||
$rootScope.bufferBottom = true;
|
||||
$scope.connectbutton = 'Connecting';
|
||||
$scope.connectbuttonicon = 'glyphicon-chevron-right';
|
||||
$scope.parseHost();
|
||||
connection.connect(settings.host, settings.port, settings.path, password, ssl);
|
||||
}
|
||||
$scope.parseHash();
|
||||
};
|
||||
|
||||
}]);
|
||||
|
||||
weechat.config(['$routeProvider',
|
||||
function($routeProvider) {
|
||||
$routeProvider.when('/', {
|
||||
weechat.config(['$routeProvider', '$locationProvider',
|
||||
function($routeProvider, $locationProvider) {
|
||||
$routeProvider.when('', {
|
||||
templateUrl: 'index.html',
|
||||
controller: 'WeechatCtrl'
|
||||
});
|
||||
|
||||
//remove hashbang from url
|
||||
$locationProvider.html5Mode({
|
||||
enabled: true,
|
||||
requireBase: false
|
||||
});
|
||||
}
|
||||
]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user