Index: trunk/extensions/MetavidWiki/maintenance/metavid2mvWiki.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | * this is the script we will use to migrate the existing metavid db the mv wiki db |
15 | 15 | */ |
16 | 16 | $cur_path = $IP = dirname( __FILE__ ); |
17 | | -// include commandLine.inc from the mediaWiki maintance dir: |
| 17 | +// include commandLine.inc from the mediaWiki maintenance dir: |
18 | 18 | require_once ( '../../../maintenance/commandLine.inc' ); |
19 | 19 | require_once ( 'metavid2mvWiki.inc.php' ); |
20 | 20 | |
Index: trunk/extensions/MetavidWiki/maintenance/metavid2mvWiki.inc.php |
— | — | @@ -692,7 +692,8 @@ |
693 | 693 | } |
694 | 694 | $max = 0; |
695 | 695 | $mapk = null; |
696 | | - // print_r($point); |
| 696 | + print_r($matches); |
| 697 | + die; |
697 | 698 | foreach ( $point as $k => $v ) { |
698 | 699 | if ( $v > $max ) { |
699 | 700 | $mapk = $matches[1][$k]; |
Index: trunk/extensions/MetavidWiki/skins/external_media_wizard.js |
— | — | @@ -20,12 +20,12 @@ |
21 | 21 | var body_elm = document.getElementsByTagName("body")[0]; |
22 | 22 | body_elm.innerHTML = body_elm.innerHTML + ''+ |
23 | 23 | '<div id="modalbox" style="background:#DDD;border:3px solid #666666;'+ |
24 | | - 'height:90%;left:10%;position:fixed;top:5%;width:80%;z-index:100;">'+ |
| 24 | + 'top:30px;left:100px;right:100px;bottom:30px;position:fixed;z-index:100;">'+ |
25 | 25 | |
26 | 26 | 'loading external media wizard<blink>...</blink>'+ |
27 | 27 | |
28 | 28 | '</div>'+ |
29 | | - '<div style="background:#000;cursor:wait;height:100%;left:0;position:fixed;'+ |
| 29 | + '<div id="mv_overlay" style="background:#000;cursor:wait;height:100%;left:0;position:fixed;'+ |
30 | 30 | 'top:0;width:100%;z-index:5;filter:alpha(opacity=60);-moz-opacity: 0.6;'+ |
31 | 31 | 'opacity: 0.6;"/>'; |
32 | 32 | //inject mv_embed |
— | — | @@ -45,7 +45,8 @@ |
46 | 46 | }else{ |
47 | 47 | mv_do_remote_search({ |
48 | 48 | 'target_id':'modalbox', |
49 | | - 'profile':'mediawiki_edit' |
| 49 | + 'profile':'mediawiki_edit', |
| 50 | + 'default_query':wgTitle |
50 | 51 | }); |
51 | 52 | } |
52 | 53 | } |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libSequencer/mv_sequencer.js |
— | — | @@ -132,11 +132,12 @@ |
133 | 133 | 'html': getMsg('loading_txt'), |
134 | 134 | 'js':function( this_seq ){ |
135 | 135 | //load the search interface with sequence tool targets |
136 | | - mvJsLoader.doLoad({'mediaWikiRemoteSearch':'libRemoteMediaSearch/mv_remote_media_search.js'}, function(){ |
| 136 | + mvJsLoader.doLoad({'remoteSearchDriver':'libRemoteMediaSearch/mv_remote_media_search.js'}, function(){ |
137 | 137 | this_seq.mySearch = new remoteSearchDriver({ |
138 | 138 | 'profile':'sequence', |
139 | 139 | 'p_seq':this_seq, |
140 | | - 'target_id':'cliplib_ic' |
| 140 | + 'target_id':'cliplib_ic', |
| 141 | + 'instance_name': this.instance_name + '.mySearch' |
141 | 142 | }); |
142 | 143 | }); |
143 | 144 | } |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libSequencer/mv_playlist.js |
— | — | @@ -113,8 +113,7 @@ |
114 | 114 | //pulls up the video editor inline |
115 | 115 | doEditor:function(){ |
116 | 116 | //black out the page: |
117 | | - $j('body').append('<div id="mv_overlay"/> '+ |
118 | | - '<div id="modalbox" class="modal_editor">'); |
| 117 | + $j('body').append('<div id="modalbox" class="modal_editor">' + '<div id="mv_overlay"/> '); |
119 | 118 | |
120 | 119 | $j('#modalbox').html('loading editor<blink>...</blink>'); |
121 | 120 | var _this=this; |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/tab-bg.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/tab-bg.png |
___________________________________________________________________ |
Added: svn:mime-type |
122 | 121 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/cc-flickr.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/cc-flickr.png |
___________________________________________________________________ |
Added: svn:mime-type |
123 | 122 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/archive_org_tab.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/archive_org_tab.png |
___________________________________________________________________ |
Added: svn:mime-type |
124 | 123 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/archive_org_logo_80.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/archive_org_logo_80.png |
___________________________________________________________________ |
Added: svn:mime-type |
125 | 124 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/metavid_tab.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/metavid_tab.png |
___________________________________________________________________ |
Added: svn:mime-type |
126 | 125 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/logo.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/logo.png |
___________________________________________________________________ |
Added: svn:mime-type |
127 | 126 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/wiki_commons_tab.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/wiki_commons_tab.png |
___________________________________________________________________ |
Added: svn:mime-type |
128 | 127 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/wiki_commons_logo_80.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/wiki_commons_logo_80.png |
___________________________________________________________________ |
Added: svn:mime-type |
129 | 128 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/combined_tab.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/combined_tab.png |
___________________________________________________________________ |
Added: svn:mime-type |
130 | 129 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/mv_sequence.css |
— | — | @@ -108,13 +108,6 @@ |
109 | 109 | top:0px; |
110 | 110 | z-index:-1; |
111 | 111 | } |
112 | | -.mv_clip_box_result{ |
113 | | - padding:10px; |
114 | | - float:left; |
115 | | -} |
116 | | -.mv_clip_list_result{ |
117 | | - padding:10px; |
118 | | -} |
119 | 112 | .mv_storyboard_container{ |
120 | 113 | position:absolute; |
121 | 114 | z-index:0; |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/styles.css |
— | — | @@ -488,5 +488,65 @@ |
489 | 489 | .ui-resizable-w { z-index:5; position:absolute; cursor: w-resize; width: 15px;height:19px; top: 0px; bottom: 0px; left: 0px;} |
490 | 490 | .ui-dragSpan {filter: alpha(opacity=70); -moz-opacity: .7; background-color:#AAF; position:absolute; left: 10px; right:10px;height:19px; } |
491 | 491 | |
| 492 | +#remote search css: |
| 493 | +ul.rsd_cp_tabs { |
| 494 | + border-bottom:1px solid #CCCCCC; |
| 495 | + display:inline; |
| 496 | + list-style-image:none; |
| 497 | + list-style-position:outside; |
| 498 | + list-style-type:none; |
| 499 | + margin:0; |
| 500 | + padding:0; |
| 501 | +} |
| 502 | +ul.rsd_cp_tabs li.rsd_selected { |
| 503 | + background:#FFFFFF none repeat scroll 0 0; |
| 504 | + border-bottom:0; |
| 505 | + padding-bottom:1px; |
| 506 | + padding-top:12px; |
| 507 | +} |
| 508 | +ul.rsd_cp_tabs li { |
| 509 | + display:inline; |
| 510 | + margin:0; |
| 511 | + padding:10px 0 0; |
| 512 | + background:#F7F7F7 url(remote_search/tab-bg.png) repeat-x scroll left bottom; |
| 513 | + border:1px solid #777; |
| 514 | + padding-bottom:0; |
| 515 | + margin-left:7px; |
| 516 | + cursor:pointer; |
| 517 | +} |
| 518 | +.rsd_results_container{ |
| 519 | + position:absolute; |
| 520 | + left:2px; |
| 521 | + right:2px; |
| 522 | + top:100px; |
| 523 | + bottom:2px; |
| 524 | + z-index:-1; |
| 525 | + overflow:auto; |
| 526 | +} |
| 527 | +#rsd_results { |
| 528 | + border-top:0; |
| 529 | + border:1px solid #777; |
| 530 | + position:relative; |
| 531 | + background:#FFF; |
492 | 532 | |
493 | | - |
| 533 | + position:absolute; |
| 534 | + left:2px; |
| 535 | + right:2px; |
| 536 | + top:66px; |
| 537 | + bottom:2px; |
| 538 | + z-index:-1; |
| 539 | + overflow:auto; |
| 540 | +} |
| 541 | +.mv_clip_box_result{ |
| 542 | + padding:10px; |
| 543 | + float:left; |
| 544 | + border: thin solid #BBB; |
| 545 | +} |
| 546 | +.mv_clip_list_result{ |
| 547 | + padding:10px; |
| 548 | +} |
| 549 | +#rds_results_bar{ |
| 550 | + margin:4px; |
| 551 | + background:#DEF; |
| 552 | + height:22px; |
| 553 | +} |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js |
— | — | @@ -120,10 +120,10 @@ |
121 | 121 | //@@todo integrate msg serving into CMS |
122 | 122 | function getMsg( key , args ) { |
123 | 123 | if ( key in gMsg ) { |
124 | | - if(typeof args == 'object'){ |
| 124 | + if(typeof args == 'object'){ |
125 | 125 | for(var v in args){ |
126 | | - gMsg[key] = gMsg[key].replace('/\$'+v+'/', args[v]); |
127 | | - } |
| 126 | + gMsg[key] = gMsg[key].replace('\$'+v, args[v]); |
| 127 | + } |
128 | 128 | }else if(typeof args =='string'){ |
129 | 129 | gMsg[key] = gMsg[key].replace(/\$1/, args); |
130 | 130 | } |
— | — | @@ -1091,7 +1091,8 @@ |
1092 | 1092 | mvJsLoader.doLoad({ |
1093 | 1093 | 'mvBaseRemoteSearch':'libRemoteMediaSearch/mv_remote_media_search.js' |
1094 | 1094 | }, function(){ |
1095 | | - var mvrs = new remoteSearchDriver( initObj ); |
| 1095 | + initObj['instance_name']= 'rsdMVRS'; |
| 1096 | + rsdMVRS = new remoteSearchDriver( initObj ); |
1096 | 1097 | }); |
1097 | 1098 | }); |
1098 | 1099 | } |
— | — | @@ -2961,8 +2962,8 @@ |
2962 | 2963 | }else{ |
2963 | 2964 | //get data via DOM injection with callback |
2964 | 2965 | global_req_cb.push(callback); |
2965 | | - //prepend json_ to feed_format |
2966 | | - if(req_url.indexOf("feed_format=")!=-1) |
| 2966 | + //prepend json_ to feed_format if not already requesting json format |
| 2967 | + if( req_url.indexOf("feed_format=")!=-1 && req_url.indexOf("feed_format=json")==-1) |
2967 | 2968 | req_url = req_url.replace(/feed_format=/, 'feed_format=json_'); |
2968 | 2969 | |
2969 | 2970 | loadExternalJs(req_url+'&cb=mv_jsdata_cb&cb_inx='+(global_req_cb.length-1)); |
— | — | @@ -3047,6 +3048,9 @@ |
3048 | 3049 | return false; |
3049 | 3050 | } |
3050 | 3051 | function loadExternalCss(url){ |
| 3052 | + if( url.indexOf('?')==-1 ){ |
| 3053 | + url+='?'+mv_embed_urid; |
| 3054 | + } |
3051 | 3055 | js_log('load css: ' + url); |
3052 | 3056 | var e = document.createElement("link"); |
3053 | 3057 | e.href = url; |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libRemoteMediaSearch/mv_remote_media_search.js |
— | — | @@ -8,7 +8,11 @@ |
9 | 9 | and archive.org |
10 | 10 | */ |
11 | 11 | |
12 | | -gMsg['mv_media_search']= 'Media Search'; |
| 12 | +gMsg['mv_media_search'] = 'Media Search'; |
| 13 | +gMsg['rsd_box_layout'] = 'Box layout'; |
| 14 | +gMsg['rsd_list_layout'] = 'List Layout'; |
| 15 | +gMsg['rsd_results_desc']= 'Results <b>$0</b> of <b>$1</b>'; |
| 16 | +gMsg['rsd_layout'] = 'Layout:'; |
13 | 17 | |
14 | 18 | var default_remote_search_options = { |
15 | 19 | 'profile':'mediawiki_edit', |
— | — | @@ -16,54 +20,83 @@ |
17 | 21 | |
18 | 22 | 'default_provider_id':'all', //all or one of the content_providers ids |
19 | 23 | |
| 24 | + 'instance_name': null, //a globally accessible callback instance name |
| 25 | + 'default_query':'', //default search query |
20 | 26 | //specific to sequence profile |
21 | | - 'p_seq':null |
| 27 | + 'p_seq':null |
22 | 28 | } |
23 | 29 | var remoteSearchDriver = function(initObj){ |
24 | 30 | return this.init( initObj ); |
25 | 31 | } |
26 | 32 | remoteSearchDriver.prototype = { |
| 33 | + results_cleared:false, |
27 | 34 | //here we define the set of possible media content providers: |
28 | 35 | main_search_options:{ |
29 | 36 | 'selprovider':{ |
30 | | - 'title': 'Select Provider' |
| 37 | + 'title': 'Select Providers' |
31 | 38 | }, |
32 | 39 | 'advanced_search':{ |
33 | 40 | 'title': 'Advanced Options' |
34 | 41 | } |
35 | 42 | }, |
36 | | - content_providers:{ |
37 | | - //@@todo seed this via the include call (can be exported to seperate library |
38 | | - // once we get the script loader integrated) |
| 43 | + content_providers:{ |
| 44 | + /*content_providers documentation: |
| 45 | + @enabled: whether the search provider can be selected |
| 46 | + @checked: whether the search provideer will show up as seletable tab (todo: user prefrence) |
| 47 | + @d: if the current cp should be displayed (only one should be the default) |
| 48 | + @title: the title of the search provider |
| 49 | + @desc: can use html... todo: need to localize |
| 50 | + @api_url: the url to query against given the library type: |
| 51 | + @lib: the search library to use corresponding to the |
| 52 | + search object ie: 'mediaWiki' = new mediaWikiSearchSearch() |
| 53 | + @local : if the content provider assets need to be imported or not. |
| 54 | + */ |
39 | 55 | 'this_wiki':{ |
| 56 | + 'enabled':0, |
| 57 | + 'checked':0, |
| 58 | + 'd' :0, |
| 59 | + 'title' :'The Current Wiki', |
| 60 | + 'desc' : '(should be updated with the proper text)', |
| 61 | + 'api_url': wgScriptPath + '/api.php', |
| 62 | + 'lib' :'mediaWiki', |
| 63 | + 'local' :true |
| 64 | + }, |
| 65 | + 'wiki_commons':{ |
40 | 66 | 'enabled':1, |
41 | 67 | 'checked':1, |
42 | | - 'title':'The Current Wiki', |
43 | | - 'desc': '(should be updated with the proper text)' |
| 68 | + 'd' :0, |
| 69 | + 'title' :'Wikipedia Commons', |
| 70 | + 'desc' : 'Wikimedia Commons is a media file repository making available public domain '+ |
| 71 | + 'and freely-licensed educational media content (images, sound and video clips) to all.', |
| 72 | + 'api_url':'http://commons.wikimedia.org/w/api.php', |
| 73 | + 'lib' :'mediaWiki', |
| 74 | + 'search_title':false, //disable title search |
| 75 | + 'local' :true |
44 | 76 | }, |
45 | | - 'wiki_commons':{ |
| 77 | + 'metavid':{ |
46 | 78 | 'enabled':1, |
47 | | - 'checked':1, |
48 | | - 'title':'Wikipedia Commons', |
49 | | - 'desc': 'Wikimedia Commons is a media file repository making available public domain '+ |
50 | | - 'and freely-licensed educational media content (images, sound and video clips) to all.', |
51 | | - 'logo': 'http://upload.wikimedia.org/wikipedia/commons/thumb/7/79/Wiki-commons.png/80px-Wiki-commons.png' |
| 79 | + 'checked':1, |
| 80 | + 'd' :1, |
| 81 | + 'title' :'Metavid.org', |
| 82 | + 'desc' : 'Metavid hosts thousands of hours of US house and senate floor proceedings', |
| 83 | + 'api_url':'http://localhost/wiki/index.php?title=Special:MvExportSearch', |
| 84 | + 'lib' : 'metavid', |
| 85 | + 'local' :false |
52 | 86 | }, |
53 | 87 | 'archive_org':{ |
54 | | - 'enabled':1, |
55 | | - 'checked':1, |
| 88 | + 'enabled':0, |
| 89 | + 'checked':0, |
| 90 | + 'd' :0, |
56 | 91 | 'title' : 'Archive.org', |
57 | | - 'desc' : 'The Internet Archive, a digital library of cultural artifacts in digital form', |
58 | | - 'logo' : 'http://www.archive.org/images/logo.jpg' |
59 | | - }, |
60 | | - 'metavid':{ |
61 | | - 'enabled':1, |
62 | | - 'checked':1, |
63 | | - 'title':'Metavid.org', |
64 | | - 'desc': 'Metavid hosts thousands of hours of US house and senate floor proccedings', |
65 | | - 'logo': 'http://metavid.org/w/skins/mvpcf/images/logo.png' |
| 92 | + 'desc' : 'The Internet Archive, a digital library of cultural artifacts', |
| 93 | + 'lib' : 'archive', |
| 94 | + 'local' : false |
66 | 95 | } |
67 | 96 | }, |
| 97 | + //some default layout values: |
| 98 | + thumb_width : 80, |
| 99 | + result_display_mode : 'box', //box or list or preview |
| 100 | + |
68 | 101 | init:function( initObj ){ |
69 | 102 | js_log('remoteSearchDriver:init'); |
70 | 103 | for( var i in default_remote_search_options ) { |
— | — | @@ -81,64 +114,62 @@ |
82 | 115 | var out = '<div class="rsd_control_container" style="width:100%">' + |
83 | 116 | '<table style="width:100%">' + |
84 | 117 | '<tr>'+ |
85 | | - '<td style="width:100px">'+ |
| 118 | + '<td style="width:110px">'+ |
86 | 119 | '<h3> Media Search </h3>'+ |
87 | 120 | '</td>'+ |
88 | 121 | '<td style="width:190px">'+ |
89 | | - '<input type="text" tabindex="1" value="" maxlength="512" id="q" name="q" '+ |
| 122 | + '<input type="text" tabindex="1" value="' + this.default_query + '" maxlength="512" id="rsd_q" name="rsd_q" '+ |
90 | 123 | 'size="20" autocomplete="off"/>'+ |
91 | 124 | '</td>'+ |
92 | | - '<td style="width:110px">'+ |
| 125 | + '<td style="width:115px">'+ |
93 | 126 | '<input type="submit" value="' + getMsg('mv_media_search') + '" tabindex="2" '+ |
94 | 127 | ' id="rms_search_button"/>'+ |
95 | 128 | '</td>'+ |
96 | 129 | '<td>'; |
97 | | - for(var i in this.main_search_options){ |
98 | | - var mso = this.main_search_options[i]; |
99 | | - out += '<a src="#" id="mso_'+i+'" >' + mso.title + '</a><br>'; |
100 | | - } |
101 | | - out+= '</td>'+ |
| 130 | + out += '<a src="#" id="mso_selprovider" >Select Providers</a><br>'; |
| 131 | + out += '<a src="#" id="mso_cancel" >Cancel</a><br>'; |
| 132 | + out += '</td>'+ |
102 | 133 | '</tr>'+ |
103 | 134 | '</table>'; |
104 | | - js_log('out: ' + out); |
105 | | - //set up the content provider selection div (do this first to get the default cp) |
106 | | - var cpsdiv = '<div id="cps_options">'+ |
107 | | - '<table style="background:transparent"><tr>'; |
108 | | - |
109 | | - for( var i in this.content_providers ){ |
110 | | - var cp = this.content_providers[i]; |
111 | | - |
112 | | - var checked_attr = ( cp.checked ) ? 'checked':''; |
113 | | - |
114 | | - cpsdiv+='<td '+ |
115 | | - ' title="' + cp.title + '" '+ |
| 135 | + js_log('out: ' + out); |
| 136 | + |
| 137 | + out+='<div id="rsd_options_bar" style="display:none;width:100%;height:0px;background:#BBB">'; |
| 138 | + //set up the content provider selection div (do this first to get the default cp) |
| 139 | + out+= '<div id="cps_options">'; |
| 140 | + for( var cp_id in this.content_providers ){ |
| 141 | + var cp = this.content_providers[cp_id]; |
| 142 | + var checked_attr = ( cp.checked ) ? 'checked':''; |
| 143 | + out+='<div title="' + cp.title + '" '+ |
116 | 144 | ' style="float:left;cursor:pointer;">'+ |
117 | | - '<input class="mv_cps_input" type="checkbox" name="mv_cps" '+ checked_attr+'>'+ |
118 | | - '</td>'+ |
119 | | - '<td>'; |
120 | | - if( cp.logo ){ |
121 | | - cpsdiv+= '<img src="' + cp.logo + '">'; |
122 | | - }else{ |
123 | | - cpsdiv+= cp.title |
124 | | - } |
125 | | - cpsdiv+='</td>'; |
126 | | - } |
127 | | - cpsdiv+='<tr><td><a id="mso_selprovider_close" href="#">'+getMsg('close')+'</a></td></tr></table></div>'; |
128 | | - |
129 | | - out+='<div id="rsd_options_bar" style="display:none;width:100%;height:0px;background:#BBB">'+ |
130 | | - cpsdiv + |
131 | | - '</div>'; |
132 | | - out+='<div class="rsd_result_bar" style="width:100%;border-top:solid thin black;background:#66F"/>'; |
| 145 | + '<input class="mv_cps_input" type="checkbox" name="mv_cps" '+ checked_attr+'>'; |
| 146 | + |
| 147 | + out+= '<img alt="'+cp.title+'" src="' + mv_embed_path + 'skins/' + mv_skin_name + '/remote_search/' + cp_id + '_tab.png">'; |
| 148 | + out+='</div>'; |
| 149 | + } |
| 150 | + out+='<div style="clear:both"/><a id="mso_selprovider_close" href="#">'+getMsg('close')+'</a></div>'; |
| 151 | + out+='</div>'; |
133 | 152 | //close up the control container: |
134 | 153 | out+='</div>'; |
135 | | - //outout the results placeholder: |
136 | | - out+='<div class="rmd_results" style="width:100%;height:100%;overflow:auto;" />'; |
| 154 | + //search provider tabs based on "checked" and "enabled" and "combined tab" |
| 155 | + out+='<div id="rsd_results_container">'; |
| 156 | + out+='</div>'; |
137 | 157 | $j('#'+ this.target_id ).html( out ); |
| 158 | + //draw the tabs: |
| 159 | + this.drawTabs(); |
| 160 | + //run the default search: |
| 161 | + this.runSearch(); |
138 | 162 | }, |
139 | 163 | add_interface_bindings:function(){ |
140 | 164 | var _this = this; |
141 | | - js_log("add_interface_bindings:"); |
| 165 | + js_log("add_interface_bindings:"); |
142 | 166 | //setup for this.main_search_options: |
| 167 | + $j('#mso_cancel').click(function(){ |
| 168 | + $j('#modalbox').fadeOut("normal",function(){ |
| 169 | + $j(this).remove(); |
| 170 | + $j('#mv_overlay').remove(); |
| 171 | + }); |
| 172 | + }); |
| 173 | + |
143 | 174 | $j('#mso_selprovider,#mso_selprovider_close').click(function(){ |
144 | 175 | if($j('#rsd_options_bar:hidden').length !=0 ){ |
145 | 176 | $j('#rsd_options_bar').animate({ |
— | — | @@ -153,69 +184,135 @@ |
154 | 185 | $j(this).hide(); |
155 | 186 | }) |
156 | 187 | } |
| 188 | + }); |
| 189 | + //setup bindings for search tabs: |
| 190 | + $j('.rsd_cp_tabs li').click(function(){ |
| 191 | + _this.selectTab( $j(this).attr('id').replace(/rsd_tab_/, '') ); |
157 | 192 | }); |
| 193 | + |
158 | 194 | //setup binding for search provider check box: |
159 | 195 | //search button: |
160 | 196 | $j('#rms_search_button').click(function(){ |
161 | 197 | _this.runSearch(); |
162 | 198 | }); |
163 | 199 | }, |
164 | | - runSearch:function(){ |
165 | | - //get a remote search object for each search provider: |
166 | | - for(var i in |
167 | | - } |
168 | | -} |
169 | | - |
170 | | -var mvBaseRemoteSearch = function(initObj) { |
171 | | - return this.init(initObj); |
172 | | -}; |
173 | | -mvBaseRemoteSearch.prototype = { |
174 | | - //default values: |
175 | | - thumb_width:80, |
176 | | - |
177 | | - completed_req:0, |
178 | | - num_req:0, |
179 | | - |
180 | | - result_display_mode:'box', //box or list or preview |
181 | | - resultsObj:{}, |
182 | | - //init the object: |
183 | | - init:function( initObj ){ |
184 | | - js_log('mvBaseRemoteSearch:init'); |
185 | | - for(var i in initObj){ |
186 | | - this[i] = initObj[i]; |
| 200 | + runSearch: function(){ |
| 201 | + var _this = this; |
| 202 | + //set loading div: |
| 203 | + $j('#rsd_results').append('<div style="postion:absolute;top:0px;left:0px;height:100%;width:100%;'+ |
| 204 | + '-moz-opacity:.50; filter:alpha(opacity=50); opacity:.50;z-index:100">' + |
| 205 | + '<img style="padding:10px;" src="'+ |
| 206 | + mv_embed_path + 'skins/' + mv_skin_name + '/images/loading_ani.gif">'+ |
| 207 | + '</div>'); |
| 208 | + //get a remote search object for each search provider and run the search |
| 209 | + for(var cp_id in this.content_providers){ |
| 210 | + cp = this.content_providers[ cp_id ]; |
| 211 | + //only run the search for default item (unless combined is selected) |
| 212 | + if( !cp.d || this.disp_item == 'combined' ) |
| 213 | + continue; |
| 214 | + //check if we need to update: |
| 215 | + if(typeof cp.sObj != 'undefined'){ |
| 216 | + if(cp.sObj.last_query == $j('#rsd_q').val()) |
| 217 | + continue; |
| 218 | + } |
| 219 | + //else we need to run the search: |
| 220 | + var iObj = {'cp':cp, 'rsd':this}; |
| 221 | + eval('cp.sObj = new '+cp.lib+'Search(iObj);'); |
| 222 | + if(!cp.sObj) |
| 223 | + js_log('Error: could not find search lib for ' + cp_id); |
| 224 | + //do search: |
| 225 | + cp.sObj.getSearchResults(); |
187 | 226 | } |
| 227 | + this.checkResultsDone(); |
| 228 | + }, |
| 229 | + checkResultsDone: function(){ |
| 230 | + var _this = this; |
| 231 | + var loading_done = true; |
| 232 | + for(var cp_id in this.content_providers){ |
| 233 | + cp = this.content_providers[ cp_id ]; |
| 234 | + if(typeof cp['sObj'] != 'undefined'){ |
| 235 | + if( cp.sObj.loading ) |
| 236 | + loading_done=false; |
| 237 | + } |
| 238 | + } |
| 239 | + if(loading_done){ |
| 240 | + this.drawOutputResults(); |
| 241 | + }else{ |
| 242 | + setTimeout( _this.instance_name + '.checkResultsDone()', 250); |
| 243 | + } |
| 244 | + }, |
| 245 | + drawTabs: function(){ |
| 246 | + //add the tabs to the rsd_results container: |
| 247 | + var o= '<ul class="rsd_cp_tabs" >'; |
| 248 | + o+='<li id="rsd_tab_combined" ><img src="' + mv_embed_path + 'skins/'+mv_skin_name+ '/remote_search/combined_tab.png"></li>'; |
| 249 | + for(var cp_id in this.content_providers){ |
| 250 | + var cp = this.content_providers[cp_id]; |
| 251 | + if( cp.enabled && cp.checked){ |
| 252 | + var class_attr = (cp.d)?'class="rsd_selected"':''; |
| 253 | + o+='<li id="rsd_tab_'+cp_id+'" ' + class_attr + '><img src="' + mv_embed_path + 'skins/' + mv_skin_name + '/remote_search/' + cp_id + '_tab.png">'; |
| 254 | + } |
| 255 | + } |
| 256 | + o+='</ul>'; |
| 257 | + //outout the resource results holder |
| 258 | + o+='<div id="rsd_results" />'; |
| 259 | + $j('#rsd_results_container').html(o); |
| 260 | + }, |
| 261 | + drawOutputResults: function(){ |
| 262 | + js_log('f:drawOutputResults'); |
| 263 | + var _this = this; |
| 264 | + var o=''; |
| 265 | + $j('#rsd_results').empty(); |
| 266 | + //output the results bar / controls |
| 267 | + _this.setResultBarControl(); |
188 | 268 | |
189 | | - var _this = this; |
190 | | - if(this['target_submit']){ |
191 | | - $j('#'+this['target_submit']).click(function(){ |
192 | | - js_log('doSearch REQ'); |
193 | | - _this.getSearchResults(); |
194 | | - }); |
| 269 | + //output all the results (hide based on tab selection) |
| 270 | + for(var cp_id in this.content_providers){ |
| 271 | + cp = this.content_providers[ cp_id ]; |
| 272 | + //output results based on display mode & input: |
| 273 | + if(typeof cp['sObj'] != 'undefined'){ |
| 274 | + $j.each(cp.sObj.resultsObj, function(rInx, resultItem){ |
| 275 | + var disp = ( cp.d ) ? '' : 'display:none;'; |
| 276 | + if( _this.result_display_mode == 'box' ){ |
| 277 | + o+='<div id="mv_result_' + rInx + '" class="mv_clip_box_result res_' + cp_id +'" style="' + disp + 'width:' + |
| 278 | + _this.thumb_width + 'px;height:'+ parseInt(_this.thumb_width) +'px">'; |
| 279 | + o+='<img style="width:' + _this.thumb_width + 'px;" src="' + resultItem.poster + '">'; |
| 280 | + o+='</div>'; |
| 281 | + }else if(_this.result_display_mode == 'list'){ |
| 282 | + o+='<div id="mv_result_' + rInx + '" class="mv_clip_list_result res_' + cp_id +'" style="' + disp + 'width:90%">'; |
| 283 | + o+='<img style="float:left;width:' + _this.thumb_width + 'px;" src="' + resultItem.poster + '">'; |
| 284 | + o+= cp.sObj.specialFormatDesc( resultItem.desc ) ; |
| 285 | + o+='</div>'; |
| 286 | + o+='<div style="clear:both" />'; |
| 287 | + } |
| 288 | + }); |
| 289 | + } |
195 | 290 | } |
196 | | - |
197 | | - //set up bindings for interface components |
198 | | - //if(this['target_input']) |
199 | | - //@@todo autocomplete for titles |
200 | | - |
201 | | - //if(this['target_results') |
202 | | - //@@todo error checking |
203 | | - |
204 | | - //check if we are in metavid Temporal semantic media search mode |
205 | | - //add an "advanced search" button |
206 | | - |
207 | | - //add in controls: (find a better place for these / use css) |
208 | | - //this seems highly verbose do do a simple control |
| 291 | + js_log('should add to rsd:' + o); |
| 292 | + //put in the new output: |
| 293 | + $j('#rsd_results').append( o ); |
| 294 | + }, |
| 295 | + setResultBarControl:function( ){ |
| 296 | + var _this = this; |
209 | 297 | var box_dark_url = mv_embed_path + 'skins/' + mv_skin_name + '/images/box_layout_icon_dark.png'; |
210 | 298 | var box_light_url = mv_embed_path + 'skins/' + mv_skin_name + '/images/box_layout_icon.png'; |
211 | 299 | var list_dark_url = mv_embed_path + 'skins/' + mv_skin_name + '/images/list_layout_icon_dark.png'; |
212 | 300 | var list_light_url = mv_embed_path + 'skins/' + mv_skin_name + '/images/list_layout_icon.png'; |
213 | 301 | |
214 | | - $j('#'+this.target_submit).after('<img id="msc_box_layout" ' + |
215 | | - 'src = "' + ( (_this.result_display_mode=='box')?box_dark_url:box_light_url ) + '" ' + |
216 | | - 'style="width:20px;height:20px;cursor:pointer;"> ' + |
217 | | - '<img id="msc_list_layout" '+ |
218 | | - 'src = "' + ( (_this.result_display_mode=='list')?list_dark_url:list_light_url ) + '" '+ |
219 | | - 'style="width:20px;height:20px;cursor:pointer;">' |
| 302 | + |
| 303 | + $j('#rsd_results').append('<div id="rds_results_bar">'+ |
| 304 | + '<span style="position:relative;top:-5px;font-style:italic;">'+ |
| 305 | + getMsg('rsd_layout')+' '+ |
| 306 | + '</span>'+ |
| 307 | + '<img id="msc_box_layout" ' + |
| 308 | + 'title = "' + getMsg('rsd_box_layout') + '" '+ |
| 309 | + 'src = "' + ( (_this.result_display_mode=='box')?box_dark_url:box_light_url ) + '" ' + |
| 310 | + 'style="width:20px;height:20px;cursor:pointer;"> ' + |
| 311 | + '<img id="msc_list_layout" '+ |
| 312 | + 'title = "' + getMsg('rsd_list_layout') + '" '+ |
| 313 | + 'src = "' + ( (_this.result_display_mode=='list')?list_dark_url:list_light_url ) + '" '+ |
| 314 | + 'style="width:20px;height:20px;cursor:pointer;">'+ |
| 315 | + '<span style="position:absolute;right:5px;">'+ getMsg('rsd_results_desc', new Array('1 - 20', '420'))+'</span>'+ |
| 316 | + '</div>' |
220 | 317 | ); |
221 | 318 | |
222 | 319 | $j('#msc_box_layout').hover(function(){ |
— | — | @@ -237,59 +334,133 @@ |
238 | 335 | $j('#msc_box_layout').attr("src", box_light_url); |
239 | 336 | _this.setDispMode('list'); |
240 | 337 | }); |
241 | | - |
242 | | - //or if we are in plain mediaWiki mode: |
243 | | - return this; |
244 | 338 | }, |
| 339 | + selectTab:function( selected_cp_id ){ |
| 340 | + js_log('select tab: ' + selected_cp_id); |
| 341 | + this.disp_item =selected_cp_id; |
| 342 | + //set display to unselected: |
| 343 | + for(var cp_id in this.content_providers){ |
| 344 | + cp = this.content_providers[ cp_id ]; |
| 345 | + if( (selected_cp_id == 'combined' && cp.checked ) || selected_cp_id == cp_id){ |
| 346 | + cp.d = 1; |
| 347 | + }else{ |
| 348 | + cp.d = 0; |
| 349 | + } |
| 350 | + } |
| 351 | + //redraw tabs |
| 352 | + this.drawTabs(); |
| 353 | + //update the search results: |
| 354 | + this.runSearch(); |
| 355 | + }, |
245 | 356 | setDispMode:function(mode){ |
246 | 357 | js_log('setDispMode:' + mode); |
247 | | - this.result_display_mode=mode; |
248 | | - //reformat the results: |
249 | | - this.formatOutputResults(); |
250 | | - }, |
251 | | - //check request done used for when we have multiple requests to check before formating results. |
252 | | - checkRequestDone:function(){ |
253 | | - //display output if done: |
254 | | - this.completed_req++; |
255 | | - if(this.completed_req == this.num_req){ |
256 | | - this.formatOutputResults(); |
| 358 | + this.result_display_mode=mode; |
| 359 | + //run /update search display: |
| 360 | + this.drawOutputResults(); |
| 361 | + } |
| 362 | +} |
| 363 | +//default values: |
| 364 | +// tag_name@{attribute} |
| 365 | +var rsd_default_rss_item_mapping = { |
| 366 | + 'poster' : 'media:thumbnail@url', |
| 367 | + 'roe_url' : 'media:roe_embed@url', |
| 368 | + 'link' : 'link', |
| 369 | + 'desc' : 'description' |
| 370 | +} |
| 371 | +var mvBaseRemoteSearch = function(initObj) { |
| 372 | + return this.init(initObj); |
| 373 | +}; |
| 374 | +mvBaseRemoteSearch.prototype = { |
| 375 | + |
| 376 | + completed_req:0, |
| 377 | + num_req:0, |
| 378 | + |
| 379 | + resultsObj:{}, |
| 380 | + //init the object: |
| 381 | + init:function( initObj ){ |
| 382 | + js_log('mvBaseRemoteSearch:init'); |
| 383 | + for(var i in initObj){ |
| 384 | + this[i] = initObj[i]; |
257 | 385 | } |
258 | | - }, |
259 | | - formatOutputResults:function(){ |
260 | | - js_log('f:formatOutputResults'); |
261 | | - //debugger; |
262 | | - var o=''; |
263 | | - //output results based on display mode: |
264 | | - for( var rInx in this.resultsObj ){ |
265 | | - var resultItem = this.resultsObj[rInx]; |
266 | | - if( this.result_display_mode == 'box' ){ |
267 | | - o+='<div id="mv_result_' + rInx + '" class="mv_clip_box_result" style="width:' + this.thumb_width + 'px;">'; |
268 | | - o+='<img style="width:' + this.thumb_width + 'px;" src="' + resultItem.poster + '">'; |
269 | | - o+='</div>'; |
270 | | - }else if(this.result_display_mode == 'list'){ |
271 | | - o+='<div id="mv_result_' + rInx + '" class="mv_clip_list_result" style="width:90%">'; |
272 | | - o+='<img style="float:left;width:' + this.thumb_width + 'px;" src="' + resultItem.poster + '">'; |
273 | | - o+= pageObj.revisions[0]['*']; |
274 | | - o+='</div>'; |
275 | | - o+='<div style="clear:both" />'; |
276 | | - } |
| 386 | + return this; |
| 387 | + }, |
| 388 | + /* |
| 389 | + * Parses and adds video rss based input format |
| 390 | + * @data XML data to parse |
| 391 | + * @provider_url the source url (used to gennerate absolute links) |
| 392 | + */ |
| 393 | + addRSSData:function( data , provider_url ){ |
| 394 | + var _this = this; |
| 395 | + var http_host = ''; |
| 396 | + var http_path = ''; |
| 397 | + if(provider_url){ |
| 398 | + pUrl = parseUri( provider_url ); |
| 399 | + http_host = pUrl.protocol +'://'+ pUrl.authority; |
| 400 | + http_path = pUrl.directory; |
277 | 401 | } |
278 | | - js_log('set : ' +this.target_results + ' to ' + o); |
279 | | - //debugger; |
280 | | - $j('#'+this.target_results).html(o); |
281 | | - } |
| 402 | + items = data.getElementsByTagName('item'); |
| 403 | + $j.each(data.getElementsByTagName('item'), function(inx, item){ |
| 404 | + var rObj ={}; |
| 405 | + for(var i in rsd_default_rss_item_mapping){ |
| 406 | + var selector = rsd_default_rss_item_mapping[i].split('@'); |
| 407 | + |
| 408 | + var tag_name = selector[0]; |
| 409 | + var attr_name = null; |
| 410 | + |
| 411 | + if( selector[1] ) |
| 412 | + attr_name = selector[1]; |
| 413 | + |
| 414 | + //grab the first match |
| 415 | + var node = item.getElementsByTagName( tag_name )[0]; |
| 416 | + //js_log('node: ' + node + ' nv:' + $j(node).html() + ' nv[0]'+ node.innerHTML + |
| 417 | + //' cn' + node.childNodes[0].nodeValue ); |
| 418 | + |
| 419 | + if( node!=null && attr_name == null ){ |
| 420 | + if( node.childNodes[0] != null){ |
| 421 | + rObj[i] = node.textContent; |
| 422 | + } |
| 423 | + } |
| 424 | + |
| 425 | + if( node!=null && attr_name != null) |
| 426 | + rObj[i] = $j(node).attr( attr_name ); |
| 427 | + } |
| 428 | + //make relative urls absolute: |
| 429 | + var url_param = new Array('src', 'poster'); |
| 430 | + for(var j=0; j < url_param.length; j++){ |
| 431 | + var p = url_param[j]; |
| 432 | + if(typeof rObj[p] != 'undefined'){ |
| 433 | + if( rObj[p].substr(0,1)=='/' ){ |
| 434 | + rObj[p] = http_host + rObj[p]; |
| 435 | + } |
| 436 | + if( parseUri( rObj[i] ).host == rObj[p]){ |
| 437 | + rObj[p] = http_host + http_path + rObj[p]; |
| 438 | + } |
| 439 | + } |
| 440 | + } |
| 441 | + _this.resultsObj[inx] = rObj; |
| 442 | + }); |
| 443 | + }, |
| 444 | + /* |
| 445 | + * by default just retun the desc unmodified |
| 446 | + */ |
| 447 | + specialFormatDesc:function( desc_html) { |
| 448 | + return desc_html; |
| 449 | + } |
282 | 450 | } |
283 | | - |
284 | 451 | /* |
285 | 452 | * api modes (implementations should call these objects which inherit the mvBaseRemoteSearch |
286 | 453 | */ |
287 | | -var metavidRemoteSearch = function(initObj) { |
| 454 | +var metavidSearch = function(initObj) { |
288 | 455 | return this.init(initObj); |
289 | 456 | }; |
290 | | -metavidRemoteSearch.prototype = { |
291 | | - init:function(initObj){ |
292 | | - var baseSearch = new mvBaseRemoteSearch(initObj); |
293 | | - //inherit: |
| 457 | +metavidSearch.prototype = { |
| 458 | + rObj:{ //set up the default request paramaters |
| 459 | + 'order':'recent', |
| 460 | + 'feed_format':'rss' |
| 461 | + }, |
| 462 | + init:function( initObj ){ |
| 463 | + //init base class and inherit: |
| 464 | + var baseSearch = new mvBaseRemoteSearch( initObj ); |
294 | 465 | for(var i in baseSearch){ |
295 | 466 | if(typeof this[i] =='undefined'){ |
296 | 467 | this[i] = baseSearch[i]; |
— | — | @@ -297,16 +468,47 @@ |
298 | 469 | this['parent_'+i] = baseSearch[i]; |
299 | 470 | } |
300 | 471 | } |
301 | | - } |
| 472 | + }, |
| 473 | + getSearchResults:function(){ |
| 474 | + var _this = this; |
| 475 | + //start loading: |
| 476 | + _this.loading= 1; |
| 477 | + js_log('metavidSearch::getSearchResults()'); |
| 478 | + //proccess all options |
| 479 | + url = this.cp.api_url; |
| 480 | + //add on the req_param |
| 481 | + for(var i in this.rObj){ |
| 482 | + url += '&' + i + '=' + this.rObj[i]; |
| 483 | + } |
| 484 | + //do basic query: |
| 485 | + url += '&f[0][t]=match&f[0][v]=' + $j('#rsd_q').val(); |
| 486 | + do_request(url, function(data){ |
| 487 | + //should have an xml rss data object: |
| 488 | + _this.addRSSData( data , url ); |
| 489 | + //done loading: |
| 490 | + _this.loading=0; |
| 491 | + }); |
| 492 | + }, |
| 493 | + addRSSData:function(data, url){ |
| 494 | + this.parent_addRSSData(data, url); |
| 495 | + //special metavid rss feed proccessing: strip mv_rss_view_only |
| 496 | + |
| 497 | + }, |
| 498 | + /* |
| 499 | + * special format description output. |
| 500 | + */ |
| 501 | + specialFormatDesc:function( desc_html ){ |
| 502 | + return desc_html; |
| 503 | + } |
302 | 504 | } |
303 | 505 | |
304 | | -var mediaWikiRemoteSearch = function(initObj) { |
305 | | - return this.init(initObj); |
| 506 | +var mediaWikiSearch = function( initObj ) { |
| 507 | + return this.init( initObj ); |
306 | 508 | }; |
307 | | -mediaWikiRemoteSearch.prototype = { |
308 | | - init:function(initObj){ |
309 | | - var baseSearch = new mvBaseRemoteSearch(initObj); |
310 | | - //inherit: |
| 509 | +mediaWikiSearch.prototype = { |
| 510 | + init:function( initObj ){ |
| 511 | + //init base class and inherit: |
| 512 | + var baseSearch = new mvBaseRemoteSearch( initObj ); |
311 | 513 | for(var i in baseSearch){ |
312 | 514 | if(typeof this[i] =='undefined'){ |
313 | 515 | this[i] = baseSearch[i]; |
— | — | @@ -316,39 +518,36 @@ |
317 | 519 | } |
318 | 520 | }, |
319 | 521 | getSearchResults:function(){ |
320 | | - js_log('f:getSearchResults for:' + $j('#'+this.target_input).val() ); |
321 | | - //set results div to "loading" |
322 | | - $j('#'+this.target_results).html( getMsg('loading_txt') ); |
| 522 | + var _this = this; |
| 523 | + this.loading=true; |
| 524 | + js_log('f:getSearchResults for:' + $j('#'+this.target_input).val() ); |
323 | 525 | //empty out the current results: |
324 | 526 | this.resultsObj={}; |
325 | | - //do two queries against the Image / File / MVD namespace: |
326 | | - //construct search request: |
327 | | - var req_url =this.p_seq.plObj.interface_url.replace(/index\.php/, 'api.php'); |
| 527 | + //do two queries against the Image / File / MVD namespace: |
328 | 528 | //build the image request object: |
329 | 529 | var rObj = { |
330 | 530 | 'action':'query', |
331 | 531 | 'generator':'search', |
332 | 532 | 'gsrsearch': encodeURIComponent( $j('#'+this.target_input).val() ), |
333 | | - 'gsrnamespace':6, //(only search images) |
| 533 | + 'gsrnamespace':6, //(only search the "file" namespace (audio, video, images) |
334 | 534 | 'gsrwhat':'title', |
335 | 535 | 'prop':'imageinfo|revisions|categories', |
336 | 536 | 'iiprop':'url', |
337 | 537 | 'iiurlwidth':'80', |
338 | 538 | 'rvprop':'content' |
339 | | - }; |
340 | | - var _this = this; |
| 539 | + }; |
341 | 540 | //set up the number of request: |
342 | 541 | this.completed_req=0; |
343 | 542 | this.num_req=2; |
344 | 543 | //setup the number of requests result flag: |
345 | | - do_api_req( rObj, req_url, function(data){ |
| 544 | + do_api_req( rObj, this.cp.api_url , function(data){ |
346 | 545 | //parse the return data |
347 | | - _this.addMediaWikiAPIResults( data); |
| 546 | + _this.addResults( data); |
348 | 547 | _this.checkRequestDone(); |
349 | 548 | }); |
350 | 549 | //also do a request for page titles (would be nice if api could query both at the same time) |
351 | 550 | rObj['gsrwhat']='text'; |
352 | | - do_api_req( rObj, req_url, function(data){ |
| 551 | + do_api_req( rObj, this.cp.api_url , function(data){ |
353 | 552 | //parse the return data |
354 | 553 | _this.addResults( data); |
355 | 554 | _this.checkRequestDone(); |
— | — | @@ -358,13 +557,12 @@ |
359 | 558 | //make sure we have pages to idoerate: |
360 | 559 | if(data.query && data.query.pages){ |
361 | 560 | for(var page_id in data.query.pages){ |
362 | | - var page = data.query.pages[ page_id ]; |
363 | | - |
364 | | - this.resultsObj['ref'][page_id]={ |
| 561 | + var page = data.query.pages[ page_id ]; |
| 562 | + this.resultsObj[page_id]={ |
365 | 563 | 'uri':page.title, |
366 | 564 | 'poster':page.imageinfo.thumburl, |
367 | 565 | 'src':page.imageinfo.url, |
368 | | - 'desc':page.revisions['*'], |
| 566 | + 'desc':page.revisions[0]['*'], |
369 | 567 | 'meta':{ |
370 | 568 | 'categories':page.categories |
371 | 569 | } |
— | — | @@ -373,5 +571,13 @@ |
374 | 572 | }else{ |
375 | 573 | js_log('no results:' + data); |
376 | 574 | } |
| 575 | + }, |
| 576 | + //check request done used for when we have multiple requests to check before formating results. |
| 577 | + checkRequestDone:function(){ |
| 578 | + //display output if done: |
| 579 | + this.completed_req++; |
| 580 | + if(this.completed_req == this.num_req){ |
| 581 | + this.loading = 0; |
| 582 | + } |
377 | 583 | } |
378 | 584 | } |
\ No newline at end of file |