Created
          January 20, 2009 10:07 
        
      - 
      
- 
        Save sealence/49422 to your computer and use it in GitHub Desktop. 
    Ubiquity: irecite
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | /* command "irecite" */ | |
| CmdUtils.CreateCommand({ | |
| names: ["irecite"], | |
| icon: "http://res.iciba.com/dict/favicon.ico", | |
| homepage: "http://scb.iciba.com/day/", | |
| author: { name: "Sealence", email: "[email protected]"}, | |
| license: "GPL", | |
| description: "Recite word everyday", | |
| arguments: [ {role: 'object', nountype: noun_arb_text, label: 'input'} ], | |
| baseurl: "http://scb.iciba.com/day", | |
| execute:function(args){ | |
| var input = args.object.text; | |
| var url = this.baseurl; | |
| if ( input.length > 0 ) | |
| url += '_' + input + '.shtml'; | |
| Utils.openUrlInBrowser(url); | |
| }, | |
| preview: function( pblock, args ) { | |
| var input = args.object.text; | |
| var url = this.baseurl; | |
| if ( input.length > 0 ) | |
| url += '_' + input + '.shtml'; | |
| Utils.parseRemoteDocument( | |
| url, // URL | |
| null, // post data | |
| function(doc) { // success callback | |
| var max = 5; | |
| var top = null, bottom = null, data = ''; | |
| for (var i=0;i<max;i++){ | |
| top = jQuery('#top' + i, doc).html(); | |
| bottom = jQuery('#bottom' + i + ' div', doc).html(); | |
| data += '<b>' + top + '</b>' + bottom + '<p/>'; | |
| } | |
| pblock.innerHTML = data ; | |
| }, | |
| function() { // error callback | |
| pblock.innerHTML = "Error!"; | |
| } | |
| ); | |
| } | |
| }); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment