mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-04 22:27:10 -04:00
changing spaces or slashes in padnames to underscores
This commit is contained in:
parent
5ea8dd6b70
commit
dc2aafa062
1 changed files with 11 additions and 4 deletions
|
@ -96,7 +96,10 @@
|
||||||
<input type="submit" value="OK">
|
<input type="submit" value="OK">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
// var pathName = "p/";
|
||||||
|
var pathName = "";
|
||||||
|
|
||||||
function randomPadName()
|
function randomPadName()
|
||||||
{
|
{
|
||||||
var chars = "23456789ABCDEFGHJKLMNPQRSTUWXYZabcdefghijkmnopqrstuwxyz";
|
var chars = "23456789ABCDEFGHJKLMNPQRSTUWXYZabcdefghijkmnopqrstuwxyz";
|
||||||
|
@ -110,10 +113,14 @@
|
||||||
return randomstring;
|
return randomstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function encodeSanitizedName( name ) {
|
||||||
|
return encodeURIComponent( name.replace( /[\/ ]/g, "_") );
|
||||||
|
}
|
||||||
|
|
||||||
function go2Name()
|
function go2Name()
|
||||||
{
|
{
|
||||||
var padname = document.getElementById("padname").value;
|
var padname = document.getElementById("padname").value;
|
||||||
padname.length > 0 ? window.location = /** "p/" + **/ padname : alert("Please enter a name")
|
padname.length > 0 ? window.location = pathName + encodeSanitizedName( padname ) : alert("Please enter a name")
|
||||||
}
|
}
|
||||||
|
|
||||||
function go2Random()
|
function go2Random()
|
||||||
|
@ -121,14 +128,14 @@
|
||||||
var rnd = randomPadName();
|
var rnd = randomPadName();
|
||||||
var prefixedName = prompt( "You can prefix or modify your random pad name with some reasonable characters.\nSpecial characters will be removed or escaped.\n\n", "-"+rnd );
|
var prefixedName = prompt( "You can prefix or modify your random pad name with some reasonable characters.\nSpecial characters will be removed or escaped.\n\n", "-"+rnd );
|
||||||
if ( prefixedName == "-" + rnd ) prefixedName = rnd;
|
if ( prefixedName == "-" + rnd ) prefixedName = rnd;
|
||||||
var escPrefixedName = encodeURIComponent( prefixedName.replace( /\//, "" ) );
|
var escPrefixedName = encodeSanitizedName( prefixedName );
|
||||||
if ( prefixedName == null ) return;
|
if ( prefixedName == null ) return;
|
||||||
if ( prefixedName == decodeURIComponent( escPrefixedName )
|
if ( prefixedName == decodeURIComponent( escPrefixedName )
|
||||||
|| ( prefixedName != escPrefixedName
|
|| ( prefixedName != escPrefixedName
|
||||||
&& confirm( "You have used characters which are not allowed in Urls, and the padname will therefore be modified to "
|
&& confirm( "You have used characters which are not allowed in Urls, and the padname will therefore be modified to "
|
||||||
+ decodeURIComponent( escPrefixedName )
|
+ decodeURIComponent( escPrefixedName )
|
||||||
+ ".\nDo you want to use this modifed name?" ) ) ) {
|
+ ".\nDo you want to use this modifed name?" ) ) ) {
|
||||||
window.location = /** "p/" + **/ escPrefixedName;
|
window.location = pathName + escPrefixedName;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue