User:Docmoates/Social: Difference between revisions

From XMethod Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 100: Line 100:
var pendingImg='';
var pendingImg='';
var api=new mw.Api();
var api=new mw.Api();
var AND=function(a,b){return a?b:false;};


function init(n){return n.split(/[\s_]+/).map(function(w){return w[0]||'';}).join('').substring(0,2).toUpperCase()||'?';}
function init(n){return n.split(/[\s_]+/).map(function(w){return w[0]||'';}).join('').substring(0,2).toUpperCase()||'?';}
Line 133: Line 134:
document.getElementById('post-btn').onclick=function(){
document.getElementById('post-btn').onclick=function(){
var c=document.getElementById('post-content').value.trim();
var c=document.getElementById('post-content').value.trim();
if(!c&&!pendingImg){alert('Write something or add image');return;}
if(!(c||pendingImg)){alert('Write something or add image');return;}
var btn=this;btn.disabled=true;btn.textContent='Posting...';
var btn=this;btn.disabled=true;btn.textContent='Posting...';
var p={action:'socialfeed',sfaction:'createpost',content:c||'(photo)'};
var p={action:'socialfeed',sfaction:'createpost',content:c||'(photo)'};
Line 142: Line 143:
btn.disabled=false;btn.textContent='Post';
btn.disabled=false;btn.textContent='Post';
load();
load();
}).fail(function(code,data){alert('Error: '+(data&&data.error?data.error.info:code));btn.disabled=false;btn.textContent='Post';});
}).fail(function(code,data){var msg=code;if(data){if(data.error){msg=data.error.info;}}alert('Error: '+msg);btn.disabled=false;btn.textContent='Post';});
};
};


Line 185: Line 186:
h+='<div class="sf-add-comment"><div class="sf-avatar sf-avatar-small">'+myPic+'</div><input class="sf-comment-input" id="cinput-'+id+'" placeholder="Write a comment..."></div>';
h+='<div class="sf-add-comment"><div class="sf-avatar sf-avatar-small">'+myPic+'</div><input class="sf-comment-input" id="cinput-'+id+'" placeholder="Write a comment..."></div>';
box.innerHTML=h;
box.innerHTML=h;
document.getElementById('cinput-'+id).onkeypress=function(e){if(e.key==='Enter'&&this.value.trim()){var v=this.value.trim();this.value='';api.postWithToken('csrf',{action:'socialfeed',sfaction:'comment',post_id:id,content:v}).done(function(){loadCmt(id);load();});}};
document.getElementById('cinput-'+id).onkeypress=function(e){if(e.key==='Enter'){if(this.value.trim()){var v=this.value.trim();this.value='';api.postWithToken('csrf',{action:'socialfeed',sfaction:'comment',post_id:id,content:v}).done(function(){loadCmt(id);load();});}}};
});
});
}
}

Revision as of 23:55, 2 February 2026

Add Story
?
Edit
📝
No posts yet
Be the first to share something!
Set Profile Photo

Upload to wiki first, then paste URL