1 /* the upload javascript
2 presently does hackery to work with Special:Upload page...
3 will be replaced with upload API once that is ready
7 "upload-enable-converter" : "Enable video converter (to upload source video not yet converted to theora format) <a href=\"http://commons.wikimedia.org/wiki/Commons:Firefogg\">more info</a>",
8 "upload-fogg_not_installed": "If you want to upload video consider installing <a href=\"http://firefogg.org\">firefogg.org</a>, <a href=\"http://commons.wikimedia.org/wiki/Commons:Firefogg\">more info</a>",
9 "upload-transcode-in-progress":"Doing Transcode & Upload (do not close this window)",
10 "upload-in-progress": "Upload in Progress (do not close this window)",
11 "upload-transcoded-status": "Transcoded",
12 "uploaded-status": "Uploaded",
13 "upload-select-file": "Select File...",
14 "wgfogg_wrong_version": "You have firefogg installed but its outdated, <a href=\"http://firefogg.org\">please upgrade</a> ",
15 "wgfogg_waring_ogg_upload": "You have selected an ogg file for conversion to ogg (this is probably unnessesary). Maybe disable the video converter?",
16 "wgfogg_waring_bad_extension" : "You have selected a file with an unsuported extension. <a href=\"http://commons.wikimedia.org/wiki/Commons:Firefogg#Supported_File_Types\">More help</a>",
17 "upload-stats-fileprogres": "$1 of $2",
19 "mv_upload_done" : "Your upload <i>should be</i> accessible <a href=\"$1\">here</a>",
20 "upload-unknown-size": "Unknown size",
22 "successfulupload" : "Successful upload",
23 "uploaderror" : "Upload error",
24 "uploadwarning": "Upload warning",
25 "unknown-error": "Unknown Error",
26 "return-to-form": "Return to form",
28 "file-exists-duplicate" : "This file is a duplicate of the following file",
29 "fileexists" : "A file with this name exists already, please check <b><tt>$1</tt></b> if you are not sure if you want to change it.",
30 "fileexists-thumb": "<center><b>Existing file</b></center>",
31 "ignorewarning" : "Ignore warning and save file anyway",
32 "file-thumbnail-no" : "The filename begins with <b><tt>$1</tt></b>"
35 var default_upload_options
= {
37 'upload_done_action':'redirect',
41 var mediaWikiUploadHelper = function(iObj
){
42 return this.init( iObj
);
44 mediaWikiUploadHelper
.prototype = {
45 init:function( iObj
){
47 js_log('init uploader');
50 for(var i
in default_upload_options
){
54 this[i
] = default_upload_options
[i
];
57 //check if we are on the uplaod page:
58 this.on_upload_page
= ( wgPageName
== "Special:Upload")?true:false;
59 js_log('f:mvUploader: onuppage:' + this.on_upload_page
);
64 //if we are not on the upload page grab the upload html via ajax:
65 //@@todo refactor with
66 if( !_this
.on_upload_page
){
67 $j
.get(wgArticlePath
.replace(/\$1/, 'Special:Upload'), {}, function(data
){
69 $j
.getScript( stylepath
+ '/common/upload.js', function(){
70 //really _really_ need an "upload api"!
71 wgAjaxUploadDestCheck
= true;
72 wgAjaxLicensePreview
= false;
73 wgUploadAutoFill
= true;
74 //strip out inline scripts:
75 sp
= data
.indexOf('<div id="content">');
76 se
= data
.indexOf('<!-- end content -->');
77 if(sp
!=-1 && se
!=-1){
78 result_data
= data
.substr(sp
, (se
-sp
) ).replace('/\<script\s.*?\<\/script\>/gi',' ');
79 js_log("trying to set: " + result_data
);
80 //$j('#'+_this.target_div).html( result_data );
82 _this
.setupFirefogg();
86 //@@could check if firefogg is enabled here:
87 _this
.setupFirefogg();
88 //if only want httpUploadFrom help enable it here:
94 * setupBaseUpInterface supports intefaces for progress indication if the browser supports it
95 * also sets up ajax progress updates for http posts
98 setupBaseUpInterface:function(){
99 //check if this feature is not false (we want it on by default (null) instances that don't have the upload api or any modifications)
100 this.upForm
= new mvBaseUploadInterface( {
101 'api_url' : this.api_url
,
102 'parent_uploader': this
105 this.upForm
.setupForm();
107 setupFirefogg:function(){
109 //add firefogg html if not already there: ( same as $wgEnableFirebug added in SpecialUpload.php )
110 if( $j('#fogg-video-file').length
==0 ){
111 js_log('add addFirefoggHtml');
112 _this
.addFirefoggHtml();
114 js_log('firefogg already init:');
116 //set up the upload_done action
117 //redirect if we are on the upload page
118 //do a callback if in called from gui)
119 var intFirefoggObj
= ( this.on_upload_page
)?
120 {'upload_done_action':'redirect'}:
121 {'upload_done_action':function( rTitle
){
122 js_log( 'add_done_action callback for uploader' );
123 //call the parent insert resource preview
124 _this
.upload_done_action( rTitle
);
129 intFirefoggObj
['api_url'] = _this
.api_url
;
131 js_log('new mvFirefogg extends mvUploader (this)');
132 this.fogg
= new mvFirefogg( intFirefoggObj
);
133 this.fogg
.setupForm();
135 //same add code as specialUpload if($wgEnableFirefogg){
136 addFirefoggHtml:function(){
137 var itd_html
= $j('#mw-upload-table .mw-input:first').html();
138 $j('#mw-upload-table .mw-input').eq(0).html('<div id="wg-base-upload">' + itd_html
+ '</div>');
139 //add in firefogg control
140 $j('#wg-base-upload').after('<p id="fogg-enable-item" >' +
141 '<input style="display:none" id="fogg-video-file" name="fogg-video-file" type="button" value="' + gM('upload-select-file') + '">' +
142 "<span id='wgfogg_not_installed'>" +
143 gM('upload-fogg_not_installed') +
145 "<span class='error' id='wgfogg_wrong_version' style='display:none;'><br>" +
146 gM('wgfogg_wrong_version') +
149 "<span class='error' id='wgfogg_waring_ogg_upload' style='display:none;'><br>"+
150 gM('wgfogg_waring_ogg_upload') +
153 "<span class='error' id='wgfogg_waring_bad_extension' style='display:none;'><br>"+
154 gM('wgfogg_waring_bad_extension') +
157 "<span id='wgfogg_installed' style='display:none' >"+
158 '<input id="wgEnableFirefogg" type="checkbox" name="wgEnableFirefogg" >' +
159 gM('upload-enable-converter') +