User:Docmoates/Social: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 280: | Line 280: | ||
<script> | <script> | ||
function initSocialFeed(){ | function initSocialFeed(){ | ||
var apiBase= | var apiBase=mw.util.wikiScript('api'); | ||
var user=mw.config.get('wgUserName')||'Guest'; | |||
var api=new mw.Api(); | |||
var | |||
user=mw.config.get('wgUserName') | |||
var photo=localStorage.getItem('sf_photo_'+user)||''; | var photo=localStorage.getItem('sf_photo_'+user)||''; | ||
| Line 316: | Line 307: | ||
function apiGet(params){ | function apiGet(params){ | ||
return api.get(params); | |||
return | |||
} | } | ||
function apiPost(params){ | function apiPost(params){ | ||
return api.postWithToken('csrf',params); | |||
return | |||
} | } | ||
function getToken(){ | function getToken(){ | ||
return api.getToken('csrf'); | |||
return | |||
} | } | ||
function uploadFile(file,prefix,onProgress,onDone,onError){ | function uploadFile(file,prefix,onProgress,onDone,onError){ | ||
var filename=prefix+'_'+user+'_'+Date.now()+'.'+file.name.split('.').pop(); | var filename=prefix+'_'+user+'_'+Date.now()+'.'+file.name.split('.').pop(); | ||
api.upload(file,{filename:filename,ignorewarnings:true}).progress(function(pct){ | |||
onProgress(pct*100); | |||
}).done(function(resp){ | |||
if(resp.upload){ | if(resp.upload){ | ||
if(resp.upload.imageinfo){onDone(resp.upload.imageinfo.url);} | if(resp.upload.imageinfo){onDone(resp.upload.imageinfo.url);} | ||
else | else{onError('Upload issue: '+JSON.stringify(resp.upload));} | ||
else{onError('Upload | }else{onError('Upload failed');} | ||
} | }).fail(function(code,result){ | ||
onError('Upload error: '+(result.error?result.error.info:code)); | |||
}); | |||
} | } | ||
| Line 982: | Line 932: | ||
} | } | ||
mw.loader.using(['mediawiki.api','mediawiki.util']).then(initSocialFeed); | |||
mw.loader.using(['mediawiki.api']).then( | |||
</script> | </script> | ||
</div> | </div> | ||
</html> | </html> | ||
Revision as of 03:17, 3 February 2026
Uploading...
Uploading...
Uploading...
Uploading...
Supports YouTube, Vimeo, or direct video URLs
— or —