You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
2.8 KiB

  1. <template>
  2. <div class="container">
  3. <div class="row">
  4. <div class="col-xs-8 col-md-8 panel scorecard">
  5. <div class="panel-body">
  6. <div v-if="previewTweet">
  7. <div class="profile">
  8. <img :src="tweet.player_photo" :style="'border-color: #'+tweet.team_color">
  9. <span><a :href="'https://twitter.com/'+tweet.player_username">@{{ tweet.player_username }}</a></span>
  10. </div>
  11. <div class="tweet">
  12. <div class="text">{{ tweet.text }}</div>
  13. <div v-if="tweet.photos">
  14. <div :class="'multi-photo photos-'+tweet.photos.length" v-if="tweet.photos">
  15. <div v-for="img in tweet.photos" class="photo" :style="'background-image:url('+img+')'" :data-featherlight="img">
  16. <img :src="img">
  17. </div>
  18. </div>
  19. <div class="multi-photo-clear"></div>
  20. </div>
  21. </div>
  22. <div class="tweet-actions">
  23. <button type="button" class="btn btn-success" v-on:click="importTweet">Import</button>
  24. </div>
  25. </div>
  26. <div v-else>
  27. <div v-if="error">
  28. <div class="alert alert-danger" role="alert">{{ error }}</div>
  29. </div>
  30. <form v-on:submit.prevent>
  31. <div class="form-group">
  32. <label for="">Tweet URL</label>
  33. <input type="url" class="form-control" placeholder="https://twitter.com/..." v-on:keyup.enter="loadTweet">
  34. </div>
  35. </form>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. </template>
  42. <script>
  43. module.exports = {
  44. props: [],
  45. data () {
  46. return {
  47. error: false,
  48. tweet: null,
  49. tweetID: null,
  50. previewTweet: false
  51. }
  52. },
  53. methods: {
  54. loadTweet(e) {
  55. var tweetURL = $(e.target).val();
  56. $.post("/import/preview", {
  57. url: tweetURL
  58. }, function(response){
  59. if(response.error) {
  60. this.tweet = null;
  61. this.tweetID = null,
  62. this.previewTweet = false;
  63. this.error = response.error;
  64. } else {
  65. console.log(response);
  66. this.tweet = response;
  67. this.tweetID = response.twitter_id;
  68. this.previewTweet = true;
  69. this.error = false;
  70. }
  71. }.bind(this));
  72. },
  73. importTweet() {
  74. $.post("/import/save", {
  75. tweet_id: this.tweetID
  76. }, function(response) {
  77. if(response.error) {
  78. this.tweet = null;
  79. this.tweetID = null,
  80. this.previewTweet = false;
  81. this.error = response.error;
  82. } else {
  83. this.tweet = null;
  84. this.tweetID = null;
  85. this.previewTweet = false;
  86. this.error = false;
  87. }
  88. }.bind(this));
  89. }
  90. }
  91. }
  92. </script>