r74874 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74873‎ | r74874 | r74875 >
Date:03:19, 17 October 2010
Author:dale
Status:deferred
Tags:
Comment:
check login info for add transcript request
Modified paths:
  • /branches/MwEmbedStandAlone/modules/TimedText/TimedText.i18n.php (modified) (history)
  • /branches/MwEmbedStandAlone/modules/TimedText/mw.TimedText.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/modules/TimedText/mw.TimedText.js
@@ -474,7 +474,7 @@
475475 } else {
476476 // Add a link to request timed text for this clip:
477477 $menu.append(
478 - $j.getLineItem( gM( 'mwe-timedtext-request-subs'), 'comment', function(){
 478+ $j.getLineItem( gM( 'mwe-timedtext-request-subs'), 'comment', function(){
479479 _this.getAddSubRequest();
480480 })
481481 );
@@ -510,7 +510,7 @@
511511 // Set the loadingSpinner:
512512 $j( this ).loadingSpinner();
513513 // Turn off buttons while loading
514 - $dialog.dialog( 'option', 'buttons', null );
 514+ $dialog.dialog( 'option', 'buttons', null );
515515
516516 // Check if the category does not already exist:
517517 mw.getJSON( apiUrl, {'titles': videoTitle, 'prop': 'categories'}, function(data){
@@ -526,29 +526,43 @@
527527 }
528528 }
529529 }
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 ){
548542 $dialog.html( gM('mwe-timedtext-request-subs-fail') );
 543+ return ;
549544 }
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+ });
551565 });
552 - });
 566+ });
553567 });
554568 };
555569 buttons[ gM('mwe-cancel') ] = function(){
Index: branches/MwEmbedStandAlone/modules/TimedText/TimedText.i18n.php
@@ -58,7 +58,7 @@
5959 'mwe-timedtext-request-subs' => 'Request transcription',
6060 'mwe-timedtext-request-subs-desc' => 'Add a request for this video file to be transcribed',
6161 '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? ',
6363 'mwe-timedtext-request-already-done' => 'A transcription of this video has already been requested',
6464 );
6565

Status & tagging log