@@ -186,7 +186,7 @@ function updateUI(state) {
186186 </div>
187187
188188 <!-- Progress Bar -->
189- <div class="w-full h-2 bg-slate-955 /40 rounded-full overflow-hidden mb-3">
189+ <div class="w-full h-2 bg-slate-950 /40 rounded-full overflow-hidden mb-3">
190190 <div id="${ workerId } -bar" class="h-full progress-fill" style="width: ${ percent } %"></div>
191191 </div>
192192
@@ -211,7 +211,7 @@ function updateUI(state) {
211211
212212function createPendingCard ( task , index ) {
213213 const card = document . createElement ( 'div' ) ;
214- card . className = 'glass-card p-4 download-card border-l-4 border-l-purple-500/40 bg-slate-955 /10 animate-slide-in' ;
214+ card . className = 'glass-card p-4 download-card border-l-4 border-l-purple-500/40 bg-slate-950 /10 animate-slide-in' ;
215215
216216 card . innerHTML = `
217217 <div class="flex items-center justify-between gap-4">
@@ -239,7 +239,7 @@ function createPendingCard(task, index) {
239239}
240240
241241async function cancelActiveWorker ( workerId ) {
242- if ( ! confirm ( '¿Cancelar esta descarga? ' ) ) return ;
242+ if ( ! await showConfirm ( '¿Cancelar Descarga?' , '¿Estás seguro de que deseas cancelar esta descarga activa?' , 'warning ') ) return ;
243243 try {
244244 const response = await fetch ( `/api/downloads/${ encodeURIComponent ( workerId ) } /cancel` , { method : 'POST' } ) ;
245245 const res = await response . json ( ) ;
@@ -257,7 +257,7 @@ async function cancelActiveWorker(workerId) {
257257}
258258
259259async function removePendingTask ( url ) {
260- if ( ! confirm ( '¿Eliminar esta tarea de la cola? ' ) ) return ;
260+ if ( ! await showConfirm ( '¿Quitar de la Cola?' , '¿Estás seguro de que deseas eliminar esta tarea de la cola de pendientes?' , 'warning ') ) return ;
261261 try {
262262 const response = await fetch ( '/api/downloads/remove-pending' , {
263263 method : 'POST' ,
@@ -457,7 +457,7 @@ async function togglePauseQueue() {
457457}
458458
459459async function cancelAllDownloads ( ) {
460- if ( ! confirm ( '¿Estás seguro de que quieres cancelar todas las descargas activas?' ) ) return ;
460+ if ( ! await showConfirm ( '¿Cancelar Todo?' , '¿ Estás seguro de que deseas cancelar todas las descargas activas?' , 'error ') ) return ;
461461 try {
462462 const response = await fetch ( '/api/downloads/cancel' , { method : 'POST' } ) ;
463463 const res = await response . json ( ) ;
@@ -488,7 +488,7 @@ async function clearHistory() {
488488}
489489
490490async function clearQueue ( ) {
491- if ( ! confirm ( '¿Cancelar todas las descargas activas y vaciar la cola de pendientes?' ) ) return ;
491+ if ( ! await showConfirm ( '¿Limpiar Lista?' , '¿ Cancelar todas las descargas activas y vaciar la cola de pendientes?' , 'error ') ) return ;
492492 try {
493493 const response = await fetch ( '/api/downloads/clear-queue' , { method : 'POST' } ) ;
494494 const res = await response . json ( ) ;
@@ -800,6 +800,52 @@ async function saveSettings() {
800800 }
801801}
802802
803+ // Custom Confirmation Modal Logic
804+ let confirmPromiseResolve = null ;
805+
806+ function showConfirm ( title , message , iconType = 'warning' ) {
807+ const modal = document . getElementById ( 'confirm-modal' ) ;
808+ const titleEl = document . getElementById ( 'confirm-modal-title' ) ;
809+ const messageEl = document . getElementById ( 'confirm-modal-message' ) ;
810+ const iconEl = document . getElementById ( 'confirm-modal-icon' ) ;
811+ const iconBg = document . getElementById ( 'confirm-modal-icon-bg' ) ;
812+
813+ titleEl . textContent = title ;
814+ messageEl . textContent = message ;
815+
816+ // Icon and colors
817+ iconBg . className = 'w-10 h-10 rounded-xl flex items-center justify-center shrink-0 border' ;
818+ if ( iconType === 'error' ) {
819+ iconBg . classList . add ( 'bg-rose-500/20' , 'border-rose-500/30' , 'text-rose-400' ) ;
820+ iconEl . className = 'fa-solid fa-ban text-lg' ;
821+ } else if ( iconType === 'info' ) {
822+ iconBg . classList . add ( 'bg-blue-500/20' , 'border-blue-500/30' , 'text-blue-400' ) ;
823+ iconEl . className = 'fa-solid fa-circle-info text-lg' ;
824+ } else { // warning
825+ iconBg . classList . add ( 'bg-amber-500/20' , 'border-amber-500/30' , 'text-amber-400' ) ;
826+ iconEl . className = 'fa-solid fa-triangle-exclamation text-lg' ;
827+ }
828+
829+ modal . classList . add ( 'modal-active' ) ;
830+
831+ return new Promise ( ( resolve ) => {
832+ confirmPromiseResolve = resolve ;
833+ } ) ;
834+ }
835+
836+ function handleConfirmResult ( value ) {
837+ const modal = document . getElementById ( 'confirm-modal' ) ;
838+ modal . classList . remove ( 'modal-active' ) ;
839+ if ( confirmPromiseResolve ) {
840+ confirmPromiseResolve ( value ) ;
841+ confirmPromiseResolve = null ;
842+ }
843+ }
844+
845+ function closeConfirmModal ( ) {
846+ handleConfirmResult ( false ) ;
847+ }
848+
803849// Fetch logs and output to terminal log box
804850async function fetchLogs ( ) {
805851 const terminal = document . getElementById ( 'terminal-logs' ) ;
@@ -826,6 +872,42 @@ window.addEventListener('DOMContentLoaded', () => {
826872 connectWebSocket ( ) ;
827873 updateCookiesStatus ( ) ;
828874
875+ // Setup confirm modal action listener
876+ const btnConfirmOk = document . getElementById ( 'btn-confirm-ok' ) ;
877+ if ( btnConfirmOk ) {
878+ btnConfirmOk . addEventListener ( 'click' , ( ) => handleConfirmResult ( true ) ) ;
879+ }
880+
881+ // Setup Drag & Drop Cookie Upload Zone
882+ const dropZone = document . getElementById ( 'cookie-drop-zone' ) ;
883+ if ( dropZone ) {
884+ [ 'dragenter' , 'dragover' ] . forEach ( eventName => {
885+ dropZone . addEventListener ( eventName , ( e ) => {
886+ e . preventDefault ( ) ;
887+ e . stopPropagation ( ) ;
888+ dropZone . classList . add ( 'dragover' ) ;
889+ } , false ) ;
890+ } ) ;
891+
892+ [ 'dragleave' , 'drop' ] . forEach ( eventName => {
893+ dropZone . addEventListener ( eventName , ( e ) => {
894+ e . preventDefault ( ) ;
895+ e . stopPropagation ( ) ;
896+ dropZone . classList . remove ( 'dragover' ) ;
897+ } , false ) ;
898+ } ) ;
899+
900+ dropZone . addEventListener ( 'drop' , ( e ) => {
901+ const dt = e . dataTransfer ;
902+ const files = dt . files ;
903+ if ( files && files . length > 0 ) {
904+ const fileInput = document . getElementById ( 'cookie-file-input' ) ;
905+ fileInput . files = files ; // Assign files to input
906+ uploadCookieFile ( ) ; // Trigger upload
907+ }
908+ } , false ) ;
909+ }
910+
829911 // Fetch logs every 5 seconds
830912 fetchLogs ( ) ;
831913 setInterval ( fetchLogs , 5000 ) ;
0 commit comments