This repository has been archived by the owner on Jul 6, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Microrefactoring + added refreshing by socket
- Loading branch information
1 parent
6c6b193
commit 2f90de7
Showing
4 changed files
with
153 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,61 @@ | ||
$(document).ready(function() { | ||
var background, connectButton, disconnectButton, hostField, portField; | ||
background = opera.extension.bgProcess.background; | ||
hostField = $('form#socketform #host'); | ||
portField = $('form#socketform #port'); | ||
connectButton = $('form#socketform #connect'); | ||
disconnectButton = $('form#socketform #disconnect'); | ||
|
||
connectButton.on("click", function(e) { | ||
e.preventDefault(); | ||
if ($(e.target).hasClass("disabled")) { | ||
return; | ||
} | ||
background.connect(hostField.val(), portField.val()); | ||
|
||
return window.close(); | ||
}); | ||
|
||
disconnectButton.on("click", function(e) { | ||
e.preventDefault(); | ||
if ($(e.target).hasClass("disabled")) { | ||
return; | ||
} | ||
background.disconnect(); | ||
return window.close(); | ||
}); | ||
}); | ||
var source; | ||
var self = this; | ||
|
||
var hostField = $('form#socketform #host'); | ||
var portField = $('form#socketform #port'); | ||
var connectButton = $('form#socketform #connect'); | ||
var disconnectButton = $('form#socketform #disconnect'); | ||
|
||
var update = function( status, host, port ) | ||
{ | ||
if ( status == true ) | ||
{ | ||
connectButton.addClass('disabled'); | ||
disconnectButton.removeClass('disabled'); | ||
} | ||
else | ||
{ | ||
connectButton.removeClass('disabled'); | ||
disconnectButton.addClass('disabled'); | ||
} | ||
|
||
hostField.attr( 'placeholder', host ); | ||
portField.attr( 'placeholder', port ); | ||
} | ||
|
||
opera.extension.onmessage = function(event) | ||
{ | ||
source = event.source; | ||
|
||
update( event.data.status, event.data.host, event.data.port ); | ||
} | ||
|
||
connectButton.on("click", | ||
function(e) | ||
{ | ||
e.preventDefault(); | ||
if ($(e.target).hasClass("disabled")) { return; } | ||
|
||
source.postMessage( { | ||
'action': 'connect' | ||
, 'host': hostField.val() | ||
, 'port': portField.val() | ||
} ); | ||
|
||
return window.close(); | ||
}); | ||
|
||
disconnectButton.on("click", | ||
function(e) | ||
{ | ||
e.preventDefault(); | ||
if ($(e.target).hasClass("disabled")) { return; } | ||
|
||
source.postMessage( { | ||
'action': 'disconnect' | ||
} ); | ||
|
||
return window.close(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters