refactored window location with angular

This commit is contained in:
hamza zia 2013-03-20 10:08:50 +01:00
parent d272f1d086
commit 02a7a595a0

View File

@ -5,8 +5,8 @@ angular
]) ])
.factory('$rpc', [ .factory('$rpc', [
'$syscall', '$globalTimeout', '$alerts', '$utils', '$syscall', '$globalTimeout', '$alerts', '$utils',
'$rootScope', '$rootScope', '$location',
function(syscall, time, alerts, utils, rootScope) { function(syscall, time, alerts, utils, rootScope, uri) {
var subscriptions = [] var subscriptions = []
, configurations = [{ host: 'localhost', port: 6800, encrypt: false }] , configurations = [{ host: 'localhost', port: 6800, encrypt: false }]
@ -14,13 +14,15 @@ function(syscall, time, alerts, utils, rootScope) {
, timeout = null , timeout = null
, forceNextUpdate = false; , forceNextUpdate = false;
if (window.location.protocol === "http:") { if (['http', 'https'].indexOf(uri.protocol()) != -1) {
configurations.unshift({ console.log(uri.host());
host: window.location.hostname, configurations.unshift({
host: uri.host(),
port: 6800, port: 6800,
encrypt: false encrypt: false
}); });
} console.log(configurations);
}
var cookieConf = utils.getCookie('aria2conf'); var cookieConf = utils.getCookie('aria2conf');
if (cookieConf) configurations.unshift(cookieConf); if (cookieConf) configurations.unshift(cookieConf);