Index: trunk/extensions/MetavidWiki/skins/add_media_wizard.js |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | load_mv_embed( function(){ |
45 | 45 | //load jQuery and what not (we need to refactor the loading system for mv_embed) |
46 | 46 | mvEmbed.load_libs(function(){ |
47 | | - mvJsLoader.doLoad({'mvUploader' : 'libAddMedia/mv_upload.js'},function(){ |
| 47 | + mvJsLoader.doLoad({'mvUploader' : 'libAddMedia/mvUploader.js'},function(){ |
48 | 48 | mvUp = new mvUploader(); |
49 | 49 | }); |
50 | 50 | }); |
Index: trunk/extensions/MetavidWiki/skins/mv_stream.js |
— | — | @@ -162,6 +162,15 @@ |
163 | 163 | |
164 | 164 | //unlock the interface updates once everything is setup: |
165 | 165 | mv_lock_vid_updates=false; |
| 166 | + |
| 167 | + //check for #autoplay ancor |
| 168 | + var hash = window.location.hash.toString(); |
| 169 | + js_log(" hash is: " + hash); |
| 170 | + if( hash =='#autoplay'){ |
| 171 | + window.location.hash = ''; |
| 172 | + $j('#embed_vid').get(0).play(); |
| 173 | + } |
| 174 | + |
166 | 175 | js_log('done with mv_init_inerface'); |
167 | 176 | //$j('#embed_vid').get(0).stop(); |
168 | 177 | }, |
— | — | @@ -191,10 +200,10 @@ |
192 | 201 | scroll_to_pos(mvd_id); |
193 | 202 | //also add onclick to mv_timeline_mvd_jumper |
194 | 203 | $j(this).click(function(){ |
195 | | - mv_do_play(mvd_id); |
| 204 | + mv_do_play( mvd_id ); |
196 | 205 | }); |
197 | 206 | } |
198 | | - this_stream.mvdOver(mvd_id); |
| 207 | + this_stream.mvdOver( mvd_id ); |
199 | 208 | }, |
200 | 209 | out:function(){ |
201 | 210 | //get the mvd_id (the last part of the this.id) |
— | — | @@ -864,11 +873,11 @@ |
865 | 874 | mv_do_play(); |
866 | 875 | } |
867 | 876 | } |
868 | | -function mv_do_play(mvd_id){ |
869 | | - js_log('mv_do_play:'+mvd_id); |
| 877 | +function mv_do_play( mvd_id ){ |
| 878 | + js_log('mv_do_play:' + mvd_id); |
870 | 879 | //stop the current |
871 | 880 | $j('#embed_vid').get(0).stop(); |
872 | | - //stop any defered updates: |
| 881 | + //stop any deferred updates: |
873 | 882 | |
874 | 883 | //force a given mvd if set |
875 | 884 | if(mvd_id){ |
— | — | @@ -879,20 +888,26 @@ |
880 | 889 | $j('#embed_vid').get(0). |
881 | 890 | //disable interface actions (mouse in out etc) |
882 | 891 | mv_lock_vid_updates=true; |
883 | | - //update the src if neasesary and no mvd provided: |
| 892 | + //update the src if nesesary and no mvd provided: |
884 | 893 | if(!mvd_id){ |
885 | 894 | if(mv_stream_interface.cur_mvd_id!=mv_stream_interface.delay_cur_mvd_id){ |
886 | 895 | mv_stream_interface.cur_mvd_id =mv_stream_interface.delay_cur_mvd_id; |
887 | 896 | do_video_mvd_update( mv_stream_interface.cur_mvd_id ); |
888 | 897 | } |
889 | 898 | } |
890 | | - //update the embed video actual play time |
891 | | - //time_chunk = $j('#embed_vid').get(0).src.split('t='); |
892 | | - //$j('#mv_videoPlayerTime').html( time_chunk[1] ); |
893 | | - //stop the video if playing and play: |
894 | | - $j('#embed_vid').get(0).didSeekJump=true; |
895 | | - //@@todo extend mv_embed to support src switching |
896 | | - $j('#embed_vid').get(0).play(); |
| 899 | + //check if we are out of range: |
| 900 | + var time_ary = $j('#mv_fd_mvd_'+mvd_id).attr('name').split('/'); |
| 901 | + if( ntp2seconds( time_ary[1] ) < ntp2seconds( $j('#embed_vid').get(0).start_ntp ) ){ |
| 902 | + window.location = wgArticlePath.replace( '$1', wgPageName +'/'+ time_ary[1] + '/' + time_ary[2]) + '#autoplay'; |
| 903 | + }else{ |
| 904 | + //update the embed video actual play time |
| 905 | + //time_chunk = $j('#embed_vid').get(0).src.split('t='); |
| 906 | + //$j('#mv_videoPlayerTime').html( time_chunk[1] ); |
| 907 | + //stop the video if playing and play: |
| 908 | + $j('#embed_vid').get(0).didSeekJump=true; |
| 909 | + //@@todo extend mv_embed to support src switching |
| 910 | + $j('#embed_vid').get(0).play(); |
| 911 | + } |
897 | 912 | |
898 | 913 | } |
899 | 914 | |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/searchLibs/solrArchiveSearch.js |
— | — | @@ -0,0 +1,40 @@ |
| 2 | +//archive.org uses solr engine: |
| 3 | +//more about solr here: |
| 4 | +//http://lucene.apache.org/solr/ |
| 5 | +var solrArchiveSearch = function ( initObj){ |
| 6 | + return this.init( initObj ); |
| 7 | +} |
| 8 | +solrArchiveSearch.prototype = { |
| 9 | + init:function( initObj ){ |
| 10 | + //init base class and inherit: |
| 11 | + var baseSearch = new mvBaseRemoteSearch( initObj ); |
| 12 | + for(var i in baseSearch){ |
| 13 | + if(typeof this[i] =='undefined'){ |
| 14 | + this[i] = baseSearch[i]; |
| 15 | + }else{ |
| 16 | + this['parent_'+i] = baseSearch[i]; |
| 17 | + } |
| 18 | + } |
| 19 | + //inherit the cp settings for |
| 20 | + }, |
| 21 | + getSearchResults:function(){ |
| 22 | + var _this = this; |
| 23 | + this.loading=true; |
| 24 | + js_log('f:getSearchResults for:' + $j('#rsd_q').val() ); |
| 25 | + //build the req: |
| 26 | + var reqObj = { |
| 27 | + 'q':$j('#rsd_q').val() + ' format:(Ogg video)', //just search for video atm |
| 28 | + 'fl':"description,identifier,licenseurl,format,license,thumbnail", |
| 29 | + 'wt':'json', |
| 30 | + 'rows':'30', |
| 31 | + 'indent':'yes' |
| 32 | + } |
| 33 | + do_api_req( { |
| 34 | + 'data':reqObj, |
| 35 | + 'url':this.cp.api_url |
| 36 | + }, function(data){ |
| 37 | + js_log('got data: ' + data); |
| 38 | + } |
| 39 | + }); |
| 40 | + } |
| 41 | +} |
\ No newline at end of file |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/searchLibs/mediaWikiSearch.js |
— | — | @@ -0,0 +1,203 @@ |
| 2 | +var mediaWikiSearch = function( initObj ) { |
| 3 | + return this.init( initObj ); |
| 4 | +}; |
| 5 | +mediaWikiSearch.prototype = { |
| 6 | + init:function( initObj ){ |
| 7 | + //init base class and inherit: |
| 8 | + var baseSearch = new mvBaseRemoteSearch( initObj ); |
| 9 | + for(var i in baseSearch){ |
| 10 | + if(typeof this[i] =='undefined'){ |
| 11 | + this[i] = baseSearch[i]; |
| 12 | + }else{ |
| 13 | + this['parent_'+i] = baseSearch[i]; |
| 14 | + } |
| 15 | + } |
| 16 | + //inherit the cp settings for |
| 17 | + }, |
| 18 | + getSearchResults:function(){ |
| 19 | + var _this = this; |
| 20 | + this.loading=true; |
| 21 | + js_log('f:getSearchResults for:' + $j('#rsd_q').val() ); |
| 22 | + //empty out the current results: |
| 23 | + this.resultsObj={}; |
| 24 | + //do two queries against the Image / File / MVD namespace: |
| 25 | + |
| 26 | + //build the image request object: |
| 27 | + var reqObj = { |
| 28 | + 'action':'query', |
| 29 | + 'generator':'search', |
| 30 | + 'gsrsearch': encodeURIComponent( $j('#rsd_q').val() ), |
| 31 | + 'gsrnamespace':6, //(only search the "file" namespace (audio, video, images) |
| 32 | + 'gsrwhat':'title', |
| 33 | + 'gsrlimit': this.cp.limit, |
| 34 | + 'gsroffset': this.cp.offset, |
| 35 | + 'prop':'imageinfo|revisions|categories', |
| 36 | + 'iiprop':'url|mime', |
| 37 | + 'iiurlwidth': parseInt( this.rsd.thumb_width ), |
| 38 | + 'rvprop':'content' |
| 39 | + }; |
| 40 | + //set up the number of request: |
| 41 | + this.completed_req=0; |
| 42 | + this.num_req=1; |
| 43 | + this.last_query = $j('#rsd_q').val(); |
| 44 | + //setup the number of requests result flag: |
| 45 | + //also do a request for page titles (would be nice if api could query both at the same time) |
| 46 | + reqObj['gsrwhat']='text'; |
| 47 | + do_api_req( { |
| 48 | + 'data':reqObj, |
| 49 | + 'url':this.cp.api_url |
| 50 | + }, function(data){ |
| 51 | + //parse the return data |
| 52 | + _this.addResults( data); |
| 53 | + //_this.checkRequestDone(); //only need if we do two queries one for title one for text |
| 54 | + _this.loading = false; |
| 55 | + }); |
| 56 | + }, |
| 57 | + addResults:function( data ){ |
| 58 | + js_log("f:addResults"); |
| 59 | + var _this = this |
| 60 | + //check if we have |
| 61 | + if( typeof data['query-continue'] != 'undefined'){ |
| 62 | + if( typeof data['query-continue'].search != 'undefined') |
| 63 | + this.more_results = true; |
| 64 | + } |
| 65 | + //make sure we have pages to iderate: |
| 66 | + |
| 67 | + if(data.query && data.query.pages){ |
| 68 | + for(var page_id in data.query.pages){ |
| 69 | + var page = data.query.pages[ page_id ]; |
| 70 | + //make sure the reop is shared |
| 71 | + if( page.imagerepository == 'shared'){ |
| 72 | + continue; |
| 73 | + } |
| 74 | + //make sure the page is not a redirect |
| 75 | + if(page.revisions[0]['*'].indexOf('#REDIRECT')===0){ |
| 76 | + //skip page is redirect |
| 77 | + continue; |
| 78 | + } |
| 79 | + //skip if its an empy or missing imageinfo: |
| 80 | + if(!page.imageinfo) |
| 81 | + continue; |
| 82 | + |
| 83 | + this.resultsObj[page_id]={ |
| 84 | + 'titleKey' : page.title, |
| 85 | + 'link' :page.imageinfo[0].descriptionurl, |
| 86 | + 'title' :page.title.replace(/File:|.jpg|.png|.svg|.ogg|.ogv/ig, ''), |
| 87 | + 'poster' :page.imageinfo[0].thumburl, |
| 88 | + 'thumbwidth':page.imageinfo[0].thumbwidth, |
| 89 | + 'thumbheight':page.imageinfo[0].thumbheight, |
| 90 | + 'mime' :page.imageinfo[0].mime, |
| 91 | + 'src' :page.imageinfo[0].url, |
| 92 | + 'desc' :page.revisions[0]['*'], |
| 93 | + //add pointer to parent search obj: |
| 94 | + 'pSobj' :_this, |
| 95 | + 'meta':{ |
| 96 | + 'categories':page.categories |
| 97 | + } |
| 98 | + } |
| 99 | + this.num_results++; |
| 100 | + //for(var i in this.resultsObj[page_id]){ |
| 101 | + // js_log('added: '+ i +' '+ this.resultsObj[page_id][i]); |
| 102 | + //} |
| 103 | + } |
| 104 | + }else{ |
| 105 | + js_log('no results:' + data); |
| 106 | + } |
| 107 | + }, |
| 108 | + //check request done used for when we have multiple requests to check before formating results. |
| 109 | + checkRequestDone:function(){ |
| 110 | + //display output if done: |
| 111 | + this.completed_req++; |
| 112 | + if(this.completed_req == this.num_req){ |
| 113 | + this.loading = 0; |
| 114 | + } |
| 115 | + }, |
| 116 | + getImageObj:function( rObj, size, callback ){ |
| 117 | + if( rObj.mime=='application/ogg' ) |
| 118 | + return callback( {'url':rObj.src, 'poster' : rObj.url } ); |
| 119 | + |
| 120 | + //build the query to get the req size image: |
| 121 | + var reqObj = { |
| 122 | + 'action':'query', |
| 123 | + 'titles':rObj.titleKey, |
| 124 | + 'prop':'imageinfo', |
| 125 | + 'iiprop':'url|size|mime' |
| 126 | + } |
| 127 | + //set the width: |
| 128 | + if(size.width) |
| 129 | + reqObj['iiurlwidth']= size.width; |
| 130 | + |
| 131 | + do_api_req( { |
| 132 | + 'data':reqObj, |
| 133 | + 'url' : this.cp.api_url |
| 134 | + }, function(data){ |
| 135 | + var imObj = {}; |
| 136 | + for(var page_id in data.query.pages){ |
| 137 | + var iminfo = data.query.pages[ page_id ].imageinfo[0]; |
| 138 | + //store the orginal width: |
| 139 | + imObj['org_width']=iminfo.width; |
| 140 | + //check if thumb size > than image size and is jpeg or png (it will not scale well above its max res) |
| 141 | + if( ( iminfo.mime=='image/jpeg' || iminfo=='image/png' ) && |
| 142 | + iminfo.thumbwidth > iminfo.width ){ |
| 143 | + imObj['url'] = iminfo.url; |
| 144 | + imObj['width'] = iminfo.width; |
| 145 | + imObj['height'] = iminfo.height; |
| 146 | + }else{ |
| 147 | + imObj['url'] = iminfo.thumburl; |
| 148 | + imObj['width'] = iminfo.thumbwidth; |
| 149 | + imObj['height'] = iminfo.thumbheight; |
| 150 | + } |
| 151 | + } |
| 152 | + js_log('getImageObj: get: ' + size.width + ' got url:' + imObj.url); |
| 153 | + callback( imObj ); |
| 154 | + }); |
| 155 | + }, |
| 156 | + //the insert image function |
| 157 | + insertImage:function( cEdit ){ |
| 158 | + if(!cEdit) |
| 159 | + var cEdit = _this.cEdit; |
| 160 | + }, |
| 161 | + getEmbedHTML: function( rObj , options) { |
| 162 | + //set up the output var with the default values: |
| 163 | + var outOpt = { 'width': rObj.width, 'height': rObj.height}; |
| 164 | + if( options['max_height'] ){ |
| 165 | + outOpt.height = (options.max_height > rObj.height) ? rObj.height : options.max_height; |
| 166 | + outOpt.width = (rObj.width / rObj.height) *outOpt.height; |
| 167 | + } |
| 168 | + var style_attr = 'style="width:' + outOpt.width + 'px;height:' + outOpt.height +'px"'; |
| 169 | + var id_attr = (options['id'])?' id = "' + options['id'] +'" ': ''; |
| 170 | + |
| 171 | + //return the html type: |
| 172 | + if(rObj.mime.indexOf('image')!=-1){ |
| 173 | + return '<img ' + id_attr + ' src="' + rObj.url + '"' + style_attr + ' >'; |
| 174 | + } |
| 175 | + if(rObj.mime.indexOf('application/ogg')!=-1){ |
| 176 | + return '<video ' + id_attr + |
| 177 | + ' src="' + rObj.src + '" ' + |
| 178 | + style_attr + |
| 179 | + ' poster="'+ rObj.poster + '" '+ |
| 180 | + ' ></video>'; |
| 181 | + } |
| 182 | + js_log('ERROR:unsupored mime type: ' + rObj.mime); |
| 183 | + }, |
| 184 | + //returns the inline wikitext for insertion (template based crops for now) |
| 185 | + getEmbedWikiText: function( rObj ){ |
| 186 | + //set default layout to right justified |
| 187 | + var layout = ( rObj.layout)? rObj.layout:"right" |
| 188 | + //if crop is null do base output: |
| 189 | + if( rObj.crop == null) |
| 190 | + return this.parent_getEmbedWikiText( rObj ); |
| 191 | + //using the preview crop template: http://en.wikipedia.org/wiki/Template:Preview_Crop |
| 192 | + //@@todo should be replaced with server side cropping |
| 193 | + return '{{Preview Crop ' + "\n" + |
| 194 | + '|Image = ' + rObj.target_resource_title + "\n" + |
| 195 | + '|bSize = ' + rObj.width + "\n" + |
| 196 | + '|cWidth = ' + rObj.crop.w + "\n" + |
| 197 | + '|cHeight = ' + rObj.crop.h + "\n" + |
| 198 | + '|oTop = ' + rObj.crop.y + "\n" + |
| 199 | + '|oLeft = ' + rObj.crop.x + "\n" + |
| 200 | + '|Location =' + layout + "\n" + |
| 201 | + '|Description =' + rObj.inlineDesc + "\n" + |
| 202 | + '}}'; |
| 203 | + } |
| 204 | +} |
\ No newline at end of file |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/searchLibs/metavidSearch.js |
— | — | @@ -0,0 +1,104 @@ |
| 2 | +/* |
| 3 | +* api modes (implementations should call these objects which inherit the mvBaseRemoteSearch |
| 4 | +*/ |
| 5 | +var metavidSearch = function(initObj) { |
| 6 | + return this.init(initObj); |
| 7 | +}; |
| 8 | +metavidSearch.prototype = { |
| 9 | + reqObj:{ //set up the default request paramaters |
| 10 | + 'order':'recent', |
| 11 | + 'feed_format':'rss' |
| 12 | + }, |
| 13 | + init:function( initObj ){ |
| 14 | + //init base class and inherit: |
| 15 | + var baseSearch = new mvBaseRemoteSearch( initObj ); |
| 16 | + for(var i in baseSearch){ |
| 17 | + if(typeof this[i] =='undefined'){ |
| 18 | + this[i] = baseSearch[i]; |
| 19 | + }else{ |
| 20 | + this['parent_'+i] = baseSearch[i]; |
| 21 | + } |
| 22 | + } |
| 23 | + }, |
| 24 | + getSearchResults:function(){ |
| 25 | + var _this = this; |
| 26 | + //start loading: |
| 27 | + _this.loading= 1; |
| 28 | + js_log('metavidSearch::getSearchResults()'); |
| 29 | + //proccess all options |
| 30 | + var url = this.cp.api_url; |
| 31 | + //add on the req_param |
| 32 | + for(var i in this.reqObj){ |
| 33 | + url += '&' + i + '=' + this.reqObj[i]; |
| 34 | + } |
| 35 | + //do basic query: |
| 36 | + this.last_query = $j('#rsd_q').val(); |
| 37 | + this.last_offset = this.cp.offset; |
| 38 | + url += '&f[0][t]=match&f[0][v]=' + $j('#rsd_q').val(); |
| 39 | + //add offset limit: |
| 40 | + url+='&limit=' + this.cp.limit; |
| 41 | + url+='&offset=' + this.cp.offset; |
| 42 | + |
| 43 | + do_request(url, function(data){ |
| 44 | + //should have an xml rss data object: |
| 45 | + _this.addRSSData( data , url ); |
| 46 | + //do some metavid specific pos processing on the rObj data: |
| 47 | + for(var i in _this.resultsObj){ |
| 48 | + var rObj = _this.resultsObj[i]; |
| 49 | + var proe = parseUri( rObj['roe_url'] ); |
| 50 | + rObj['start_time'] = proe.queryKey['t'].split('/')[0]; |
| 51 | + rObj['end_time'] = proe.queryKey['t'].split('/')[1]; |
| 52 | + rObj['stream_name'] = proe.queryKey['stream_name']; |
| 53 | + //transform the title into a wiki_safe title: |
| 54 | + //rObj['titleKey'] = proe.queryKey['stream_name'] + '_' + rObj['start_time'].replace(/:/g,'.') + '_' + rObj['end_time'].replace(/:/g,'.') + '.ogg'; |
| 55 | + rObj['titleKey'] = proe.queryKey['stream_name'] + '/' + rObj['start_time'] + '/' + rObj['end_time'] + '__.ogg'; |
| 56 | + } |
| 57 | + //done loading: |
| 58 | + _this.loading=0; |
| 59 | + }); |
| 60 | + }, |
| 61 | + getEmbedWikiText:function(rObj, options){ |
| 62 | + //if we are using a local copy do the standard b: |
| 63 | + if( this.cp.local_copy == true) |
| 64 | + return this.parent_getEmbedWikiText(rObj, options); |
| 65 | + //if local_copy is false and embed metavid extension is enabled: |
| 66 | + return |
| 67 | + }, |
| 68 | + getEmbedHTML:function( rObj , options ){ |
| 69 | + var id_attr = (options['id'])?' id = "' + options['id'] +'" ': ''; |
| 70 | + var style_attr = (options['max_width'])?' style="width:'+options['max_width']+'px;"':''; |
| 71 | + if(options['only_poster']){ |
| 72 | + return '<img ' + id_attr + ' src="' + rObj['poster']+'" ' + style_attr + '>'; |
| 73 | + }else{ |
| 74 | + return '<video ' + id_attr + ' roe="' + rObj['roe_url'] + '"></video>'; |
| 75 | + } |
| 76 | + }, |
| 77 | + getEmbedObjParsedInfo:function(rObj, eb_id){ |
| 78 | + var sources = $j('#'+eb_id).get(0).media_element.getSources(); |
| 79 | + rObj.other_versions ='*[' + rObj['roe_url'] + ' XML of all Video Formats and Timed Text]'+"\n"; |
| 80 | + for(var i in sources){ |
| 81 | + var cur_source = sources[i]; |
| 82 | + //rObj.other_versions += '*['+cur_source.getURI() +' ' + cur_source.title +']' + "\n"; |
| 83 | + if( cur_source.id == this.cp.target_source_id) |
| 84 | + rObj['url'] = cur_source.getURI(); |
| 85 | + } |
| 86 | + js_log('set url to: ' + rObj['url']); |
| 87 | + return rObj; |
| 88 | + }, |
| 89 | + //update rObj for import: |
| 90 | + updateDataForImport:function( rObj ){ |
| 91 | + rObj['author']='US Government'; |
| 92 | + //convert data to UTC type date: |
| 93 | + var dateExp = new RegExp(/_([0-9]+)\-([0-9]+)\-([0-9]+)/); |
| 94 | + var dParts = rObj.link.match (dateExp); |
| 95 | + var d = new Date(); |
| 96 | + var year_full = (dParts[3].length==2)?'20'+dParts[3].toString():dParts[3]; |
| 97 | + d.setFullYear(year_full, dParts[1]-1, dParts[2]); |
| 98 | + rObj['date'] = d.toDateString(); |
| 99 | + rObj['licence_template_tag']='PD-USGov'; |
| 100 | + //update based on new start time: |
| 101 | + js_log('url is: ' + rObj.src + ' ns: ' + rObj.start_time + ' ne:' + rObj.end_time); |
| 102 | + |
| 103 | + return rObj; |
| 104 | + } |
| 105 | +} |
\ No newline at end of file |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/remoteSearchDriver.js |
— | — | @@ -121,6 +121,20 @@ |
122 | 122 | 'limit' : 30, |
123 | 123 | 'tab_img':true |
124 | 124 | }, |
| 125 | + 'archive_org':{ |
| 126 | + 'enabled':1, |
| 127 | + 'checked':1, |
| 128 | + 'd' :0, |
| 129 | + 'title' : 'Archive.org', |
| 130 | + 'desc' : 'The Internet Archive, a digital library of cultural artifacts', |
| 131 | + 'homepage':'http://archive.org', |
| 132 | + |
| 133 | + 'api_url':'http://metavid.org/w/index.php?title=Special:MvExportSearch', |
| 134 | + 'lib' : 'solrArchive', |
| 135 | + 'local' : false, |
| 136 | + 'resource_prefix': 'AO_', |
| 137 | + 'tab_img':true |
| 138 | + }, |
125 | 139 | 'metavid':{ |
126 | 140 | 'enabled':1, |
127 | 141 | 'checked':1, |
— | — | @@ -142,18 +156,6 @@ |
143 | 157 | 'remote_embed_ext': false, //if running the remoteEmbed extension no need to copy local |
144 | 158 | //syntax will be [remoteEmbed:roe_url link title] |
145 | 159 | 'tab_img':true |
146 | | - }, |
147 | | - 'archive_org':{ |
148 | | - 'enabled':0, |
149 | | - 'checked':0, |
150 | | - 'd' :0, |
151 | | - 'title' : 'Archive.org', |
152 | | - 'desc' : 'The Internet Archive, a digital library of cultural artifacts', |
153 | | - 'homepage':'http://archive.org', |
154 | | - 'lib' : 'archive', |
155 | | - 'local' : false, |
156 | | - 'resource_prefix': 'AO_', |
157 | | - 'tab_img':true |
158 | 160 | } |
159 | 161 | }, |
160 | 162 | //some default layout values: |
— | — | @@ -314,8 +316,7 @@ |
315 | 317 | ); |
316 | 318 | }); |
317 | 319 | }, |
318 | | - runSearch: function(){ |
319 | | - var _this = this; |
| 320 | + runSearch: function(){ |
320 | 321 | //set loading div: |
321 | 322 | mv_set_loading('#rsd_results'); |
322 | 323 | //get a remote search object for each search provider and run the search |
— | — | @@ -335,9 +336,17 @@ |
336 | 337 | if(cp.sObj.last_query == $j('#rsd_q').val() && cp.sObj.last_offset == cp.offset) |
337 | 338 | continue; |
338 | 339 | } |
| 340 | + //make sure the search library is loaded and do the search: |
| 341 | + this.getLibSearchResults( cp ); |
| 342 | + } |
| 343 | + }, |
| 344 | + getLibSearchResults:function( cp ){ |
| 345 | + var _this = this; |
| 346 | + eval('var libLoadReq = {'+cp.lib+'Search: \'libAddMedia/searchLibs/' +cp.lib + 'Search.js\' };'); |
| 347 | + mvJsLoader.doLoad( libLoadReq, function(){ |
339 | 348 | //else we need to run the search: |
340 | | - var iObj = {'cp':cp, 'rsd':this}; |
341 | | - eval('cp.sObj = new '+cp.lib+'Search(iObj);'); |
| 349 | + var iObj = {'cp':cp, 'rsd':_this}; |
| 350 | + eval('cp.sObj = new '+cp.lib+'Search( iObj );'); |
342 | 351 | if(!cp.sObj) |
343 | 352 | js_log('Error: could not find search lib for ' + cp_id); |
344 | 353 | |
— | — | @@ -346,10 +355,10 @@ |
347 | 356 | cp.offset = (cp.offset) ? cp.offset : cp.sObj.offset; |
348 | 357 | |
349 | 358 | //do search: |
350 | | - cp.sObj.getSearchResults(); |
351 | | - } |
352 | | - this.checkResultsDone(); |
353 | | - }, |
| 359 | + cp.sObj.getSearchResults(); |
| 360 | + _this.checkResultsDone(); |
| 361 | + }); |
| 362 | + }, |
354 | 363 | checkResultsDone: function(){ |
355 | 364 | var _this = this; |
356 | 365 | var loading_done = true; |
— | — | @@ -413,10 +422,14 @@ |
414 | 423 | 'action':'query', |
415 | 424 | 'titles': _this.cFileNS + ':' + rTitle |
416 | 425 | }; |
417 | | - do_api_req( reqObj, this.local_wiki_api_url, function(data){ |
418 | | - //propogate the rO |
419 | | - var rObj = {}; |
420 | | - }); |
| 426 | + do_api_req( { |
| 427 | + 'data':reqObj, |
| 428 | + 'url':this.local_wiki_api_url |
| 429 | + }, function(data){ |
| 430 | + //propogate the rO |
| 431 | + var rObj = {}; |
| 432 | + } |
| 433 | + ); |
421 | 434 | }, |
422 | 435 | //@@todo we could load the id with the content provider id to find the object faster... |
423 | 436 | getResourceFromId:function( rid ){ |
— | — | @@ -670,183 +683,193 @@ |
671 | 684 | //check if the resource is not already on this wiki |
672 | 685 | reqObj={'action':'query', 'titles': _this.cFileNS + ':' + rObj.target_resource_title}; |
673 | 686 | |
674 | | - do_api_req( reqObj, this.local_wiki_api_url, function(data){ |
675 | | - var found_title = false; |
676 | | - for(var i in data.query.pages){ |
677 | | - if( i != '-1' && i != '-2' ){ |
678 | | - js_log('found title: ' + i + ':' + data.query.pages[i]['title']); |
679 | | - found_title=data.query.pages[i]['title']; |
680 | | - } |
681 | | - } |
682 | | - if( found_title ){ |
683 | | - js_log("checkImportResource:found title:" + found_title); |
684 | | - //resource is already present (or resource with same name is already present) |
685 | | - rObj.target_resource_title = found_title.replace(/File:|Image:/,''); |
686 | | - cir_callback( rObj ); |
687 | | - }else{ |
688 | | - js_log("resource not present: update:"+ _this.cFileNS + ':' + rObj.target_resource_title); |
689 | | - |
690 | | - //update the rObj with import info |
691 | | - rObj.pSobj.updateDataForImport( rObj ); |
692 | | - |
693 | | - //setup the resource description from resource description: |
694 | | - var base_resource_desc = '{{Information '+"\n"+ |
695 | | - '|Description= ' + rObj.title + ' imported from ' + '[' + cp.homepage + |
696 | | - ' ' + cp.title+']' + "\n" + |
697 | | - '|Source=' + '[' + rObj.link.replace(/^\s\s*/, '').replace(/\s\s*$/, '') +' Original Source]'+ "\n"; |
698 | | - |
699 | | - if( rObj.author ) |
700 | | - base_resource_desc+='|Author= ' + rObj.author +"\n"; |
| 687 | + do_api_req( { |
| 688 | + 'data':reqObj, |
| 689 | + 'url':this.local_wiki_api_url |
| 690 | + }, function(data){ |
| 691 | + var found_title = false; |
| 692 | + for(var i in data.query.pages){ |
| 693 | + if( i != '-1' && i != '-2' ){ |
| 694 | + js_log('found title: ' + i + ':' + data.query.pages[i]['title']); |
| 695 | + found_title=data.query.pages[i]['title']; |
| 696 | + } |
| 697 | + } |
| 698 | + if( found_title ){ |
| 699 | + js_log("checkImportResource:found title:" + found_title); |
| 700 | + //resource is already present (or resource with same name is already present) |
| 701 | + rObj.target_resource_title = found_title.replace(/File:|Image:/,''); |
| 702 | + cir_callback( rObj ); |
| 703 | + }else{ |
| 704 | + js_log("resource not present: update:"+ _this.cFileNS + ':' + rObj.target_resource_title); |
701 | 705 | |
702 | | - if( rObj.date ) |
703 | | - base_resource_desc+='|Date=' + rObj.date +"\n"; |
704 | | - |
705 | | - if( rObj.permission ) |
706 | | - base_resource_desc+='|Permission='+ rObj.permission +"\n"; |
| 706 | + //update the rObj with import info |
| 707 | + rObj.pSobj.updateDataForImport( rObj ); |
707 | 708 | |
708 | | - if( rObj.other_versions ) |
709 | | - base_resource_desc+='|Other_versions=' + rObj.other_versions + "\n"; |
710 | | - |
711 | | - base_resource_desc+='}}'; |
712 | | - |
713 | | - //add in licence template tag: |
714 | | - if( rObj.licence_template_tag ) |
715 | | - base_resource_desc += "\n" + |
716 | | - '== [[Commons:Copyright tags|Licensing]]: ==' +"\n"+ |
717 | | - '{{' + rObj.licence_template_tag + '}}'; |
718 | | - |
719 | | - $j('#rsd_resource_import').remove();//remove any old resource imports |
720 | | - //@@ show user dialog to import the resource |
721 | | - $j( '#'+ _this.target_id ).append('<div id="rsd_resource_import" '+ |
722 | | - 'style="position:absolute;top:50px;left:50px;right:50px;bottom:50px;background-color:#FFF;border:solid thick red;z-index:3">' + |
723 | | - '<h3 style="color:red">Resource: <span style="color:black">' + rObj.title + '</span> needs to be imported</h3>'+ |
724 | | - '<div id="rsd_preview_import_container" style="position:absolute;width:50%;bottom:0px;left:0px;overflow:auto;top:30px;">' + |
725 | | - rObj.pSobj.getEmbedHTML( rObj, {'max_height':'200','only_poster':true} )+ //get embedHTML with small thumb: |
726 | | - '<br style="clear both">'+ |
727 | | - '<strong>Resource Page Description:</strong>'+ |
728 | | - '<div id="rsd_import_desc" syle="display:inline;">'+ |
729 | | - mv_get_loading_img('position:absolute;top:5px;left:5px', 'mv_img_loader') + |
730 | | - '</div>'+ |
731 | | - '</div>'+ |
732 | | - '<div id="rds_edit_import_container" style="position:absolute;left:50%;' + |
733 | | - 'bottom:0px;top:30px;right:0px;overflow:auto;">'+ |
734 | | - '<strong>Local Resource Title:</strong><br>'+ |
735 | | - '<input type="text" size="30" value="' + rObj.target_resource_title + '" readonly="true"><br>'+ |
736 | | - '<strong>Edit WikiText Resource Description:</strong>(will be replaced by forms soon)'+ |
737 | | - '<textarea id="rsd_import_ta" id="mv_img_desc" style="width:90%;" rows="8" cols="50">'+ |
738 | | - base_resource_desc + |
739 | | - '</textarea><br>'+ |
740 | | - '<input type="checkbox" value="true" id="wpWatchthis" name="wpWatchthis" tabindex="7"/>'+ |
741 | | - '<label for="wpWatchthis">Watch this page</label><br>'+ |
742 | | - '<input id="rsd_import_apreview" type="button" value="Update Preview"> ' + |
743 | | - '<input style="font-weight: bold" id="rsd_import_doimport" type="button" value="Do Import Resource"> '+ |
744 | | - '<a id="rsd_import_acancel" href="#">Cancel Import</a>'+ |
745 | | - '</div>'+ |
746 | | - //output the rendered and non-renderd version of description for easy swiching: |
747 | | - '</div>'); |
748 | | - //load the preview text: |
749 | | - _this.getParsedWikiText( base_resource_desc, _this.cFileNS +':'+ rObj.target_resource_title, function( o ){ |
750 | | - $j('#rsd_import_desc').html(o); |
751 | | - }); |
752 | | - //add bidings: |
753 | | - $j('#rsd_import_apreview').click(function(){ |
754 | | - $j('#rsd_import_desc').show().html( |
755 | | - mv_get_loading_img() |
756 | | - ); |
757 | | - //load the preview text: |
758 | | - _this.getParsedWikiText( $j('#rsd_import_ta').val(), _this.cFileNS +':'+ rObj.target_resource_title, function( o ){ |
759 | | - js_log('got updated preivew: '+ o); |
| 709 | + //setup the resource description from resource description: |
| 710 | + var base_resource_desc = '{{Information '+"\n"+ |
| 711 | + '|Description= ' + rObj.title + ' imported from ' + '[' + cp.homepage + |
| 712 | + ' ' + cp.title+']' + "\n" + |
| 713 | + '|Source=' + '[' + rObj.link.replace(/^\s\s*/, '').replace(/\s\s*$/, '') +' Original Source]'+ "\n"; |
| 714 | + |
| 715 | + if( rObj.author ) |
| 716 | + base_resource_desc+='|Author= ' + rObj.author +"\n"; |
| 717 | + |
| 718 | + if( rObj.date ) |
| 719 | + base_resource_desc+='|Date=' + rObj.date +"\n"; |
| 720 | + |
| 721 | + if( rObj.permission ) |
| 722 | + base_resource_desc+='|Permission='+ rObj.permission +"\n"; |
| 723 | + |
| 724 | + if( rObj.other_versions ) |
| 725 | + base_resource_desc+='|Other_versions=' + rObj.other_versions + "\n"; |
| 726 | + |
| 727 | + base_resource_desc+='}}'; |
| 728 | + |
| 729 | + //add in licence template tag: |
| 730 | + if( rObj.licence_template_tag ) |
| 731 | + base_resource_desc += "\n" + |
| 732 | + '== [[Commons:Copyright tags|Licensing]]: ==' +"\n"+ |
| 733 | + '{{' + rObj.licence_template_tag + '}}'; |
| 734 | + |
| 735 | + $j('#rsd_resource_import').remove();//remove any old resource imports |
| 736 | + //@@ show user dialog to import the resource |
| 737 | + $j( '#'+ _this.target_id ).append('<div id="rsd_resource_import" '+ |
| 738 | + 'style="position:absolute;top:50px;left:50px;right:50px;bottom:50px;background-color:#FFF;border:solid thick red;z-index:3">' + |
| 739 | + '<h3 style="color:red">Resource: <span style="color:black">' + rObj.title + '</span> needs to be imported</h3>'+ |
| 740 | + '<div id="rsd_preview_import_container" style="position:absolute;width:50%;bottom:0px;left:0px;overflow:auto;top:30px;">' + |
| 741 | + rObj.pSobj.getEmbedHTML( rObj, {'max_height':'200','only_poster':true} )+ //get embedHTML with small thumb: |
| 742 | + '<br style="clear both">'+ |
| 743 | + '<strong>Resource Page Description:</strong>'+ |
| 744 | + '<div id="rsd_import_desc" syle="display:inline;">'+ |
| 745 | + mv_get_loading_img('position:absolute;top:5px;left:5px', 'mv_img_loader') + |
| 746 | + '</div>'+ |
| 747 | + '</div>'+ |
| 748 | + '<div id="rds_edit_import_container" style="position:absolute;left:50%;' + |
| 749 | + 'bottom:0px;top:30px;right:0px;overflow:auto;">'+ |
| 750 | + '<strong>Local Resource Title:</strong><br>'+ |
| 751 | + '<input type="text" size="30" value="' + rObj.target_resource_title + '" readonly="true"><br>'+ |
| 752 | + '<strong>Edit WikiText Resource Description:</strong>(will be replaced by forms soon)'+ |
| 753 | + '<textarea id="rsd_import_ta" id="mv_img_desc" style="width:90%;" rows="8" cols="50">'+ |
| 754 | + base_resource_desc + |
| 755 | + '</textarea><br>'+ |
| 756 | + '<input type="checkbox" value="true" id="wpWatchthis" name="wpWatchthis" tabindex="7"/>'+ |
| 757 | + '<label for="wpWatchthis">Watch this page</label><br>'+ |
| 758 | + '<input id="rsd_import_apreview" type="button" value="Update Preview"> ' + |
| 759 | + '<input style="font-weight: bold" id="rsd_import_doimport" type="button" value="Do Import Resource"> '+ |
| 760 | + '<a id="rsd_import_acancel" href="#">Cancel Import</a>'+ |
| 761 | + '</div>'+ |
| 762 | + //output the rendered and non-renderd version of description for easy swiching: |
| 763 | + '</div>'); |
| 764 | + //load the preview text: |
| 765 | + _this.getParsedWikiText( base_resource_desc, _this.cFileNS +':'+ rObj.target_resource_title, function( o ){ |
760 | 766 | $j('#rsd_import_desc').html(o); |
761 | 767 | }); |
762 | | - }); |
763 | | - $j('#rsd_import_doimport').click(function(){ |
764 | | - //replace the parent with progress bar: |
765 | | - $j('#rsd_resource_import').html( |
766 | | - '<h3>Importing asset</h3>'+ |
767 | | - mv_get_loading_img() |
768 | | - ); |
769 | | - //get an edittoken: |
770 | | - var reqObj = {'action':'query','prop':'info','intoken':'edit','titles': rObj.titleKey }; |
771 | | - do_api_req( reqObj, _this.local_wiki_api_url, function(data){ |
772 | | - //could recheck if it has been created in the mean time |
773 | | - if( data.query.pages[-1] ){ |
774 | | - var editToken = data.query.pages[-1]['edittoken']; |
775 | | - if(!editToken){ |
776 | | - //@@todo give an ajax login or be more friendly in some way: |
777 | | - js_error("You don't have permission to upload (are you logged in?)"); |
778 | | - //remove top level: |
779 | | - $j('#modalbox').fadeOut("normal",function(){ |
780 | | - $j(this).remove(); |
781 | | - $j('#mv_overlay').remove(); |
782 | | - }); |
783 | | - }else{ |
784 | | - //not sure if we can do remote url uploads (so just do a local post) |
785 | | - js_log('got token for new page:' +editToken); |
786 | | - var postVars = { |
787 | | - 'wpSourceType' :'web', |
788 | | - 'wpUploadFileURL' : rObj.url, |
789 | | - 'wpDestFile' : rObj.target_resource_title, |
790 | | - 'wpUploadDescription':$j('#rsd_import_ta').val(), |
791 | | - 'wpWatchthis' : $j('#wpWatchthis').val(), |
792 | | - 'wpUpload' : 'Upload file' |
793 | | - } |
794 | | - //set to uploading: |
795 | | - $j('#rsd_resource_import').append('<div id="rsd_import_progress"'+ |
796 | | - 'style="position:absolute;top:0px;'+ |
797 | | - 'left:0px;width:100%;height:100%;'+ |
798 | | - 'z-index:5;background:#FFF;overflow:auto;">'+ |
799 | | - '<div style="position:absolute;left:30%;right:30%"><h3>Importing Asset</h3><br>' + |
800 | | - mv_get_loading_img('','mv_loading_bar_img') + |
801 | | - '</div>'+ |
802 | | - '</div>' |
803 | | - ); |
804 | | - $j.post(wgArticlePath.replace(/\$1/,'Special:Upload'), |
805 | | - postVars, |
806 | | - function(data){ |
807 | | - //@@todo this will be replaced once we add upload image support to the api. |
808 | | - |
809 | | - //very basic test to see if we got passed to the image page: |
810 | | - //@@todo more normalization stuff |
811 | | - var sstring ='var wgPageName = "' + _this.cFileNS + ':' + rObj.target_resource_title.replace(/ /g,'_') +'"'; |
812 | | - if(data.indexOf( sstring ) !=-1){ |
813 | | - js_log('found: ' + sstring); |
814 | | - $j('#rsd_resource_import').remove(); |
815 | | - cir_callback( rObj ); |
816 | | - }else{ |
817 | | - js_log("Error or warning: (did not find: \"" + sstring + ' in output' ); |
818 | | - pos_etitle = '<h1 class="firstHeading">'; |
819 | | - var error_txt=''; |
820 | | - if(data.indexOf(pos_etitle)!=-1){ |
821 | | - var sp = data.indexOf(pos_etitle) + pos_etitle.length; |
822 | | - error_txt = data.substr(sp , |
823 | | - (data.indexOf('</h1>',sp )-sp) |
824 | | - ); |
825 | | - } |
826 | | - //var error_msg = |
827 | | - $j('#rsd_resource_import').html( |
828 | | - '<b>error importing asset (we should have better error handling soon)</b><br>'+ |
829 | | - error_txt + '<br>'+ |
830 | | - '<a href="#" id="rsd_import_error" >Cancel import</a>' |
831 | | - ); |
832 | | - $j('#rsd_import_error').click(function(){ |
833 | | - $j('#rsd_resource_import').remove(); |
834 | | - }); |
| 768 | + //add bidings: |
| 769 | + $j('#rsd_import_apreview').click(function(){ |
| 770 | + $j('#rsd_import_desc').show().html( |
| 771 | + mv_get_loading_img() |
| 772 | + ); |
| 773 | + //load the preview text: |
| 774 | + _this.getParsedWikiText( $j('#rsd_import_ta').val(), _this.cFileNS +':'+ rObj.target_resource_title, function( o ){ |
| 775 | + js_log('got updated preivew: '+ o); |
| 776 | + $j('#rsd_import_desc').html(o); |
| 777 | + }); |
| 778 | + }); |
| 779 | + $j('#rsd_import_doimport').click(function(){ |
| 780 | + //replace the parent with progress bar: |
| 781 | + $j('#rsd_resource_import').html( |
| 782 | + '<h3>Importing asset</h3>'+ |
| 783 | + mv_get_loading_img() |
| 784 | + ); |
| 785 | + //get an edittoken: |
| 786 | + do_api_req( { |
| 787 | + 'data': { 'action':'query', |
| 788 | + 'prop':'info', |
| 789 | + 'intoken':'edit', |
| 790 | + 'titles': rObj.titleKey |
| 791 | + }, |
| 792 | + 'url':_this.local_wiki_api_url |
| 793 | + }, function(data){ |
| 794 | + //could recheck if it has been created in the mean time |
| 795 | + if( data.query.pages[-1] ){ |
| 796 | + var editToken = data.query.pages[-1]['edittoken']; |
| 797 | + if(!editToken){ |
| 798 | + //@@todo give an ajax login or be more friendly in some way: |
| 799 | + js_error("You don't have permission to upload (are you logged in?)"); |
| 800 | + //remove top level: |
| 801 | + $j('#modalbox').fadeOut("normal",function(){ |
| 802 | + $j(this).remove(); |
| 803 | + $j('#mv_overlay').remove(); |
| 804 | + }); |
| 805 | + }else{ |
| 806 | + //not sure if we can do remote url uploads (so just do a local post) |
| 807 | + js_log('got token for new page:' +editToken); |
| 808 | + var postVars = { |
| 809 | + 'wpSourceType' :'web', |
| 810 | + 'wpUploadFileURL' : rObj.url, |
| 811 | + 'wpDestFile' : rObj.target_resource_title, |
| 812 | + 'wpUploadDescription':$j('#rsd_import_ta').val(), |
| 813 | + 'wpWatchthis' : $j('#wpWatchthis').val(), |
| 814 | + 'wpUpload' : 'Upload file' |
835 | 815 | } |
836 | | - |
837 | | - } |
838 | | - ); |
839 | | - } |
840 | | - } |
| 816 | + //set to uploading: |
| 817 | + $j('#rsd_resource_import').append('<div id="rsd_import_progress"'+ |
| 818 | + 'style="position:absolute;top:0px;'+ |
| 819 | + 'left:0px;width:100%;height:100%;'+ |
| 820 | + 'z-index:5;background:#FFF;overflow:auto;">'+ |
| 821 | + '<div style="position:absolute;left:30%;right:30%"><h3>Importing Asset</h3><br>' + |
| 822 | + mv_get_loading_img('','mv_loading_bar_img') + |
| 823 | + '</div>'+ |
| 824 | + '</div>' |
| 825 | + ); |
| 826 | + $j.post(wgArticlePath.replace(/\$1/,'Special:Upload'), |
| 827 | + postVars, |
| 828 | + function(data){ |
| 829 | + //@@todo this will be replaced once we add upload image support to the api. |
| 830 | + |
| 831 | + //very basic test to see if we got passed to the image page: |
| 832 | + //@@todo more normalization stuff |
| 833 | + var sstring ='var wgPageName = "' + _this.cFileNS + ':' + rObj.target_resource_title.replace(/ /g,'_') +'"'; |
| 834 | + if(data.indexOf( sstring ) !=-1){ |
| 835 | + js_log('found: ' + sstring); |
| 836 | + $j('#rsd_resource_import').remove(); |
| 837 | + cir_callback( rObj ); |
| 838 | + }else{ |
| 839 | + js_log("Error or warning: (did not find: \"" + sstring + ' in output' ); |
| 840 | + pos_etitle = '<h1 class="firstHeading">'; |
| 841 | + var error_txt=''; |
| 842 | + if(data.indexOf(pos_etitle)!=-1){ |
| 843 | + var sp = data.indexOf(pos_etitle) + pos_etitle.length; |
| 844 | + error_txt = data.substr(sp , |
| 845 | + (data.indexOf('</h1>',sp )-sp) |
| 846 | + ); |
| 847 | + } |
| 848 | + //var error_msg = |
| 849 | + $j('#rsd_resource_import').html( |
| 850 | + '<b>error importing asset (we should have better error handling soon)</b><br>'+ |
| 851 | + error_txt + '<br>'+ |
| 852 | + '<a href="#" id="rsd_import_error" >Cancel import</a>' |
| 853 | + ); |
| 854 | + $j('#rsd_import_error').click(function(){ |
| 855 | + $j('#rsd_resource_import').remove(); |
| 856 | + }); |
| 857 | + } |
| 858 | + |
| 859 | + } |
| 860 | + ); |
| 861 | + } |
| 862 | + } |
| 863 | + } |
| 864 | + ); |
841 | 865 | }); |
842 | | - |
843 | | - }); |
844 | | - $j('#rsd_import_acancel').click(function(){ |
845 | | - $j('#rsd_resource_import').fadeOut("fast",function(){ |
846 | | - $j(this).remove(); |
847 | | - }) |
848 | | - }) |
849 | | - } |
850 | | - }); |
| 866 | + $j('#rsd_import_acancel').click(function(){ |
| 867 | + $j('#rsd_resource_import').fadeOut("fast",function(){ |
| 868 | + $j(this).remove(); |
| 869 | + }); |
| 870 | + }); |
| 871 | + } |
| 872 | + } |
| 873 | + ); |
851 | 874 | } |
852 | 875 | }, |
853 | 876 | previewResource:function( rObj ){ |
— | — | @@ -891,13 +914,16 @@ |
892 | 915 | _this.caret_pos.text.substring( _this.caret_pos.s ); |
893 | 916 | }, |
894 | 917 | getParsedWikiText:function( wikitext, title, callback ){ |
895 | | - var reqObj = { |
896 | | - 'action':'parse', |
897 | | - 'text':wikitext |
898 | | - }; |
899 | | - do_api_req( reqObj, this.local_wiki_api_url, function(data){ |
900 | | - callback( data.parse.text['*'] ); |
901 | | - }); |
| 918 | + do_api_req( |
| 919 | + 'data':{ |
| 920 | + 'action':'parse', |
| 921 | + 'text':wikitext |
| 922 | + }, |
| 923 | + 'url':this.local_wiki_api_url |
| 924 | + },function(data){ |
| 925 | + callback( data.parse.text['*'] ); |
| 926 | + } |
| 927 | + ); |
902 | 928 | }, |
903 | 929 | insertResource:function( rObj){ |
904 | 930 | var _this = this |
— | — | @@ -1145,310 +1171,4 @@ |
1146 | 1172 | return rObj; |
1147 | 1173 | } |
1148 | 1174 | } |
1149 | | -/* |
1150 | | -* api modes (implementations should call these objects which inherit the mvBaseRemoteSearch |
1151 | | -*/ |
1152 | | -var metavidSearch = function(initObj) { |
1153 | | - return this.init(initObj); |
1154 | | -}; |
1155 | | -metavidSearch.prototype = { |
1156 | | - reqObj:{ //set up the default request paramaters |
1157 | | - 'order':'recent', |
1158 | | - 'feed_format':'rss' |
1159 | | - }, |
1160 | | - init:function( initObj ){ |
1161 | | - //init base class and inherit: |
1162 | | - var baseSearch = new mvBaseRemoteSearch( initObj ); |
1163 | | - for(var i in baseSearch){ |
1164 | | - if(typeof this[i] =='undefined'){ |
1165 | | - this[i] = baseSearch[i]; |
1166 | | - }else{ |
1167 | | - this['parent_'+i] = baseSearch[i]; |
1168 | | - } |
1169 | | - } |
1170 | | - }, |
1171 | | - getSearchResults:function(){ |
1172 | | - var _this = this; |
1173 | | - //start loading: |
1174 | | - _this.loading= 1; |
1175 | | - js_log('metavidSearch::getSearchResults()'); |
1176 | | - //proccess all options |
1177 | | - var url = this.cp.api_url; |
1178 | | - //add on the req_param |
1179 | | - for(var i in this.reqObj){ |
1180 | | - url += '&' + i + '=' + this.reqObj[i]; |
1181 | | - } |
1182 | | - //do basic query: |
1183 | | - this.last_query = $j('#rsd_q').val(); |
1184 | | - this.last_offset = this.cp.offset; |
1185 | | - url += '&f[0][t]=match&f[0][v]=' + $j('#rsd_q').val(); |
1186 | | - //add offset limit: |
1187 | | - url+='&limit=' + this.cp.limit; |
1188 | | - url+='&offset=' + this.cp.offset; |
1189 | | - |
1190 | | - do_request(url, function(data){ |
1191 | | - //should have an xml rss data object: |
1192 | | - _this.addRSSData( data , url ); |
1193 | | - //do some metavid specific pos processing on the rObj data: |
1194 | | - for(var i in _this.resultsObj){ |
1195 | | - var rObj = _this.resultsObj[i]; |
1196 | | - var proe = parseUri( rObj['roe_url'] ); |
1197 | | - rObj['start_time'] = proe.queryKey['t'].split('/')[0]; |
1198 | | - rObj['end_time'] = proe.queryKey['t'].split('/')[1]; |
1199 | | - rObj['stream_name'] = proe.queryKey['stream_name']; |
1200 | | - //transform the title into a wiki_safe title: |
1201 | | - //rObj['titleKey'] = proe.queryKey['stream_name'] + '_' + rObj['start_time'].replace(/:/g,'.') + '_' + rObj['end_time'].replace(/:/g,'.') + '.ogg'; |
1202 | | - rObj['titleKey'] = proe.queryKey['stream_name'] + '/' + rObj['start_time'] + '/' + rObj['end_time'] + '__.ogg'; |
1203 | | - } |
1204 | | - //done loading: |
1205 | | - _this.loading=0; |
1206 | | - }); |
1207 | | - }, |
1208 | | - getEmbedWikiText:function(rObj, options){ |
1209 | | - //if we are using a local copy do the standard b: |
1210 | | - if( this.cp.local_copy == true) |
1211 | | - return this.parent_getEmbedWikiText(rObj, options); |
1212 | | - //if local_copy is false and embed metavid extension is enabled: |
1213 | | - return |
1214 | | - }, |
1215 | | - getEmbedHTML:function( rObj , options ){ |
1216 | | - var id_attr = (options['id'])?' id = "' + options['id'] +'" ': ''; |
1217 | | - var style_attr = (options['max_width'])?' style="width:'+options['max_width']+'px;"':''; |
1218 | | - if(options['only_poster']){ |
1219 | | - return '<img ' + id_attr + ' src="' + rObj['poster']+'" ' + style_attr + '>'; |
1220 | | - }else{ |
1221 | | - return '<video ' + id_attr + ' roe="' + rObj['roe_url'] + '"></video>'; |
1222 | | - } |
1223 | | - }, |
1224 | | - getEmbedObjParsedInfo:function(rObj, eb_id){ |
1225 | | - var sources = $j('#'+eb_id).get(0).media_element.getSources(); |
1226 | | - rObj.other_versions ='*[' + rObj['roe_url'] + ' XML of all Video Formats and Timed Text]'+"\n"; |
1227 | | - for(var i in sources){ |
1228 | | - var cur_source = sources[i]; |
1229 | | - //rObj.other_versions += '*['+cur_source.getURI() +' ' + cur_source.title +']' + "\n"; |
1230 | | - if( cur_source.id == this.cp.target_source_id) |
1231 | | - rObj['url'] = cur_source.getURI(); |
1232 | | - } |
1233 | | - js_log('set url to: ' + rObj['url']); |
1234 | | - return rObj; |
1235 | | - }, |
1236 | | - //update rObj for import: |
1237 | | - updateDataForImport:function( rObj ){ |
1238 | | - rObj['author']='US Government'; |
1239 | | - //convert data to UTC type date: |
1240 | | - var dateExp = new RegExp(/_([0-9]+)\-([0-9]+)\-([0-9]+)/); |
1241 | | - var dParts = rObj.link.match (dateExp); |
1242 | | - var d = new Date(); |
1243 | | - var year_full = (dParts[3].length==2)?'20'+dParts[3].toString():dParts[3]; |
1244 | | - d.setFullYear(year_full, dParts[1]-1, dParts[2]); |
1245 | | - rObj['date'] = d.toDateString(); |
1246 | | - rObj['licence_template_tag']='PD-USGov'; |
1247 | | - //update based on new start time: |
1248 | | - js_log('url is: ' + rObj.src + ' ns: ' + rObj.start_time + ' ne:' + rObj.end_time); |
1249 | | - |
1250 | | - return rObj; |
1251 | | - } |
1252 | | -} |
1253 | 1175 | |
1254 | | -var mediaWikiSearch = function( initObj ) { |
1255 | | - return this.init( initObj ); |
1256 | | -}; |
1257 | | -mediaWikiSearch.prototype = { |
1258 | | - init:function( initObj ){ |
1259 | | - //init base class and inherit: |
1260 | | - var baseSearch = new mvBaseRemoteSearch( initObj ); |
1261 | | - for(var i in baseSearch){ |
1262 | | - if(typeof this[i] =='undefined'){ |
1263 | | - this[i] = baseSearch[i]; |
1264 | | - }else{ |
1265 | | - this['parent_'+i] = baseSearch[i]; |
1266 | | - } |
1267 | | - } |
1268 | | - //inherit the cp settings for |
1269 | | - }, |
1270 | | - getSearchResults:function(){ |
1271 | | - var _this = this; |
1272 | | - this.loading=true; |
1273 | | - js_log('f:getSearchResults for:' + $j('#rsd_q').val() ); |
1274 | | - //empty out the current results: |
1275 | | - this.resultsObj={}; |
1276 | | - //do two queries against the Image / File / MVD namespace: |
1277 | | - |
1278 | | - //build the image request object: |
1279 | | - var reqObj = { |
1280 | | - 'action':'query', |
1281 | | - 'generator':'search', |
1282 | | - 'gsrsearch': encodeURIComponent( $j('#rsd_q').val() ), |
1283 | | - 'gsrnamespace':6, //(only search the "file" namespace (audio, video, images) |
1284 | | - 'gsrwhat':'title', |
1285 | | - 'gsrlimit': this.cp.limit, |
1286 | | - 'gsroffset': this.cp.offset, |
1287 | | - 'prop':'imageinfo|revisions|categories', |
1288 | | - 'iiprop':'url|mime', |
1289 | | - 'iiurlwidth': parseInt( this.rsd.thumb_width ), |
1290 | | - 'rvprop':'content' |
1291 | | - }; |
1292 | | - //set up the number of request: |
1293 | | - this.completed_req=0; |
1294 | | - this.num_req=1; |
1295 | | - this.last_query = $j('#rsd_q').val(); |
1296 | | - //setup the number of requests result flag: |
1297 | | - //do_api_req( reqObj, this.cp.api_url , function(data){ |
1298 | | - //parse the return data |
1299 | | - // _this.addResults( data); |
1300 | | - // _this.checkRequestDone(); |
1301 | | - //}); |
1302 | | - //also do a request for page titles (would be nice if api could query both at the same time) |
1303 | | - reqObj['gsrwhat']='text'; |
1304 | | - do_api_req( reqObj, this.cp.api_url , function(data){ |
1305 | | - //parse the return data |
1306 | | - _this.addResults( data); |
1307 | | - //_this.checkRequestDone(); //only need if we do two queries one for title one for text |
1308 | | - _this.loading = false; |
1309 | | - }); |
1310 | | - }, |
1311 | | - addResults:function( data ){ |
1312 | | - js_log("f:addResults"); |
1313 | | - var _this = this |
1314 | | - //check if we have |
1315 | | - if( typeof data['query-continue'] != 'undefined'){ |
1316 | | - if( typeof data['query-continue'].search != 'undefined') |
1317 | | - this.more_results = true; |
1318 | | - } |
1319 | | - //make sure we have pages to iderate: |
1320 | | - |
1321 | | - if(data.query && data.query.pages){ |
1322 | | - for(var page_id in data.query.pages){ |
1323 | | - var page = data.query.pages[ page_id ]; |
1324 | | - //make sure the reop is shared |
1325 | | - if( page.imagerepository == 'shared'){ |
1326 | | - continue; |
1327 | | - } |
1328 | | - //make sure the page is not a redirect |
1329 | | - if(page.revisions[0]['*'].indexOf('#REDIRECT')===0){ |
1330 | | - //skip page is redirect |
1331 | | - continue; |
1332 | | - } |
1333 | | - //skip if its an empy or missing imageinfo: |
1334 | | - if(!page.imageinfo) |
1335 | | - continue; |
1336 | | - |
1337 | | - this.resultsObj[page_id]={ |
1338 | | - 'titleKey' : page.title, |
1339 | | - 'link' :page.imageinfo[0].descriptionurl, |
1340 | | - 'title' :page.title.replace(/File:|.jpg|.png|.svg|.ogg|.ogv/ig, ''), |
1341 | | - 'poster' :page.imageinfo[0].thumburl, |
1342 | | - 'thumbwidth':page.imageinfo[0].thumbwidth, |
1343 | | - 'thumbheight':page.imageinfo[0].thumbheight, |
1344 | | - 'mime' :page.imageinfo[0].mime, |
1345 | | - 'src' :page.imageinfo[0].url, |
1346 | | - 'desc' :page.revisions[0]['*'], |
1347 | | - //add pointer to parent search obj: |
1348 | | - 'pSobj' :_this, |
1349 | | - 'meta':{ |
1350 | | - 'categories':page.categories |
1351 | | - } |
1352 | | - } |
1353 | | - this.num_results++; |
1354 | | - //for(var i in this.resultsObj[page_id]){ |
1355 | | - // js_log('added: '+ i +' '+ this.resultsObj[page_id][i]); |
1356 | | - //} |
1357 | | - } |
1358 | | - }else{ |
1359 | | - js_log('no results:' + data); |
1360 | | - } |
1361 | | - }, |
1362 | | - //check request done used for when we have multiple requests to check before formating results. |
1363 | | - checkRequestDone:function(){ |
1364 | | - //display output if done: |
1365 | | - this.completed_req++; |
1366 | | - if(this.completed_req == this.num_req){ |
1367 | | - this.loading = 0; |
1368 | | - } |
1369 | | - }, |
1370 | | - getImageObj:function( rObj, size, callback ){ |
1371 | | - if( rObj.mime=='application/ogg' ) |
1372 | | - return callback( {'url':rObj.src, 'poster' : rObj.url } ); |
1373 | | - |
1374 | | - //build the query to get the req size image: |
1375 | | - var reqObj = { |
1376 | | - 'action':'query', |
1377 | | - 'titles':rObj.titleKey, |
1378 | | - 'prop':'imageinfo', |
1379 | | - 'iiprop':'url|size|mime' |
1380 | | - } |
1381 | | - //set the width: |
1382 | | - if(size.width) |
1383 | | - reqObj['iiurlwidth']= size.width; |
1384 | | - |
1385 | | - do_api_req( reqObj, this.cp.api_url , function(data){ |
1386 | | - var imObj = {}; |
1387 | | - for(var page_id in data.query.pages){ |
1388 | | - var iminfo = data.query.pages[ page_id ].imageinfo[0]; |
1389 | | - //store the orginal width: |
1390 | | - imObj['org_width']=iminfo.width; |
1391 | | - //check if thumb size > than image size and is jpeg or png (it will not scale well above its max res) |
1392 | | - if( ( iminfo.mime=='image/jpeg' || iminfo=='image/png' ) && |
1393 | | - iminfo.thumbwidth > iminfo.width ){ |
1394 | | - imObj['url'] = iminfo.url; |
1395 | | - imObj['width'] = iminfo.width; |
1396 | | - imObj['height'] = iminfo.height; |
1397 | | - }else{ |
1398 | | - imObj['url'] = iminfo.thumburl; |
1399 | | - imObj['width'] = iminfo.thumbwidth; |
1400 | | - imObj['height'] = iminfo.thumbheight; |
1401 | | - } |
1402 | | - } |
1403 | | - js_log('getImageObj: get: ' + size.width + ' got url:' + imObj.url); |
1404 | | - callback( imObj ); |
1405 | | - }); |
1406 | | - }, |
1407 | | - //the insert image function |
1408 | | - insertImage:function( cEdit ){ |
1409 | | - if(!cEdit) |
1410 | | - var cEdit = _this.cEdit; |
1411 | | - }, |
1412 | | - getEmbedHTML: function( rObj , options) { |
1413 | | - //set up the output var with the default values: |
1414 | | - var outOpt = { 'width': rObj.width, 'height': rObj.height}; |
1415 | | - if( options['max_height'] ){ |
1416 | | - outOpt.height = (options.max_height > rObj.height) ? rObj.height : options.max_height; |
1417 | | - outOpt.width = (rObj.width / rObj.height) *outOpt.height; |
1418 | | - } |
1419 | | - var style_attr = 'style="width:' + outOpt.width + 'px;height:' + outOpt.height +'px"'; |
1420 | | - var id_attr = (options['id'])?' id = "' + options['id'] +'" ': ''; |
1421 | | - |
1422 | | - //return the html type: |
1423 | | - if(rObj.mime.indexOf('image')!=-1){ |
1424 | | - return '<img ' + id_attr + ' src="' + rObj.url + '"' + style_attr + ' >'; |
1425 | | - } |
1426 | | - if(rObj.mime.indexOf('application/ogg')!=-1){ |
1427 | | - return '<video ' + id_attr + |
1428 | | - ' src="' + rObj.src + '" ' + |
1429 | | - style_attr + |
1430 | | - ' poster="'+ rObj.poster + '" '+ |
1431 | | - ' ></video>'; |
1432 | | - } |
1433 | | - js_log('ERROR:unsupored mime type: ' + rObj.mime); |
1434 | | - }, |
1435 | | - //returns the inline wikitext for insertion (template based crops for now) |
1436 | | - getEmbedWikiText: function( rObj ){ |
1437 | | - //set default layout to right justified |
1438 | | - var layout = ( rObj.layout)? rObj.layout:"right" |
1439 | | - //if crop is null do base output: |
1440 | | - if( rObj.crop == null) |
1441 | | - return this.parent_getEmbedWikiText( rObj ); |
1442 | | - //using the preview crop template: http://en.wikipedia.org/wiki/Template:Preview_Crop |
1443 | | - //@@todo should be replaced with server side cropping |
1444 | | - return '{{Preview Crop ' + "\n" + |
1445 | | - '|Image = ' + rObj.target_resource_title + "\n" + |
1446 | | - '|bSize = ' + rObj.width + "\n" + |
1447 | | - '|cWidth = ' + rObj.crop.w + "\n" + |
1448 | | - '|cHeight = ' + rObj.crop.h + "\n" + |
1449 | | - '|oTop = ' + rObj.crop.y + "\n" + |
1450 | | - '|oLeft = ' + rObj.crop.x + "\n" + |
1451 | | - '|Location =' + layout + "\n" + |
1452 | | - '|Description =' + rObj.inlineDesc + "\n" + |
1453 | | - '}}'; |
1454 | | - } |
1455 | | -} |
\ No newline at end of file |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libSequencer/mvSequencer.js |
— | — | @@ -455,20 +455,28 @@ |
456 | 456 | if(typeof this.sequenceEditToken == 'undefined'){ |
457 | 457 | var reqObj = {'action':'query','prop':'info','intoken':'edit','titles': this_seq.plObj.mTitle}; |
458 | 458 | var api_url = this.plObj.interface_url.replace(/index\.php/, 'api.php'); |
459 | | - do_api_req( reqObj, api_url,function(data){ |
460 | | - for(var i in data.query.pages){ |
461 | | - if(data.query.pages[i]['edittoken']) |
462 | | - this_seq.sequenceEditToken = data.query.pages[i]['edittoken']; |
| 459 | + do_api_req( { |
| 460 | + 'data':reqObj, |
| 461 | + 'url':api_url |
| 462 | + },function(data){ |
| 463 | + for(var i in data.query.pages){ |
| 464 | + if(data.query.pages[i]['edittoken']) |
| 465 | + this_seq.sequenceEditToken = data.query.pages[i]['edittoken']; |
| 466 | + } |
| 467 | + this_seq.updateSeqSaveButtons(); |
463 | 468 | } |
464 | | - this_seq.updateSeqSaveButtons(); |
465 | | - }); |
| 469 | + ); |
466 | 470 | reqObj['titles']=this_seq.plObj.mTalk; |
467 | | - do_api_req(reqObj, api_url, function( data ){ |
468 | | - for(var j in data.query.pages){ |
469 | | - if(data.query.pages[j]['edittoken']) |
470 | | - this_seq.clipboardEditToken = data.query.pages[j]['edittoken']; |
| 471 | + do_api_req( { |
| 472 | + 'data':reqObj, |
| 473 | + 'url':api_url |
| 474 | + }, function( data ){ |
| 475 | + for(var j in data.query.pages){ |
| 476 | + if(data.query.pages[j]['edittoken']) |
| 477 | + this_seq.clipboardEditToken = data.query.pages[j]['edittoken']; |
| 478 | + } |
471 | 479 | } |
472 | | - }); |
| 480 | + ); |
473 | 481 | //also grab permissions for sending clipboard commands to the server |
474 | 482 | |
475 | 483 | //(calling the sequencer inline) try and get edit token via api call: |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/mvClipEdit.js |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | /* |
3 | 3 | hanndles clip edit controls |
4 | 4 | 'inoutpoints':0, //should let you set the in and out points of clip |
5 | | - 'panzoom':0, //should allow setting keyframes and tweening modes |
| 5 | + 'panzoom':0, //should allow setting keyframes and tweenning modes |
6 | 6 | 'overlays':0, //should allow setting "locked to clip" overlay tracks |
7 | 7 | 'audio':0 //should allow controlling the audio volume (with keyframes) |
8 | 8 | */ |
— | — | @@ -191,41 +191,45 @@ |
192 | 192 | //get the interface uri from the plObject |
193 | 193 | var api_url = _this.p_seqObj.plObj.interface_url.replace(/index\.php/, 'api.php'); |
194 | 194 | //first check |
195 | | - do_api_req( reqObj, api_url,function(data){ |
196 | | - if(typeof data.query.pages == 'undefined') |
197 | | - return doEditHtml(); |
198 | | - for(var i in data.query.pages){ |
199 | | - var page = data.query.pages[i]; |
200 | | - var template_rev = page['revisions'][0]['*']; |
201 | | - } |
202 | | - |
203 | | - //do a regular ex to get the ~likely~ template values |
204 | | - //(ofcourse this sucks) |
205 | | - //but maybe this will make its way into the api sometime soon to support wysiwyg type editors |
206 | | - //idealy it would expose a good deal of info about the template params |
207 | | - js_log('matching against: ' + template_rev); |
208 | | - var tempVars = template_rev.match(/\{\{\{([^\}]*)\}\}\}/gi); |
209 | | - //clean up results: |
210 | | - _this.rObj.tVars = new Array(); |
211 | | - for(var i=0; i < tempVars.length; i++){ |
212 | | - var tvar = tempVars[i].replace('{{{','').replace('}}}',''); |
213 | | - //strip anything after a | |
214 | | - if(tvar.indexOf('|') != -1){ |
215 | | - tvar = tvar.substr(0, tvar.indexOf('|')); |
216 | | - } |
217 | | - //check for duplicates: |
218 | | - var do_add=true; |
219 | | - for(var j=0; j < _this.rObj.tVars.length; j++){ |
220 | | - js_log('checking: ' + _this.rObj.tVars[j] + ' against:' + tvar); |
221 | | - if( _this.rObj.tVars[j] == tvar) |
222 | | - do_add=false; |
223 | | - } |
224 | | - //add the template vars to the output obj |
225 | | - if(do_add) |
226 | | - _this.rObj.tVars.push( tvar ); |
227 | | - } |
228 | | - doEditHtml(); |
229 | | - }); |
| 195 | + do_api_req( { |
| 196 | + 'data':reqObj, |
| 197 | + 'url':api_url |
| 198 | + }, function(data){ |
| 199 | + if(typeof data.query.pages == 'undefined') |
| 200 | + return doEditHtml(); |
| 201 | + for(var i in data.query.pages){ |
| 202 | + var page = data.query.pages[i]; |
| 203 | + var template_rev = page['revisions'][0]['*']; |
| 204 | + } |
| 205 | + |
| 206 | + //do a regular ex to get the ~likely~ template values |
| 207 | + //(ofcourse this sucks) |
| 208 | + //but maybe this will make its way into the api sometime soon to support wysiwyg type editors |
| 209 | + //idealy it would expose a good deal of info about the template params |
| 210 | + js_log('matching against: ' + template_rev); |
| 211 | + var tempVars = template_rev.match(/\{\{\{([^\}]*)\}\}\}/gi); |
| 212 | + //clean up results: |
| 213 | + _this.rObj.tVars = new Array(); |
| 214 | + for(var i=0; i < tempVars.length; i++){ |
| 215 | + var tvar = tempVars[i].replace('{{{','').replace('}}}',''); |
| 216 | + //strip anything after a | |
| 217 | + if(tvar.indexOf('|') != -1){ |
| 218 | + tvar = tvar.substr(0, tvar.indexOf('|')); |
| 219 | + } |
| 220 | + //check for duplicates: |
| 221 | + var do_add=true; |
| 222 | + for(var j=0; j < _this.rObj.tVars.length; j++){ |
| 223 | + js_log('checking: ' + _this.rObj.tVars[j] + ' against:' + tvar); |
| 224 | + if( _this.rObj.tVars[j] == tvar) |
| 225 | + do_add=false; |
| 226 | + } |
| 227 | + //add the template vars to the output obj |
| 228 | + if(do_add) |
| 229 | + _this.rObj.tVars.push( tvar ); |
| 230 | + } |
| 231 | + doEditHtml(); |
| 232 | + } |
| 233 | + ); |
230 | 234 | }else{ |
231 | 235 | doEditHtml(); |
232 | 236 | } |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js |
— | — | @@ -1022,43 +1022,46 @@ |
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | //does a remote or local api request based on request url |
1026 | | -function do_api_req(req_param, api_url, callback){ |
1027 | | - if(typeof req_param != 'object'){ |
| 1026 | +//@param : url, data, cbParam, callback |
| 1027 | +function do_api_req( options, callback ){ |
| 1028 | + if(typeof options.data != 'object'){ |
1028 | 1029 | js_log('Error: request paramaters must be an object'); |
1029 | 1030 | return false; |
1030 | 1031 | } |
1031 | | - if( !api_url){ |
| 1032 | + if( typeof options.url == 'undefined' ){ |
1032 | 1033 | if(!wgServer || ! wgScriptPath){ |
1033 | 1034 | js_log('Error: no api url'); |
1034 | 1035 | return false; |
1035 | | - } |
1036 | | - |
1037 | | - api_url = wgServer +((wgServer == null) ? parseUri(document.URL).host + (wgScriptPath + "/api.php") : parseUri(document.URL).host + wgScript); |
| 1036 | + } |
| 1037 | + options.url = wgServer +((wgServer == null) ? parseUri(document.URL).host + (wgScriptPath + "/api.php") : parseUri(document.URL).host + wgScript); |
1038 | 1038 | //update to api.php (if index.php was in the wgScript path): |
1039 | | - api_url = api_url.replace('index.php', 'api.php'); |
1040 | | - } |
1041 | | - //build request string: (force the format to json): |
1042 | | - var req_url = api_url + '?format=json'; |
1043 | | - if( parseUri(document.URL).host == parseUri(api_url).host ){ |
| 1039 | + options.url = options.url.replace('index.php', 'api.php'); |
| 1040 | + } |
| 1041 | + if(typeof options.data == 'undefined') |
| 1042 | + options.data = {}; |
| 1043 | + //build request string: (force the format to json): |
| 1044 | + if( parseUri(document.URL).host == parseUri( options['api_url'] ).host ){ |
1044 | 1045 | //local request do api request directly |
1045 | 1046 | $j.ajax({ |
1046 | 1047 | type: "POST", |
1047 | | - url:req_url, |
1048 | | - data: req_param, |
| 1048 | + url: options.url, |
| 1049 | + data: options.data, |
1049 | 1050 | async: false, |
1050 | | - success:function(data){ |
1051 | | - eval('var result_data=' + data ); |
1052 | | - callback( result_data ); |
| 1051 | + success:function(data){ |
| 1052 | + callback( data ); |
1053 | 1053 | } |
1054 | 1054 | }); |
1055 | 1055 | }else{ |
| 1056 | + if( typeof options.cbParam == 'undefiend') |
| 1057 | + options.cbParam = 'callback'; |
| 1058 | + |
1056 | 1059 | //put all the values into the GET req: |
1057 | 1060 | for(var i in req_param){ |
1058 | 1061 | req_url += '&' + encodeURIComponent( i ) + '=' + encodeURIComponent( req_param[i] ); |
1059 | 1062 | } |
1060 | 1063 | var fname = 'mycpfn_' + ( global_cb_count++ ); |
1061 | | - _global[ fname ] = callback ; |
1062 | | - req_url += '&callback=' + fname; |
| 1064 | + _global[ fname ] = callback; |
| 1065 | + req_url += '&' + options.cbParam + '=' + fname; |
1063 | 1066 | loadExternalJs( req_url ); |
1064 | 1067 | } |
1065 | 1068 | } |
— | — | @@ -1078,7 +1081,7 @@ |
1079 | 1082 | callback( data ); |
1080 | 1083 | } |
1081 | 1084 | }); |
1082 | | - }else{ |
| 1085 | + }else{ |
1083 | 1086 | //get data via DOM injection with callback |
1084 | 1087 | global_req_cb.push(callback); |
1085 | 1088 | //prepend json_ to feed_format if not already requesting json format |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libEmbedObj/mv_baseEmbed.js |
— | — | @@ -187,7 +187,7 @@ |
188 | 188 | +' <p class="short_match"><a href="javascript:$j(\'#'+ctrlBuilder.id+'\').get(0).showEmbedCode();" onClick="$j(\'#mv_embedded_options_'+ctrlBuilder.id+'\').hide();" ><span><strong>Share or Embed</strong></span></a></p>'; |
189 | 189 | |
190 | 190 | //link to the stream page if we are not already there: |
191 | | - if( ctrlBuilder.embedObj.roe ) |
| 191 | + if( ctrlBuilder.embedObj.roe && typeof mv_stream_interface == 'undefined' ) |
192 | 192 | o+='<p class="short_match"><a href="javascript:$j(\'#'+ctrlBuilder.id+'\').get(0).doLinkBack()"><span><strong>Source Page</strong></span></a></p>'; |
193 | 193 | |
194 | 194 | o+='' |