Timeline.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. <template>
  2. <div class="container" style="">
  3. <div class="row">
  4. <div class="col-md-8 col-lg-8 pt-2 px-0 my-3 timeline">
  5. <div class="loader text-center">
  6. <div class="lds-ring"><div></div><div></div><div></div><div></div></div>
  7. </div>
  8. <div class="card mb-4 status-card card-md-rounded-0" :data-status-id="status.id" v-for="(status, index) in feed" :key="status.id">
  9. <div class="card-header d-inline-flex align-items-center bg-white">
  10. <img v-bind:src="status.account.avatar" width="32px" height="32px" style="border-radius: 32px;">
  11. <a class="username font-weight-bold pl-2 text-dark" v-bind:href="status.account.url">
  12. {{status.account.username}}
  13. </a>
  14. <div class="text-right" style="flex-grow:1;">
  15. <div class="dropdown">
  16. <button class="btn btn-link text-dark no-caret dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Post options">
  17. <span class="fas fa-ellipsis-v fa-lg text-muted"></span>
  18. </button>
  19. <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
  20. <a class="dropdown-item font-weight-bold" :href="status.url">Go to post</a>
  21. <span v-bind:class="[statusOwner(status) ? 'd-none' : '']">
  22. <a class="dropdown-item font-weight-bold" :href="reportUrl(status)">Report</a>
  23. <a class="dropdown-item font-weight-bold" v-on:click="muteProfile(status)">Mute Profile</a>
  24. <a class="dropdown-item font-weight-bold" v-on:click="blockProfile(status)">Block Profile</a>
  25. </span>
  26. <span v-bind:class="[statusOwner(status) ? '' : 'd-none']">
  27. <a class="dropdown-item font-weight-bold" :href="editUrl(status)">Edit</a>
  28. <a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost(status)">Delete</a>
  29. </span>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. <div class="postPresenterContainer">
  35. <div v-if="status.pf_type === 'photo'" class="w-100">
  36. <div v-if="status.sensitive == true">
  37. <details class="details-animated">
  38. <summary>
  39. <p class="mb-0 lead font-weight-bold">{{ status.spoiler_text ? status.spoiler_text : 'CW / NSFW / Hidden Media'}}</p>
  40. <p class="font-weight-light">(click to show)</p>
  41. </summary>
  42. <a class="max-hide-overflow" :href="status.url" :class="status.media_attachments[0].filter_class">
  43. <img class="card-img-top" :src="status.media_attachments[0].url">
  44. </a>
  45. </details>
  46. </div>
  47. <div v-else>
  48. <div :class="status.media_attachments[0].filter_class">
  49. <img class="card-img-top" :src="status.media_attachments[0].url">
  50. </div>
  51. </div>
  52. </div>
  53. <div v-else-if="status.pf_type === 'video'" class="w-100">
  54. <div v-if="status.sensitive == true">
  55. <details class="details-animated">
  56. <summary>
  57. <p class="mb-0 lead font-weight-bold">{{ status.spoiler_text ? status.spoiler_text : 'CW / NSFW / Hidden Media'}}</p>
  58. <p class="font-weight-light">(click to show)</p>
  59. </summary>
  60. <div class="embed-responsive embed-responsive-16by9">
  61. <video class="video" preload="none" controls loop>
  62. <source :src="status.media_attachments[0].url" :type="status.media_attachments[0].mime">
  63. </video>
  64. </div>
  65. </details>
  66. </div>
  67. <div v-else class="embed-responsive embed-responsive-16by9">
  68. <video class="video" preload="none" controls loop>
  69. <source :src="status.media_attachments[0].url" :type="status.media_attachments[0].mime">
  70. </video>
  71. </div>
  72. </div>
  73. <div v-else-if="status.pf_type === 'photo:album'" class="w-100">
  74. <div v-if="status.sensitive == true">
  75. <details class="details-animated">
  76. <summary>
  77. <p class="mb-0 lead font-weight-bold">{{ status.spoiler_text ? status.spoiler_text : 'CW / NSFW / Hidden Media'}}</p>
  78. <p class="font-weight-light">(click to show)</p>
  79. </summary>
  80. <b-carousel :id="status.id + '-carousel'"
  81. style="text-shadow: 1px 1px 2px #333;"
  82. controls
  83. indicators
  84. background="#ffffff"
  85. :interval="0"
  86. >
  87. <b-carousel-slide v-for="(img, index) in status.media_attachments" :key="img.id">
  88. <img slot="img" class="d-block img-fluid w-100" :src="img.url" :alt="img.description">
  89. </b-carousel-slide>
  90. </b-carousel>
  91. </details>
  92. </div>
  93. <div v-else>
  94. <b-carousel :id="status.id + '-carousel'"
  95. style="text-shadow: 1px 1px 2px #333;"
  96. controls
  97. indicators
  98. background="#ffffff"
  99. :interval="0"
  100. >
  101. <b-carousel-slide v-for="(img, index) in status.media_attachments" :key="img.id">
  102. <img slot="img" class="d-block img-fluid w-100" :src="img.url" :alt="img.description">
  103. </b-carousel-slide>
  104. </b-carousel>
  105. </div>
  106. </div>
  107. <div v-else-if="status.pf_type === 'video:album'" class="w-100">
  108. <div v-if="status.sensitive == true">
  109. <details class="details-animated">
  110. <summary>
  111. <p class="mb-0 lead font-weight-bold">{{ status.spoiler_text ? status.spoiler_text : 'CW / NSFW / Hidden Media'}}</p>
  112. <p class="font-weight-light">(click to show)</p>
  113. </summary>
  114. <b-carousel :id="status.id + '-carousel'"
  115. style="text-shadow: 1px 1px 2px #333; background-color: #000;"
  116. controls
  117. img-blank
  118. background="#ffffff"
  119. :interval="0"
  120. >
  121. <b-carousel-slide v-for="(vid, index) in status.media_attachments" :key="vid.id + '-media'">
  122. <video slot="img" class="embed-responsive-item" preload="none" controls loop :alt="vid.description" width="100%" height="100%">
  123. <source :src="vid.url" :type="vid.mime">
  124. </video>
  125. </b-carousel-slide>
  126. </b-carousel>
  127. </details>
  128. </div>
  129. <div v-else>
  130. <b-carousel :id="status.id + '-carousel'"
  131. style="text-shadow: 1px 1px 2px #333; background-color: #000;"
  132. controls
  133. img-blank
  134. background="#ffffff"
  135. :interval="0"
  136. >
  137. <b-carousel-slide v-for="(vid, index) in status.media_attachments" :key="vid.id + '-media'">
  138. <video slot="img" class="embed-responsive-item" preload="none" controls loop :alt="vid.description" width="100%" height="100%">
  139. <source :src="vid.url" :type="vid.mime">
  140. </video>
  141. </b-carousel-slide>
  142. </b-carousel>
  143. </div>
  144. </div>
  145. <div v-else-if="status.pf_type === 'photo:video:album'" class="w-100">
  146. <div v-if="status.sensitive == true">
  147. <details class="details-animated">
  148. <summary>
  149. <p class="mb-0 lead font-weight-bold">{{ status.spoiler_text ? status.spoiler_text : 'CW / NSFW / Hidden Media'}}</p>
  150. <p class="font-weight-light">(click to show)</p>
  151. </summary>
  152. <b-carousel :id="status.id + '-carousel'"
  153. style="text-shadow: 1px 1px 2px #333; background-color: #000;"
  154. controls
  155. img-blank
  156. background="#ffffff"
  157. :interval="0"
  158. >
  159. <b-carousel-slide v-for="(media, index) in status.media_attachments" :key="media.id + '-media'">
  160. <video v-if="media.type == 'Video'" slot="img" class="embed-responsive-item" preload="none" controls loop :alt="media.description" width="100%" height="100%">
  161. <source :src="media.url" :type="media.mime">
  162. </video>
  163. <img v-else-if="media.type == 'Image'" slot="img" class="d-block img-fluid w-100" :src="media.url" :alt="media.description">
  164. <p v-else class="text-center p-0 font-weight-bold text-white">Error: Problem rendering preview.</p>
  165. </b-carousel-slide>
  166. </b-carousel>
  167. </details>
  168. </div>
  169. <div v-else>
  170. <b-carousel :id="status.id + '-carousel'"
  171. style="text-shadow: 1px 1px 2px #333; background-color: #000;"
  172. controls
  173. img-blank
  174. background="#ffffff"
  175. :interval="0"
  176. >
  177. <b-carousel-slide v-for="(media, index) in status.media_attachments" :key="media.id + '-media'">
  178. <video v-if="media.type == 'Video'" slot="img" class="embed-responsive-item" preload="none" controls loop :alt="media.description" width="100%" height="100%">
  179. <source :src="media.url" :type="media.mime">
  180. </video>
  181. <img v-else-if="media.type == 'Image'" slot="img" class="d-block img-fluid w-100" :src="media.url" :alt="media.description">
  182. <p v-else class="text-center p-0 font-weight-bold text-white">Error: Problem rendering preview.</p>
  183. </b-carousel-slide>
  184. </b-carousel>
  185. </div>
  186. </div>
  187. <div v-else class="w-100">
  188. <p class="text-center p-0 font-weight-bold text-white">Error: Problem rendering preview.</p>
  189. </div>
  190. </div>
  191. <div class="card-body">
  192. <div class="reactions my-1">
  193. <h3 v-bind:class="[status.favourited ? 'fas fa-heart text-danger pr-3 m-0 cursor-pointer' : 'far fa-heart pr-3 m-0 like-btn cursor-pointer']" title="Like" v-on:click="likeStatus(status, $event)"></h3>
  194. <h3 class="far fa-comment pr-3 m-0 cursor-pointer" title="Comment" v-on:click="commentFocus(status, $event)"></h3>
  195. <h3 v-bind:class="[status.reblogged ? 'far fa-share-square pr-3 m-0 text-primary cursor-pointer' : 'far fa-share-square pr-3 m-0 share-btn cursor-pointer']" title="Share" v-on:click="shareStatus(status, $event)"></h3>
  196. </div>
  197. <div class="likes font-weight-bold">
  198. <span class="like-count">{{status.favourites_count}}</span> {{status.favourites_count == 1 ? 'like' : 'likes'}}
  199. </div>
  200. <div class="caption">
  201. <p class="mb-2 read-more" style="overflow: hidden;">
  202. <span class="username font-weight-bold">
  203. <bdi><a class="text-dark" :href="status.account.url">{{status.account.username}}</a></bdi>
  204. </span>
  205. <span v-html="status.content"></span>
  206. </p>
  207. </div>
  208. <div class="comments">
  209. </div>
  210. <div class="timestamp pt-1">
  211. <p class="small text-uppercase mb-0">
  212. <a :href="status.url" class="text-muted">
  213. <timeago :datetime="status.created_at" :auto-update="60" :converter-options="{includeSeconds:true}" :title="timestampFormat(status.created_at)" v-b-tooltip.hover.bottom></timeago>
  214. </a>
  215. </p>
  216. </div>
  217. </div>
  218. <div class="card-footer bg-white d-none">
  219. <form class="" v-on:submit.prevent="commentSubmit(status, $event)">
  220. <input type="hidden" name="item" value="">
  221. <input class="form-control status-reply-input" name="comment" placeholder="Add a comment…" autocomplete="off">
  222. </form>
  223. </div>
  224. </div>
  225. </div>
  226. <div class="col-md-4 col-lg-4 pt-2 my-3">
  227. <div class="mb-4">
  228. <div class="card profile-card">
  229. <div class="card-body loader text-center">
  230. <div class="lds-ring"><div></div><div></div><div></div><div></div></div>
  231. </div>
  232. <div class="card-body contents d-none">
  233. <div class="media d-flex align-items-center">
  234. <a :href="profile.url">
  235. <img class="mr-3 rounded-circle box-shadow" :src="profile.avatar || '/storage/avatars/default.png'" alt="avatar" width="64px" height="64px">
  236. </a>
  237. <div class="media-body">
  238. <p class="mb-0 px-0 font-weight-bold"><a :href="profile.url" class="text-dark">&commat;{{profile.username}}</a></p>
  239. <p class="my-0 text-muted text-truncate pb-0">{{profile.display_name}}</p>
  240. </div>
  241. </div>
  242. </div>
  243. <div class="card-footer bg-white py-1 d-none">
  244. <div class="d-flex justify-content-between text-center">
  245. <span class="pl-3">
  246. <p class="mb-0 font-weight-bold">{{profile.statuses_count}}</p>
  247. <p class="mb-0 small text-muted">Posts</p>
  248. </span>
  249. <span>
  250. <p class="mb-0 font-weight-bold">{{profile.followers_count}}</p>
  251. <p class="mb-0 small text-muted">Followers</p>
  252. </span>
  253. <span class="pr-3">
  254. <p class="mb-0 font-weight-bold">{{profile.following_count}}</p>
  255. <p class="mb-0 small text-muted">Following</p>
  256. </span>
  257. </div>
  258. </div>
  259. </div>
  260. </div>
  261. <div class="mb-4">
  262. <div class="card notification-card">
  263. <div class="card-header bg-white">
  264. <p class="mb-0 d-flex align-items-center justify-content-between">
  265. <span class="text-muted font-weight-bold">Notifications</span>
  266. <a class="text-dark small" href="/account/activity">See All</a>
  267. </p>
  268. </div>
  269. <div class="card-body loader text-center" style="height: 300px;">
  270. <div class="lds-ring"><div></div><div></div><div></div><div></div></div>
  271. </div>
  272. <div class="card-body pt-2 contents" style="max-height: 300px; overflow-y: scroll;">
  273. <div class="media mb-3 align-items-center" v-for="(n, index) in notifications">
  274. <img class="mr-2 rounded-circle img-thumbnail" :src="n.account.avatar" alt="" width="32px" height="32px">
  275. <div class="media-body font-weight-light small">
  276. <div v-if="n.type == 'favourite'">
  277. <p class="my-0">
  278. <span class="font-weight-bold">{{n.account.username}}</span> liked your post.
  279. </p>
  280. </div>
  281. <div v-else-if="n.type == 'comment'">
  282. <p class="my-0">
  283. <span class="font-weight-bold">{{n.account.username}}</span> commented on your post.
  284. </p>
  285. </div>
  286. <div v-else-if="n.type == 'mention'">
  287. <p class="my-0">
  288. <span class="font-weight-bold">{{n.account.username}}</span> mentioned you.
  289. </p>
  290. </div>
  291. <div v-else-if="n.type == 'follow'">
  292. <p class="my-0">
  293. <span class="font-weight-bold">{{n.account.username}}</span> followed you.
  294. </p>
  295. </div>
  296. </div>
  297. </div>
  298. </div>
  299. </div>
  300. </div>
  301. <footer>
  302. <div class="container pb-5">
  303. <p class="mb-0 text-uppercase font-weight-bold text-muted small">
  304. <a href="/site/about" class="text-dark pr-2">About Us</a>
  305. <a href="/site/help" class="text-dark pr-2">Support</a>
  306. <a href="/site/open-source" class="text-dark pr-2">Open Source</a>
  307. <a href="/site/language" class="text-dark pr-2">Language</a>
  308. <a href="/site/terms" class="text-dark pr-2">Terms</a>
  309. <a href="/site/privacy" class="text-dark pr-2">Privacy</a>
  310. <a href="/site/platform" class="text-dark pr-2">API</a>
  311. </p>
  312. <p class="mb-0 text-uppercase font-weight-bold text-muted small">
  313. <a href="http://pixelfed.org" class="text-muted" rel="noopener" title="" data-toggle="tooltip">Powered by PixelFed</a>
  314. </p>
  315. </div>
  316. </footer>
  317. </div>
  318. </div>
  319. </div>
  320. </template>
  321. <style type="text/css">
  322. .postPresenterContainer {
  323. display: flex;
  324. align-items: center;
  325. background: #000;
  326. }
  327. @media(min-width: 720px) {
  328. .postPresenterContainer {
  329. min-height: 600px;
  330. }
  331. }
  332. .cursor-pointer {
  333. cursor: pointer;
  334. }
  335. </style>
  336. <script type="text/javascript">
  337. export default {
  338. data() {
  339. return {
  340. page: 1,
  341. feed: [],
  342. profile: {},
  343. scope: window.location.pathname,
  344. min_id: 0,
  345. max_id: 0,
  346. notifications: {},
  347. stories: {},
  348. suggestions: {},
  349. }
  350. },
  351. beforeMount() {
  352. this.fetchTimelineApi();
  353. this.fetchProfile();
  354. },
  355. mounted() {
  356. },
  357. updated() {
  358. this.scroll();
  359. },
  360. methods: {
  361. fetchProfile() {
  362. axios.get('/api/v1/accounts/verify_credentials').then(res => {
  363. this.profile = res.data;
  364. $('.profile-card .loader').addClass('d-none');
  365. $('.profile-card .contents').removeClass('d-none');
  366. $('.profile-card .card-footer').removeClass('d-none');
  367. this.fetchNotifications();
  368. }).catch(err => {
  369. swal(
  370. 'Oops, something went wrong',
  371. 'Please reload the page.',
  372. 'error'
  373. );
  374. });
  375. },
  376. fetchTimelineApi() {
  377. let homeTimeline = '/api/v1/timelines/home?page=' + this.page;
  378. let localTimeline = '/api/v1/timelines/public?page=' + this.page;
  379. let apiUrl = this.scope == '/' ? homeTimeline : localTimeline;
  380. axios.get(apiUrl).then(res => {
  381. $('.timeline .loader').addClass('d-none');
  382. let data = res.data;
  383. this.feed.push(...data);
  384. let ids = data.map(status => status.id);
  385. this.min_id = Math.min(...ids);
  386. if(this.page == 1) {
  387. this.max_id = Math.max(...ids);
  388. }
  389. this.page++;
  390. }).catch(err => {
  391. });
  392. },
  393. fetchNotifications() {
  394. axios.get('/api/v1/notifications')
  395. .then(res => {
  396. this.notifications = res.data;
  397. $('.notification-card .loader').addClass('d-none');
  398. $('.notification-card .contents').removeClass('d-none');
  399. });
  400. },
  401. scroll() {
  402. window.onscroll = () => {
  403. let bottomOfWindow = document.documentElement.scrollTop + window.innerHeight == document.documentElement.offsetHeight;
  404. if (bottomOfWindow) {
  405. this.fetchTimelineApi();
  406. }
  407. };
  408. },
  409. reportUrl(status) {
  410. let type = status.in_reply_to ? 'comment' : 'post';
  411. let id = status.id;
  412. return '/i/report?type=' + type + '&id=' + id;
  413. },
  414. commentFocus(status, $event) {
  415. let el = event.target;
  416. let card = el.parentElement.parentElement.parentElement;
  417. let comments = card.getElementsByClassName('comments')[0];
  418. if(comments.children.length == 0) {
  419. comments.classList.add('mb-2');
  420. this.fetchStatusComments(status, card);
  421. }
  422. let footer = card.querySelectorAll('.card-footer')[0];
  423. let input = card.querySelectorAll('.status-reply-input')[0];
  424. if(footer.classList.contains('d-none') == true) {
  425. footer.classList.remove('d-none');
  426. input.focus();
  427. } else {
  428. footer.classList.add('d-none');
  429. input.blur();
  430. }
  431. },
  432. likeStatus(status, $event) {
  433. if($('body').hasClass('loggedIn') == false) {
  434. return;
  435. }
  436. axios.post('/i/like', {
  437. item: status.id
  438. }).then(res => {
  439. status.favourites_count = res.data.count;
  440. if(status.favourited == true) {
  441. status.favourited = false;
  442. } else {
  443. status.favourited = true;
  444. }
  445. }).catch(err => {
  446. swal('Error', 'Something went wrong, please try again later.', 'error');
  447. });
  448. },
  449. shareStatus(status, $event) {
  450. if($('body').hasClass('loggedIn') == false) {
  451. return;
  452. }
  453. axios.post('/i/share', {
  454. item: status.id
  455. }).then(res => {
  456. status.reblogs_count = res.data.count;
  457. if(status.reblogged == true) {
  458. status.reblogged = false;
  459. } else {
  460. status.reblogged = true;
  461. }
  462. }).catch(err => {
  463. swal('Error', 'Something went wrong, please try again later.', 'error');
  464. });
  465. },
  466. timestampFormat(timestamp) {
  467. let ts = new Date(timestamp);
  468. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  469. },
  470. editUrl(status) {
  471. return status.url + '/edit';
  472. },
  473. statusOwner(status) {
  474. let sid = status.account.id;
  475. let uid = this.profile.id;
  476. if(sid == uid) {
  477. return true;
  478. } else {
  479. return false;
  480. }
  481. },
  482. fetchStatusComments(status, card) {
  483. axios.get('/api/v2/status/'+status.id+'/replies')
  484. .then(res => {
  485. let comments = card.querySelectorAll('.comments')[0];
  486. let data = res.data;
  487. data.forEach(function(i, k) {
  488. let username = document.createElement('a');
  489. username.classList.add('font-weight-bold');
  490. username.classList.add('text-dark');
  491. username.classList.add('mr-2');
  492. username.setAttribute('href', i.account.url);
  493. username.textContent = i.account.username;
  494. let text = document.createElement('span');
  495. text.innerHTML = i.content;
  496. let comment = document.createElement('p');
  497. comment.classList.add('read-more');
  498. comment.classList.add('mb-0');
  499. comment.appendChild(username);
  500. comment.appendChild(text);
  501. comments.appendChild(comment);
  502. });
  503. }).catch(err => {
  504. })
  505. },
  506. muteProfile(status) {
  507. if($('body').hasClass('loggedIn') == false) {
  508. return;
  509. }
  510. axios.post('/i/mute', {
  511. type: 'user',
  512. item: status.account.id
  513. }).then(res => {
  514. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  515. swal('Success', 'You have successfully muted ' + status.account.acct, 'success');
  516. }).catch(err => {
  517. swal('Error', 'Something went wrong. Please try again later.', 'error');
  518. });
  519. },
  520. blockProfile(status) {
  521. if($('body').hasClass('loggedIn') == false) {
  522. return;
  523. }
  524. axios.post('/i/block', {
  525. type: 'user',
  526. item: status.account.id
  527. }).then(res => {
  528. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  529. swal('Success', 'You have successfully blocked ' + status.account.acct, 'success');
  530. }).catch(err => {
  531. swal('Error', 'Something went wrong. Please try again later.', 'error');
  532. });
  533. },
  534. deletePost(status, index) {
  535. if($('body').hasClass('loggedIn') == false || status.account.id !== this.profile.id) {
  536. return;
  537. }
  538. axios.post('/i/delete', {
  539. type: 'status',
  540. item: status.id
  541. }).then(res => {
  542. this.feed.splice(index,1);
  543. swal('Success', 'You have successfully deleted this post', 'success');
  544. }).catch(err => {
  545. swal('Error', 'Something went wrong. Please try again later.', 'error');
  546. });
  547. },
  548. commentSubmit(status, $event) {
  549. let id = status.id;
  550. let form = $event.target;
  551. let input = $(form).find('input[name="comment"]');
  552. let comment = input.val();
  553. let comments = form.parentElement.parentElement.getElementsByClassName('comments')[0];
  554. axios.post('/i/comment', {
  555. item: id,
  556. comment: comment
  557. }).then(res => {
  558. input.val('');
  559. input.blur();
  560. let username = document.createElement('a');
  561. username.classList.add('font-weight-bold');
  562. username.classList.add('text-dark');
  563. username.classList.add('mr-2');
  564. username.setAttribute('href', this.profile.url);
  565. username.textContent = this.profile.username;
  566. let text = document.createElement('span');
  567. text.innerHTML = comment;
  568. let wrapper = document.createElement('p');
  569. wrapper.classList.add('read-more');
  570. wrapper.classList.add('mb-0');
  571. wrapper.appendChild(username);
  572. wrapper.appendChild(text);
  573. comments.insertBefore(wrapper, comments.firstChild);
  574. });
  575. }
  576. }
  577. }
  578. </script>