|
34 | 34 | : "400"; |
35 | 35 |
|
36 | 36 | ed.addCommand('mceEtherPadLite', function() { |
37 | | - var xmlhttp; |
38 | | - if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari |
39 | | - xmlhttp = new XMLHttpRequest(); |
40 | | - } else { // code for IE6, IE5 |
41 | | - xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); |
42 | | - } |
43 | | - xmlhttp.onreadystatechange = function() { |
44 | | - if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { |
45 | | - var padName = xmlhttp.responseText; |
46 | | - var iframe = "<iframe name='embed_readwrite' src='" + padUrl + padName + "?showControls=true&showChat=true&&alwaysShowChat=true&lang=pt&showLineNumbers=true&useMonospaceFont=false' width='" + padWidth + "' height='" + padHeight + "'></iframe>"; |
47 | | - ed.execCommand('mceInsertContent', false, iframe); |
48 | | - } |
49 | | - }; |
50 | | - xmlhttp.open("GET", url+"/etherpad_name_generator.php?padPrefix="+padPrefix, true); |
51 | | - xmlhttp.send(); |
| 37 | + var padName = padPrefix + '.' + randomPadName(); |
| 38 | + var iframe = "<iframe name='embed_readwrite' src='" + padUrl + padName + "?showControls=true&showChat=true&&alwaysShowChat=true&lang=pt&showLineNumbers=true&useMonospaceFont=false' width='" + padWidth + "' height='" + padHeight + "'></iframe>"; |
| 39 | + ed.execCommand('mceInsertContent', false, iframe); |
52 | 40 | }); |
53 | 41 |
|
54 | 42 | ed.addButton('etherpadlite', {title : 'etherpadlite.desc', cmd : 'mceEtherPadLite', image : url + '/img/etherpadlite.gif'}); |
|
64 | 52 | }; |
65 | 53 | } |
66 | 54 | }); |
| 55 | + |
| 56 | + function randomPadName() { |
| 57 | + var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; |
| 58 | + var string_length = 10; |
| 59 | + var randomstring = ''; |
| 60 | + for (var i = 0; i < string_length; i++) { |
| 61 | + var rnum = Math.floor(Math.random() * chars.length); |
| 62 | + randomstring += chars.substring(rnum, rnum + 1); |
| 63 | + } |
| 64 | + return randomstring; |
| 65 | + } |
67 | 66 |
|
68 | 67 |
|
69 | 68 | // Register plugin |
|
0 commit comments