Personal blog written from scratch using Node.js, Bootstrap, and MySQL. https://jrtechs.net
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.

164 lines
3.9 KiB

  1. {header}
  2. <script src="https://code.jquery.com/jquery-3.3.1.min.js"
  3. integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
  4. crossorigin="anonymous">
  5. </script>
  6. <style>
  7. :root {
  8. --primary:rgba(16,116,231,1);
  9. --secondary:rgba(46,188,79,1);
  10. --dark:rgba(36,41,46,1);
  11. --dark-2:rgba(43,49,55,1);
  12. --white:rgba(255,255,255,1);
  13. }
  14. .vis-timeline {
  15. border: none;
  16. font-size: 16px;
  17. color: var(--white);
  18. background-color: var(--dark);
  19. }
  20. .vis-item {
  21. font-size: 16px;
  22. color: var(--dark);
  23. background-color: var(--white);
  24. box-sizing: border-box;
  25. box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.06), 0px 4px 6px rgba(0, 0, 0, 0.06);
  26. border-color: transparent;
  27. }
  28. .vis-item.vis-box {
  29. border-radius: 2px;
  30. padding: 0;
  31. border: none;
  32. }
  33. .vis-item .vis-item-content {
  34. padding: 8px 10px;
  35. }
  36. .vis-item.vis-box.vis-selected {
  37. border: 2px solid var(--primary);
  38. }
  39. .vis-item.vis-line {
  40. border-width: 2px;
  41. border-color: var(--primary)
  42. }
  43. .vis-item.vis-dot {
  44. border-color: var(--primary);
  45. }
  46. .vis-item.vis-selected {
  47. border-color: var(--primary);
  48. background-color: var(--white);
  49. box-shadow: 0px 20px 25px rgba(0, 0, 0, 0.2), 0px 10px 10px rgba(0, 0, 0, 0.14);
  50. }
  51. .vis-time-axis .vis-text {
  52. color: var(--white)!important;
  53. padding-top: 8px;
  54. padding-left: 16px;
  55. }
  56. .vis-time-axis .vis-grid.vis-minor {
  57. border-width: 2px;
  58. border-color: rgba(255, 255, 255, .29);
  59. }
  60. .vis-labelset .vis-label {
  61. color: var(--white);
  62. }
  63. .vis-time-axis .vis-grid.vis-major {
  64. border-width: 1px;
  65. border-color: rgba(255, 255, 255, .5);
  66. }
  67. </style>
  68. <br><br><br><br><br>
  69. <div id="timeline"></div>
  70. <br><br>
  71. <div class="container">
  72. <div class="row">
  73. <div class="col-md-8 col-12">
  74. <div class="card">
  75. <div id="previewPost"></div>
  76. </div>
  77. <br><br>
  78. </div>
  79. <div class="col-md-4 col-12">
  80. {>sideBar}
  81. </div>
  82. </div>
  83. </div>
  84. <script src="/includes/js/vis/dist/vis-timeline-graph2d.min.js"></script>
  85. <link href="/includes/js/vis/dist/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" />
  86. <script type="text/javascript">
  87. function runAjax(url, successCallBack, errorCallBack)
  88. {
  89. console.log(url);
  90. $.ajax({
  91. type:'GET',
  92. url: url,
  93. crossDomain: true,
  94. dataType: "json",
  95. success: successCallBack,
  96. error:errorCallBack,
  97. timeout: 3000
  98. });
  99. }
  100. function fetchPosts()
  101. {
  102. return new Promise((resolve, reject)=>
  103. {
  104. runAjax("api/posts", (data)=>
  105. {
  106. var datasetContents = [];
  107. for(var i=0; i < data.length; i++)
  108. {
  109. datasetContents.push(
  110. {
  111. start: new Date(data[i].published),
  112. content: data[i].name
  113. }
  114. );
  115. }
  116. resolve(datasetContents);
  117. },
  118. (error)=>
  119. {
  120. resolve([]);
  121. });
  122. });
  123. }
  124. var container = document.getElementById('timeline');
  125. $(document).ready(function()
  126. {
  127. fetchPosts().then((data)=>
  128. {
  129. var options =
  130. {
  131. editable: false,
  132. margin: {
  133. item: 20,
  134. axis: 40
  135. },
  136. start:data[12].start,
  137. end:data[0].start
  138. };
  139. var items = new vis.DataSet(data);
  140. var timeline = new vis.Timeline(container, items, options);
  141. });
  142. });
  143. </script>
  144. {footer}