/*
* mwProxy js2 page system.
*
-* invokes the apiProxy system
+* Invokes the apiProxy system
*/
/*
- * since this is proxy server set a pre-append debug flag to know which debug msgs are coming from where
+ * Since this is proxy server set a pre-append debug flag to know which debug msgs are coming from where
*/
$mw.conf['debug_pre'] = 'Proxy';
if( !mwApiProxyConfig )
var mwApiProxyConfig = {};
-//The default mwApiProxyConfig config
-//(presently hard coded but should read from user and site config)
+// The default mwApiProxyConfig config
+// (presently hard coded but should read from user and site config)
var mwApiProxyDefaultConfig = {
'master_whitelist' : [ 'en.wikipedia.org', 'localhost', '127.1.1.100' ],
'master_blacklist' : []
};
-//user_white_list should also be checked and configured at runtime.
+
+// User white_list should also be checked and configured at runtime.
js2AddOnloadHook( function() {
//build our configuration from the default and mwApiProxyConfig vars
mwApiProxyConfig = $j.extend(true, mwApiProxyDefaultConfig, mwApiProxyConfig);
// kind of tricky, it would be nice to use run on ready "loader" call here
var didWikiEditorBind = false;
- //setup the drag drop binding (will only work for html5 upload browsers)
+ //Set-up the drag drop binding (will only work for html5 upload browsers)
//$j('textarea#wpTextbox1').dragFileUpload();
//set up the add-media-wizard binding:
}
);
}
- //add to old toolbar if wikiEditor did not remove '#toolbar' from the page:
+ //Add to old toolbar if wikiEditor did not remove '#toolbar' from the page:
setTimeout(function(){
if( $j('#btn-add-media-wiz').length == 0 && $j( '#toolbar' ).length != 0 ){
js_log(' old toolbar bind:');
);
}else{
js_log('failed to bind via build section bind via target:');
- //make sure the wikieditor got binded:
+ //Make sure the wikieditor got binded:
if( !didWikiEditorBind )
$j(".tool[rel='file']").unbind().addMediaWiz( amwConf );
}
border:medium none;
}
</style>
- <!-- <script type="text/javascript" src="../mv_embed.js?debug=true"></script> -->
- <script type="text/javascript" src="../jsScriptLoader.php?class=window.jQuery,mv_embed,remoteSearchDriver,$j.ui,$j.ui.resizable,$j.ui.draggable,$j.ui.dialog,$j.ui.tabs,$j.ui.sortable,$j.cookie,baseRemoteSearch&urid=1257728132531&debug=true&uselang=en"></script>
+ <script type="text/javascript" src="../mv_embed.js?debug=true"></script>
+ <!--<script type="text/javascript" src="../jsScriptLoader.php?class=window.jQuery,mv_embed,remoteSearchDriver,$j.ui,$j.ui.resizable,$j.ui.draggable,$j.ui.dialog,$j.ui.tabs,$j.ui.sortable,$j.cookie,baseRemoteSearch&urid=1257728132531&debug=true&uselang=en"></script> -->
<script type="text/javascript">
js2AddOnloadHook(function(){
$j('#add_media_link').addMediaWiz( {
* This core jsScriptLoader class provides the script loader functionality
* @file
*/
-// Check if we are being invoked in a MediaWiki context or stand alone usage:
-//setup the script local script cache directory (has to be hard coded rather than config based for fast non-mediawiki config hits
+
+//Setup the script local script cache directory (has to be hard coded rather than config based for fast non-mediawiki config hits
$wgScriptCacheDirectory = realpath( dirname( __FILE__ ) ) . '/php/script-cache';
+// Check if we are being invoked in a MediaWiki context or stand alone usage:
if ( !defined( 'MEDIAWIKI' ) && !defined( 'MW_CACHE_SCRIPT_CHECK' ) ){
// Load noMediaWiki helper for quick cache result
$myScriptLoader = new jsScriptLoader();
if( $myScriptLoader->outputFromCache() )
exit();
- //else load up all the config and do normal stand alone ScriptLoader process:
+ //Else load up all the config and do normal stand alone ScriptLoader process:
require_once( realpath( dirname( __FILE__ ) ) . '/php/noMediaWikiConfig.php' );
$myScriptLoader->doScriptLoader();
}
return substr($str, 0, $inx['s']-1) . $translated . substr($str, $inx['e']+1);
}
}
- //return the js str unmodified if we did not transform with the localization.
+ //return the js str unmodified if we did not transform with the localisation.
return $str;
}
static public function getLoadGmIndex( $str ){
readfile( $this->filename );
return true;
}
- //output without gzip:
+ // Output without gzip:
if ( substr( $this->filename, - 3 ) == '.gz' ) {
readgzfile( $this->filename );
} else {
$j('#multiple_file_input').remove();
- $j('body').append('<div title="' + gM('mwe-upload-multi', fileCount) + '" '+
- 'style="position:absolute;bottom:5em;top:3em;right:0px;left:0px" '+
- 'id="multiple_file_input">'+
- '</div>');
+ $j('body').append('<div title="' + gM('mwe-upload-multi', fileCount) + '" ' +
+ 'style="position:absolute;bottom:5em;top:3em;right:0px;left:0px" ' +
+ 'id="multiple_file_input">' +
+ '</div>'
+ );
var cBtn = {};
return this.init( iObj );
}
var default_mvAdvFirefogg_config = {
- //which config groups to include
+ // Which config groups to include
'config_groups' : ['preset', 'range', 'quality', 'meta', 'advVideo', 'advAudio'],
- //if you want to load any custom presets must follow the mvAdvFirefogg.presetConf json outline below
+ // If you want to load any custom presets must follow the mvAdvFirefogg.presetConf json outline below
'custom_presets' : {},
- //any firefog config properties that may need to be excluded from options
+ // Any firefog config properties that may need to be excluded from options
'exclude_settings' : [],
- //the control container (where we put all the controls)
+ // The control container (where we put all the controls)
'target_control_container':false
}
//the global groupings and titles for for configuration options :
config_groups : [ 'preset', 'range', 'quality', 'meta', 'advVideo', 'advAudio'],
//list of pre-sets:
+
//local instance encoder config:
-default_local_settings:{
- 'd' : 'webvideo',
- 'type' : 'select',
- 'selectVal': ['webvideo'],
- 'group' : "preset",
- 'pSet' : {
- 'custom':{
- 'descKey': 'fogg-preset-custom',
- 'conf': {}
- },
- 'webvideo': {
- 'desc': gM('fogg-webvideo-desc'),
- 'conf': {
- 'maxSize' : 400,
- 'videoBitrate' : 544,
- 'audioBitrate' : 96,
- 'noUpscaling' : true,
- }
- },
- 'savebandwith': {
- 'desc': gM('fogg-savebandwith-desc'),
- 'conf': {
- 'maxSize' : 200,
- 'videoBitrate' : 164,
- 'audioBitrate' : 32,
- 'samplerate' : 22050,
- 'framerate' : 15,
- 'channels' : 1,
- 'noUpscaling' : true
- }
- },
- 'hqstream':{
- 'desc': gM('fogg-highquality-desc'),
- 'conf': {
- 'maxSize' : 1080,
- 'videoQuality' : 6,
- 'audioQuality' : 3,
- 'noUpscaling' : true,
- }
- },
- }
-},
+ default_local_settings:{
+ 'd' : 'webvideo',
+ 'type' : 'select',
+ 'selectVal': ['webvideo'],
+ 'group' : "preset",
+ 'pSet' : {
+ 'custom':{
+ 'descKey': 'fogg-preset-custom',
+ 'conf': {}
+ },
+ 'webvideo': {
+ 'desc': gM('fogg-webvideo-desc'),
+ 'conf': {
+ 'maxSize' : 400,
+ 'videoBitrate' : 544,
+ 'audioBitrate' : 96,
+ 'noUpscaling' : true,
+ }
+ },
+ 'savebandwith': {
+ 'desc': gM('fogg-savebandwith-desc'),
+ 'conf': {
+ 'maxSize' : 200,
+ 'videoBitrate' : 164,
+ 'audioBitrate' : 32,
+ 'samplerate' : 22050,
+ 'framerate' : 15,
+ 'channels' : 1,
+ 'noUpscaling' : true
+ }
+ },
+ 'hqstream':{
+ 'desc': gM('fogg-highquality-desc'),
+ 'conf': {
+ 'maxSize' : 1080,
+ 'videoQuality' : 6,
+ 'audioQuality' : 3,
+ 'noUpscaling' : true,
+ }
+ },
+ }
+ },
local_settings: {},
//core firefogg default encoder configuration
//maintain source video aspect ratio:
if(_this.getClassId(this, 'slider_') == 'width'){
var hv = parseInt((_this.sourceFileInfo.video[0]['height']/_this.sourceFileInfo.video[0]['width'])* ui.value );
- //update the height value: the new hight value is > that orginal the slider:
+ //update the height value: the new height value is > that original the slider:
if(hv > _this.updateInterfaceValue('height', hv))
return false;
}
if(_this.getClassId(this, 'slider_') == 'height'){
var wv = parseInt((_this.sourceFileInfo.video[0]['width']/_this.sourceFileInfo.video[0]['height'])* ui.value );
- //update the height value: the new hight value is > that orginal the slider:
+ //update the height value: the new height value is > that original the slider:
if(wv > _this.updateInterfaceValue('width', wv))
return false;
}
if( this.encoder_settings['passthrough'] ){
js_log("in passthrough mode (hide control)");
//hide all controls
- //dispaly not encodable video
+ //display not encodable video
$j(this.target_control_container).hide('slow');
$j(this.target_passthrough_mode).show('slow');
return ;
}
setValues(k, val, maxVal);
}
- //audio stream settings, assumes for now thare is only one stream
+ //audio stream settings, assumes for now there is only one stream
for(var i in this.sourceFileInfo.audio[0]){
var val = this.sourceFileInfo.audio[0][i];
var k = false;
/**
- * the base Upload Interface for uploading.
+ * The base Upload Interface for uploading.
*
- * this base uploader is optionally extended by Firefogg
+ * This base upload class is optionally extended by Firefogg
*
- * @@todo: checkme: gM 'thumbnail-more' is used; only defined in MediaWiki core. Will that work properly?
*/
loadGM({
"mwe-upload-transcode-in-progress" : "Transcode and upload in progress (do not close this window)",
'done_upload_cb': null,
'target_edit_from':null,
- //default upload mode is 'api' but if no api_url will try tp post
+ // Default upload mode is 'api'
'upload_mode': 'api'
}
}
mvBaseUploadInterface.prototype = {
parent_uploader:false,
- formData:{}, //the form to be submitted
+ formData:{}, // The form data to be submitted
warnings_sessionkey:null,
chunks_supported:true,
form_post_override:false,
http_copy_upload : false,
action_done:false,
- //the edit token:
+ // The edit token:
etoken:false,
init: function( iObj ){
if(!iObj)
iObj = {};
- //inherit iObj properties:
+ // Inherit iObj properties:
$j.extend( this, default_bui_options, iObj);
js_log( "init mvBaseUploadInterface:: " + this.api_url);
},
setupForm:function(){
js_log("Base::setupForm::");
var _this = this;
- //set up the local pointer to the edit form:
+ // Set up the local pointer to the edit form:
_this.editForm = _this.getEditForm();
if( _this.editForm ){
- //if in api re-map the upload form to api: (we have to do this BEFORE the users selects a file)
+ // If in api re-map the upload form to api: (we have to do this BEFORE the users selects a file)
if( _this.upload_mode == 'api'){
_this.doRemapFormToApi();
}
- //set up the org_onsubmit if not set:
+ // Set up the org_onsubmit if not set:
if( typeof( _this.org_onsubmit ) == 'undefined' && _this.editForm.onsubmit )
_this.org_onsubmit = _this.editForm.onsubmit;
- //set up the submit action:
+ // Set up the submit action:
$j( _this.editForm ).submit( function(){
js_log('setupForm.onSubmit:');
- //set the upload mode:
+ // Set the upload mode:
_this.setWgUploadSelect();
- //run the original onsubmit (if not run yet set flag to avoid excessive chaining )
+ // Run the original onsubmit (if not run yet set flag to avoid excessive chaining )
if( typeof( _this.org_onsubmit ) == 'function' ){
if( ! _this.org_onsubmit() ){
//error in org submit return false;
return false;
}
}
- //check for post action override:
+ // Check for post action override:
if( _this.form_post_override ){
js_log('form_post_override is true do form proccesing:');
return true;
}
- //get the input form data in flat json:
+ // Get the input form data in flat json:
js_log('update formData::');
var tmpAryData = $j( _this.editForm ).serializeArray();
for(var i=0; i < tmpAryData.length; i++){
if( tmpAryData[i]['name'] )
_this.formData[ tmpAryData[i]['name'] ] = tmpAryData[i]['value'];
}
- //put into a try catch so we are sure to return false:
+ // Put into a try catch so we are sure to return false:
try{
debugger;
- //get a clean loader:
+ // Get a clean loader:
_this.dispProgressOverlay();
- //for some unknown reason we have to drop down the #p-search z-index:
+ // For some unknown reason we have to drop down the #p-search z-index:
$j('#p-search').css('z-index', 1);
- //select upload mode:
+ // Select upload mode:
_this.detectUploadMode();
}catch(e){
js_log('::error in dispProgressOverlay or detectUploadMode');
}
- //don't submit the form we will do the post in ajax
+ // Don't submit the form we will do the post in ajax
return false;
});
}
detectUploadMode:function( callback ){
var _this = this;
js_log('detectUploadMode::' + _this.upload_mode);
- //check the upload mode:
+ // Check the upload mode:
if( _this.upload_mode == 'autodetect' ){
js_log('detectUploadMode::' + _this.upload_mode + ' api:' + _this.api_url);
if( ! _this.api_url )
_this.doUploadSwitch();
}
},
- //@@NOTE this could probably be depricated to just have a special:upload page that uses api keys?
- // or maybe its usefull to seperate js and non-js submits
+ //@@NOTE this could probably be deprecated in favor of automated input
doRemapFormToApi:function(){
var _this = this;
if( !_this.api_url )
};
var default_firefogg_options = {
- //what to do when finished uploading
+ // What to do when finished uploading
'done_upload_cb':false,
- //if firefoog is enabled
+ // If firefoog is enabled
'fogg_enabled':false,
- //the api url to upload to
+ // The api url to upload to
'api_url':null,
- //the passthrough flag (enables un-modified uploads)
+ // The passthrough flag (enables un-modified uploads)
'passthrough': false,
- //if we will be showing the encoder interface
+ // If we will be showing the encoder interface
'encoder_interface': false,
- //if we want to limit the library functionality to "only firefoog" (no upload or progress bars)
+ // If we want to limit the library functionality to "only firefoog" (no upload or progress bars)
'only_fogg': false,
-
- //callbacks:
+ // Callbacks:
'new_source_cb': false, //called on source name update passes along source name
- //target control container or form (can't be left null)
+ // Target control container or form (can't be left null)
'selector': '',
- //if not rewriting a form we are encoding local.
+ // If not rewriting a form we are encoding local.
'form_rewrite': false,
- //taget buttons:
+ // Target buttons:
'target_btn_select_file': false,
'target_btn_select_new_file': false,
//'target_btn_select_url': false,
-
'target_btn_save_local_file': false,
'target_input_file_name': false,
- //target install descriptions
+ // Target install descriptions
'target_check_for_fogg': false,
'target_installed': false,
'target_please_install': false,
'target_use_latest_fox': false,
- //status:
+
+ // Status:
'target_passthrough_mode':false,
- //if firefogg should take over the form submit action
+ // If firefogg should take over the form submit action
'firefogg_form_action':true,
- //if we should show a preview of encoding progress
+ // If we should show a preview of encoding progress
'show_preview':false
}
if(!iObj)
iObj = {};
- //if we have no api_url set upload to "post"
+ // If we have no api_url set upload to "post"
if(!iObj.api_url)
iObj.upload_mode = 'post';
- //inherit iObj properties:
+ // Inherit iObj properties:
for(var i in default_firefogg_options){
if(iObj[i]){
this[i] = iObj[i];
this[i] = default_firefogg_options[i];
}
}
- //check if we want to limit the usage:
+ // Check if we want to limit the usage:
if(!this.only_fogg){
var myBUI = new mvBaseUploadInterface( iObj );
- //standard extends code:
+ // Standard extends code:
for(var i in myBUI){
if(this[i]){
this['pe_'+ i] = myBUI[i];
_this.form_rewrite = true;
}
}
- //check if we are rewriting an input or a form:
+ // Check if we are rewriting an input or a form:
if( this.form_rewrite ){
this.setupForm();
}else{
this.doControlBindings();
}
- //doRewrite is done:
+ // doRewrite is done:
if(callback)
callback();
},
$j.each(default_firefogg_options, function(target, na){
if(target.substring(0, 6)=='target'){
//js_log('check for target html: ' + target);
- //check for the target if missing add to the output:
+ // Check for the target if missing add to the output:
if( _this[target] === false){
out += _this.getTargetHtml(target) + ' ';
- //update the target selector
+ // Update the target selector
_this[target] = _this.selector + ' .' + target;
}
}
doControlBindings: function(){
var _this = this;
- //hide all targets:
+ // Hide all targets:
var hide_target_list='';
var coma='';
$j.each( default_firefogg_options, function(target, na) {
coma=',';
}
});
+
+ // Hide all but check-for-fogg
$j( hide_target_list ).hide();
- //now that the proper set of items has been hiiden show:
+ // Now that the proper set of items has been hiiden show:
$j( _this.selector ).show();
-
-
- //hide all but check-for-fogg
- //check for firefogg
+
+ // Check for firefogg
if( _this.firefoggCheck() ){
- //if rewriting the form lets keep the text input around:
+ // If rewriting the form lets keep the text input around:
if( _this.form_rewrite )
$j( _this.target_input_file_name ).show();
- //show select file:
+ // Show select file:
$j( this.target_btn_select_file ).unbind(
).attr('disabled', false
).css({'display':'inline'}
})
}else{
- //first check firefox version:
+ // First check firefox version:
if(!( $j.browser.mozilla && $j.browser.version >= '1.9.1' )) {
js_log( 'show use latest::' + _this.target_use_latest_fox );
if( _this.target_use_latest_fox ){
return ;
}
- //if rewriting form use upload msg text
+ // If rewriting form use upload msg text
var upMsg = (_this.form_rewrite) ? gM('fogg-for_improved_uplods') : '';
$j( _this.target_please_install ).html( upMsg + gM('fogg-please_install', _this.getOSlink() )).css('padding', '10px').show();
}
- //setup the target save local file bindins:
+ // Setup the target save local file bindings:
$j( _this.target_btn_save_local_file ).unbind().click(function(){
_this.saveLocalFogg();
});
return false;
}
},
- //assume input target
+ // Assume input target
setupForm: function(){
js_log('firefogg::setupForm::');
//to parent form setup if we want http updates
this.pe_setupForm();
}
- //check if we have firefogg (if not just add a link and stop proccessing)
+ // Check if we have firefogg (if not just add a link and stop processing)
if( !this.firefoggCheck() ){
//add some status indicators if not provided:
if(!this.target_please_install){
$j(this.selector).after ( this.getTargetHtml('target_use_latest_fox') );
this.target_use_latest_fox = this.selector + ' ~ .target_use_latest_fox';
}
- //update download link:
+ // Update download link:
this.doControlBindings();
return ;
}
- //change the file browser to type text: (can't directly change input from "file" to "text" so longer way:
+ // Change the file browser to type text: (can't directly change input from "file" to "text" so longer way:
var inTag = '<input ';
$j.each($j(this.selector).get(0).attributes, function(i, attr){
var val = attr.value;
$j(this.selector).replaceWith(inTag);
this.target_input_file_name = 'input[name=' + $j(this.selector).attr('name') + ']';
- //update the selector to the control target:
+
+ // Update the selector to the control target:
this.selector = '#' + $j(this.selector).attr('name') + "_fogg-control";
this.doControlHTML();
- //check for the other inline status indicator targets:
- //update the bindings:
+ // Update the bindings:
this.doControlBindings();
},
- //do firefogg specific additions:
+ // Do firefogg specific additions:
dispProgressOverlay:function(){
this.pe_dispProgressOverlay();
- //if we are uploading video (not in passthrough mode show preview button)
+ // If we are uploading video (not in passthrough mode show preview button)
if( this.fogg_enabled && ! this.encoder_settings['passthrough'] && ! this.http_copy_upload ){
this.doPreviewControl();
}
},
doPreviewControl:function(){
var _this = this;
- //prepend preview (if fogg)
+ // Prepend preview (if fogg)
$j('#upProgressDialog').append(
'<div style="clear:both;height:3em"/>'+
$j.btnHtml(gM('fogg-preview'), 'fogg_preview', 'triangle-1-e') +
'<canvas style="margin:auto;" id="fogg_preview_canvas" />' +
'</div>'
);
- //set initial state
+ // Set initial state
if( _this.show_preview == true){
$j('#fogg_preview_canvas').show();
}else{
- //update icon:
+ // Update icon:
$j(this).children('.ui-icon')
.removeClass('ui-icon-triangle-1-s')
.addClass('ui-icon-triangle-1-e');
- //update text:
+ // Update text:
$j(this).children('.btnText').text( gM('fogg-preview') );
$j('#fogg_preview_canvas').hide();
}
- //apply preview binding:
+ // Apply preview binding:
$j('#upProgressDialog .fogg_preview').btnBind().click( function(){
js_log("click .foog_preview" + $j(this).children('.ui-icon').attr('class') );
- //check state:
+ // Check state:
if( $j(this).children('.ui-icon').hasClass('ui-icon-triangle-1-e') ){
_this.show_preview = true;
- //update icon:
+ // Update icon:
$j(this).children('.ui-icon')
.removeClass('ui-icon-triangle-1-e')
.addClass('ui-icon-triangle-1-s');
- //update text
+ // Update text
$j(this).children('.btnText').text( gM('fogg-hidepreview') );
- //show preview window
+ // Show preview window
$j('#fogg_preview_canvas').show('fast');
}else{
_this.show_preview = false;
- //update icon:
+ // Update icon:
$j(this).children('.ui-icon')
.removeClass('ui-icon-triangle-1-s')
.addClass('ui-icon-triangle-1-e');
- //update text:
+ // Update text:
$j(this).children('.btnText').text( gM('fogg-preview') );
$j('#fogg_preview_canvas').hide('slow');
}
- //don't follow the #
+ // Don't follow the #
return false;
});
},
doRenderPreview:function(){
var _this = this;
- //set up the hidden video to pull frames from:
+ // Set up the hidden video to pull frames from:
if( $j('#fogg_preview_vid').length == 0 )
$j('body').append('<video id="fogg_preview_vid" style="display:none"></video>');
var v = $j('#fogg_preview_vid').get(0);
}
var previewI=null;
function preview() {
- //initialize the video if not setup already:
+ // Initialize the video if not setup already:
var v = $j('#fogg_preview_vid').get(0);
if( v.src != _this.fogg.previewUrl ){
js_log('init preview with url:' + _this.fogg.previewUrl);
v.src = _this.fogg.previewUrl;
- //set the video to seek to the end of the video
+ // Set the video to seek to the end of the video
v.removeEventListener("loadedmetadata", seekToEnd, true);
v.addEventListener("loadedmetadata", seekToEnd, true);
- //render a frame once seek is complete:
+ // Render a frame once seek is complete:
v.removeEventListener("seeked", getFrame, true);
v.addEventListener("seeked", getFrame, true);
- //refresh the video duration/meta:
+ // Refresh the video duration/meta:
clearInterval(previewI);
var previewI = setInterval(function(){
if (_this.fogg.status() != "encoding"){
getEditForm:function(){
if( this.target_edit_from )
return this.pe_getEditForm();
- //else try to get the parent "from" of the file selector:
+ // Else try to get the parent "from" of the file selector:
return $j(this.selector).parents('form:first').get(0);
},
selectFogg:function(){
selectFoggActions:function(){
var _this = this;
js_log('videoSelectReady');
- //if not already hidden hide select file and show "select new":
+ // If not already hidden hide select file and show "select new":
$j(_this.target_btn_select_file).hide();
- //show and setup binding for select new file:
+ // Show and setup binding for select new file:
$j(_this.target_btn_select_new_file).show().unbind().click(function(){
//create new fogg instance:
_this.fogg = new Firefogg();
_this.selectFogg();
});
- //update if we are in passthrough mode or going to encode
+ // Update if we are in passthrough mode or going to encode
if( _this.fogg.sourceInfo && _this.fogg.sourceFilename ){
//update the source status
try{
js_error('error could not parse fogg sourceInfo');
}
- //now setup encoder settings based source type:
+ // Now setup encoder settings based source type:
_this.autoEncoderSettings();
- //if set to passthough update the interface (if not a form)
+ // If set to passthough update the interface (if not a form)
if(_this.encoder_settings['passthrough'] == true && !_this.form_rewrite){
$j(_this.target_passthrough_mode).show();
}else{
$j(_this.target_passthrough_mode).hide();
- //if set to encoder expose the encode button:
+ // If set to encoder expose the encode button:
if( !_this.form_rewrite ){
$j(_this.target_btn_save_local_file).show();
}
}
//~otherwise the encoding will be triggered by the form~
- //do source name update callback:
+ // Do source name update callback:
js_log(" should update: " + _this.target_input_file_name + ' to: ' + _this.fogg.sourceFilename );
$j(_this.target_input_file_name).val(_this.fogg.sourceFilename).show();
}
},
saveLocalFogg:function(){
- //request target location:
+ // Request target location:
if(this.fogg){
if(!this.fogg.saveVideoAs() )
return false;
- //we have set a target now call the encode:
+ // We have set a target now call the encode:
this.doEncode();
}
},
- //simple auto encoder settings just enable passthough if file is not video or > 480 pixles tall
+ // Simple auto encoder settings just enable passthough if file is not video or > 480 pixles tall
autoEncoderSettings:function(){
var _this = this;
- //grab the extension:
+ // Grab the extension:
var sf = _this.fogg.sourceFilename;
var ext = '';
if( sf.lastIndexOf('.') != -1)
ext = sf.substring( sf.lastIndexOf('.')+1 ).toLowerCase();
- //set to passthrough to true by default (images, arbitrary files that we want to send with http chunks)
+ // Set to passthrough to true by default (images, arbitrary files that we want to send with http chunks)
this.encoder_settings['passthrough'] = true;
- //see if we have video or audio:
+ // See if we have video or audio:
if( _this.isSourceAudio() || _this.isSourceVideo() )
_this.encoder_settings['passthrough'] = false;
- //special case see if we already have ogg video:
+ // Special case see if we already have ogg video:
if( _this.isOggFormat() )
_this.encoder_settings['passthrough'] = true;
},
getProgressTitle:function(){
js_log("fogg:getProgressTitle f:" + this.fogg_enabled + ' rw:' + this.form_rewrite);
- //return the parent if we don't have fogg turned on:
+ // Return the parent if we don't have fogg turned on:
if(! this.fogg_enabled || !this.firefogg_form_action )
return this.pe_getProgressTitle();
if( !this.form_rewrite )
return gM('fogg-transcoding');
- //else return our upload+transcode msg:
+ // Else return our upload+transcode msg:
return gM('mwe-upload-transcode-in-progress');
},
doUploadSwitch:function(){
var _this = this;
js_log("firefogg: doUploadSwitch:: " + this.fogg_enabled + ' up mode:' + _this.upload_mode);
- //make sure firefogg is enabled otherwise do parent UploadSwich:
+ // Make sure firefogg is enabled otherwise do parent UploadSwich:
if( !this.fogg_enabled || !this.firefogg_form_action )
return _this.pe_doUploadSwitch();
- //check what mode to use firefogg in:
+ // Check what mode to use firefogg in:
if( _this.upload_mode == 'post' ){
_this.doEncode();
}else if( _this.upload_mode == 'api' ){ //if api mode and chunks supported do chunkUpload
js_error( 'Error: unrecongized upload mode: ' + _this.upload_mode );
}
},
- //doChunkUpload does both uploading and encoding at the same time and uploads one meg chunks as they are ready
+ /**
+ * doChunkUpload
+ * does both uploading and encoding at the same time and uploads one meg chunks
+ */
doChunkUpload : function(){
js_log('firefogg::doChunkUpload');
var _this = this;
_this.action_done = false;
- //extension should already be ogg but since its user editable,
- //check again
- //we are transcoding so we know it will be an ogg
- //(should not be done for passthrough mode)
+ // File extension should already be ogg but since its user editable,
+ // (should not be needed for passthrough mode)
var sf = _this.formData['filename'];
var ext = '';
if( sf.lastIndexOf('.') != -1){
var extreg = new RegExp(ext + '$', 'i');
_this.formData['filename'] = sf.replace(extreg, '.ogg');
}
- //add chunk response hook to build the resultURL when uploading chunks
+ // Add chunk response hook to build the resultURL when uploading chunks
- //check for editToken:
+ // Check for editToken:
if(!this.etoken){
js_log('missing token try ' + _this.formData['token']);
if( _this.formData['token']){
doChunkWithFormData:function(){
var _this = this;
js_log("firefogg::doChunkWithFormData" + _this.etoken);
- //build the api url:
+ // Build the api url:
var aReq ={
'action': 'upload',
'format': 'json',
js_log('foggEncode: '+ JSON.stringify( _this.encoder_settings ) );
_this.fogg.upload( JSON.stringify( _this.encoder_settings ), _this.api_url , JSON.stringify( aReq ) );
- //update upload status:
+ // Update upload status:
_this.doUploadStatus();
},
- //doEncode and monitor progress:
+ // doEncode and monitor progress:
doEncode : function(){
var _this = this;
_this.action_done = false;
js_log('doEncode: with: ' + JSON.stringify( _this.encoder_settings ) );
_this.fogg.encode( JSON.stringify( _this.encoder_settings ) );
- //show transcode status:
+ // Show transcode status:
$j('#up-status-state').html( gM('mwe-upload-transcoded-status') );
- //setup a local function for timed callback:
+ // Setup a local function for timed callback:
var encodingStatus = function() {
var status = _this.fogg.status();
_this.doRenderPreview();
}
- //update progress bar
+ // Update progress bar
_this.updateProgress( _this.fogg.progress() );
- //loop to get new status if still encoding
+ // Loop to get new status if still encoding
if( _this.fogg.state == 'encoding' ) {
setTimeout(encodingStatus, 500);
}else if ( _this.fogg.state == 'encoding done' ) { //encoding done, state can also be 'encoding failed
var _this = this;
js_log('::encodeDone::');
_this.action_done = true;
- //send to the post url:
+
+ // Send to the post url:
if( _this.form_rewrite && _this.upload_mode == 'post' ){
js_log('done with encoding do POST upload:' + _this.editForm.action);
// ignore warnings & set source type
delete _this.formData[ 'file' ];
_this.fogg.post( _this.editForm.action, 'wpUploadFile', JSON.stringify( _this.formData ) );
- //update upload status:
+ // Update upload status:
_this.doUploadStatus();
}else{
js_log("done with encoding (no upload) ");
- //set stuats to 100% for one second:
+ // Set status to 100% for one second:
_this.updateProgress( 1 );
setTimeout(function(){
_this.updateProgressWin(gM('fogg-encoding-done'),
gM('fogg-encoding-done') + '<br>' +
- //show the video at full resolution upto 720px wide
+ // Show the video at full resolution up-to 720px wide
'<video controls="true" style="margin:auto" id="fogg_final_vid" src="' +
_this.fogg.previewUrl + '"></video>'
);
var vW = v.videoWidth;
var vH = v.videoHeight;
}
- //reize the video:
+ // Resize the video:
$j(v).css({
'width' : vW,
'height': vH
});
- //if large video resize the dialog box:
+ // If large video resize the dialog box:
if( vW + 5 > 400){
//also resize the dialog box
$j('#upProgressDialog').dialog('option', 'width', vW + 20);
$j( '#up-status-state' ).html( gM('mwe-uploaded-status') );
_this.oldResponseText = '';
- //setup a local function for timed callback:
+ // Setup a local function for timed callback:
var uploadStatus = function(){
- //get the response text:
+ // Get the response text:
var response_text = _this.fogg.responseText;
if(!response_text){
try{
if( _this.oldResponseText != response_text){
js_log('new result text:' + response_text + ' state:' + _this.fogg.state);
_this.oldResponseText = response_text;
- //try and parse the response text and check for errors
+ // Try and parse the response text and check for errors
try{
var apiResult = JSON.parse( response_text );
}catch(e){
}
}
if(apiResult && _this.apiUpdateErrorCheck( apiResult ) === false){
- //stop status update we have an error
+ // Stop status update we have an error
_this.action_done = true;
_this.fogg.cancel();
return false;
}
}
- //update progress bar
+ // Update progress bar
_this.updateProgress( _this.fogg.progress() );
- //loop to get new status if still uploading (could also be encoding if we are in chunk upload mode)
+ // Loop to get new status if still uploading (could also be encoding if we are in chunk upload mode)
if( _this.fogg.state == 'encoding' || _this.fogg.state == 'uploading') {
setTimeout(uploadStatus, 100);
- }//check upload state
+ }// Check upload state
else if( _this.fogg.state == 'upload done' ||
_this.fogg.state == 'done' ||
_this.fogg.state == 'encoding done' ) {
- //if in "post" upload mode read the html response (should be depricated):
+ // If in "post" upload mode read the html response (should be deprecated):
if( _this.upload_mode == 'api' ){
if( apiResult && apiResult.resultUrl ){
var buttons ={};
}
var go_to_url_txt = gM('mwe-go-to-resource');
if( typeof _this.done_upload_cb == 'function' ){
- //if done action return 'true'
+ // If done action return 'true'
if( _this.done_upload_cb( _this.formData ) ){
- //update status
+ // Update status
_this.updateProgressWin( gM('mwe-successfulupload'), gM( 'mwe-upload_done', apiResult.resultUrl),buttons);
}else{
- //if done action returns 'false' //close progress window
+ // If done action returns 'false' //close progress window
this.action_done = true;
$j('#upProgressDialog').empty().dialog('close');
}
}else{
- //update status (without done_upload_cb)
+ // Update status (without done_upload_cb)
_this.updateProgressWin( gM('mwe-successfulupload'), gM( 'mwe-upload_done', apiResult.resultUrl),buttons);
}
}else{
- //done state with error? ..not really possible given how firefogg works
+ // Done state with error? ..not really possible given how firefogg works
js_log(" Upload done in chunks mode, but no resultUrl!");
}
}else{
js_log("Error:: not supported upload mode" + _this.upload_mode);
}
}else{
- //upload error:
+ // Upload error:
js_log('Error:firefogg upload error: ' + _this.fogg.state );
}
}
$j(dlElm).empty().dialog('close');
}
}
- //dont' follow the link:
+ // Dont' follow the link:
return false;
}
};
/*
- * a library for doing remote media searches
- *
- * initial targeted archives are:
- the local wiki
- wikimedia commons
- metavid
- and archive.org
+ * remoteSearchDriver
+ * Provides a base interface for the Add-Media-Wizard
+ * supporting remote searching of http archives for free images/audio/video assets
*/
loadGM({
"mwe-ftype-png" : "PNG image file",
"mwe-ftype-oga" : "Ogg audio file",
"mwe-ftype-ogg" : "Ogg video file",
- "mwe-ftype-unk" : "Unknown file format"
+ "mwe-ftype-unk" : "Unknown file format",
+
+ "rsd-wiki_commons-title": "Wikimedia Commons",
+ "rsd-wiki_commons": "Wikimedia Commons, an archive of freely-licensed educational media content (images, sound and video clips)",
+
+ "rsd-this_wiki-title" : "This Wiki",
+ "rsd-this_wiki-desc" : "The local wiki install",
+
+ "rsd-archive_org-title": "Archive.org",
+ "rsd-archive_org-desc" : "The Internet Archive, a digital library of cultural artifacts",
+
+ "rsd-flickr-title" : "Flickr.com",
+ "rsd-flickr-desc" : "Flickr.com, a online photo sharing site",
+ "rsd-metavid-title" : "Meavid.org",
+ "rsd-metavid-desc" : "Metavid a community archive of US House and Senate floor proceedings"
+
});
var default_remote_search_options = {
'caret_pos':null,
'local_wiki_api_url':null,
- //can be 'api', 'autodetect', 'remote_link'
+ // Can be 'api', 'autodetect', 'remote_link'
'import_url_mode': 'api',
'target_title':null,
- //edit tools (can be an array of tools or keyword 'all')
+ // Edit tools (can be an array of tools or keyword 'all')
'enabled_tools' : 'all',
'target_render_area': null, //where output render should go:
'instance_name': null, //a globally accessible callback instance name
'default_query':null, //default search query
- //specific to sequence profile
+
+ //Specific to sequence profile
'p_seq':null,
'cFileNS':'File', //What is the canonical namespace prefix for images
//@@todo (should get that from the api or in-page vars)
stylepath = '';
/*
- * base remoteSearch Driver interface
+ * Base remoteSearch Driver interface
*/
var remoteSearchDriver = function(iObj){
return this.init( iObj );
*
@enabled: whether the search provider can be selected
- @checked: whether the search provider will show up as seleatable tab (todo: user preference)
+ @checked: whether the search provider will show up as selectable tab
@d: default: if the current cp should be displayed (only one should be the default)
@title: the title of the search provider
- @desc: can use html... todo: need to localize
+ @desc: can use html
@api_url: the url to query against given the library type:
@lib: the search library to use corresponding to the
search object ie: 'mediaWiki' = new mediaWikiSearchSearch()
@local_domains : sets of domains for which the content is local
//@@todo should query wgForeignFileRepos setting maybe interwikimap from the api
*/
+
'this_wiki':{
'enabled': 1,
- 'checked': 1,
- 'title' : 'This Wiki',
- 'desc' : '(should be updated with the proper text) maybe import from some config value',
+ 'checked': 1,
'api_url': ( wgServer && wgScriptPath )? wgServer + wgScriptPath+ '/api.php': null,
'lib' : 'mediaWiki',
'local' : true,
'tab_img': false
- },
+ },
'wiki_commons':{
'enabled': 1,
- 'checked': 1,
- 'title' :'Wikimedia Commons',
- 'desc' : 'Wikimedia Commons is a media file repository making available public domain '+
- 'and freely-licensed educational media content (images, sound and video clips) to all.',
+ 'checked': 1,
'homepage': 'http://commons.wikimedia.org/wiki/Main_Page',
'api_url':'http://commons.wikimedia.org/w/api.php',
'lib' :'mediaWiki',
},
'archive_org':{
'enabled':1,
- 'checked':1,
- 'title' : 'Archive.org',
- 'desc' : 'The Internet Archive, a digital library of cultural artifacts',
+ 'checked':1,
'homepage':'http://www.archive.org/about/about.php',
'api_url':'http://homeserver7.us.archive.org:8983/solr/select',
},
'flickr':{
'enabled':1,
- 'checked':1,
- 'title' : 'flickr.com',
- 'desc' : 'flickr.com, a online photo sharing site',
+ 'checked':1,
'homepage':'http://www.flickr.com/about/',
'api_url':'http://www.flickr.com/services/rest/',
'lib' : 'flickr',
'local' : false,
- //resources from fliker don't have a human parsable identieifer/title
+ //resources from fliker don't have a human parsable identifier/title
'resource_prefix': '',
'tab_img':true
- },
+ },
'metavid':{
'enabled' : 1,
'checked' : 1,
- 'title' : 'Metavid.org',
'homepage':'http://metavid.org/wiki/Metavid_Overview',
- 'desc' : 'Metavid hosts thousands of hours of US house and senate floor proceedings',
'api_url':'http://metavid.org/w/index.php?title=Special:MvExportSearch',
'lib' : 'metavid',
'local' :false, //if local set to true we can use local
o+='<li class="rsd_cp_tab">';
o+='<a id="rsd_tab_' + cp_id + '" href="#tab-' + cp_id + '">';
if(cp.tab_img === true){
- o+='<img alt="' + cp.title +'" src="' + mv_embed_path +'/skins/common/remote_cp/' + cp_id + '_tab.png">';
+ o+='<img alt="' + gM('rsd-' + cp_id + '-title' ) +'" src="' + mv_embed_path +'/skins/common/remote_cp/' + cp_id + '_tab.png">';
}else{
- o+= cp.title;
+ o+= gM('rsd-' + cp_id + '-title' );
}
o+='</a>';
o+='</li>';
tabc+='<div id="tab-'+ cp_id +'" class="rsd_results"/>';
}
- //do an upload tab if enabled:
+ // Do an upload tab if enabled:
if( this.content_providers['upload'].enabled ){
o+='<li class="rsd_cp_tab" ><a id="rsd_tab_upload" href="#tab-upload">' + gM('mwe-upload_tab') + '</a></li>';
tabc+='<div id="tab-upload" />';
selected_tab = inx++;
}
o+='</ul>';
- //output the tab content containers:
+ // Output the tab content containers:
o+=tabc;
o+='</div>'; //close tab container
- //output the respective results holders
+ // Output the respective results holders
$j('#rsd_results_container').html(o);
- //setup bindings for tabs make them sortable: (@@todo remember order)
+ // Setup bindings for tabs make them sortable: (@@todo remember order)
js_log('selected tab is: ' + selected_tab);
$j("#rsd_tabs_container").tabs({
selected:selected_tab,
select: function(event, ui) {
_this.selectTab( $j(ui.tab).attr('id').replace('rsd_tab_', '') );
}
- //add sorting
+ // Add sorting
}).find(".ui-tabs-nav").sortable({axis:'x'});
//@@todo store sorted repo
},
- //resource title
+ // Resource title
getResourceFromTitle : function( rTitle , callback){
var _this = this;
reqObj={
}else{
var cp = this.content_providers[this.disp_item];
tab_target = '#tab-' + cp_id;
- //output the results bar / controls
+ // Output the results bar / controls
}
- //empty the existing results:
+ // Empty the existing results:
$j(tab_target).empty();
//@@todo give the user upload control love
if(this.disp_item != 'upload'){
var drawResultCount = 0;
- //output all the results for the current disp_item
+ // Output all the results for the current disp_item
if( typeof cp['sObj'] != 'undefined' ){
$j.each(cp.sObj.resultsObj, function(rInx, rItem){
if( _this.result_display_mode == 'box' ){
o+='<div id="mv_result_' + rInx + '" class="mv_clip_box_result" style="width:' +
_this.thumb_width + 'px;height:'+ (_this.thumb_width-20) +'px;position:relative;">';
- //check for missing poster types for audio
+ // Check for missing poster types for audio
if( rItem.mime=='audio/ogg' && !rItem.poster ){
rItem.poster = mv_skin_img_path + 'sound_music_icon-80.png';
}
- //get a thumb with proper resolution transform if possible:
+ // Get a thumb with proper resolution transform if possible:
o+='<img title="'+rItem.title+'" class="rsd_res_item" id="res_' + cp_id + '__' + rInx +
'" style="width:' + _this.thumb_width + 'px;" src="' +
cp.sObj.getImageTransform( rItem, { 'width' : _this.thumb_width } )
+ '">';
- //add a linkback to resource page in upper right:
+ // Add a linkback to resource page in upper right:
if( rItem.link )
o+='<div class="rsd_linkback ui-corner-all ui-state-default ui-widget-content" >' +
'<a target="_new" title="' + gM('mwe-resource_description_page') +
'" href="' + rItem.link + '">'+ gM('mwe-link') + '</a>' +
'</div>';
- //add file type icon if known
+ // Add file type icon if known
if( rItem.mime ){
o+= _this.getTypeIcon( rItem.mime );
}
- //add license icons if present
+ // Add license icons if present
if( rItem.license )
o+= _this.getlicenseImgSet( rItem.license );
_this.thumb_width + 'px;" src="' +
cp.sObj.getImageTransform( rItem, {'width':_this.thumb_width } )
+ '">';
- //add license icons if present
+ // Add license icons if present
if( rItem.license )
o+= _this.getlicenseImgSet( rItem.license );
drawResultCount++;
});
js_log('append to: ' + '#tab-' + cp_id);
- //put in the tab output (plus clear the output)
+ // Put in the tab output (plus clear the output)
$j(tab_target).append( o + '<div style="clear:both"/>');
}
js_log( 'did drawResultCount :: ' + drawResultCount + ' append: ' + $j('#rsd_q').val() );
- //remove any old search res
+ // Remove any old search res
$j('#rsd_no_search_res').remove();
if( drawResultCount == 0 )
$j('#tab-' + cp_id).append( '<span style="padding:10px">' + gM( 'rsd_no_results', $j('#rsd_q').val() ) + '</span>');
var _this = this;
$j('.mv_clip_'+_this.result_display_mode+'_result').hover(function(){
$j(this).addClass('mv_clip_'+_this.result_display_mode+'_result_over');
- //also set the animated image if available
+ // Also set the animated image if available
var res_id = $j(this).children('.rsd_res_item').attr('id');
var rObj = _this.getResourceFromId( res_id );
if( rObj.poster_ani )
$j(this).removeClass('mv_clip_'+_this.result_display_mode+'_result_over');
var res_id = $j(this).children('.rsd_res_item').attr('id');
var rObj = _this.getResourceFromId( res_id );
- //restore the original (non animated)
+ // Restore the original (non animated)
if( rObj.poster_ani )
$j('#' + res_id ).attr('src', rObj.poster);
});
- //resource click action: (bring up the resource editor)
+ // Resource click action: (bring up the resource editor)
$j('.rsd_res_item').unbind().click(function(){
var rObj = _this.getResourceFromId( $j(this).attr("id") );
_this.resourceEdit( rObj, this );
var _this = this;
if(!maxWidth)maxWidth=400;
if(!overflow_style)overflow_style='overflow:auto;';
- //remove any old instance:
+ // Remove any old instance:
$j( _this.target_container ).find('#rsd_resource_edit').remove();
- //add the edit layout window with loading place holders
+ // Add the edit layout window with loading place holders
$j( _this.target_container ).append('<div id="rsd_resource_edit" '+
'style="position:absolute;top:0px;left:0px;bottom:0px;right:4px;background-color:#FFF;">' +
'<div id="clip_edit_ctrl" class="ui-widget ui-widget-content ui-corner-all" style="position:absolute;'+
resourceEdit:function( rObj, rsdElement){
js_log('f:resourceEdit:' + rObj.title);
var _this = this;
- //remove any existing resource edit interface:
+ // Remove any existing resource edit interface:
$j('#rsd_resource_edit').remove();
//set the media type:
if(rObj.mime.indexOf('image')!=-1){
- //set width to default image_edit_width
+ // Set width to default image_edit_width
var maxWidth = _this.image_edit_width;
var mediaType = 'image';
}else if(rObj.mime.indexOf('audio')!=-1){
var maxWidth = _this.video_edit_width;
var mediaType = 'audio';
}else{
- //set to default video size:
+ // Set to default video size:
var maxWidth = _this.video_edit_width;
var mediaType = 'video';
}
- //so that transcripts show ontop
+ // So that transcripts show ontop
var overflow_style = ( mediaType =='video' )?'':'overflow:auto;';
- //append to the top level of model window:
+ // Append to the top level of model window:
_this.addResourceEditLoader(maxWidth, overflow_style);
//update add media wizard title:
$j( _this.target_container ).dialog( 'option', 'title', gM('mwe-add_media_wizard')+': '+ gM('rsd_resource_edit', rObj.title ) );
$j('#rsd_edit_img').remove();//remove any existing rsd_edit_img
- //left side holds the image right size the controls /
+ // Left side holds the image right size the controls /
$j(rsdElement).clone().attr('id', 'rsd_edit_img').appendTo('#clip_edit_disp').css({
'position':'absolute',
'top':'40%',
'opacity':0
});
- //try and keep aspect ratio for the thumbnail that we clicked:
+ // Try and keep aspect ratio for the thumbnail that we clicked:
var tRatio = $j(rsdElement).height() / $j(rsdElement).width();
if( ! tRatio )
var tRatio = 1; //set ratio to 1 if tRatio did not work.
js_log('Set from ' + tRatio + ' to init thumbimage to ' + maxWidth + ' x ' + parseInt( tRatio * maxWidth) );
- //scale up image and to swap with high res version
+ // Scale up image and to swap with high res version
$j('#rsd_edit_img').animate({
'opacity':1,
'top':'5px',
$j('.mv_loading_img').remove();
});
}
- //also fade in the container:
+ // Also fade in the container:
$j('#rsd_resource_edit').animate({
'opacity':1,
'background-color':'#FFF',
'z-index':99
});
- //do load the media Editor
+ // Do load the media Editor
_this.doMediaEdit( rObj , mediaType );
},
loadHQImg:function(rObj, size, target_img_id, callback){
// See if we need to animate some transition
if( size.width != imObj.width ){
js_log('loadHQImg:size mismatch: ' + size.width + ' != ' + imObj.width );
- //set the target id to the new size:
+ // Set the target id to the new size:
$j('#'+target_img_id).animate( {
'width':imObj.width + 'px',
'height':imObj.height + 'px'
js_log('using req size: ' + imObj.width + 'x' + imObj.height);
$j('#'+target_img_id).animate( {'width':imObj.width+'px', 'height' : imObj.height + 'px'});
}
- //don't swap it in until its loaded:
+ // Don't swap it in until its loaded:
var img = new Image();
- // load the image image:
+ // Load the image image:
$j(img).load(function () {
$j('#'+target_img_id).attr('src', rObj.edit_url );
- //let the caller know we are done and what size we ended up with:
+ // Let the caller know we are done and what size we ended up with:
callback();
}).error(function () {
js_log("Error with: " + rObj.edit_url);
js_log('cancelClipEditCB');
var b_target = _this.target_container + '~ .ui-dialog-buttonpane';
$j('#rsd_resource_edit').remove();
- //remove preview if its 'on'
+ // Remove preview if its 'on'
$j('#rsd_preview_display').remove();
- //restore the resource container:
+ // Restore the resource container:
$j('#rsd_results_container').show();
- //restore the title:
+ // Restore the title:
$j( _this.target_container ).dialog( 'option', 'title', gM('mwe-add_media_wizard'));
js_log("should update: " + b_target + ' with: cancel');
- //restore the buttons:
+ // Restore the buttons:
$j(b_target).html( $j.btnHtml( gM('mwe-cancel') , 'mv_cancel_rsd', 'close'))
.children('.mv_cancel_rsd')
.btnBind()
})
},
- /*set-up the control actions for clipEdit with relevant callbacks */
+ /* getClipEditControlActions
+ * Set-up the control actions for clipEdit with relevant callbacks
+ */
getClipEditControlActions:function( cp ){
var _this = this;
var cConf= {};
cConf['insert'] = function(rObj){
_this.insertResource(rObj);
}
- //if not directly inserting the resource is support a preview option:
+ // If not directly inserting the resource is support a preview option:
if( _this.import_url_mode != 'remote_link'){
cConf['preview'] = function(rObj){
_this.previewResource( rObj )
}
return cConf;
},
- //loads the media editor:
+ // Loads the media editor:
doMediaEdit:function( rObj , mediaType){
var _this = this;
var cp = rObj.pSobj.cp;
'controlActionsCb' : _this.getClipEditControlActions( cp ),
'enabled_tools' : _this.enabled_tools
};
- //set the base clip edit lib class req set:
+ // Set the base clip edit lib class req set:
var clibs = ['mvClipEdit'];
if( mediaType == 'image'){
- //display the mvClipEdit obj once we are done loading:
+ // Display the mvClipEdit obj once we are done loading:
mvJsLoader.doLoad( clibs, function(){
- //run the image clip tools
+ // Run the image clip tools
_this.cEdit = new mvClipEdit( mvClipInit );
});
}else if( mediaType == 'video' || mediaType == 'audio'){
js_log('media type:: ' + mediaType);
- //get any additional embedding helper meta data prior to doing the actual embed
+ // Get any additional embedding helper meta data prior to doing the actual embed
// normally this meta should be provided in the search result (but archive.org has another query for more media meta)
rObj.pSobj.getEmbedTimeMeta( rObj, function(){
- //make sure we have the embedVideo libs:
+ // Make sure we have the embedVideo libs:
var runFlag = false;
mvJsLoader.embedVideoCheck( function(){
- //strange concurency issue with callbacks
+ // Strange concurrency issue with callbacks
//@@todo try and figure out why this callback is fired twice
if(!runFlag){
runFlag = true;
}else{
- js_log('only run embed vid once');
+ js_log('Error: embedVideoCheck run twice');
return false;
}
js_log('append html: ' + rObj.pSobj.getEmbedHTML( rObj, {id:'embed_vid'}) );
})
);
js_log("about to call rewrite_by_id::embed_vid");
- //rewrite by id
+ // Rewrite by id
rewrite_by_id('embed_vid', function(){
- //grab any information that we got from the ROE xml or parsed from the media file
+ // Grab any information that we got from the ROE xml or parsed from the media file
rObj.pSobj.getEmbedObjParsedInfo( rObj, 'embed_vid' );
- //add the re-sizable to the doLoad request:
+ // Add the re-sizable to the doLoad request:
clibs.push( '$j.ui.resizable');
clibs.push( '$j.fn.hoverIntent');
mvJsLoader.doLoad(clibs, function(){
- //make sure the rsd_edit_img is hidden:
+ // Make sure the rsd_edit_img is hidden:
$j('#rsd_edit_img').remove();
- //run the image clip tools
+ // Run the image clip tools
_this.cEdit = new mvClipEdit( mvClipInit );
});
});
if( cp.local ){
return true;
}else{
- //check if we can embed the content locally per a domain name check:
+ // Check if we can embed the content locally per a domain name check:
var local_host = parseUri( this.local_wiki_api_url ).host;
if( cp.local_domains ) {
for(var i=0;i < cp.local_domains.length; i++){
},
checkImportResource:function( rObj, cir_callback){
var _this = this;
- //add a loader ontop:
+ // Add a loader ontop:
$j.addLoaderDialog( gM('mwe-checking-resource') );
- //extend the callback with close dialog
+ // Extend the callback with close dialog
var org_cir_callback = cir_callback;
cir_callback = function( rObj ){
var cat = org_cir_callback;
var cp = rObj.pSobj.cp;
var _this = this;
- //update base target_resource_title:
+ // Update base target_resource_title:
rObj.target_resource_title = rObj.titleKey.replace(/File:|Image:/,'')
//check if local repository
//or if import mode if just "linking" (we should already have the 'url'
if( this.checkRepoLocal( cp ) || this.import_url_mode == 'remote_link'){
- //local repo jump directly to check Import Resource callback:
+ // Local repo jump directly to check Import Resource callback:
cir_callback( rObj );
}else{
- //check if the file is local (can be shared repo)
+ // Check if the file is local (can be shared repo)
if( cp.check_shared ){
_this.checkForFile(rObj.target_resource_title, function(imagePage){
if( imagePage && imagePage['imagerepository'] == 'shared' ){
if( this.content_providers[this.disp_item] ){
var cp = this.content_providers[this.disp_item];
about_desc ='<span style="position:relative;top:0px;font-style:italic;">' +
- '<i>' + gM('mwe-results_from', [cp.homepage, cp.title]) + '</i></span>';
+ '<i>' + gM('mwe-results_from', [cp.homepage, gM('rsd-' + this.disp_item + '-title' ) ]) + '</i></span>';
$j('#tab-'+this.disp_item).append( '<div id="rds_results_bar">'+
'<span style="float:left;top:0px;font-style:italic;">'+
gM('rsd_layout')+' '+
return srtData;
}
function getVideoTitle() {
- var videoTitle = wgPageName.split('.');
+ var videoTitle = wgTitle.split('.');
videoTitle.pop();
videoTitle.pop();
videoTitle = videoTitle.join('.').replace('TimedText:', 'File:');
return videoTitle;
}
-
- var availableSubtitles = {};
- var langData = {};
-
- function addLanguageSelect(ttoolbar) {
- var apprefix = wgPageName.split('.');
- apprefix.pop();
- var currentLanguage = apprefix.pop();
- apprefix = apprefix.join('.');
+ function uploadSubtitles() {
do_api_req({
'data': {
'meta' : 'siteinfo',
'siprop' : 'languages'
}
- }, function( langDataRaw ) {
- var lagRaw = langDataRaw.query.languages;
- for(var j in lagRaw){
- var code = lagRaw[j].code;
- var language = lagRaw[j]['*'];
- langData[ code ] = language;
- }
- do_api_req({
- 'data': {
- 'list' : 'allpages',
- 'apprefix' : apprefix.replace("TimedText:", ""),
- 'apnamespace' : 102
- }
- }, function( subData ) {
- for(var i in subData.query.allpages){
- var subPage = subData.query.allpages[i];
- var langKey = subPage.title.split('.');
- var extension = langKey.pop();
- langKey = langKey.pop();
- availableSubtitles[langKey] = subPage.title;
- }
- var select = $j('<select>');
- var haveOtherLanguages = 0;
- for(var i in availableSubtitles){
- haveOtherLanguages++;
- var opt = $j('<option>')
- .html(langData[ i ] + '('+i+')')
- .click(function(i) {
- return function() {
- document.location.href = wgArticlePath.replace('/$1', '?title=' + availableSubtitles[i] + '&action=edit');
- }}(i));
- if(currentLanguage == i) {
- opt.attr('selected', 'selcted');
+ }, function( langDataRaw ) {
+ var apprefix = wgTitle.split('.');
+ apprefix.pop();
+ apprefix.pop();
+ apprefix = apprefix.join('.');
+ do_api_req({
+ 'data': {
+ 'list' : 'allpages',
+ 'apprefix' : apprefix
+ }
+ }, function( subData ) {
+ var availableSubtitles = {};
+ for(var i in subData.query.allpages){
+ var subPage = subData.query.allpages[i];
+ var langKey = subPage.title.split('.');
+ var extension = langKey.pop();
+ langKey = langKey.pop();
+ availableSubtitles[langKey] = subPage.title;
}
- select.append(opt);
- }
- if (haveOtherLanguages > 1) {
- ttoolbar.append(" " +gM('mwe-select-other-language')+": ");
- ttoolbar.append(select);
- }
- });
- });
- }
+ var langData = {};
+ var languageSelect = '<select id="timed_text_language">';
- function uploadSubtitles() {
- var languageSelect = '<select id="timed_text_language">';
- for(code in langData) {
- var language = langData[ code ];
- languageSelect += '<option value="'+code+'">';
- if (availableSubtitles[code]) {
- languageSelect += language+'('+code+') +';
- } else {
- languageSelect += language+'('+code+') -';
- }
- languageSelect += '</option>';
- }
- languageSelect += '/</select>';
- var cBtn = {};
- cBtn[ gM('mwe-cancel') ] = function(){
- $j(this).dialog('close');
- }
- cBtn[ gM('mwe-ok') ] = function(){
- var file = $j('#timed_text_file_upload');
- var langKey = file[0].files[0].name.split('.');
- var extension = langKey.pop();
- langKey = langKey.pop();
- var mimeTypes = {
- 'srt': 'text/x-srt',
- 'cmml': 'text/cmml'
- }
- if( !mimeTypes[ extension ] ){
- js_log('Error: unknown extension:'+ extension);
- }
- //get language from form
- langKey = $j('#timed_text_language').val();
- if(extension == "srt") {
- var srt = getSubtitle(file[0]);
- $j(this).html("saving...<br>"+mv_get_loading_img());
- $j('.ui-dialog-buttonpane').remove();
- var editToken = $j('input[name=wpEditToken]').val();
- var title = wgPageName.split('.');
- title.pop();
- title.pop();
- title = title.join('.') + '.' + langKey + '.srt';
- do_api_req({
- 'data': {
- 'action' : 'edit',
- 'title' : title,
- 'text' : srt,
- 'token': editToken
+ var lagRaw = langDataRaw.query.languages;
+ for(var j in lagRaw){
+ var code = lagRaw[j].code;
+ var language = lagRaw[j]['*'];
+ langData[ code ] = language;
+ languageSelect += '<option value="'+code+'">';
+ if (availableSubtitles[code]) {
+ languageSelect += language+'('+code+') +';
+ } else {
+ languageSelect += language+'('+code+') -';
+ }
+ languageSelect += '</option>';
}
- }, function(dialog) {
- return function( result ) {
- document.location.href = wgArticlePath.replace('/$1', '?title=' + title + '&action=edit');
- $j(dialog).dialog('close');
- }}(this)
- );
- } else {
- $j(this).html(gM("mwe-error-only-srt"));
- }
- }
- $j.addDialog(gM("mwe-add-subs-file-title"),
- '<input type="file" id="timed_text_file_upload"></input><br />' + languageSelect,
- cBtn);
- $j('#timed_text_file_upload').change(function(ev) {
- var langKey = this.files[0].name.split('.');
- var extension = langKey.pop();
- langKey = langKey.pop();
- $j('#timed_text_language').val( langKey );
+ languageSelect += '/</select>';
+ var cBtn = {};
+ cBtn[ gM('mwe-cancel') ] = function(){
+ $j(this).dialog('close');
+ }
+ cBtn[ gM('mwe-ok') ] = function(){
+ //get language from form
+ langKey = $j('#timed_text_language').val();
+ var title = wgTitle.split('.');
+ title.pop();
+ title.pop();
+ title = title.join('.') + '.' + langKey + '.srt';
+
+ var file = $j('#timed_text_file_upload');
+ if( file[0].files[0]){
+ //no file to upload just jump to the lang key:
+ document.location.href = wgArticlePath.replace('/$1', '?title=' + title + '&action=edit');
+ return ;
+ }
+ var langKey = file[0].files[0].name.split('.');
+ var extension = langKey.pop();
+ langKey = langKey.pop();
+ var mimeTypes = {
+ 'srt': 'text/x-srt',
+ 'cmml': 'text/cmml'
+ }
+ if( !mimeTypes[ extension ] ){
+ js_log('Error: unknown extension:'+ extension);
+ }
+
+
+ if(extension == "srt") {
+ var srt = getSubtitle(file[0]);
+ $j(this).html("saving...");
+ $j('.ui-dialog-buttonpane').remove();
+
+ var editToken = $j('input[name=wpEditToken]').val();
+
+ do_api_req({
+ 'data': {
+ 'action' : 'edit',
+ 'title' : title,
+ 'text' : srt,
+ 'token': editToken
+ }
+ }, function(dialog) {
+ return function( result ) {
+ document.location.href = wgArticlePath.replace('/$1', '?title=' + title + '&action=edit');
+ $j(dialog).dialog('close');
+ }}(this)
+ );
+ } else {
+ $j(this).html(gM("mwe-error-only-srt"));
+ }
+ }
+ $j.addDialog(gM("mwe-add-subs-file-title"),
+ '<input type="file" id="timed_text_file_upload"></input><br />' + languageSelect,
+ cBtn);
+ $j('#timed_text_file_upload').change(function(ev) {
+ if( this.files[0] ){
+ var langKey = this.files[0].name.split('.');
+ var extension = langKey.pop();
+ langKey = langKey.pop();
+ $j('#timed_text_language').val( langKey );
+ }
+ });
+ });
});
}
- $j('#toolbar').hide();
+ var tselect = ($j('#wikiEditor-ui-top').length != 0)?'#wikiEditor-ui-top':'#toolbar';
+ $j(tselect).hide();
var ttoolbar = $j('<div>');
- $j('#toolbar').after(ttoolbar);
+ $j(tselect).after(ttoolbar);
var button = $j('<button>');
button.click(uploadSubtitles)
button.click(function() { document.location.href = wgArticlePath.replace('$1', getVideoTitle()); })
button.text(gM("mwe-watch-video"));
ttoolbar.append(button);
- addLanguageSelect(ttoolbar);
+
});
$.lang.gMsgSwap = function( key , args ){
if(! gMsg[ key ])
return '<' + key + '>';// Missing key placeholder
- //get the messege string:
+ //get the messeage string:
var ms = gMsg[ key ];
//replace values
/**
* Add Supported Magic Words to parser
*/
- //set the setupflag to false:
+ // Set the setupflag to false:
$.lang.doneSetup=false;
$.lang.magicSetup = function(){
if(!$.lang.doneSetup){
// JavaScript does not let you choose the precision when rounding
var p = Math.pow(10,round);
var size = Math.round( size * p ) / p;
- //@@todo we need a formatNum and we need to request some special packaged info to deal with that case.
return gM( msg , size );
};
$.lang.formatNumber = function( num ){
/*
- addSeparatorsNF
- Str: The number to be formatted, as a string or number.
- outD: The decimal character for the output, such as ',' for the number 100,2
- sep: The separator character for the output, such as ',' for the number 1,000.2
+ * addSeparatorsNF
+ * @param Str: The number to be formatted, as a string or number.
+ * @param outD: The decimal character for the output, such as ',' for the number 100,2
+ * @param sep: The separator character for the output, such as ',' for the number 1,000.2
*/
function addSeparatorsNF(nStr, outD, sep){
nStr += '';
/**
* parser addMagic
*
- * lets you add a set of magic keys and associated callback functions
- * callback: @param ( Object Template )
- * callback: @return the transformed template output
+ * Lets you add a set of magic keys and associated callback functions
*
* @param object magicSet key:callback
*/
*/
// ~ probably a better algorithm out there / should mirror php parser flow ~
- // (we are already running white-space issues ie php parse strips whitespace diffrently)
+ // (we are already running white-space issues ie php parse strips whitespace differently)
// ... but I am having fun with recursion so here it is...
// or at least mirror: http://www.mediawiki.org/wiki/Extension:Page_Object_Model
}
if(!node['t'])
node['t']='';
- //dont put closures into output:
+ //don't put closures into output:
if( txt[a] && txt[a]!='}' )
node['t'] += txt[a];
},
/*
- * parsed template api ~losely based off of ~POM~
+ * parsed template api ~loosely based off of ~POM~
* http://www.mediawiki.org/wiki/Extension:Page_Object_Model
*/
/**
* Returns the transformed wikitext
*
- * Build output from swappable index
+ * Build output from swapable index
* (all transforms must be expanded in parse stage and linearly rebuilt)
* Alternatively we could build output using a place-holder & replace system
- * (this lets us be slightly more slopy with ordering and indexes, but probably slower)
+ * (this lets us be slightly more sloppy with ordering and indexes, but probably slower)
*
* Ideal: we build a 'wiki DOM'
* When editing you update the data structure directly
}
/**
-* mvJsLoader class handles initialization and js file loads
+* mvJsLoader class handles initialisation and js file loads
*/
var mvJsLoader = {
libreq : {},
}
if( _this.jQuerySetupFlag == false){
//js_log('setup mv_embed jQuery bindings');
- //setup our global settings using the (jQuery helper)
+ // Setup our global settings using the (jQuery helper)
// Set up the skin path
_global['mv_jquery_skin_path'] = mv_embed_path + 'jquery/jquery.ui/themes/' + $mw.conf['jui_skin'] + '/';
]
];
- //add any requested skins (suports multiple skins per single page)
+ //add any requested skins (supports multiple skins per single page)
if( $mw.skin_list ){
for(var i in $mw.skin_list ){
depReq[0].push( $mw.skin_list[i] + 'Config' );
}
- }
-
+ }
// Add PNG fix if needed:
if( $j.browser.msie || $j.browser.version < 7 )
}
});
}
-// Deprecated mwAddOnloadHook in favor of js2 naming (for clear separation of js2 code from old MW code
+// Deprecated mwAddOnloadHook in favour of js2 naming (for clear separation of js2 code from old MW code
var mwAddOnloadHook = js2AddOnloadHook;
/*
* This function allows for targeted rewriting
* Store all the mwEmbed jQuery-specific bindings
* (set up after jQuery is available).
*
- * These functions are genneraly are loaders that do the dynamic mapping of
- * dependencies for a given commponet
+ * These functions are generally are loaders that do the dynamic mapping of
+ * dependencies for a given component
*
*
*/
}
return sElm['firefogg'];
} else {
- // Avoid concurency
+ // Avoid concurrency
sElm['firefogg'] = 'loading';
}
// Add the selector
* Utility functions
*/
function js_log( string ) {
- ///add any prepend debug strings if nessesary (used for cross browser)
+ // Add any prepend debug strings if necessary (used for cross browser)
if( $mw.conf['debug_pre'] )
string = $mw.conf['debug_pre']+ string;
<script type="text/javascript" >
var scriptLoaderURID = 't14';
//for just setting one or two to test at a time for debug
-var langKeyDebug = ['en'];
-//var langKeyDebug = [ 'az', 'da', 'pt', 'fr', 'lv', 'en'];
-
-//shortLangKey is an array of at least one language from every group in cldrConverter.php
-var langKeyGroups = ['en','az', 'da', 'pt', 'fr', 'lv', 'ga','hr','cy','mk','mt','pl','sl'];
+//var langKeyDebug = ['sl']; //pl
+var langKeyDebug = [ 'az', 'da', 'pt', 'fr', 'lv', 'en'];
+//var langKeyDebug = ['en','az', 'da', 'pt', 'fr', 'lv', 'ga','hr','cy','mk','mt','pl','sl'];
//longlangKey is every language we have a much more verbose test
var langKeyAll = [
function doLangTable( langSet ){
//build table output:
var msgTestSet = {
- 'mwe-upload-multi' : [ 0, 1, 2, 5, 21, 30 ],
+ 'undelete_short' : [ 0, 1, 2, 5, 21, 30 ],
//category-subcat-count' has two params:
'category-subcat-count' : [
[0,10],
var urlparts = getRemoteEmbedPath();
var mwEmbedHostPath = urlparts[0];
var mwRemoteVersion = '1.05';
+var mwUseScriptLoader = true;
reqArguments = urlparts[1];
}
addOnloadHook( function(){
- //only do rewrites if MV_EMBED / js2 is "off"
+ // Only do rewrites if MV_EMBED / js2 is "off"
if( typeof MV_EMBED_VERSION == 'undefined' ) {
doPageSpecificRewrite();
}
} );
}
- //timed text display:
+ // Timed text display:
if(wgPageName.indexOf("TimedText") === 0){
load_mv_embed(function(){
$mw.load( ['mvTimeTextEdit'],function(){
} );
}
}
-// will be depreciated in favor of updates to OggHandler
+// This will be depreciated in favour of updates to OggHandler
function rewrite_for_OggHandler( vidIdList ){
function procVidId( vidId ){
//don't process empty vids
function load_mv_embed( callback ) {
// Inject mv_embed if needed
if( typeof $mw == 'undefined' ) {
- if( reqParam['uselang'] || reqParam['useloader'] ){
+ if( ( reqParam['uselang'] || reqParam['useloader'] ) && mwUseScriptLoader){
var rurl = mwEmbedHostPath + '/mwEmbed/jsScriptLoader.php?class=mv_embed';
- //add jQuery too if we need it:
+ // Add jQuery too if we need it:
if(typeof window.jQuery == 'undefined'){
rurl+= ',window.jQuery';
}
if(reqParam['uselang'] )
rurl+='&uselang=' + reqParam['uselang'];
-
- //do import url:
+
importScriptURI(rurl);
}else{
importScriptURI( mwEmbedHostPath + '/mwEmbed/mv_embed.js' + reqArguments );
} else {
callback();
}
-}
\ No newline at end of file
+}
/**
* Set the upload radio buttons
*
- * boolean set
+ * @boolean set
*/
toggleUpType: function( set ) {
$j( '#wpSourceTypeFile' ).attr( 'checked', set );
'warn_target': '#wpDestFile-warning'
} );
}
-}
\ No newline at end of file
+}