1/** 2 * Plotly Lazy Loader 3 * Plotly kütüphanesini sadece ihtiyaç duyulduÄunda yükler 4 * Bu sayede sayfa ilk yüklemesinde ~1MB tasarruf saÄlanır 5 */ 6 7(function() { 8 'use strict'; 9 10 const PLOTLY_CDN_URL = 'https://cdn.plot.ly/plotly-2.30.0.min.js'; 11 12 let plotlyLoaded = false; 13 let plotlyLoading = false; 14 let loadPromise = null; 15 16 /** 17 * Plotly kütüphanesini lazy load eder 18 * @returns {Promise<Plotly>} Plotly nesnesi 19 */ 20 function loadPlotly() { 21 // Zaten yüklüyse direkt dön 22 if (plotlyLoaded && window.Plotly) { 23 return Promise.resolve(window.Plotly); 24 } 25 26 // Yükleme devam ediyorsa mevcut promise'i dön 27 if (plotlyLoading && loadPromise) { 28 return loadPromise; 29 } 30 31 plotlyLoading = true; 32 33 loadPromise = new Promise((resolve, reject) => { 34 const script = document.createElement('script'); 35 script.src = PLOTLY_CDN_URL; 36 script.async = true; 37 38 script.onload = function() { 39 plotlyLoaded = true; 40 plotlyLoading = false; 41 resolve(window.Plotly); 42 }; 43 44 script.onerror = function(err) { 45 plotlyLoading = false; 46 loadPromise = null; 47 console.error('[PlotlyLoader] Plotly yüklenemedi:', err); 48 reject(new Error('Plotly yüklenemedi')); 49 }; 50 51 document.head.appendChild(script); 52 }); 53 54 return loadPromise; 55 } 56 57 /** 58 * Plotly'nin yüklenip yüklenmediÄini kontrol eder 59 * @returns {boolean} 60 */ 61 function isPlotlyLoaded() { 62 return plotlyLoaded && !!window.Plotly; 63 } 64 65 /** 66 * Plotly fonksiyonlarını sarmalayan wrapper 67 * İlk kullanımda otomatik yükler 68 */ 69 const PlotlyWrapper = { 70 newPlot: async function(...args) { 71 const Plotly = await loadPlotly(); 72 return Plotly.newPlot(...args); 73 }, 74 75 relayout: async function(...args) { 76 const Plotly = await loadPlotly(); 77 return Plotly.relayout(...args); 78 }, 79 80 purge: async function(...args) { 81 // Purge için Plotly yüklü deÄilse sessizce geç 82 if (!isPlotlyLoaded()) { 83 return Promise.resolve(); 84 } 85 return window.Plotly.purge(...args); 86 }, 87 88 react: async function(...args) { 89 const Plotly = await loadPlotly(); 90 return Plotly.react(...args); 91 }, 92 93 // DiÄer sık kullanılan metodlar 94 restyle: async function(...args) { 95 const Plotly = await loadPlotly(); 96 return Plotly.restyle(...args); 97 }, 98 99 update: async function(...args) { 100 const Plotly = await loadPlotly(); 101 return Plotly.update(...args); 102 } 103 }; 104 105 // Global'e ekle 106 window.PlotlyLoader = { 107 load: loadPlotly, 108 isLoaded: isPlotlyLoaded, 109 wrapper: PlotlyWrapper 110 }; 111 112 // Plotly kullanmaya çalıÅan eski kodlar için uyumluluk 113 // EÄer Plotly henüz yoksa bir proxy oluÅtur 114 if (!window.Plotly) { 115 window.Plotly = new Proxy({}, { 116 get: function(target, prop) { 117 if (prop === 'then') return undefined; // Promise olmadıÄını belirt 118 119 return async function(...args) { 120 const Plotly = await loadPlotly(); 121 if (typeof Plotly[prop] === 'function') { 122 return Plotly[prop](...args); 123 } 124 return Plotly[prop]; 125 }; 126 } 127 }); 128 } 129 130})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.