MCPcopy Create free account
hub / github.com/dajie111/nodeseek-userscript / niAppendQuickProgressRow

Function niAppendQuickProgressRow

nodeImage.js:790–879  ·  view source on GitHub ↗
(host, fileName, uploadAbortState)

Source from the content-addressed store, hash-verified

788 };
789 }
790 function niAppendQuickProgressRow(host, fileName, uploadAbortState) {
791 var row = document.createElement('div');
792 row.style.cssText = 'margin-bottom:10px;';
793 var head = document.createElement('div');
794 head.style.cssText = 'display:flex;align-items:center;justify-content:space-between;gap:6px;margin-bottom:3px;';
795 var nm = document.createElement('div');
796 nm.textContent = fileName;
797 nm.style.cssText =
798 'font-size:11px;color:#334155;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;flex:1;';
799 var rowCancel = document.createElement('button');
800 rowCancel.type = 'button';
801 rowCancel.textContent = '取消';
802 rowCancel.style.cssText =
803 'flex-shrink:0;padding:2px 8px;font-size:10px;border:1px solid #fecaca;background:#fff;color:#dc2626;border-radius:4px;cursor:pointer;';
804 rowCancel.onclick = function (e) {
805 e.stopPropagation();
806 e.preventDefault();
807 uploadAbortState.abortCurrentFile();
808 };
809 head.appendChild(nm);
810 head.appendChild(rowCancel);
811 var barWrap = document.createElement('div');
812 barWrap.className = 'ns-ni-pbar';
813 barWrap.style.cssText =
814 'height:8px;background:#e2e8f0;border-radius:4px;overflow:hidden;position:relative;';
815 var barFill = document.createElement('div');
816 barFill.style.cssText =
817 'height:100%;width:0%;background:#0d9488;border-radius:4px;transition:width .12s linear;';
818 barWrap.appendChild(barFill);
819 var stt = document.createElement('div');
820 stt.style.cssText = 'font-size:10px;color:#64748b;margin-top:3px;';
821 stt.textContent = '等待中…';
822 row.appendChild(head);
823 row.appendChild(barWrap);
824 row.appendChild(stt);
825 host.prepend(row);
826 var realProgress = false;
827 var fakeTimer = null;
828 return {
829 startUpload: function () {
830 barWrap.classList.add('ns-ni-pbar-ind');
831 barFill.style.width = '0%';
832 barFill.style.background = '#0d9488';
833 stt.style.color = '#64748b';
834 stt.textContent = '上传中…';
835 var fake = 0.06;
836 fakeTimer = setInterval(function () {
837 if (realProgress) return;
838 fake = Math.min(0.9, fake + 0.035 + Math.random() * 0.025);
839 barFill.style.width = fake * 100 + '%';
840 }, 320);
841 },
842 setLoadedTotal: function (loaded, total) {
843 if (!total || total <= 0) return;
844 realProgress = true;
845 if (fakeTimer) {
846 clearInterval(fakeTimer);
847 fakeTimer = null;

Callers 2

niQuickUploadRunBatchFunction · 0.85
stepFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected