Skip to content

Commit

Permalink
fixed #57 added viewSourceExternalEditor
Browse files Browse the repository at this point in the history
new command:
viewSourceExternalEditor
  • Loading branch information
hbt committed Jan 30, 2017
1 parent b2d8c91 commit ee9ad1c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,7 @@
* Added `openLastDownload` command
* Added alias `incrementURLFirstPath` to command `incrementURLPath` and `decrementURLFirstPath` to `decrementURLPath`
* Added `incrementURLLastPath` `decrementURLLastPath` commands
* Added `viewSourceExternalEditor` command

## 1.3.0

Expand Down
15 changes: 15 additions & 0 deletions background_scripts/actions.js
Expand Up @@ -40,6 +40,21 @@ Actions = (function() {
o.url = 'view-source:' + o.sender.tab.url;
_.openLink(o);
};

_.viewSourceExternalEditor = function(o) {
$.ajax({
url: o.url
}).done(function (data) {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://127.0.0.1:' + settings.vimport);
xhr.send(JSON.stringify({
command: settings.vimcommand,
data: data,
line: 0,
column: 0
}));
});
}

_.openLink = function(o) {
var i;
Expand Down
9 changes: 6 additions & 3 deletions content_scripts/mappings.js
Expand Up @@ -205,9 +205,6 @@ Mappings.actions = {
goToTab: function(repeats) {
RUNTIME('goToTab', {index: repeats - 1});
},
hideDownloadsShelf: function() {
RUNTIME('hideDownloadsShelf');
},
goToRootUrl: function() {
RUNTIME('openLink', {
url: location.protocol + '//' + location.hostname +
Expand Down Expand Up @@ -780,6 +777,12 @@ Mappings.actions = {
a.download = "cvim-settings.json"
a.click()
},
viewSourceExternalEditor: function() {
RUNTIME('viewSourceExternalEditor', {url: window.location.href});
},
hideDownloadsShelf: function() {
RUNTIME('hideDownloadsShelf');
},
openLastDownload: function() {
// TODO(hbt) ENHANCE add counter support where it would download the the second last download for example
RUNTIME('openLastDownloadedFile')
Expand Down
3 changes: 3 additions & 0 deletions docs/commands.adoc
Expand Up @@ -39,6 +39,7 @@ unmapAll
map x mouselessCommandName
----

// TODO(hbt) NEXT list commands starting by :
// TODO(hbt) NEXT fix commands flagged as review
// TODO(hbt) NEXT move settings to their own map + add usage
// TODO(hbt) NEXT add example configuration in tips
Expand Down Expand Up @@ -389,6 +390,8 @@ map x mouselessCommandName
| :viewsource!
| go to the view-source:// page for the current Url

| viewSourceExternalEditor
| same as viewsource but opens in configured external editor

| toggleImageZoom
| toggle image zoom (same as clicking the image on image-only pages)
Expand Down
4 changes: 4 additions & 0 deletions docs/commands.html
Expand Up @@ -975,6 +975,10 @@ <h3 id="_page">Page</h3>
<td class="tableblock halign-left valign-top"><p class="tableblock">go to the view-source:// page for the current Url</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">viewSourceExternalEditor</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">same as viewsource but opens in configured external editor</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">toggleImageZoom</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">toggle image zoom (same as clicking the image on image-only pages)</p></td>
</tr>
Expand Down

0 comments on commit ee9ad1c

Please sign in to comment.