Index: branches/MwEmbedStandAlone/modules/TimedText/mw.TimedText.js |
— | — | @@ -474,7 +474,7 @@ |
475 | 475 | } else { |
476 | 476 | // Add a link to request timed text for this clip: |
477 | 477 | $menu.append( |
478 | | - $j.getLineItem( gM( 'mwe-timedtext-request-subs'), 'comment', function(){ |
| 478 | + $j.getLineItem( gM( 'mwe-timedtext-request-subs'), 'comment', function(){ |
479 | 479 | _this.getAddSubRequest(); |
480 | 480 | }) |
481 | 481 | ); |
— | — | @@ -510,7 +510,7 @@ |
511 | 511 | // Set the loadingSpinner: |
512 | 512 | $j( this ).loadingSpinner(); |
513 | 513 | // Turn off buttons while loading |
514 | | - $dialog.dialog( 'option', 'buttons', null ); |
| 514 | + $dialog.dialog( 'option', 'buttons', null ); |
515 | 515 | |
516 | 516 | // Check if the category does not already exist: |
517 | 517 | mw.getJSON( apiUrl, {'titles': videoTitle, 'prop': 'categories'}, function(data){ |
— | — | @@ -526,29 +526,43 @@ |
527 | 527 | } |
528 | 528 | } |
529 | 529 | } |
530 | | - } |
531 | | - // Else category not found add to category: |
532 | | - mw.getToken( apiUrl, videoTitle, function( token ) { |
533 | | - var request = { |
534 | | - 'action' : 'edit', |
535 | | - 'summary' : 'Added request for subtitles using [[Commons:MwEmbed|MwEmbed]]', |
536 | | - 'title' : videoTitle, |
537 | | - 'appendtext' : "\n[[Category:" + catName + "]]", |
538 | | - 'token': token |
539 | | - }; |
540 | | - mw.getJSON( apiUrl, request, function(data){ |
541 | | - if( data.edit && data.edit.newrevid){ |
542 | | - $dialog.html( gM('mwe-timedtext-request-subs-done', |
543 | | - apiUrl.replace('api.php', 'index.php') + |
544 | | - '?title=Category:' + catName.replace(' ', '_') |
545 | | - ) |
546 | | - ); |
547 | | - } else { |
| 530 | + } |
| 531 | + |
| 532 | + // Else category not found add to category: |
| 533 | + // check if the user is logged in: |
| 534 | + mw.getUserName( apiUrl, function( userName ){ |
| 535 | + if( !userName ){ |
| 536 | + $dialog.html( gM('mwe-timedtext-request-subs-fail') ); |
| 537 | + return ; |
| 538 | + } |
| 539 | + // Get an edit token: |
| 540 | + mw.getToken( apiUrl, videoTitle, function( token ) { |
| 541 | + if( !token ){ |
548 | 542 | $dialog.html( gM('mwe-timedtext-request-subs-fail') ); |
| 543 | + return ; |
549 | 544 | } |
550 | | - $dialog.dialog( 'option', 'buttons', buttonOk); |
| 545 | + var request = { |
| 546 | + 'action' : 'edit', |
| 547 | + 'summary' : 'Added request for subtitles using [[Commons:MwEmbed|MwEmbed]]', |
| 548 | + 'title' : videoTitle, |
| 549 | + 'appendtext' : "\n[[Category:" + catName + "]]", |
| 550 | + 'token': token |
| 551 | + }; |
| 552 | + // Do the edit request: |
| 553 | + mw.getJSON( apiUrl, request, function(data){ |
| 554 | + if( data.edit && data.edit.newrevid){ |
| 555 | + $dialog.html( gM('mwe-timedtext-request-subs-done', |
| 556 | + apiUrl.replace('api.php', 'index.php') + |
| 557 | + '?title=Category:' + catName.replace(' ', '_') |
| 558 | + ) |
| 559 | + ); |
| 560 | + } else { |
| 561 | + $dialog.html( gM('mwe-timedtext-request-subs-fail') ); |
| 562 | + } |
| 563 | + $dialog.dialog( 'option', 'buttons', buttonOk ); |
| 564 | + }); |
551 | 565 | }); |
552 | | - }); |
| 566 | + }); |
553 | 567 | }); |
554 | 568 | }; |
555 | 569 | buttons[ gM('mwe-cancel') ] = function(){ |
Index: branches/MwEmbedStandAlone/modules/TimedText/TimedText.i18n.php |
— | — | @@ -58,7 +58,7 @@ |
59 | 59 | 'mwe-timedtext-request-subs' => 'Request transcription', |
60 | 60 | 'mwe-timedtext-request-subs-desc' => 'Add a request for this video file to be transcribed', |
61 | 61 | 'mwe-timedtext-request-subs-done' => 'Transcription request added. [$1 See all transcribe requests]', |
62 | | - 'mwe-timedtext-request-subs-fail' => 'Failed to add transcription request', |
| 62 | + 'mwe-timedtext-request-subs-fail' => 'Failed to add transcription request, Are you logged in? ', |
63 | 63 | 'mwe-timedtext-request-already-done' => 'A transcription of this video has already been requested', |
64 | 64 | ); |
65 | 65 | |