mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 05:53:27 -07:00
Moving back to trunk!
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1602 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
ad265b2c54
commit
8d458998a1
332 changed files with 17647 additions and 9466 deletions
|
@ -0,0 +1,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<script src='jquery-1.7.1.min.js' type='text/javascript'></script>
|
||||
<script src='background.js' type='text/javascript'></script>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas"></canvas>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,29 @@
|
|||
function sendCaptureToGreenshot(dataURL) {
|
||||
window.console.info('Sending data...');
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "POST",
|
||||
contentType: "image/png;base64",
|
||||
dataType: "text",
|
||||
processData: false,
|
||||
data: dataURL,
|
||||
url: 'http://localhost:11234',
|
||||
success : function (text) {
|
||||
window.console.info('Got: ' + text);
|
||||
},
|
||||
error : function () {
|
||||
alert("Couldn't send capture, please check if Greenshot is running!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function capture() {
|
||||
window.console.info('Starting capture');
|
||||
try {
|
||||
chrome.tabs.captureVisibleTab(null, {format:'png'}, captureTaken);
|
||||
} catch(exception) {
|
||||
alert( exception.toString());
|
||||
}
|
||||
}
|
||||
|
||||
chrome.browserAction.onClicked.addListener(function(tab) {capture();});
|
Binary file not shown.
After Width: | Height: | Size: 7.8 KiB |
4
GreenshotNetworkImportPlugin/Browser-Plugins/Chrome/jquery-1.7.1.min.js
vendored
Normal file
4
GreenshotNetworkImportPlugin/Browser-Plugins/Chrome/jquery-1.7.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "Greenshot",
|
||||
"version": "1.0",
|
||||
"description": "Adds a Greenshot capture button",
|
||||
"icons": { "128": "greenshot.png" },
|
||||
"permissions": [
|
||||
"tabs",
|
||||
"clipboardRead",
|
||||
"clipboardWrite",
|
||||
"http://*/*"
|
||||
],
|
||||
"background_page": "background.html",
|
||||
"browser_action": {
|
||||
"default_icon": "greenshot.png",
|
||||
"default_title": "Greenshot"
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
content greenshot content/
|
||||
skin greenshot greenshotskin skin/
|
||||
overlay chrome://browser/content/browser.xul chrome://greenshot/content/overlay.xul
|
4
GreenshotNetworkImportPlugin/Browser-Plugins/Firefox/greenshot/content/jquery-1.7.1.min.js
vendored
Normal file
4
GreenshotNetworkImportPlugin/Browser-Plugins/Firefox/greenshot/content/jquery-1.7.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,182 @@
|
|||
/// Javscript logic for the Greenshot extension
|
||||
var greenshotPrefObserver = {
|
||||
register: function() {
|
||||
// First we'll need the preference services to look for preferences.
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
|
||||
// For this._branch we ask that the preferences for extensions.myextension. and children
|
||||
this._branch = prefService.getBranch("extensions.greenshot.");
|
||||
// Now we queue the interface called nsIPrefBranch2. This interface is described as:
|
||||
// "nsIPrefBranch2 allows clients to observe changes to pref values."
|
||||
this._branch.QueryInterface(Components.interfaces.nsIPrefBranch2);
|
||||
// Finally add the observer.
|
||||
this._branch.addObserver("", this, false);
|
||||
},
|
||||
unregister: function() {
|
||||
if (!this._branch) return;
|
||||
this._branch.removeObserver("", this);
|
||||
},
|
||||
readDestination: function() {
|
||||
return "http://" + this._branch.getCharPref("host") + ":" + this._branch.getIntPref("port");
|
||||
},
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if(aTopic != "nsPref:changed") return;
|
||||
// aSubject is the nsIPrefBranch we're observing (after appropriate QI)
|
||||
// aData is the name of the pref that's been changed (relative to aSubject)
|
||||
switch (aData) {
|
||||
case "host":
|
||||
this.readDestination();
|
||||
break;
|
||||
case "port":
|
||||
this.readDestination();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
greenshotPrefObserver.register();
|
||||
|
||||
function doMenuClick() {
|
||||
capture();
|
||||
}
|
||||
function doStatusbarClick() {
|
||||
capture();
|
||||
}
|
||||
|
||||
function sendImage(dataUrl, title) {
|
||||
var destination = greenshotPrefObserver.readDestination();
|
||||
try {
|
||||
// Send the image via a HTTP Request to our localhost
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "POST",
|
||||
contentType: "image/png;base64",
|
||||
dataType: "text",
|
||||
processData: false,
|
||||
data: dataUrl,
|
||||
url: destination + '?title=' + escape(encodeUTF8(title)),
|
||||
success : function (text) {
|
||||
alert("Sent image to: " + destination);
|
||||
//document.getElementById("statusbar-display").label = "Greenshot: " + text;
|
||||
},
|
||||
error : function () {
|
||||
alert("Couldn't send image to '" + destination + "' please check if Greenshot is running!");
|
||||
}
|
||||
});
|
||||
} catch (exception) {
|
||||
alert(exception.message);
|
||||
}
|
||||
}
|
||||
///
|
||||
/// Capture the current opened window
|
||||
/// and send it to Greenshot
|
||||
///
|
||||
function capture() {
|
||||
// Used variables
|
||||
var width;
|
||||
var height;
|
||||
var xOffset;
|
||||
var yOffset;
|
||||
var context;
|
||||
|
||||
try {
|
||||
// Get document width & height
|
||||
width = $(window.content.document).width();
|
||||
height = $(window.content.document).height();
|
||||
|
||||
// Create canvas
|
||||
var canvas = window.content.document.createElement('canvas');
|
||||
|
||||
// change the canvas size to the document size
|
||||
canvas.setAttribute('width', width);
|
||||
canvas.setAttribute('height', height);
|
||||
|
||||
// Get the drawing context
|
||||
context = canvas.getContext("2d");
|
||||
|
||||
// Set the scroll location to top-left, so we don't have problems with funny banners that move while scrolling
|
||||
xOffset = window.content.window.scrollX;
|
||||
yOffset = window.content.window.scrollY;
|
||||
window.content.window.scrollTo(0,0);
|
||||
|
||||
} catch (exception) {
|
||||
}
|
||||
// continue after timeout, so the page is scrolled correctly and has time to move it's items, e.g. for Jira
|
||||
setTimeout( function(){
|
||||
try {
|
||||
// Draw the window to the context
|
||||
context.drawWindow(window.content.window, 0, 0, width, height, 'rgb(255,255,255)');
|
||||
window.content.window.scrollTo(xOffset,yOffset);
|
||||
|
||||
// Send the canvas
|
||||
|
||||
sendImage(canvas.toDataURL("image/png"), window.content.document.title);
|
||||
} catch (exception) {
|
||||
alert(exception.message);
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
|
||||
function captureImage(imageToCapture) {
|
||||
try {
|
||||
var canvas = window.content.document.createElement('canvas');
|
||||
|
||||
// change the canvas size to the document size
|
||||
canvas.setAttribute('width', imageToCapture.width);
|
||||
canvas.setAttribute('height', imageToCapture.height);
|
||||
|
||||
// Get the drawing context
|
||||
context = canvas.getContext("2d");
|
||||
context.drawImage(imageToCapture, 0, 0);
|
||||
|
||||
// Get filename from url
|
||||
var title
|
||||
if (imageToCapture.alt) {
|
||||
title =imageToCapture.alt;
|
||||
} else {
|
||||
title = imageToCapture.src.replace(/\?.*/,'').replace(/^.*(\\|\/|\:)/, '').replace(/\.[^.]*/,'');
|
||||
}
|
||||
// Send the canvas
|
||||
sendImage(canvas.toDataURL("image/png"), title);
|
||||
} catch (exception) {
|
||||
alert(exception.message);
|
||||
}
|
||||
}
|
||||
|
||||
// private method for UTF-8 encoding
|
||||
function encodeUTF8(string) {
|
||||
string = string.replace(/\r\n/g,"\n");
|
||||
var utftext = "";
|
||||
for (var n = 0; n < string.length; n++) {
|
||||
var c = string.charCodeAt(n);
|
||||
if (c < 128) {
|
||||
utftext += String.fromCharCode(c);
|
||||
} else if((c > 127) && (c < 2048)) {
|
||||
utftext += String.fromCharCode((c >> 6) | 192);
|
||||
utftext += String.fromCharCode((c & 63) | 128);
|
||||
} else {
|
||||
utftext += String.fromCharCode((c >> 12) | 224);
|
||||
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
||||
utftext += String.fromCharCode((c & 63) | 128);
|
||||
}
|
||||
}
|
||||
return utftext;
|
||||
}
|
||||
|
||||
function ShowHideGreenshotMenuItem(event) {
|
||||
try {
|
||||
gContextMenu.showItem("greenshot-menu-item", gContextMenu.onImage);
|
||||
} catch (exception) {
|
||||
alert(exception.message);
|
||||
}
|
||||
}
|
||||
|
||||
function InitializeGreenshotExtension() {
|
||||
try {
|
||||
var contextMenu = document.getElementById("contentAreaContextMenu");
|
||||
if (contextMenu) {
|
||||
contextMenu.addEventListener("popupshowing", ShowHideGreenshotMenuItem, false);
|
||||
}
|
||||
} catch (exception) {
|
||||
alert(exception.message);
|
||||
}
|
||||
}
|
||||
window.addEventListener("load", InitializeGreenshotExtension, false);
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0"?>
|
||||
<overlay id="greenshotOverlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml">
|
||||
<script type="text/javascript" src="jquery-1.7.1.min.js"/>
|
||||
<script type="text/javascript" src="overlay.js"/>
|
||||
<menupopup id="menu_ToolsPopup">
|
||||
<menuitem id="greenshotPopupMenuitem" label="Capture with Greenshot" insertbefore="sanitizeSeparator" oncommand="doMenuClick();"/>
|
||||
</menupopup>
|
||||
<statusbar id="status-bar">
|
||||
<statusbarpanel class="statusbarpanel-iconic" id="greenshot_statusbar" onclick="doStatusbarClick();" src="chrome://greenshot/skin/greenshot16.png" />
|
||||
</statusbar>
|
||||
<popup id="contentAreaContextMenu">
|
||||
<menuitem id="greenshot-menu-item" label="Send image to Greenshot" oncommand="captureImage(gContextMenu.target);"/>
|
||||
</popup>
|
||||
</overlay>
|
|
@ -0,0 +1,4 @@
|
|||
// Port number to post the screenshot to
|
||||
pref("extensions.greenshot.port", 11234);
|
||||
// hostname to post the screenshot to
|
||||
pref("extensions.greenshot.host", "localhost");
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0"?>
|
||||
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
|
||||
<Description about="urn:mozilla:install-manifest">
|
||||
<!-- Unique ID for extension. Can be in e-mail address format or GUID format -->
|
||||
<em:id>greenshot@getgreenshot.org</em:id>
|
||||
<!-- Indicates that this add-on is an extension -->
|
||||
<em:type>2</em:type>
|
||||
<!-- Extension name displayed in Add-on Manager -->
|
||||
<em:name>Greenshot</em:name>
|
||||
<!-- Extension version number. There is a version numbering scheme you must follow -->
|
||||
<em:version>0.1</em:version>
|
||||
<!-- Brief description displayed in Add-on Manager -->
|
||||
<em:description>A simple capture to Greenshot extension.</em:description>
|
||||
<!-- Name of extension's primary developer. Change to your name -->
|
||||
<em:creator>Lakritzator</em:creator>
|
||||
<!-- Web page address through which extension is distributed -->
|
||||
<em:homepageURL>http://getgreenshot.org</em:homepageURL>
|
||||
<!-- This section gives details of the target application for the extension (in this case: Firefox 2) -->
|
||||
<em:iconURL>chrome://greenshot/skin/greenshot90.png</em:iconURL>
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||
<em:minVersion>3.5.*</em:minVersion>
|
||||
<em:maxVersion>10.*</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
</Description>
|
||||
</RDF>
|
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 7.8 KiB |
Loading…
Add table
Add a link
Reference in a new issue