Skip to content

Commit

Permalink
Prefill input field with url parameter. Start the process automatical…
Browse files Browse the repository at this point in the history
…ly. (wmde#233)
  • Loading branch information
martinkraft authored and manicki committed Mar 7, 2017
1 parent 1b0bb17 commit 99522fe
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.base.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ <h2>{{i18n.index.description}}</h2>
</div>

<form id="file-form" class="yes-script" onsubmit="return false;">
<input id="file-form-input" type="text" inputmode="url" name="file" placeholder="{{i18n.index.input-placeholder}}" autofocus><button type="submit" class="green-btn">{{i18n.index.go-button}}</button>
<input id="file-form-input" type="text" inputmode="url" name="file" placeholder="{{i18n.index.input-placeholder}}" {{inputattr}} autofocus><button type="submit" class="green-btn">{{i18n.index.go-button}}</button>
<div class="container-fluid display-none" id="file-form-alert">
<span class="glyphicon glyphicon-warning-sign"></span><span id="file-form-alert-placeholder">Alert</span>
</div>
Expand Down
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// Get the base html to output
$html = file_get_contents( __DIR__ . '/index.base.html' );
$html = str_replace( '{{i18n.lang}}', $lang, $html );
$html = str_replace( '{{inputattr}}', isset( $_GET['url'] ) ? ' value="'.htmlspecialchars($_GET['url']).'"' : '', $html );

// If we have any i18n data replace the i18n codes with new strings
if ( $i18nData && isset( $i18nData['index'] ) ) {
Expand Down
12 changes: 12 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,15 @@ $feedbackForm.submit( function( e ) {

e.preventDefault();
} );

$( function() {
// Instant start if input field is filled

var $fileForm = $( '#file-form' ),
$fileFormInput = $fileForm.find( '#file-form-input' ),
fileFormVal = $fileFormInput.val();

if( fileFormVal && fileFormVal !== '' ) {
$fileForm.submit();
}
} );

0 comments on commit 99522fe

Please sign in to comment.