Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
45 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,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) | ||
+"¬es="+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) | ||
+ "¬es=" + encodeURIComponent(text) | ||
+ "&source=firefox"; | ||
} | ||
}); | ||
|
||
}; |