Skip to content

Commit

Permalink
New way to generate random names, without the need of an ajax call
Browse files Browse the repository at this point in the history
  • Loading branch information
dtygel committed Aug 29, 2013
1 parent 3da73ca commit 6b64496
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*~
counter.txt
.gitignore
1 change: 0 additions & 1 deletion counter.txt

This file was deleted.

2 changes: 1 addition & 1 deletion editor_plugin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 14 additions & 15 deletions editor_plugin_src.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,9 @@
: "400";

ed.addCommand('mceEtherPadLite', function() {
var xmlhttp;
if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var padName = xmlhttp.responseText;
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>";
ed.execCommand('mceInsertContent', false, iframe);
}
};
xmlhttp.open("GET", url+"/etherpad_name_generator.php?padPrefix="+padPrefix, true);
xmlhttp.send();
var padName = padPrefix + '.' + randomPadName();
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>";
ed.execCommand('mceInsertContent', false, iframe);
});

ed.addButton('etherpadlite', {title : 'etherpadlite.desc', cmd : 'mceEtherPadLite', image : url + '/img/etherpadlite.gif'});
Expand All @@ -64,6 +52,17 @@
};
}
});

function randomPadName() {
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var string_length = 10;
var randomstring = '';
for (var i = 0; i < string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum, rnum + 1);
}
return randomstring;
}


// Register plugin
Expand Down
8 changes: 0 additions & 8 deletions etherpad_name_generator.php

This file was deleted.

Binary file modified img/etherpadlite.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6b64496

Please sign in to comment.