Skip to content

Commit

Permalink
Initial checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
martinremy committed Aug 29, 2013
0 parents commit ff707b5
Show file tree
Hide file tree
Showing 29 changed files with 9,702 additions and 0 deletions.
29 changes: 29 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,29 @@
### 1.2 - 20100721

* Auto-proofread is now disabled by default
* The auto-proofread option now warns users about bad things that could happen (the feature is pretty safe though).
* AtD now refuses to attach to Google spreadsheets
* Widget positioning now works with editors that have a z-index set.
* Disabled AtD in WYSIWYG editor for http://drafts.blogger.com (couldn't get it to work right)
* Added an option to disable "no writing errors were found" message box.
* Added a load delay to GMail (should fix widget not showing up sometimes on GMail).

### 1.1 - 20100524

* Fixed a typo on preferences page.
* AtD toolbar button is now in the address bar, added an option to hide it
* Removed auto-proofread feature from Chrome/Stable channel. Upgrade if you want it. A JavaScript
function AtD relies on does not work as expected in Stable channel. This fixes the Facebook comment
submit issue many of you reported.
* AtD now loads CSS after page load and only when AtD is enabled on the current site.
* Added a hack to prevent AtD from loading on Acid3 test page. Chrome w/ AtD loaded now passes.
* Auto-proofread no longer activated on Like, Unlike, and Share Facebook events.
* Updated auto-proofread dialog to get explicit about OK/Cancel buttons.
* AtD does a better job of removing/restoring its widget when the editor becomes hidden/visible. This fixes an issue that affected blogger users losing the AtD widget after switching editors.
* Added a check to prevent WYSIWYG editor proofreader from inheriting properties that could mess up the experience. This means you can edit while proofreading on Blogger and should fix the menu cut-off issue in some CMSs
* AtD widget in proofread mode now lines up with widget in non-proofread mode on Google Docs.
* _To protect your data_, text sent to AtD server for grammar/spell check is now sent over SSL.

### 1.0 - 20100514

* initial release
339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions README.md
@@ -0,0 +1,26 @@
atd-chrome
==========

### Chrome extensions for After the Deadline spelling, style and grammar checker

An extension for [Chrome](https://www.google.com/intl/en/chrome/browser/) that uses the After the Deadline spelling, style, and grammar checker.

Automattic no longer supports this plugin. We're putting it on Github so that you can feel free to fork it, hack it, and release your own version.

### License

GPLv2

### Commercial use and running your own server

This extension requires a running instance of an [After the Deadline Server](https://github.com/automattic/atd-server) in order to work. Automattic operates an that you can use for personal use as long as you don't send too much traffic. The extension is configured to use this instance by default.

For high volume and commercial uses of AtD, you must run your own server. The code is available on Github: [After the Deadline Server](https://github.com/automattic/atd-server). See the [After the Deadline Developer's page](http://open.afterthedeadline.com/) for more information, and check out the [AtD Developers Google Group](http://groups.google.com/group/atd-developers) for discussion and community support.

When you run your own server, replace `service.afterthedeadline.com` with your server's hostname.

### Contact

We (Automattic) are no longer supporting this extension. This code has always been open source. We're putting it on Github so that you can feel free to fork it, hack it, and release your own version.

Join the [atd-developers](http://groups.google.com/group/atd-developers) list for support.
61 changes: 61 additions & 0 deletions action/actions.js
@@ -0,0 +1,61 @@
function goTo(url) {
chrome.tabs.getAllInWindow(undefined, function(tabs) {
for (var i = 0, tab; tab = tabs[i]; i++) {
if (tab.url && tab.url == url) {
chrome.tabs.update(tab.id, {selected: true});
return;
}
}
chrome.tabs.create({ url: url });
});
}

function currentSite(callback) {
chrome.tabs.getSelected(null, function(t) {
callback(t.url);
window.close();
});
}

function toHost(url) {
var host = new RegExp('(https{0,1}://.*?)/.*').exec(url);
if (host == null)
host = url;
else
host = host[1];
return host;
}

function __enable() {
currentSite(function(url) {
var host = toHost(url);
var sites = localStorage['sites'].split(/,\s+/);

var newsites = [];
for (var x = 0; x < sites.length; x++) {
var site = sites[x];
if (host != site)
newsites.push(site);
}
localStorage['sites'] = newsites.join(', ');
chrome.extension.sendRequest({ command: 'refreshTabs' });
});
}

function __disable() {
currentSite(function(url) {
var sites = localStorage['sites'].split(/,\s+/);
var host = toHost(url);
sites.push(host);
localStorage['sites'] = sites.join(', ');
chrome.extension.sendRequest({ command: 'refreshTabs' });
});
}

function home() {
goTo('http://chrome.afterthedeadline.com/proofreading-for-google-chrome-help/');
}

function options() {
goTo('chrome-extension://' + location.hostname + '/options/options.html');
}
17 changes: 17 additions & 0 deletions action/disable.html
@@ -0,0 +1,17 @@
<html>
<head>
<style type="text/css">
@import url(style.css);
</style>
<script src="actions.js"></script>
</head>
<body>
<p>AtD Actions:</p>

<ul>
<li><a href="javascript:__disable()">Disable on this site</a></li>
<li><a href="javascript:options()">View Options</a></li>
<li><a href="javascript:home()">Documentation</a></li>
</ul>
</body>
</html>
17 changes: 17 additions & 0 deletions action/enable.html
@@ -0,0 +1,17 @@
<html>
<head>
<style type="text/css">
@import url(style.css);
</style>
<script src="actions.js"></script>
</head>
<body>
<p>AtD Actions:</p>

<ol>
<li><a href="javascript:__enable()">Enable on this site</a></li>
<li><a href="javascript:options()">View Options</a></li>
<li><a href="javascript:home()">Documentation</a></li>
</ol>
</body>
</html>
15 changes: 15 additions & 0 deletions action/style.css
@@ -0,0 +1,15 @@
body {
width: 200px;
background: #fff;
font: 14px "Lucida Grande", Arial, Helvetica, sans-serif;
}
a {
color: #1390ec;
}

a:visited {
color: #006;
}
a:hover {
color: #000;
}
186 changes: 186 additions & 0 deletions background.html
@@ -0,0 +1,186 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script>
function toHost(url) {
var host = new RegExp('(https{0,1}://.*?)/.*').exec(url);
if (host == null)
host = url;
else
host = host[1];
return host;
}

/* define default values for Language and the keyboard shortcut */
if (localStorage['language'] == undefined)
localStorage['language'] = 'English';
if (localStorage['shortcut'] == undefined)
localStorage['shortcut'] = 'true,false,true,false,83,0';
if (localStorage['auto'] == undefined)
localStorage['auto'] = 'false';
if (localStorage['button'] == undefined)
localStorage['button'] = 'true';
if (localStorage['message'] == undefined)
localStorage['message'] = 'true';

/* always disable auto-proofread feature in older versions of Chrome */
if (chrome.pageAction['setPopup'] == undefined)
localStorage['auto'] = false;

/* we're going to get some nasty errors if our options are not set */
var options = ['options', 'sites', 'phrases', 'guess'];
for (var x = 0; x < options.length; x++) {
if (localStorage[options[x]] == undefined)
localStorage[options[x]] = '';
}

/* a function to refresh all the tab icons */
function checkTab(tabId, url, change) {
var sites = localStorage['sites'].split(/,\s+/);
var enabled = true;
var aurl = toHost(url);
for (var x = 0; x < sites.length; x++) {
if (sites[x] != '' && sites[x] == aurl)
enabled = false;
}

if (!change)
chrome.tabs.sendRequest(tabId, enabled ? 'enabled' : 'disabled');

if (enabled) {
chrome.pageAction.setIcon({ path: 'images/icon48.png', tabId: tabId });

/* check if we're using an older ver of Chrome, if so don't even mess with page actions */
if (chrome.pageAction['setPopup'] != undefined)
chrome.pageAction.setPopup({ popup: 'action/disable.html', tabId: tabId });
}
else {
chrome.pageAction.setIcon({ path: 'images/icon48bw.png', tabId: tabId });

/* check if we're using an older ver of Chrome, if so don't even mess with page actions */
if (chrome.pageAction['setPopup'] != undefined)
chrome.pageAction.setPopup({ popup: 'action/enable.html', tabId: tabId });
}

if (localStorage['button'] == 'true') {
chrome.pageAction.show(tabId);
}
else {
chrome.pageAction.hide(tabId);
}

/* show AtD will have nothing to do with these pages */
if (aurl == 'http://acid3.acidtests.org' || aurl == 'https://chrome.google.com' || aurl == 'https://spreadsheets.google.com' || aurl == 'http://spreadsheets.google.com') {
chrome.pageAction.hide(tabId);
enabled = false;
}
}

function refreshTabs() {
chrome.windows.getAll({ populate: true }, function(windows) {
for (var x = 0; x < windows.length; x++) {
var window = windows[x];
for (var y = 0; y < window.tabs.length; y++) {
checkTab(window.tabs[y].id, window.tabs[y].url);
}
}
});
}

/* setup code to show whether AtD is enabled/disabled on the current site */
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if (changeInfo.url) {
checkTab(tabId, changeInfo.url, true);
}
else {
chrome.tabs.get(tabId, function(t) {
checkTab(tabId, t.url, true);
});
}
});

/* chrome message passing listener */
chrome.extension.onRequest.addListener(function(request, sender, callback) {
if (request.command == 'options') {
callback({ auto: localStorage['auto'],
options: localStorage['options'],
sites: localStorage['sites'],
phrases: localStorage['phrases'],
shortcut: localStorage['shortcut'] });
return;
}
else if (request.command == 'alert') {
if (localStorage['message'] == 'true') {
alert(request.text);
}
return;
}
else if (request.command == 'refreshTabs') {
refreshTabs();
return;
}
else if (request.command == 'ignore') {
var strings = localStorage['phrases'].split(/,\s*/);
strings.push(request.word);
localStorage['phrases'] = strings.join(', ');
return;
}
else if (request.command == 'open') {
var left = (screen.width / 2) - (480 / 2);
var top = (screen.height / 2) - (380 / 2);
window.open( request.url, '', 'width=480,height=440,toolbar=0,status=0,resizable=0,location=0,menuBar=0,left=' + left + ',top=' + top).focus();
return;
}

var xhr = new XMLHttpRequest();

if (!xhr)
return null;

/* handle language option */
var language = localStorage['language'];
if (language == 'French')
request.url = 'https://fr.service.afterthedeadline.com' + request.url;
else if (language == 'German')
request.url = 'https://de.service.afterthedeadline.com' + request.url;
else if (language == 'Portuguese')
request.url = 'https://pt.service.afterthedeadline.com' + request.url;
else if (language == 'Spanish')
request.url = 'https://es.service.afterthedeadline.com' + request.url;
else
request.url = 'https://en.service.afterthedeadline.com' + request.url;

xhr.open('POST', request.url, true );

xhr.onreadystatechange = function() {
if ( xhr.readyState == 4 ) {
callback( xhr.responseText );
}
};

if (localStorage['user-key'] == undefined)
localStorage['user-key'] = 'atd-chrome-' + (new Date()).getTime();

if (request.data.length)
request.data = encodeURI(request.data).replace(/&/g, '%26');

if (request.data.length)
request.data += '&key=' + localStorage['user-key'];
else
request.data = 'key=' + localStorage['user-key'];

/* language guessing option */
if (localStorage['guess'] == 'true')
request.data += '&guess=true';

xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send("data=" + request.data);
});

/* if we have any tabs, lets set their icon to the right thing, right now */
refreshTabs();
</script>
</head>
<body>
</body>
</html>

0 comments on commit ff707b5

Please sign in to comment.