satyr (owner)

Revisions

gist: 187722 Download_button fork
public
Description:
Thank You Mario!
Public Clone URL: git://gist.github.com/187722.git
Embed All Files: show embed
thank-you-mario.ubiq.js #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const TYM = 'http://wigflip.com/thankyoumario/';
CmdUtils.CreateCommand({
  name: 'thank you mario',
  description: 'Thank You Mario!'.link(TYM),
  icon: 'http://wigflip.com/favicon.ico',
  author: {name: 'satyr', email: 'murky.satyr@gmail.com'},
  license: 'MIT',
  arguments: {
    object_message: noun_arb_text,
    instrument_title: noun_arb_text,
    alias_name: noun_arb_text,
  },
  execute: function(args){
    this._post(args, function(gif){
      CmdUtils.setSelection(
        <img src={gif}/>.toXMLString(),
        {text: Utils.clipboard.text = gif});
    });
  },
  preview: function(pb, args){
    this._post(args, function(gif){
      pb.innerHTML = <center><img src={gif}/></center>;
    }, pb);
  },
  _post: function({object, instrument, alias}, cb, pb){
    var params = {
      url: TYM,
      type: 'post',
      data: {
        name: alias.text,
        lines: object.text.replace(/;;/g, '\n'),
        title: instrument.text,
        double: pb ? 'n' : 'y',
      },
      success: function(htm){
        cb(/\bhttp:\/\/attach\.tym\.wigflip\.com\/\S+?\.gif/(htm) +'');
      },
    };
    pb ? CmdUtils.previewAjax(pb, params) : $.ajax(params);
  },
});