Ver Fonte

Inline artifacts script

ghorsington há 4 anos atrás
pai
commit
58abe0466d
2 ficheiros alterados com 29 adições e 24 exclusões
  1. 0 21
      src/static/script/artifacts.js
  2. 29 3
      src/templates/project_view.html

+ 0 - 21
src/static/script/artifacts.js

@@ -1,21 +0,0 @@
-function init() {
-    let dates = document.querySelectorAll("span.build-date");
-
-    for (let date of dates) {
-        date.textContent = new Date(date.textContent).toLocaleString();
-    }
-
-    let artifacts = document.querySelectorAll("div.artifact-item");
-    for (let artifact of artifacts) {
-        let contents = artifact.querySelector(".artifact-contents");
-        if (!contents || !(contents instanceof HTMLElement))
-            continue;
-        artifact.addEventListener("click", e => {
-            e.preventDefault();
-            if (contents.classList.contains("contents-visible"))
-                contents.classList.remove("contents-visible");
-            else
-                contents.classList.add("contents-visible");
-        });
-    }
-}

+ 29 - 3
src/templates/project_view.html

@@ -2,7 +2,7 @@
 
 {%block head%}
 <link rel="stylesheet" href="{{ url_for('static', filename='style/fontello/css/fontello.css') }}"" />
-<script src="{{ url_for('static', filename='script/artifacts.js') | timestamp }}"></script>
+</script>
 {%endblock%}
 
 {%block title%}{{selected_project.info.name}}{%endblock%}
@@ -55,7 +55,10 @@
                     <tbody>
                         {%-for download_item in artifact.artifacts%}
                         <tr>
-                            <td class="min-size"><a class="button is-link" style="width: calc({{download_item.width}} * 0.6rem);" href="{{ url_for('download_item', project_id=selected_project.id, artifact_id=artifact.id, download_item=download_item.file)}}">{{download_item.file}}</a></td>
+                            <td class="min-size"><a class="button is-link button-scale"
+                                    style="width: calc({{download_item.width * 0.5}}em);"
+                                    href="{{ url_for('download_item', project_id=selected_project.id, artifact_id=artifact.id, download_item=download_item.file)}}">{{download_item.file}}</a>
+                            </td>
                             <td>{{download_item.description}}</td>
                         </tr>
                         {%-endfor%}
@@ -74,5 +77,28 @@
 </div>
 {%-endfor%}
 
-<script>init();</script>
+<script>
+    function init() {
+        let dates = document.querySelectorAll("span.build-date");
+
+        for (let date of dates) {
+            date.textContent = new Date(date.textContent).toLocaleString();
+        }
+
+        let artifacts = document.querySelectorAll("div.artifact-item");
+        for (let artifact of artifacts) {
+            let contents = artifact.querySelector(".artifact-contents");
+            if (!contents || !(contents instanceof HTMLElement))
+                continue;
+            artifact.addEventListener("click", e => {
+                e.preventDefault();
+                if (contents.classList.contains("contents-visible"))
+                    contents.classList.remove("contents-visible");
+                else
+                    contents.classList.add("contents-visible");
+            });
+        }
+    }
+    init();
+</script>
 {%endblock%}