r58739 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58738‎ | r58739 | r58740 >
Date:08:45, 8 November 2009
Author:j
Status:deferred
Tags:
Comment:
* use loadGM for interface strings
* hide default toolbar and only show add subtitle button
Modified paths:
  • /trunk/phase3/js2/mwEmbed/libTimedText/mvTimeTextEdit.js (modified) (history)

Diff [purge]

Index: trunk/phase3/js2/mwEmbed/libTimedText/mvTimeTextEdit.js
@@ -8,6 +8,13 @@
99
1010 var mvTimedTextEdit = {};
1111
 12+loadGM({
 13+ "mwe-add-subs-file" : "Add/Replace Subtitle",
 14+ "mwe-add-subs-file-title": "Select Subtitle to upload",
 15+ "mwe-error-only-srt" : "Only srt files can be uploaded right now."
 16+})
 17+
 18+
1219 js2AddOnloadHook( function() {
1320 function getSubtitle(f) {
1421 var name = f.files[0].name;
@@ -33,35 +40,35 @@
3441 languageSelect += '<option value="'+code+'">'+language+'('+code+')</option>';
3542 }
3643 languageSelect += '/</select>';
37 - var cBtn = {};
38 - cBtn[ gM('mwe-cancel') ] = function(){
39 - $j(this).dialog('close');
40 - }
41 - cBtn[ gM('mwe-ok') ] = function(){
42 - var file = $j('#timed_text_file_upload');
43 - var langKey = file[0].files[0].name.split('.');
44 - var extension = langKey.pop();
45 - langKey = langKey.pop();
46 - var mimeTypes = {
47 - 'srt': 'text/x-srt',
48 - 'cmml': 'text/cmml'
49 - }
50 - if( !mimeTypes[ extension ] ){
51 - js_log('Error: unknown extension:'+ extension);
52 - }
53 - //get language from form
54 - langKey = $j('#timed_text_language').val();
 44+ var cBtn = {};
 45+ cBtn[ gM('mwe-cancel') ] = function(){
 46+ $j(this).dialog('close');
 47+ }
 48+ cBtn[ gM('mwe-ok') ] = function(){
 49+ var file = $j('#timed_text_file_upload');
 50+ var langKey = file[0].files[0].name.split('.');
 51+ var extension = langKey.pop();
 52+ langKey = langKey.pop();
 53+ var mimeTypes = {
 54+ 'srt': 'text/x-srt',
 55+ 'cmml': 'text/cmml'
 56+ }
 57+ if( !mimeTypes[ extension ] ){
 58+ js_log('Error: unknown extension:'+ extension);
 59+ }
 60+ //get language from form
 61+ langKey = $j('#timed_text_language').val();
5562
56 - if(extension == "srt") {
57 - var srt = getSubtitle(file[0]);
58 - $j(this).html("saving...");
59 - $j('.ui-dialog-buttonpane').remove();
 63+ if(extension == "srt") {
 64+ var srt = getSubtitle(file[0]);
 65+ $j(this).html("saving...");
 66+ $j('.ui-dialog-buttonpane').remove();
6067
61 - var editToken = $j('input[name=wpEditToken]').val();
62 - var title = wgTitle.split('.');
63 - title.pop();
64 - title.pop();
65 - title = title.join('.') + '.' + langKey + '.srt';
 68+ var editToken = $j('input[name=wpEditToken]').val();
 69+ var title = wgTitle.split('.');
 70+ title.pop();
 71+ title.pop();
 72+ title = title.join('.') + '.' + langKey + '.srt';
6673 do_api_req({
6774 'data': {
6875 'action' : 'edit',
@@ -75,24 +82,28 @@
7683 $j(dialog).dialog('close');
7784 }}(this)
7885 );
79 - } else {
80 - $j(this).html("error only srt works right now.");
81 - }
82 - }
83 - $j.addDialog("Select Subtitle to upload",
84 - '<input type="file" id="timed_text_file_upload"></input><br>' + languageSelect,
 86+ } else {
 87+ $j(this).html(gM("mwe-error-only-srt"));
 88+ }
 89+ }
 90+ $j.addDialog(gM("mwe-add-subs-file-title"),
 91+ '<input type="file" id="timed_text_file_upload"></input><br />' + languageSelect,
8592 cBtn);
8693 $j('#timed_text_file_upload').change(function(ev) {
87 - var langKey = this.files[0].name.split('.');
88 - var extension = langKey.pop();
89 - langKey = langKey.pop();
90 - $j('#timed_text_language').val( langKey );
 94+ var langKey = this.files[0].name.split('.');
 95+ var extension = langKey.pop();
 96+ langKey = langKey.pop();
 97+ $j('#timed_text_language').val( langKey );
9198 });
9299 });
93100 }
 101+ $j('#toolbar').hide();
 102+ var ttoolbar = $j('<div>');
 103+ $j('#toolbar').after(ttoolbar);
 104+
94105 var button = $j('<button>');
95106 button.click(uploadSubtitles)
96 - button.text("Upload Subtitle");
97 - $j('#toolbar').append(button);
 107+ button.text(gM("mwe-add-subs-file"));
 108+ ttoolbar.append(button);
98109 });
99110

Status & tagging log