vn-support/client/main.js

135 lines
2.6 KiB
JavaScript

var Conf =
{
host: 'support.verdnatura.es',
path: 'HKCU\\Software\\TightVNC\\Server',
checkKey: 'ExtraPorts',
params:
{
'UseMirrorDriver' : true,
'BlockRemoteInput' : false,
'EnableFileTransfers' : true,
'RemoveWallpaper' : true,
'PollingInterval' : 500,
'GrabTransparentWindows' : true,
'LoopbackOnly' : false
},
optParams:
{
'ExtraPorts' : '',
'QueryAcceptOnTimeout' : false,
'BlockLocalInput' : false,
'AcceptRfbConnections' : false,
'UseVncAuthentication' : true,
'AcceptHttpConnections' : false,
'EnableUrlParams' : true,
'AlwaysShared' : false,
'NeverShared' : false,
'DisconnectClients' : true,
'AllowLoopback' : false
}
};
var Support =
{
shell: new ActiveXObject ('WScript.Shell'),
init: function ()
{
var width = 420;
var height = 185;
window.resizeTo (width, height);
window.moveTo ((screen.width - width) / 2, (screen.height - height) / 2);
this.regWrites (Conf.path, Conf.params);
if (this.regRead (Conf.path, Conf.checkKey) === null)
this.regWrites (Conf.path, Conf.optParams);
this.run ('tvnserver.exe -run');
},
regRead: function (path, key)
{
try {
var value = this.shell.regRead (path +'\\'+ key);
}
catch (e) {
var value = null;
}
return value;
},
regWrites: function (path, params)
{
for (var key in params)
{
var type;
var value = params[key];
switch (typeof (value))
{
case 'boolean':
type = 'REG_DWORD';
value = value ? 1 : 0;
break;
case 'number':
type = 'REG_DWORD';
break;
default:
type = 'REG_SZ';
}
this.shell.regWrite (path +'\\'+ key, value.toString (), type);
}
},
$: function (id)
{
return document.getElementById (id);
},
run: function (command, wait)
{
if (!wait)
wait = false;
this.shell.run (command, 0, wait);
},
_onLoad: function ()
{
var select = this.$('operator');
for (var i = 1; i <= 10; i++)
{
var option = document.createElement ('option');
option.value = i;
option.appendChild (document.createTextNode (i));
select.appendChild (option);
}
},
_onStartClick: function ()
{
var port = 5500 + parseInt (this.$('operator').value);
this.run ('tvnserver.exe -controlapp -connect '+ Conf.host +'::'+ port);
},
_onCloseClick: function ()
{
window.close ();
},
_onUnload: function ()
{
this.run ('tvnserver.exe -controlapp -disconnectall', true);
this.run ('tvnserver.exe -controlapp -shutdown');
}
};
Support.init ();