mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-30 17:41:54 +08:00
adjustable stream size
This commit is contained in:
@@ -71,15 +71,16 @@ var mouse = new function() {
|
||||
var __sendMove = function() {
|
||||
var pos = __current_pos;
|
||||
if (pos.x !== __sent_pos.x || pos.y !== __sent_pos.y) {
|
||||
tools.debug("Mouse move:", pos);
|
||||
el_stream_image = $("stream-image");
|
||||
var to = {
|
||||
x: __translate(pos.x, 0, el_stream_image.clientWidth, -32768, 32767),
|
||||
y: __translate(pos.y, 0, el_stream_image.clientHeight, -32768, 32767),
|
||||
};
|
||||
tools.debug("Mouse move:", to);
|
||||
if (__ws) {
|
||||
el_stream_image = $("stream-image");
|
||||
__ws.send(JSON.stringify({
|
||||
event_type: "mouse_move",
|
||||
to: {
|
||||
x: __translate(pos.x, 0, el_stream_image.clientWidth, -32768, 32767),
|
||||
y: __translate(pos.y, 0, el_stream_image.clientHeight, -32768, 32767),
|
||||
},
|
||||
to: to,
|
||||
}));
|
||||
}
|
||||
__sent_pos = pos;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
var stream = new function() {
|
||||
var __prev_state = false;
|
||||
var __normal_size = {width: 640, height: 480};
|
||||
var __size_factor = 1;
|
||||
|
||||
this.startPoller = function() {
|
||||
var http = tools.makeRequest("GET", "/streamer/?action=snapshot", function() {
|
||||
@@ -38,14 +40,24 @@ var stream = new function() {
|
||||
});
|
||||
};
|
||||
|
||||
this.resize = function(percent) {
|
||||
$("stream-size-counter").innerHTML = percent + "%";
|
||||
__size_factor = percent / 100;
|
||||
__applySizeFactor();
|
||||
};
|
||||
|
||||
var __applySizeFactor = function() {
|
||||
var el_stream_image = $("stream-image");
|
||||
el_stream_image.style.width = __normal_size.width * __size_factor + "px";
|
||||
el_stream_image.style.height = __normal_size.height * __size_factor + "px";
|
||||
};
|
||||
|
||||
var __refreshImage = function() {
|
||||
var http = tools.makeRequest("GET", "/kvmd/streamer", function() {
|
||||
if (http.readyState === 4 && http.status === 200) {
|
||||
size = JSON.parse(http.responseText).result.size;
|
||||
el_stream_image = $("stream-image");
|
||||
el_stream_image.style.width = size.width + "px";
|
||||
el_stream_image.style.height = size.height + "px";
|
||||
el_stream_image.src = "/streamer/?action=stream&time=" + new Date().getTime();
|
||||
__normal_size = JSON.parse(http.responseText).result.size;
|
||||
__applySizeFactor();
|
||||
$("stream-image").src = "/streamer/?action=stream&time=" + new Date().getTime();
|
||||
ui.showWindow("stream-window");
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user