Skip to content

Commit

Permalink
code cleanup and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hernan committed Aug 29, 2012
1 parent 239ea90 commit e25234c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 40 deletions.
12 changes: 12 additions & 0 deletions data/blank.html
@@ -0,0 +1,12 @@
<!doctype html>
<html>
<head>
<style>
body { margin:0; background-color: #fff; text-align: center; }
img { margin: 50px auto; }
</style>
</head>
<body>
<img src="spinner.gif" alt="" />
</body>
</html>
Binary file added data/spinner.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 33 additions & 40 deletions lib/main.js
@@ -1,48 +1,41 @@
exports.main = function() {
var currentUrl = '';
var currentTitle = '';
var currentSelection = '';

var self = require("self");

var selection = require("selection");
var self = require("self");
var selection = require("selection");
var tabs = require("tabs");
var widget = require('widget').Widget;
var panel = require('panel').Panel;

var selectedText = '';
exports.main = function() {
var selectedText = {text: '', tabUrl: null};

function selectionChanged(event){
selectedText = selection.text;
selectedText.text = selection.text;
selectedText.tabUrl = tabs.activeTab.url;
}

selection.on('select', selectionChanged);

// Create widget that will show panel on click
require("widget").Widget({
id: "kippt",
label: "Kippt it",
contentURL: self.data.url("icon.png"),
onClick: function(){
var tabs = require("tabs");
var currentUrl = tabs.activeTab.url;
var currentTitle = tabs.activeTab.title;
if (!selectedText) selectedText = '';

// Create panel for kippt
var kipptPanel = require("panel").Panel({
width:420,
height:245,
contentURL : "https://kippt.com/extensions/new/?"
+"url="+encodeURIComponent(currentUrl)
+"&title="+encodeURIComponent(currentTitle)
+"&notes="+encodeURIComponent(selectedText)
+"&source=firefox",
contentScript: "setInterval(function(){ if (document.getElementById('submit_clip').value === 'Saved!') { setTimeout(function() { self.port.emit('close', null);}, 700); }}, 500);"
});
kipptPanel.port.on("close", function () {
kipptPanel.destroy();
});

kipptPanel.show();
}

var kipptPanel = panel({
width: 450,
height: 240,
contentURL : self.data.url('blank.html'),
onHide: function(){ kipptPanel.contentURL = self.data.url('blank.html'); }
});

};

widget({
id: 'kippt',
label: 'Kippt it',
contentURL: self.data.url("icon.png"),
panel: kipptPanel,
onClick: function(){
var text = tabs.activeTab.url == selectedText.tabUrl ? selectedText.text : '';

kipptPanel.contentURL = "https://kippt.com/extensions/new/?"
+ "url=" + encodeURIComponent(tabs.activeTab.url)
+ "&title=" + encodeURIComponent(tabs.activeTab.title)
+ "&notes=" + encodeURIComponent(text)
+ "&source=firefox";
}
});

};

0 comments on commit e25234c

Please sign in to comment.