Skip to content
Browse files

Fix bugs, add few comments, move sources into src

  • Loading branch information...
1 parent 2f90de7 commit 839744a212ecd681ec5bab8053c1c30a36f8b10f @dummer dummer committed
View
137 README.md
@@ -1,69 +1,70 @@
-# LiveRefresh - SublimeText2 Plugin
-
-Your SublimeText2 will include a websocket-server which sends a signal to all clients when you save a file.
-This repository includes the browser- extensions/plugins too.
-
-### Supported Browsers
-
-* Google Chrome
-
-## Installation
-
-You have three ways to install LiveRefresh: using git, installing it manually or using the SublimeText2 "Package Controll" (Available here: http://wbond.net/sublime_packages/package_control)
-
-### Install using git
-
-To install this Plugin via git, simply browse to your 'Packages' folder like this:
-
-for Windows
-
- cd %APPDATA%/Sublime Text 2/Packages
-
-for OS X
-
- cd ~/Library/Application Support/Sublime Text 2/Packages
-
-for Linux
-
- cd ~/.Sublime Text 2/Packages
-
-for Portable Installations
-
- cd PATH_TO_PORTABLE_INSTALLATION/Sublime Text 2/Data/Packages
-
-and clone this repository
-
- git clone https://github.com/PhilippSchaffrath/LiveRefresh
-
-
-### Install manually
-
-* Download the files using the GitHub .zip download option
-* Unzip the files and rename the folder to 'LiveRefresh'
-* Copy the folder to your Sublime Text 2 'Packages' directory
-
-### Install using Package Control (NOT AVAILABLE AT THIS MOMENT)
-
-If you are familiar with Package Control you definetly know what to do, if not, go to [SublimeText2 - Package Control](http://wbond.net/sublime_packages/package_control) click on 'Install' and follow the instructions
-
-## How it works
-
-The WebsocketServer running in SublimeText listens at port 1025. If you save a File, it will send "refresh" to all connected clients.
-
-The included Chrome Extension allows you to connect to your SublimeText2. Simply insert host and port (defaults to 127.0.0.1:1025 if empty) and click "Connect", ready to go, your browser will now refresh and focus this tab when you save a File in SublimeText2.
-
-
-## Usage
-
-* Install the SublimeText2 Plugin and restart the Application
-* Install the Browser Plugin/Extension and restart the Browser
-* Open both and start the Browser Plugin
-* Connect the Browser to your IP and let it refresh :)
-
-## Release Notes
-
-LiveRefresh is designed to work with the latest [development build](http://www.sublimetext.com/dev) of Sublime Text 2
-
-## Development
-
+# LiveRefresh - SublimeText2 Plugin
+
+Your SublimeText2 will include a websocket-server which sends a signal to all clients when you save a file.
+This repository includes the browser- extensions/plugins too.
+
+### Supported Browsers
+
+* Google Chrome
+* Opera
+
+## Installation
+
+You have three ways to install LiveRefresh: using git, installing it manually or using the SublimeText2 "Package Controll" (Available here: http://wbond.net/sublime_packages/package_control)
+
+### Install using git
+
+To install this Plugin via git, simply browse to your 'Packages' folder like this:
+
+for Windows
+
+ cd %APPDATA%/Sublime Text 2/Packages
+
+for OS X
+
+ cd ~/Library/Application Support/Sublime Text 2/Packages
+
+for Linux
+
+ cd ~/.Sublime Text 2/Packages
+
+for Portable Installations
+
+ cd PATH_TO_PORTABLE_INSTALLATION/Sublime Text 2/Data/Packages
+
+and clone this repository
+
+ git clone https://github.com/PhilippSchaffrath/LiveRefresh
+
+
+### Install manually
+
+* Download the files using the GitHub .zip download option
+* Unzip the files and rename the folder to 'LiveRefresh'
+* Copy the folder to your Sublime Text 2 'Packages' directory
+
+### Install using Package Control (NOT AVAILABLE AT THIS MOMENT)
+
+If you are familiar with Package Control you definetly know what to do, if not, go to [SublimeText2 - Package Control](http://wbond.net/sublime_packages/package_control) click on 'Install' and follow the instructions
+
+## How it works
+
+The WebsocketServer running in SublimeText listens at port 1025. If you save a File, it will send "refresh" to all connected clients.
+
+The included Chrome Extension allows you to connect to your SublimeText2. Simply insert host and port (defaults to 127.0.0.1:1025 if empty) and click "Connect", ready to go, your browser will now refresh and focus this tab when you save a File in SublimeText2.
+
+
+## Usage
+
+* Install the SublimeText2 Plugin and restart the Application
+* Install the Browser Plugin/Extension and restart the Browser
+* Open both and start the Browser Plugin
+* Connect the Browser to your IP and let it refresh :)
+
+## Release Notes
+
+LiveRefresh is designed to work with the latest [development build](http://www.sublimetext.com/dev) of Sublime Text 2
+
+## Development
+
The intension behind this, was because of personal sloth. If you want any new features or plugins or something, feel free to contact me, but also feel free to do them on your own. I cant promise to add any new functionallity.
View
BIN browser_plugins/opera/LiveRefresh_0.8.oex
Binary file not shown.
View
4 browser_plugins/opera/config.xml → browser_plugins/opera/src/config.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
id="https://github.com/PhilippSchaffrath/LiveRefresh"
- version="0.5">
+ version="0.8">
<name>LiveRefresh</name>
<description>Lets you independently connect your tabs to WebSocket-Server. Each time, a tab received "refresh" it will focus and refresh.</description>
- <author href="http://github.com/yadummer" email="yadummer@gmail.com">Konenko [yadummer] Artem</author>
+ <author href="https://github.com/dummer" email="yadummer@gmail.com">Konenko [yadummer] Artem</author>
</widget>
View
0 browser_plugins/opera/css/bootstrap.min.css → ...r_plugins/opera/src/css/bootstrap.min.css
File renamed without changes.
View
0 browser_plugins/opera/img/icon.png → browser_plugins/opera/src/img/icon.png
File renamed without changes
View
0 browser_plugins/opera/img/icon_active.png → ...ser_plugins/opera/src/img/icon_active.png
File renamed without changes
View
0 browser_plugins/opera/index.html → browser_plugins/opera/src/index.html
File renamed without changes.
View
39 browser_plugins/opera/js/background.js → browser_plugins/opera/src/js/background.js
@@ -6,15 +6,15 @@ var background =
, tabs: new Array() // tabId -> tab:BrowserTab, socket:WebSocket, host, port
, Init: function()
{
- window.addEventListener("load", this.onLoad(), false); // Constructor for the widget
+ window.addEventListener("load", this.onLoad(), false); // Call constructor after load
}
- , onLoad: function()
+ , onLoad: function() // Constructor for the extension
{
var self = this; // The crutch for access to object into anonymous function.
var ToolbarUIItemProperties =
{
- title: "LiveRefreshDev"
+ title: "LiveRefresh"
, icon: "img/icon.png"
, popup: {
href: "popup.html",
@@ -22,18 +22,21 @@ var background =
height: 40
}
};
- this.button = opera.contexts.toolbar.createItem(ToolbarUIItemProperties);
+ this.button = opera.contexts.toolbar.createItem(ToolbarUIItemProperties);
opera.contexts.toolbar.addItem(this.button);
- opera.extension.tabs.onfocus = function() { self.onFocus(); };
- opera.extension.onconnect = function(event)
+ opera.extension.tabs.onfocus = function() { self.onFocus(); }; // Action for each switching tabs
+ opera.extension.onconnect = function(event) // Post message to popup with status connection of current tab
{
var tabId = opera.extension.tabs.getFocused().id;
var status = self.tabs[tabId] != undefined;
- // It's magic, but our extension drops, when we try used host and port fields
- // I will try fix it in next iteration
- var host = 'Localhost'; // self.tabs[tabId].host;
- var port = 1025; // self.tabs[tabId].port;
+
+ var host, port;
+ if (status) // If connection exist, we write current host/port to inputs placeholder
+ {
+ host = self.tabs[tabId].host;
+ port = self.tabs[tabId].port;
+ }
event.source.postMessage( {
'tabId': tabId
@@ -56,7 +59,7 @@ var background =
this.updateIcon('passive');
}
}
- , onMessage: function(event)
+ , onMessage: function(event) // Handler for incoming messages
{
var action = event.data.action;
var tabId = opera.extension.tabs.getFocused().id;
@@ -81,7 +84,6 @@ var background =
{
this.disconnect(tabId);
}
-
}
, connect: function(host, port, tabId)
{
@@ -95,9 +97,10 @@ var background =
}
this.tabs[tabId].socket.onopen = function () { self.onSocketOpen(); };
- this.tabs[tabId].socket.onclose = function(event) { self.onSocketClose(event); };
+ this.tabs[tabId].socket.onclose = function(event) { self.onSocketClose( event, tabId ); };
this.tabs[tabId].socket.onmessage = function(event)
{
+ // Refreshing the target tab after receive message through socket
self.onSocketMessage( event,
function ()
{
@@ -118,14 +121,9 @@ var background =
{
this.updateIcon('active');
}
- , onSocketClose: function (event)
+ , onSocketClose: function (event, tabId)
{
- if (event.wasClean) {
- // Closed as normal
- } else {
- // Break connection
- }
- opera.postError('Socket closed');
+ this.disconnect( tabId ); // If the connection aborted we close socket
}
, onSocketMessage: function (event, refresh)
{
@@ -134,7 +132,6 @@ var background =
, onSocketError: function (error)
{
// We have the problem, but I don't know what we should do :(
- opera.postError('Error');
}
, updateIcon: function (type)
{
View
0 ...plugins/opera/js/libs/jquery-1.8.3.min.js → ...ins/opera/src/js/libs/jquery-1.8.3.min.js
File renamed without changes.
View
23 browser_plugins/opera/js/plugin.js → browser_plugins/opera/src/js/plugin.js
@@ -1,6 +1,5 @@
$(document).ready(function() {
- var source;
- var self = this;
+ var source; // The channel for messaging
var hostField = $('form#socketform #host');
var portField = $('form#socketform #port');
@@ -9,26 +8,22 @@ $(document).ready(function() {
var update = function( status, host, port )
{
- if ( status == true )
+ if ( status )
{
connectButton.addClass('disabled');
- disconnectButton.removeClass('disabled');
+ hostField.attr( 'placeholder', host );
+ portField.attr( 'placeholder', port );
}
else
{
- connectButton.removeClass('disabled');
disconnectButton.addClass('disabled');
}
-
- hostField.attr( 'placeholder', host );
- portField.attr( 'placeholder', port );
}
- opera.extension.onmessage = function(event)
+ opera.extension.onmessage = function(event) // Initialisation after connect with background.js
{
- source = event.source;
-
- update( event.data.status, event.data.host, event.data.port );
+ source = event.source;
+ update( event.data.status, event.data.host, event.data.port );
}
connectButton.on("click",
@@ -43,7 +38,7 @@ $(document).ready(function() {
, 'port': portField.val()
} );
- return window.close();
+ return window.close(); // Popup of Opera's extension not close in development mode. Use oex archive
});
disconnectButton.on("click",
@@ -56,6 +51,6 @@ $(document).ready(function() {
'action': 'disconnect'
} );
- return window.close();
+ return window.close(); // Popup of Opera's extension not close in development mode. Use oex archive
});
});
View
0 browser_plugins/opera/popup.html → browser_plugins/opera/src/popup.html
File renamed without changes.

0 comments on commit 839744a

Please sign in to comment.
Something went wrong with that request. Please try again.