Timeline.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  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">
  43. <img class="card-img-top" :src="status.media_attachments[0].url">
  44. </a>
  45. </details>
  46. </div>
  47. <div v-else>
  48. <div>
  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'">
  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">
  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">
  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. min-height: 600px;
  327. }
  328. .cursor-pointer {
  329. cursor: pointer;
  330. }
  331. </style>
  332. <script type="text/javascript">
  333. export default {
  334. data() {
  335. return {
  336. page: 1,
  337. feed: [],
  338. profile: {},
  339. scope: window.location.pathname,
  340. min_id: 0,
  341. max_id: 0,
  342. notifications: {},
  343. stories: {},
  344. suggestions: {},
  345. }
  346. },
  347. beforeMount() {
  348. this.fetchTimelineApi();
  349. this.fetchProfile();
  350. },
  351. mounted() {
  352. },
  353. updated() {
  354. this.scroll();
  355. },
  356. methods: {
  357. fetchProfile() {
  358. axios.get('/api/v1/accounts/verify_credentials').then(res => {
  359. this.profile = res.data;
  360. $('.profile-card .loader').addClass('d-none');
  361. $('.profile-card .contents').removeClass('d-none');
  362. $('.profile-card .card-footer').removeClass('d-none');
  363. this.fetchNotifications();
  364. }).catch(err => {
  365. swal(
  366. 'Oops, something went wrong',
  367. 'Please reload the page.',
  368. 'error'
  369. );
  370. });
  371. },
  372. fetchTimelineApi() {
  373. let homeTimeline = '/api/v1/timelines/home?page=' + this.page;
  374. let localTimeline = '/api/v1/timelines/public?page=' + this.page;
  375. let apiUrl = this.scope == '/' ? homeTimeline : localTimeline;
  376. axios.get(apiUrl).then(res => {
  377. $('.timeline .loader').addClass('d-none');
  378. let data = res.data;
  379. this.feed.push(...data);
  380. let ids = data.map(status => status.id);
  381. this.min_id = Math.min(...ids);
  382. if(this.page == 1) {
  383. this.max_id = Math.max(...ids);
  384. }
  385. this.page++;
  386. }).catch(err => {
  387. });
  388. },
  389. fetchNotifications() {
  390. axios.get('/api/v1/notifications')
  391. .then(res => {
  392. this.notifications = res.data;
  393. $('.notification-card .loader').addClass('d-none');
  394. $('.notification-card .contents').removeClass('d-none');
  395. });
  396. },
  397. scroll() {
  398. window.onscroll = () => {
  399. let bottomOfWindow = document.documentElement.scrollTop + window.innerHeight == document.documentElement.offsetHeight;
  400. if (bottomOfWindow) {
  401. this.fetchTimelineApi();
  402. }
  403. };
  404. },
  405. reportUrl(status) {
  406. let type = status.in_reply_to ? 'comment' : 'post';
  407. let id = status.id;
  408. return '/i/report?type=' + type + '&id=' + id;
  409. },
  410. commentFocus(status, $event) {
  411. let el = event.target;
  412. let card = el.parentElement.parentElement.parentElement;
  413. let comments = card.getElementsByClassName('comments')[0];
  414. if(comments.children.length == 0) {
  415. comments.classList.add('mb-2');
  416. this.fetchStatusComments(status, card);
  417. }
  418. let footer = card.querySelectorAll('.card-footer')[0];
  419. let input = card.querySelectorAll('.status-reply-input')[0];
  420. if(footer.classList.contains('d-none') == true) {
  421. footer.classList.remove('d-none');
  422. input.focus();
  423. } else {
  424. footer.classList.add('d-none');
  425. input.blur();
  426. }
  427. },
  428. likeStatus(status, $event) {
  429. if($('body').hasClass('loggedIn') == false) {
  430. return;
  431. }
  432. axios.post('/i/like', {
  433. item: status.id
  434. }).then(res => {
  435. status.favourites_count = res.data.count;
  436. if(status.favourited == true) {
  437. status.favourited = false;
  438. } else {
  439. status.favourited = true;
  440. }
  441. }).catch(err => {
  442. swal('Error', 'Something went wrong, please try again later.', 'error');
  443. });
  444. },
  445. shareStatus(status, $event) {
  446. if($('body').hasClass('loggedIn') == false) {
  447. return;
  448. }
  449. axios.post('/i/share', {
  450. item: status.id
  451. }).then(res => {
  452. status.reblogs_count = res.data.count;
  453. if(status.reblogged == true) {
  454. status.reblogged = false;
  455. } else {
  456. status.reblogged = true;
  457. }
  458. }).catch(err => {
  459. swal('Error', 'Something went wrong, please try again later.', 'error');
  460. });
  461. },
  462. timestampFormat(timestamp) {
  463. let ts = new Date(timestamp);
  464. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  465. },
  466. editUrl(status) {
  467. return status.url + '/edit';
  468. },
  469. statusOwner(status) {
  470. let sid = status.account.id;
  471. let uid = this.profile.id;
  472. if(sid == uid) {
  473. return true;
  474. } else {
  475. return false;
  476. }
  477. },
  478. fetchStatusComments(status, card) {
  479. axios.get('/api/v2/status/'+status.id+'/replies')
  480. .then(res => {
  481. let comments = card.querySelectorAll('.comments')[0];
  482. let data = res.data;
  483. data.forEach(function(i, k) {
  484. let username = document.createElement('a');
  485. username.classList.add('font-weight-bold');
  486. username.classList.add('text-dark');
  487. username.classList.add('mr-2');
  488. username.setAttribute('href', i.account.url);
  489. username.textContent = i.account.username;
  490. let text = document.createElement('span');
  491. text.innerHTML = i.content;
  492. let comment = document.createElement('p');
  493. comment.classList.add('read-more');
  494. comment.classList.add('mb-0');
  495. comment.appendChild(username);
  496. comment.appendChild(text);
  497. comments.appendChild(comment);
  498. });
  499. }).catch(err => {
  500. })
  501. },
  502. muteProfile(status) {
  503. if($('body').hasClass('loggedIn') == false) {
  504. return;
  505. }
  506. axios.post('/i/mute', {
  507. type: 'user',
  508. item: status.account.id
  509. }).then(res => {
  510. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  511. swal('Success', 'You have successfully muted ' + status.account.acct, 'success');
  512. }).catch(err => {
  513. swal('Error', 'Something went wrong. Please try again later.', 'error');
  514. });
  515. },
  516. blockProfile(status) {
  517. if($('body').hasClass('loggedIn') == false) {
  518. return;
  519. }
  520. axios.post('/i/block', {
  521. type: 'user',
  522. item: status.account.id
  523. }).then(res => {
  524. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  525. swal('Success', 'You have successfully blocked ' + status.account.acct, 'success');
  526. }).catch(err => {
  527. swal('Error', 'Something went wrong. Please try again later.', 'error');
  528. });
  529. },
  530. deletePost(status, index) {
  531. if($('body').hasClass('loggedIn') == false || status.account.id !== this.profile.id) {
  532. return;
  533. }
  534. axios.post('/i/delete', {
  535. type: 'status',
  536. item: status.id
  537. }).then(res => {
  538. this.feed.splice(index,1);
  539. swal('Success', 'You have successfully deleted this post', 'success');
  540. }).catch(err => {
  541. swal('Error', 'Something went wrong. Please try again later.', 'error');
  542. });
  543. },
  544. commentSubmit(status, $event) {
  545. let id = status.id;
  546. let form = $event.target;
  547. let input = $(form).find('input[name="comment"]');
  548. let comment = input.val();
  549. let comments = form.parentElement.parentElement.getElementsByClassName('comments')[0];
  550. axios.post('/i/comment', {
  551. item: id,
  552. comment: comment
  553. }).then(res => {
  554. input.val('');
  555. input.blur();
  556. let username = document.createElement('a');
  557. username.classList.add('font-weight-bold');
  558. username.classList.add('text-dark');
  559. username.classList.add('mr-2');
  560. username.setAttribute('href', this.profile.url);
  561. username.textContent = this.profile.username;
  562. let text = document.createElement('span');
  563. text.innerHTML = comment;
  564. let wrapper = document.createElement('p');
  565. wrapper.classList.add('read-more');
  566. wrapper.classList.add('mb-0');
  567. wrapper.appendChild(username);
  568. wrapper.appendChild(text);
  569. comments.insertBefore(wrapper, comments.firstChild);
  570. });
  571. }
  572. }
  573. }
  574. </script>