Merge pull request #110 from lukeIam/develop
New features for the remote keyboard and some JS fixes
This commit is contained in:
commit
5f037e6cf3
9 files changed
+204
-67
No files matched your search
@@ -33,6 +33,7 @@ namespace ServerLib
|
||||
private bool _Encrypted;
|
||||
|
||||
public static SendKeyEventDelegate SendKeyEvent { internal get; set; }
|
||||
public static SendKeyStringEventDelegate SendKeyStringEvent { internal get; set; }
|
||||
|
||||
#region profile
|
||||
public static GetProfileDataDelegate GetProfileData { internal get; set; }
|
||||
|
||||
@@ -58,6 +58,23 @@ namespace ServerLib
|
||||
CServer.SendKeyEvent(key);
|
||||
}
|
||||
|
||||
public void SendKeyStringEvent(string keyString, bool isShiftPressed = false, bool isAltPressed = false, bool isCtrlPressed = false)
|
||||
{
|
||||
if (!_CheckRight(EUserRights.UseKeyboard))
|
||||
return;
|
||||
|
||||
if (CServer.SendKeyStringEvent == null)
|
||||
{
|
||||
if (WebOperationContext.Current != null)
|
||||
{
|
||||
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotFound;
|
||||
WebOperationContext.Current.OutgoingResponse.StatusDescription = "Not found";
|
||||
}
|
||||
}
|
||||
else
|
||||
CServer.SendKeyStringEvent(keyString, isShiftPressed, isAltPressed, isCtrlPressed);
|
||||
}
|
||||
|
||||
#region profile
|
||||
public int GetOwnProfileId()
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@ using System.Text.RegularExpressions;
|
||||
namespace ServerLib
|
||||
{
|
||||
public delegate bool SendKeyEventDelegate(string key);
|
||||
public delegate bool SendKeyStringEventDelegate(string keyString, bool isShiftPressed , bool isAltPressed , bool isCtrlPressed);
|
||||
|
||||
#region profile
|
||||
public delegate SProfileData GetProfileDataDelegate(int profileId, bool isReadonly);
|
||||
|
||||
@@ -30,6 +30,11 @@ namespace ServerLib
|
||||
UriTemplate = "/sendKeyEvent?key={key}")]
|
||||
void SendKeyEvent(string key);
|
||||
|
||||
[OperationContract, WebInvoke(Method = "GET",
|
||||
ResponseFormat = WebMessageFormat.Json,
|
||||
UriTemplate = "/sendKeyStringEvent?keyString={keyString}&shift={isShiftPressed}&alt={isAltPressed}&ctrl={isCtrlPressed}")]
|
||||
void SendKeyStringEvent(string keyString, bool isShiftPressed = false, bool isAltPressed = false, bool isCtrlPressed = false);
|
||||
|
||||
#region profile
|
||||
[OperationContract, WebInvoke(Method = "GET",
|
||||
ResponseFormat = WebMessageFormat.Json,
|
||||
|
||||
@@ -64,6 +64,7 @@ namespace Vocaluxe.Base.Server
|
||||
_Server = new CServer(CConfig.ServerPort, CConfig.ServerEncryption == EOffOn.TR_CONFIG_ON);
|
||||
|
||||
CServer.SendKeyEvent = _SendKeyEvent;
|
||||
CServer.SendKeyStringEvent = _sendKeyStringEvent;
|
||||
CServer.GetProfileData = _GetProfileData;
|
||||
CServer.SendProfileData = _SendProfileData;
|
||||
CServer.GetProfileList = _GetProfileList;
|
||||
@@ -125,9 +126,11 @@ namespace Vocaluxe.Base.Server
|
||||
private static bool _SendKeyEvent(string key)
|
||||
{
|
||||
bool result = false;
|
||||
if (!string.IsNullOrEmpty(key))
|
||||
var lowerKey = key.ToLower();
|
||||
|
||||
if (!string.IsNullOrEmpty(lowerKey))
|
||||
{
|
||||
switch (key.ToLower())
|
||||
switch (lowerKey)
|
||||
{
|
||||
case "up":
|
||||
Controller.AddKeyEvent(new SKeyEvent(ESender.Keyboard, false, false, false, false, Char.MinValue, Keys.Up));
|
||||
@@ -157,25 +160,22 @@ namespace Vocaluxe.Base.Server
|
||||
Controller.AddKeyEvent(new SKeyEvent(ESender.Keyboard, false, false, false, false, Char.MinValue, Keys.Tab));
|
||||
result = true;
|
||||
break;
|
||||
case "backspace":
|
||||
Controller.AddKeyEvent(new SKeyEvent(ESender.Keyboard, false, false, false, false, Char.MinValue, Keys.Back));
|
||||
result = true;
|
||||
break;
|
||||
default:
|
||||
foreach (char c in key)
|
||||
if (lowerKey.StartsWith("f"))
|
||||
{
|
||||
bool shift = true;
|
||||
char keyChar;
|
||||
if (char.ToUpper(c) != c)
|
||||
{
|
||||
keyChar = char.ToUpper(c);
|
||||
shift = false;
|
||||
}
|
||||
else
|
||||
keyChar = c;
|
||||
var numberString = lowerKey.Substring(1);
|
||||
int number;
|
||||
Keys fKey;
|
||||
|
||||
if ((keyChar >= '0' && keyChar <= '9') || (keyChar >= 'A' && keyChar <= 'Z'))
|
||||
if (Int32.TryParse(numberString, out number) && number >= 1
|
||||
&& number <= 12
|
||||
&& Enum.TryParse("F" + number, true, out fKey))
|
||||
{
|
||||
Keys keys = (Keys)keyChar;
|
||||
if (shift)
|
||||
keys |= Keys.Shift;
|
||||
Controller.AddKeyEvent(new SKeyEvent(ESender.Keyboard, false, false, false, false, Char.MinValue, keys));
|
||||
Controller.AddKeyEvent(new SKeyEvent(ESender.Keyboard, false, false, false, false, Char.MinValue, fKey));
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
@@ -186,6 +186,43 @@ namespace Vocaluxe.Base.Server
|
||||
return result;
|
||||
}
|
||||
|
||||
private static bool _sendKeyStringEvent(string keyString, bool isShiftPressed , bool isAltPressed , bool isCtrlPressed )
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
foreach (var key in keyString.ToCharArray())
|
||||
{
|
||||
Controller.AddKeyEvent(new SKeyEvent(ESender.Keyboard, isAltPressed,
|
||||
Char.IsUpper(key) || isShiftPressed,
|
||||
isCtrlPressed, true,
|
||||
isShiftPressed?Char.ToUpper(key) :key,
|
||||
_ParseKeys(key)));
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Keys _ParseKeys(char keyText)
|
||||
{
|
||||
Keys key;
|
||||
|
||||
if (!Enum.TryParse(keyText.ToString(), true, out key))
|
||||
{
|
||||
switch (keyText)
|
||||
{
|
||||
case ' ':
|
||||
key = Keys.Space;
|
||||
break;
|
||||
default:
|
||||
key = Keys.None;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
#region profile
|
||||
private static SProfileData _GetProfileData(int profileId, bool isReadonly)
|
||||
{
|
||||
|
||||
@@ -297,14 +297,36 @@
|
||||
<div class="ui-block-c">
|
||||
<a data-role="button" id="keyboardButtonReturn" data-i18n="keyboardButtonReturn"></a>
|
||||
</div>
|
||||
<div class="ui-block-a">
|
||||
<!--
|
||||
<fieldset data-role="controlgroup" data-type="horizontal">
|
||||
<input type="checkbox" name="keyboardButtonFunct" id="keyboardButtonFunct" />
|
||||
<label data-i18n="keyboardButtonFunct" for="keyboardButtonFunct"></label>
|
||||
</fieldset>-->
|
||||
</div>
|
||||
<div class="ui-block-b">
|
||||
<fieldset data-role="controlgroup" data-type="horizontal">
|
||||
<input type="checkbox" name="keyboardButtonShift" id="keyboardButtonShift" />
|
||||
<label data-i18n="keyboardButtonShift" for="keyboardButtonShift"></label>
|
||||
<input type="checkbox" name="keyboardButtonAlt" id="keyboardButtonAlt" />
|
||||
<label data-i18n="keyboardButtonAlt" for="keyboardButtonAlt"></label>
|
||||
<input type="checkbox" name="keyboardButtonCtrl" id="keyboardButtonCtrl" />
|
||||
<label data-i18n="keyboardButtonCtrl" for="keyboardButtonCtrl"></label>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="ui-block-c">
|
||||
<a data-role="button" id="keyboardButtonP">P</a>
|
||||
<a data-role="button" id="keyboardButtonBackspace" data-i18n="keyboardButtonBackspace"></a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div style>
|
||||
<div>
|
||||
<fieldset data-role="controlgroup" data-type="horizontal">
|
||||
<input type="checkbox" name="keyboardAutoSend" id="keyboardAutoSend" />
|
||||
<label data-i18n="keyboardAutoSend" for="keyboardAutoSend"></label>
|
||||
</fieldset>
|
||||
<label for="keyboardButtonKeys" data-i18n="keyboardButtonKeys"></label>
|
||||
<input type="text" id="keyboardButtonKeys" data-mini="true">
|
||||
</div> -->
|
||||
<a data-role="button" id="keyboardButtonSend" data-i18n="keyboardButtonSend"></a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /content -->
|
||||
</div>
|
||||
|
||||
+87
-45
@@ -26,11 +26,11 @@
|
||||
function preStart() {
|
||||
translator.translationLoaded.done(function () {
|
||||
translator.translate();
|
||||
|
||||
|
||||
sessionHandler = new SessionHandler();
|
||||
imageLoader = new ImageLoader();
|
||||
externalServices = new ExternalServices();
|
||||
pageHandler = new PageHandler();
|
||||
pageHandler = new PageHandler();
|
||||
|
||||
pageHandler.init();
|
||||
});
|
||||
@@ -154,7 +154,7 @@
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function ExternalServices() {
|
||||
var popupVideoHeight = 390;
|
||||
var popupVideoWidth = 640;
|
||||
@@ -190,7 +190,7 @@
|
||||
'height': h - (ifrPadding + ifrBorder)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
$("#popupVideo").find("a").click(function () {
|
||||
$("#popupVideo").popup("close");
|
||||
$("#popupVideo").popup("close"); //Sometimes twice??
|
||||
@@ -300,6 +300,8 @@
|
||||
var songPageHandler;
|
||||
var playlistPageHandler;
|
||||
|
||||
var t = this;
|
||||
|
||||
this.customSelectPlaylistSongCallback = null;
|
||||
this.profileIdRequest = -1;
|
||||
this.songIdRequest = -1;
|
||||
@@ -316,9 +318,9 @@
|
||||
};
|
||||
|
||||
this.reset = function () {
|
||||
this.customSelectPlaylistSongCallback = null;
|
||||
this.profileIdRequest = -1;
|
||||
this.songIdRequest = -1;
|
||||
t.customSelectPlaylistSongCallback = null;
|
||||
t.profileIdRequest = -1;
|
||||
t.songIdRequest = -1;
|
||||
};
|
||||
|
||||
var replaceTransitionHandler = function () {
|
||||
@@ -639,7 +641,6 @@
|
||||
|
||||
var KeyboardPageHandler = function () {
|
||||
var init = function () {
|
||||
|
||||
initKeyboardPageHandler();
|
||||
};
|
||||
|
||||
@@ -686,25 +687,64 @@
|
||||
});
|
||||
});
|
||||
|
||||
$('#keyboardButtonP').click(function () {
|
||||
$('#keyboardButtonBackspace').click(function () {
|
||||
request({
|
||||
url: "sendKeyEvent?key=p"
|
||||
url: "sendKeyEvent?key=backspace"
|
||||
});
|
||||
});
|
||||
|
||||
$('#keyboardButtonKeys').keyup(function (e) {
|
||||
var c = String.fromCharCode(e.keyCode);
|
||||
if (c.match(/\w/)) {
|
||||
c = e.keyCode >= 65 ? c.toLowerCase() : c;
|
||||
request({
|
||||
url: "sendKeyEvent?key=" + c
|
||||
});
|
||||
}
|
||||
var oldText = $('#keyboardButtonKeys')[0].value;
|
||||
if (oldText.length > 0) {
|
||||
$('#keyboardButtonKeys')[0].value = oldText.slice(1);
|
||||
$("#keyboardAutoSend").change(function () {
|
||||
if ($('#keyboardAutoSend').is(':checked')) {
|
||||
$('#keyboardButtonSend').hide();
|
||||
} else {
|
||||
$('#keyboardButtonSend').show();
|
||||
}
|
||||
});
|
||||
|
||||
$('#keyboardButtonSend').click(function () {
|
||||
sendKeyboardText();
|
||||
});
|
||||
|
||||
$('#keyboardButtonKeys').keyup(function (e) {
|
||||
if (!$('#keyboardAutoSend').is(':checked') && e.keyCode != 13) {
|
||||
return;
|
||||
}
|
||||
sendKeyboardText();
|
||||
});
|
||||
|
||||
function sendKeyboardText() {
|
||||
var text = $('#keyboardButtonKeys')[0].value;
|
||||
|
||||
if (text.length <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('#keyboardButtonKeys')[0].value = "";
|
||||
$('#keyboardButtonKeys').first().focus();
|
||||
|
||||
/* if ($('#keyboardButtonFunct').is(':checked')) {
|
||||
$('#keyboardButtonKeys')[0].value = text.splice(1) + $('#keyboardButtonKeys')[0].value;
|
||||
var numericElements = /^[0-9][0-9]?/.exec(text.charAt(0));
|
||||
if (parseInt(numericElements)) {
|
||||
request({
|
||||
url: "sendKeyEvent?key=F" + numericElements
|
||||
});
|
||||
}
|
||||
$("#keyboardButtonFunct").attr("checked", false).checkboxradio("refresh");
|
||||
}*/
|
||||
|
||||
request({
|
||||
contentType: "application/json;charset=utf-8",
|
||||
type: "GET",
|
||||
url: "sendKeyStringEvent?keyString=" + text
|
||||
+ "&shift=" + $('#keyboardButtonShift').is(':checked')
|
||||
+ "&alt=" + $('#keyboardButtonAlt').is(':checked')
|
||||
+ "&ctrl=" + $('#keyboardButtonCtrl').is(':checked')
|
||||
|
||||
}).fail(function () {
|
||||
$('#keyboardButtonKeys')[0].value = text + $('#keyboardButtonKeys')[0].value;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
init();
|
||||
@@ -812,7 +852,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
var handleDisplayProfileData = function(data) {
|
||||
var handleDisplayProfileData = function (data) {
|
||||
$('#playerName').prop("value", data.PlayerName);
|
||||
|
||||
imageLoader.addImage($('#playerAvatar')[0], data.Avatar, "img/profile.png");
|
||||
@@ -829,19 +869,19 @@
|
||||
$('#playerPassword').prop('disabled', false).prop("value", "***__oldPassword__***").parent().show();
|
||||
$('#playerPasswordLabel').show();
|
||||
|
||||
$('#playerAvatar').click(function() {
|
||||
$('#playerAvatar').click(function () {
|
||||
if ($('#captureContainer').length > 0) {
|
||||
$('#captureContainer').remove();
|
||||
}
|
||||
|
||||
if (document.location.protocol == "file:"
|
||||
&& typeof(navigator) != 'undefined'
|
||||
&& typeof(navigator.camera) != 'undefined'
|
||||
&& typeof(navigator.camera.getPicture) != 'undefined') {
|
||||
navigator.camera.getPicture(function(imageData) {
|
||||
&& typeof (navigator) != 'undefined'
|
||||
&& typeof (navigator.camera) != 'undefined'
|
||||
&& typeof (navigator.camera.getPicture) != 'undefined') {
|
||||
navigator.camera.getPicture(function (imageData) {
|
||||
$('#playerAvatar').prop("src", "data:image/jpeg;base64," + imageData);
|
||||
$('#playerAvatar').data("changed", true);
|
||||
}, function() {
|
||||
}, function () {
|
||||
//Fail - do nothing
|
||||
}, {
|
||||
destinationType: navigator.camera.DestinationType.DATA_URL,
|
||||
@@ -854,11 +894,11 @@
|
||||
} else {
|
||||
$(document.body).append('<div id="captureContainer" style="height: 0px;width:0px; overflow:hidden;"> <input type="file" accept="image/*" id="capture" capture> </div>');
|
||||
|
||||
$('#capture').change(function(eventData) {
|
||||
$('#capture').change(function (eventData) {
|
||||
if (eventData && eventData.target && eventData.target.files && eventData.target.files.length == 1) {
|
||||
var file = eventData.target.files[0];
|
||||
var reader = new FileReader();
|
||||
reader.onloadend = function(e) {
|
||||
reader.onloadend = function (e) {
|
||||
$('#playerAvatar').prop("src", e.target.result);
|
||||
$('#playerAvatar').data("changed", true);
|
||||
$('#captureContainer').remove();
|
||||
@@ -1358,27 +1398,29 @@
|
||||
this.sessionId = "";
|
||||
this.serverBaseAddress = "";
|
||||
|
||||
var init = function() {
|
||||
var t = this;
|
||||
|
||||
var init = function () {
|
||||
initHeartbeat();
|
||||
};
|
||||
|
||||
this.logout = function () {
|
||||
this.ownProfileId = -1;
|
||||
|
||||
this.sessionId = "";
|
||||
|
||||
pageHandler.reset();
|
||||
t.ownProfileId = -1;
|
||||
|
||||
t.sessionId = "";
|
||||
|
||||
pageHandler.reset();
|
||||
|
||||
if (window.localStorage) {
|
||||
window.localStorage.setItem("VocaluxeSessionKey", "");
|
||||
}
|
||||
$.mobile.changePage("#login", { transition: "slidefade" });
|
||||
};
|
||||
|
||||
|
||||
var checkSession = function() {
|
||||
if (ownProfileId == -1
|
||||
&& profileIdRequest == -1
|
||||
|
||||
|
||||
var checkSession = function () {
|
||||
if (t.ownProfileId == -1
|
||||
&& pageHandler.profileIdRequest == -1
|
||||
&& ($.mobile.activePage.attr("id") == "displayProfile" || $.mobile.activePage.attr("id") == "login" || $.mobile.activePage.attr("id") == "discover")) {
|
||||
return;
|
||||
}
|
||||
@@ -1386,17 +1428,17 @@
|
||||
url: "getOwnProfileId"
|
||||
}, "noOverlay").done(function (result) {
|
||||
if (result == -1) {
|
||||
this.logout();
|
||||
t.logout();
|
||||
}
|
||||
}).fail(function (result) {
|
||||
this.logout();
|
||||
t.logout();
|
||||
});
|
||||
};
|
||||
|
||||
var initHeartbeat = function() {
|
||||
var initHeartbeat = function () {
|
||||
setInterval(checkSession, 20000);
|
||||
};
|
||||
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
@@ -76,5 +76,11 @@
|
||||
"discoverConnectServerAddress": "Serveradresse:",
|
||||
"discoverConnectButton": "Verbinden",
|
||||
"Checking...": "Prüfen...",
|
||||
"timeout": "Zeitüberschreitung"
|
||||
"timeout": "Zeitüberschreitung",
|
||||
"keyboardButtonShift": "Umschalt",
|
||||
"keyboardButtonAlt": "Alt",
|
||||
"keyboardButtonCtrl": "Steuerung",
|
||||
"keyboardButtonBackspace": "Rücktaste",
|
||||
"keyboardAutoSend": "Tasten autom. senden",
|
||||
"keyboardButtonSend": "Senden"
|
||||
}
|
||||
@@ -76,5 +76,11 @@
|
||||
"discoverConnectServerAddress": "Serveraddress:",
|
||||
"discoverConnectButton": "Connect",
|
||||
"Checking...": "Checking...",
|
||||
"timeout": "Timeout"
|
||||
"timeout": "Timeout",
|
||||
"keyboardButtonShift": "Shift",
|
||||
"keyboardButtonAlt": "Alt",
|
||||
"keyboardButtonCtrl": "Control",
|
||||
"keyboardButtonBackspace": "Backspace",
|
||||
"keyboardAutoSend": "Auto send keys",
|
||||
"keyboardButtonSend": "Send"
|
||||
}
|
||||
Reference in new issue
Block a user