Websever: add a page to enter serveraddress for usage in apps
This commit is contained in:
1 parent
6bcd849967
commit
35709fd5d1
4 files changed
+96
-8
No files matched your search
@@ -257,6 +257,11 @@ namespace ServerLib
|
|||||||
return CServer.GetDelayedImage(id);
|
return CServer.GetDelayedImage(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsServerOnline()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region songs
|
#region songs
|
||||||
|
|||||||
@@ -97,6 +97,12 @@ namespace ServerLib
|
|||||||
UriTemplate = "/delayedImage?id={id}")]
|
UriTemplate = "/delayedImage?id={id}")]
|
||||||
CBase64Image GetDelayedImage(String id);
|
CBase64Image GetDelayedImage(String id);
|
||||||
|
|
||||||
|
[OperationContract]
|
||||||
|
[WebInvoke(Method = "GET",
|
||||||
|
ResponseFormat = WebMessageFormat.Json,
|
||||||
|
UriTemplate = "/isServerOnline")]
|
||||||
|
bool IsServerOnline();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region songs
|
#region songs
|
||||||
|
|||||||
@@ -12,7 +12,21 @@
|
|||||||
<script src="js/i18next-1.7.1.min.js"></script>
|
<script src="js/i18next-1.7.1.min.js"></script>
|
||||||
<script src="js/main.js"></script>
|
<script src="js/main.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div id="discover" data-content-theme="a" data-role="page" data-add-back-btn="true">
|
||||||
|
<div data-role="header">
|
||||||
|
<h1 data-i18n="discoverConnectHeader"></h1>
|
||||||
|
</div>
|
||||||
|
<!-- /header -->
|
||||||
|
|
||||||
|
<div id="discoverContent" data-role="content">
|
||||||
|
<label for="discoverServerAddress" class="input" data-i18n="discoverConnectServerAddress"></label>
|
||||||
|
<input type="text" id="discoverServerAddress" name="discoverServerAddress" data-mini="true">
|
||||||
|
<a data-role="button" id="discoverConnect" data-i18n="discoverConnectButton"></a>
|
||||||
|
</div>
|
||||||
|
<!-- /content -->
|
||||||
|
</div>
|
||||||
|
<!-- /page -->
|
||||||
<div id="login" data-content-theme="a" data-role="page" data-add-back-btn="true">
|
<div id="login" data-content-theme="a" data-role="page" data-add-back-btn="true">
|
||||||
<div data-role="header">
|
<div data-role="header">
|
||||||
<h1 data-i18n="">Login</h1>
|
<h1 data-i18n="">Login</h1>
|
||||||
@@ -326,7 +340,7 @@
|
|||||||
<!-- /page -->
|
<!-- /page -->
|
||||||
|
|
||||||
<div class="ui-loader-background"></div>
|
<div class="ui-loader-background"></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@@ -6,6 +6,7 @@ var playlistIdRequest = -1;
|
|||||||
var playlistRequestName = "";
|
var playlistRequestName = "";
|
||||||
var customSelectPlaylistSongCallback = null;
|
var customSelectPlaylistSongCallback = null;
|
||||||
var sessionId = "";
|
var sessionId = "";
|
||||||
|
var serverBaseAddress = "";
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
replaceTransitionHandler();
|
replaceTransitionHandler();
|
||||||
@@ -42,6 +43,9 @@ function replaceTransitionHandler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initPageLoadHandler() {
|
function initPageLoadHandler() {
|
||||||
|
//pageLoadHandler for discover
|
||||||
|
$(document).on('pagebeforeshow', '#discover', pagebeforeshowDiscover);
|
||||||
|
|
||||||
//pageLoadHandler for displayProfile
|
//pageLoadHandler for displayProfile
|
||||||
$(document).on('pagebeforeshow', '#displayProfile', function () {
|
$(document).on('pagebeforeshow', '#displayProfile', function () {
|
||||||
if (profileIdRequest >= 0) {
|
if (profileIdRequest >= 0) {
|
||||||
@@ -677,6 +681,26 @@ function pagebeforeshowLogin() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pagebeforeshowDiscover() {
|
||||||
|
if (document.location.protocol == "file:") {
|
||||||
|
if (window.localStorage) {
|
||||||
|
var address = window.localStorage.getItem("VocaluxeServerAddress");
|
||||||
|
if (address != null) {
|
||||||
|
var prom = request({ url: address + "isServerOnline" }, "Checking...").done(function () {
|
||||||
|
serverBaseAddress = address;
|
||||||
|
window.localStorage.getItem("VocaluxeServerAddress", address);
|
||||||
|
$.mobile.changePage("#login", { transition: "none" });
|
||||||
|
});
|
||||||
|
$(this).data('promise', prom);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$.mobile.changePage("#login", { transition: "none" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function initLoginPageHandler() {
|
function initLoginPageHandler() {
|
||||||
var keyPressed = function (e) {
|
var keyPressed = function (e) {
|
||||||
if (e.which == 13) {
|
if (e.which == 13) {
|
||||||
@@ -715,7 +739,7 @@ function initLoginPageHandler() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//Fire pageLoadHandler for login
|
//Fire pageLoadHandler for login
|
||||||
pagebeforeshowLogin();
|
//pagebeforeshowLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
function initMainPageHandler() {
|
function initMainPageHandler() {
|
||||||
@@ -826,6 +850,37 @@ function initKeyboardPageHandler() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initLoginPageHandler() {
|
||||||
|
var keyPressed = function (e) {
|
||||||
|
if (e.which == 13) {
|
||||||
|
$('#discoverConnect').click();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$('#discoverServerAddress').keypress(keyPressed);
|
||||||
|
|
||||||
|
$('#discoverConnect').click(function () {
|
||||||
|
var address = $('#discoverServerAddress').prop("value");
|
||||||
|
if (address != null && address != "") {
|
||||||
|
if (address.indexOf("http") != 0) {
|
||||||
|
address = "http://" + address;
|
||||||
|
}
|
||||||
|
if (address.slice(-1) != '/') {
|
||||||
|
address = address + '/';
|
||||||
|
}
|
||||||
|
request({ url: address + "isServerOnline" }, "Checking...").done(function () {
|
||||||
|
serverBaseAddress = address;
|
||||||
|
window.localStorage.getItem("VocaluxeServerAddress", address);
|
||||||
|
$.mobile.changePage("#login", { transition: "slidefade" });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Fire pageLoadHandler for discover (first page shown after start)
|
||||||
|
pagebeforeshowDiscover();
|
||||||
|
$(this).removeData('promise');
|
||||||
|
}
|
||||||
|
|
||||||
var cachedImages = {};
|
var cachedImages = {};
|
||||||
|
|
||||||
function delayedImageLoad(elem, id, fail) {
|
function delayedImageLoad(elem, id, fail) {
|
||||||
@@ -880,7 +935,7 @@ function logout() {
|
|||||||
function checkSession() {
|
function checkSession() {
|
||||||
if (ownProfileId == -1
|
if (ownProfileId == -1
|
||||||
&& profileIdRequest == -1
|
&& profileIdRequest == -1
|
||||||
&& ($.mobile.activePage.attr("id") == "displayProfile" || $.mobile.activePage.attr("id") == "login")) {
|
&& ($.mobile.activePage.attr("id") == "displayProfile" || $.mobile.activePage.attr("id") == "login" || $.mobile.activePage.attr("id") == "discover")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
request({
|
request({
|
||||||
@@ -925,6 +980,7 @@ function request(data, message) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
data["headers"]["session"] = sessionId;
|
data["headers"]["session"] = sessionId;
|
||||||
|
data.url = serverBaseAddress + data.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $.ajax(data).always(function (result) {
|
return $.ajax(data).always(function (result) {
|
||||||
@@ -1142,7 +1198,11 @@ function initTranslation() {
|
|||||||
'This is not a valid name.': 'This is not a valid name.',
|
'This is not a valid name.': 'This is not a valid name.',
|
||||||
'Uploading profile...': 'Uploading profile...',
|
'Uploading profile...': 'Uploading profile...',
|
||||||
'songs': 'songs',
|
'songs': 'songs',
|
||||||
'YourName': 'YourName'
|
'YourName': 'YourName',
|
||||||
|
'discoverConnectHeader': 'Connect to server',
|
||||||
|
'discoverConnectServerAddress': 'Serveraddress:',
|
||||||
|
'discoverConnectButton': 'Connect',
|
||||||
|
'Checking...': 'Checking...'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"de": {
|
"de": {
|
||||||
@@ -1217,15 +1277,18 @@ function initTranslation() {
|
|||||||
'This is not a valid name.': 'Dies ist kein gültiger Name.',
|
'This is not a valid name.': 'Dies ist kein gültiger Name.',
|
||||||
'Uploading profile...': 'Profil hochladen...',
|
'Uploading profile...': 'Profil hochladen...',
|
||||||
'songs': 'Lieder',
|
'songs': 'Lieder',
|
||||||
'YourName': 'DeinName'
|
'YourName': 'DeinName',
|
||||||
|
'discoverConnectHeader': 'Verbinde zum Server',
|
||||||
|
'discoverConnectServerAddress': 'Serveradresse:',
|
||||||
|
'discoverConnectButton': 'Verbinden',
|
||||||
|
'Checking...': 'Prüfen...'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$.i18n.init({
|
$.i18n.init({
|
||||||
resStore: translations,
|
resStore: translations,
|
||||||
lng: "de",
|
lng: "de",
|
||||||
fallbackLng: 'en',
|
fallbackLng: 'en'
|
||||||
debug: true
|
|
||||||
}).done(function () {
|
}).done(function () {
|
||||||
$('body').i18n();
|
$('body').i18n();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user