-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSidebar.html
More file actions
124 lines (107 loc) · 3.81 KB
/
Sidebar.html
File metadata and controls
124 lines (107 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<?!= include('Stylesheet'); ?>
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700&display=swap" rel="stylesheet">
</head>
<body>
<div class="container">
<header>
<div class="logo-icon">S</div>
<h1>SmartPaste AI</h1>
<div class="credit-badge">📦 <span id="credit-count">?</span></div>
</header>
<div class="main-content">
<div class="card">
<h3>1. Paste your raw data</h3>
<textarea id="paste-area" placeholder="Paste text, web data, PDF extracts here..."></textarea>
</div>
<div class="card preview-card" id="preview-section" style="display:none;">
<h3>2. Transmutation Preview</h3>
<div id="preview-table" class="scroll-table"></div>
</div>
<div class="actions">
<button id="transmute-btn" class="primary-btn" onclick="transmute()">✨ Transmute Now</button>
<button id="insert-btn" class="secondary-btn" style="display:none;" onclick="insertData()">📥 Insert into Sheets</button>
</div>
<div id="status-msg"></div>
</div>
<footer>
<span>Sanadidari Ecosystem</span>
<span class="version">v1.0</span>
</footer>
</div>
<script>
let lastTransmutedData = null;
function transmute() {
const rawData = document.getElementById('paste-area').value;
if (!rawData) return showStatus("Please paste some data first.", "error");
const btn = document.getElementById('transmute-btn');
btn.disabled = true;
btn.innerText = "Analyzing...";
showStatus("AI is analyzing your data...", "info");
google.script.run
.withSuccessHandler((res) => {
btn.disabled = false;
btn.innerText = "✨ Transmute Again";
if (res.status === 'success') {
lastTransmutedData = res.data;
showPreview(res.data);
updateCredits(res.credits);
showStatus(res.message, "success");
document.getElementById('insert-btn').style.display = 'block';
} else {
showStatus(res.message, "error");
}
})
.withFailureHandler((err) => {
btn.disabled = false;
btn.innerText = "✨ Retry";
showStatus("Error : " + err, "error");
})
.processSmartPaste(rawData);
}
function insertData() {
if (!lastTransmutedData) return;
showStatus("Inserting into your sheet...", "info");
google.script.run
.withSuccessHandler((res) => {
if (res.status === 'success') {
showStatus("Data inserted successfully! ✅", "success");
} else {
showStatus("Insertion error: " + res.message, "error");
}
})
.insertDataIntoSheet(lastTransmutedData);
}
function showPreview(data) {
const container = document.getElementById('preview-table');
const section = document.getElementById('preview-section');
section.style.display = 'block';
let html = '<table>';
data.slice(0, 5).forEach(row => { // Preview first 5 rows
html += '<tr>';
row.forEach(cell => {
html += `<td>${cell || ''}</td>`;
});
html += '</tr>';
});
html += '</table>';
if (data.length > 5) html += `<p class='more'>+ ${data.length - 5} more lines...</p>`;
container.innerHTML = html;
}
function showStatus(msg, type) {
const el = document.getElementById('status-msg');
el.innerText = msg;
el.className = type;
}
function updateCredits(count) {
document.getElementById('credit-count').innerText = count;
}
window.onload = () => {
google.script.run.withSuccessHandler(updateCredits).getCurrentUserCredits();
};
</script>
</body>
</html>