Rebaser: Generate random doc name if none provided

Change-Id: Ib790fa5d61df7f2318cd014d5ffa60a3ab3861d3
This commit is contained in:
Ed Sanders 2018-01-08 15:32:15 +00:00
parent 037f666985
commit 1bef5a03ce

View file

@ -80,10 +80,13 @@
function onSubmit() { function onSubmit() {
documentNameInput.getValidity().then( function () { documentNameInput.getValidity().then( function () {
var title = mw.Title.newFromText( documentNameInput.getValue() ), var specialTitle,
specialTitle = mw.Title.newFromText( 'Special:CollabPad/' + title.toString() ); title = mw.Title.newFromText(
documentNameInput.getValue().trim() || Math.random().toString( 36 ).slice( 2 )
);
if ( title ) { if ( title ) {
specialTitle = mw.Title.newFromText( 'Special:CollabPad/' + title.toString() );
if ( history.pushState ) { if ( history.pushState ) {
// TODO: Handle popstate // TODO: Handle popstate
history.pushState( { tag: 'collabTarget', title: title.toString() }, title.getMain(), specialTitle.getUrl() ); history.pushState( { tag: 'collabTarget', title: title.toString() }, title.getMain(), specialTitle.getUrl() );
@ -98,8 +101,8 @@
} }
documentNameInput.setValidation( function ( value ) { documentNameInput.setValidation( function ( value ) {
var title = mw.Title.newFromText( value ); // Empty input will create a random document name, otherwise must be valid
return !!title; return value === '' || !!mw.Title.newFromText( value );
} ); } );
submitButton.setDisabled( false ); submitButton.setDisabled( false );