From 043f92672490b544549107996bcd412e03718cd5 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Thu, 12 Nov 2009 17:54:12 +0000 Subject: [PATCH] Run patched version of stylize.php (http://pywiki.pastey.net/128379 for diff) on non-lib non-minimised JavaScript files in js2, except for 3 files locked by timstarling. mdale will run tests on this. Should not be considered anywhere near stable until reviewed (!!!) The script had some trouble processing some of the regular expressions. Those were put back to their original formatting. Some were updated manually, others were not. --- js2/ajaxcategories.js | 174 +- js2/apiProxyPage.js | 16 +- js2/editPage.js | 46 +- js2/js2stopgap.js | 252 +- js2/mwEmbed/libAddMedia/dragDropFile.js | 102 +- js2/mwEmbed/libAddMedia/remoteSearchDriver.js | 1846 +++++------ .../searchLibs/archiveOrgSearch.js | 130 +- .../searchLibs/baseRemoteSearch.js | 246 +- .../libAddMedia/searchLibs/flickrSearch.js | 154 +- .../libAddMedia/searchLibs/mediaWikiSearch.js | 440 +-- .../libAddMedia/searchLibs/metavidSearch.js | 234 +- js2/mwEmbed/libAddMedia/simpleUploadForm.js | 156 +- js2/mwEmbed/libClipEdit/mvClipEdit.js | 916 +++--- js2/mwEmbed/libEmbedVideo/embedVideo.js | 2848 ++++++++-------- js2/mwEmbed/libEmbedVideo/flowplayerEmbed.js | 1594 ++++----- js2/mwEmbed/libEmbedVideo/genericEmbed.js | 18 +- js2/mwEmbed/libEmbedVideo/htmlEmbed.js | 244 +- js2/mwEmbed/libEmbedVideo/javaEmbed.js | 206 +- js2/mwEmbed/libEmbedVideo/kplayerEmbed.js | 66 +- js2/mwEmbed/libEmbedVideo/nativeEmbed.js | 358 +- js2/mwEmbed/libEmbedVideo/omtkEmbed.js | 80 +- js2/mwEmbed/libEmbedVideo/vlcEmbed.js | 326 +- js2/mwEmbed/libMwApi/mw.proxy.js | 232 +- js2/mwEmbed/libSequencer/mvFirefoggRender.js | 142 +- js2/mwEmbed/libSequencer/mvPlayList.js | 2886 ++++++++--------- js2/mwEmbed/libSequencer/mvSequencer.js | 1792 +++++----- .../libSequencer/mvTimedEffectsEdit.js | 324 +- .../libSequencer/seqRemoteSearchDriver.js | 184 +- js2/mwEmbed/libTimedText/mvTextInterface.js | 762 ++--- js2/mwEmbed/libTimedText/mvTimeTextEdit.js | 142 +- js2/mwEmbed/mv_embed.js | 1184 +++---- js2/mwEmbed/skins/ctrlBuilder.js | 480 +-- js2/mwEmbed/skins/kskin/kskin.js | 132 +- js2/mwEmbed/tests/testLang.js | 16 +- js2/remoteMwEmbed.js | 148 +- js2/uploadPage.js | 44 +- 36 files changed, 9460 insertions(+), 9460 deletions(-) diff --git a/js2/ajaxcategories.js b/js2/ajaxcategories.js index b37cd62842..b46d8b3adf 100644 --- a/js2/ajaxcategories.js +++ b/js2/ajaxcategories.js @@ -13,25 +13,25 @@ loadGM( { } ); var ajaxCategories = { - handleAddLink : function(e) { + handleAddLink : function( e ) { e.preventDefault(); // Make sure the suggestion plugin is loaded. Load everything else while we're at it mvJsLoader.doLoad( ['$j.ui', '$j.ui.dialog', '$j.fn.suggestions'], function() { - $j('#mw-addcategory-prompt').toggle(); + $j( '#mw-addcategory-prompt' ).toggle(); - $j('#mw-addcategory-input').suggestions( { + $j( '#mw-addcategory-input' ).suggestions( { 'fetch':ajaxCategories.fetchSuggestions, 'cancel': function() { var req = ajaxCategories.request; - if (req.abort) + if ( req.abort ) req.abort(); } } ); - $j('#mw-addcategory-input').suggestions(); + $j( '#mw-addcategory-input' ).suggestions(); } ); }, @@ -44,7 +44,7 @@ var ajaxCategories = { 'action': 'query', 'list': 'allpages', 'apnamespace': 14, - 'apprefix': $j(this).val(), + 'apprefix': $j( this ).val(), 'format': 'json' }, dataType: 'json', @@ -53,27 +53,27 @@ var ajaxCategories = { var pages = data.query.allpages; var titleArr = []; - $j.each(pages, function(i, page) { + $j.each( pages, function( i, page ) { var title = page.title.split( ':', 2 )[1]; - titleArr.push(title); + titleArr.push( title ); } ); - $j(that).suggestions( 'suggestions', titleArr ); + $j( that ).suggestions( 'suggestions', titleArr ); } - }); + } ); ajaxCategories.request = request; }, reloadCategoryList : function( response ) { - var holder = $j('
'); + var holder = $j( '
' ); holder.load( - window.location.href+' .catlinks', + window.location.href + ' .catlinks', function() { - $j('.catlinks').replaceWith( holder.find('.catlinks') ); + $j( '.catlinks' ).replaceWith( holder.find( '.catlinks' ) ); ajaxCategories.setupAJAXCategories(); - ajaxCategories.removeProgressIndicator( $j('.catlinks') ); + ajaxCategories.removeProgressIndicator( $j( '.catlinks' ) ); } ); }, @@ -85,31 +85,31 @@ var ajaxCategories = { function() { // Produce a confirmation dialog - var dialog = $j('
'); + var dialog = $j( '
' ); - dialog.addClass('mw-ajax-confirm-dialog'); - dialog.attr( 'title', gM('ajax-confirm-title') ); + dialog.addClass( 'mw-ajax-confirm-dialog' ); + dialog.attr( 'title', gM( 'ajax-confirm-title' ) ); // Intro text. - var confirmIntro = $j('

'); - confirmIntro.text( gM('ajax-confirm-prompt') ); - dialog.append(confirmIntro); + var confirmIntro = $j( '

' ); + confirmIntro.text( gM( 'ajax-confirm-prompt' ) ); + dialog.append( confirmIntro ); // Summary of the action to be taken - var summaryHolder = $j('

'); - var summaryLabel = $j(''); - summaryLabel.text(gM('ajax-confirm-actionsummary')+" " ); + var summaryHolder = $j( '

' ); + var summaryLabel = $j( '' ); + summaryLabel.text( gM( 'ajax-confirm-actionsummary' ) + " " ); summaryHolder.text( actionSummary ); summaryHolder.prepend( summaryLabel ); - dialog.append(summaryHolder); + dialog.append( summaryHolder ); // Reason textbox. - var reasonBox = $j(''); - reasonBox.addClass('mw-ajax-confirm-reason'); - dialog.append(reasonBox); + var reasonBox = $j( '' ); + reasonBox.addClass( 'mw-ajax-confirm-reason' ); + dialog.append( reasonBox ); // Submit button - var submitButton = $j(''); + var submitButton = $j( '' ); submitButton.val( gM( 'ajax-confirm-save' ) ); var submitFunction = function() { @@ -120,21 +120,21 @@ var ajaxCategories = { reasonBox.val(), function() { doneFn(); - dialog.dialog('close'); + dialog.dialog( 'close' ); ajaxCategories.removeProgressIndicator( dialog ); } ); }; - var buttons = {}; - buttons[gM('ajax-confirm-save')] = submitFunction; + var buttons = { }; + buttons[gM( 'ajax-confirm-save' )] = submitFunction; var dialogOptions = { 'AutoOpen' : true, 'buttons' : buttons, 'width' : 450 }; - $j('#catlinks').prepend(dialog); + $j( '#catlinks' ).prepend( dialog ); dialog.dialog( dialogOptions ); } ); @@ -151,19 +151,19 @@ var ajaxCategories = { 'format':'json' }; - $j.get(wgScriptPath+'/api.php', getTokenVars, + $j.get( wgScriptPath + '/api.php', getTokenVars, function( reply ) { var infos = reply.query.pages; $j.each( infos, - function(pageid, data) { + function( pageid, data ) { var token = data.edittoken; var timestamp = data.revisions[0].timestamp; var oldText = data.revisions[0]['*']; - var newText = fn(oldText); + var newText = fn( oldText ); - if (newText === false) return; + if ( newText === false ) return; var postEditVars = { 'action':'edit', @@ -175,7 +175,7 @@ var ajaxCategories = { 'format':'json' }; - $j.post( wgScriptPath+'/api.php', postEditVars, doneFn, 'json' ); + $j.post( wgScriptPath + '/api.php', postEditVars, doneFn, 'json' ); } ); } @@ -183,35 +183,35 @@ var ajaxCategories = { }, addProgressIndicator : function( elem ) { - var indicator = $j('

'); + var indicator = $j( '
' ); - indicator.addClass('mw-ajax-loader'); + indicator.addClass( 'mw-ajax-loader' ); elem.append( indicator ); }, removeProgressIndicator : function( elem ) { - elem.find('.mw-ajax-loader').remove(); + elem.find( '.mw-ajax-loader' ).remove(); }, - handleCategoryAdd : function(e) { + handleCategoryAdd : function( e ) { // Grab category text - var category = $j('#mw-addcategory-input').val(); - var appendText = "\n[["+wgFormattedNamespaces[14]+":"+category+"]]\n"; - var summary = gM('ajax-add-category-summary', category); + var category = $j( '#mw-addcategory-input' ).val(); + var appendText = "\n[[" + wgFormattedNamespaces[14] + ":" + category + "]]\n"; + var summary = gM( 'ajax-add-category-summary', category ); ajaxCategories.confirmEdit( wgPageName, - function(oldText) { return oldText+appendText }, + function( oldText ) { return oldText + appendText }, summary, ajaxCategories.reloadCategoryList ); }, - handleDeleteLink : function(e) { + handleDeleteLink : function( e ) { e.preventDefault(); - var category = $j(this).parent().find('a').text(); + var category = $j( this ).parent().find( 'a' ).text(); // Build a regex that matches legal invocations of that category. @@ -219,37 +219,37 @@ var ajaxCategories = { // Shouldn't have any real impact, can't be exploited or anything, so we'll // leave it for now. var categoryNSFragment = ''; - $j.each(wgNamespaceIds, function( name, id ) { - if (id == 14) { + $j.each( wgNamespaceIds, function( name, id ) { + if ( id == 14 ) { // Allow the first character to be any case - var firstChar = name.charAt(0); - firstChar = '['+firstChar.toUpperCase()+firstChar.toLowerCase()+']'; - categoryNSFragment += '|'+firstChar+name.substr(1); + var firstChar = name.charAt( 0 ); + firstChar = '[' + firstChar.toUpperCase() + firstChar.toLowerCase() + ']'; + categoryNSFragment += '|' + firstChar + name.substr( 1 ); } } ); - categoryNSFragment = categoryNSFragment.substr(1); // Remove leading | + categoryNSFragment = categoryNSFragment.substr( 1 ); // Remove leading | // Build the regex var titleFragment = category; - firstChar = category.charAt(0); - firstChar = '['+firstChar.toUpperCase()+firstChar.toLowerCase()+']'; - titleFragment = firstChar+category.substr(1); - var categoryRegex = '\\[\\['+categoryNSFragment+':'+titleFragment+'(\\|[^\\]]*)?\\]\\]'; + firstChar = category.charAt( 0 ); + firstChar = '[' + firstChar.toUpperCase() + firstChar.toLowerCase() + ']'; + titleFragment = firstChar + category.substr( 1 ); + var categoryRegex = '\\[\\[' + categoryNSFragment + ':' + titleFragment + '(\\|[^\\]]*)?\\]\\]'; categoryRegex = new RegExp( categoryRegex, 'g' ); - var summary = gM('ajax-remove-category-summary', category); + var summary = gM( 'ajax-remove-category-summary', category ); ajaxCategories.confirmEdit( wgPageName, - function(oldText) { - var newText = oldText.replace(categoryRegex, ''); + function( oldText ) { + var newText = oldText.replace( categoryRegex, '' ); - if (newText == oldText) { - var error = gM('ajax-remove-category-error'); + if ( newText == oldText ) { + var error = gM( 'ajax-remove-category-error' ); ajaxCategories.showError( error ); - ajaxCategories.removeProgressIndicator( $j('.mw-ajax-confirm-dialog') ); - $j('.mw-ajax-confirm-dialog').dialog('close'); + ajaxCategories.removeProgressIndicator( $j( '.mw-ajax-confirm-dialog' ) ); + $j( '.mw-ajax-confirm-dialog' ).dialog( 'close' ); return false; } @@ -260,66 +260,66 @@ var ajaxCategories = { }, showError : function( str ) { - var dialog = $j('
'); - dialog.text(str); + var dialog = $j( '
' ); + dialog.text( str ); - $j('#bodyContent').append(dialog); + $j( '#bodyContent' ).append( dialog ); - var buttons = {}; - buttons[gM('ajax-error-dismiss')] = function(e) { - dialog.dialog('close'); + var buttons = { }; + buttons[gM( 'ajax-error-dismiss' )] = function( e ) { + dialog.dialog( 'close' ); }; var dialogOptions = { 'buttons' : buttons, 'AutoOpen' : true, - 'title' : gM('ajax-error-title') + 'title' : gM( 'ajax-error-title' ) }; - dialog.dialog(dialogOptions); + dialog.dialog( dialogOptions ); }, setupAJAXCategories : function() { // Only do it for articles. if ( !wgIsArticle ) return; - var clElement = $j('.catlinks'); + var clElement = $j( '.catlinks' ); // Unhide hidden category holders. clElement.removeClass( 'catlinks-allhidden' ); - var addLink = $j(''); + var addLink = $j( '' ); addLink.addClass( 'mw-ajax-addcategory' ); // Create [Add Category] link addLink.text( gM( 'ajax-add-category' ) ); - addLink.attr('href', '#'); + addLink.attr( 'href', '#' ); addLink.click( ajaxCategories.handleAddLink ); - clElement.append(addLink); + clElement.append( addLink ); // Create add category prompt - var promptContainer = $j('
'); - var promptTextbox = $j(''); - var addButton = $j('' ); - addButton.val( gM('ajax-add-category-submit') ); + var promptContainer = $j( '
' ); + var promptTextbox = $j( '' ); + var addButton = $j( '' ); + addButton.val( gM( 'ajax-add-category-submit' ) ); promptTextbox.keypress( ajaxCategories.handleCategoryInput ); addButton.click( ajaxCategories.handleCategoryAdd ); - promptContainer.append(promptTextbox); - promptContainer.append(addButton); + promptContainer.append( promptTextbox ); + promptContainer.append( addButton ); promptContainer.hide(); // Create delete link for each category. - $j('.catlinks div span a').each( function(e) { + $j( '.catlinks div span a' ).each( function( e ) { // Create a remove link - var deleteLink = $j(''); + var deleteLink = $j( '' ); - deleteLink.click(ajaxCategories.handleDeleteLink); + deleteLink.click( ajaxCategories.handleDeleteLink ); - $j(this).after(deleteLink); + $j( this ).after( deleteLink ); } ); - clElement.append(promptContainer); + clElement.append( promptContainer ); } }; diff --git a/js2/apiProxyPage.js b/js2/apiProxyPage.js index 7e37959a10..f113a5d119 100644 --- a/js2/apiProxyPage.js +++ b/js2/apiProxyPage.js @@ -10,19 +10,19 @@ mw.conf['debug_pre'] = 'Proxy'; -if( !mwApiProxyConfig ) - var mwApiProxyConfig = {}; +if ( !mwApiProxyConfig ) + var mwApiProxyConfig = { }; // 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' : [] + 'master_blacklist' : [] }; // 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); - $j.apiProxy( 'server', mwApiProxyConfig ); -}); +js2AddOnloadHook( function() { + // build our configuration from the default and mwApiProxyConfig vars + mwApiProxyConfig = $j.extend( true, mwApiProxyDefaultConfig, mwApiProxyConfig ); + $j.apiProxy( 'server', mwApiProxyConfig ); +} ); diff --git a/js2/editPage.js b/js2/editPage.js index 0e93231d2f..15c47f9e52 100644 --- a/js2/editPage.js +++ b/js2/editPage.js @@ -4,10 +4,10 @@ */ // Setup configuration vars (if not set already) -if( !mwAddMediaConfig ) - var mwAddMediaConfig = {}; +if ( !mwAddMediaConfig ) + var mwAddMediaConfig = { }; -//The default editPage AMW config +// The default editPage AMW config var defaultAddMediaConfig = { 'profile': 'mediawiki_edit', 'target_textbox': '#wpTextbox1', @@ -21,35 +21,35 @@ var defaultAddMediaConfig = { }; js2AddOnloadHook( function() { - js_log("edit page js2AddOnloadHook::"); + js_log( "edit page js2AddOnloadHook::" ); var amwConf = $j.extend( true, defaultAddMediaConfig, mwAddMediaConfig ); // kind of tricky, it would be nice to use run on ready "loader" call here - var didWikiEditorBind = false; + var didWikiEditorBind = false; - //Set-up the drag drop binding (will only work for html5 upload browsers) - //$j('textarea#wpTextbox1').dragFileUpload(); - - //set up the add-media-wizard binding: - if( typeof $j.wikiEditor != 'undefined' ) { - //the below seems to be broken :( + // Set-up the drag drop binding (will only work for html5 upload browsers) + // $j('textarea#wpTextbox1').dragFileUpload(); + + // set up the add-media-wizard binding: + if ( typeof $j.wikiEditor != 'undefined' ) { + // the below seems to be broken :( $j( 'textarea#wpTextbox1' ).bind( 'wikiEditor-toolbar-buildSection-main', function( e, section ) { didWikiEditorBind = true; if ( typeof section.groups.insert.tools.file !== 'undefined' ) { section.groups.insert.tools.file.action = { 'type': 'callback', - 'execute': function() { - js_log('click add media wiz'); + 'execute': function() { + js_log( 'click add media wiz' ); $j.addMediaWiz( amwConf ); } }; } } ); - } - //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 ){ + } + // 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( 'Do old toolbar bind:' ); didWikiEditorBind = true; $j( '#toolbar' ).append( ')[^>]*$|^#([\w-]+)$/, // Is it a simple selector - isSimple = /^.[^:#\[\.,]*$/; + isSimple = / ^ .[ ^ :# \[\.,]*$/; jQuery.fn = jQuery.prototype = { init: function( selector, context ) { @@ -50,7 +50,7 @@ jQuery.fn = jQuery.prototype = { var match = quickExpr.exec( selector ); // Verify a match, and that no context was specified for #id - if ( match && (match[1] || !context) ) { + if ( match && ( match[1] || !context ) ) { // HANDLE: $(html) -> $(array) if ( match[1] ) @@ -88,9 +88,9 @@ jQuery.fn = jQuery.prototype = { this.context = selector.context; } - return this.setArray(jQuery.isArray( selector ) ? + return this.setArray( jQuery.isArray( selector ) ? selector : - jQuery.makeArray(selector)); + jQuery.makeArray( selector ) ); }, // Start with an empty selector @@ -128,7 +128,7 @@ jQuery.fn = jQuery.prototype = { ret.context = this.context; if ( name === "find" ) - ret.selector = this.selector + (this.selector ? " " : "") + selector; + ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; else if ( name ) ret.selector = this.selector + "." + name + "(" + selector + ")"; @@ -174,12 +174,12 @@ jQuery.fn = jQuery.prototype = { return this[0] && jQuery[ type || "attr" ]( this[0], name ); else { - options = {}; + options = { }; options[ name ] = value; } // Check to see if we're setting style values - return this.each(function(i){ + return this.each( function( i ) { // Set all the styles for ( name in options ) jQuery.attr( @@ -188,30 +188,30 @@ jQuery.fn = jQuery.prototype = { this, name, jQuery.prop( this, options[ name ], type, i, name ) ); - }); + } ); }, css: function( key, value ) { // ignore negative width and height values - if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 ) + if ( ( key == 'width' || key == 'height' ) && parseFloat( value ) < 0 ) value = undefined; return this.attr( key, value, "curCSS" ); }, text: function( text ) { if ( typeof text !== "object" && text != null ) - return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); + return this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( text ) ); var ret = ""; - jQuery.each( text || this, function(){ - jQuery.each( this.childNodes, function(){ + jQuery.each( text || this, function() { + jQuery.each( this.childNodes, function() { if ( this.nodeType != 8 ) ret += this.nodeType != 1 ? this.nodeValue : jQuery.fn.text( [ this ] ); - }); - }); + } ); + } ); return ret; }, @@ -219,60 +219,60 @@ jQuery.fn = jQuery.prototype = { wrapAll: function( html ) { if ( this[0] ) { // The elements to wrap the target around - var wrap = jQuery( html, this[0].ownerDocument ).clone(); + var wrap = jQuery( html, this[0].ownerDocument ). clone (); if ( this[0].parentNode ) wrap.insertBefore( this[0] ); - wrap.map(function(){ + wrap.map( function() { var elem = this; while ( elem.firstChild ) elem = elem.firstChild; return elem; - }).append(this); + } ).append( this ); } return this; }, wrapInner: function( html ) { - return this.each(function(){ + return this.each( function() { jQuery( this ).contents().wrapAll( html ); - }); + } ); }, wrap: function( html ) { - return this.each(function(){ + return this.each( function() { jQuery( this ).wrapAll( html ); - }); + } ); }, append: function() { - return this.domManip(arguments, true, function(elem){ - if (this.nodeType == 1) + return this.domManip( arguments, true, function( elem ) { + if ( this.nodeType == 1 ) this.appendChild( elem ); - }); + } ); }, prepend: function() { - return this.domManip(arguments, true, function(elem){ - if (this.nodeType == 1) + return this.domManip( arguments, true, function( elem ) { + if ( this.nodeType == 1 ) this.insertBefore( elem, this.firstChild ); - }); + } ); }, before: function() { - return this.domManip(arguments, false, function(elem){ + return this.domManip( arguments, false, function( elem ) { this.parentNode.insertBefore( elem, this ); - }); + } ); }, after: function() { - return this.domManip(arguments, false, function(elem){ + return this.domManip( arguments, false, function( elem ) { this.parentNode.insertBefore( elem, this.nextSibling ); - }); + } ); }, end: function() { @@ -292,16 +292,16 @@ jQuery.fn = jQuery.prototype = { jQuery.find( selector, this[0], ret ); return ret; } else { - return this.pushStack( jQuery.unique(jQuery.map(this, function(elem){ + return this.pushStack( jQuery.unique( jQuery.map( this, function( elem ) { return jQuery.find( selector, elem ); - })), "find", selector ); + } ) ), "find", selector ); } }, - clone: function( events ) { + clone : function( events ) { // Do the clone - var ret = this.map(function(){ - if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { + var ret = this.map( function() { + if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc( this ) ) { // IE copies events bound via attachEvent when // using cloneNode. Calling detachEvent on the // clone will also remove the events from the orignal @@ -312,21 +312,21 @@ jQuery.fn = jQuery.prototype = { // the name attribute on an input). var html = this.outerHTML; if ( !html ) { - var div = this.ownerDocument.createElement("div"); - div.appendChild( this.cloneNode(true) ); + var div = this.ownerDocument.createElement( "div" ); + div.appendChild( this.cloneNode( true ) ); html = div.innerHTML; } - return jQuery.clean([html.replace(/ jQuery\d+="(?:\d+|null)"/g, "").replace(/^\s*/, "")])[0]; + return jQuery.clean( [ html.replace( / jQuery\d+="(?:\d+|null)"/g, "" ).replace( /^\s*/, "" ) ] )[0]; } else - return this.cloneNode(true); - }); + return this.cloneNode( true ); + } ); // Copy the events from the original to the clone if ( events === true ) { - var orig = this.find("*").andSelf(), i = 0; + var orig = this.find( "*" ).andSelf(), i = 0; - ret.find("*").andSelf().each(function(){ + ret.find( "*" ).andSelf().each( function() { if ( this.nodeName !== orig[i].nodeName ) return; @@ -339,7 +339,7 @@ jQuery.fn = jQuery.prototype = { } i++; - }); + } ); } // Return the cloned set @@ -349,30 +349,30 @@ jQuery.fn = jQuery.prototype = { filter: function( selector ) { return this.pushStack( jQuery.isFunction( selector ) && - jQuery.grep(this, function(elem, i){ + jQuery.grep( this, function( elem, i ) { return selector.call( elem, i ); - }) || + } ) || - jQuery.multiFilter( selector, jQuery.grep(this, function(elem){ + jQuery.multiFilter( selector, jQuery.grep( this, function( elem ) { return elem.nodeType === 1; - }) ), "filter", selector ); + } ) ), "filter", selector ); }, closest: function( selector ) { - var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null, + var pos = jQuery.expr.match.POS.test( selector ) ? jQuery( selector ) : null, closer = 0; - return this.map(function(){ + return this.map( function() { var cur = this; while ( cur && cur.ownerDocument ) { - if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) { - jQuery.data(cur, "closest", closer); + if ( pos ? pos.index( cur ) > - 1 : jQuery( cur ).is( selector ) ) { + jQuery.data( cur, "closest", closer ); return cur; } cur = cur.parentNode; closer++; } - }); + } ); }, not: function( selector ) { @@ -384,9 +384,9 @@ jQuery.fn = jQuery.prototype = { selector = jQuery.multiFilter( selector, this ); var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType; - return this.filter(function() { + return this.filter( function() { return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector; - }); + } ); }, add: function( selector ) { @@ -395,7 +395,7 @@ jQuery.fn = jQuery.prototype = { typeof selector === "string" ? jQuery( selector ) : jQuery.makeArray( selector ) - ))); + ) ) ); }, is: function( selector ) { @@ -407,12 +407,12 @@ jQuery.fn = jQuery.prototype = { }, val: function( value ) { - if ( value === undefined ) { + if ( value === undefined ) { var elem = this[0]; if ( elem ) { - if( jQuery.nodeName( elem, 'option' ) ) - return (elem.attributes.value || {}).specified ? elem.value : elem.text; + if ( jQuery.nodeName( elem, 'option' ) ) + return ( elem.attributes.value || { } ).specified ? elem.value : elem.text; // We need to handle select boxes special if ( jQuery.nodeName( elem, "select" ) ) { @@ -431,7 +431,7 @@ jQuery.fn = jQuery.prototype = { if ( option.selected ) { // Get the specifc value for the option - value = jQuery(option).val(); + value = jQuery( option ).val(); // We don't need an array for one selects if ( one ) @@ -442,11 +442,11 @@ jQuery.fn = jQuery.prototype = { } } - return values; + return values; } // Everything else, we just grab the value - return (elem.value || "").replace(/\r/g, ""); + return ( elem.value || "" ).replace( /\r/g, "" ); } @@ -456,35 +456,35 @@ jQuery.fn = jQuery.prototype = { if ( typeof value === "number" ) value += ''; - return this.each(function(){ + return this.each( function() { if ( this.nodeType != 1 ) return; - if ( jQuery.isArray(value) && /radio|checkbox/.test( this.type ) ) - this.checked = (jQuery.inArray(this.value, value) >= 0 || - jQuery.inArray(this.name, value) >= 0); + if ( jQuery.isArray( value ) && / radio | checkbox / .test( this.type ) ) + this.checked = ( jQuery.inArray( this.value, value ) >= 0 || + jQuery.inArray( this.name, value ) >= 0 ); else if ( jQuery.nodeName( this, "select" ) ) { - var values = jQuery.makeArray(value); + var values = jQuery.makeArray( value ); - jQuery( "option", this ).each(function(){ - this.selected = (jQuery.inArray( this.value, values ) >= 0 || - jQuery.inArray( this.text, values ) >= 0); - }); + jQuery( "option", this ).each( function() { + this.selected = ( jQuery.inArray( this.value, values ) >= 0 || + jQuery.inArray( this.text, values ) >= 0 ); + } ); if ( !values.length ) - this.selectedIndex = -1; + this.selectedIndex = - 1; } else this.value = value; - }); + } ); }, html: function( value ) { return value === undefined ? - (this[0] ? - this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g, "") : - null) : + ( this[0] ? + this[0].innerHTML.replace( / jQuery\d+="(?:\d+|null)"/g, "" ) : + null ) : this.empty().append( value ); }, @@ -493,18 +493,18 @@ jQuery.fn = jQuery.prototype = { }, eq: function( i ) { - return this.slice( i, +i + 1 ); + return this.slice( i, + i + 1 ); }, slice: function() { return this.pushStack( Array.prototype.slice.apply( this, arguments ), - "slice", Array.prototype.slice.call(arguments).join(",") ); + "slice", Array.prototype.slice.call( arguments ).join( "," ) ); }, map: function( callback ) { - return this.pushStack( jQuery.map(this, function(elem, i){ + return this.pushStack( jQuery.map( this, function( elem, i ) { return callback.call( elem, i, elem ); - })); + } ) ); }, andSelf: function() { @@ -513,14 +513,14 @@ jQuery.fn = jQuery.prototype = { domManip: function( args, table, callback ) { if ( this[0] ) { - var fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(), - scripts = jQuery.clean( args, (this[0].ownerDocument || this[0]), fragment ), + var fragment = ( this[0].ownerDocument || this[0] ).createDocumentFragment(), + scripts = jQuery.clean( args, ( this[0].ownerDocument || this[0] ), fragment ), first = fragment.firstChild; if ( first ) for ( var i = 0, l = this.length; i < l; i++ ) - callback.call( root(this[i], first), this.length > 1 || i > 0 ? - fragment.cloneNode(true) : fragment ); + callback.call( root( this[i], first ), this.length > 1 || i > 0 ? + fragment.cloneNode( true ) : fragment ); if ( scripts ) jQuery.each( scripts, evalScript ); @@ -529,9 +529,9 @@ jQuery.fn = jQuery.prototype = { return this; function root( elem, cur ) { - return table && jQuery.nodeName(elem, "table") && jQuery.nodeName(cur, "tr") ? - (elem.getElementsByTagName("tbody")[0] || - elem.appendChild(elem.ownerDocument.createElement("tbody"))) : + return table && jQuery.nodeName( elem, "table" ) && jQuery.nodeName( cur, "tr" ) ? + ( elem.getElementsByTagName( "tbody" )[0] || + elem.appendChild( elem.ownerDocument.createElement( "tbody" ) ) ) : elem; } } @@ -542,11 +542,11 @@ jQuery.fn.init.prototype = jQuery.fn; function evalScript( i, elem ) { if ( elem.src ) - jQuery.ajax({ + jQuery.ajax( { url: elem.src, async: false, dataType: "script" - }); + } ); else jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); @@ -555,25 +555,25 @@ function evalScript( i, elem ) { elem.parentNode.removeChild( elem ); } -function now(){ - return +new Date; +function now() { + return + new Date; } jQuery.extend = jQuery.fn.extend = function() { // copy reference to target object - var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options; + var target = arguments[0] || { }, i = 1, length = arguments.length, deep = false, options; // Handle a deep copy situation if ( typeof target === "boolean" ) { deep = target; - target = arguments[1] || {}; + target = arguments[1] || { }; // skip the boolean and the target i = 2; } // Handle case when target is a string or something (possible in deep copy) - if ( typeof target !== "object" && !jQuery.isFunction(target) ) - target = {}; + if ( typeof target !== "object" && !jQuery.isFunction( target ) ) + target = { }; // extend jQuery itself if only one argument is passed if ( length == i ) { @@ -583,7 +583,7 @@ jQuery.extend = jQuery.fn.extend = function() { for ( ; i < length; i++ ) // Only deal with non-null/undefined values - if ( (options = arguments[ i ]) != null ) + if ( ( options = arguments[ i ] ) != null ) // Extend the base object for ( var name in options ) { var src = target[ name ], copy = options[ name ]; @@ -594,7 +594,7 @@ jQuery.extend = jQuery.fn.extend = function() { // Recurse if we're merging object values if ( deep && copy && typeof copy === "object" && !copy.nodeType ) - target[ name ] = jQuery.extend( deep, + target[ name ] = jQuery.extend( deep, // Never move original objects, clone them src || ( copy.length != null ? [ ] : { } ) , copy ); @@ -610,12 +610,12 @@ jQuery.extend = jQuery.fn.extend = function() { }; // exclude the following css properties to add px -var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, +var exclude = / z - ? index | font - ? weight | opacity | zoom | line - ? height / i, // cache defaultView - defaultView = document.defaultView || {}, + defaultView = document.defaultView || { }, toString = Object.prototype.toString; -jQuery.extend({ +jQuery.extend( { noConflict: function( deep ) { window.$ = _$; @@ -629,11 +629,11 @@ jQuery.extend({ // Since version 1.3, DOM methods and functions like alert // aren't supported. They return false on IE (#2968). isFunction: function( obj ) { - return toString.call(obj) === "[object Function]"; + return toString.call( obj ) === "[object Function]"; }, isArray: function( obj ) { - return toString.call(obj) === "[object Array]"; + return toString.call( obj ) === "[object Array]"; }, // check if an element is in a (or is an) XML document @@ -644,11 +644,11 @@ jQuery.extend({ // Evalulates a script in a global context globalEval: function( data ) { - if ( data && /\S/.test(data) ) { + if ( data && /\S/.test( data ) ) { // Inspired by code by Andrea Giammarchi // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html - var head = document.getElementsByTagName("head")[0] || document.documentElement, - script = document.createElement("script"); + var head = document.getElementsByTagName( "head" )[0] || document.documentElement, + script = document.createElement( "script" ); script.type = "text/javascript"; if ( jQuery.support.scriptEval ) @@ -689,7 +689,7 @@ jQuery.extend({ break; } else for ( var value = object[0]; - i < length && callback.call( value, i, value ) !== false; value = object[++i] ){} + i < length && callback.call( value, i, value ) !== false; value = object[++i] ) { } } return object; @@ -709,31 +709,31 @@ jQuery.extend({ className: { // internal only, use addClass("class") add: function( elem, classNames ) { - jQuery.each((classNames || "").split(/\s+/), function(i, className){ + jQuery.each( ( classNames || "" ).split( /\s+/ ), function( i, className ) { if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) ) - elem.className += (elem.className ? " " : "") + className; - }); + elem.className += ( elem.className ? " " : "" ) + className; + } ); }, // internal only, use removeClass("class") remove: function( elem, classNames ) { - if (elem.nodeType == 1) + if ( elem.nodeType == 1 ) elem.className = classNames !== undefined ? - jQuery.grep(elem.className.split(/\s+/), function(className){ + jQuery.grep( elem.className.split( /\s+/ ), function( className ) { return !jQuery.className.has( classNames, className ); - }).join(" ") : + } ).join( " " ) : ""; }, // internal only, use hasClass("class") has: function( elem, className ) { - return elem && jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1; + return elem && jQuery.inArray( className, ( elem.className || elem ).toString().split( /\s+/ ) ) > -1; } }, // A method for quickly swapping in/out CSS properties to get correct calculations swap: function( elem, options, callback ) { - var old = {}; + var old = { }; // Remember the old values, and insert the new ones for ( var name in options ) { old[ name ] = elem.style[ name ]; @@ -759,12 +759,12 @@ jQuery.extend({ jQuery.each( which, function() { if ( !extra ) - val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; + val -= parseFloat( jQuery.curCSS( elem, "padding" + this, true ) ) || 0; if ( extra === "margin" ) - val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0; + val += parseFloat( jQuery.curCSS( elem, "margin" + this, true ) ) || 0; else - val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; - }); + val -= parseFloat( jQuery.curCSS( elem, "border" + this + "Width", true ) ) || 0; + } ); } if ( elem.offsetWidth !== 0 ) @@ -772,7 +772,7 @@ jQuery.extend({ else jQuery.swap( elem, props, getWH ); - return Math.max(0, Math.round(val)); + return Math.max( 0, Math.round( val ) ); } return jQuery.curCSS( elem, name, force ); @@ -791,7 +791,7 @@ jQuery.extend({ } // Make sure we're using the right name for getting the float value - if ( name.match( /float/i ) ) + if ( name.match( / float / i ) ) name = styleFloat; if ( !force && style && style[ name ] ) @@ -800,10 +800,10 @@ jQuery.extend({ else if ( defaultView.getComputedStyle ) { // Only "float" is needed here - if ( name.match( /float/i ) ) + if ( name.match( / float / i ) ) name = "float"; - name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase(); + name = name.replace( / ( [A - Z] ) / g, "-$1" ).toLowerCase(); var computedStyle = defaultView.getComputedStyle( elem, null ); @@ -815,9 +815,9 @@ jQuery.extend({ ret = "1"; } else if ( elem.currentStyle ) { - var camelCase = name.replace(/\-(\w)/g, function(all, letter){ + var camelCase = name.replace( /\-(\w)/g, function( all, letter ) { return letter.toUpperCase(); - }); + } ); ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; diff --git a/js2/mwEmbed/libAddMedia/dragDropFile.js b/js2/mwEmbed/libAddMedia/dragDropFile.js index 35bf0f4a78..dad7b042d7 100644 --- a/js2/mwEmbed/libAddMedia/dragDropFile.js +++ b/js2/mwEmbed/libAddMedia/dragDropFile.js @@ -1,39 +1,39 @@ /* firefox 3.6 drag-drop uploading */ -loadGM({ +loadGM( { "mwe-upload-multi" : "Upload {{PLURAL:$1|file|files}}", "mwe-review-upload": "Review file {{PLURAL:$1|upload|uploads}}" -}); +} ); -(function($){ +( function( $ ) { $.fn.dragDropFile = function () { - js_log("drag drop: " + this.selector); - //setup drag binding and highlight - var dC = $j( this.selector ).get(0); - dC.addEventListener("dragenter", - function(event){ - $j(dC).css('border', 'solid red'); + js_log( "drag drop: " + this.selector ); + // setup drag binding and highlight + var dC = $j( this.selector ).get( 0 ); + dC.addEventListener( "dragenter", + function( event ) { + $j( dC ).css( 'border', 'solid red' ); event.stopPropagation(); event.preventDefault(); - }, false); - dC.addEventListener("dragleave", - function(event){ - //default textbox css (should be an easy way to do this) - $j(dC).css('border', ''); + }, false ); + dC.addEventListener( "dragleave", + function( event ) { + // default textbox css (should be an easy way to do this) + $j( dC ).css( 'border', '' ); event.stopPropagation(); event.preventDefault(); - }, false); - dC.addEventListener("dragover", - function(event){ + }, false ); + dC.addEventListener( "dragover", + function( event ) { event.stopPropagation(); event.preventDefault(); - }, false); - dC.addEventListener("drop", - function( event ){ + }, false ); + dC.addEventListener( "drop", + function( event ) { doDrop( event ); - //handle the drop loader and call event - }, false); - function doDrop(event){ + // handle the drop loader and call event + }, false ); + function doDrop( event ) { var dt = event.dataTransfer, files = dt.files, fileCount = files.length; @@ -41,47 +41,47 @@ loadGM({ event.stopPropagation(); event.preventDefault(); - $j('#multiple_file_input').remove(); + $j( '#multiple_file_input' ).remove(); - $j('body').append('
' + '
' ); - var cBtn = {}; - cBtn[ gM('mwe-cancel') ] = function(){ - $j(this).dialog('close'); + var cBtn = { }; + cBtn[ gM( 'mwe-cancel' ) ] = function() { + $j( this ).dialog( 'close' ); } - cBtn[ gM('mwe-upload-multi', fileCount) ] = function(){ - alert('do multiple file upload'); + cBtn[ gM( 'mwe-upload-multi', fileCount ) ] = function() { + alert( 'do multiple file upload' ); } - //open up the dialog - $j('#multiple_file_input').dialog({ + // open up the dialog + $j( '#multiple_file_input' ).dialog( { bgiframe: true, autoOpen: true, modal: true, draggable:false, resizable:false, buttons:cBtn - }); - $j('#multiple_file_input').dialogFitWindow(); - $j(window).resize(function(){ - $j('#multiple_file_input').dialogFitWindow(); - }); - //add the inital table / title: - $j('#multiple_file_input').html('

' + gM('mwe-review-upload') + '

'+ - '
'); - $j.each(files, function(i, file){ - if(file.fileSize < 64048576) { - $j('#multiple_file_input .table_list').append( + } ); + $j( '#multiple_file_input' ).dialogFitWindow(); + $j( window ).resize( function() { + $j( '#multiple_file_input' ).dialogFitWindow(); + } ); + // add the inital table / title: + $j( '#multiple_file_input' ).html( '

' + gM( 'mwe-review-upload' ) + '

' + + '
' ); + $j.each( files, function( i, file ) { + if ( file.fileSize < 64048576 ) { + $j( '#multiple_file_input .table_list' ).append( '' + - '' +''+ + '' + '' + '' + - 'File Name:
'+ - 'File Desc:
'+ - ''+ + 'File Name:
' + + 'File Desc:
' + + '' + '' ); /*$j.addDialog( "upload this image", '' + @@ -89,11 +89,11 @@ loadGM({ '
size: ' + files[i].fileSize + '
' + '
mime: ' + files[i].mediaType + '
'); */ - //do the add-media-wizard with the upload tab + // do the add-media-wizard with the upload tab } else { - alert("file is too big, needs to be below 64mb"); + alert( "file is too big, needs to be below 64mb" ); } - }); + } ); } } -})(jQuery); +} )( jQuery ); diff --git a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js index 6442b5cf84..34f32cd496 100644 --- a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js +++ b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js @@ -4,7 +4,7 @@ * supporting remote searching of http archives for free images/audio/video assets */ -loadGM({ +loadGM( { "mwe-add_media_wizard" : "Add media wizard", "mwe-media_search" : "Media search", "rsd_box_layout" : "Box layout", @@ -66,15 +66,15 @@ loadGM({ "rsd-metavid-title" : "Metavid.org", "rsd-metavid-desc" : "Metavid.org, a community archive of US House and Senate floor proceedings" -}); +} ); var default_remote_search_options = { 'profile':'mediawiki_edit', - 'target_container':null, //the div that will hold the search interface + 'target_container':null, // the div that will hold the search interface - 'target_invocation': null, //the button or link that will invoke the search interface + 'target_invocation': null, // the button or link that will invoke the search interface - 'default_provider_id':'all', //all or one of the content_providers ids + 'default_provider_id':'all', // all or one of the content_providers ids 'caret_pos':null, 'local_wiki_api_url':null, @@ -89,48 +89,48 @@ var default_remote_search_options = { 'target_textbox':null, - '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 + '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 'p_seq':null, - 'cFileNS':'File', //What is the canonical namespace prefix for images - //@@todo (should get that from the api or in-page vars) - + 'cFileNS':'File', // What is the canonical namespace prefix for images + // @@todo (should get that from the api or in-page vars) + 'upload_api_target': 'local', // can be local or the url or remote 'upload_api_name' : null, - 'upload_api_proxy_frame': null, //a page that will request mw.proxy.server - - 'enabled_cps':'all', //can be keyword 'all' or an array of enabled content provider keys - - 'disp_item':null //sets the default display item: + 'upload_api_proxy_frame': null, // a page that will request mw.proxy.server + + 'enabled_cps':'all', // can be keyword 'all' or an array of enabled content provider keys + + 'disp_item':null // sets the default display item: } -if(typeof wgServer == 'undefined') +if ( typeof wgServer == 'undefined' ) wgServer = ''; -if(typeof wgScriptPath == 'undefined') +if ( typeof wgScriptPath == 'undefined' ) wgScriptPath = ''; -if(typeof stylepath == 'undefined') +if ( typeof stylepath == 'undefined' ) stylepath = ''; /* * Base remoteSearch Driver interface */ -var remoteSearchDriver = function(iObj){ +var remoteSearchDriver = function( iObj ) { return this.init( iObj ); } remoteSearchDriver.prototype = { results_cleared:false, - //here we define the set of possible media content providers: - main_search_options:{ - 'selprovider':{ + // here we define the set of possible media content providers: + main_search_options: { + 'selprovider': { 'title': 'Select Providers' }, - 'advanced_search':{ + 'advanced_search': { 'title': 'Advanced Options' } - }, + }, /** the default content providers list. * * (should be note that special tabs like "upload" and "combined" don't go into the content providers list: @@ -138,7 +138,7 @@ remoteSearchDriver.prototype = { * * @@todo we will want to load more per user-preference and per category lookup */ - content_providers:{ + content_providers: { /*content_providers documentation: * @@todo we should move the bulk of the configuration to each file * @@ -163,36 +163,36 @@ remoteSearchDriver.prototype = { //@@todo should query wgForeignFileRepos setting maybe interwikimap from the api */ - 'this_wiki':{ + 'this_wiki': { 'enabled': 1, - 'checked': 1, - 'api_url': ( wgServer && wgScriptPath )? wgServer + wgScriptPath+ '/api.php': null, + 'checked': 1, + 'api_url': ( wgServer && wgScriptPath ) ? wgServer + wgScriptPath + '/api.php': null, 'lib' : 'mediaWiki', 'local' : true, 'tab_img': false - }, - 'wiki_commons':{ + }, + 'wiki_commons': { 'enabled': 1, - 'checked': 1, + 'checked': 1, 'homepage': 'http://commons.wikimedia.org/wiki/Main_Page', 'api_url':'http://commons.wikimedia.org/w/api.php', 'lib' :'mediaWiki', - 'resource_prefix': 'WC_', //prefix on imported resources (not applicable if the repository is local) - - //if we should check for shared repository asset ( generally only applicable to commons ) + 'resource_prefix': 'WC_', // prefix on imported resources (not applicable if the repository is local) + + // if we should check for shared repository asset ( generally only applicable to commons ) 'check_shared':true, - //list all the domains where commons is local? + // list all the domains where commons is local? // probably should set this some other way by doing an api query // or by seeding this config when calling the remote search? - 'local_domains': ['wikimedia','wikipedia','wikibooks'], - //specific to wiki commons config: - 'search_title':false, //disable title search + 'local_domains': ['wikimedia', 'wikipedia', 'wikibooks'], + // specific to wiki commons config: + 'search_title':false, // disable title search 'tab_img':true }, - 'archive_org':{ + 'archive_org': { 'enabled':1, - 'checked':1, + 'checked':1, 'homepage':'http://www.archive.org/about/about.php', 'api_url':'http://homeserver7.us.archive.org:8983/solr/select', @@ -201,118 +201,118 @@ remoteSearchDriver.prototype = { 'resource_prefix': 'AO_', 'tab_img':true }, - 'flickr':{ + 'flickr': { 'enabled':1, - 'checked':1, + '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 identifier/title + // resources from fliker don't have a human parsable identifier/title 'resource_prefix': '', 'tab_img':true - }, - 'metavid':{ + }, + 'metavid': { 'enabled' : 1, 'checked' : 1, 'homepage':'http://metavid.org/wiki/Metavid_Overview', 'api_url':'http://metavid.org/w/index.php?title=Special:MvExportSearch', 'lib' : 'metavid', - 'local' :false, //if local set to true we can use local - 'resource_prefix': 'MV_', //what prefix to use on imported resources + 'local' :false, // if local set to true we can use local + 'resource_prefix': 'MV_', // what prefix to use on imported resources 'local_domains': ['metavid'], // if the domain name contains metavid // no need to import metavid content to metavid sites 'stream_import_key': 'mv_ogg_low_quality', // which stream to import, could be mv_ogg_high_quality - //or flash stream, see ROE xml for keys + // or flash stream, see ROE xml for keys - 'remote_embed_ext': false, //if running the remoteEmbed extension no need to copy local - //syntax will be [remoteEmbed:roe_url link title] + 'remote_embed_ext': false, // if running the remoteEmbed extension no need to copy local + // syntax will be [remoteEmbed:roe_url link title] 'tab_img':true }, - //special cp "upload" - 'upload':{ + // special cp "upload" + 'upload': { 'enabled':1, 'checked':1, 'title' :'Upload' } - }, - //some default layout values: + }, + // some default layout values: thumb_width : 80, image_edit_width : 400, video_edit_width : 400, - insert_text_pos : 0, //insert at the start (will be overwritten by the user cursor pos) - result_display_mode : 'box', //box or list + insert_text_pos : 0, // insert at the start (will be overwritten by the user cursor pos) + result_display_mode : 'box', // box or list cUpLoader : null, cEdit : null, proxySetupDone : null, - dmodalCss : {}, + dmodalCss : { }, - init: function( options ){ + init: function( options ) { var _this = this; - js_log('remoteSearchDriver:init'); + js_log( 'remoteSearchDriver:init' ); - //merge in the options: - //@@todo for cleaner config we should set _this.opt to the provided options) - $j.extend( _this, default_remote_search_options, options); + // merge in the options: + // @@todo for cleaner config we should set _this.opt to the provided options) + $j.extend( _this, default_remote_search_options, options ); - //Quick fix for cases where people put ['all'] instead of 'all' for enabled_cps - if( _this.enabled_cps.length == 1 && _this.enabled_cps[0] == 'all') + // Quick fix for cases where people put ['all'] instead of 'all' for enabled_cps + if ( _this.enabled_cps.length == 1 && _this.enabled_cps[0] == 'all' ) _this.enabled_cps = 'all'; - //modify the content provider config based on options: - for(var i in this.content_providers){ - if( _this.enabled_cps == 'all' && !this.disp_item ){ + // modify the content provider config based on options: + for ( var i in this.content_providers ) { + if ( _this.enabled_cps == 'all' && !this.disp_item ) { this.disp_item = i; - //end the for loop (no need to idorate if enabled_cps == 'all' + // end the for loop (no need to idorate if enabled_cps == 'all' break; - }else{ - if( $j.inArray( i, _this.enabled_cps ) != -1 ){ - //if no default display set to first enabled cp: - if( !this.disp_item ) + } else { + if ( $j.inArray( i, _this.enabled_cps ) != - 1 ) { + // if no default display set to first enabled cp: + if ( !this.disp_item ) this.disp_item = i; this.content_providers[i].enabled = true; - }else{ - if( _this.enabled_cps != 'all' ){ + } else { + if ( _this.enabled_cps != 'all' ) { this.content_providers[i].enabled = false; } - } + } } } - //set the upload target name if unset - if( _this.upload_api_target == 'local' && ! _this.upload_api_name && typeof wgSiteName != 'undefined') + // set the upload target name if unset + if ( _this.upload_api_target == 'local' && ! _this.upload_api_name && typeof wgSiteName != 'undefined' ) _this.upload_api_name = wgSiteName; - //if the upload_api_proxy_frame is set _this.upload_api_target to "proxy" - if( _this.upload_api_proxy_frame ) + // if the upload_api_proxy_frame is set _this.upload_api_target to "proxy" + if ( _this.upload_api_proxy_frame ) _this.upload_api_target = 'proxy'; - //map "local" to the local api - if( _this.upload_api_target == 'local' ){ - if( ! _this.local_wiki_api_url ){ - $j('#tab-upload').html( gM( 'rsd_config_error', 'missing_local_api_url' ) ); + // map "local" to the local api + if ( _this.upload_api_target == 'local' ) { + if ( ! _this.local_wiki_api_url ) { + $j( '#tab-upload' ).html( gM( 'rsd_config_error', 'missing_local_api_url' ) ); return false; - }else{ + } else { _this.upload_api_target = _this.local_wiki_api_url; } - } + } - //set up the target invocation: - if( $j( this.target_invocation ).length==0 ){ - js_log("RemoteSearchDriver:: no target invocation provided (will have to run your own doInitDisplay() )"); - }else{ - if( this.target_invocation ){ - $j(this.target_invocation).css('cursor','pointer').attr('title', gM('mwe-add_media_wizard')).click(function(){ + // set up the target invocation: + if ( $j( this.target_invocation ).length == 0 ) { + js_log( "RemoteSearchDriver:: no target invocation provided (will have to run your own doInitDisplay() )" ); + } else { + if ( this.target_invocation ) { + $j( this.target_invocation ).css( 'cursor', 'pointer' ).attr( 'title', gM( 'mwe-add_media_wizard' ) ).click( function() { _this.doInitDisplay(); - }); + } ); } } }, - //define the licenses + // define the licenses // ... this will get complicated quick... // (just look at complexity for creative commons without excessive "duplicate data") // ie cc_by could be "by/3.0/us/" or "by/2.1/jp/" to infinitum... @@ -321,10 +321,10 @@ remoteSearchDriver.prototype = { // but we will have to abstract into another class let content providers provide license urls // and we have to clone the license object and allow local overrides - licenses:{ - //for now only support creative commons type licenses - //used page: http://creativecommons.org/licenses/ - 'cc':{ + licenses: { + // for now only support creative commons type licenses + // used page: http://creativecommons.org/licenses/ + 'cc': { 'base_img_url':'http://upload.wikimedia.org/wikipedia/commons/thumb/', 'base_license_url': 'http://creativecommons.org/licenses/', 'licenses':[ @@ -337,20 +337,20 @@ remoteSearchDriver.prototype = { 'by-sa', 'pd' ], - 'license_img':{ - 'by':{ + 'license_img': { + 'by': { 'im':'1/11/Cc-by_new_white.svg/20px-Cc-by_new_white.svg.png' }, - 'nc':{ + 'nc': { 'im':'2/2f/Cc-nc_white.svg/20px-Cc-nc_white.svg.png' }, - 'nd':{ + 'nd': { 'im':'b/b3/Cc-nd_white.svg/20px-Cc-nd_white.svg.png' }, - 'sa':{ + 'sa': { 'im':'d/df/Cc-sa_white.svg/20px-Cc-sa_white.svg.png' }, - 'pd':{ + 'pd': { 'im':'5/51/Cc-pd-new_white.svg/20px-Cc-pd-new_white.svg.png' } } @@ -360,36 +360,36 @@ remoteSearchDriver.prototype = { * getlicenseImgSet * @param license_key the license key (ie "by-sa" or "by-nc-sa" etc) */ - getlicenseImgSet: function( licenseObj ){ - //js_log('output images: '+ imgs); - return '
' + - ''+ + getlicenseImgSet: function( licenseObj ) { + // js_log('output images: '+ imgs); + return ''; - }, + }, /* * getLicenceKeyFromKey * @param license_key the key of the license (must be defined in: this.licenses.cc.licenses) */ - getLicenceFromKey:function( license_key , force_url){ - //set the current license pointer: + getLicenceFromKey:function( license_key , force_url ) { + // set the current license pointer: var cl = this.licenses.cc; - var title = gM('mwe-cc_title'); + var title = gM( 'mwe-cc_title' ); var imgs = ''; - var license_set = license_key.split('-'); - for(var i=0;i < license_set.length; i++){ + var license_set = license_key.split( '-' ); + for ( var i = 0; i < license_set.length; i++ ) { var lkey = license_set[i]; - if(! cl.license_img[ lkey ] ){ - js_log("MISSING::" + lkey ); + if ( ! cl.license_img[ lkey ] ) { + js_log( "MISSING::" + lkey ); } - title += ' ' + gM( 'mwe-cc_' + lkey + '_title'); - imgs +=''; } - var url = (force_url) ? force_url : cl.base_license_url + cl.licenses[ license_key ]; + var url = ( force_url ) ? force_url : cl.base_license_url + cl.licenses[ license_key ]; return { 'title' : title, 'img_html' : imgs, @@ -401,31 +401,31 @@ remoteSearchDriver.prototype = { * getLicenceKeyFromUrl * @param licence_url the url of the license */ - getLicenceFromUrl: function( license_url ){ - //check for some pre-defined url types: - if( license_url == 'http://www.usa.gov/copyright.shtml' || + getLicenceFromUrl: function( license_url ) { + // check for some pre-defined url types: + if ( license_url == 'http://www.usa.gov/copyright.shtml' || license_url == 'http://creativecommons.org/licenses/publicdomain' ) - return this.getLicenceFromKey('pd' , license_url); + return this.getLicenceFromKey( 'pd' , license_url ); - //js_log("getLicenceFromUrl::" + license_url); - //first do a direct lookup check: - for(var j =0; j < this.licenses.cc.licenses.length; j++){ + // js_log("getLicenceFromUrl::" + license_url); + // first do a direct lookup check: + for ( var j = 0; j < this.licenses.cc.licenses.length; j++ ) { var jL = this.licenses.cc.licenses[ j ]; - //special 'pd' case: - if( jL == 'pd'){ + // special 'pd' case: + if ( jL == 'pd' ) { var keyCheck = 'publicdomain'; - }else{ + } else { var keyCheck = jL; - } - if( parseUri(license_url).path.indexOf('/'+ keyCheck +'/') != -1){ - return this.getLicenceFromKey(jL , license_url); } - }; - //could not find it return mwe-unknown_license + if ( parseUri( license_url ).path.indexOf( '/' + keyCheck + '/' ) != - 1 ) { + return this.getLicenceFromKey( jL , license_url ); + } + }; + // could not find it return mwe-unknown_license return { - 'title' : gM('mwe-unknown_license'), - 'img_html' : '' + gM('mwe-unknown_license') + '', + 'title' : gM( 'mwe-unknown_license' ), + 'img_html' : '' + gM( 'mwe-unknown_license' ) + '', 'lurl' : license_url }; }, @@ -433,9 +433,9 @@ remoteSearchDriver.prototype = { * getTypeIcon * @param str mime type of the requested file */ - getTypeIcon:function( mimetype) { + getTypeIcon:function( mimetype ) { var typestr = 'unk'; - switch( mimetype ){ + switch( mimetype ) { case 'image/svg+xml': typestr = 'svg'; break; @@ -453,275 +453,275 @@ remoteSearchDriver.prototype = { break; } - if(typestr=='unk'){ - js_log("unkown ftype: " + mimetype ); + if ( typestr == 'unk' ) { + js_log( "unkown ftype: " + mimetype ); return ''; - } + } - return '
' + + return '
' + typestr + '
' }, - doInitDisplay:function(){ + doInitDisplay:function() { var _this = this; - //try and get the text selection: + // try and get the text selection: _this.getTexboxSelection(); - //setup the parent container: + // setup the parent container: this.init_modal(); - //fill in the html: + // fill in the html: this.init_interface_html(); - //bind actions: + // bind actions: this.add_interface_bindings(); - //update the target binding to just un-hide the dialog: - if( this.target_invocation ){ - $j(this.target_invocation).unbind().click(function(){ - js_log("doInitDisplay:target_invocation: click doReDisp"); + // update the target binding to just un-hide the dialog: + if ( this.target_invocation ) { + $j( this.target_invocation ).unbind().click( function() { + js_log( "doInitDisplay:target_invocation: click doReDisp" ); _this.doReDisplay(); - }); + } ); } }, - doReDisplay: function(){ + doReDisplay: function() { var _this = this; - js_log("doReDisplay::"); - //update the base text: + js_log( "doReDisplay::" ); + // update the base text: _this.getTexboxSelection(); - if( _this.default_query != $j('#rsd_q').val() ){ - $j('#rsd_q').val( _this.default_query ); + if ( _this.default_query != $j( '#rsd_q' ).val() ) { + $j( '#rsd_q' ).val( _this.default_query ); _this.runSearch(); } - //$j(_this.target_container).dialog("open"); - $j(_this.target_container).parents('.ui-dialog').fadeIn('slow'); - //re-center the dialog: - $j(_this.target_container).dialog('option', 'position','center'); + // $j(_this.target_container).dialog("open"); + $j( _this.target_container ).parents( '.ui-dialog' ).fadeIn( 'slow' ); + // re-center the dialog: + $j( _this.target_container ).dialog( 'option', 'position', 'center' ); }, - //gets the in and out points for insert position or grabs the selected text for search - getTexboxSelection:function(){ - if(this.target_textbox){ - //get the selection text: - var ts = $j(this.target_textbox).textSelection(); - if(ts!=''){ + // gets the in and out points for insert position or grabs the selected text for search + getTexboxSelection:function() { + if ( this.target_textbox ) { + // get the selection text: + var ts = $j( this.target_textbox ).textSelection(); + if ( ts != '' ) { this.default_query = ts; } - //get the caretPos / value - this.caret_pos={}; - this.caret_pos.text = $j(this.target_textbox).val(); - this.caret_pos.s = $j(this.target_textbox).getCaretPosition(); + // get the caretPos / value + this.caret_pos = { }; + this.caret_pos.text = $j( this.target_textbox ).val(); + this.caret_pos.s = $j( this.target_textbox ).getCaretPosition(); } - }, - init_modal:function(){ - js_log("init_modal"); - var _this = this; - //add the parent target_container if not provided or missing - if(!_this.target_container || $j(_this.target_container).length==0){ + }, + init_modal:function() { + js_log( "init_modal" ); + var _this = this; + // add the parent target_container if not provided or missing + if ( !_this.target_container || $j( _this.target_container ).length == 0 ) { _this.target_container = '#rsd_modal_target'; - $j('body').append('
'); - //js_log('appended: #rsd_modal_target' + $j(_this.target_container).attr('id')); - //js_log('added target id:' + $j(_this.target_container).attr('id')); - //get layout - js_log( 'width: ' + $j(window).width() + ' height: ' + $j(window).height()); - var cBtn = {}; - cBtn[ gM('mwe-cancel') ] = function(){ + $j( 'body' ).append( '
' ); + // js_log('appended: #rsd_modal_target' + $j(_this.target_container).attr('id')); + // js_log('added target id:' + $j(_this.target_container).attr('id')); + // get layout + js_log( 'width: ' + $j( window ).width() + ' height: ' + $j( window ).height() ); + var cBtn = { }; + cBtn[ gM( 'mwe-cancel' ) ] = function() { _this.cancelClipEditCB(); - } + } - $j(_this.target_container).dialog({ + $j( _this.target_container ).dialog( { bgiframe: true, autoOpen: true, modal: true, draggable:false, resizable:false, - buttons:cBtn, + buttons:cBtn, close: function() { - //if we are 'editing' a item close that - //@@todo maybe prompt the user? - _this.cancelClipEditCB(); - $j(this).parents('.ui-dialog').fadeOut('slow'); + // if we are 'editing' a item close that + // @@todo maybe prompt the user? + _this.cancelClipEditCB(); + $j( this ).parents( '.ui-dialog' ).fadeOut( 'slow' ); } - }); - $j(_this.target_container).dialogFitWindow(); - $j(window).resize(function(){ - $j(_this.target_container).dialogFitWindow(); - }); + } ); + $j( _this.target_container ).dialogFitWindow(); + $j( window ).resize( function() { + $j( _this.target_container ).dialogFitWindow(); + } ); - //add cancel callback and updated button with icon - _this.cancelClipEditCB(); + // add cancel callback and updated button with icon + _this.cancelClipEditCB(); } }, - //sets up the initial html interface - init_interface_html:function(){ - js_log('init_interface_html'); + // sets up the initial html interface + init_interface_html:function() { + js_log( 'init_interface_html' ); var _this = this; - var dq = (this.default_query)? this.default_query : ''; - js_log('f::init_interface_html'); + var dq = ( this.default_query ) ? this.default_query : ''; + js_log( 'f::init_interface_html' ); var o = '
' + - '
'+ - ' '+ - $j.btnHtml( gM('mwe-media_search'), 'rms_search_button', 'search') + + '' + + ' ' + + $j.btnHtml( gM( 'mwe-media_search' ), 'rms_search_button', 'search' ) + '
'; - //close up the control container: - o+='
'; + // close up the control container: + o += '
'; - //search provider tabs based on "checked" and "enabled" and "combined tab" - o+='
'; - $j(this.target_container).html( o ); + // search provider tabs based on "checked" and "enabled" and "combined tab" + o += '
'; + $j( this.target_container ).html( o ); - //add simple styles: - $j(this.target_container + ' .rms_search_button').btnBind().click(function(){ + // add simple styles: + $j( this.target_container + ' .rms_search_button' ).btnBind().click( function() { _this.runSearch(); - }); + } ); - //draw the tabs: + // draw the tabs: this.drawTabs(); - //run the default search: - if( this.default_query ) + // run the default search: + if ( this.default_query ) this.runSearch(); }, - add_interface_bindings:function(){ + add_interface_bindings:function() { var _this = this; - js_log("f:add_interface_bindings:"); + js_log( "f:add_interface_bindings:" ); - $j('#mso_selprovider,#mso_selprovider_close').unbind().click(function(){ - if($j('#rsd_options_bar:hidden').length !=0 ){ - $j('#rsd_options_bar').animate({ + $j( '#mso_selprovider,#mso_selprovider_close' ).unbind().click( function() { + if ( $j( '#rsd_options_bar:hidden' ).length != 0 ) { + $j( '#rsd_options_bar' ).animate( { 'height':'110px', 'opacity':1 - }, "normal"); - }else{ - $j('#rsd_options_bar').animate({ + }, "normal" ); + } else { + $j( '#rsd_options_bar' ).animate( { 'height':'0px', 'opacity':0 - }, "normal", function(){ - $j(this).hide(); - }); + }, "normal", function() { + $j( this ).hide(); + } ); } - }); - //set form bindings - $j('#rsd_form').unbind().submit(function(){ + } ); + // set form bindings + $j( '#rsd_form' ).unbind().submit( function() { _this.runSearch(); - //don't submit the form + // don't submit the form return false; - }); + } ); }, - doUploadInteface:function(){ - js_log("doUploadInteface::"); + doUploadInteface:function() { + js_log( "doUploadInteface::" ); var _this = this; - //set it to loading: - mv_set_loading('#tab-upload'); - //do things async to keep interface snappy - setTimeout(function(){ - //check if we need to setup the proxy:: - if( _this.upload_api_target == 'proxy' ){ - _this.setupProxy( function(){ + // set it to loading: + mv_set_loading( '#tab-upload' ); + // do things async to keep interface snappy + setTimeout( function() { + // check if we need to setup the proxy:: + if ( _this.upload_api_target == 'proxy' ) { + _this.setupProxy( function() { _this.getUploadForm(); - }); - }else{ + } ); + } else { _this.getUploadForm(); - } - },1); + } + }, 1 ); }, - getUploadForm:function(){ + getUploadForm:function() { var _this = this; - mvJsLoader.doLoad(['$j.fn.simpleUploadForm'],function(){ - //get extends info about the file + mvJsLoader.doLoad( ['$j.fn.simpleUploadForm'], function() { + // get extends info about the file var cp = _this.content_providers['this_wiki']; - //check for "this_wiki" enabled + // check for "this_wiki" enabled /*if(!cp.enabled){ $j('#tab-upload').html('error this_wiki not enabled (can\'t get uploaded file info)'); return false; }*/ - //load this_wiki search system to grab the rObj - _this.loadSearchLib(cp, function(){ - //do basic layout form on left upload "bin" on right - $j('#tab-upload').html('' + + // load this_wiki search system to grab the rObj + _this.loadSearchLib( cp, function() { + // do basic layout form on left upload "bin" on right + $j( '#tab-upload' ).html( '
' + '' + '' + '' + '' + - '
' + - '

' + gM('mwe-upload_a_file', _this.upload_api_name ) + '

' + + '

' + gM( 'mwe-upload_a_file', _this.upload_api_name ) + '

' + '
' + mv_get_loading_img() + '
' + '
' + - '

' + gM('mwe-your_recent_uploads', _this.upload_api_name) + '

' + + '

' + gM( 'mwe-your_recent_uploads', _this.upload_api_name ) + '

' + '
' + mv_get_loading_img() + - '
'+ + '' + '
'); + '' ); - //fill in the user page: - if(typeof wgUserName != 'undefined' && wgUserName){ - //load the upload bin with anything the current user has uploaded - cp.sObj.getUserRecentUploads( wgUserName, function(){ + // fill in the user page: + if ( typeof wgUserName != 'undefined' && wgUserName ) { + // load the upload bin with anything the current user has uploaded + cp.sObj.getUserRecentUploads( wgUserName, function() { _this.drawOutputResults(); - }); - }else{ - $j('#upload_bin_cnt').empty(); + } ); + } else { + $j( '#upload_bin_cnt' ).empty(); } - //deal with the api form upload form directly: - $j('#upload_form').simpleUploadForm({ + // deal with the api form upload form directly: + $j( '#upload_form' ).simpleUploadForm( { "api_target" : _this.upload_api_target, - "ondone_cb" : function( resultData ){ - var wTitle = resultData['filename']; - //add a loading div + "ondone_cb" : function( resultData ) { + var wTitle = resultData['filename']; + // add a loading div _this.addResourceEditLoader(); - //@@note: we have most of what we need in resultData imageinfo - cp.sObj.addByTitle( wTitle, function( rObj ){ - //redraw ( with added result if new ) + // @@note: we have most of what we need in resultData imageinfo + cp.sObj.addByTitle( wTitle, function( rObj ) { + // redraw ( with added result if new ) _this.drawOutputResults(); - //pull up resource editor: - _this.resourceEdit( rObj, $j('#res_upload__' + rObj.id).get(0) ); - }); - //return false to close progress window: + // pull up resource editor: + _this.resourceEdit( rObj, $j( '#res_upload__' + rObj.id ).get( 0 ) ); + } ); + // return false to close progress window: return false; } - }); - }); //load searchLibs - }); //load simpleUploadForm + } ); + } ); // load searchLibs + } ); // load simpleUploadForm }, - runSearch: function( restPage ){ - js_log("f:runSearch::" + this.disp_item); + runSearch: function( restPage ) { + js_log( "f:runSearch::" + this.disp_item ); var draw_direct_flag = true; - //check if its the special upload tab case: - if( this.disp_item == 'upload'){ + // check if its the special upload tab case: + if ( this.disp_item == 'upload' ) { this.doUploadInteface(); return true; } - //else do runSearch + // else do runSearch var cp = this.content_providers[this.disp_item]; - //check if we need to update: - if( typeof cp.sObj != 'undefined' ){ - if(cp.sObj.last_query == $j('#rsd_q').val() && cp.sObj.last_offset == cp.offset){ - js_log('last query is: ' + cp.sObj.last_query + ' matches: ' + $j('#rsd_q').val() ); - }else{ - js_log('last query is: ' + cp.sObj.last_query + ' not match: ' + $j('#rsd_q').val() ); + // check if we need to update: + if ( typeof cp.sObj != 'undefined' ) { + if ( cp.sObj.last_query == $j( '#rsd_q' ).val() && cp.sObj.last_offset == cp.offset ) { + js_log( 'last query is: ' + cp.sObj.last_query + ' matches: ' + $j( '#rsd_q' ).val() ); + } else { + js_log( 'last query is: ' + cp.sObj.last_query + ' not match: ' + $j( '#rsd_q' ).val() ); draw_direct_flag = false; } - }else{ + } else { draw_direct_flag = false; } - if( !draw_direct_flag ){ - //see if we should reset the paging - if( restPage ){ + if ( !draw_direct_flag ) { + // see if we should reset the paging + if ( restPage ) { cp.sObj.offset = cp.offset = 0; } - //set the content to loading while we do the search: - $j('#tab-' + this.disp_item).html( mv_get_loading_img() ); + // set the content to loading while we do the search: + $j( '#tab-' + this.disp_item ).html( mv_get_loading_img() ); // Make sure the search library is loaded and issue the search request this.getLibSearchResults( cp ); @@ -729,50 +729,50 @@ remoteSearchDriver.prototype = { }, // Issue a api request & cache the result // this check can be avoided by setting the this.import_url_mode = 'api' | 'form' | instead of 'autodetect' or 'none' - checkForCopyURLSupport:function ( callback ){ + checkForCopyURLSupport:function ( callback ) { var _this = this; - js_log('checkForCopyURLSupport:: '); + js_log( 'checkForCopyURLSupport:: ' ); // See if we already have the import mode: - if( this.import_url_mode != 'autodetect'){ - js_log('import mode: ' + _this.import_url_mode); + if ( this.import_url_mode != 'autodetect' ) { + js_log( 'import mode: ' + _this.import_url_mode ); callback(); } // If we don't have the local wiki api defined we can't auto-detect use "link" - if( ! _this.upload_api_target ){ - js_log('import mode: remote link (no import_wiki_api_url)'); + if ( ! _this.upload_api_target ) { + js_log( 'import mode: remote link (no import_wiki_api_url)' ); _this.import_url_mode = 'remote_link'; callback(); } - if( this.import_url_mode == 'autodetect' ){ + if ( this.import_url_mode == 'autodetect' ) { do_api_req( { 'url': _this.upload_api_target, - 'data': { - 'action':'paraminfo', - 'modules':'upload' + 'data': { + 'action':'paraminfo', + 'modules':'upload' } - }, function(data){ - //jump right into api checks: - for( var i in data.paraminfo.modules[0].parameters ){ + }, function( data ) { + // jump right into api checks: + for ( var i in data.paraminfo.modules[0].parameters ) { var pname = data.paraminfo.modules[0].parameters[i].name; - if( pname == 'url' ){ + if ( pname == 'url' ) { js_log( 'Autodetect Upload Mode: api: copy by url:: ' ); - //check permission too: - _this.checkForCopyURLPermission(function( canCopyUrl ){ - if(canCopyUrl){ + // check permission too: + _this.checkForCopyURLPermission( function( canCopyUrl ) { + if ( canCopyUrl ) { _this.import_url_mode = 'api'; - js_log('import mode: ' + _this.import_url_mode); + js_log( 'import mode: ' + _this.import_url_mode ); callback(); - }else{ + } else { _this.import_url_mode = 'none'; - js_log('import mode: ' + _this.import_url_mode); + js_log( 'import mode: ' + _this.import_url_mode ); callback(); } - }); + } ); break; } } - }); + } ); } }, /* @@ -780,470 +780,470 @@ remoteSearchDriver.prototype = { * not really necessary the api request to upload will return appropriate error if the user lacks permission. or $wgAllowCopyUploads is set to false * (use this function if we want to issue a warning up front) */ - checkForCopyURLPermission:function( callback ){ + checkForCopyURLPermission:function( callback ) { var _this = this; - //do api check: + // do api check: do_api_req( { - 'data':{ 'action' : 'query', 'meta' : 'userinfo', 'uiprop' : 'rights' }, + 'data': { 'action' : 'query', 'meta' : 'userinfo', 'uiprop' : 'rights' }, 'url': _this.upload_api_target, 'userinfo' : true - }, function(data){ - for( var i in data.query.userinfo.rights){ + }, function( data ) { + for ( var i in data.query.userinfo.rights ) { var right = data.query.userinfo.rights[i]; - //js_log('checking: ' + right ) ; - if(right == 'upload_by_url'){ + // js_log('checking: ' + right ) ; + if ( right == 'upload_by_url' ) { callback( true ); - return true; //break out of the function + return true; // break out of the function } } callback( false ); - }); + } ); }, - getLibSearchResults:function( cp ){ + getLibSearchResults:function( cp ) { var _this = this; - //first check if we should even run the search at all (can we import / insert into the page? ) - if( !this.checkRepoLocal( cp ) && this.import_url_mode == 'autodetect' ){ - //cp is not local check if we can support the import mode: - this.checkForCopyURLSupport( function(){ + // first check if we should even run the search at all (can we import / insert into the page? ) + if ( !this.checkRepoLocal( cp ) && this.import_url_mode == 'autodetect' ) { + // cp is not local check if we can support the import mode: + this.checkForCopyURLSupport( function() { _this.getLibSearchResults( cp ); - }); + } ); return false; - }else if( !this.checkRepoLocal( cp ) && this.import_url_mode == 'none'){ - if( this.disp_item == 'combined' ){ - //combined results are harder to error handle just ignore that repo + } else if ( !this.checkRepoLocal( cp ) && this.import_url_mode == 'none' ) { + if ( this.disp_item == 'combined' ) { + // combined results are harder to error handle just ignore that repo cp.sObj.loading = false; - }else{ - $j('#tab-' + this.disp_item).html( '
'+ gM('mwe-no_import_by_url') +'
'); + } else { + $j( '#tab-' + this.disp_item ).html( '
' + gM( 'mwe-no_import_by_url' ) + '
' ); } return false; } - _this.loadSearchLib(cp, function(){ + _this.loadSearchLib( cp, function() { // Do the search cp.sObj.getSearchResults(); _this.checkResultsDone(); - }); + } ); }, - loadSearchLib:function(cp, callback){ - var _this = this; - //set up the library req: + loadSearchLib:function( cp, callback ) { + var _this = this; + // set up the library req: mvJsLoader.doLoad( [ 'baseRemoteSearch', cp.lib + 'Search' - ], function(){ - js_log("loaded lib:: " + cp.lib ); - //else we need to run the search: + ], function() { + js_log( "loaded lib:: " + cp.lib ); + // else we need to run the search: var iObj = { - 'cp' : cp, + 'cp' : cp, 'rsd' : _this }; - eval('cp.sObj = new ' + cp.lib + 'Search( iObj );' ); - if(!cp.sObj){ - js_log('Error: could not find search lib for ' + cp_id); + eval( 'cp.sObj = new ' + cp.lib + 'Search( iObj );' ); + if ( !cp.sObj ) { + js_log( 'Error: could not find search lib for ' + cp_id ); return false; } - //inherit defaults if not set: - cp.limit = (cp.limit) ? cp.limit : cp.sObj.limit; - cp.offset = (cp.offset) ? cp.offset : cp.sObj.offset; + // inherit defaults if not set: + cp.limit = ( cp.limit ) ? cp.limit : cp.sObj.limit; + cp.offset = ( cp.offset ) ? cp.offset : cp.sObj.offset; callback(); - }); + } ); }, /* check for all the results to finish */ - checkResultsDone: function(){ - //js_log('rsd:checkResultsDone'); + checkResultsDone: function() { + // js_log('rsd:checkResultsDone'); var _this = this; var loading_done = true; - for(var cp_id in this.content_providers){ + for ( var cp_id in this.content_providers ) { var cp = this.content_providers[ cp_id ]; - if(typeof cp['sObj'] != 'undefined'){ - if( cp.sObj.loading ) + if ( typeof cp['sObj'] != 'undefined' ) { + if ( cp.sObj.loading ) loading_done = false; } } - if( loading_done ){ + if ( loading_done ) { this.drawOutputResults(); - }else{ - //make sure the instance name is up-to-date refrerance to _this; - eval( _this.instance_name + ' = _this'); - setTimeout( _this.instance_name + '.checkResultsDone()', 50); + } else { + // make sure the instance name is up-to-date refrerance to _this; + eval( _this.instance_name + ' = _this' ); + setTimeout( _this.instance_name + '.checkResultsDone()', 50 ); } }, - drawTabs: function(){ + drawTabs: function() { var _this = this; - //add the tabs to the rsd_results container: - var o='
'; + // add the tabs to the rsd_results container: + var o = '
'; var selected_tab = 0; - var inx =0; - o+= ''; // Output the tab content containers: - o+=tabc; - o+='
'; //close tab container + o += tabc; + o += '
'; // close tab container // Output the respective results holders - $j('#rsd_results_container').html(o); + $j( '#rsd_results_container' ).html( o ); // Setup bindings for tabs make them sortable: (@@todo remember order) - js_log('selected tab is: ' + selected_tab); - $j("#rsd_tabs_container").tabs({ + 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_', '') ); + select: function( event, ui ) { + _this.selectTab( $j( ui.tab ).attr( 'id' ).replace( 'rsd_tab_', '' ) ); } // Add sorting - }).find(".ui-tabs-nav").sortable({axis:'x'}); - //@@todo store sorted repo + } ).find( ".ui-tabs-nav" ).sortable( { axis:'x' } ); + // @@todo store sorted repo }, // Resource title - getResourceFromTitle : function( rTitle , callback){ + getResourceFromTitle : function( rTitle , callback ) { var _this = this; - reqObj={ + reqObj = { 'action':'query', 'titles': _this.cFileNS + ':' + rTitle }; do_api_req( { 'data':reqObj, 'url':this.local_wiki_api_url - }, function(data){ - //@@todo propagate the rObj - var rObj = {}; + }, function( data ) { + // @@todo propagate the rObj + var rObj = { }; } ); }, - //@@todo we could load the id with the content provider id to find the object faster... - getResourceFromId:function( rid ){ - //js_log('getResourceFromId:' + rid ); - //strip out /res/ if preset: - rid = rid.replace(/res_/, ''); - //js_log("looking at: " + rid); - p = rid.split('__'); + // @@todo we could load the id with the content provider id to find the object faster... + getResourceFromId:function( rid ) { + // js_log('getResourceFromId:' + rid ); + // strip out /res/ if preset: + rid = rid.replace( / res_ / , '' ); + // js_log("looking at: " + rid); + p = rid.split( '__' ); var cp_id = p[0]; var rid = p[1]; - //Set the upload helper cp_id (to render recent uploads by this user) - if(cp_id == 'upload') + // Set the upload helper cp_id (to render recent uploads by this user) + if ( cp_id == 'upload' ) cp_id = 'this_wiki'; var cp = this.content_providers[cp_id]; - if(cp && cp['sObj'] && cp.sObj.resultsObj[rid]){ + if ( cp && cp['sObj'] && cp.sObj.resultsObj[rid] ) { return cp.sObj.resultsObj[rid]; } - js_log("ERROR: could not find " + rid); + js_log( "ERROR: could not find " + rid ); return false; }, - drawOutputResults: function(){ - js_log('f:drawOutputResults::' + this.disp_item); + drawOutputResults: function() { + js_log( 'f:drawOutputResults::' + this.disp_item ); var _this = this; - var o=''; + var o = ''; var cp_id = this.disp_item; var tab_target = ''; - if(this.disp_item == 'upload'){ + if ( this.disp_item == 'upload' ) { tab_target = '#upload_bin'; - var cp = _this.content_providers['this_wiki']; - }else{ + var cp = _this.content_providers['this_wiki']; + } else { var cp = this.content_providers[this.disp_item]; tab_target = '#tab-' + cp_id; // Output the results bar / controls - } + } // Empty the existing results: - $j(tab_target).empty(); - //@@todo give the user upload control love - if(this.disp_item != 'upload'){ + $j( tab_target ).empty(); + // @@todo give the user upload control love + if ( this.disp_item != 'upload' ) { _this.setResultBarControl(); } var drawResultCount = 0; // 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+='
'; + if ( typeof cp['sObj'] != 'undefined' ) { + $j.each( cp.sObj.resultsObj, function( rInx, rItem ) { + if ( _this.result_display_mode == 'box' ) { + o += '
'; // Check for missing poster types for audio - if( rItem.mime=='audio/ogg' && !rItem.poster ){ + 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: - o+=''; // Add a linkback to resource page in upper right: - if( rItem.link ) - o+='
' + - ''+ gM('mwe-link') + '' + + if ( rItem.link ) + o += ''; // Add file type icon if known - if( rItem.mime ){ - o+= _this.getTypeIcon( rItem.mime ); - } + if ( rItem.mime ) { + o += _this.getTypeIcon( rItem.mime ); + } // Add license icons if present - if( rItem.license ) - o+= _this.getlicenseImgSet( rItem.license ); + if ( rItem.license ) + o += _this.getlicenseImgSet( rItem.license ); - o+='
'; - }else if(_this.result_display_mode == 'list'){ - o+='
'; - o+=''; + o += ''; // Add license icons if present - if( rItem.license ) - o+= _this.getlicenseImgSet( rItem.license ); + if ( rItem.license ) + o += _this.getlicenseImgSet( rItem.license ); - o+= rItem.desc ; - o+='
'; - o+='
'; + o += rItem.desc ; + o += '
'; + o += '
'; } drawResultCount++; - }); - js_log('append to: ' + '#tab-' + cp_id); + } ); + js_log( 'append to: ' + '#tab-' + cp_id ); // Put in the tab output (plus clear the output) - $j(tab_target).append( o + '
'); + $j( tab_target ).append( o + '
' ); } - js_log( 'did drawResultCount :: ' + drawResultCount + ' append: ' + $j('#rsd_q').val() ); + js_log( 'did drawResultCount :: ' + drawResultCount + ' append: ' + $j( '#rsd_q' ).val() ); // Remove any old search res - $j('#rsd_no_search_res').remove(); - if( drawResultCount == 0 ) - $j('#tab-' + cp_id).append( '' + gM( 'rsd_no_results', $j('#rsd_q').val() ) + ''); + $j( '#rsd_no_search_res' ).remove(); + if ( drawResultCount == 0 ) + $j( '#tab-' + cp_id ).append( '' + gM( 'rsd_no_results', $j( '#rsd_q' ).val() ) + '' ); this.addResultBindings(); }, - addResultBindings:function(){ + addResultBindings:function() { var _this = this; - $j('.mv_clip_'+_this.result_display_mode+'_result').hover(function(){ - $j(this).addClass('mv_clip_'+_this.result_display_mode+'_result_over'); + $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 - var res_id = $j(this).children('.rsd_res_item').attr('id'); + var res_id = $j( this ).children( '.rsd_res_item' ).attr( 'id' ); var rObj = _this.getResourceFromId( res_id ); - if( rObj.poster_ani ) - $j('#' + res_id ).attr('src', rObj.poster_ani); - },function(){ - $j(this).removeClass('mv_clip_'+_this.result_display_mode+'_result_over'); - var res_id = $j(this).children('.rsd_res_item').attr('id'); + if ( rObj.poster_ani ) + $j( '#' + res_id ).attr( 'src', rObj.poster_ani ); + }, function() { + $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) - if( rObj.poster_ani ) - $j('#' + res_id ).attr('src', rObj.poster); - }); + if ( rObj.poster_ani ) + $j( '#' + res_id ).attr( 'src', rObj.poster ); + } ); // Resource click action: (bring up the resource editor) - $j('.rsd_res_item').unbind().click(function(){ - var rObj = _this.getResourceFromId( $j(this).attr("id") ); + $j( '.rsd_res_item' ).unbind().click( function() { + var rObj = _this.getResourceFromId( $j( this ).attr( "id" ) ); _this.resourceEdit( rObj, this ); - }); + } ); }, - addResourceEditLoader:function(maxWidth, overflow_style){ + addResourceEditLoader:function( maxWidth, overflow_style ) { var _this = this; - if(!maxWidth)maxWidth=400; - if(!overflow_style)overflow_style='overflow:auto;'; + if ( !maxWidth )maxWidth = 400; + if ( !overflow_style )overflow_style = 'overflow:auto;'; // Remove any old instance: - $j( _this.target_container ).find('#rsd_resource_edit').remove(); + $j( _this.target_container ).find( '#rsd_resource_edit' ).remove(); // Add the edit layout window with loading place holders - $j( _this.target_container ).append('
' + - '
'+ + '
' + mv_get_loading_img() + - '
'+ - '
' + - '

' + gM('mwe-resource-needs-import', [rObj.title, _this.upload_api_name] ) + '

' + + '

' + gM( 'mwe-resource-needs-import', [rObj.title, _this.upload_api_name] ) + '

' + '
' + rObj.pSobj.getEmbedHTML( rObj, { - 'id': _this.target_container + '_rsd_pv_vid', + 'id': _this.target_container + '_rsd_pv_vid', 'max_height':'220', 'only_poster':true - }) + //get embedHTML with small thumb: - '
'+ - ''+gM('mwe-resource_page_desc') +''+ - '
'+ - mv_get_loading_img('position:absolute;top:5px;left:5px') + - '
'+ - '
'+ + } ) + // get embedHTML with small thumb: + '
' + + '' + gM( 'mwe-resource_page_desc' ) + '' + + '
' + + mv_get_loading_img( 'position:absolute;top:5px;left:5px' ) + + '
' + + '
' + '
'+ - '' + gM('mwe-local_resource_title') + '
'+ - '
'+ - '' + gM('mwe-edit_resource_desc') + '' + + 'bottom:0px;top:30px;right:0px;overflow:auto;">' + + '' + gM( 'mwe-local_resource_title' ) + '
' + + '
' + + '' + gM( 'mwe-edit_resource_desc' ) + '' + '
' + '' + - '


' + - '
'+ - //output the rendered and non-rendered version of description for easy switching: - '
'); - var bPlaneTarget = _this.target_container +'~ .ui-dialog-buttonpane'; - $j(bPlaneTarget).html ( - //add the btns to the bottom: - $j.btnHtml(gM('mwe-do_import_resource'), 'rsd_import_doimport', 'check' ) + ' ' + + '


' + + '
' + + // output the rendered and non-rendered version of description for easy switching: + '
' ); + var bPlaneTarget = _this.target_container + '~ .ui-dialog-buttonpane'; + $j( bPlaneTarget ).html ( + // add the btns to the bottom: + $j.btnHtml( gM( 'mwe-do_import_resource' ), 'rsd_import_doimport', 'check' ) + ' ' + - $j.btnHtml(gM('mwe-update_preview'), 'rsd_import_apreview', 'refresh' ) + ' '+ + $j.btnHtml( gM( 'mwe-update_preview' ), 'rsd_import_apreview', 'refresh' ) + ' ' + - $j.btnHtml(gM('mwe-cancel_import'), 'rsd_import_acancel', 'close' ) + ' ' - ).addClass('ui-state-error'); - - //add hover: + $j.btnHtml( gM( 'mwe-cancel_import' ), 'rsd_import_acancel', 'close' ) + ' ' + ).addClass( 'ui-state-error' ); - //update video tag (if a video) - if( rObj.mime.indexOf('video/') !== -1 ) - rewrite_by_id( $j(_this.target_container).attr('id') + '_rsd_pv_vid'); + // add hover: + + // update video tag (if a video) + if ( rObj.mime.indexOf( 'video/' ) !== - 1 ) + rewrite_by_id( $j( _this.target_container ).attr( 'id' ) + '_rsd_pv_vid' ); - //load the preview text: - _this.getParsedWikiText( wt, _this.cFileNS +':'+ rObj.target_resource_title, function( o ){ - $j('#rsd_import_desc').html(o); - }); - //add bindings: - $j( bPlaneTarget + ' .rsd_import_apreview').btnBind().click(function(){ - js_log("do preview asset"); - $j('#rsd_import_desc').html( mv_get_loading_img() ); - //load the preview text: - _this.getParsedWikiText( $j('#rsd_import_ta').val(), _this.cFileNS +':'+ rObj.target_resource_title, function( o ){ - js_log('got updated preview: '); - $j('#rsd_import_desc').html(o); - }); - }); - $j( bPlaneTarget + ' .rsd_import_doimport').btnBind().click(function(){ - js_log("do import asset:" + _this.import_url_mode); - //check import mode: - if( _this.import_url_mode == 'api' ){ - if( _this.upload_api_target == 'proxy' ){; - _this.setupProxy( function(){ - _this.doImportAPI( rObj , callback); - }); - }else{ - _this.doImportAPI( rObj , callback); + // load the preview text: + _this.getParsedWikiText( wt, _this.cFileNS + ':' + rObj.target_resource_title, function( o ) { + $j( '#rsd_import_desc' ).html( o ); + } ); + // add bindings: + $j( bPlaneTarget + ' .rsd_import_apreview' ).btnBind().click( function() { + js_log( "do preview asset" ); + $j( '#rsd_import_desc' ).html( mv_get_loading_img() ); + // load the preview text: + _this.getParsedWikiText( $j( '#rsd_import_ta' ).val(), _this.cFileNS + ':' + rObj.target_resource_title, function( o ) { + js_log( 'got updated preview: ' ); + $j( '#rsd_import_desc' ).html( o ); + } ); + } ); + $j( bPlaneTarget + ' .rsd_import_doimport' ).btnBind().click( function() { + js_log( "do import asset:" + _this.import_url_mode ); + // check import mode: + if ( _this.import_url_mode == 'api' ) { + if ( _this.upload_api_target == 'proxy' ) { ; + _this.setupProxy( function() { + _this.doImportAPI( rObj , callback ); + } ); + } else { + _this.doImportAPI( rObj , callback ); } - }else{ - js_log("Error: import mode is not form or API (can not copy asset)"); + } else { + js_log( "Error: import mode is not form or API (can not copy asset)" ); } - }); - $j( bPlaneTarget + ' .rsd_import_acancel').btnBind().click(function(){ - $j('#rsd_resource_import').fadeOut("fast",function(){ - $j(this).remove(); - //restore buttons (from the clipEdit object::) + } ); + $j( bPlaneTarget + ' .rsd_import_acancel' ).btnBind().click( function() { + $j( '#rsd_resource_import' ).fadeOut( "fast", function() { + $j( this ).remove(); + // restore buttons (from the clipEdit object::) _this.cEdit.updateInsertControlActions(); - $j(bPlaneTarget).removeClass('ui-state-error'); - }); - }); - }, + $j( bPlaneTarget ).removeClass( 'ui-state-error' ); + } ); + } ); + }, /** * sets up the proxy for the remote inserts */ - setupProxy:function(callback){ + setupProxy:function( callback ) { var _this = this; - if( _this.proxySetupDone ){ - if(callback) + if ( _this.proxySetupDone ) { + if ( callback ) callback(); return ; } - //setup the the proxy via mv_embed $j.apiProxy loader: - if( ! _this.upload_api_proxy_frame ){ - js_log("Error:: remote api but no proxy frame target"); + // setup the the proxy via mv_embed $j.apiProxy loader: + if ( ! _this.upload_api_proxy_frame ) { + js_log( "Error:: remote api but no proxy frame target" ); return false; - }else{ + } else { $j.apiProxy( 'client', { - 'server_frame' : _this.upload_api_proxy_frame - },function(){ + 'server_frame' : _this.upload_api_proxy_frame + }, function() { _this.proxySetupDone = true - if(callback) + if ( callback ) callback(); - } - ); + } + ); } }, - checkForFile:function( fName, callback){ - js_log("checkForFile::" + fName ); - var _this = this; - reqObj={ + checkForFile:function( fName, callback ) { + js_log( "checkForFile::" + fName ); + var _this = this; + reqObj = { 'action':'query', 'titles': _this.cFileNS + ':' + fName, 'prop' : 'imageinfo', 'iiprop' : 'url', 'iiurlwidth': '400' - }; - //first check the api for imagerepository + }; + // first check the api for imagerepository do_api_req( { 'data':reqObj, 'url':this.local_wiki_api_url - },function(data){ - if( data.query.pages ){ - for(var i in data.query.pages){ - for(var j in data.query.pages[i]){ - if(j == 'missing' && data.query.pages[i].imagerepository != 'shared'){ - js_log(fName + " not found"); + }, function( data ) { + if ( data.query.pages ) { + for ( var i in data.query.pages ) { + for ( var j in data.query.pages[i] ) { + if ( j == 'missing' && data.query.pages[i].imagerepository != 'shared' ) { + js_log( fName + " not found" ); callback( false ); return ; - } - } - //else page is found: - js_log(fName + " found"); - callback( data.query.pages[i] ); + } + } + // else page is found: + js_log( fName + " found" ); + callback( data.query.pages[i] ); } } } ); }, - doImportAPI:function(rObj, cir_callback){ + doImportAPI:function( rObj, cir_callback ) { var _this = this; - js_log(":doImportAPI:"); - $j.addLoaderDialog( gM('mwe-importing_asset') ); - //baseUploadInterface - mvJsLoader.doLoad([ + js_log( ":doImportAPI:" ); + $j.addLoaderDialog( gM( 'mwe-importing_asset' ) ); + // baseUploadInterface + mvJsLoader.doLoad( [ 'mvBaseUploadInterface', '$j.ui.progressbar' - ],function(){ - js_log('mvBaseUploadInterface ready'); - //initiate a upload object ( similar to url copy ): - myUp = new mvBaseUploadInterface({ + ], function() { + js_log( 'mvBaseUploadInterface ready' ); + // initiate a upload object ( similar to url copy ): + myUp = new mvBaseUploadInterface( { 'api_url' : _this.upload_api_target, - 'done_upload_cb':function(){ - js_log('doImportAPI:: run callback::' ); - //we have finished the upload: - - //close up the rsd_resource_import - $j('#rsd_resource_import').remove(); - //return the parent callback: - return cir_callback(); + 'done_upload_cb':function() { + js_log( 'doImportAPI:: run callback::' ); + // we have finished the upload: + + // close up the rsd_resource_import + $j( '#rsd_resource_import' ).remove(); + // return the parent callback: + return cir_callback(); } - }); - //get the edit token if we have it handy - _this.getEditToken(function( token ){ + } ); + // get the edit token if we have it handy + _this.getEditToken( function( token ) { myUp.etoken = token; - //close the loader now that we are ready to present the progress dialog:: + // close the loader now that we are ready to present the progress dialog:: $j.closeLoaderDialog(); - myUp.doHttpUpload({ + myUp.doHttpUpload( { 'url' : rObj.src, 'filename' : rObj.target_resource_title, - 'comment' : $j('#rsd_import_ta').val() - }); - }) + 'comment' : $j( '#rsd_import_ta' ).val() + } ); + } ) - }); + } ); }, - getEditToken:function(callback){ + getEditToken:function( callback ) { var _this = this; - if( _this.upload_api_target != 'proxy'){ - //(if not a proxy) first try to get the token from the page: - var etoken = $j("input[name='wpEditToken']").val(); - if(etoken){ + if ( _this.upload_api_target != 'proxy' ) { + // (if not a proxy) first try to get the token from the page: + var etoken = $j( "input[name='wpEditToken']" ).val(); + if ( etoken ) { callback( etoken ); return ; } } - //@@todo try to load over ajax if( _this.local_wiki_api_url ) is set + // @@todo try to load over ajax if( _this.local_wiki_api_url ) is set // (your on the api domain but are inserting from a normal page view) - get_mw_token(null, _this.upload_api_target, function(token){ + get_mw_token( null, _this.upload_api_target, function( token ) { callback( token ); - }); - }, - previewResource:function( rObj ){ + } ); + }, + previewResource:function( rObj ) { var _this = this; - this.checkImportResource( rObj, function(){ - //put another window ontop: - $j( _this.target_container ).append('
' + - mv_get_loading_img('top:30px;left:30px') + - '
'); + mv_get_loading_img( 'top:30px;left:30px' ) + + '
' ); - var bPlaneTarget = _this.target_container +'~ .ui-dialog-buttonpane'; - var pTitle = $j( _this.target_container ).dialog('option', 'title'); + var bPlaneTarget = _this.target_container + '~ .ui-dialog-buttonpane'; + var pTitle = $j( _this.target_container ).dialog( 'option', 'title' ); - //update title: - $j( _this.target_container ).dialog('option', 'title', gM('mwe-preview_insert_resource', rObj.title) ); + // update title: + $j( _this.target_container ).dialog( 'option', 'title', gM( 'mwe-preview_insert_resource', rObj.title ) ); - //update buttons preview: - $j(bPlaneTarget).html( $j.btnHtml( gM('rsd_do_insert'), 'preview_do_insert', 'check') + ' ' ) - .children('.preview_do_insert') - .click(function(){ + // update buttons preview: + $j( bPlaneTarget ).html( $j.btnHtml( gM( 'rsd_do_insert' ), 'preview_do_insert', 'check' ) + ' ' ) + .children( '.preview_do_insert' ) + .click( function() { _this.insertResource( rObj ); - }); - //update cancel button - $j(bPlaneTarget).append('Do More Modification') - .children('.preview_close') - .click(function(){ - $j('#rsd_preview_display').remove(); - //restore title: - $j( _this.target_container ).dialog('option', 'title', pTitle); - //restore buttons (from the clipEdit object::) + } ); + // update cancel button + $j( bPlaneTarget ).append( 'Do More Modification' ) + .children( '.preview_close' ) + .click( function() { + $j( '#rsd_preview_display' ).remove(); + // restore title: + $j( _this.target_container ).dialog( 'option', 'title', pTitle ); + // restore buttons (from the clipEdit object::) _this.cEdit.updateInsertControlActions(); - }); + } ); - //update the preview_wtext + // update the preview_wtext _this.updatePreviewText( rObj ); - _this.getParsedWikiText(_this.preview_wtext, _this.target_title, - function(phtml){ - $j('#rsd_preview_display').html( phtml ); - //update the display of video tag items (if any) - mwdomReady(true); + _this.getParsedWikiText( _this.preview_wtext, _this.target_title, + function( phtml ) { + $j( '#rsd_preview_display' ).html( phtml ); + // update the display of video tag items (if any) + mwdomReady( true ); } ); - }); + } ); }, - updatePreviewText:function( rObj ){ + updatePreviewText:function( rObj ) { var _this = this; - if( _this.import_url_mode == 'remote_link' ){ - _this.cur_embed_code = rObj.pSobj.getEmbedHTML(rObj); - }else{ + if ( _this.import_url_mode == 'remote_link' ) { + _this.cur_embed_code = rObj.pSobj.getEmbedHTML( rObj ); + } else { _this.cur_embed_code = rObj.pSobj.getEmbedWikiCode( rObj ); } - //insert at start if textInput cursor has not been set (ie == length) - if( _this.caret_pos && _this.caret_pos.text){ - if( _this.caret_pos.text.length == _this.caret_pos.s) - _this.caret_pos.s=0; - _this.preview_wtext = _this.caret_pos.text.substring(0, _this.caret_pos.s) + + // insert at start if textInput cursor has not been set (ie == length) + if ( _this.caret_pos && _this.caret_pos.text ) { + if ( _this.caret_pos.text.length == _this.caret_pos.s ) + _this.caret_pos.s = 0; + _this.preview_wtext = _this.caret_pos.text.substring( 0, _this.caret_pos.s ) + _this.cur_embed_code + _this.caret_pos.text.substring( _this.caret_pos.s ); - }else{ - _this.preview_wtext = $j(_this.target_textbox).val() + _this.cur_embed_code; + } else { + _this.preview_wtext = $j( _this.target_textbox ).val() + _this.cur_embed_code; } - //check for missing - if( _this.preview_wtext.indexOf('') ==-1 && _this.preview_wtext.indexOf('') != -1 ) + // check for missing + if ( _this.preview_wtext.indexOf( '' ) == - 1 && _this.preview_wtext.indexOf( '' ) != - 1 ) _this.preview_wtext = _this.preview_wtext + ''; }, - getParsedWikiText:function( wikitext, title, callback ){ + getParsedWikiText:function( wikitext, title, callback ) { do_api_req( { - 'data':{'action':'parse', + 'data': { 'action':'parse', 'text':wikitext }, 'url':this.local_wiki_api_url - },function(data){ + }, function( data ) { callback( data.parse.text['*'] ); } ); }, - insertResource:function( rObj){ - js_log('insertResource: ' + rObj.title); + insertResource:function( rObj ) { + js_log( 'insertResource: ' + rObj.title ); var _this = this - //dobule check that the resource is present: - this.checkImportResource( rObj, function(){ + // dobule check that the resource is present: + this.checkImportResource( rObj, function() { _this.updatePreviewText( rObj ); - $j(_this.target_textbox).val( _this.preview_wtext ); + $j( _this.target_textbox ).val( _this.preview_wtext ); - //update the render area (if present) - if(_this.target_render_area && _this.cur_embed_code){ - //output with some padding: - $j(_this.target_render_area).append( _this.cur_embed_code + '
') + // update the render area (if present) + if ( _this.target_render_area && _this.cur_embed_code ) { + // output with some padding: + $j( _this.target_render_area ).append( _this.cur_embed_code + '
' ) - //update the player if video or audio: - if( rObj.mime.indexOf('audio')!=-1 || - rObj.mime.indexOf('video')!=-1 || - rObj.mime.indexOf('/ogg') !=-1){ - mvJsLoader.embedVideoCheck(function(){ + // update the player if video or audio: + if ( rObj.mime.indexOf( 'audio' ) != - 1 || + rObj.mime.indexOf( 'video' ) != - 1 || + rObj.mime.indexOf( '/ogg' ) != - 1 ) { + mvJsLoader.embedVideoCheck( function() { mv_video_embed(); - }); + } ); } } _this.closeAll(); - }); + } ); }, - closeAll:function(){ + closeAll:function() { var _this = this; - js_log("close all:: " + _this.target_container); + js_log( "close all:: " + _this.target_container ); _this.cancelClipEditCB(); - $j(_this.target_container).dialog('close'); + $j( _this.target_container ).dialog( 'close' ); }, - setResultBarControl:function( ){ + setResultBarControl:function( ) { var _this = this; var box_dark_url = mv_skin_img_path + 'box_layout_icon_dark.png'; var box_light_url = mv_skin_img_path + 'box_layout_icon.png'; var list_dark_url = mv_skin_img_path + 'list_layout_icon_dark.png'; var list_light_url = mv_skin_img_path + 'list_layout_icon.png'; - var about_desc =''; - if( this.content_providers[this.disp_item] ){ + var about_desc = ''; + if ( this.content_providers[this.disp_item] ) { var cp = this.content_providers[this.disp_item]; - about_desc ='' + - '' + gM('mwe-results_from', [cp.homepage, gM('rsd-' + this.disp_item + '-title' ) ]) + ''; - $j('#tab-'+this.disp_item).append( '
'+ - ''+ - gM('rsd_layout')+' '+ + about_desc = '' + + '' + gM( 'mwe-results_from', [cp.homepage, gM( 'rsd-' + this.disp_item + '-title' ) ] ) + ''; + $j( '#tab-' + this.disp_item ).append( '
' + + '' + + gM( 'rsd_layout' ) + ' ' + ' ' + - ''+ + '' + about_desc + - ''+ - ''+ + '' + + '' + '
' ); - //get paging with bindings: - this.getPaging('#rsd_paging_ctrl'); - - $j('#msc_box_layout').hover(function(){ - $j(this).attr("src", box_dark_url ); - }, function(){ - $j(this).attr("src", ( (_this.result_display_mode=='box')?box_dark_url:box_light_url ) ); - }).click(function(){ - $j(this).attr("src", box_dark_url); - $j('#msc_list_layout').attr("src", list_light_url); - _this.setDispMode('box'); - }); - - $j('#msc_list_layout').hover(function(){ - $j(this).attr("src", list_dark_url); - }, function(){ - $j(this).attr("src", ( (_this.result_display_mode=='list')?list_dark_url:list_light_url ) ); - }).click(function(){ - $j(this).attr("src", list_dark_url); - $j('#msc_box_layout').attr("src", box_light_url); - _this.setDispMode('list'); - }); + // get paging with bindings: + this.getPaging( '#rsd_paging_ctrl' ); + + $j( '#msc_box_layout' ).hover( function() { + $j( this ).attr( "src", box_dark_url ); + }, function() { + $j( this ).attr( "src", ( ( _this.result_display_mode == 'box' ) ? box_dark_url:box_light_url ) ); + } ).click( function() { + $j( this ).attr( "src", box_dark_url ); + $j( '#msc_list_layout' ).attr( "src", list_light_url ); + _this.setDispMode( 'box' ); + } ); + + $j( '#msc_list_layout' ).hover( function() { + $j( this ).attr( "src", list_dark_url ); + }, function() { + $j( this ).attr( "src", ( ( _this.result_display_mode == 'list' ) ? list_dark_url:list_light_url ) ); + } ).click( function() { + $j( this ).attr( "src", list_dark_url ); + $j( '#msc_box_layout' ).attr( "src", box_light_url ); + _this.setDispMode( 'list' ); + } ); } }, - getPaging:function(target){ + getPaging:function( target ) { var _this = this; var cp_id = this.disp_item; - if( this.disp_item == 'upload'){ + if ( this.disp_item == 'upload' ) { var cp = _this.content_providers['this_wiki']; - }else{ + } else { var cp = this.content_providers[ this.disp_item ]; - } - js_log('getPaging:'+ cp_id + ' len: ' + cp.sObj.num_results); - var to_num = ( cp.limit > cp.sObj.num_results )? - (parseInt( cp.offset ) + parseInt( cp.sObj.num_results ) ): - ( parseInt( cp.offset ) + parseInt( cp.limit) ); - var out = ''; + } + js_log( 'getPaging:' + cp_id + ' len: ' + cp.sObj.num_results ); + var to_num = ( cp.limit > cp.sObj.num_results ) ? + ( parseInt( cp.offset ) + parseInt( cp.sObj.num_results ) ): + ( parseInt( cp.offset ) + parseInt( cp.limit ) ); + var out = ''; - //@@todo we should instead support the wiki number format template system instead of inline calls - if( cp.sObj.num_results != 0 ){ - if( cp.sObj.num_results > cp.limit){ - out+= gM( 'rsd_results_desc_total', [(cp.offset+1), to_num, mw.lang.formatNumber( cp.sObj.num_results )] ); - }else{ - out+= gM( 'rsd_results_desc', [(cp.offset+1), to_num] ); + // @@todo we should instead support the wiki number format template system instead of inline calls + if ( cp.sObj.num_results != 0 ) { + if ( cp.sObj.num_results > cp.limit ) { + out += gM( 'rsd_results_desc_total', [( cp.offset + 1 ), to_num, mw.lang.formatNumber( cp.sObj.num_results )] ); + } else { + out += gM( 'rsd_results_desc', [( cp.offset + 1 ), to_num] ); } } - //check if we have more results (next prev link) - if( cp.offset >= cp.limit ) - out+=' ' + gM('rsd_results_prev') + ' ' + cp.limit + ''; + // check if we have more results (next prev link) + if ( cp.offset >= cp.limit ) + out += ' ' + gM( 'rsd_results_prev' ) + ' ' + cp.limit + ''; - if( cp.sObj.more_results ) - out+=' ' + gM('rsd_results_next') + ' ' + cp.limit + ''; + if ( cp.sObj.more_results ) + out += ' ' + gM( 'rsd_results_next' ) + ' ' + cp.limit + ''; - $j(target).html(out); + $j( target ).html( out ); - //set bindings - $j('#rsd_pnext').click(function(){ + // set bindings + $j( '#rsd_pnext' ).click( function() { cp.offset += cp.limit; _this.runSearch( false ); - }); + } ); - $j('#rsd_pprev').click(function(){ + $j( '#rsd_pprev' ).click( function() { cp.offset -= cp.limit; - if(cp.offset<0) - cp.offset=0; - _this.runSearch( false); - }); + if ( cp.offset < 0 ) + cp.offset = 0; + _this.runSearch( false ); + } ); return; }, - selectTab:function( selected_cp_id ){ - js_log('select tab: ' + selected_cp_id); + selectTab:function( selected_cp_id ) { + js_log( 'select tab: ' + selected_cp_id ); this.disp_item = selected_cp_id; - if( this.disp_item == 'upload' ){ + if ( this.disp_item == 'upload' ) { this.doUploadInteface(); - }else{ - //update the search results: + } else { + // update the search results: this.runSearch(); } }, - setDispMode:function(mode){ - js_log('setDispMode:' + mode); - this.result_display_mode=mode; - //run /update search display: + setDispMode:function( mode ) { + js_log( 'setDispMode:' + mode ); + this.result_display_mode = mode; + // run /update search display: this.drawOutputResults(); } }; diff --git a/js2/mwEmbed/libAddMedia/searchLibs/archiveOrgSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/archiveOrgSearch.js index c67befdf9b..ab179005cc 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/archiveOrgSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/archiveOrgSearch.js @@ -1,114 +1,114 @@ -//archive.org uses solr engine: -//more about solr here: -//http://lucene.apache.org/solr/ +// archive.org uses solr engine: +// more about solr here: +// http://lucene.apache.org/solr/ -var archiveOrgSearch = function ( iObj){ +var archiveOrgSearch = function ( iObj ) { return this.init( iObj ); } archiveOrgSearch.prototype = { // Archive.org constants: dnUrl:'http://www.archive.org/download/', dtUrl:'http://www.archive.org/details/', - init:function( iObj ){ + init:function( iObj ) { // Init base class and inherit: var baseSearch = new baseRemoteSearch( iObj ); - for(var i in baseSearch){ - if(typeof this[i] =='undefined'){ + for ( var i in baseSearch ) { + if ( typeof this[i] == 'undefined' ) { this[i] = baseSearch[i]; - }else{ - this['parent_'+i] = baseSearch[i]; + } else { + this['parent_' + i] = baseSearch[i]; } } // Inherit the cp settings for }, - getSearchResults:function(){ - //call parent: - this.parent_getSearchResults(); - var _this = this; - js_log('f:getSearchResults for:' + $j('#rsd_q').val() ); - //build the query var - var q = $j('#rsd_q').val(); - //@@todo check advanced options: include audio and images media types - //for now force (Ogg video) & url based license - q+=' format:(Ogg video)'; - q+=' licenseurl:(http\\:\\/\\/*)'; + getSearchResults:function() { + // call parent: + this.parent_getSearchResults(); + var _this = this; + js_log( 'f:getSearchResults for:' + $j( '#rsd_q' ).val() ); + // build the query var + var q = $j( '#rsd_q' ).val(); + // @@todo check advanced options: include audio and images media types + // for now force (Ogg video) & url based license + q += ' format:(Ogg video)'; + q += ' licenseurl:(http\\:\\/\\/*)'; var reqObj = { - 'q': q, //just search for video atm - 'fl':"description,title,identifier,licenseurl,format,license,thumbnail", - 'wt':'json', + 'q': q, // just search for video atm + 'fl':"description,title,identifier,licenseurl,format,license,thumbnail", + 'wt':'json', 'rows' : this.cp.limit, - 'start' : this.cp.offset - } + 'start' : this.cp.offset + } do_api_req( { - 'data':reqObj, + 'data':reqObj, 'url':this.cp.api_url, 'jsonCB':'json.wrf' - }, function(data){ - _this.addResults( data); + }, function( data ) { + _this.addResults( data ); _this.loading = false; } ); }, - addResults:function( data ){ - var _this = this; - if(data.response && data.response.docs){ - //set result info: + addResults:function( data ) { + var _this = this; + if ( data.response && data.response.docs ) { + // set result info: this.num_results = data.response.numFound; - for(var resource_id in data.response.docs){ - var resource = data.response.docs[resource_id]; + for ( var resource_id in data.response.docs ) { + var resource = data.response.docs[resource_id]; var rObj = { - //@@todo we should add .ogv or oga if video or audio: + // @@todo we should add .ogv or oga if video or audio: 'titleKey' : resource.identifier + '.ogg', - 'resourceKey': resource.identifier, - 'link' : _this.dtUrl + resource.identifier, + 'resourceKey': resource.identifier, + 'link' : _this.dtUrl + resource.identifier, 'title' : resource.title, - 'poster' : _this.dnUrl + resource.identifier+'/format=thumbnail', - 'poster_ani' : _this.dnUrl + resource.identifier+'/format=Animated+Gif', + 'poster' : _this.dnUrl + resource.identifier + '/format=thumbnail', + 'poster_ani' : _this.dnUrl + resource.identifier + '/format=Animated+Gif', 'thumbwidth' : 160, - 'thumbheight': 110, + 'thumbheight': 110, 'desc' : resource.description, - 'src' : _this.dnUrl + resource.identifier+'/format=Ogg+video', + 'src' : _this.dnUrl + resource.identifier + '/format=Ogg+video', 'mime' : 'application/ogg', - //set the license: (rsd is a pointer to the parent remoteSearchDriver ) + // set the license: (rsd is a pointer to the parent remoteSearchDriver ) 'license' : this.rsd.getLicenceFromUrl( resource.licenseurl ), - 'pSobj' :_this + 'pSobj' :_this - }; - this.resultsObj[ resource_id ] = rObj; + }; + this.resultsObj[ resource_id ] = rObj; } - } + } }, - //getTitleKey:function(rObj){ + // getTitleKey:function(rObj){ // return rObj['stream_name'] + '__' + rObj['start_time'].replace(/:/g,'.') + '_to_' + rObj['end_time'].replace(/:/g,'.') + '.ogg';; - //} - getEmbedTimeMeta:function(rObj, callback){ + // } + getEmbedTimeMeta:function( rObj, callback ) { var _this = this; do_api_req( { - 'data':{'avinfo':1}, - 'url':_this.dnUrl + rObj.resourceKey + '/format=Ogg+video' - },function(data){ - if(data['length']) + 'data': { 'avinfo':1 }, + 'url':_this.dnUrl + rObj.resourceKey + '/format=Ogg+video' + }, function( data ) { + if ( data['length'] ) rObj.duration = data['length']; - if(data['width']) + if ( data['width'] ) rObj.width = data['width']; - if(data['height']) + if ( data['height'] ) rObj.height = data['height']; callback(); - }); + } ); }, - getEmbedHTML: function( rObj , options) { - js_log('getEmbedHTML:: ' + rObj.poster ); - if(!options) - options ={}; - var id_attr = (options['id'])?' id = "' + options['id'] +'" ': ''; - if( rObj.duration ){ - var src = rObj.src + '?t=0:0:0/'+ seconds2npt( rObj.duration ); - }else{ + getEmbedHTML: function( rObj , options ) { + js_log( 'getEmbedHTML:: ' + rObj.poster ); + if ( !options ) + options = { }; + var id_attr = ( options['id'] ) ? ' id = "' + options['id'] + '" ': ''; + if ( rObj.duration ) { + var src = rObj.src + '?t=0:0:0/' + seconds2npt( rObj.duration ); + } else { var src = rObj.src; } - if(rObj.mime == 'application/ogg' || rObj.mime == 'audio/ogg' || rObj.mime=='video/ogg'){ + if ( rObj.mime == 'application/ogg' || rObj.mime == 'audio/ogg' || rObj.mime == 'video/ogg' ) { return ''; } } diff --git a/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js index 9fb234aa4d..787961532a 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js @@ -1,8 +1,8 @@ -//base remote search obj +// base remote search obj -loadGM({ +loadGM( { "mwe-imported_from" : "$1 imported from [$2 $3]. See the original [$4 resource page] for more information." -}) +} ) // @key is name of rObj variable // @value is where to find the value in the item xml // @@ -19,228 +19,228 @@ var rsd_default_rss_item_mapping = { 'title' : 'title', 'link' : 'link', 'desc' : 'description', - //multiple items + // multiple items 'category' : '.media:category@label|url' } -var baseRemoteSearch = function(iObj) { - return this.init(iObj); +var baseRemoteSearch = function( iObj ) { + return this.init( iObj ); }; baseRemoteSearch.prototype = { completed_req:0, num_req:0, - resultsObj:{}, + resultsObj: { }, - //default search result values for paging: + // default search result values for paging: offset :0, limit : 30, more_results : false, num_results : 0, - //init the object: - init: function( iObj ){ - js_log('mvBaseRemoteSearch:init'); - for(var i in iObj){ + // init the object: + init: function( iObj ) { + js_log( 'mvBaseRemoteSearch:init' ); + for ( var i in iObj ) { this[i] = iObj[i]; } return this; }, - getSearchResults:function(){ - //empty out the current results before issuing a request - this.resultsObj = {}; - //do global getSearchResults bindings - this.last_query = $j('#rsd_q').val(); + getSearchResults:function() { + // empty out the current results before issuing a request + this.resultsObj = { }; + // do global getSearchResults bindings + this.last_query = $j( '#rsd_q' ).val(); this.last_offset = this.cp.offset; - //set the loading flag: - this.loading=true; - }, + // set the loading flag: + this.loading = true; + }, /* * Parses and adds video rss based input format * @param $data XML data to parse * @param provider_url the source url (used to generate absolute links) */ - addRSSData:function( data , provider_url ){ - js_log('f:addRSSData'); + addRSSData:function( data , provider_url ) { + js_log( 'f:addRSSData' ); var _this = this; var http_host = ''; var http_path = ''; - if(provider_url){ + if ( provider_url ) { pUrl = parseUri( provider_url ); - http_host = pUrl.protocol +'://'+ pUrl.authority; + http_host = pUrl.protocol + '://' + pUrl.authority; http_path = pUrl.directory; } - var items = data.getElementsByTagName('item'); - //js_log('found ' + items.length ); - $j.each(items, function(inx, item){ - var rObj = {}; - for(var i in rsd_default_rss_item_mapping){ - var selector = rsd_default_rss_item_mapping[i].split('@'); - - var flag_multiple = ( selector[0].substr(0,1) == '.' ) ? true : false; - if( flag_multiple ){ + var items = data.getElementsByTagName( 'item' ); + // js_log('found ' + items.length ); + $j.each( items, function( inx, item ) { + var rObj = { }; + for ( var i in rsd_default_rss_item_mapping ) { + var selector = rsd_default_rss_item_mapping[i].split( '@' ); + + var flag_multiple = ( selector[0].substr( 0, 1 ) == '.' ) ? true : false; + if ( flag_multiple ) { rObj[i] = new Array(); - var tag_name = selector[0].substr(1); - }else{ + var tag_name = selector[0].substr( 1 ); + } else { var tag_name = selector[0]; } var attr_name = null; - if( typeof selector[1] != 'undefined'){ + if ( typeof selector[1] != 'undefined' ) { attr_name = selector[1]; - if( attr_name.indexOf('|') != -1 ) - attr_name = attr_name.split('|'); + if ( attr_name.indexOf( '|' ) != - 1 ) + attr_name = attr_name.split( '|' ); } - $j.each( item.getElementsByTagName( tag_name ), function ( inx, node ){ + $j.each( item.getElementsByTagName( tag_name ), function ( inx, node ) { var tag_val = ''; - if( node!=null && attr_name == null ){ - if( node.childNodes[0] != null){ - //trim and strip html: - tag_val = $j.trim( node.firstChild.nodeValue ).replace(/(<([^>]+)>)/ig,""); + if ( node != null && attr_name == null ) { + if ( node.childNodes[0] != null ) { + // trim and strip html: + tag_val = $j.trim( node.firstChild.nodeValue ).replace( / ( < ( [ ^ > ] + ) > ) / ig, "" ); } } - if( node!=null && attr_name != null){ - if( typeof attr_name == 'string' ){ + if ( node != null && attr_name != null ) { + if ( typeof attr_name == 'string' ) { tag_val = $j.trim( $j( node ).attr( attr_name ) ); - }else{ - var attr_vals = {}; - for( var j in attr_name ){ - if( $j(node).attr( attr_name[j] ).length != 0) - attr_vals[ attr_name[j] ] = $j.trim( $j(node).attr( attr_name[j]) ).replace(/(<([^>]+)>)/ig,""); + } else { + var attr_vals = { }; + for ( var j in attr_name ) { + if ( $j( node ).attr( attr_name[j] ).length != 0 ) + attr_vals[ attr_name[j] ] = $j.trim( $j( node ).attr( attr_name[j] ) ).replace( / ( < ( [ ^ > ] + ) > ) / ig, "" ); } tag_val = attr_vals ; } } - if(flag_multiple){ - rObj[i].push( tag_val) - }else{ + if ( flag_multiple ) { + rObj[i].push( tag_val ) + } else { rObj[i] = tag_val; } - }); + } ); } // done with property loop - //make relative urls absolute: - var url_param = new Array('src', 'poster'); - for(var j=0; j < url_param.length; j++){ + // make relative urls absolute: + var url_param = new Array( 'src', 'poster' ); + for ( var j = 0; j < url_param.length; j++ ) { var p = url_param[j]; - if(typeof rObj[p] != 'undefined'){ - if( rObj[p].substr(0,1)=='/' ){ + if ( typeof rObj[p] != 'undefined' ) { + if ( rObj[p].substr( 0, 1 ) == '/' ) { rObj[p] = http_host + rObj[p]; } - if( parseUri( rObj[i] ).host == rObj[p]){ + if ( parseUri( rObj[i] ).host == rObj[p] ) { rObj[p] = http_host + http_path + rObj[p]; } } } - //force a mime type for now.. in the future generalize for other RSS feeds and conversions + // force a mime type for now.. in the future generalize for other RSS feeds and conversions rObj['mime'] = 'video/ogg'; - //add pointer to parent search obj:( this.cp.limit )? this.cp.limit : this.limit, + // add pointer to parent search obj:( this.cp.limit )? this.cp.limit : this.limit, rObj['pSobj'] = _this; - //add the result to the result set: + // add the result to the result set: _this.resultsObj[ inx ] = rObj; _this.num_results++; - }); + } ); }, - getEmbedHTML: function( rObj , options) { - if(!options) - options = {}; - //set up the output var with the default values: - var outOpt = { 'width': rObj.width, 'height': rObj.height}; - if( options['max_height'] ){ - outOpt.height = (options.max_height > rObj.height) ? rObj.height : options.max_height; - outOpt.width = (rObj.width / rObj.height) *outOpt.height; - } - options.style_attr = 'style="width:' + outOpt.width + 'px;height:' + outOpt.height +'px"'; - options.id_attr = (options['id'])?' id = "' + options['id'] +'" ': ''; + getEmbedHTML: function( rObj , options ) { + if ( !options ) + options = { }; + // set up the output var with the default values: + var outOpt = { 'width': rObj.width, 'height': rObj.height }; + if ( options['max_height'] ) { + outOpt.height = ( options.max_height > rObj.height ) ? rObj.height : options.max_height; + outOpt.width = ( rObj.width / rObj.height ) * outOpt.height; + } + options.style_attr = 'style="width:' + outOpt.width + 'px;height:' + outOpt.height + 'px"'; + options.id_attr = ( options['id'] ) ? ' id = "' + options['id'] + '" ': ''; - if( rObj.mime.indexOf('image') != -1 ){ + if ( rObj.mime.indexOf( 'image' ) != - 1 ) { return this.getImageEmbedHTML( rObj, options ); - }else{ - js_log("ERROR:: no embed code for mime type: " + rObj.mime); + } else { + js_log( "ERROR:: no embed code for mime type: " + rObj.mime ); return ' Error missing embed code '; } }, - getImageEmbedHTML:function( rObj, options ) { - //if crop is null do base output: + getImageEmbedHTML:function( rObj, options ) { + // if crop is null do base output: var imgHtml = ''; - if( rObj.crop == null) + if ( rObj.crop == null ) return imgHtml - //else do crop output: - return '
' + - '
'+ - imgHtml + - '
'+ + // else do crop output: + return '
' + + '
' + + imgHtml + + '
' + '
'; }, - //by default just return the existing image with callback - getImageObj:function( rObj, size, callback){ - callback( {'url':rObj.poster} ); + // by default just return the existing image with callback + getImageObj:function( rObj, size, callback ) { + callback( { 'url':rObj.poster } ); }, - //by default just return the rObj.desc - getInlineDescWiki:function( rObj ){ - //return striped html & trim white space - if(rObj.desc) - return $j.trim( rObj.desc.replace(/(<([^>]+)>)/ig,"") ); - //no desc avaliable: + // by default just return the rObj.desc + getInlineDescWiki:function( rObj ) { + // return striped html & trim white space + if ( rObj.desc ) + return $j.trim( rObj.desc.replace( / ( < ( [ ^ > ] + ) > ) / ig, "" ) ); + // no desc avaliable: return ''; }, - //default license permission wiki text is cc based template mapping (does not confirm the templates actually exist) - getPermissionWikiTag: function( rObj ){ - if(!rObj.license) - return '';//no license info - //check that its a defined creative commons licnese key: - if( this.rsd.licenses.cc.licenses[ rObj.license.key ] != 'undefined' ){ + // default license permission wiki text is cc based template mapping (does not confirm the templates actually exist) + getPermissionWikiTag: function( rObj ) { + if ( !rObj.license ) + return '';// no license info + // check that its a defined creative commons licnese key: + if ( this.rsd.licenses.cc.licenses[ rObj.license.key ] != 'undefined' ) { return '{{Cc-' + rObj.license.key + '}}'; - }else if( rObj.license.lurl ) { + } else if ( rObj.license.lurl ) { return '{{Template:External_License|' + rObj.license.lurl + '}}'; } }, - getImportResourceDescWiki:function(rObj){ - return gM('mwe-imported_from', [rObj.title, this.cp.homepage, this.cp.title, rObj.link]); + getImportResourceDescWiki:function( rObj ) { + return gM( 'mwe-imported_from', [rObj.title, this.cp.homepage, this.cp.title, rObj.link] ); }, - //for thigns like categories and the like - getExtraResourceDescWiki:function( rObj ){ + // for thigns like categories and the like + getExtraResourceDescWiki:function( rObj ) { return ''; }, - //by default just return the poster (clients can overide) - getImageTransform:function(rObj, opt){ + // by default just return the poster (clients can overide) + getImageTransform:function( rObj, opt ) { return rObj.poster; }, - getEmbedObjParsedInfo:function(rObj, eb_id){ + getEmbedObjParsedInfo:function( rObj, eb_id ) { return rObj; }, - getEmbedTimeMeta:function(rObj, callback){ + getEmbedTimeMeta:function( rObj, callback ) { callback(); }, - getEmbedWikiCode:function(rObj){ - var layout = ( rObj.layout)? rObj.layout:"right" - var o= '[[' + this.rsd.cFileNS + ':' + rObj.target_resource_title + '|thumb|'+layout; + getEmbedWikiCode:function( rObj ) { + var layout = ( rObj.layout ) ? rObj.layout:"right" + var o = '[[' + this.rsd.cFileNS + ':' + rObj.target_resource_title + '|thumb|' + layout; - if(!rObj.target_width && rObj.width){ - rObj.target_width = (rObj.width < 640)? rObj.width: '640'; + if ( !rObj.target_width && rObj.width ) { + rObj.target_width = ( rObj.width < 640 ) ? rObj.width: '640'; } - if(rObj.target_width) - o+='|' + rObj.target_width + 'px'; + if ( rObj.target_width ) + o += '|' + rObj.target_width + 'px'; - if( rObj.inlineDesc ) - o+='|' + rObj.inlineDesc; + if ( rObj.inlineDesc ) + o += '|' + rObj.inlineDesc; - o+=']]'; + o += ']]'; return o; }, - updateTargetResourceTitle:function(rObj){ - rObj.target_resource_title = rObj.titleKey.replace(/File:|Image:/,''); + updateTargetResourceTitle:function( rObj ) { + rObj.target_resource_title = rObj.titleKey.replace( / File: | Image: / , '' ); rObj.target_resource_title = this.cp.resource_prefix + rObj.target_resource_title; }, - updateDataForImport:function( rObj ){ + updateDataForImport:function( rObj ) { return rObj; } } diff --git a/js2/mwEmbed/libAddMedia/searchLibs/flickrSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/flickrSearch.js index 9c95d9a662..eb320c9f6d 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/flickrSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/flickrSearch.js @@ -15,141 +15,141 @@ http://www.flickr.com/services/rest/?method=flickr.test.echo&format=json&api_key (8) United States Government Work */ -var flickrSearch = function ( iObj){ +var flickrSearch = function ( iObj ) { return this.init( iObj ); } flickrSearch.prototype = { dtUrl : 'http://www.flickr.com/photos/', - //@@todo probably would be good to read the api-key from configuration - apikey : '2867787a545cc66c0bce6f2e57aca1d1', - //what licence we are interested in - _licence_keys: '4,5,7,8', - _srctypes: ['t','sq','s','m','o'], - licenceMap:{ + // @@todo probably would be good to read the api-key from configuration + apikey : '2867787a545cc66c0bce6f2e57aca1d1', + // what licence we are interested in + _licence_keys: '4,5,7,8', + _srctypes: ['t', 'sq', 's', 'm', 'o'], + licenceMap: { '4' : 'http://creativecommons.org/licenses/by/3.0/', '5' : 'http://creativecommons.org/licenses/by-sa/3.0/', '7' : 'http://www.flickr.com/commons/usage/', '8' : 'http://www.usa.gov/copyright.shtml' }, - init:function( iObj ){ - //init base class and inherit: + init:function( iObj ) { + // init base class and inherit: var baseSearch = new baseRemoteSearch( iObj ); - for(var i in baseSearch){ - if(typeof this[i] =='undefined'){ + for ( var i in baseSearch ) { + if ( typeof this[i] == 'undefined' ) { this[i] = baseSearch[i]; - }else{ - this['parent_'+i] = baseSearch[i]; + } else { + this['parent_' + i] = baseSearch[i]; } } - //inherit the cp settings for + // inherit the cp settings for }, - getSearchResults:function(){ + getSearchResults:function() { var _this = this; - js_log("flickr::getSearchResults"); - //call parent (sets loading sate and other setup stuff) + js_log( "flickr::getSearchResults" ); + // call parent (sets loading sate and other setup stuff) this.parent_getSearchResults(); - //setup the flickr request: + // setup the flickr request: var reqObj = { - 'method':'flickr.photos.search', + 'method':'flickr.photos.search', 'format':'json', - 'license':this._licence_keys, - 'api_key':this.apikey, + 'license':this._licence_keys, + 'api_key':this.apikey, 'per_page': this.cp.limit, 'page' : this.cp.offset, - 'text': $j('#rsd_q').val(), - 'extras' : 'license, date_upload, date_taken, owner_name, icon_server, original_format, last_update, geo, tags, machine_tags, o_dims, views, media, path_alias, url_sq, url_t, url_s, url_m, url_o' - } + 'text': $j( '#rsd_q' ).val(), + 'extras' : 'license, date_upload, date_taken, owner_name, icon_server, original_format, last_update, geo, tags, machine_tags, o_dims, views, media, path_alias, url_sq, url_t, url_s, url_m, url_o' + } do_api_req( { 'data': reqObj, 'url':this.cp.api_url, 'jsonCB':'jsoncallback', - }, function( data ){ - _this.addResults( data); + }, function( data ) { + _this.addResults( data ); _this.loading = false; - }); + } ); }, - addResults:function( data ){ - var _this = this; - if(data.photos && data.photos.photo){ - //set result info: - this.num_results = data.photos.total; - if( this.num_results > this.cp.offset + this.cp.limit ){ + addResults:function( data ) { + var _this = this; + if ( data.photos && data.photos.photo ) { + // set result info: + this.num_results = data.photos.total; + if ( this.num_results > this.cp.offset + this.cp.limit ) { this.more_results = true; - } - for(var resource_id in data.photos.photo){ - var resource = data.photos.photo[resource_id]; + } + for ( var resource_id in data.photos.photo ) { + var resource = data.photos.photo[resource_id]; var rObj = { 'titleKey' : resource.title + '.jpg', 'resourceKey': resource.id, - 'link' : _this.dtUrl + resource.pathalias + '/'+ resource.id, + 'link' : _this.dtUrl + resource.pathalias + '/' + resource.id, 'title' : resource.title, 'thumbwidth' : resource.width_t, - 'thumbheight': resource.height_t, - 'desc' : resource.title, - //set the license: (rsd is a pointer to the parent remoteSearchDriver ) + 'thumbheight': resource.height_t, + 'desc' : resource.title, + // set the license: (rsd is a pointer to the parent remoteSearchDriver ) 'license' : this.rsd.getLicenceFromUrl( _this.licenceMap[ resource.license ] ), - 'pSobj' : _this, - //assume image/jpeg for "photos" - 'mime' : 'image/jpeg' - }; - //set all the provided srcs: - rObj['srcSet'] = {}; - for( var i in _this._srctypes){ + 'pSobj' : _this, + // assume image/jpeg for "photos" + 'mime' : 'image/jpeg' + }; + // set all the provided srcs: + rObj['srcSet'] = { }; + for ( var i in _this._srctypes ) { var st = _this._srctypes[i]; - //if resource has a url add it to the srcSet: - if( resource['url_' + st] ){ + // if resource has a url add it to the srcSet: + if ( resource['url_' + st] ) { rObj['srcSet'][st] = { 'h': resource['height_' + st], 'w': resource['width_' + st], 'src': resource['url_' + st] } - //set src to the largest + // set src to the largest rObj['src'] = resource['url_' + st]; } - } + } _this.resultsObj[ resource_id ] = rObj; } } }, - //return image transform via callback - getImageObj:function( rObj, size, callback){ - if( size.width ){ - var skey = this.getSrcTypeKey(rObj, size.width ) - callback ({ + // return image transform via callback + getImageObj:function( rObj, size, callback ) { + if ( size.width ) { + var skey = this.getSrcTypeKey( rObj, size.width ) + callback ( { 'url' : rObj.srcSet[ skey ].src, 'width' : rObj.srcSet[ skey ].w, 'height' : rObj.srcSet[ skey ].h - }); + } ); + } + }, + getImageTransform:function( rObj, opt ) { + if ( opt.width ) { + return rObj.srcSet[ this.getSrcTypeKey( rObj, opt.width ) ].src; } - }, - getImageTransform:function(rObj, opt){ - if( opt.width ){ - return rObj.srcSet[ this.getSrcTypeKey(rObj, opt.width) ].src; - } }, - getSrcTypeKey:function(rObj, width ){ - if( width <= 75 ){ - if( rObj.srcSet['sq'] ) - return 'sq'; - }else if( width <= 100 ){ - if( rObj.srcSet['t'] ) + getSrcTypeKey:function( rObj, width ) { + if ( width <= 75 ) { + if ( rObj.srcSet['sq'] ) + return 'sq'; + } else if ( width <= 100 ) { + if ( rObj.srcSet['t'] ) return 't'; - }else if( width <= 240 ){ - if( rObj.srcSet['s'] ) + } else if ( width <= 240 ) { + if ( rObj.srcSet['s'] ) return 's'; - }else if( width <= 500 ){ - if( rObj.srcSet['m'] ) + } else if ( width <= 500 ) { + if ( rObj.srcSet['m'] ) return 'm'; - }else{ - if( rObj.srcSet['o'] ) + } else { + if ( rObj.srcSet['o'] ) return 'o'; } - //original was missing return medium or small - if( rObj.srcSet['m'] ) + // original was missing return medium or small + if ( rObj.srcSet['m'] ) return 'm'; - if( rObj.srcSet['s'] ) + if ( rObj.srcSet['s'] ) return 's'; } diff --git a/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js index 1740e3da8e..27113c96a6 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js @@ -1,129 +1,129 @@ -var mediaWikiSearch = function( iObj ) { +var mediaWikiSearch = function( iObj ) { return this.init( iObj ); }; mediaWikiSearch.prototype = { - init:function( iObj ){ - //init base class and inherit: + init:function( iObj ) { + // init base class and inherit: var baseSearch = new baseRemoteSearch( iObj ); - for(var i in baseSearch){ - if(typeof this[i] =='undefined'){ + for ( var i in baseSearch ) { + if ( typeof this[i] == 'undefined' ) { this[i] = baseSearch[i]; - }else{ - this['parent_'+i] = baseSearch[i]; + } else { + this['parent_' + i] = baseSearch[i]; } } - //inherit the cp settings for - }, - //returns a rObj by title - addByTitle:function( title , callback, redirect_count){ - js_log("AddByTitle::" + title); - var _this = this; - if(!redirect_count) - redirect_count=0; - if(redirect_count > 5){ - js_log('Error: addByTitle too many redirects'); + // inherit the cp settings for + }, + // returns a rObj by title + addByTitle:function( title , callback, redirect_count ) { + js_log( "AddByTitle::" + title ); + var _this = this; + if ( !redirect_count ) + redirect_count = 0; + if ( redirect_count > 5 ) { + js_log( 'Error: addByTitle too many redirects' ); callback( false ); return false; } var reqObj = { 'action':'query', - 'titles':'File:'+title, + 'titles':'File:' + title, 'prop':'imageinfo|revisions|categories', 'iiprop':'url|mime|size', 'iiurlwidth': parseInt( this.rsd.thumb_width ), - 'rvprop':'content' + 'rvprop':'content' } do_api_req( { - 'data':reqObj, - 'url':this.cp.api_url - }, function(data){ - //check for redirect - for(var i in data.query.pages){ - var page = data.query.pages[i]; - if(page.revisions[0]['*'] && page.revisions[0]['*'].indexOf('#REDIRECT') === 0){ - var re = new RegExp(/[^\[]*\[\[([^\]]*)/); + 'data':reqObj, + 'url':this.cp.api_url + }, function( data ) { + // check for redirect + for ( var i in data.query.pages ) { + var page = data.query.pages[i]; + if ( page.revisions[0]['*'] && page.revisions[0]['*'].indexOf( '#REDIRECT' ) === 0 ) { + var re = new RegExp( /[^\[]*\[\[([^\]]*)/ ); var pt = page.revisions[0]['*'].match( re ); - if( pt[1] ){ - _this.addByTitle( pt[1], callback, redirect_count++); + if ( pt[1] ) { + _this.addByTitle( pt[1], callback, redirect_count++ ); return ; - }else{ - js_log('Error: addByTitle could not proccess redirect'); + } else { + js_log( 'Error: addByTitle could not proccess redirect' ); callback( false ); return false; } } } - //if not a redirect do the callback directly: - callback( _this.addSingleResult(data) ); + // if not a redirect do the callback directly: + callback( _this.addSingleResult( data ) ); } - ); + ); }, - clearResults:function(){ - this.resultsObj = {}; - this.last_query =''; + clearResults:function() { + this.resultsObj = { }; + this.last_query = ''; }, - //update the resultObj with recently uploaded items by current User: - getUserRecentUploads:function(wgUser, callback){ + // update the resultObj with recently uploaded items by current User: + getUserRecentUploads:function( wgUser, callback ) { var _this = this; - do_api_req({ - 'data':{ + do_api_req( { + 'data': { 'action':'query', 'list':'recentchanges', - 'rcnamespace':6, //only files + 'rcnamespace':6, // only files 'rcuser': wgUser, - 'rclimit':15, //get last 15 uploaded files + 'rclimit':15, // get last 15 uploaded files }, 'url':this.cp.api_url - },function(data){ - var titleSet = {}; + }, function( data ) { + var titleSet = { }; var titleStr = '' var pound = ''; - //loop over the data and group by title - if(data.query && data.query.recentchanges){ - for(var i in data.query.recentchanges){ + // loop over the data and group by title + if ( data.query && data.query.recentchanges ) { + for ( var i in data.query.recentchanges ) { var rc = data.query.recentchanges[i]; - if( !titleSet[ rc.title ] ){ - titleSet[ rc.title ]=true; - titleStr+= pound + rc.title; - pound ='|'; + if ( !titleSet[ rc.title ] ) { + titleSet[ rc.title ] = true; + titleStr += pound + rc.title; + pound = '|'; } } - } - //now run the actual query ( too bad we can't use recentchanges as a generator ) - //bug 20563 - do_api_req({ + } + // now run the actual query ( too bad we can't use recentchanges as a generator ) + // bug 20563 + do_api_req( { 'data' : { 'action' : 'query', - 'titles' : titleStr, + 'titles' : titleStr, 'prop' : 'imageinfo|revisions|categories', 'iiprop' : 'url|mime|size', 'iiurlwidth': parseInt( _this.rsd.thumb_width ), - 'rvprop':'content' + 'rvprop':'content' }, 'url':_this.cp.api_url - },function(data){ + }, function( data ) { _this.clearResults(); - _this.addResults(data); - if(callback) + _this.addResults( data ); + if ( callback ) callback(); - }); - }); - }, - getSearchResults:function(){ - //call parent: + } ); + } ); + }, + getSearchResults:function() { + // call parent: this.parent_getSearchResults(); - //set local ref: + // set local ref: var _this = this; - js_log('f:getSearchResults for:' + $j('#rsd_q').val() ); - //do two queries against the Image / File / MVD namespace: - - //build the image request object: + js_log( 'f:getSearchResults for:' + $j( '#rsd_q' ).val() ); + // do two queries against the Image / File / MVD namespace: + + // build the image request object: var reqObj = { - 'action':'query', + 'action':'query', 'generator':'search', - 'gsrsearch': $j('#rsd_q').val(), - 'gsrnamespace':6, //(only search the "file" namespace (audio, video, images) + 'gsrsearch': $j( '#rsd_q' ).val(), + 'gsrnamespace':6, // (only search the "file" namespace (audio, video, images) 'gsrwhat':'title', 'gsrlimit': this.cp.limit, 'gsroffset': this.cp.offset, @@ -131,61 +131,61 @@ mediaWikiSearch.prototype = { 'iiprop':'url|mime|size', 'iiurlwidth': parseInt( this.rsd.thumb_width ), 'rvprop':'content' - }; - //set up the number of request: - this.completed_req=0; - this.num_req=1; - //setup the number of requests result flag: - //also do a request for page titles (would be nice if api could query both at the same time) - reqObj['gsrwhat']='text'; + }; + // set up the number of request: + this.completed_req = 0; + this.num_req = 1; + // setup the number of requests result flag: + // also do a request for page titles (would be nice if api could query both at the same time) + reqObj['gsrwhat'] = 'text'; do_api_req( { - 'data':reqObj, - 'url':this.cp.api_url - }, function(data){ - js_log('mediaWikiSearch: got data response'); - //parse the return data - _this.addResults( data); - //_this.checkRequestDone(); //only need if we do two queries one for title one for text + 'data':reqObj, + 'url':this.cp.api_url + }, function( data ) { + js_log( 'mediaWikiSearch: got data response' ); + // parse the return data + _this.addResults( data ); + // _this.checkRequestDone(); //only need if we do two queries one for title one for text _this.loading = false; - }); - }, - //same as below but returns your rObj for convenience - addSingleResult:function( data ){ - return this.addResults(data, true); + } ); + }, + // same as below but returns your rObj for convenience + addSingleResult:function( data ) { + return this.addResults( data, true ); }, - addResults:function( data, returnFirst ){ - js_log("f:addResults"); - var _this = this - //check if we have - if( typeof data['query-continue'] != 'undefined'){ - if( typeof data['query-continue'].search != 'undefined') - this.more_results = true; + addResults:function( data, returnFirst ) { + js_log( "f:addResults" ); + var _this = this + // check if we have + if ( typeof data['query-continue'] != 'undefined' ) { + if ( typeof data['query-continue'].search != 'undefined' ) + this.more_results = true; } - //make sure we have pages to idorate: - if(data.query && data.query.pages){ - for(var page_id in data.query.pages){ + // make sure we have pages to idorate: + if ( data.query && data.query.pages ) { + for ( var page_id in data.query.pages ) { var page = data.query.pages[ page_id ]; - //make sure the reop is shared (don't show for now it confusing things) - //@@todo support remote repository better - if( page.imagerepository == 'shared'){ + // make sure the reop is shared (don't show for now it confusing things) + // @@todo support remote repository better + if ( page.imagerepository == 'shared' ) { continue; } - //make sure the page is not a redirect - if(page.revisions && page.revisions[0] && - page.revisions[0]['*'] && page.revisions[0]['*'].indexOf('#REDIRECT') === 0){ - //skip page is redirect + // make sure the page is not a redirect + if ( page.revisions && page.revisions[0] && + page.revisions[0]['*'] && page.revisions[0]['*'].indexOf( '#REDIRECT' ) === 0 ) { + // skip page is redirect continue; - } - //skip if its an empty or missing imageinfo: - if( !page.imageinfo ) + } + // skip if its an empty or missing imageinfo: + if ( !page.imageinfo ) continue; var rObj = { 'id' : page_id, 'titleKey' : page.title, - 'link' : page.imageinfo[0].descriptionurl, - 'title' : page.title.replace(/File:|.jpg|.png|.svg|.ogg|.ogv|.oga/ig, ''), + 'link' : page.imageinfo[0].descriptionurl, + 'title' : page.title.replace( / File: | .jpg | .png | .svg | .ogg | .ogv | .oga / ig, '' ), 'poster' : page.imageinfo[0].thumburl, 'thumbwidth' : page.imageinfo[0].thumbwidth, 'thumbheight': page.imageinfo[0].thumbheight, @@ -193,13 +193,13 @@ mediaWikiSearch.prototype = { 'orgheight' : page.imageinfo[0].height, 'mime' : page.imageinfo[0].mime, 'src' : page.imageinfo[0].url, - 'desc' : page.revisions[0]['*'], - //add pointer to parent search obj: - 'pSobj' :_this, - 'meta':{ + 'desc' : page.revisions[0]['*'], + // add pointer to parent search obj: + 'pSobj' :_this, + 'meta': { 'categories':page.categories } - }; + }; /* //to use once we get the wiki-text parser in shape var pObj = mw.parser.pNew( rObj.desc ); @@ -207,162 +207,162 @@ mediaWikiSearch.prototype = { var tmplInfo = pObj.templates( 'information' ); */ - //attempt to parse out the description current user desc from the commons template: - //@@todo these could be combined to a single regEx + // attempt to parse out the description current user desc from the commons template: + // @@todo these could be combined to a single regEx // or better improve the wiki-text parsing and use above - var desc = rObj.desc.match(/\|\s*description\s*=\s*(([^\n]*\n)*)\|\s*source=/i); - if( desc && desc[1] ){ - rObj.desc = $j.trim( desc[1] ); - //attempt to get the user language if set: - if( typeof wgUserLanguage != 'undefined' && wgUserLanguage ){ - //for some reason the RegExp object is not happy: - var reg = new RegExp( '\{\{\s*' + wgUserLanguage + '([^=]*)=([^\}]*)\}\}', 'gim' ); + var desc = rObj.desc.match( /\|\s*description\s*=\s*(([^\n]*\n)*)\|\s*source=/i ); + if ( desc && desc[1] ) { + rObj.desc = $j.trim( desc[1] ); + // attempt to get the user language if set: + if ( typeof wgUserLanguage != 'undefined' && wgUserLanguage ) { + // for some reason the RegExp object is not happy: + var reg = new RegExp( '\{\{\s*' + wgUserLanguage + '([^=]*)=([^\}]*)\}\}', 'gim' ); var langMatch = reg.exec( rObj.desc ); - if(langMatch && langMatch[2]){ + if ( langMatch && langMatch[2] ) { rObj.desc = langMatch[2]; - }else{ - //try simple lang template form: + } else { + // try simple lang template form: var reg = new RegExp( '\{\{\s*' + wgUserLanguage + '\\|([^\}]*)\}\}', 'gim' ); - var langMatch = reg.exec( rObj.desc ); - if(langMatch && langMatch[1]){ + var langMatch = reg.exec( rObj.desc ); + if ( langMatch && langMatch[1] ) { rObj.desc = langMatch[1]; - } + } } - } + } } - //likely a audio clip if no poster and type application/ogg - //@@todo we should return audio/ogg for the mime type or some other way to specify its "audio" - if( ! rObj.poster && rObj.mime == 'application/ogg' ){ + // likely a audio clip if no poster and type application/ogg + // @@todo we should return audio/ogg for the mime type or some other way to specify its "audio" + if ( ! rObj.poster && rObj.mime == 'application/ogg' ) { rObj.mime = 'audio/ogg'; } - //add to the resultObj + // add to the resultObj this.resultsObj[page_id] = rObj; - //if returnFirst flag: - if(returnFirst) + // if returnFirst flag: + if ( returnFirst ) return this.resultsObj[page_id]; - this.num_results++; - //for(var i in this.resultsObj[page_id]){ + this.num_results++; + // for(var i in this.resultsObj[page_id]){ // js_log('added: '+ i +' '+ this.resultsObj[page_id][i]); - //} + // } } - }else{ - js_log('no results:' + data); - } - }, - //check request done used for when we have multiple requests to check before formating results. - checkRequestDone:function(){ - //display output if done: + } else { + js_log( 'no results:' + data ); + } + }, + // check request done used for when we have multiple requests to check before formating results. + checkRequestDone:function() { + // display output if done: this.completed_req++; - if(this.completed_req == this.num_req){ + if ( this.completed_req == this.num_req ) { this.loading = 0; } - }, - getImageObj:function( rObj, size, callback ){ - if( rObj.mime=='application/ogg' ) - return callback( {'url':rObj.src, 'poster' : rObj.url } ); + }, + getImageObj:function( rObj, size, callback ) { + if ( rObj.mime == 'application/ogg' ) + return callback( { 'url':rObj.src, 'poster' : rObj.url } ); - //his could be depreciated if thumb.php improves + // his could be depreciated if thumb.php improves var reqObj = { 'action':'query', 'format':'json', 'titles':rObj.titleKey, 'prop':'imageinfo', - 'iiprop':'url|size|mime' + 'iiprop':'url|size|mime' } - //set the width: - if(size.width) - reqObj['iiurlwidth']= size.width; - js_log('going to do req: ' + this.cp.api_url + ' ' + reqObj ); + // set the width: + if ( size.width ) + reqObj['iiurlwidth'] = size.width; + js_log( 'going to do req: ' + this.cp.api_url + ' ' + reqObj ); do_api_req( { - 'data':reqObj, + 'data':reqObj, 'url' : this.cp.api_url - }, function(data){ - var imObj = {}; - for(var page_id in data.query.pages){ + }, function( data ) { + var imObj = { }; + for ( var page_id in data.query.pages ) { var iminfo = data.query.pages[ page_id ].imageinfo[0]; - //store the orginal width: - imObj['org_width']=iminfo.width; - //check if thumb size > than image size and is jpeg or png (it will not scale well above its max res) - if( ( iminfo.mime=='image/jpeg' || iminfo=='image/png' ) && - iminfo.thumbwidth > iminfo.width ){ + // store the orginal width: + imObj['org_width'] = iminfo.width; + // check if thumb size > than image size and is jpeg or png (it will not scale well above its max res) + if ( ( iminfo.mime == 'image/jpeg' || iminfo == 'image/png' ) && + iminfo.thumbwidth > iminfo.width ) { imObj['url'] = iminfo.url; imObj['width'] = iminfo.width; - imObj['height'] = iminfo.height; - }else{ - imObj['url'] = iminfo.thumburl; + imObj['height'] = iminfo.height; + } else { + imObj['url'] = iminfo.thumburl; imObj['width'] = iminfo.thumbwidth; imObj['height'] = iminfo.thumbheight; } } - js_log('getImageObj: get: ' + size.width + ' got url:' + imObj.url); - callback( imObj ); - }); + js_log( 'getImageObj: get: ' + size.width + ' got url:' + imObj.url ); + callback( imObj ); + } ); }, - //the insert image function - insertImage:function( cEdit ){ - if(!cEdit) - var cEdit = _this.cEdit; + // the insert image function + insertImage:function( cEdit ) { + if ( !cEdit ) + var cEdit = _this.cEdit; }, - getEmbedHTML: function( rObj , options) { - if(!options) - options = {}; - this.parent_getEmbedHTML( rObj, options); - //check for image output: - if( rObj.mime.indexOf('image') != -1 ){ - return this.getImageEmbedHTML( rObj, options ); + getEmbedHTML: function( rObj , options ) { + if ( !options ) + options = { }; + this.parent_getEmbedHTML( rObj, options ); + // check for image output: + if ( rObj.mime.indexOf( 'image' ) != - 1 ) { + return this.getImageEmbedHTML( rObj, options ); } - //for video and audio output: - var ahtml=''; - if( rObj.mime == 'application/ogg' || rObj.mime == 'audio/ogg' ){ - ahtml = options.id_attr + + // for video and audio output: + var ahtml = ''; + if ( rObj.mime == 'application/ogg' || rObj.mime == 'audio/ogg' ) { + ahtml = options.id_attr + ' src="' + rObj.src + '" ' + options.style_attr + - ' poster="'+ rObj.poster + '" ' - if(rObj.mime.indexOf('application/ogg')!=-1){ - return ''; + ' poster="' + rObj.poster + '" ' + if ( rObj.mime.indexOf( 'application/ogg' ) != - 1 ) { + return ''; } - if(rObj.mime.indexOf('audio/ogg')!=-1){ + if ( rObj.mime.indexOf( 'audio/ogg' ) != - 1 ) { return ''; } - } + } js_log( 'ERROR:unsupored mime type: ' + rObj.mime ); }, - getInlineDescWiki:function( rObj ){ + getInlineDescWiki:function( rObj ) { var desc = this.parent_getInlineDescWiki( rObj ); - //strip categories for inline Desc: (should strip license tags too but not as easy) - desc = desc.replace(/\[\[Category\:[^\]]*\]\]/, ''); + // strip categories for inline Desc: (should strip license tags too but not as easy) + desc = desc.replace( /\[\[Category\:[^\]]*\]\]/, '' ); - //just grab the description tag for inline desc: - var descMatch = new RegExp(/Description=(\{\{en\|)?([^|]*|)/); - var dparts = desc.match(descMatch); + // just grab the description tag for inline desc: + var descMatch = new RegExp( /Description=(\{\{en\|)?([^|]*|)/ ); + var dparts = desc.match( descMatch ); - if( dparts && dparts.length > 1){ - desc = (dparts.length == 2) ? dparts[1] : dparts[2].replace('}}',''); - desc = (desc.substr(0,2) == '1=') ?desc.substr(2): desc; - return desc; + if ( dparts && dparts.length > 1 ) { + desc = ( dparts.length == 2 ) ? dparts[1] : dparts[2].replace( '}}', '' ); + desc = ( desc.substr( 0, 2 ) == '1=' ) ? desc.substr( 2 ): desc; + return desc; } - //else return the title since we could not find the desc: - js_log('Error: No Description Tag, Using::' + desc ); + // else return the title since we could not find the desc: + js_log( 'Error: No Description Tag, Using::' + desc ); return desc; }, - //returns the inline wikitext for insertion (template based crops for now) - getEmbedWikiCode: function( rObj ){ - //set default layout to right justified - var layout = ( rObj.layout)? rObj.layout:"right" - //if crop is null do base output: - if( rObj.crop == null) - return this.parent_getEmbedWikiCode( rObj ); - //using the preview crop template: http://en.wikipedia.org/wiki/Template:Preview_Crop - //@@todo should be replaced with server side cropping + // returns the inline wikitext for insertion (template based crops for now) + getEmbedWikiCode: function( rObj ) { + // set default layout to right justified + var layout = ( rObj.layout ) ? rObj.layout:"right" + // if crop is null do base output: + if ( rObj.crop == null ) + return this.parent_getEmbedWikiCode( rObj ); + // using the preview crop template: http://en.wikipedia.org/wiki/Template:Preview_Crop + // @@todo should be replaced with server side cropping return '{{Preview Crop ' + "\n" + '|Image = ' + rObj.target_resource_title + "\n" + - '|bSize = ' + rObj.width + "\n" + + '|bSize = ' + rObj.width + "\n" + '|cWidth = ' + rObj.crop.w + "\n" + '|cHeight = ' + rObj.crop.h + "\n" + '|oTop = ' + rObj.crop.y + "\n" + diff --git a/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js index 221ace969c..9590a2e0db 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js @@ -1,202 +1,202 @@ /* * API modes (implementations should call these objects which inherit the mvBaseRemoteSearch */ -loadGM({ +loadGM( { "mwe-stream_title" : "$1 $2 to $3" -}); -var metavidSearch = function(iObj) { - return this.init(iObj); +} ); +var metavidSearch = function( iObj ) { + return this.init( iObj ); }; metavidSearch.prototype = { - reqObj:{ //set up the default request paramaters + reqObj: { // set up the default request paramaters 'order':'recent', 'feed_format':'rss' }, - init:function( iObj ){ - //init base class and inherit: + init:function( iObj ) { + // init base class and inherit: var baseSearch = new baseRemoteSearch( iObj ); - for(var i in baseSearch){ - if(typeof this[i] =='undefined'){ + for ( var i in baseSearch ) { + if ( typeof this[i] == 'undefined' ) { this[i] = baseSearch[i]; - }else{ - this['parent_'+i] = baseSearch[i]; + } else { + this['parent_' + i] = baseSearch[i]; } } }, - getSearchResults:function(){ - //call parent: + getSearchResults:function() { + // call parent: this.parent_getSearchResults(); - //set local ref: - var _this = this; - js_log('metavidSearch::getSearchResults()'); - //proccess all options + // set local ref: + var _this = this; + js_log( 'metavidSearch::getSearchResults()' ); + // proccess all options var url = this.cp.api_url; - //add on the req_param - for(var i in this.reqObj){ + // add on the req_param + for ( var i in this.reqObj ) { url += '&' + i + '=' + this.reqObj[i]; } - url += '&f[0][t]=match&f[0][v]=' + $j('#rsd_q').val(); - //add offset limit: - url+='&limit=' + this.cp.limit; - url+='&offset=' + this.cp.offset; + url += '&f[0][t]=match&f[0][v]=' + $j( '#rsd_q' ).val(); + // add offset limit: + url += '&limit=' + this.cp.limit; + url += '&offset=' + this.cp.offset; - do_request(url, function(data){ + do_request( url, function( data ) { - js_log('mvSearch: got data response'); - //should have an xml rss data object: + js_log( 'mvSearch: got data response' ); + // should have an xml rss data object: _this.addRSSData( data , url ); - //do some metavid specific pos processing on the rObj data: - for(var i in _this.resultsObj){ + // do some metavid specific pos processing on the rObj data: + for ( var i in _this.resultsObj ) { var rObj = _this.resultsObj[i]; var proe = parseUri( rObj['roe_url'] ); - rObj['start_time'] = proe.queryKey['t'].split('/')[0]; - rObj['end_time'] = proe.queryKey['t'].split('/')[1]; + rObj['start_time'] = proe.queryKey['t'].split( '/' )[0]; + rObj['end_time'] = proe.queryKey['t'].split( '/' )[1]; rObj['stream_name'] = proe.queryKey['stream_name']; - //all metavid content is public domain: + // all metavid content is public domain: rObj['license'] = _this.rsd.getLicenceFromKey( 'pd' ); - //transform the title into a wiki_safe title: - //rObj['titleKey'] = proe.queryKey['stream_name'] + '_' + rObj['start_time'].replace(/:/g,'.') + '_' + rObj['end_time'].replace(/:/g,'.') + '.ogg'; + // transform the title into a wiki_safe title: + // rObj['titleKey'] = proe.queryKey['stream_name'] + '_' + rObj['start_time'].replace(/:/g,'.') + '_' + rObj['end_time'].replace(/:/g,'.') + '.ogg'; rObj['titleKey'] = _this.getTitleKey( rObj ); - //default width of metavid clips: - rObj['target_width'] = 400; + // default width of metavid clips: + rObj['target_width'] = 400; } - //done loading: - _this.loading=0; - }); + // done loading: + _this.loading = 0; + } ); }, - getTitleKey:function( rObj ){ - return rObj['stream_name'] + '_part_' + rObj['start_time'].replace(/:/g,'.') + '_to_' + rObj['end_time'].replace(/:/g,'.') + '.ogv'; + getTitleKey:function( rObj ) { + return rObj['stream_name'] + '_part_' + rObj['start_time'].replace( / : / g, '.' ) + '_to_' + rObj['end_time'].replace( / : / g, '.' ) + '.ogv'; }, - getTitle:function( rObj ){ - var sn = rObj['stream_name'].replace(/_/g, ' '); - sn = sn.charAt(0).toUpperCase() + sn.substr(1); - return gM('mwe-stream_title', [ sn, rObj.start_time, rObj.end_time ]); + getTitle:function( rObj ) { + var sn = rObj['stream_name'].replace( / _ / g, ' ' ); + sn = sn.charAt( 0 ).toUpperCase() + sn.substr( 1 ); + return gM( 'mwe-stream_title', [ sn, rObj.start_time, rObj.end_time ] ); }, - //metavid descption tied to public domain license key (government produced content) - getPermissionWikiTag:function( rObj ){ + // metavid descption tied to public domain license key (government produced content) + getPermissionWikiTag:function( rObj ) { return '{{PD-USGov}}'; }, - getExtraResourceDescWiki:function( rObj ){ + getExtraResourceDescWiki:function( rObj ) { var o = "\n"; - //check for person - if( rObj.person && rObj.person['label']) + // check for person + if ( rObj.person && rObj.person['label'] ) o += '* featuring [[' + rObj.person['label'] + ']]' + "\n"; - if( rObj.parent_clip ) - o += '* part of longer [' + rObj.parent_clip + ' video clip]'+ "\n"; + if ( rObj.parent_clip ) + o += '* part of longer [' + rObj.parent_clip + ' video clip]' + "\n"; - if( rObj.person && rObj.person['url'] && rObj.person['label'] ) - o += '* also see speeches by [' + $j.trim( rObj.person.url ) + ' ' + rObj.person['label'] + ']'+ "\n"; + if ( rObj.person && rObj.person['url'] && rObj.person['label'] ) + o += '* also see speeches by [' + $j.trim( rObj.person.url ) + ' ' + rObj.person['label'] + ']' + "\n"; - //check for bill: - if( rObj.bill && rObj.bill['label'] && rObj.bill['url']) - o += '* related to bill: [[' + rObj.bill['label'] + ']] more bill [' + rObj.bill['url'] + ' video clips]'+ "\n"; + // check for bill: + if ( rObj.bill && rObj.bill['label'] && rObj.bill['url'] ) + o += '* related to bill: [[' + rObj.bill['label'] + ']] more bill [' + rObj.bill['url'] + ' video clips]' + "\n"; return o; }, - //format is "quote" followed by [[name of person]] - getInlineDescWiki:function( rObj ){ + // format is "quote" followed by [[name of person]] + getInlineDescWiki:function( rObj ) { var o = this.parent_getInlineDescWiki( rObj ); - //add in person if found - if( rObj.person && rObj.person['label'] ){ - o = $j.trim( o.replace(rObj.person['label'], '') ); - //trim leading : - if(o.substr(0,1)==':') - o = o.substr(1); - //add quotes and person at the end: + // add in person if found + if ( rObj.person && rObj.person['label'] ) { + o = $j.trim( o.replace( rObj.person['label'], '' ) ); + // trim leading : + if ( o.substr( 0, 1 ) == ':' ) + o = o.substr( 1 ); + // add quotes and person at the end: var d = this.getDateFromLink( rObj.link ); - o ='"' + o + '" [[' + rObj.person['label'] + ']] on ' + d.toDateString(); + o = '"' + o + '" [[' + rObj.person['label'] + ']] on ' + d.toDateString(); } - //could do ref or direct link: + // could do ref or direct link: o += ' \'\'[' + $j.trim( rObj.link ) + ' source clip]\'\' '; - //var o= '"' + o + '" by [[' + rObj.person['label'] + ']] '+ + // var o= '"' + o + '" by [[' + rObj.person['label'] + ']] '+ // '[' + rObj.link + ' Metavid Source Page] for ' + rObj.title +''; return o; }, - //give an updated start and end time updates the title and url - applyVideoAdj: function( rObj ){ - js_log('mv ApplyVideoAdj::'); - //update the titleKey: + // give an updated start and end time updates the title and url + applyVideoAdj: function( rObj ) { + js_log( 'mv ApplyVideoAdj::' ); + // update the titleKey: rObj['titleKey'] = this.getTitleKey( rObj ); - //update the title: + // update the title: rObj['title'] = this.getTitle( rObj ); - //update the interface: - js_log('update title to: ' + rObj['title']); - $j('#rsd_resource_title').html( gM('rsd_resource_edit', rObj['title'] ) ); + // update the interface: + js_log( 'update title to: ' + rObj['title'] ); + $j( '#rsd_resource_title' ).html( gM( 'rsd_resource_edit', rObj['title'] ) ); - //if the video is "roe" based select the ogg stream - if( rObj.roe_url && rObj.pSobj.cp.stream_import_key){ - var source = $j('#embed_vid').get(0).media_element.getSourceById( rObj.pSobj.cp.stream_import_key ); - if(!source){ - js_error('Error::could not find source: ' + rObj.pSobj.cp.stream_import_key); - }else{ + // if the video is "roe" based select the ogg stream + if ( rObj.roe_url && rObj.pSobj.cp.stream_import_key ) { + var source = $j( '#embed_vid' ).get( 0 ).media_element.getSourceById( rObj.pSobj.cp.stream_import_key ); + if ( !source ) { + js_error( 'Error::could not find source: ' + rObj.pSobj.cp.stream_import_key ); + } else { rObj['src'] = source.getURI(); - js_log("g src_key: " + rObj.pSobj.cp.stream_import_key + ' src:' + rObj['src']) ; + js_log( "g src_key: " + rObj.pSobj.cp.stream_import_key + ' src:' + rObj['src'] ) ; return true; } } }, - getEmbedHTML:function( rObj , options ){ - if(!options) - options={}; - var id_attr = (options['id'])?' id = "' + options['id'] +'" ': ''; - var style_attr = (options['max_width'])?' style="width:'+options['max_width']+'px;"':''; - //@@maybe check type here ? - if(options['only_poster']){ - return ''; - }else{ + getEmbedHTML:function( rObj , options ) { + if ( !options ) + options = { }; + var id_attr = ( options['id'] ) ? ' id = "' + options['id'] + '" ': ''; + var style_attr = ( options['max_width'] ) ? ' style="width:' + options['max_width'] + 'px;"':''; + // @@maybe check type here ? + if ( options['only_poster'] ) { + return ''; + } else { return ''; } }, - getImageTransform:function( rObj, opt ){ - if( opt.width <= 80 ){ + getImageTransform:function( rObj, opt ) { + if ( opt.width <= 80 ) { return getURLParamReplace( rObj.poster, { 'size' : "icon" } ) - }else if( opt.width <= 160 ){ + } else if ( opt.width <= 160 ) { return getURLParamReplace( rObj.poster, { 'size' : "small" } ) - }else if( opt.width <= 320 ){ + } else if ( opt.width <= 320 ) { return getURLParamReplace( rObj.poster, { 'size' : 'medium' } ) - }else if( opt.width <= 512 ){ + } else if ( opt.width <= 512 ) { return getURLParamReplace( rObj.poster, { 'size' : 'large' } ) - }else{ + } else { return getURLParamReplace( rObj.poster, { 'size' : 'full' } ) } }, - getEmbedObjParsedInfo:function(rObj, eb_id){ - var sources = $j('#'+eb_id).get(0).media_element.getSources(); - rObj.other_versions ='*[' + rObj['roe_url'] + ' XML of all Video Formats and Timed Text]'+"\n"; - for(var i in sources){ + getEmbedObjParsedInfo:function( rObj, eb_id ) { + var sources = $j( '#' + eb_id ).get( 0 ).media_element.getSources(); + rObj.other_versions = '*[' + rObj['roe_url'] + ' XML of all Video Formats and Timed Text]' + "\n"; + for ( var i in sources ) { var cur_source = sources[i]; - //rObj.other_versions += '*['+cur_source.getURI() +' ' + cur_source.title +']' + "\n"; - if( cur_source.id == this.cp.target_source_id) + // rObj.other_versions += '*['+cur_source.getURI() +' ' + cur_source.title +']' + "\n"; + if ( cur_source.id == this.cp.target_source_id ) rObj['url'] = cur_source.getURI(); } - //js_log('set url to: ' + rObj['url']); + // js_log('set url to: ' + rObj['url']); return rObj; }, - //update rObj for import: - updateDataForImport:function( rObj ){ - rObj['author']='US Government'; - //convert data to UTC type date: + // update rObj for import: + updateDataForImport:function( rObj ) { + rObj['author'] = 'US Government'; + // convert data to UTC type date: var d = this.getDateFromLink( rObj.link ); rObj['date'] = d.toDateString(); - rObj['license_template_tag']='PD-USGov'; - //update based on new start time: - js_log('url is: ' + rObj.src + ' ns: ' + rObj.start_time + ' ne:' + rObj.end_time); + rObj['license_template_tag'] = 'PD-USGov'; + // update based on new start time: + js_log( 'url is: ' + rObj.src + ' ns: ' + rObj.start_time + ' ne:' + rObj.end_time ); return rObj; }, - getDateFromLink:function( link ){ - var dateExp = new RegExp(/_([0-9]+)\-([0-9]+)\-([0-9]+)/); - var dParts = link.match (dateExp); + getDateFromLink:function( link ) { + var dateExp = new RegExp( /_([0-9]+)\-([0-9]+)\-([0-9]+)/ ); + var dParts = link.match ( dateExp ); var d = new Date(); - var year_full = (dParts[3].length==2)?'20'+dParts[3].toString():dParts[3]; - d.setFullYear(year_full, dParts[1]-1, dParts[2]); + var year_full = ( dParts[3].length == 2 ) ? '20' + dParts[3].toString():dParts[3]; + d.setFullYear( year_full, dParts[1] - 1, dParts[2] ); return d; } } diff --git a/js2/mwEmbed/libAddMedia/simpleUploadForm.js b/js2/mwEmbed/libAddMedia/simpleUploadForm.js index 53b99993a8..bb442f63ed 100644 --- a/js2/mwEmbed/libAddMedia/simpleUploadForm.js +++ b/js2/mwEmbed/libAddMedia/simpleUploadForm.js @@ -4,7 +4,7 @@ * */ -loadGM({ +loadGM( { "mwe-select_file" : "Select file", "mwe-more_licence_options" : "For more licence options, view the normal upload page<\/a>", "mwe-select_ownwork" : "I am uploading entirely my own work, and licencing it under:", @@ -15,7 +15,7 @@ loadGM({ "mwe-error_not_loggedin" : "You do not appear to be logged in or do not have upload privileges.", "mwe-watch-this-file" : "Watch this file", "mwe-ignore-any-warnings" : "Ignore any warnings" -}); +} ); var default_form_options = { 'enable_fogg' : true, @@ -24,127 +24,127 @@ var default_form_options = { 'ondone_cb' : null }; -(function($) { - $.fn.simpleUploadForm = function( opt , callback){ +( function( $ ) { + $.fn.simpleUploadForm = function( opt , callback ) { var _this = this; - //set the options: - for(var i in default_form_options){ - if(!opt[i]) + // set the options: + for ( var i in default_form_options ) { + if ( !opt[i] ) opt[i] = default_form_options[i]; } - //first do a reality check on the options: - if( !opt.api_target ){ - $(this.selector).html('Error: Missing api target'); + // first do a reality check on the options: + if ( !opt.api_target ) { + $( this.selector ).html( 'Error: Missing api target' ); return false; } - //@@todo this is just a proof of concept - //much todo to improved this web form - get_mw_token('File:MyRandomFileTokenCheck', opt.api_target, function(eToken){ - if( !eToken || eToken == '+\\' ){ - $(this.selector).html( gM('mwe-error_not_loggedin') ); + // @@todo this is just a proof of concept + // much todo to improved this web form + get_mw_token( 'File:MyRandomFileTokenCheck', opt.api_target, function( eToken ) { + if ( !eToken || eToken == '+\\' ) { + $( this.selector ).html( gM( 'mwe-error_not_loggedin' ) ); return false; } - //build an upload form: - var o = '
'+ + // build an upload form: + var o = '
' + '
' + - //hidden input: - ''+ - ''+ - '' + + // hidden input: + '' + + '' + + '' + - //form name set: - '
'+ + // form name set: + '
' + '
' + - '
'+ - '
'+ + '
' + + '
' + - '
' + - '
'; - //js_log('getInsertDescHtml: ' + o ); + o += '
'; + // js_log('getInsertDescHtml: ' + o ); return o; }, - updateInsertControlActions:function(){ + updateInsertControlActions:function() { var _this = this; var b_target = _this.p_rsdObj.target_container + '~ .ui-dialog-buttonpane'; - //empty the ui-dialog-buttonpane bar: - $j(b_target).empty(); - for( var cbType in _this.controlActionsCb ){ - switch(cbType){ + // empty the ui-dialog-buttonpane bar: + $j( b_target ).empty(); + for ( var cbType in _this.controlActionsCb ) { + switch( cbType ) { case 'insert_seq': - $j(b_target).append( $j.btnHtml(gM('mwe-insert_into_sequence'), 'mv_insert_sequence', 'check' ) + ' ' ) - .children('.mv_insert_sequence') + $j( b_target ).append( $j.btnHtml( gM( 'mwe-insert_into_sequence' ), 'mv_insert_sequence', 'check' ) + ' ' ) + .children( '.mv_insert_sequence' ) .btnBind() - .click(function(){ + .click( function() { _this.applyEdit(); _this.controlActionsCb['insert_seq']( _this.rObj ); - }); + } ); break; case 'insert': - $j(b_target).append( $j.btnHtml(gM('mwe-insert_image_page'), 'mv_insert_image_page', 'check' ) + ' ' ) - .children('.mv_insert_image_page') + $j( b_target ).append( $j.btnHtml( gM( 'mwe-insert_image_page' ), 'mv_insert_image_page', 'check' ) + ' ' ) + .children( '.mv_insert_image_page' ) .btnBind() - .click(function(){ + .click( function() { _this.applyEdit(); _this.controlActionsCb['insert']( _this.rObj ); - }).show('slow'); + } ).show( 'slow' ); break; case 'preview': - $j(b_target).append( $j.btnHtml( gM('mwe-preview_insert'), 'mv_preview_insert', 'refresh') + ' ' ) - .children('.mv_preview_insert') + $j( b_target ).append( $j.btnHtml( gM( 'mwe-preview_insert' ), 'mv_preview_insert', 'refresh' ) + ' ' ) + .children( '.mv_preview_insert' ) .btnBind() - .click(function(){ + .click( function() { _this.applyEdit(); _this.controlActionsCb['preview']( _this.rObj ); - }).show('slow'); + } ).show( 'slow' ); break; case 'cancel': - $j(b_target).append( $j.btnHtml( gM('mwe-cancel_image_insert'), 'mv_cancel_img_edit', 'close') + ' ') - .children('.mv_cancel_img_edit') + $j( b_target ).append( $j.btnHtml( gM( 'mwe-cancel_image_insert' ), 'mv_cancel_img_edit', 'close' ) + ' ' ) + .children( '.mv_cancel_img_edit' ) .btnBind() - .click(function(){ - //no cancel action; + .click( function() { + // no cancel action; _this.controlActionsCb['cancel']( _this.rObj ); - }).show('slow'); + } ).show( 'slow' ); break; } } }, - applyEdit:function(){ + applyEdit:function() { var _this = this; - js_log('applyEdit::' + this.media_type); - if(this.media_type == 'image'){ + js_log( 'applyEdit::' + this.media_type ); + if ( this.media_type == 'image' ) { this.applyCrop(); - }else if(this.media_type == 'video'){ + } else if ( this.media_type == 'video' ) { this.applyVideoAdj(); } - //copy over the desc text to the resource object - _this.rObj['inlineDesc']= $j('#mv_inline_img_desc').val(); + // copy over the desc text to the resource object + _this.rObj['inlineDesc'] = $j( '#mv_inline_img_desc' ).val(); }, - appendTool: function( $target, tool_id ){ + appendTool: function( $target, tool_id ) { var _this = this; - switch(tool_id){ - case 'layout': - $target.append( ''+ + switch( tool_id ) { + case 'layout': + $target.append( '' + 'Layout:' + - '
'+ - '
'+ - '

' + '
' + + '
' + + '

' ); - //make sure the default is reflected: - if( ! _this.rObj.layout ) + // make sure the default is reflected: + if ( ! _this.rObj.layout ) _this.rObj.layout = 'right'; - $j('#mv_layout_' + _this.rObj.layout)[0].checked = true; + $j( '#mv_layout_' + _this.rObj.layout )[0].checked = true; - //left radio click - $j('#mv_layout_left,#mv_layout_left_img').click(function(){ - $j('#mv_layout_right')[0].checked = false; - $j('#mv_layout_left')[0].checked = true; + // left radio click + $j( '#mv_layout_left,#mv_layout_left_img' ).click( function() { + $j( '#mv_layout_right' )[0].checked = false; + $j( '#mv_layout_left' )[0].checked = true; _this.rObj.layout = 'left'; - }); - //right radio click - $j('#mv_layout_right,#mv_layout_right_img').click(function(){ - $j('#mv_layout_left')[0].checked = false; - $j('#mv_layout_right')[0].checked = true; + } ); + // right radio click + $j( '#mv_layout_right,#mv_layout_right_img' ).click( function() { + $j( '#mv_layout_left' )[0].checked = false; + $j( '#mv_layout_right' )[0].checked = true; _this.rObj.layout = 'right'; - }); + } ); break; - case 'crop': - $target.append( ''+ - '
'+ - '' + gM('mwe-crop') + ' '+ - ' '+ - ' '+ - ' '+ + case 'crop': + $target.append( '' + + '
' + + '' + gM( 'mwe-crop' ) + ' ' + + ' ' + + ' ' + + ' ' + '

' ); - //add binding: - $j('#mv_crop_button,.mv_crop_msg,.mv_apply_crop').click(function(){ - js_log('click:mv_crop_button: base width: ' + _this.rObj.width + ' bh: ' + _this.rObj.height); - if($j('#mv_crop_button').hasClass('mv_crop_button_selected')){ + // add binding: + $j( '#mv_crop_button,.mv_crop_msg,.mv_apply_crop' ).click( function() { + js_log( 'click:mv_crop_button: base width: ' + _this.rObj.width + ' bh: ' + _this.rObj.height ); + if ( $j( '#mv_crop_button' ).hasClass( 'mv_crop_button_selected' ) ) { _this.applyCrop(); - }else{ - js_log('click:turn on'); + } else { + js_log( 'click:turn on' ); _this.enableCrop(); } - }); - $j('.mv_reset_crop').click(function(){ - $j('.mv_apply_crop,.mv_reset_crop').hide(); - $j('.mv_crop_msg').show(); - $j('#mv_crop_button').removeClass('mv_crop_button_selected').addClass('mv_crop_button_base').attr('title',gM('mwe-crop')); - _this.rObj.crop=null; - $j('#' + _this.clip_disp_ct ).empty().html( + } ); + $j( '.mv_reset_crop' ).click( function() { + $j( '.mv_apply_crop,.mv_reset_crop' ).hide(); + $j( '.mv_crop_msg' ).show(); + $j( '#mv_crop_button' ).removeClass( 'mv_crop_button_selected' ).addClass( 'mv_crop_button_base' ).attr( 'title', gM( 'mwe-crop' ) ); + _this.rObj.crop = null; + $j( '#' + _this.clip_disp_ct ).empty().html( '' ); - }); + } ); break; case 'scale': /*scale: @@ -594,187 +594,187 @@ mvClipEdit.prototype = { break; } }, - setUpImageCtrl:function(){ + setUpImageCtrl:function() { var _this = this; - var $tool_target = $j('#'+this.control_ct); - //by default apply Crop tool - if( _this.enabled_tools == 'all' || _this.enabled_tools.length > 0){ - $tool_target.append( '

'+ gM('mwe-edit-tools') +'

' ); - for( var i in _this.toolset ){ + var $tool_target = $j( '#' + this.control_ct ); + // by default apply Crop tool + if ( _this.enabled_tools == 'all' || _this.enabled_tools.length > 0 ) { + $tool_target.append( '

' + gM( 'mwe-edit-tools' ) + '

' ); + for ( var i in _this.toolset ) { var toolid = _this.toolset[i]; - if( $j.inArray( toolid, _this.enabled_tools) != -1 || _this.enabled_tools=='all') + if ( $j.inArray( toolid, _this.enabled_tools ) != - 1 || _this.enabled_tools == 'all' ) _this.appendTool( $tool_target, toolid ); } } - //add the insert description text field: + // add the insert description text field: $tool_target.append( _this.getInsertDescHtml() ); - //add the actions to the 'button bar' + // add the actions to the 'button bar' _this.updateInsertControlActions(); }, - applyVideoAdj:function(){ - js_log('applyVideoAdj::'); - $tp = $j('#'+this.control_ct ); + applyVideoAdj:function() { + js_log( 'applyVideoAdj::' ); + $tp = $j( '#' + this.control_ct ); - //be sure to "stop the video (some plugins can't have DOM elements on top of them) - $j('#embed_vid').get(0).stop(); + // be sure to "stop the video (some plugins can't have DOM elements on top of them) + $j( '#embed_vid' ).get( 0 ).stop(); - //update video related keys - this.rObj['start_time'] = $tp.find('.startInOut').val(); - this.rObj['end_time'] = $tp.find('.endInOut').val() ; + // update video related keys + this.rObj['start_time'] = $tp.find( '.startInOut' ).val(); + this.rObj['end_time'] = $tp.find( '.endInOut' ).val() ; - //do the local video adjust - if(typeof this.rObj.pSobj['applyVideoAdj'] != 'undefined'){ + // do the local video adjust + if ( typeof this.rObj.pSobj['applyVideoAdj'] != 'undefined' ) { this.rObj.pSobj.applyVideoAdj( this.rObj ); } }, - applyCrop:function(){ + applyCrop:function() { var _this = this; - $j('.mv_apply_crop').hide(); - $j('.mv_crop_msg').show(); - $j('#mv_crop_button').removeClass('mv_crop_button_selected').addClass('mv_crop_button_base').attr('title',gM('mwe-crop')); + $j( '.mv_apply_crop' ).hide(); + $j( '.mv_crop_msg' ).show(); + $j( '#mv_crop_button' ).removeClass( 'mv_crop_button_selected' ).addClass( 'mv_crop_button_base' ).attr( 'title', gM( 'mwe-crop' ) ); js_log( 'click:turn off' ); var cat = _this.rObj; - if(_this.rObj.crop){ - //empty out and display cropped: - $j('#'+_this.clip_disp_ct ).empty().html( - '
'+ - '
'+ - ''+ - '
'+ + if ( _this.rObj.crop ) { + // empty out and display cropped: + $j( '#' + _this.clip_disp_ct ).empty().html( + '
' + + '
' + + '' + + '
' + '
' ); } return true; }, - //right now enableCrop loads "just in time" - //@@todo we really need an "auto loader" type system. - enableCrop:function(){ + // right now enableCrop loads "just in time" + // @@todo we really need an "auto loader" type system. + enableCrop:function() { var _this = this; - $j('.mv_crop_msg').hide(); - $j('.mv_crop_msg_load').show(); - var doEnableCrop = function(){ - $j('.mv_crop_msg_load').hide(); - $j('.mv_reset_crop,.mv_apply_crop').show(); - $j('#mv_crop_button').removeClass('mv_crop_button_base').addClass('mv_crop_button_selected').attr('title',gM('mwe-crop_done')); - $j('#' + _this.clip_disp_ct + ' img').Jcrop({ - onSelect: function(c){ - js_log('on select:' + c.x +','+ c.y+','+ c.x2+','+ c.y2+','+ c.w+','+ c.h); + $j( '.mv_crop_msg' ).hide(); + $j( '.mv_crop_msg_load' ).show(); + var doEnableCrop = function() { + $j( '.mv_crop_msg_load' ).hide(); + $j( '.mv_reset_crop,.mv_apply_crop' ).show(); + $j( '#mv_crop_button' ).removeClass( 'mv_crop_button_base' ).addClass( 'mv_crop_button_selected' ).attr( 'title', gM( 'mwe-crop_done' ) ); + $j( '#' + _this.clip_disp_ct + ' img' ).Jcrop( { + onSelect: function( c ) { + js_log( 'on select:' + c.x + ',' + c.y + ',' + c.x2 + ',' + c.y2 + ',' + c.w + ',' + c.h ); _this.rObj.crop = c; }, - onChange: function(c){ + onChange: function( c ) { } - }); - //temporary hack (@@todo need to debug why rsd_res_item gets moved ) - $j('#clip_edit_disp .rsd_res_item').css({ + } ); + // temporary hack (@@todo need to debug why rsd_res_item gets moved ) + $j( '#clip_edit_disp .rsd_res_item' ).css( { 'top':'0px', 'left':'0px' - }); + } ); } - //load the jcrop library if needed: - mvJsLoader.doLoad([ + // load the jcrop library if needed: + mvJsLoader.doLoad( [ '$j.Jcrop' - ],function(){ + ], function() { doEnableCrop(); - }); + } ); } } // mv_lock_vid_updates defined in mv_stream.js (we need to do some more refactoring ) -if(typeof mv_lock_vid_updates == 'undefined') - mv_lock_vid_updates= false; +if ( typeof mv_lock_vid_updates == 'undefined' ) + mv_lock_vid_updates = false; -function add_adjust_hooks(mvd_id, adj_callback){ +function add_adjust_hooks( mvd_id, adj_callback ) { - var start_sec = npt2seconds($j('#mv_start_hr_' + mvd_id).val() ); - var end_sec = npt2seconds($j('#mv_end_hr_' + mvd_id).val() ); + var start_sec = npt2seconds( $j( '#mv_start_hr_' + mvd_id ).val() ); + var end_sec = npt2seconds( $j( '#mv_end_hr_' + mvd_id ).val() ); - //if we don't have 0 as start then assume we are in a range request and give some buffer area: - var min_slider = (start_sec - 60 < 0 ) ? 0 : start_sec - 60; - if(min_slider!=0){ - var max_slider = end_sec+60; - }else{ + // if we don't have 0 as start then assume we are in a range request and give some buffer area: + var min_slider = ( start_sec - 60 < 0 ) ? 0 : start_sec - 60; + if ( min_slider != 0 ) { + var max_slider = end_sec + 60; + } else { max_slider = end_sec; } - //pre-destroy just in case: - $j('#mvd_form_' + mvd_id + ' .inOutSlider').slider( 'destroy' ).slider({ + // pre-destroy just in case: + $j( '#mvd_form_' + mvd_id + ' .inOutSlider' ).slider( 'destroy' ).slider( { range: true, min: min_slider, max: max_slider, values: [start_sec, end_sec], - slide: function(event, ui) { - js_log(" vals:"+ seconds2npt( ui.values[0] ) + ' : ' + seconds2npt( ui.values[1]) ); - $j('#mv_start_hr_' + mvd_id).val( seconds2npt( ui.values[0] ) ); - $j('#mv_end_hr_' + mvd_id).val( seconds2npt( ui.values[1] ) ); + slide: function( event, ui ) { + js_log( " vals:" + seconds2npt( ui.values[0] ) + ' : ' + seconds2npt( ui.values[1] ) ); + $j( '#mv_start_hr_' + mvd_id ).val( seconds2npt( ui.values[0] ) ); + $j( '#mv_end_hr_' + mvd_id ).val( seconds2npt( ui.values[1] ) ); }, - change:function(event, ui){ - do_video_time_update( seconds2npt( ui.values[0]), seconds2npt( ui.values[1] ) ); + change:function( event, ui ) { + do_video_time_update( seconds2npt( ui.values[0] ), seconds2npt( ui.values[1] ) ); } - }); - $j('.mv_adj_hr').change(function(){ - //preserve track duration for nav and seq: - //ie seems to crash so no interface updates for IE for the time being - if(!$j.browser.msie){ - if(mvd_id=='nav'||mvd_id=='seq'){ - add_adjust_hooks(mvd_id); // (no adj_callback) - }else{ - add_adjust_hooks(mvd_id) + } ); + $j( '.mv_adj_hr' ).change( function() { + // preserve track duration for nav and seq: + // ie seems to crash so no interface updates for IE for the time being + if ( !$j.browser.msie ) { + if ( mvd_id == 'nav' || mvd_id == 'seq' ) { + add_adjust_hooks( mvd_id ); // (no adj_callback) + } else { + add_adjust_hooks( mvd_id ) } } - //update the video time for onChange - do_video_time_update( $j('#mv_start_hr_'+mvd_id).val(), $j('#mv_end_hr_'+mvd_id).val() ); - }); + // update the video time for onChange + do_video_time_update( $j( '#mv_start_hr_' + mvd_id ).val(), $j( '#mv_end_hr_' + mvd_id ).val() ); + } ); } -function do_video_time_update(start_time, end_time, mvd_id) { - js_log('do_video_time_update: ' +start_time +' '+ end_time); - if( mv_lock_vid_updates == false ){ - //update the vid title: - $j('#mv_videoPlayerTime').html( start_time + ' to ' + end_time ); - var ebvid = $j('#embed_vid').get(0); - if( ebvid ){ - if(ebvid.isPaused()) +function do_video_time_update( start_time, end_time, mvd_id ) { + js_log( 'do_video_time_update: ' + start_time + ' ' + end_time ); + if ( mv_lock_vid_updates == false ) { + // update the vid title: + $j( '#mv_videoPlayerTime' ).html( start_time + ' to ' + end_time ); + var ebvid = $j( '#embed_vid' ).get( 0 ); + if ( ebvid ) { + if ( ebvid.isPaused() ) ebvid.stop(); - ebvid.updateVideoTime(start_time, end_time); - js_log('update thumb: '+ start_time); + ebvid.updateVideoTime( start_time, end_time ); + js_log( 'update thumb: ' + start_time ); ebvid.updateThumbTimeNTP( start_time ); } } } -//some custom jquery bindings: -(function( $ ) { - $.fn.upDownTimeInputBind = function( inputCB ){ - $( this.selector ).unbind('focus').focus(function(){ +// some custom jquery bindings: +( function( $ ) { + $.fn.upDownTimeInputBind = function( inputCB ) { + $( this.selector ).unbind( 'focus' ).focus( function() { var doDelayCall = true; - $(this).addClass('ui-state-focus'); - //bind up down keys - $(this).unbind('keydown').keydown(function (e) { - var sec = npt2seconds( $j(this).val() ); - var k = e.which; - if(k == 38 ){//up - $(this).val( seconds2npt( sec + 1 ) ); - }else if( k == 40 ){ //down - var sval = ( (sec - 1) < 0 ) ? 0 : (sec - 1) - $(this).val( seconds2npt( sval ) ); - } - //set the delay updates: - if(k == 38 || k == 40){ + $( this ).addClass( 'ui-state-focus' ); + // bind up down keys + $( this ).unbind( 'keydown' ).keydown( function ( e ) { + var sec = npt2seconds( $j( this ).val() ); + var k = e.which; + if ( k == 38 ) {// up + $( this ).val( seconds2npt( sec + 1 ) ); + } else if ( k == 40 ) { // down + var sval = ( ( sec - 1 ) < 0 ) ? 0 : ( sec - 1 ) + $( this ).val( seconds2npt( sval ) ); + } + // set the delay updates: + if ( k == 38 || k == 40 ) { var _inputElm = this; - if(doDelayCall){ - setTimeout(function(){ + if ( doDelayCall ) { + setTimeout( function() { inputCB( _inputElm ); doDelayCall = true; - },500); + }, 500 ); doDelayCall = false; - } - } - }); - }).unbind('blur').blur(function(){ - $(this).removeClass('ui-state-focus'); - }); + } + } + } ); + } ).unbind( 'blur' ).blur( function() { + $( this ).removeClass( 'ui-state-focus' ); + } ); } -})(jQuery); +} )( jQuery ); diff --git a/js2/mwEmbed/libEmbedVideo/embedVideo.js b/js2/mwEmbed/libEmbedVideo/embedVideo.js index f9bc4071a8..b42a5423ab 100644 --- a/js2/mwEmbed/libEmbedVideo/embedVideo.js +++ b/js2/mwEmbed/libEmbedVideo/embedVideo.js @@ -2,7 +2,7 @@ * for supported attribute details see README */ -loadGM({ +loadGM( { "mwe-loading_plugin" : "loading plugin ...", "mwe-select_playback" : "Set playback preference", "mwe-link_back" : "Link back", @@ -52,7 +52,7 @@ loadGM({ "mwe-related_videos" : "Related videos", "mwe-seeking" : "seeking", "mwe-copy-code" : "Copy code" -}); +} ); var default_video_attributes = { "id" : null, @@ -63,7 +63,7 @@ var default_video_attributes = { "width" : "320", "height" : "240", - //video attributes: + // video attributes: "src" : null, "autoplay" : false, "start" : 0, @@ -72,40 +72,40 @@ var default_video_attributes = { "muted" : false, "wikiTitleKey" : null, - //roe url (for xml based metadata) + // roe url (for xml based metadata) "roe" : null, - //if roe includes metadata tracks we can expose a link to metadata + // if roe includes metadata tracks we can expose a link to metadata "show_meta_link" : true, - //default state attributes per html5 spec: - //http://www.whatwg.org/specs/web-apps/current-work/#video) + // default state attributes per html5 spec: + // http://www.whatwg.org/specs/web-apps/current-work/#video) "paused" : true, - "readyState" : 0, //http://www.whatwg.org/specs/web-apps/current-work/#readystate - "currentTime" :0, //current playback position (should be updated by plugin) - "duration" :null, //media duration (read from file or the temporal url) + "readyState" : 0, // http://www.whatwg.org/specs/web-apps/current-work/#readystate + "currentTime" :0, // current playback position (should be updated by plugin) + "duration" :null, // media duration (read from file or the temporal url) "networkState" : 0, - "startOffset" : null, //if serving an ogg_chop segment use this to offset the presentation time + "startOffset" : null, // if serving an ogg_chop segment use this to offset the presentation time - //custom attributes for mv_embed: - "play_button" : true, + // custom attributes for mv_embed: + "play_button" : true, "thumbnail" : null, "linkback" : null, "embed_link" : true, "download_link" : true, - "type" :null, //the content type of the media + "type" :null, // the content type of the media }; /* * the base source attribute checks */ -var mv_default_source_attr= new Array( +var mv_default_source_attr = new Array( 'id', 'src', 'apisrc', 'titleKey', 'title', - 'URLTimeEncoding', //boolean if we support temporal url requests on the source media - 'startOffset', + 'URLTimeEncoding', // boolean if we support temporal url requests on the source media + 'startOffset', 'durationHint', 'start', @@ -114,85 +114,85 @@ var mv_default_source_attr= new Array( 'default', 'lang' ); -//set the dismissNativeWarn flag: +// set the dismissNativeWarn flag: _global['dismissNativeWarn'] = false; /* * Converts all occurrences of
' ); + $j( '#img_thumb_' + this.id ).fadeOut( "fast" ); + $j( '#dc_' + _this.id + ' .related_vids ul' ).html( gM( 'mwe-loading_txt' ) ); this.relatedTitleKeySearch(); - }else{ + } else { this.onClipDoneDisp(); - } + } }, - onClipDoneDisp:function(){ + onClipDoneDisp:function() { var _this = this; - //add the liks_info_div black back - $j('#dc_'+this.id).append('
'+ - '
' + // add the liks_info_div black back + $j( '#dc_' + this.id ).append( '
' + + '
' ); - //start animation (make thumb small in upper left add in div for "loading" - $j('#img_thumb_'+this.id).animate({ - width : parseInt( parseInt(_this.width)/2 ), - height : parseInt( parseInt(_this.height)/2 ), + // start animation (make thumb small in upper left add in div for "loading" + $j( '#img_thumb_' + this.id ).animate( { + width : parseInt( parseInt( _this.width ) / 2 ), + height : parseInt( parseInt( _this.height ) / 2 ), top:20, left:10 }, - 1000, - function(){ - //animation done.. add "loading" to div if empty - if($j('#liks_info_'+_this.id).html()==''){ - $j('#liks_info_'+_this.id).html(gM('mwe-loading_txt')); - } + 1000, + function() { + // animation done.. add "loading" to div if empty + if ( $j( '#liks_info_' + _this.id ).html() == '' ) { + $j( '#liks_info_' + _this.id ).html( gM( 'mwe-loading_txt' ) ); + } } - ) - //now load roe if run the showNextPrevLinks - if(this.roe && this.media_element.addedROEData==false){ - do_request(this.roe, function(data) - { - _this.media_element.addROE(data); + ) + // now load roe if run the showNextPrevLinks + if ( this.roe && this.media_element.addedROEData == false ) { + do_request( this.roe, function( data ) + { + _this.media_element.addROE( data ); _this.getNextPrevLinks(); - }); - }else{ + } ); + } else { this.getNextPrevLinks(); - } + } }, - //@@todo we should merge getNextPrevLinks with textInterface .. there is repeated code between them. - getNextPrevLinks:function(){ - js_log('f:getNextPrevLinks'); + // @@todo we should merge getNextPrevLinks with textInterface .. there is repeated code between them. + getNextPrevLinks:function() { + js_log( 'f:getNextPrevLinks' ); var anno_track_url = null; - var _this = this; - //check for annoative track - $j.each(this.media_element.sources, function(inx, n){ - if(n.mime_type=='text/cmml'){ - if( n.id == 'Anno_en'){ + var _this = this; + // check for annoative track + $j.each( this.media_element.sources, function( inx, n ) { + if ( n.mime_type == 'text/cmml' ) { + if ( n.id == 'Anno_en' ) { anno_track_url = n.src; } } - }); + } ); - if(!anno_track_url){ - js_log('no annotative track url found'); - //$j('#liks_info_'+this.id).html('no metadata found for related links'); + if ( !anno_track_url ) { + js_log( 'no annotative track url found' ); + // $j('#liks_info_'+this.id).html('no metadata found for related links'); _this.doThumbnailHTML(); return ; } - js_log('we have annotative track:'+ anno_track_url); + js_log( 'we have annotative track:' + anno_track_url ); // Zero out seconds (should improve cache hit rate and generally expands metadata search) // @@todo this could be replaced with a regExp - var annoURL = parseUri(anno_track_url); - var times = annoURL.queryKey['t'].split('/'); - var stime_parts = times[0].split(':'); - var etime_parts = times[1].split(':'); - //zero out the hour: - var new_start = stime_parts[0]+':'+'0:0'; - //zero out the end sec - var new_end = (etime_parts[0]== stime_parts[0])? (etime_parts[0]+1)+':0:0' :etime_parts[0]+':0:0'; + var annoURL = parseUri( anno_track_url ); + var times = annoURL.queryKey['t'].split( '/' ); + var stime_parts = times[0].split( ':' ); + var etime_parts = times[1].split( ':' ); + // zero out the hour: + var new_start = stime_parts[0] + ':' + '0:0'; + // zero out the end sec + var new_end = ( etime_parts[0] == stime_parts[0] ) ? ( etime_parts[0] + 1 ) + ':0:0' :etime_parts[0] + ':0:0'; - var etime_parts = times[1].split(':'); + var etime_parts = times[1].split( ':' ); - var new_anno_track_url = annoURL.protocol +'://'+ annoURL.host + annoURL.path +'?'; - $j.each(annoURL.queryKey, function(i, val){ - new_anno_track_url +=(i=='t')?'t='+new_start+'/'+new_end +'&' : - i+'='+ val+'&'; - }); - var request_key = new_start+'/'+new_end; - //check the anno_data cache: - //@@todo search cache see if current is in range. - if(this.anno_data_cache){ - js_log('anno data found in cache: '+request_key); + var new_anno_track_url = annoURL.protocol + '://' + annoURL.host + annoURL.path + '?'; + $j.each( annoURL.queryKey, function( i, val ) { + new_anno_track_url += ( i == 't' ) ? 't=' + new_start + '/' + new_end + '&' : + i + '=' + val + '&'; + } ); + var request_key = new_start + '/' + new_end; + // check the anno_data cache: + // @@todo search cache see if current is in range. + if ( this.anno_data_cache ) { + js_log( 'anno data found in cache: ' + request_key ); this.showNextPrevLinks(); - }else{ - do_request(new_anno_track_url, function(cmml_data){ - js_log('raw response: '+ cmml_data); - if(typeof cmml_data == 'string'){ - var parser=new DOMParser(); - js_log('Parse CMML data:' + cmml_data); - cmml_data=parser.parseFromString(cmml_data,"text/xml"); + } else { + do_request( new_anno_track_url, function( cmml_data ) { + js_log( 'raw response: ' + cmml_data ); + if ( typeof cmml_data == 'string' ) { + var parser = new DOMParser(); + js_log( 'Parse CMML data:' + cmml_data ); + cmml_data = parser.parseFromString( cmml_data, "text/xml" ); } - //init anno_data_cache - if(!_this.anno_data_cache) - _this.anno_data_cache={}; - //grab all metadata and put it into the anno_data_cache: - $j.each(cmml_data.getElementsByTagName('clip'), function(inx, clip){ - _this.anno_data_cache[ $j(clip).attr("id") ]={ - 'start_time_sec':npt2seconds($j(clip).attr("start").replace('npt:','')), - 'end_time_sec':npt2seconds($j(clip).attr("end").replace('npt:','')), - 'time_req':$j(clip).attr("start").replace('npt:','')+'/'+$j(clip).attr("end").replace('npt:','') + // init anno_data_cache + if ( !_this.anno_data_cache ) + _this.anno_data_cache = { }; + // grab all metadata and put it into the anno_data_cache: + $j.each( cmml_data.getElementsByTagName( 'clip' ), function( inx, clip ) { + _this.anno_data_cache[ $j( clip ).attr( "id" ) ] = { + 'start_time_sec':npt2seconds( $j( clip ).attr( "start" ).replace( 'npt:', '' ) ), + 'end_time_sec':npt2seconds( $j( clip ).attr( "end" ).replace( 'npt:', '' ) ), + 'time_req':$j( clip ).attr( "start" ).replace( 'npt:', '' ) + '/' + $j( clip ).attr( "end" ).replace( 'npt:', '' ) }; - //grab all its meta - _this.anno_data_cache[ $j(clip).attr("id") ]['meta']={}; - $j.each(clip.getElementsByTagName('meta'),function(imx, meta){ - //js_log('adding meta: '+ $j(meta).attr("name")+ ' = '+ $j(meta).attr("content")); - _this.anno_data_cache[$j(clip).attr("id")]['meta'][$j(meta).attr("name")]=$j(meta).attr("content"); - }); - }); - _this.showNextPrevLinks(); - }); - } - //query current request time +|- 60s to get prev next speech links. - }, - showNextPrevLinks:function(){ - //js_log('f:showNextPrevLinks'); - //int requested links: + // grab all its meta + _this.anno_data_cache[ $j( clip ).attr( "id" ) ]['meta'] = { }; + $j.each( clip.getElementsByTagName( 'meta' ), function( imx, meta ) { + // js_log('adding meta: '+ $j(meta).attr("name")+ ' = '+ $j(meta).attr("content")); + _this.anno_data_cache[$j( clip ).attr( "id" )]['meta'][$j( meta ).attr( "name" )] = $j( meta ).attr( "content" ); + } ); + } ); + _this.showNextPrevLinks(); + } ); + } + // query current request time +|- 60s to get prev next speech links. + }, + showNextPrevLinks:function() { + // js_log('f:showNextPrevLinks'); + // int requested links: var link = { 'prev':'', 'current':'', 'next':'' - } - var curTime = this.getTimeReq().split('/'); + } + var curTime = this.getTimeReq().split( '/' ); - var s_sec = npt2seconds(curTime[0]); - var e_sec = npt2seconds(curTime[1]); - js_log('showNextPrevLinks: req time: '+ s_sec + ' to ' + e_sec); - //now we have all the data in anno_data_cache - var current_done=false; - for(var clip_id in this.anno_data_cache){ //for in loop oky for object + var s_sec = npt2seconds( curTime[0] ); + var e_sec = npt2seconds( curTime[1] ); + js_log( 'showNextPrevLinks: req time: ' + s_sec + ' to ' + e_sec ); + // now we have all the data in anno_data_cache + var current_done = false; + for ( var clip_id in this.anno_data_cache ) { // for in loop oky for object var clip = this.anno_data_cache[clip_id]; - //js_log('on clip:'+ clip_id); - //set prev_link (if cur_link is still empty) - if( s_sec > clip.end_time_sec){ + // js_log('on clip:'+ clip_id); + // set prev_link (if cur_link is still empty) + if ( s_sec > clip.end_time_sec ) { link.prev = clip_id; - js_log('showNextPrevLinks: ' + s_sec + ' < ' + clip.end_time_sec + ' set prev'); + js_log( 'showNextPrevLinks: ' + s_sec + ' < ' + clip.end_time_sec + ' set prev' ); } - if(e_sec==clip.end_time_sec && s_sec== clip.start_time_sec) + if ( e_sec == clip.end_time_sec && s_sec == clip.start_time_sec ) current_done = true; - //current clip is not done: - if( e_sec < clip.end_time_sec && link.current=='' && !current_done){ + // current clip is not done: + if ( e_sec < clip.end_time_sec && link.current == '' && !current_done ) { link.current = clip_id; - js_log('showNextPrevLinks: ' + e_sec + ' < ' + clip.end_time_sec + ' set current'); + js_log( 'showNextPrevLinks: ' + e_sec + ' < ' + clip.end_time_sec + ' set current' ); } - //set end clip (first clip where start time is > end_time of req - if( e_sec < clip.start_time_sec && link.next==''){ + // set end clip (first clip where start time is > end_time of req + if ( e_sec < clip.start_time_sec && link.next == '' ) { link.next = clip_id; - js_log('showNextPrevLinks: '+ e_sec + ' < '+ clip.start_time_sec + ' && ' + link.next ); + js_log( 'showNextPrevLinks: ' + e_sec + ' < ' + clip.start_time_sec + ' && ' + link.next ); } - } - var html=''; - if(link.prev=='' && link.current=='' && link.next==''){ - html='

clip page'; - }else{ - for(var link_type in link){ - var link_id = link[link_type]; - if(link_id!=''){ - var clip = this.anno_data_cache[link_id]; - var title_msg=''; - for(var j in clip['meta']){ - title_msg+=j.replace(/_/g,' ') +': ' +clip['meta'][j].replace(/_/g,' ') +"
"; - } + } + var html = ''; + if ( link.prev == '' && link.current == '' && link.next == '' ) { + html = '

clip page'; + } else { + for ( var link_type in link ) { + var link_id = link[link_type]; + if ( link_id != '' ) { + var clip = this.anno_data_cache[link_id]; + var title_msg = ''; + for ( var j in clip['meta'] ) { + title_msg += j.replace( / _ / g, ' ' ) + ': ' + clip['meta'][j].replace( / _ / g, ' ' ) + "
"; + } var time_req = clip.time_req; - if(link_type=='current') //if current start from end of current clip play to end of current meta: - time_req = curTime[1]+ '/' + seconds2npt( clip.end_time_sec ); + if ( link_type == 'current' ) // if current start from end of current clip play to end of current meta: + time_req = curTime[1] + '/' + seconds2npt( clip.end_time_sec ); - //do special linkbacks for metavid content: - var regTimeCheck = new RegExp(/[0-9]+:[0-9]+:[0-9]+\/[0-9]+:[0-9]+:[0-9]+/); - html+='

' + - gM('mwe-' + link_type+'_clip_msg') + - '
'+ title_msg +'

'; - } + html += ' title="' + title_msg + '">' + + gM( 'mwe-' + link_type + '_clip_msg' ) + + '
' + title_msg + '

'; + } } - } - //js_og("should set html:"+ html); - $j('#liks_info_'+this.id).html( html ); + } + // js_og("should set html:"+ html); + $j( '#liks_info_' + this.id ).html( html ); }, - playByTimeReq: function(time_req){ - js_log('f:playByTimeReq: '+time_req ); + playByTimeReq: function( time_req ) { + js_log( 'f:playByTimeReq: ' + time_req ); this.stop(); - this.updateVideoTimeReq(time_req); - this.play(); + this.updateVideoTimeReq( time_req ); + this.play(); }, - doThumbnailHTML:function(){ + doThumbnailHTML:function() { var _this = this; - js_log('f:doThumbnailHTML'+ this.thumbnail_disp); - this.closeDisplayedHTML(); + js_log( 'f:doThumbnailHTML' + this.thumbnail_disp ); + this.closeDisplayedHTML(); $j( '#mv_embedded_player_' + this.id ).html( this.getThumbnailHTML() ); - this.paused = true; + this.paused = true; this.thumbnail_disp = true; - //make sure the ctrlBuilder remain active: - this.ctrlBuilder.addControlHooks(); + // make sure the ctrlBuilder remain active: + this.ctrlBuilder.addControlHooks(); }, - refreshControlsHTML:function(){ - if($j('#' + this.id + ' .control-bar').length == 0){ - js_log('refreshControlsHTML::control-bar not present, no refresh'); + refreshControlsHTML:function() { + if ( $j( '#' + this.id + ' .control-bar' ).length == 0 ) { + js_log( 'refreshControlsHTML::control-bar not present, no refresh' ); return ; } // Do update controls: - $j('#' + this.id + ' .control-bar').html( this.getControlsHTML() ); - this.ctrlBuilder.addControlHooks(); + $j( '#' + this.id + ' .control-bar' ).html( this.getControlsHTML() ); + this.ctrlBuilder.addControlHooks(); - }, - getControlsHTML:function(){ + }, + getControlsHTML:function() { return this.ctrlBuilder.getControls( this ); - }, - getHTML : function (){ - //@@todo check if we have sources available - js_log('embedVideo:getHTML : ' + this.id + ' resource type: ' + this.type); + }, + getHTML : function () { + // @@todo check if we have sources available + js_log( 'embedVideo:getHTML : ' + this.id + ' resource type: ' + this.type ); - //set-up the local ctrlBuilder instance: + // set-up the local ctrlBuilder instance: this.ctrlBuilder = new ctrlBuilder( this ); - var _this = this; - var html_code = ''; - html_code = '
'; - html_code += '
' + - this.getThumbnailHTML() + - '
'; + var _this = this; + var html_code = ''; + html_code = '
'; + html_code += '
' + + this.getThumbnailHTML() + + '
'; - //js_log("mvEmbed:controls "+ typeof this.controls); - if( this.controls ){ - js_log("f:getHTML:AddControls"); - html_code +='
'; - html_code += this.getControlsHTML(); - html_code +='
'; - //block out some space by encapulating the top level div - $j(this).wrap('
'); + // js_log("mvEmbed:controls "+ typeof this.controls); + if ( this.controls ) { + js_log( "f:getHTML:AddControls" ); + html_code += '
'; + html_code += this.getControlsHTML(); + html_code += '
'; + // block out some space by encapulating the top level div + $j( this ).wrap( '
' ); } - html_code += '
'; //videoPlayer div close - - //js_log('should set: '+this.id); - $j(this).html( html_code ); + html_code += '
'; // videoPlayer div close + + // js_log('should set: '+this.id); + $j( this ).html( html_code ); // Add hooks once Controls are in DOM - this.ctrlBuilder.addControlHooks(); + this.ctrlBuilder.addControlHooks(); - if( this.autoplay ){ - js_log('getHTML::activating autoplay'); + if ( this.autoplay ) { + js_log( 'getHTML::activating autoplay' ); this.play(); } }, @@ -1515,117 +1515,117 @@ embedVideo.prototype = { * get missing plugin html (check for user included code) * @param {String} misssing_type missing type mime */ - getPluginMissingHTML : function(missing_type){ - //keep the box width hight: - var out = '
'; - if(this.user_missing_plugin_html){ - out+= this.user_missing_plugin_html; - }else{ - if(!missing_type) - missing_type=''; - out+= gM('mwe-generic_missing_plugin', missing_type) + '
'+gM('mwe-download_clip')+''; + getPluginMissingHTML : function( missing_type ) { + // keep the box width hight: + var out = '
'; + if ( this.user_missing_plugin_html ) { + out += this.user_missing_plugin_html; + } else { + if ( !missing_type ) + missing_type = ''; + out += gM( 'mwe-generic_missing_plugin', missing_type ) + '
' + gM( 'mwe-download_clip' ) + ''; } return out + '
'; }, - updateVideoTimeReq:function( time_req ){ - js_log('f:updateVideoTimeReq'); - var time_parts =time_req.split('/'); + updateVideoTimeReq:function( time_req ) { + js_log( 'f:updateVideoTimeReq' ); + var time_parts = time_req.split( '/' ); this.updateVideoTime( time_parts[0], time_parts[1] ); }, - //update video time - updateVideoTime:function(start_ntp, end_ntp){ - //update media + // update video time + updateVideoTime:function( start_ntp, end_ntp ) { + // update media this.media_element.updateSourceTimes( start_ntp, end_ntp ); - //update mv_time + // update mv_time this.setStatus( start_ntp + '/' + end_ntp ); - //reset slider - this.setSliderValue(0); - //reset seek_offset: - if( this.media_element.selected_source.URLTimeEncoding ) - this.seek_time_sec=0; + // reset slider + this.setSliderValue( 0 ); + // reset seek_offset: + if ( this.media_element.selected_source.URLTimeEncoding ) + this.seek_time_sec = 0; else - this.seek_time_sec=npt2seconds(start_ntp); - }, + this.seek_time_sec = npt2seconds( start_ntp ); + }, // Should overwrite by embed library if we can render frames natively - renderTimelineThumbnail:function( options ){ + renderTimelineThumbnail:function( options ) { var my_thumb_src = this.media_element.getThumbnailURL(); - //check if our thumbnail has a time attribute: - if( my_thumb_src.indexOf('t=') !== -1){ - var time_ntp = seconds2npt ( options.time + parseInt(this.start_offset) ); + // check if our thumbnail has a time attribute: + if ( my_thumb_src.indexOf( 't=' ) !== - 1 ) { + var time_ntp = seconds2npt ( options.time + parseInt( this.start_offset ) ); my_thumb_src = getURLParamReplace( my_thumb_src, { 't':time_ntp, 'size': options.size } ); } - var thumb_class = (typeof options['thumb_class'] != 'undefined' ) ? options['thumb_class'] : ''; - return '
' + - '' + + '' + '
'; }, - updateThumbTimeNTP:function( time){ - this.updateThumbTime( npt2seconds(time) - parseInt(this.start_offset) ); + updateThumbTimeNTP:function( time ) { + this.updateThumbTime( npt2seconds( time ) - parseInt( this.start_offset ) ); }, - updateThumbTime:function( float_sec ){ - //js_log('updateThumbTime:'+float_sec); - var _this = this; - if( typeof this.org_thum_src=='undefined' ){ + updateThumbTime:function( float_sec ) { + // js_log('updateThumbTime:'+float_sec); + var _this = this; + if ( typeof this.org_thum_src == 'undefined' ) { this.org_thum_src = this.media_element.getThumbnailURL(); - } - if( this.org_thum_src.indexOf('t=') !== -1){ - this.last_thumb_url = getURLParamReplace(this.org_thum_src, - { 't' : seconds2npt( float_sec + parseInt(this.start_offset)) } ); - if(!this.thumbnail_updating){ - this.updateThumbnail(this.last_thumb_url ,false); - this.last_thumb_url =null; + } + if ( this.org_thum_src.indexOf( 't=' ) !== - 1 ) { + this.last_thumb_url = getURLParamReplace( this.org_thum_src, + { 't' : seconds2npt( float_sec + parseInt( this.start_offset ) ) } ); + if ( !this.thumbnail_updating ) { + this.updateThumbnail( this.last_thumb_url , false ); + this.last_thumb_url = null; } } }, - updateThumbPerc:function( perc ){ - return this.updateThumbTime( (this.getDuration() * perc) ); + updateThumbPerc:function( perc ) { + return this.updateThumbTime( ( this.getDuration() * perc ) ); }, // Updates the thumbnail if the thumbnail is being displayed - updateThumbnail : function(src, quick_switch){ - //make sure we don't go to the same url if we are not already updating: - if( !this.thumbnail_updating && $j('#img_thumb_'+this.id).attr('src')== src ) + updateThumbnail : function( src, quick_switch ) { + // make sure we don't go to the same url if we are not already updating: + if ( !this.thumbnail_updating && $j( '#img_thumb_' + this.id ).attr( 'src' ) == src ) return false; - //if we are already updating don't issue a new update: - if( this.thumbnail_updating && $j('#new_img_thumb_'+this.id).attr('src')== src ) + // if we are already updating don't issue a new update: + if ( this.thumbnail_updating && $j( '#new_img_thumb_' + this.id ).attr( 'src' ) == src ) return false; - js_log('update thumb: ' + src); + js_log( 'update thumb: ' + src ); - if(quick_switch){ - $j('#img_thumb_'+this.id).attr('src', src); - }else{ - var _this = this; - //if still animating remove new_img_thumb_ - if(this.thumbnail_updating==true) - $j('#new_img_thumb_'+this.id).stop().remove(); + if ( quick_switch ) { + $j( '#img_thumb_' + this.id ).attr( 'src', src ); + } else { + var _this = this; + // if still animating remove new_img_thumb_ + if ( this.thumbnail_updating == true ) + $j( '#new_img_thumb_' + this.id ).stop().remove(); - if(this.thumbnail_disp){ - js_log('set to thumb:'+ src); - this.thumbnail_updating=true; - $j('#dc_'+this.id).append(''); - //js_log('appended: new_img_thumb_'); - $j('#new_img_thumb_'+this.id).fadeIn("slow", function(){ - //once faded in remove org and rename new: - $j('#img_thumb_'+_this.id).remove(); - $j('#new_img_thumb_'+_this.id).attr('id', 'img_thumb_'+_this.id); - $j('#img_thumb_'+_this.id).css('zindex','1'); - _this.thumbnail_updating=false; - //js_log("done fadding in "+ $j('#img_thumb_'+_this.id).attr("src")); - - //if we have a thumb queued update to that - if(_this.last_thumb_url){ - var src_url =_this.last_thumb_url; - _this.last_thumb_url=null; - _this.updateThumbnail(src_url); + 'width="' + this.width + '" height="' + this.height + '" ' + + 'id = "new_img_thumb_' + this.id + '" />' ); + // js_log('appended: new_img_thumb_'); + $j( '#new_img_thumb_' + this.id ).fadeIn( "slow", function() { + // once faded in remove org and rename new: + $j( '#img_thumb_' + _this.id ).remove(); + $j( '#new_img_thumb_' + _this.id ).attr( 'id', 'img_thumb_' + _this.id ); + $j( '#img_thumb_' + _this.id ).css( 'zindex', '1' ); + _this.thumbnail_updating = false; + // js_log("done fadding in "+ $j('#img_thumb_'+_this.id).attr("src")); + + // if we have a thumb queued update to that + if ( _this.last_thumb_url ) { + var src_url = _this.last_thumb_url; + _this.last_thumb_url = null; + _this.updateThumbnail( src_url ); } - }); + } ); } } }, @@ -1635,160 +1635,160 @@ embedVideo.prototype = { * playing, configuring the player, inline cmml display, HTML linkback, * download, and embed code. */ - getThumbnailHTML : function (){ - js_log('embedVideo:getThumbnailHTML::' + this.id); + getThumbnailHTML : function () { + js_log( 'embedVideo:getThumbnailHTML::' + this.id ); var thumb_html = ''; - var class_atr=''; - var style_atr=''; - //if(this.class)class_atr = ' class="'+this.class+'"'; - //if(this.style)style_atr = ' style="'+this.style+'"'; + var class_atr = ''; + var style_atr = ''; + // if(this.class)class_atr = ' class="'+this.class+'"'; + // if(this.style)style_atr = ' style="'+this.style+'"'; // else style_atr = 'overflow:hidden;height:'+this.height+'px;width:'+this.width+'px;'; this.thumbnail = this.media_element.getThumbnailURL(); - //put it all in the div container dc_id - thumb_html+= '
'+ - ''; + // put it all in the div container dc_id + thumb_html += '
' + + ''; - if(this.play_button == true && this.controls == true) - thumb_html+= this.ctrlBuilder.getComponent( 'play-btn-large' ); + if ( this.play_button == true && this.controls == true ) + thumb_html += this.ctrlBuilder.getComponent( 'play-btn-large' ); - thumb_html+='
'; + thumb_html += '
'; return thumb_html; }, - getEmbeddingHTML:function(){ + getEmbeddingHTML:function() { var thumbnail = this.media_element.getThumbnailURL(); var embed_thumb_html; - if(thumbnail.substring(0,1)=='/'){ - eURL = parseUri(mv_embed_path); + if ( thumbnail.substring( 0, 1 ) == '/' ) { + eURL = parseUri( mv_embed_path ); embed_thumb_url = eURL.protocol + '://' + eURL.host + thumbnail; - //js_log('set from mv_embed_path:'+embed_thumb_html); - }else{ - embed_thumb_url = (thumbnail.indexOf('http://')!=-1)?thumbnail:mv_embed_path + thumbnail; + // js_log('set from mv_embed_path:'+embed_thumb_html); + } else { + embed_thumb_url = ( thumbnail.indexOf( 'http://' ) != - 1 ) ? thumbnail:mv_embed_path + thumbnail; } var embed_code_html = '<script type="text/javascript" ' + 'src="' + mv_embed_path + 'mv_embed.js"></script>' + '<video '; - if(this.roe){ - embed_code_html+='roe="' + escape( this.roe ) + '" '; - }else{ - embed_code_html+='src="'+this.src+'" ' + - 'poster="'+ escape( embed_thumb_url )+'" '; + if ( this.roe ) { + embed_code_html += 'roe="' + escape( this.roe ) + '" '; + } else { + embed_code_html += 'src="' + this.src + '" ' + + 'poster="' + escape( embed_thumb_url ) + '" '; } // Add in the wikiTitle key if provided // (in the future we should just include the titleKey on remote embeds // and query a roe like xml/json representaiton thing from mediawiki) - if( this.wikiTitleKey ){ - embed_code_html+= 'wikiTitleKey="' + escape( this.wikiTitleKey ) + '"'; + if ( this.wikiTitleKey ) { + embed_code_html += 'wikiTitleKey="' + escape( this.wikiTitleKey ) + '"'; } - //close the video tag - embed_code_html+='></video>'; + // close the video tag + embed_code_html += '></video>'; return embed_code_html; }, - doOptionsHTML:function(){ - var sel_id = (this.pc!=null)?this.pc.pp.id:this.id; - var pos = $j('#'+sel_id + ' .options-btn').offset(); - pos['top']=pos['top']+24; - pos['left']=pos['left']-124; - //js_log('pos of options button: t:'+pos['top']+' l:'+ pos['left']); - $j('#mv_vid_options_'+sel_id).css(pos).toggle(); + doOptionsHTML:function() { + var sel_id = ( this.pc != null ) ? this.pc.pp.id:this.id; + var pos = $j( '#' + sel_id + ' .options-btn' ).offset(); + pos['top'] = pos['top'] + 24; + pos['left'] = pos['left'] - 124; + // js_log('pos of options button: t:'+pos['top']+' l:'+ pos['left']); + $j( '#mv_vid_options_' + sel_id ).css( pos ).toggle(); return; - }, - doLinkBack:function(){ - if(this.roe && this.media_element.addedROEData==false){ + }, + doLinkBack:function() { + if ( this.roe && this.media_element.addedROEData == false ) { var _this = this; - this.displayHTML( gM('mwe-loading_txt') ); - do_request(this.roe, function(data){ - _this.media_element.addROE(data); + this.displayHTML( gM( 'mwe-loading_txt' ) ); + do_request( this.roe, function( data ) { + _this.media_element.addROE( data ); _this.doLinkBack(); - }); - }else{ - if( this.linkback){ + } ); + } else { + if ( this.linkback ) { window.location = this.linkback; - }else if(this.media_element.linkback){ + } else if ( this.media_element.linkback ) { window.location = this.media_element.linkback; - }else{ - this.displayHTML( gM('mwe-could_not_find_linkback') ); + } else { + this.displayHTML( gM( 'mwe-could_not_find_linkback' ) ); } - } + } }, - showShare:function($target){ + showShare:function( $target ) { var embed_code = this.getEmbeddingHTML(); var o = ''; var _this = this; - //@todo: hook events to two a's for swapping in and out code for link vs. embed; + // @todo: hook events to two a's for swapping in and out code for link vs. embed; // hook events for changing active class of li based on a. - o+= '

' + gM('mwe-share_this_video') + '

' + + o += '

' + gM( 'mwe-share_this_video' ) + '

' + '' + + o += '' + '
' + - '' + - '
' + gM('mwe-read_before_embed') + '
' + + '' + + '
' + gM( 'mwe-read_before_embed' ) + '
' + '
'; - $target.html(o); - $cpBtn = $j( '#' + this.id + ' .copycode'); - $cpTxt = $j( '#' + this.id + ' .source_wrap textarea'); + $target.html( o ); + $cpBtn = $j( '#' + this.id + ' .copycode' ); + $cpTxt = $j( '#' + this.id + ' .source_wrap textarea' ); - $cpTxt.click(function(){ - $j(this).get(0).select(); - }); + $cpTxt.click( function() { + $j( this ).get( 0 ).select(); + } ); - //add copy binding: - $cpBtn.click(function(){ - $cpTxt.focus().get(0).select(); - if(document.selection){ - CopiedTxt = document.selection.createRange(); - CopiedTxt.execCommand("Copy"); + // add copy binding: + $cpBtn.click( function() { + $cpTxt.focus().get( 0 ).select(); + if ( document.selection ) { + CopiedTxt = document.selection.createRange(); + CopiedTxt.execCommand( "Copy" ); } - }); + } ); }, - showTextInterface:function(){ + showTextInterface:function() { var _this = this; - //display the text container with loading text: - //@@todo support position config - var loc = $j(this).position(); - if($j('#metaBox_'+this.id).length==0){ - var theight = (parseInt( this.height ) < 200) ? 200 : parseInt( this.height ); - $j(this).after('
'+ + 'id="metaBox_' + this.id + '">' + mv_get_loading_img() + - '
'); - } - //fade in the text display - $j('#metaBox_'+this.id).fadeIn("fast"); - //check if textObj present: - if(typeof this.textInterface == 'undefined' ){ - //load the default text interface: - mvJsLoader.doLoad([ - 'mvTextInterface', + '
' ); + } + // fade in the text display + $j( '#metaBox_' + this.id ).fadeIn( "fast" ); + // check if textObj present: + if ( typeof this.textInterface == 'undefined' ) { + // load the default text interface: + mvJsLoader.doLoad( [ + 'mvTextInterface', '$j.fn.hoverIntent' - ], function(){ - _this.textInterface = new mvTextInterface( _this ); - //show interface - _this.textInterface.show(); + ], function() { + _this.textInterface = new mvTextInterface( _this ); + // show interface + _this.textInterface.show(); } ); - }else{ - //show interface + } else { + // show interface this.textInterface.show(); } }, - closeTextInterface:function(){ - js_log('closeTextInterface '+ typeof this.textInterface); - if(typeof this.textInterface !== 'undefined' ){ + closeTextInterface:function() { + js_log( 'closeTextInterface ' + typeof this.textInterface ); + if ( typeof this.textInterface !== 'undefined' ) { this.textInterface.close(); } }, @@ -1800,478 +1800,478 @@ embedVideo.prototype = { */ displayHTML:function( html_code ) { - var sel_id = (this.pc!=null)?this.pc.pp.id:this.id; + var sel_id = ( this.pc != null ) ? this.pc.pp.id:this.id; - if(!this.supports['overlays']) + if ( !this.supports['overlays'] ) this.stop(); - //put select list on-top - //make sure the parent is relatively positioned: - $j('#'+sel_id).css('position', 'relative'); - //set height width (check for playlist container) - var width = (this.pc)?this.pc.pp.width:this.playerPixelWidth(); - var height = (this.pc)?this.pc.pp.height:this.playerPixelHeight(); + // put select list on-top + // make sure the parent is relatively positioned: + $j( '#' + sel_id ).css( 'position', 'relative' ); + // set height width (check for playlist container) + var width = ( this.pc ) ? this.pc.pp.width:this.playerPixelWidth(); + var height = ( this.pc ) ? this.pc.pp.height:this.playerPixelHeight(); - if(this.pc) - height+=(this.pc.pp.pl_layout.title_bar_height + this.pc.pp.pl_layout.control_height); + if ( this.pc ) + height += ( this.pc.pp.pl_layout.title_bar_height + this.pc.pp.pl_layout.control_height ); var fade_in = true; - if($j('#blackbg_'+sel_id).length!=0) + if ( $j( '#blackbg_' + sel_id ).length != 0 ) { fade_in = false; - $j('#blackbg_'+sel_id).remove(); - } - //fade in a black bg div ontop of everything - var div_code = '
'+ - '
'+ - //@@TODO: this style should go to .css - '' + - 'close' + - ''+ - '
'+ - html_code - +'
'+ + $j( '#blackbg_' + sel_id ).remove(); + } + // fade in a black bg div ontop of everything + var div_code = '
' + + '
' + + // @@TODO: this style should go to .css + '' + + 'close' + + '' + + '
' + + html_code + + '
' + '
'; - $j('#'+sel_id).prepend(div_code); - if (fade_in) - $j('#blackbg_'+sel_id).fadeIn("slow"); + $j( '#' + sel_id ).prepend( div_code ); + if ( fade_in ) + $j( '#blackbg_' + sel_id ).fadeIn( "slow" ); else - $j('#blackbg_'+sel_id).show(); - return false; //onclick action return false + $j( '#blackbg_' + sel_id ).show(); + return false; // onclick action return false }, /** * Close the custom HTML displayed using displayHTML and restores the * regular mv_embed display. */ - closeDisplayedHTML:function(){ - var sel_id = (this.pc!=null)?this.pc.pp.id:this.id; - $j('#blackbg_'+sel_id).fadeOut("slow", function(){ - $j('#blackbg_'+sel_id).remove(); - }); - return false; //onclick action return false - }, - showPlayerselect:function( $target ){ + closeDisplayedHTML:function() { + var sel_id = ( this.pc != null ) ? this.pc.pp.id:this.id; + $j( '#blackbg_' + sel_id ).fadeOut( "slow", function() { + $j( '#blackbg_' + sel_id ).remove(); + } ); + return false; // onclick action return false + }, + showPlayerselect:function( $target ) { // Get id (in case where we have a parent container) - var this_id = (this.pc!=null)?this.pc.pp.id:this.id; - var _this=this; - var o= ''; - o+='

' + gM('mwe-chose_player') + '

'; - var _this=this; - $j.each( this.media_element.getPlayableSources(), function(source_id, source){ + var this_id = ( this.pc != null ) ? this.pc.pp.id:this.id; + var _this = this; + var o = ''; + o += '

' + gM( 'mwe-chose_player' ) + '

'; + var _this = this; + $j.each( this.media_element.getPlayableSources(), function( source_id, source ) { var default_player = embedTypes.players.defaultPlayer( source.getMIMEType() ); - var is_selected = (source == _this.media_element.selected_source); + var is_selected = ( source == _this.media_element.selected_source ); var image_src = mv_skin_img_path ; - if (default_player){ - o+=''; + } else { + o += source.getTitle() + ' - no player available'; } - }); - $target.html(o); + } ); + $target.html( o ); // Set up the click bindings: - $target.find("[rel='sel_source']").each(function(){ - $j(this).click(function(){ - var iparts = $j(this).attr( 'id' ).replace(/sc_/,'').split('_'); + $target.find( "[rel='sel_source']" ).each( function() { + $j( this ).click( function() { + var iparts = $j( this ).attr( 'id' ).replace( / sc_ / , '' ).split( '_' ); var source_id = iparts[0]; var default_player_id = iparts[1]; - js_log('source id: ' + source_id + ' player id: ' + default_player_id); + js_log( 'source id: ' + source_id + ' player id: ' + default_player_id ); - $j('#' + this_id ).get(0).closeDisplayedHTML(); - $j('#' + _this.id ).get(0).media_element.selectSource( source_id ); + $j( '#' + this_id ).get( 0 ).closeDisplayedHTML(); + $j( '#' + _this.id ).get( 0 ).media_element.selectSource( source_id ); embedTypes.players.userSelectPlayer( default_player_id, _this.media_element.sources[ source_id ].getMIMEType() ); // Issue a stop - $j('#' + this_id ).get(0).stop(); + $j( '#' + this_id ).get( 0 ).stop(); // Don't follow the empty # link: return false; - }); - }); - }, - showDownload:function( $target ){ + } ); + } ); + }, + showDownload:function( $target ) { var _this = this; // Load the roe if available (to populate out download options: - function getShowVideoDownload(){ - var out='
'; - var dl_list=''; - var dl_txt_list=''; - $j.each(_this.media_element.getSources(), function(index, source){ - var dl_line = '
  • ' + ' ' - + source.getTitle()+' '+ '
  • '+"\n"; - if( source.getURI().indexOf('?t=')!==-1){ - out+=dl_line; - }else if( this.getMIMEType()=="text/cmml" || this.getMIMEType()=="text/x-srt" ){ - dl_txt_list+=dl_line; - }else{ - dl_list+=dl_line; + function getShowVideoDownload() { + var out = '
    '; + var dl_list = ''; + var dl_txt_list = ''; + $j.each( _this.media_element.getSources(), function( index, source ) { + var dl_line = '
  • ' + ' ' + + source.getTitle() + ' ' + '
  • ' + "\n"; + if ( source.getURI().indexOf( '?t=' ) !== - 1 ) { + out += dl_line; + } else if ( this.getMIMEType() == "text/cmml" || this.getMIMEType() == "text/x-srt" ) { + dl_txt_list += dl_line; + } else { + dl_list += dl_line; } - }); + } ); - if( dl_list != '' ) - out += gM('mwe-download_full') + '
    ' + dl_list + '
    '; - if( dl_txt_list != '' ) - out += gM('mwe-download_text') + '
    ' + dl_txt_list +'
    '; + if ( dl_list != '' ) + out += gM( 'mwe-download_full' ) + '
    ' + dl_list + '
    '; + if ( dl_txt_list != '' ) + out += gM( 'mwe-download_text' ) + '
    ' + dl_txt_list + '
    '; out += '
    '; return out; } - //js_log('f:showDownload '+ this.roe + ' ' + this.media_element.addedROEData); - if(this.roe && this.media_element.addedROEData == false){ + // js_log('f:showDownload '+ this.roe + ' ' + this.media_element.addedROEData); + if ( this.roe && this.media_element.addedROEData == false ) { var _this = this; - $target.html( gM('loading_txt') ); - do_request(this.roe, function(data){ - _this.media_element.addROE(data); + $target.html( gM( 'loading_txt' ) ); + do_request( this.roe, function( data ) { + _this.media_element.addROE( data ); $target.html( getShowVideoDownload() ); - }); - }else{ + } ); + } else { $target.html( getShowVideoDownload() ); } - }, - showCredits:function( $target ){ - $target.html('

    ' + gM('mwe-credits') + '

    '); + }, + showCredits:function( $target ) { + $target.html( '

    ' + gM( 'mwe-credits' ) + '

    ' ); }, /* * Base embed controls * The Play Action: */ - play : function(){ - var eid = (this.pc!=null)?this.pc.pp.id:this.id; + play : function() { + var eid = ( this.pc != null ) ? this.pc.pp.id:this.id; - //check if thumbnail is being displayed and embed html - if( this.thumbnail_disp ){ - if( !this.selected_player ){ - js_log('no selected_player'); - //this.innerHTML = this.getPluginMissingHTML(); - $j('#'+this.id).html( this.getPluginMissingHTML() ); - }else{ + // check if thumbnail is being displayed and embed html + if ( this.thumbnail_disp ) { + if ( !this.selected_player ) { + js_log( 'no selected_player' ); + // this.innerHTML = this.getPluginMissingHTML(); + $j( '#' + this.id ).html( this.getPluginMissingHTML() ); + } else { this.doEmbedHTML(); - this.onClipDone_disp=false; - this.paused=false; - this.thumbnail_disp=false; + this.onClipDone_disp = false; + this.paused = false; + this.thumbnail_disp = false; } - }else{ - //the plugin is already being displayed - this.paused=false; //make sure we are not "paused" - this.seeking=false; - } + } else { + // the plugin is already being displayed + this.paused = false; // make sure we are not "paused" + this.seeking = false; + } - $j('#' + eid + ' .play-btn span').removeClass('ui-icon-play').addClass('ui-icon-pause'); - $j('#' + eid + ' .play-btn').unbind().btnBind().click(function(){ - $j('#' + eid ).get(0).pause(); - }).attr('title', gM('mwe-pause_clip')); + $j( '#' + eid + ' .play-btn span' ).removeClass( 'ui-icon-play' ).addClass( 'ui-icon-pause' ); + $j( '#' + eid + ' .play-btn' ).unbind().btnBind().click( function() { + $j( '#' + eid ).get( 0 ).pause(); + } ).attr( 'title', gM( 'mwe-pause_clip' ) ); }, - load:function(){ - //should be done by child (no base way to pre-buffer video) - js_log('baseEmbed:load call'); + load:function() { + // should be done by child (no base way to pre-buffer video) + js_log( 'baseEmbed:load call' ); }, - getSrc:function(){ + getSrc:function() { return this.media_element.selected_source.getURI( this.seek_time_sec ); - }, + }, /* * Base embed pause * there is no general way to pause the video * must be overwritten by embed object to support this functionality. */ - pause: function(){ - var eid = (this.pc!=null)?this.pc.pp.id:this.id; - //js_log('mv_embed:do pause'); - //(playing) do pause - this.paused = true; - //update the ctrl "paused state" - $j('#' + eid + ' .play-btn span').removeClass('ui-icon-pause').addClass('ui-icon-play'); - $j('#' + eid + ' .play-btn').unbind().btnBind().click(function(){ - $j('#'+eid).get(0).play(); - }).attr('title', gM('mwe-play_clip')); - }, + pause: function() { + var eid = ( this.pc != null ) ? this.pc.pp.id:this.id; + // js_log('mv_embed:do pause'); + // (playing) do pause + this.paused = true; + // update the ctrl "paused state" + $j( '#' + eid + ' .play-btn span' ).removeClass( 'ui-icon-pause' ).addClass( 'ui-icon-play' ); + $j( '#' + eid + ' .play-btn' ).unbind().btnBind().click( function() { + $j( '#' + eid ).get( 0 ).play(); + } ).attr( 'title', gM( 'mwe-play_clip' ) ); + }, /** * Base embed stop (can be overwritten by the plugin) */ - stop: function(){ + stop: function() { var _this = this; - js_log('mvEmbed:stop:'+this.id); + js_log( 'mvEmbed:stop:' + this.id ); - //no longer seeking: - this.didSeekJump=false; + // no longer seeking: + this.didSeekJump = false; - //first issue pause to update interface (only call the parent) - if(this['parent_pause']){ + // first issue pause to update interface (only call the parent) + if ( this['parent_pause'] ) { this.parent_pause(); - }else{ + } else { this.pause(); - } + } - //reset the currentTime: - this.currentTime=0; - //check if thumbnail is being displayed in which case do nothing - if( this.thumbnail_disp ){ - //already in stooped state - js_log('already in stopped state'); - }else{ - //rewrite the html to thumbnail disp + // reset the currentTime: + this.currentTime = 0; + // check if thumbnail is being displayed in which case do nothing + if ( this.thumbnail_disp ) { + // already in stooped state + js_log( 'already in stopped state' ); + } else { + // rewrite the html to thumbnail disp this.doThumbnailHTML(); - this.bufferedPercent=0; //reset buffer state - this.setSliderValue(0); + this.bufferedPercent = 0; // reset buffer state + this.setSliderValue( 0 ); this.setStatus( this.getTimeReq() ); } - //make sure the big playbutton is has click action: - $j('#' + _this.id + ' .play-btn-large').unbind('click').click(function(){ - $j('#' +_this.id).get(0).play(); - }); + // make sure the big playbutton is has click action: + $j( '#' + _this.id + ' .play-btn-large' ).unbind( 'click' ).click( function() { + $j( '#' + _this.id ).get( 0 ).play(); + } ); - if(this.update_interval) + if ( this.update_interval ) { - clearInterval(this.update_interval); + clearInterval( this.update_interval ); this.update_interval = null; } }, - toggleMute:function(){ - var eid = (this.pc!=null)?this.pc.pp.id:this.id; - if( this.muted ){ - this.muted=false; - $j('#' + eid + ' .volume-slider').slider('value', 100); - this.updateVolumen(1); - }else{ - this.muted=true; - $j('#' + eid + ' .volume-slider').slider('value', 0); - this.updateVolumen(0); + toggleMute:function() { + var eid = ( this.pc != null ) ? this.pc.pp.id:this.id; + if ( this.muted ) { + this.muted = false; + $j( '#' + eid + ' .volume-slider' ).slider( 'value', 100 ); + this.updateVolumen( 1 ); + } else { + this.muted = true; + $j( '#' + eid + ' .volume-slider' ).slider( 'value', 0 ); + this.updateVolumen( 0 ); } - js_log('f:toggleMute::' + this.muted); + js_log( 'f:toggleMute::' + this.muted ); }, - updateVolumen:function(perc){ - js_log('update volume not supported with current playback type'); + updateVolumen:function( perc ) { + js_log( 'update volume not supported with current playback type' ); }, - fullscreen:function(){ - js_log('fullscreen not supported with current playback type'); + fullscreen:function() { + js_log( 'fullscreen not supported with current playback type' ); }, /** * returns bool true if playing or paused, false if stooped */ - isPlaying : function(){ - if(this.thumbnail_disp){ - //in stoped state + isPlaying : function() { + if ( this.thumbnail_disp ) { + // in stoped state return false; - }else if( this.paused ){ - //paused state + } else if ( this.paused ) { + // paused state return false; - }else{ + } else { return true; } }, - isPaused : function(){ + isPaused : function() { return this.isPlaying() && this.paused; }, - isStoped : function(){ + isStoped : function() { return this.thumbnail_disp; }, - playlistSupport:function(){ - //by default not supported (implemented in js) + playlistSupport:function() { + // by default not supported (implemented in js) return false; }, - postEmbedJS:function(){ + postEmbedJS:function() { return ''; }, /* * Monitor playback and update interface components. * underling plugin objects are responsible for updating currentTime */ - monitor:function(){ - //js_log(' ct: ' + this.currentTime + ' dur: ' + ( parseInt( this.duration ) + 1 ) + ' is seek: ' + this.seeking ); - if( this.currentTime && this.currentTime > 0 && this.duration){ - if( !this.userSlide && !this.seeking ){ - if( this.start_offset ){ - //if start offset include that calculation + monitor:function() { + // js_log(' ct: ' + this.currentTime + ' dur: ' + ( parseInt( this.duration ) + 1 ) + ' is seek: ' + this.seeking ); + if ( this.currentTime && this.currentTime > 0 && this.duration ) { + if ( !this.userSlide && !this.seeking ) { + if ( this.start_offset ) { + // if start offset include that calculation this.setSliderValue( ( this.currentTime - this.start_offset ) / this.duration ); - var et = (this.ctrlBuilder.long_time_disp)? '/'+ seconds2npt(parseFloat(this.start_offset)+parseFloat(this.duration) ) : ''; - this.setStatus( seconds2npt(this.currentTime) + et); - }else{ + var et = ( this.ctrlBuilder.long_time_disp ) ? '/' + seconds2npt( parseFloat( this.start_offset ) + parseFloat( this.duration ) ) : ''; + this.setStatus( seconds2npt( this.currentTime ) + et ); + } else { this.setSliderValue( this.currentTime / this.duration ); - var et = (this.ctrlBuilder.long_time_disp)? '/' + seconds2npt( this.duration ):''; - this.setStatus( seconds2npt( this.currentTime ) + et); - } + var et = ( this.ctrlBuilder.long_time_disp ) ? '/' + seconds2npt( this.duration ):''; + this.setStatus( seconds2npt( this.currentTime ) + et ); + } } // Check if we are "done" - if( this.currentTime > ( parseInt(this.duration) + 1 ) ){ - js_log("should run clip done ct:: " + this.currentTime + ' > ' + parseInt( this.duration + 1 ) ); + if ( this.currentTime > ( parseInt( this.duration ) + 1 ) ) { + js_log( "should run clip done ct:: " + this.currentTime + ' > ' + parseInt( this.duration + 1 ) ); this.onClipDone(); - } - }else{ + } + } else { // Media lacks duration just show end time - //js_log(' ct:' + this.currentTime + ' dur: ' + this.duration); - if( this.isStoped() ){ + // js_log(' ct:' + this.currentTime + ' dur: ' + this.duration); + if ( this.isStoped() ) { this.setStatus( this.getTimeReq() ); - }else if( this.isPaused() ){ - this.setStatus( gM('mwe-paused') ); - }else if( this.isPlaying() ){ - if( this.currentTime && ! this.duration ) + } else if ( this.isPaused() ) { + this.setStatus( gM( 'mwe-paused' ) ); + } else if ( this.isPlaying() ) { + if ( this.currentTime && ! this.duration ) this.setStatus( seconds2npt( this.currentTime ) + ' /' ); - else - this.setStatus(" - - - "); - }else{ + else + this.setStatus( " - - - " ); + } else { this.setStatus( this.getTimeReq() ); - } + } } // Could check if time > duration here and stop playback - + // Update buffer information this.updateBufferStatus(); var _this = this; // Update monitorTimerId to call child monitor - if( ! this.monitorTimerId ){ + if ( ! this.monitorTimerId ) { // Make sure an instance of this.id exists: - if( document.getElementById(this.id) ){ - this.monitorTimerId = setInterval(function(){ - if(_this.id && $j( '#'+_this.id ).length != 0){ - $j( '#'+_this.id ).get(0).monitor(); + if ( document.getElementById( this.id ) ) { + this.monitorTimerId = setInterval( function() { + if ( _this.id && $j( '#' + _this.id ).length != 0 ) { + $j( '#' + _this.id ).get( 0 ).monitor(); } - }, 250); + }, 250 ); } } - }, - stopMonitor:function(){ - if( this.monitorTimerId != 0 ) + }, + stopMonitor:function() { + if ( this.monitorTimerId != 0 ) { clearInterval( this.monitorTimerId ); this.monitorTimerId = 0; } }, - updateBufferStatus: function(){ + updateBufferStatus: function() { // Build the buffer target based for playlist vs clip - var buffer_select = (this.pc) ? - '#cl_status_' + this.id + ' .mv_buffer': + var buffer_select = ( this.pc ) ? + '#cl_status_' + this.id + ' .mv_buffer': '#' + this.id + ' .play_head .mv_buffer'; // Update the buffer progress bar (if available ) - if( this.bufferedPercent != 0 ){ - //js_log('bufferedPercent: ' + this.bufferedPercent); - if(this.bufferedPercent > 1) - this.bufferedPercent=1; + if ( this.bufferedPercent != 0 ) { + // js_log('bufferedPercent: ' + this.bufferedPercent); + if ( this.bufferedPercent > 1 ) + this.bufferedPercent = 1; - $j(buffer_select).css("width", (this.bufferedPercent*100) +'%' ); - }else{ - $j(buffer_select).css("width", '0px' ); + $j( buffer_select ).css( "width", ( this.bufferedPercent * 100 ) + '%' ); + } else { + $j( buffer_select ).css( "width", '0px' ); } }, - relativeCurrentTime: function(){ - if(!this.start_offset) - this.start_offset =0; + relativeCurrentTime: function() { + if ( !this.start_offset ) + this.start_offset = 0; var rt = this.currentTime - this.start_offset; - if( rt < 0 ) //should not happen but does. + if ( rt < 0 ) // should not happen but does. return 0; return rt; }, - getPluginEmbed : function(){ - if (window.document[this.pid]){ + getPluginEmbed : function() { + if ( window.document[this.pid] ) { return window.document[this.pid]; } - if ($j.browser.msie){ - return document.getElementById(this.pid ); - }else{ - if (document.embeds && document.embeds[this.pid]) + if ( $j.browser.msie ) { + return document.getElementById( this.pid ); + } else { + if ( document.embeds && document.embeds[this.pid] ) return document.embeds[this.pid]; } return null; }, - setSliderValue: function(perc, hide_progress){ - var eid = (this.pc)?this.pc.pp.id:this.id; - if(this.controls && $j('#' + eid + ' .play_head').length != 0){ - var val = parseInt( perc*1000 ); - $j('#' + eid + ' .play_head').slider('value', val); + setSliderValue: function( perc, hide_progress ) { + var eid = ( this.pc ) ? this.pc.pp.id:this.id; + if ( this.controls && $j( '#' + eid + ' .play_head' ).length != 0 ) { + var val = parseInt( perc * 1000 ); + $j( '#' + eid + ' .play_head' ).slider( 'value', val ); } - //js_log('set#mv_seeker_slider_'+eid + ' perc in: ' + perc + ' * ' + $j('#mv_seeker_'+eid).width() + ' = set to: '+ val + ' - '+ Math.round(this.mv_seeker_width*perc) ); - //js_log('op:' + offset_perc + ' *('+perc+' * ' + $j('#slider_'+id).width() + ')'); + // js_log('set#mv_seeker_slider_'+eid + ' perc in: ' + perc + ' * ' + $j('#mv_seeker_'+eid).width() + ' = set to: '+ val + ' - '+ Math.round(this.mv_seeker_width*perc) ); + // js_log('op:' + offset_perc + ' *('+perc+' * ' + $j('#slider_'+id).width() + ')'); }, - highlightPlaySection:function(options){ - js_log('highlightPlaySection'); - var eid = (this.pc)?this.pc.pp.id:this.id; + highlightPlaySection:function( options ) { + js_log( 'highlightPlaySection' ); + var eid = ( this.pc ) ? this.pc.pp.id:this.id; var dur = this.getDuration(); - var hide_progress = true; - //set the left percet and update the slider: - rel_start_sec = npt2seconds( options['start']); - //remove the start_offset if relevent: - if(this.start_offset) + var hide_progress = true; + // set the left percet and update the slider: + rel_start_sec = npt2seconds( options['start'] ); + // remove the start_offset if relevent: + if ( this.start_offset ) rel_start_sec = rel_start_sec - this.start_offset - var slider_perc=0; - if( rel_start_sec <= 0 ){ - left_perc =0; + var slider_perc = 0; + if ( rel_start_sec <= 0 ) { + left_perc = 0; options['start'] = seconds2npt( this.start_offset ); - rel_start_sec=0; - this.setSliderValue( 0 , hide_progress); - }else{ - left_perc = parseInt( (rel_start_sec / dur)*100 ) ; - slider_perc = (left_perc / 100); - } + rel_start_sec = 0; + this.setSliderValue( 0 , hide_progress ); + } else { + left_perc = parseInt( ( rel_start_sec / dur ) * 100 ) ; + slider_perc = ( left_perc / 100 ); + } - js_log("slider perc:" + slider_perc); - if( ! this.isPlaying() ){ - this.setSliderValue( slider_perc , hide_progress); + js_log( "slider perc:" + slider_perc ); + if ( ! this.isPlaying() ) { + this.setSliderValue( slider_perc , hide_progress ); } - width_perc = parseInt( (( npt2seconds( options['end'] ) - npt2seconds( options['start'] ) ) / dur)*100 ) ; - if( (width_perc + left_perc) > 100 ){ - width_perc = 100 - left_perc; - } - //js_log('should hl: '+rel_start_sec+ '/' + dur + ' re:' + rel_end_sec+' lp:' + left_perc + ' width: ' + width_perc); - $j('#mv_seeker_' + eid + ' .mv_highlight').css({ - 'left' : left_perc+'%', - 'width' : width_perc+'%' - }).show(); + width_perc = parseInt( ( ( npt2seconds( options['end'] ) - npt2seconds( options['start'] ) ) / dur ) * 100 ) ; + if ( ( width_perc + left_perc ) > 100 ) { + width_perc = 100 - left_perc; + } + // js_log('should hl: '+rel_start_sec+ '/' + dur + ' re:' + rel_end_sec+' lp:' + left_perc + ' width: ' + width_perc); + $j( '#mv_seeker_' + eid + ' .mv_highlight' ).css( { + 'left' : left_perc + '%', + 'width' : width_perc + '%' + } ).show(); this.jump_time = options['start']; - this.seek_time_sec = npt2seconds( options['start']); - //trim output to - this.setStatus( gM('mwe-seek_to', seconds2npt( this.seek_time_sec ) ) ); - js_log('DO update: ' + this.jump_time); - this.updateThumbTime( rel_start_sec ); - }, - hideHighlight:function(){ - var eid = (this.pc)?this.pc.pp.id:this.id; - $j('#mv_seeker_' + eid + ' .mv_highlight').hide(); + this.seek_time_sec = npt2seconds( options['start'] ); + // trim output to + this.setStatus( gM( 'mwe-seek_to', seconds2npt( this.seek_time_sec ) ) ); + js_log( 'DO update: ' + this.jump_time ); + this.updateThumbTime( rel_start_sec ); + }, + hideHighlight:function() { + var eid = ( this.pc ) ? this.pc.pp.id:this.id; + $j( '#mv_seeker_' + eid + ' .mv_highlight' ).hide(); this.setStatus( this.getTimeReq() ); this.setSliderValue( 0 ); }, - setStatus:function(value){ - var eid = (this.pc)?this.pc.pp.id:this.id; - //update status: - $j('#' + eid + ' .time-disp').html(value); - }, + setStatus:function( value ) { + var eid = ( this.pc ) ? this.pc.pp.id:this.id; + // update status: + $j( '#' + eid + ' .time-disp' ).html( value ); + }, /** * Helper Functions for selected source - */ + */ /* * returns the selected source url for players to play */ - getURI : function( seek_time_sec ){ + getURI : function( seek_time_sec ) { return this.media_element.selected_source.getURI( this.seek_time_sec ); }, - supportsURLTimeEncoding: function(){ - //do head request if on the same domain + supportsURLTimeEncoding: function() { + // do head request if on the same domain return this.media_element.selected_source.URLTimeEncoding; } } @@ -2285,9 +2285,9 @@ embedVideo.prototype = { * @param {String} library external script containing the plugin interface code. (mv_Embed.js) * @constructor */ -function mediaPlayer(id, supported_types, library) +function mediaPlayer( id, supported_types, library ) { - this.id=id; + this.id = id; this.supported_types = supported_types; this.library = library; this.loaded = false; @@ -2300,48 +2300,48 @@ mediaPlayer.prototype = supported_types:null, library:null, loaded:false, - loading_callbacks:null, - supportsMIMEType : function(type) - { - for (var i=0; i < this.supported_types.length; i++) - if(this.supported_types[i] == type) + loading_callbacks:null, + supportsMIMEType : function( type ) + { + for ( var i = 0; i < this.supported_types.length; i++ ) + if ( this.supported_types[i] == type ) return true; return false; }, getName : function() { - return gM('mwe-ogg-player-' + this.id); - }, - load : function(callback){ - mvJsLoader.doLoad([ - this.library + 'Embed' - ],function(){ - callback(); - }); - } + return gM( 'mwe-ogg-player-' + this.id ); + }, + load : function( callback ) { + mvJsLoader.doLoad( [ + this.library + 'Embed' + ], function() { + callback(); + } ); + } } /* players and supported mime types @@note ideally we query the plugin to get what mime types it supports in practice not always reliable/avaliable */ -var flowPlayer = new mediaPlayer('flowplayer', ['video/x-flv', 'video/h264'], 'flowplayer'); -//var kplayer = new mediaPlayer('kplayer', ['video/x-flv', 'video/h264'], 'kplayer'); +var flowPlayer = new mediaPlayer( 'flowplayer', ['video/x-flv', 'video/h264'], 'flowplayer' ); +// var kplayer = new mediaPlayer('kplayer', ['video/x-flv', 'video/h264'], 'kplayer'); -var omtkPlayer = new mediaPlayer('omtkplayer',['audio/ogg'], 'omtk' ); +var omtkPlayer = new mediaPlayer( 'omtkplayer', ['audio/ogg'], 'omtk' ); -var cortadoPlayer = new mediaPlayer('cortado',['video/ogg', 'audio/ogg'],'java'); -var videoElementPlayer = new mediaPlayer('videoElement',['video/ogg', 'audio/ogg'],'native'); +var cortadoPlayer = new mediaPlayer( 'cortado', ['video/ogg', 'audio/ogg'], 'java' ); +var videoElementPlayer = new mediaPlayer( 'videoElement', ['video/ogg', 'audio/ogg'], 'native' ); var vlcMineList = ['video/ogg', 'audio/ogg', 'video/x-flv', 'video/mp4', 'video/h264']; -var vlcPlayer = new mediaPlayer('vlc-player', vlcMineList, 'vlc'); +var vlcPlayer = new mediaPlayer( 'vlc-player', vlcMineList, 'vlc' ); -//add generic -var oggPluginPlayer = new mediaPlayer('oggPlugin',['video/ogg'],'generic'); +// add generic +var oggPluginPlayer = new mediaPlayer( 'oggPlugin', ['video/ogg'], 'generic' ); -//depricate quicktime in favor of safari native -//var quicktimeMozillaPlayer = new mediaPlayer('quicktime-mozilla',['video/ogg'],'quicktime'); -//var quicktimeActiveXPlayer = new mediaPlayer('quicktime-activex',['video/ogg'],'quicktime'); +// depricate quicktime in favor of safari native +// var quicktimeMozillaPlayer = new mediaPlayer('quicktime-mozilla',['video/ogg'],'quicktime'); +// var quicktimeActiveXPlayer = new mediaPlayer('quicktime-activex',['video/ogg'],'quicktime'); -var htmlPlayer = new mediaPlayer('html',['text/html', 'image/jpeg', 'image/png', 'image/svg'], 'html'); +var htmlPlayer = new mediaPlayer( 'html', ['text/html', 'image/jpeg', 'image/png', 'image/svg'], 'html' ); /** * mediaPlayers is a collection of mediaPlayer objects supported by the client. @@ -2357,18 +2357,18 @@ mediaPlayers.prototype = { players : null, preference : null, - default_players : {}, - init : function(){ + default_players : { }, + init : function() { this.players = new Array(); this.loadPreferences(); - //set up default players order for each library type + // set up default players order for each library type this.default_players['video/x-flv'] = ['flowplayer', 'vlc']; this.default_players['video/h264'] = ['flowplayer', 'vlc']; - this.default_players['video/ogg'] = ['native','vlc','java', 'generic']; - this.default_players['application/ogg'] = ['native','vlc','java', 'generic']; - this.default_players['audio/ogg'] = ['native','vlc', 'java', 'omtk' ]; + this.default_players['video/ogg'] = ['native', 'vlc', 'java', 'generic']; + this.default_players['application/ogg'] = ['native', 'vlc', 'java', 'generic']; + this.default_players['audio/ogg'] = ['native', 'vlc', 'java', 'omtk' ]; this.default_players['video/mp4'] = ['vlc']; this.default_players['text/html'] = ['html']; @@ -2377,56 +2377,56 @@ mediaPlayers.prototype = this.default_players['image/svg'] = ['html']; }, - addPlayer : function(player, mime_type){ - for (var i =0; i < this.players.length; i++){ - if (this.players[i].id == player.id){ - if(mime_type!=null){ - //make sure the mime_type is not already there: - var add_mime = true; - for(var j=0; j < this.players[i].supported_types.length; j++ ){ - if( this.players[i].supported_types[j]== mime_type) - add_mime=false; - } - if(add_mime) + addPlayer : function( player, mime_type ) { + for ( var i = 0; i < this.players.length; i++ ) { + if ( this.players[i].id == player.id ) { + if ( mime_type != null ) { + // make sure the mime_type is not already there: + var add_mime = true; + for ( var j = 0; j < this.players[i].supported_types.length; j++ ) { + if ( this.players[i].supported_types[j] == mime_type ) + add_mime = false; + } + if ( add_mime ) this.players[i].supported_types.push( mime_type ); } return ; } } // Player not found: - if( mime_type != null ) - player.supported_types.push(mime_type); + if ( mime_type != null ) + player.supported_types.push( mime_type ); - js_log('Adding ' + player.id + ' with mime_type ' + mime_type); + js_log( 'Adding ' + player.id + ' with mime_type ' + mime_type ); this.players.push( player ); }, - getMIMETypePlayers : function(mime_type){ + getMIMETypePlayers : function( mime_type ) { var mime_players = new Array(); var _this = this; var inx = 0; - if( this.default_players[mime_type] ){ - $j.each( this.default_players[mime_type], function(d, lib){ - var library = _this.default_players[mime_type][d]; - for ( var i=0; i < _this.players.length; i++ ){ - if ( _this.players[i].library == library && _this.players[i].supportsMIMEType(mime_type) ){ - mime_players[ inx ] = _this.players[i]; + if ( this.default_players[mime_type] ) { + $j.each( this.default_players[mime_type], function( d, lib ) { + var library = _this.default_players[mime_type][d]; + for ( var i = 0; i < _this.players.length; i++ ) { + if ( _this.players[i].library == library && _this.players[i].supportsMIMEType( mime_type ) ) { + mime_players[ inx ] = _this.players[i]; inx++; } } - }); - } + } ); + } return mime_players; }, - defaultPlayer : function(mime_type){ - js_log("get defaultPlayer for " + mime_type); - var mime_players = this.getMIMETypePlayers(mime_type); - if( mime_players.length > 0) + defaultPlayer : function( mime_type ) { + js_log( "get defaultPlayer for " + mime_type ); + var mime_players = this.getMIMETypePlayers( mime_type ); + if ( mime_players.length > 0 ) { // Check for prior preference for this mime type - for( var i=0; i < mime_players.length; i++ ){ - if( mime_players[i].id==this.preference[mime_type] ) + for ( var i = 0; i < mime_players.length; i++ ) { + if ( mime_players[i].id == this.preference[mime_type] ) return mime_players[i]; - } + } // Otherwise just return the first compatible player // (it will be chosen according to the default_players list return mime_players[0]; @@ -2434,54 +2434,54 @@ mediaPlayers.prototype = js_log( 'No default player found for ' + mime_type ); return null; }, - userSelectFormat : function (mime_format){ + userSelectFormat : function ( mime_format ) { this.preference['format_prefrence'] = mime_format; this.savePreferences(); }, - userSelectPlayer : function(player_id, mime_type){ - var selected_player=null; - for(var i=0; i < this.players.length; i++){ - if(this.players[i].id == player_id){ + userSelectPlayer : function( player_id, mime_type ) { + var selected_player = null; + for ( var i = 0; i < this.players.length; i++ ) { + if ( this.players[i].id == player_id ) { selected_player = this.players[i]; - js_log('choosing ' + player_id + ' for ' + mime_type); - this.preference[mime_type]=player_id; + js_log( 'choosing ' + player_id + ' for ' + mime_type ); + this.preference[mime_type] = player_id; this.savePreferences(); break; } } - if( selected_player ){ - for(var i=0; i < mw.player_list.length; i++){ - var embed = $j('#'+mw.player_list[i]).get(0); - if(embed.media_element.selected_source && (embed.media_element.selected_source.mime_type == mime_type)) + if ( selected_player ) { + for ( var i = 0; i < mw.player_list.length; i++ ) { + var embed = $j( '#' + mw.player_list[i] ).get( 0 ); + if ( embed.media_element.selected_source && ( embed.media_element.selected_source.mime_type == mime_type ) ) { - embed.selectPlayer(selected_player); - js_log('using ' + embed.selected_player.getName() + ' for ' + embed.media_element.selected_source.getTitle()); + embed.selectPlayer( selected_player ); + js_log( 'using ' + embed.selected_player.getName() + ' for ' + embed.media_element.selected_source.getTitle() ); } } } }, loadPreferences : function() { - this.preference = new Object(); + this.preference = new Object(); // see if we have a cookie set to a clientSupported type: var cookieVal = $j.cookie( 'ogg_player_exp' ); - if (cookieVal){ - var pairs = cookieVal.split('&'); - for(var i=0; i < pairs.length; i++) + if ( cookieVal ) { + var pairs = cookieVal.split( '&' ); + for ( var i = 0; i < pairs.length; i++ ) { - var name_value = pairs[i].split('='); - this.preference[name_value[0]]=name_value[1]; - //js_log('load preference for ' + name_value[0] + ' is ' + name_value[1]); + var name_value = pairs[i].split( '=' ); + this.preference[name_value[0]] = name_value[1]; + // js_log('load preference for ' + name_value[0] + ' is ' + name_value[1]); } } }, - savePreferences : function(){ - var cookieVal = ''; - for(var i in this.preference) - cookieVal+= i + '='+ this.preference[i] + '&'; + savePreferences : function() { + var cookieVal = ''; + for ( var i in this.preference ) + cookieVal += i + '=' + this.preference[i] + '&'; - cookieVal=cookieVal.substr(0, cookieVal.length-1); - var week = 7*86400*1000; + cookieVal = cookieVal.substr( 0, cookieVal.length - 1 ); + var week = 7 * 86400 * 1000; $j.cookie( 'ogg_player_exp', cookieVal, { 'expires':week } ); } }; @@ -2494,137 +2494,137 @@ mediaPlayers.prototype = var embedTypes = { // List of players players: null, - detect_done:false, - init: function(){ - //detect supported types + detect_done:false, + init: function() { + // detect supported types this.detect(); - this.detect_done=true; + this.detect_done = true; }, clientSupports: { 'thumbnail' : true }, - supportedMimeType: function(mimetype) { - for (var i = navigator.plugins.length; i-- > 0; ) { + supportedMimeType: function( mimetype ) { + for ( var i = navigator.plugins.length; i-- > 0; ) { var plugin = navigator.plugins[i]; - if (typeof plugin[mimetype] != "undefined") + if ( typeof plugin[mimetype] != "undefined" ) return true; } return false; }, detect: function() { - js_log("running detect"); + js_log( "running detect" ); this.players = new mediaPlayers(); - //every browser supports html rendering: - this.players.addPlayer( htmlPlayer ); + // every browser supports html rendering: + this.players.addPlayer( htmlPlayer ); // In Mozilla, navigator.javaEnabled() only tells us about preferences, we need to // search navigator.mimeTypes to see if it's installed - var javaEnabled = navigator.javaEnabled(); + var javaEnabled = navigator.javaEnabled(); // Some browsers filter out duplicate mime types, hiding some plugins - var uniqueMimesOnly = $j.browser.opera || $j.browser.safari; + var uniqueMimesOnly = $j.browser.opera || $j.browser.safari; // Opera will switch off javaEnabled in preferences if java can't be found. // And it doesn't register an application/x-java-applet mime type like Mozilla does. if ( javaEnabled ) - this.players.addPlayer( cortadoPlayer ); + this.players.addPlayer( cortadoPlayer ); // ActiveX plugins - if($j.browser.msie){ + if ( $j.browser.msie ) { // check for flash - if ( this.testActiveX( 'ShockwaveFlash.ShockwaveFlash')){ - //try to get the flash version for omtk include: + if ( this.testActiveX( 'ShockwaveFlash.ShockwaveFlash' ) ) { + // try to get the flash version for omtk include: try { - a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".7"); - d = a.GetVariable("$version"); // Will crash fp6.0.21/23/29 - if (d) { - d = d.split(" ")[1].split(","); - //we need flash version 10 or greater: - if(parseInt( d[0]) >=10){ + a = new ActiveXObject( SHOCKWAVE_FLASH_AX + ".7" ); + d = a.GetVariable( "$version" ); // Will crash fp6.0.21/23/29 + if ( d ) { + d = d.split( " " )[1].split( "," ); + // we need flash version 10 or greater: + if ( parseInt( d[0] ) >= 10 ) { this.players.addPlayer( omtkPlayer ); - } - } - }catch(e) { - //failed to check for flash - } - //flowplayer has pretty good compatiablity + } + } + } catch ( e ) { + // failed to check for flash + } + // flowplayer has pretty good compatiablity // (but if we wanted to be fancy we would check for version of flash and update the mp4/h.264 support - - //this.players.addPlayer( kplayer ); - this.players.addPlayer( flowPlayer ); + + // this.players.addPlayer( kplayer ); + this.players.addPlayer( flowPlayer ); } // VLC if ( this.testActiveX( 'VideoLAN.VLCPlugin.2' ) ) - this.players.addPlayer(vlcActiveXPlayer); + this.players.addPlayer( vlcActiveXPlayer ); // Java ActiveX if ( this.testActiveX( 'JavaWebStart.isInstalled' ) ) this.players.addPlayer( cortadoPlayer ); // quicktime (currently off) - //if ( this.testActiveX( 'QuickTimeCheckObject.QuickTimeCheck.1' ) ) + // if ( this.testActiveX( 'QuickTimeCheckObject.QuickTimeCheck.1' ) ) // this.players.addPlayer(quicktimeActiveXPlayer); - } + } //