Permalink
Browse files

Download and log HTML

  • Loading branch information...
NickTikhonov committed Aug 18, 2016
1 parent aa3ec55 commit 85992043e57c802ca71ff6e8a4f9c477fbfd13db
Showing with 12 additions and 4 deletions.
  1. +10 −2 lib/sourcefetch.js
  2. +2 −2 package.json
View
@@ -1,6 +1,7 @@
'use babel';
import { CompositeDisposable } from 'atom'
import request from 'request'
export default {
@@ -22,8 +23,15 @@ export default {
let editor
if (editor = atom.workspace.getActiveTextEditor()) {
let selection = editor.getSelectedText()
selection = selection.split("").reverse().join("")
editor.insertText(selection)
this.download(selection)
}
},
download(url) {
request(url, (error, response, body) => {
if (!error && response.statusCode == 200) {
console.log(body)
}
})
}
};
View
@@ -3,8 +3,7 @@
"main": "./lib/sourcefetch",
"version": "0.0.0",
"description": "A short description of your package",
"keywords": [
],
"keywords": [],
"activationCommands": {
"atom-workspace": "sourcefetch:fetch"
},
@@ -14,5 +13,6 @@
"atom": ">=1.0.0 <2.0.0"
},
"dependencies": {
"request": "^2.73.0"
}
}

1 comment on commit 8599204

@wozuishuai13768

This comment has been minimized.

Show comment
Hide comment
@wozuishuai13768

wozuishuai13768 Jul 12, 2018

My code is the same as yours, but mine doesn't work
When I try to run my package( ctrl + alt + o ) ,it shows nothing.
I have tried https://google.com , http://www.atom.io
I am sure that my network is ok

./lib/terminal-v

'use babel';

import TerminalVView from './terminal-v-view';
import request from 'request';
import { CompositeDisposable } from 'atom';

export default {

  terminalVView: null,
  modalPanel: null,
  subscriptions: null,

  activate(state) {
    this.terminalVView = new TerminalVView(state.terminalVViewState);
    this.modalPanel = atom.workspace.addModalPanel({
      item: this.terminalVView.getElement(),
      visible: false
    });

    // Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable
    this.subscriptions = new CompositeDisposable();

    // Register command that toggles this view
    this.subscriptions.add(atom.commands.add('atom-workspace', {
      'terminal-v:fetch': () => this.fetch()
    }));
  },

  deactivate() {
    this.modalPanel.destroy();
    this.subscriptions.dispose();
    this.terminalVView.destroy();
  },

  serialize() {
    return {
      terminalVViewState: this.terminalVView.serialize()
    };
  },

  fetch() {
    let editor;
    if (editor = atom.workspace.getActiveTextEditor()) {
        let selection = editor.getSelectedText()
        this.download(selection)
    }
  }

  download(url) {
      request(url, (error, response, body) => {
          if (!error && response.statusCode == 200) {
              console.log(body)
          }
      })
  }

};

wozuishuai13768 commented on 8599204 Jul 12, 2018

My code is the same as yours, but mine doesn't work
When I try to run my package( ctrl + alt + o ) ,it shows nothing.
I have tried https://google.com , http://www.atom.io
I am sure that my network is ok

./lib/terminal-v

'use babel';

import TerminalVView from './terminal-v-view';
import request from 'request';
import { CompositeDisposable } from 'atom';

export default {

  terminalVView: null,
  modalPanel: null,
  subscriptions: null,

  activate(state) {
    this.terminalVView = new TerminalVView(state.terminalVViewState);
    this.modalPanel = atom.workspace.addModalPanel({
      item: this.terminalVView.getElement(),
      visible: false
    });

    // Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable
    this.subscriptions = new CompositeDisposable();

    // Register command that toggles this view
    this.subscriptions.add(atom.commands.add('atom-workspace', {
      'terminal-v:fetch': () => this.fetch()
    }));
  },

  deactivate() {
    this.modalPanel.destroy();
    this.subscriptions.dispose();
    this.terminalVView.destroy();
  },

  serialize() {
    return {
      terminalVViewState: this.terminalVView.serialize()
    };
  },

  fetch() {
    let editor;
    if (editor = atom.workspace.getActiveTextEditor()) {
        let selection = editor.getSelectedText()
        this.download(selection)
    }
  }

  download(url) {
      request(url, (error, response, body) => {
          if (!error && response.statusCode == 200) {
              console.log(body)
          }
      })
  }

};
Please sign in to comment.