here it is ... the upload-api, script-server, js2 (javascript phase2) branch merge...
[lhc/web/wiklou.git] / js2 / mwEmbed / mv_embed.js
1 /*
2 * ~mv_embed version 1.0~
3 * for details see: http://metavid.org/wiki/index.php/Mv_embed
4 *
5 * All Metavid Wiki code is Released under the GPL2
6 * for more info visit http://metavid.org/wiki/Code
7 *
8 * @url http://metavid.org
9 *
10 * parseUri:
11 * http://stevenlevithan.com/demo/parseuri/js/
12 *
13 * config values you can manually set the location of the mv_embed folder here
14 * (in cases where media will be hosted in a different place than the embedding page)
15 *
16 */
17 //fix multiple instances of mv_embed (ie include twice from two different servers)
18 var MV_DO_INIT=true;
19 if( MV_EMBED_VERSION ){
20 MV_DO_INIT=false;
21 }
22 //used to grab fresh copies of scripts. (should be changed on commit)
23 var MV_EMBED_VERSION = '1.0r17';
24
25 /*
26 * Configuration variables (can be set from some precceding script)
27 */
28 //the name of the player skin (default is mvpcf)
29 if(!mv_skin_name)
30 var mv_skin_name = 'mvpcf';
31
32 if(!mwjQueryUiSkin)
33 var mwjQueryUiSkin = 'redmond';
34
35 //whether or not to load java from an iframe.
36 //note: this is necessary for remote embedding because of java security model)
37 if(!mv_java_iframe)
38 var mv_java_iframe = true;
39
40 //media_server mv_embed_path (the path on media servers to mv_embed for java iframe with leading and trailing slashes)
41 if(!mv_media_iframe_path)
42 var mv_media_iframe_path = '/mv_embed/';
43
44 //the default height/width of the video (if no style or width attribute provided)
45 if(!mv_default_video_size)
46 var mv_default_video_size = '400x300';
47
48 //for when useing mv_embed with script-loader in root mediawiki path
49 var mediaWiki_mvEmbed_path = 'js2/mwEmbed/';
50
51 var global_player_list = new Array(); //the global player list per page
52 var global_req_cb = new Array(); //the global request callback array
53 var _global = this; //global obj
54 var mv_init_done=false;
55 var global_cb_count =0;
56
57 /*parseUri class parses URIs:*/
58 var parseUri=function(d){var o=parseUri.options,value=o.parser[o.strictMode?"strict":"loose"].exec(d);for(var i=0,uri={};i<14;i++){uri[o.key[i]]=value[i]||""}uri[o.q.name]={};uri[o.key[12]].replace(o.q.parser,function(a,b,c){if(b)uri[o.q.name][b]=c});return uri};parseUri.options={strictMode:false,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};
59
60
61 //get mv_embed location if it has not been set
62 if( !mv_embed_path ){
63 var mv_embed_path = getMvEmbedPath();
64 }
65 jQueryUiVN = 'jquery.ui-1.7.1';
66
67
68 //setup the skin path:
69 var mv_jquery_skin_path = mv_embed_path + 'jquery/' + jQueryUiVN + '/themes/' + mwjQueryUiSkin + '/';
70 var mv_skin_img_path = mv_embed_path + 'skins/' + mv_skin_name + '/images/';
71 var mv_default_thumb_url = mv_skin_img_path + 'vid_default_thumb.jpg';
72
73
74 //init the global Msg if not already
75 if(!gMsg){var gMsg={};}
76 //laguage loader:
77 function loadGM( msgSet ){
78 for(var i in msgSet){
79 gMsg[ i ] = msgSet[i];
80 }
81 }
82
83 //all default msg in [English] should be overwritten by the CMS language msg system.
84 loadGM({
85 "loading_txt":"loading <blink>...</blink>",
86 "loading_title" : "Loading...",
87
88 "size-gigabytes" : "$1 GB",
89 "size-megabytes" : "$1 MB",
90 "size-kilobytes" : "$1 K",
91 "size-bytes" : "$1 B"
92
93 });
94
95 /**
96 * AutoLoader paths (this should mirror the file: jsAutoloadLocalClasses.php )
97 * any file _not_ listed here won't be auto-loadable
98 * @path the path to the file (or set of files) with ending slash
99 * @gClasses the set of classes
100 * if an array $j.className become jquery.className.js
101 * if an asssociative objec then key => value paris are used
102 */
103 if(typeof mvClassPaths == 'undefined')
104 mvClassPaths = {};
105
106 function lcPaths( path, gClasses , opt){
107 if(!opt)
108 opt = {};
109 if(typeof opt['j_replace'] == 'undefined')
110 opt['j_replace'] = 'jquery.';
111 if(!path)
112 path = '';
113 if(gClasses.length){
114 //do array loop:
115 for(var i=0; i<gClasses.length; i++){
116 if(typeof gClasses[i] != 'undefined'){
117 //setup normal replacement of j with jquery
118 var jsName = ( gClasses[i].substr(0,3) == '$j.' ) ? opt['j_replace'] + gClasses[i].substr(3) : gClasses[i];
119 mvClassPaths[ gClasses[i] ] = path + jsName + '.js';
120 }
121 }
122 }else{
123 //do object loop:
124 for(var i in gClasses){
125 //assume object with key:path:
126 mvClassPaths[i] = path + gClasses[ i ];
127 }
128 }
129 var cat = mvClassPaths;
130 }
131 function mvGetClassPath(k){
132 if( mvClassPaths[k] ){
133 //js_log('got classpath:' + k + ' : '+ mvClassPaths[k]);
134 return mvClassPaths[k];
135 }else{
136 return js_error('could not find path for requested class ' + k );
137 }
138 }
139 if(typeof mvCssPaths == 'undefined')
140 mvCssPaths = {};
141
142 function lcCssPath(cssSet){
143 for(var i in cssSet){
144 mvCssPaths[i]= mv_embed_path + cssSet[i];
145 }
146 }
147 //core and (non-standard named files relative to class the init):
148 lcPaths('',{
149 'mv_embed' : 'mv_embed.js',
150 'window.jQuery' : 'jquery/jquery-1.3.2.js',
151 '$j.fn.pngFix' : 'jquery/plugins/jquery.pngFix.js',
152 '$j.fn.autocomplete': 'jquery/plugins/jquery.autocomplete.js',
153 '$j.fn.hoverIntent' : 'jquery/plugins/jquery.hoverIntent.js',
154 '$j.fn.datePicker' : 'jquery/plugins/jquery.datePicker.js',
155 '$j.ui' : 'jquery/jquery.ui-1.7.1/ui/ui.core.js',
156 '$j.fn.ColorPicker' : 'libClipEdit/colorpicker/js/colorpicker.js',
157 '$j.Jcrop' : 'libClipEdit/Jcrop/js/jquery.Jcrop.js'
158 });
159 //query plugins
160 lcPaths( 'jquery/plugins/', [
161 '$j.secureEvalJSON',
162 '$j.cookie',
163 '$j.contextMenu',
164 ]);
165 //jquery ui
166 lcPaths('jquery/jquery.ui-1.7.1/ui/', [
167 '$j.effects.blind',
168 '$j.effects.drop',
169 '$j.effects.pulsate',
170 '$j.effects.transfer',
171 '$j.ui.droppable',
172 '$j.ui.slider',
173 '$j.effects.bounce',
174 '$j.effects.explode',
175 '$j.effects.scale',
176 '$j.ui.datepicker',
177 '$j.ui.progressbar',
178 '$j.ui.sortable',
179 '$j.effects.clip',
180 '$j.effects.fold',
181 '$j.effects.shake',
182 '$j.ui.dialog',
183 '$j.ui.resizable',
184 '$j.ui.tabs',
185 '$j.effects.core',
186 '$j.effects.highlight',
187 '$j.effects.slide',
188 '$j.ui.accordion',
189 '$j.ui.draggable',
190 '$j.ui.selectable',
191 ],
192 {'j_replace':''});
193 //add mediaLibs
194 lcPaths('libAddMedia/', [
195 'mvFirefogg',
196 'mvAdvFirefogg',
197 'mvBaseUploadInterface',
198 'remoteSearchDriver',
199 'seqRemoteSearchDriver',
200 ]);
201 //search libs:
202 lcPaths('libAddMedia/searchLibs/', [
203 'baseRemoteSearch',
204 'mediaWikiSearch',
205 'metavidSearch',
206 'archiveOrgSearch',
207 'baseRemoteSearch'
208 ]);
209 //libclip edit
210 lcPaths( 'libClipEdit/', [
211 'mvClipEdit'
212 ])
213 //libEmbedObj (we could load all these clasess in embedVideo):
214 lcPaths( 'libEmbedVideo/', [
215 'embedVideo',
216 'flashEmbed',
217 'genericEmbed',
218 'htmlEmbed',
219 'javaEmbed',
220 'nativeEmbed',
221 'quicktimeEmbed',
222 'vlcEmbed'
223 ])
224 //libSequencer:
225 lcPaths( 'libSequencer/', [
226 'mvPlayList',
227 'mvSequencer',
228 'mvTimedEffectsEdit'
229 ])
230 //libTimedText:
231 lcPaths( 'libTimedText/', [
232 'mvTextInterface'
233 ]);
234
235 //depencency mapping for css files for self contained included plugins:
236 lcCssPath({
237 '$j.Jcrop' : 'libClipEdit/Jcrop/css/jquery.Jcrop.css',
238 '$j.fn.ColorPicker': 'libClipEdit/colorpicker/css/colorpicker.css'
239 })
240
241 /**
242 * Language Functions:
243 *
244 * These functions try to losely mirro the functionality of Language.php in mediaWiki
245 */
246 function gM( key , args ) {
247 var ms ='';
248 if ( key in gMsg ) {
249 ms = gMsg[ key ];
250 if(typeof args == 'object' || typeof args == 'array'){
251 for(var v in args){
252 //msg test replace arguments start at 1 insted of zero:
253 var rep = '\$'+ ( parseInt(v) + 1 );
254 ms = ms.replace( rep, args[v]);
255 }
256 }else if(typeof args =='string' || typeof args =='number'){
257 ms = ms.replace(/\$1/, args);
258 }
259 return ms;
260 } else{
261 //key is missing return indication:
262 return '&lt;' + key + '&gt;';
263 }
264 }
265 /*
266 * msgSet is either a string corresponding to a single msg to load
267 * or msgSet is an array with set of msg to load
268 */
269 function gMsgLoadRemote(msgSet, callback){
270 var ammessages = '';
271 if(typeof msgSet == 'object' ){
272 for(var i in msgSet){
273 ammessages += msgSet[i] + '|';
274 }
275 }else if(typeof msgSet == 'string'){
276 ammessages += msgSet;
277 }
278 if(ammessages == ''){
279 js_log('gMsgLoadRemote::no msg set requested');
280 return false;
281 }
282 do_api_req({
283 'data':{
284 'meta':'allmessages',
285 'ammessages':ammessages
286 }
287 },function(data){
288 if(data.query.allmessages){
289 var msgs = data.query.allmessages;
290 for(var i in msgs){
291 var ld = {};
292 ld[ msgs[i]['name'] ] = msgs[i]['*'];
293 loadGM( ld );
294 }
295 }
296 //load the result into local msg var
297 callback();
298 });
299 }
300
301 /**
302 * Format a size in bytes for output, using an appropriate
303 * unit (B, KB, MB or GB) according to the magnitude in question
304 *
305 * @param size Size to format
306 * @return string Plain text (not HTML)
307 */
308 function formatSize( size ) {
309 // For small sizes no decimal places necessary
310 var round = 0;
311 var msg = '';
312 if( size > 1024 ) {
313 size = size / 1024;
314 if( size > 1024 ) {
315 size = size / 1024;
316 // For MB and bigger two decimal places are smarter
317 round = 2;
318 if( size > 1024 ) {
319 size = size / 1024;
320 msg = 'size-gigabytes';
321 } else {
322 msg = 'size-megabytes';
323 }
324 } else {
325 msg = 'size-kilobytes';
326 }
327 } else {
328 msg = 'size-bytes';
329 }
330 //javascript does not let you do precession points in rounding
331 var p = Math.pow(10,round);
332 var size = Math.round( size * p ) / p;
333 //@@todo we need a formatNum and we need to request some special packaged info to deal with that case.
334 return gM( msg , size );
335 }
336
337 //gets the loading image:
338 function mv_get_loading_img( style , class_attr ){
339 var style_txt = (style)?style:'';
340 var class_attr = (class_attr)?'class="'+class_attr+'"':'class="mv_loading_img"';
341 return '<div '+class_attr+' style="' + style +'"></div>';
342 }
343
344 function mv_set_loading(target, load_id){
345 var id_attr = ( load_id )?' id="' + load_id + '" ':'';
346 $j(target).append('<div '+id_attr+' style="position:absolute;top:0px;left:0px;height:100%;width:100%;'+
347 'background-color:#FFF;">' +
348 mv_get_loading_img('top:30px;left:30px') +
349 '</div>');
350 }
351
352 /**
353 * mvJsLoader class handles initialization and js file loads
354 */
355 var mvJsLoader = {
356 libreq : {},
357 libs : {},
358 //base lib flags:
359 onReadyEvents:new Array(),
360 doneReadyEvents:false,
361 jQueryCheckFlag:false,
362 //to keep consistency across threads:
363 ptime:0,
364 ctime:0,
365 load_error:false, //load error flag (false by default)
366 load_time:0,
367 callbacks:new Array(),
368 cur_path: null,
369 missing_path : null,
370 doLoad:function(loadLibs, callback){
371 this.ctime++;
372 if( loadLibs && loadLibs.length!=0 ){ //setup this.libs:
373
374 //first check if we already have this lib loaded
375 var all_libs_loaded=true;
376 for(var i=0; i< loadLibs.length; i++){
377 //check if the lib is already loaded:
378 if( ! this.checkObjPath( loadLibs[i] ) ){
379 all_libs_loaded=false;
380 }
381 }
382 if( all_libs_loaded ){
383 js_log('all libs already loaded skipping... load req');
384 callback();
385 return ;
386 }
387 //do a check for any css we may need and get it:
388 for(var i=0; i< loadLibs.length; i++){
389 if( typeof mvCssPaths[ loadLibs[i] ] != 'undefined' ){
390 loadExternalCss( mvCssPaths[ loadLibs[i] ]);
391 }
392 }
393
394 //check if we should use the script loader to combine all the requests into one:
395 if( typeof mwSlScript != 'undefined' ){
396 var class_set = '';
397 var last_class = '';
398 var coma = '';
399 for(var i=0; i< loadLibs.length; i++){
400 var curLib = loadLibs[i];
401 //only add if not included yet:
402 if( ! this.checkObjPath( curLib ) ){
403 class_set+=coma + curLib ;
404 last_class=curLib;
405 coma=',';
406 }
407 }
408 var puri = parseUri( getMvEmbedURL() );
409 if( (getMvEmbedURL().indexOf('://')!=-1) && puri.host != parseUri( document.URL).host){
410 mwSlScript = puri.protocol + '://' + puri.authority + mwSlScript;
411 }
412
413 var dbug_attr = (puri.queryKey['debug'])?'&debug=true':'';
414 this.libs[ last_class ] = mwSlScript + '?class=' + class_set +
415 '&urid=' + getMvUniqueReqId() + dbug_attr;
416
417 }else{
418 //do many requests:
419 for(var i=0; i< loadLibs.length; i++){
420 var curLib = loadLibs[i];
421 if(curLib){
422 var libLoc = mvGetClassPath(curLib);
423 // do a direct load of the file (pass along unique request id from request or mv_embed Version )
424 var qmark = (libLoc.indexOf('?')!==true)?'?':'&';
425 this.libs[curLib] = mv_embed_path + libLoc + qmark + 'urid='+ getMvUniqueReqId();
426 }
427 }
428 }
429 }
430 if( callback ){
431 this.callbacks.push(callback);
432 }
433 if( this.checkLoading() ){
434 if( this.load_time++ > 1000){ //time out after ~80seconds
435 js_error( gM('error_load_lib') + this.missing_path );
436 this.load_error=true;
437 }else{
438 setTimeout( 'mvJsLoader.doLoad()', 20 );
439 }
440 }else{
441 //js_log('checkLoading passed run callbacks');
442 //only do callback if we are in the same instance (weird concurency issue)
443 var cb_count=0;
444 for(var i=0; i < this.callbacks.length; i++)
445 cb_count++;
446 //js_log('REST LIBS: loading is: '+ loading + ' run callbacks: '+cb_count +' p:'+ this.ptime +' c:'+ this.ctime);
447 //reset the libs
448 this.libs={};
449 //js_log('done loading do call: ' + this.callbacks[0] );
450 while( this.callbacks.length !=0 ){
451 if( this.ptime== ( this.ctime-1) ){ //enforce thread consistency
452 this.callbacks.pop()();
453 //func = this.callbacks.pop();
454 //js_log(' run: '+this.ctime+ ' p: ' + this.ptime + ' ' +loading+ ' :'+ func);
455 //func();
456 }else{
457 //re-issue doLoad ( ptime will be set to ctime so we should catch up)
458 setTimeout( 'mvJsLoader.doLoad()', 25 );
459 break;
460 }
461 }
462 }
463 this.ptime=this.ctime;
464 },
465 doLoadFullPaths:function(loadObj, callback){
466
467 },
468 doLoadDepMode:function(loadChain, callback){
469 //firefox executes js ~in-order of it being included~ so just directly issue request:
470 if( $j.browser.firefox ){
471 var loadSet = [];
472 for(var i=0; i< loadChain.length;i++){
473 for(var j=0;j<loadChain[i].length;j++){
474 loadSet.push(loadChain[i][j]);
475 }
476 }
477 mvJsLoader.doLoad(loadSet, callback);
478 }else{
479 //safari and IE tend to execute out of order so load with dependenciy checks
480 mvJsLoader.doLoad(loadChain.shift(),function(){
481 if(loadChain.length!=0){
482 mvJsLoader.doLoadDepMode(loadChain, callback);
483 }else{
484 callback();
485 }
486 });
487 } },
488 checkLoading:function(){
489 var loading=0;
490 var i=null;
491 for(var i in this.libs){ //for in loop oky on object
492 if( !this.checkObjPath( i ) ){
493 if(!this.libreq[i]){
494 loadExternalJs( this.libs[i] );
495 }
496
497 this.libreq[i]=1;
498 //js_log("has not yet loaded: " + i);
499 loading=1;
500 }
501 }
502 return loading;
503 },
504 checkObjPath:function( libVar ){
505 if(!libVar)
506 return false;
507 var objPath = libVar.split('.')
508 var cur_path ='';
509 for(var p=0; p < objPath.length; p++){
510 cur_path = (cur_path=='')?cur_path+objPath[p]:cur_path+'.'+objPath[p];
511 eval( 'var ptest = typeof ( '+ cur_path + ' ); ');
512 if( ptest == 'undefined'){
513 this.missing_path = cur_path;
514 return false;
515 }
516 }
517 this.cur_path = cur_path;
518 return true;
519 },
520 /**
521 * checks for jQuery and adds the $j noConflict var
522 */
523 jQueryCheck:function(callback){
524 //skip stuff if $j is already loaded:
525 if(_global['$j'] && callback)
526 callback();
527 var _this = this;
528 //load jquery
529 _this.doLoad([
530 'window.jQuery'
531 ],function(){
532 _global['$j'] = jQuery.noConflict();
533 //set up ajax to not send dynamic urls for loading scripts (we control that with the scriptLoader)
534 $j.ajaxSetup({
535 cache: true
536 });
537 js_log('jquery loaded');
538 //setup mvEmbed jquery bindigns:
539 mv_jqueryBindings();
540 //run the callback
541 if(callback){
542 callback();
543 }
544 });
545 },
546 embedVideoCheck:function( callback ){
547 var _this = this;
548 js_log('embedVideoCheck:');
549 //issue a style sheet request get both mv_embed and jquery styles:
550 loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' );
551 loadExternalCss( mv_embed_path + 'skins/'+mv_skin_name+'/styles.css');
552
553 //make sure we have jQuery
554 _this.jQueryCheck(function(){
555 var depReq = [
556 [
557 '$j.ui',
558 'embedVideo',
559 '$j.cookie'
560 ],
561 [
562 '$j.ui.slider',
563 ]
564 ];
565 //add png fix if needed:
566 if($j.browser.msie || $j.browser.version < 7)
567 depReq[0].push( '$j.fn.pngFix' );
568
569 _this.doLoadDepMode(depReq,function(){
570 embedTypes.init();
571 callback();
572 });
573 });
574 },
575 addLoadEvent:function(fn){
576 this.onReadyEvents.push(fn);
577 },
578 //checks the jQuery flag (this way when remote embeding we don't load jQuery
579 // unless mwAddOnloadHook was used or there is video on the page
580 runQuededFunctions:function(){
581 var _this = this;
582 this.doneReadyEvents=true;
583 if(this.jQueryCheckFlag){
584 this.jQueryCheck(function(){
585 _this.runReadyEvents();
586 });
587 }else{
588 this.runReadyEvents();
589 }
590 },
591 runReadyEvents:function(){
592 js_log("runReadyEvents");
593 while( this.onReadyEvents.length ){
594 this.onReadyEvents.shift()();
595 }
596 }
597
598 }
599 //load an external JS (similar to jquery .require plugin)
600 //but checks for object availability rather than load state
601
602 /*********** INITIALIZATION CODE *************
603 * this will get called when DOM is ready
604 *********************************************/
605 /* jQuery .ready does not work when jQuery is loaded dynamically
606 * for an example of the problem see:1.1.3 working:http://pastie.caboo.se/92588
607 * and >= 1.1.4 not working: http://pastie.caboo.se/92595
608 * $j(document).ready( function(){ */
609 function mwdomReady(force){
610 js_log('f:mwdomReady:');
611 if( !force && mv_init_done ){
612 js_log("mv_init_done already done do nothing...");
613 return false;
614 }
615 mv_init_done=true;
616 //handle the execution of Queded function with jQuery "ready"
617
618 //check if this page does have video or playlist
619 if(document.getElementsByTagName("video").length!=0 ||
620 document.getElementsByTagName("audio").length!=0 ||
621 document.getElementsByTagName("playlist").length!=0){
622 js_log('we have things to rewrite');
623 //load libs and proccess:
624 mvJsLoader.embedVideoCheck(function(){
625 //run any queded global events:
626 mv_video_embed( function(){
627 mvJsLoader.runQuededFunctions();
628 });
629 });
630 }else{
631 //if we already have jQuery make sure its loaded into its proper context $j
632 //run any queded global events:
633 mvJsLoader.runQuededFunctions();
634 }
635 }
636 //mwAddOnloadHook: ensure jQuery and the DOM are ready:
637 function mwAddOnloadHook( func ) {
638 //make sure the skin/style sheets are avaliable always:
639 loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' );
640 loadExternalCss( mv_embed_path + 'skins/'+mv_skin_name+'/styles.css');
641
642 //if we have already run the dom ready just run the function directly:
643 if( mvJsLoader.doneReadyEvents ){
644 //make sure jQuery is there:
645 mvJsLoader.jQueryCheck(function(){
646 func();
647 });
648 }else{
649 //if using mwAddOnloadHook we need to get jQuery into place (if its not already included)
650 mvJsLoader.jQueryCheckFlag = true;
651 mvJsLoader.addLoadEvent( func );
652 };
653 }
654 /*
655 * this function allows for targeted rewriting
656 */
657 function rewrite_by_id( vid_id, ready_callback ){
658 js_log('f:rewrite_by_id: ' + vid_id);
659 //force a recheck of the dom for playlist or video element:
660 mvJsLoader.embedVideoCheck(function(){
661 mv_video_embed(ready_callback, vid_id );
662 });
663 }
664 //depricated in favor of updates to oggHanlder
665 function rewrite_for_oggHanlder( vidIdList ){
666 for(var i = 0; i < vidIdList.length ; i++){
667 var vidId = vidIdList[i];
668 js_log('looking at vid: ' + i +' ' + vidId);
669 //grab the thumbnail and src video
670 var pimg = $j('#'+vidId + ' img');
671 var poster_attr = 'poster = "' + pimg.attr('src') + '" ';
672 var pwidth = pimg.attr('width');
673 var pheight = pimg.attr('height');
674
675 var type_attr = '';
676 //check for audio
677 if( pwidth=='22' && pheight=='22'){
678 pwidth='400';
679 pheight='300';
680 type_attr = 'type="audio/ogg"';
681 poster_attr = '';
682 }
683
684 //parsed values:
685 var src = '';
686 var duration = '';
687
688 var re = new RegExp( /videoUrl(&quot;:?\s*)*([^&]*)/ );
689 src = re.exec( $j('#'+vidId).html() )[2];
690
691 var re = new RegExp( /length(&quot;:?\s*)*([^&]*)/ );
692 duration = re.exec( $j('#'+vidId).html() )[2];
693
694 var re = new RegExp( /offset(&quot;:?\s*)*([^&]*)/ );
695 offset = re.exec( $j('#'+vidId).html() )[2];
696 var offset_attr = (offset)? 'startOffset="'+ offset + '"': '';
697
698 if( src ){
699 //replace the top div with mv_embed based player:
700 var vid_html = '<video id="vid_' + i +'" '+
701 'src="' + src + '" ' +
702 poster_attr + ' ' +
703 type_attr + ' ' +
704 offset_attr + ' ' +
705 'duration="' + duration + '" ' +
706 'style="width:' + pwidth + 'px;height:' +
707 pheight + 'px;"></video>';
708 //js_log("video html: " + vid_html);
709 $j('#'+vidId).html( vid_html );
710 }
711
712 //rewrite that video id:
713 rewrite_by_id('vid_' + i);
714 }
715 }
716
717
718 /*********** INITIALIZATION CODE *************
719 * set DOM ready callback to init_mv_embed
720 *********************************************/
721 // for Mozilla browsers
722 if (document.addEventListener ) {
723 document.addEventListener("DOMContentLoaded", function(){mwdomReady()}, false);
724 }else{
725 //backup "onload" method in case on DOMContentLoaded does not exist
726 window.onload = function(){ mwdomReady() };
727 }
728 /*
729 * should depreciate and use jquery.ui.dialog instead
730 */
731 function mv_write_modal(content, speed){
732 $j('#modalbox,#mv_overlay').remove();
733 $j('body').append('<div id="modalbox" style="background:#DDD;border:3px solid #666666;font-size:115%;'+
734 'top:30px;left:20px;right:20px;bottom:30px;position:fixed;z-index:100;">'+
735 content +
736 '</div>'+
737 '<div id="mv_overlay" style="background:#000;cursor:wait;height:100%;left:0;position:fixed;'+
738 'top:0;width:100%;z-index:5;filter:alpha(opacity=60);-moz-opacity: 0.6;'+
739 'opacity: 0.6;"/>');
740 $j('#modalbox,#mv_overlay').show( speed );
741 }
742 function mv_remove_modal(speed){
743 $j('#modalbox,#mv_overlay').remove( speed);
744 }
745
746 /*
747 * stores all the mwEmbed jQuery specific bindings
748 * (setup after jQuery is avaliable)
749 * lets you call rewrites in a jquery "way"
750 *
751 * @@ eventually we should refactor mwCode over to jQuery style plugins
752 * and mv_embed.js will just hanndle dependency mapping and loading.
753 *
754 */
755 function mv_jqueryBindings(){
756 js_log('mv_jqueryBindings');
757 (function($) {
758
759 $.fn.addMediaWiz = function( iObj, callback ){
760 //first set the cursor for the button to "loading"
761 $j(this.selector).css('cursor','wait').attr('title', gM('loading_title'));
762
763 iObj['target_invocation'] = this.selector;
764
765 //load the mv_embed_base skin:
766 loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' );
767 loadExternalCss( mv_embed_path + 'skins/'+mv_skin_name+'/styles.css' );
768 //load all the req libs:
769 mvJsLoader.jQueryCheck(function(){
770 //load with staged dependeinces (for ie and safari that don't execute in order)
771 mvJsLoader.doLoadDepMode([
772 [ 'remoteSearchDriver',
773 '$j.cookie',
774 '$j.ui'
775 ],[
776 '$j.ui.resizable',
777 '$j.ui.draggable',
778 '$j.ui.dialog',
779 '$j.ui.tabs',
780 '$j.ui.sortable'
781 ]
782 ], function(){
783 iObj['instance_name']= 'rsdMVRS';
784 _global['rsdMVRS'] = new remoteSearchDriver( iObj );
785 if( callback ){
786 callback( _global['rsdMVRS'] );
787 }
788 });
789 });
790 }
791 $.fn.sequencer = function( iObj, callback){
792 //debugger;
793 iObj['target_sequence_container'] = this.selector;
794 //issue a request to get the css file (if not already included):
795 loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css');
796 loadExternalCss( mv_embed_path+'skins/'+mv_skin_name+'/mv_sequence.css');
797 //make sure we have the required mv_embed libs (they are not loaded when no video element is on the page)
798 mvJsLoader.embedVideoCheck(function(){
799 //load playlist object and then jquery ui stuff:
800 mvJsLoader.doLoadDepMode([
801 [
802 'mvPlayList',
803 '$j.ui',
804 '$j.contextMenu',
805 '$j.secureEvalJSON',
806 'mvSequencer'
807 ],
808 [
809 '$j.ui.accordion',
810 '$j.ui.dialog',
811 '$j.ui.droppable',
812 '$j.ui.draggable',
813 '$j.ui.progressbar',
814 '$j.ui.sortable',
815 '$j.ui.resizable',
816 '$j.ui.slider',
817 '$j.ui.tabs'
818 ]
819 ], function(){
820 js_log('calling new mvSequencer');
821 //init the sequence object (it will take over from there) no more than one mvSeq obj for now:
822 if(!_global['mvSeq']){
823 _global['mvSeq'] = new mvSequencer(iObj);
824 }else{
825 js_log('mvSeq already init');
826 }
827 });
828 });
829 }
830 /*
831 * the firefogg jquery function:
832 * @@note this firefogg envocation could be made to work more like real jquery plugins
833 */
834 $.fn.firefogg = function( iObj, callback ) {
835 if(!iObj)
836 iObj={};
837 //add base theme css:
838 loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css');
839 loadExternalCss( mv_embed_path + 'skins/'+mv_skin_name+'/styles.css' );
840
841 //check if we already have firefogg loaded (the call just updates properties for that element)
842 var sElm = $j(this.selector).get(0);
843 if(sElm['firefogg']){
844 if(sElm['firefogg']=='loading'){
845 js_log("Error: called firefogg operations on Firefogg selector that is not done loading");
846 return false;
847 }
848 //update properties:
849 for(var i in iObj){
850 js_log("firefogg::updated: "+ i + ' to '+ iObj[i]);
851 sElm['firefogg'][i] = iObj[i];
852 }
853 return sElm['firefogg'];
854 }else{
855 //avoid concurency
856 sElm['firefogg'] = 'loading';
857 }
858 //add the selector:
859 iObj['selector'] = this.selector;
860
861 var loadSet = [
862 [
863 'mvBaseUploadInterface',
864 'mvFirefogg',
865 '$j.ui'
866 ],
867 [
868 '$j.ui.progressbar',
869 '$j.ui.dialog'
870 ]
871 ];
872 if( iObj.encoder_interface ){
873 loadSet.push([
874 'mvAdvFirefogg',
875 '$j.cookie',
876 '$j.ui.accordion',
877 '$j.ui.slider',
878 '$j.ui.datepicker'
879 ]);
880 }
881 //make sure we have everything loaded that we need:
882 mvJsLoader.doLoadDepMode( loadSet, function(){
883 js_log('firefogg libs loaded. target select:' + iObj.selector);
884 //select interface provicer based on if we want to include the encoder interface or not:
885 if(iObj.encoder_interface){
886 var myFogg = new mvAdvFirefogg( iObj );
887 }else{
888 var myFogg = new mvFirefogg( iObj );
889 }
890 if(myFogg){
891 myFogg.doRewrite( callback );
892 var selectorElement = $j( iObj.selector ).get(0);
893 selectorElement['firefogg']=myFogg;
894 }
895 });
896 }
897
898 $.fn.baseUploadInterface = function(iObj){
899 mvJsLoader.doLoad([
900 'mvBaseUploadInterface',
901 '$j.ui',
902 '$j.ui.progressbar',
903 '$j.ui.dialog'
904 ],function(){
905 myUp = new mvBaseUploadInterface( iObj );
906 myUp.setupForm();
907 });
908 }
909
910 //shortcut to a themed button:
911 $.btnHtml = function(msg, className, iconId, opt){
912 if(!opt)
913 opt = {};
914 var href = (opt.href)?opt.href:'#';
915 var target_attr = (opt.target)?' target="' + opt.target + '" ':'';
916 var style_attr = (opt.style)?' style="'+opt.style +'" ':'';
917 return '<a href="' + href + '" ' + target_attr + style_attr +' class="ui-state-default ui-corner-all ui-icon_link ' +
918 className + '"><span class="ui-icon ui-icon-' + iconId + '" />' +
919 msg + '</a>';
920 }
921 //shortcut to bind hover state:
922 $.fn.btnBind = function(){
923 $j(this).hover(
924 function(){
925 $j(this).addClass('ui-state-hover');
926 },
927 function(){
928 $j(this).removeClass('ui-state-hover');
929 }
930 )
931 return this;
932 }
933
934 })(jQuery);
935 }
936 /*
937 * utility functions:
938 */
939 //simple url re-writer for rewriting urls (could probably be refactored into an inline regular expresion)
940 function getURLParamReplace( url, opt ){
941 var pSrc = parseUri( url );
942 if(pSrc.protocol != '' ){
943 var new_url = pSrc.protocol +'://'+ pSrc.authority + pSrc.path +'?';
944 }else{
945 var new_url = pSrc.path +'?';
946 }
947 var amp = '';
948 for(var key in pSrc.queryKey){
949 var val = pSrc.queryKey[ key ];
950 //do override if requested
951 if( opt[ key ] )
952 val = opt[ key ];
953 new_url+= amp + key + '=' + val;
954 amp = '&';
955 };
956 //add any vars that did were not originally there:
957 for(var i in opt){
958 if(!pSrc.queryKey[i]){
959 new_url+=amp + i + '=' + opt[i];
960 amp = '&';
961 }
962 }
963 return new_url;
964 }
965 /**
966 * seconds2npt given a float seconds returns npt format response:
967 * @param float seconds
968 * @param boolean if we should show ms or not.
969 */
970 function seconds2npt(sec, show_ms){
971 if( isNaN( sec ) ){
972 js_log("warning: trying to get npt time on NaN:" + sec);
973 return '0:0:0';
974 }
975 var hours = Math.floor(sec/ 3600);
976 var minutes = Math.floor((sec/60) % 60);
977 var seconds = sec % 60;
978 //round the second amount requested significant digits
979 if(show_ms){
980 seconds = Math.round( seconds * 1000 ) / 1000;
981 }else{
982 seconds = Math.round( seconds );
983 }
984 if(seconds <10 )
985 seconds = '0'+ seconds;
986 if(minutes < 10 )
987 minutes = '0' + minutes;
988
989 return hours+":"+minutes+":"+seconds;
990 }
991 /*
992 * takes hh:mm:ss,ms or hh:mm:ss.ms input returns number of seconds
993 */
994 function npt2seconds( npt_str ){
995 if(!npt_str){
996 //js_log('npt2seconds:not valid ntp:'+ntp);
997 return false;
998 }
999 //strip npt: time definition if present
1000 npt_str = npt_str.replace('npt:', '');
1001
1002 times = npt_str.split(':');
1003 if(times.length!=3){
1004 js_log('error: npt2seconds on ' + npt_str);
1005 return false;
1006 }
1007 //sometimes the comma is used inplace of pereid for ms
1008 times[2] = times[2].replace(/,\s?/,'.');
1009 //return seconds float (ie take seconds float value if present):
1010 return parseInt(times[0]*3600)+parseInt(times[1]*60)+parseFloat(times[2]);
1011 }
1012
1013 //does a remote or local api request based on request url
1014 //@param options: url, data, cbParam, callback
1015 function do_api_req( options, callback ){
1016 if(typeof options.data != 'object'){
1017 return js_error('Error: request paramaters must be an object');;
1018 }
1019 //gennerate the url if its missing:
1020 if( typeof options.url == 'undefined' ){
1021 if(!wgServer || ! wgScriptPath){
1022 return js_error('Error: no api url for api request');;
1023 }
1024 if (wgServer && wgScript)
1025 options.url = wgServer + wgScript;
1026 //update to api.php (if index.php was in the wgScript path):
1027 options.url = options.url.replace(/index.php/, 'api.php');
1028 }
1029 if( typeof options.data == 'undefined' )
1030 options.data = {};
1031
1032 //force format to json (if not already set)
1033 options.data['format'] = 'json';
1034
1035 //if action not set assume query
1036 if(!options.data['action'])
1037 options.data['action']='query';
1038
1039 js_log('do api req: ' + options.url +'?' + jQuery.param(options.data) );
1040 //build request string:
1041 if( parseUri( document.URL ).host == parseUri( options.url ).host ){
1042 //local request do api request directly
1043 $j.ajax({
1044 type: "POST",
1045 url: options.url,
1046 data: options.data,
1047 dataType:'json', //api requests _should_ always return JSON data:
1048 async: false,
1049 success:function(data){
1050 callback( data );
1051 },
1052 error:function(e){
1053 js_error( ' error' + e +' in getting: ' + options.url);
1054 }
1055 });
1056 }else{
1057 //set the callback param if not already set:
1058 if( typeof options.jsonCB == 'undefined')
1059 options.jsonCB = 'callback';
1060
1061 var req_url = options.url;
1062 var paramAnd = (req_url.indexOf('?')==-1)?'?':'&';
1063 //put all the values into the GET req:
1064 for(var i in options.data){
1065 req_url += paramAnd + encodeURIComponent( i ) + '=' + encodeURIComponent( options.data[i] );
1066 paramAnd ='&';
1067 }
1068 var fname = 'mycpfn_' + ( global_cb_count++ );
1069 _global[ fname ] = callback;
1070 req_url += '&' + options.jsonCB + '=' + fname;
1071 loadExternalJs( req_url );
1072 }
1073 }
1074 //grab wiki form error for wiki html page proccessing (should be depricated)
1075 function grabWikiFormError ( result_page ){
1076 var res = {};
1077 sp = result_page.indexOf('<span class="error">');
1078 if(sp!=-1){
1079 se = result_page.indexOf('</span>', sp);
1080 res.error_txt = result_page.substr(sp, (sp-se)) + '</span>';
1081 }else{
1082 //look for warning:
1083 sp = result_page.indexOf('<ul class="warning">')
1084 if(sp != -1){
1085 se = result_page.indexOf('</ul>', sp);
1086 res.error_txt = result_page.substr(sp, (se-sp)) + '</ul>';
1087 //try and add the ignore form item:
1088 sfp = result_page.indexOf('<form method="post"');
1089 if(sfp!=-1){
1090 sfe = result_page.indexOf('</form>', sfp);
1091 res.form_txt = result_page.substr(sfp, ( sfe - sfp )) + '</form>';
1092 }
1093 }else{
1094 //one more error type check:
1095 sp = result_page.indexOf('class="mw-warning-with-logexcerpt">')
1096 if(sp!=-1){
1097 se = result_page.indexOf('</div>', sp);
1098 res.error_txt = result_page.substr(sp, ( se - sp )) + '</div>';
1099 }
1100 }
1101 }
1102 return res;
1103 }
1104 //do a "normal" request
1105 function do_request(req_url, callback){
1106 js_log('do_request::req_url:' + req_url + ' != ' + parseUri( req_url).host);
1107 //if we are doing a request to the same domain or relative link do a normal GET:
1108 if( parseUri(document.URL).host == parseUri(req_url).host ||
1109 req_url.indexOf('://') == -1 ){ //relative url
1110 //do a direct request:
1111 $j.ajax({
1112 type: "GET",
1113 url:req_url,
1114 async: false,
1115 success:function(data){
1116 callback( data );
1117 }
1118 });
1119 }else{
1120 //get data via DOM injection with callback
1121 global_req_cb.push(callback);
1122 //prepend json_ to feed_format if not already requesting json format
1123 if( req_url.indexOf("feed_format=")!=-1 && req_url.indexOf("feed_format=json")==-1)
1124 req_url = req_url.replace(/feed_format=/, 'feed_format=json_');
1125 loadExternalJs(req_url+'&cb=mv_jsdata_cb&cb_inx='+(global_req_cb.length-1));
1126 }
1127 }
1128
1129 function mv_jsdata_cb(response){
1130 js_log('f:mv_jsdata_cb:'+ response['cb_inx']);
1131 //run the callback from the global req cb object:
1132 if( !global_req_cb[response['cb_inx']] ){
1133 js_log('missing req cb index');
1134 return false;
1135 }
1136 if( !response['pay_load'] ){
1137 js_log("missing pay load");
1138 return false;
1139 }
1140 //switch on content type:
1141 switch(response['content-type']){
1142 case 'text/plain':
1143 break;
1144 case 'text/xml':
1145 if(typeof response['pay_load'] == 'string'){
1146 //js_log('load string:'+"\n"+ response['pay_load']);
1147 //debugger;
1148 //attempt to parse as xml for IE
1149 if( $j.browser.msie ){
1150 var xmldata=new ActiveXObject("Microsoft.XMLDOM");
1151 xmldata.async="false";
1152 xmldata.loadXML(response['pay_load']);
1153 }else{ //for others (firefox, safari etc)
1154 try{
1155 var xmldata = (new DOMParser()).parseFromString(response['pay_load'], "text/xml");
1156 }catch(e) {
1157 js_log('XML parse ERROR: ' + e.message);
1158 }
1159 }
1160 //@@todo hanndle xml parser errors
1161 if(xmldata)response['pay_load']=xmldata;
1162 }
1163 break
1164 default:
1165 js_log('bad response type' + response['content-type']);
1166 return false;
1167 break;
1168 }
1169 global_req_cb[response['cb_inx']]( response['pay_load'] );
1170 }
1171 //load external js via dom injection
1172 function loadExternalJs( url ){
1173 js_log('load js: '+ url);
1174 //if(window['$j']) //use jquery call:
1175 /*$j.ajax({
1176 type: "GET",
1177 url: url,
1178 dataType: 'script',
1179 cache: true
1180 });*/
1181 // else{
1182 var e = document.createElement("script");
1183 e.setAttribute('src', url);
1184 e.setAttribute('type',"text/javascript");
1185 //e.setAttribute('defer', true);
1186 document.getElementsByTagName("head")[0].appendChild(e);
1187 // }
1188 }
1189
1190 function styleSheetPresent(url){
1191 style_elements = document.getElementsByTagName('link');
1192 if( style_elements.length > 0) {
1193 for(i = 0; i < style_elements.length; i++) {
1194 if(style_elements[i].href == url)
1195 return true;
1196 }
1197 }
1198 return false;
1199 }
1200 function loadExternalCss(url){
1201 //if could have script loader group thes css request
1202 //but debatable it may hurt more than it helps with caching and all
1203 if(typeof url =='object'){
1204 for(var i in url){
1205 loadExternalCss ( url[i] );
1206 }
1207 return ;
1208 }
1209
1210 if( url.indexOf('?') == -1 ){
1211 url+='?'+getMvUniqueReqId();
1212 }
1213 if(!styleSheetPresent(url) ){
1214 js_log('load css: ' + url);
1215 var e = document.createElement("link");
1216 e.href = url;
1217 e.type = "text/css";
1218 e.rel = 'stylesheet';
1219 document.getElementsByTagName("head")[0].appendChild(e);
1220 }
1221 }
1222 function getMvEmbedURL(){
1223 if( _global['mv_embed_url'] )
1224 return _global['mv_embed_url'];
1225 var js_elements = document.getElementsByTagName("script");
1226 for(var i=0; i < js_elements.length; i++){
1227 //check for normal mv_embed.js and or script loader
1228 var src = js_elements[i].getAttribute("src");
1229 if( src ){
1230 if( src.indexOf('mv_embed.js') !=-1 || (
1231 ( src.indexOf('mwScriptLoader.php') != -1 || src.indexOf('jsScriptLoader.php') != -1 )
1232 && src.indexOf('mv_embed') != -1) ){ //(check for class=mv_embed script_loader call)
1233 _global['mv_embed_url'] = src;
1234 return src;
1235 }
1236 }
1237 }
1238 js_error('Error: getMvEmbedURL failed to get Embed Path');
1239 return false;
1240 }
1241 //gets a unique request id to ensure fresh javascript
1242 function getMvUniqueReqId(){
1243 if( _global['urid'] )
1244 return _global['urid'];
1245 var mv_embed_url = getMvEmbedURL();
1246 //if we have a uri retun that:
1247 var urid = parseUri( mv_embed_url).queryKey['urid']
1248 if( urid ){
1249 _global['urid'] = urid;
1250 return urid;
1251 }
1252 //if in debug mode get a fresh unique request key:
1253 if( parseUri( mv_embed_url ).queryKey['debug'] == 'true'){
1254 var d = new Date();
1255 var urid = d.getTime();
1256 _global['urid'] = urid;
1257 return urid;
1258 }
1259 //else just return the mv_embed version;
1260 return MV_EMBED_VERSION;
1261 }
1262 /*
1263 * sets the global mv_embed path based on the scripts location
1264 */
1265 function getMvEmbedPath(){
1266 var mv_embed_url = getMvEmbedURL();
1267 if( mv_embed_url.indexOf('mv_embed.js') !== -1 ){
1268 mv_embed_path = mv_embed_url.substr(0, mv_embed_url.indexOf('mv_embed.js'));
1269 }else if(mv_embed_url.indexOf('mwScriptLoader.php')!==-1){
1270 //script load is in the root of mediaWiki so include the default mv_embed extention path (if using the script loader)
1271 mv_embed_path = mv_embed_url.substr(0, mv_embed_url.indexOf('mwScriptLoader.php')) + mediaWiki_mvEmbed_path ;
1272 }else{
1273 mv_embed_path = mv_embed_url.substr(0, mv_embed_url.indexOf('jsScriptLoader.php'));
1274 }
1275 //absolute the url (if relative) (if we don't have mv_embed path)
1276 if( mv_embed_path.indexOf('://') == -1){
1277 var pURL = parseUri( document.URL );
1278 if(mv_embed_path.charAt(0)=='/'){
1279 mv_embed_path = pURL.protocol + '://' + pURL.authority + mv_embed_path;
1280 }else{
1281 //relative:
1282 if(mv_embed_path==''){
1283 mv_embed_path = pURL.protocol + '://' + pURL.authority + pURL.directory + mv_embed_path;
1284 }
1285 }
1286 }
1287 return mv_embed_path;
1288 }
1289
1290 if (typeof DOMParser == "undefined") {
1291 DOMParser = function () {}
1292 DOMParser.prototype.parseFromString = function (str, contentType) {
1293 if (typeof ActiveXObject != "undefined") {
1294 var d = new ActiveXObject("MSXML.DomDocument");
1295 d.loadXML(str);
1296 return d;
1297 } else if (typeof XMLHttpRequest != "undefined") {
1298 var req = new XMLHttpRequest;
1299 req.open("GET", "data:" + (contentType || "application/xml") +
1300 ";charset=utf-8," + encodeURIComponent(str), false);
1301 if (req.overrideMimeType) {
1302 req.overrideMimeType(contentType);
1303 }
1304 req.send(null);
1305 return req.responseXML;
1306 }
1307 }
1308 }
1309 /*
1310 * utility functions:
1311 */
1312 function js_log(string){
1313 if( window.console ){
1314 window.console.log(string);
1315 }else{
1316 /*
1317 * IE and non-firebug debug:
1318 */
1319 /*var log_elm = document.getElementById('mv_js_log');
1320 if(!log_elm){
1321 document.getElementsByTagName("body")[0].innerHTML = document.getElementsByTagName("body")[0].innerHTML +
1322 '<div style="position:absolute;z-index:500;top:0px;left:0px;right:0px;height:10px;">'+
1323 '<textarea id="mv_js_log" cols="120" rows="5"></textarea>'+
1324 '</div>';
1325
1326 var log_elm = document.getElementById('mv_js_log');
1327 }
1328 if(log_elm){
1329 log_elm.value+=string+"\n";
1330 }*/
1331 }
1332 return false;
1333 }
1334
1335 function js_error(string){
1336 alert(string);
1337 return false;
1338 }