GLAkavya commited on
Commit
2042ce5
·
verified ·
1 Parent(s): ed0ded6

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +46 -5
static/script.js CHANGED
@@ -28,6 +28,15 @@ function renderMeta(meta) {
28
  mGemini.textContent = `Gemini: ${meta.generated_by.gemini}`;
29
  mFallback.textContent = `Fallback: ${meta.generated_by.fallback}`;
30
  mModels.textContent = `Gen: ${meta.model.generation} • Sentiment: ${meta.model.sentiment}`;
 
 
 
 
 
 
 
 
 
31
  }
32
 
33
  function renderPie(percent) {
@@ -44,9 +53,18 @@ function renderPie(percent) {
44
  plot_bgcolor: 'rgba(0,0,0,0)',
45
  font: {color: '#eaf2ff'},
46
  margin: {l: 4, r: 4, t: 0, b: 0},
47
- showlegend: false
 
48
  };
49
- Plotly.newPlot(pieDiv, data, layout, {displayModeBar:false, responsive:true});
 
 
 
 
 
 
 
 
50
  }
51
 
52
  function renderLine(rolling) {
@@ -54,7 +72,8 @@ function renderLine(rolling) {
54
  x: [...Array(rolling.length).keys()].map(i => i+1),
55
  y: rolling,
56
  type: 'scatter',
57
- mode: 'lines+markers'
 
58
  }];
59
  const layout = {
60
  paper_bgcolor: 'rgba(0,0,0,0)',
@@ -62,19 +81,30 @@ function renderLine(rolling) {
62
  font: {color: '#eaf2ff'},
63
  margin: {l: 30, r: 10, t: 0, b: 24},
64
  yaxis: {range:[0,1], tickformat: '.0%'},
 
65
  };
66
- Plotly.newPlot(lineDiv, data, layout, {displayModeBar:false, responsive:true});
 
 
 
 
 
 
 
 
67
  }
68
 
69
  function renderTable(rows) {
70
  tableDiv.innerHTML = "";
71
- rows.forEach(r => {
72
  const row = document.createElement("div");
73
  row.className = "row";
 
74
  // text
75
  const c1 = document.createElement("div");
76
  c1.className = "cell";
77
  c1.textContent = r.text;
 
78
  // source chip
79
  const c2 = document.createElement("div");
80
  c2.className = "cell";
@@ -82,6 +112,7 @@ function renderTable(rows) {
82
  chip.className = "chip " + (r.source === "gemini" ? "chip-gemini" : "chip-fallback");
83
  chip.textContent = r.source === "gemini" ? "Gemini" : "Fallback";
84
  c2.appendChild(chip);
 
85
  // sentiment badge
86
  const c3 = document.createElement("div");
87
  c3.className = "cell";
@@ -94,6 +125,16 @@ function renderTable(rows) {
94
  row.appendChild(c1);
95
  row.appendChild(c2);
96
  row.appendChild(c3);
 
 
 
 
 
 
 
 
 
 
97
  tableDiv.appendChild(row);
98
  });
99
  }
 
28
  mGemini.textContent = `Gemini: ${meta.generated_by.gemini}`;
29
  mFallback.textContent = `Fallback: ${meta.generated_by.fallback}`;
30
  mModels.textContent = `Gen: ${meta.model.generation} • Sentiment: ${meta.model.sentiment}`;
31
+
32
+ // meta fade-in animation
33
+ metaBox.style.opacity = "0";
34
+ metaBox.style.transform = "translateY(10px)";
35
+ requestAnimationFrame(() => {
36
+ metaBox.style.transition = "all .6s ease";
37
+ metaBox.style.opacity = "1";
38
+ metaBox.style.transform = "translateY(0)";
39
+ });
40
  }
41
 
42
  function renderPie(percent) {
 
53
  plot_bgcolor: 'rgba(0,0,0,0)',
54
  font: {color: '#eaf2ff'},
55
  margin: {l: 4, r: 4, t: 0, b: 0},
56
+ showlegend: false,
57
+ transition: {duration: 500, easing: "cubic-in-out"}
58
  };
59
+ Plotly.newPlot(pieDiv, data, layout, {displayModeBar:false, responsive:true}).then(() => {
60
+ pieDiv.style.opacity = "0";
61
+ pieDiv.style.transform = "scale(0.9)";
62
+ requestAnimationFrame(() => {
63
+ pieDiv.style.transition = "all .6s ease";
64
+ pieDiv.style.opacity = "1";
65
+ pieDiv.style.transform = "scale(1)";
66
+ });
67
+ });
68
  }
69
 
70
  function renderLine(rolling) {
 
72
  x: [...Array(rolling.length).keys()].map(i => i+1),
73
  y: rolling,
74
  type: 'scatter',
75
+ mode: 'lines+markers',
76
+ line: {shape: 'spline', smoothing: 1.3}
77
  }];
78
  const layout = {
79
  paper_bgcolor: 'rgba(0,0,0,0)',
 
81
  font: {color: '#eaf2ff'},
82
  margin: {l: 30, r: 10, t: 0, b: 24},
83
  yaxis: {range:[0,1], tickformat: '.0%'},
84
+ transition: {duration: 600, easing: "cubic-in-out"}
85
  };
86
+ Plotly.newPlot(lineDiv, data, layout, {displayModeBar:false, responsive:true}).then(() => {
87
+ lineDiv.style.opacity = "0";
88
+ lineDiv.style.transform = "translateY(20px)";
89
+ requestAnimationFrame(() => {
90
+ lineDiv.style.transition = "all .7s ease";
91
+ lineDiv.style.opacity = "1";
92
+ lineDiv.style.transform = "translateY(0)";
93
+ });
94
+ });
95
  }
96
 
97
  function renderTable(rows) {
98
  tableDiv.innerHTML = "";
99
+ rows.forEach((r, i) => {
100
  const row = document.createElement("div");
101
  row.className = "row";
102
+
103
  // text
104
  const c1 = document.createElement("div");
105
  c1.className = "cell";
106
  c1.textContent = r.text;
107
+
108
  // source chip
109
  const c2 = document.createElement("div");
110
  c2.className = "cell";
 
112
  chip.className = "chip " + (r.source === "gemini" ? "chip-gemini" : "chip-fallback");
113
  chip.textContent = r.source === "gemini" ? "Gemini" : "Fallback";
114
  c2.appendChild(chip);
115
+
116
  // sentiment badge
117
  const c3 = document.createElement("div");
118
  c3.className = "cell";
 
125
  row.appendChild(c1);
126
  row.appendChild(c2);
127
  row.appendChild(c3);
128
+
129
+ // add animation
130
+ row.style.opacity = "0";
131
+ row.style.transform = "translateX(-15px)";
132
+ setTimeout(() => {
133
+ row.style.transition = "all .4s ease";
134
+ row.style.opacity = "1";
135
+ row.style.transform = "translateX(0)";
136
+ }, 100 * i);
137
+
138
  tableDiv.appendChild(row);
139
  });
140
  }