Javascript for editing posts simplified