xref: /plugin/vshare/script.js (revision 9af27a92defbb3bacfe076c4579892ede265eb18)
1
2/**
3 * Append a toolbar button
4 */
5if(window.toolbar != undefined){
6    toolbar[toolbar.length] = {"type":  "pluginvshare",
7                               "title": LANG['plugins']['vshare']['button'],
8                               "icon":  DOKU_BASE+"lib/plugins/vshare/button.png",
9                               "key":   ""};
10}
11
12/**
13 * Try to determine the video service, extract the ID and insert
14 * the correct syntax
15 */
16function tb_pluginvshare(btn, props, edid) {
17    var text = prompt(LANG['plugins']['vshare']['prompt']);
18    if(!text) return;
19
20    // This includes the site patterns:
21    /* DOKUWIKI:include sites.js */
22
23    for (var key in sites){
24        var RE = new RegExp(sites[key],'i');
25        var match = text.match(RE);
26        if(match){
27            var code = '{{'+key+'>'+match[1]+'?medium}}';
28            insertAtCarret(edid, code);
29            return;
30        }
31    }
32
33    alert(LANG['plugins']['vshare']['notfound']);
34}
35
36