PageSourceSearch

https://proparcel.com/static/js/initialization/toolbar_extras_auth_gate.js?v=20260518-2

js proparcel.com collected 2026-09-24 14:51:16 UTC 10,409 bytes, 274 lines download raw bytes

1/**
2 * Ek harita araçları: misafirde tüm premium butonlar görünür, overlay + pasif.
3 * Eski index.html (sunucu yenilenmemiş) için DOM'a buton enjekte eder.
4 */
5(function () {
6  'use strict';
7
8  var OVERLAY_TEXT = 'Ücretsiz Kullanım İçin Üye Girişi Yapın';
9  var LOGIN_URL = '/accounts/login/?next=' + encodeURIComponent(
10    typeof window.location !== 'undefined' ? window.location.pathname + window.location.search : '/',
11  );
12
13  var LOCKED_ROOT_IDS = [
14    'pp-capture-menu-wrap',
15    'pp-screenshot-map-btn',
16    'toggle3DMap',
17    'street-view-menu-btn',
18    'hisseli-parsel-btn',
19    'pp-3d-editor-toolbar-link',
20    'pp-ne-yapilir-btn',
21    'pp-ai-drone-video-btn',
22  ];
23
24  var WEBGL_DISABLED_STYLE = 'background:#e5e7eb!important;background-image:none!important;color:#64748b!important;border-color:#cbd5e1!important;box-shadow:none!important;text-shadow:none!important;opacity:.45!important;filter:grayscale(1)!important;cursor:not-allowed!important;';
25
26  function isGuest() {
27    try {
28      if (typeof window.ppIsAuthenticated === 'function') {
29        return !window.ppIsAuthenticated();
30      }
31    } catch (e) { /* ignore */ }
32    try {
33      var ppEl = document.getElementById('pp-user');
34      if (ppEl) {
35        var data = JSON.parse(ppEl.textContent || '{}');
36        return data.authenticated !== true;
37      }
38    } catch (e2) { /* ignore */ }
39    return !(window.PP_USER_AUTHENTICATED === true);
40  }
41
42  function buildMissingToolbarMarkup() {
43    return ''
44      + '<div class="pp-toolbar-extras-auth-overlay" role="status" aria-live="polite" hidden>'
45      + '<p class="pp-toolbar-extras-auth-overlay-text">' + OVERLAY_TEXT + '</p>'
46      + '</div>'
47      + '<div class="pp-capture-menu-wrap" id="pp-capture-menu-wrap">'
48      + '<button type="button" id="pp-screenshot-map-btn" class="toggle-btn" title="Harita görüntüsü al">'
49      + '<i class="fas fa-camera" aria-hidden="true"></i><span>Görüntü Al</span>'
50      + '<i class="fas fa-chevron-down pp-capture-menu-caret" aria-hidden="true"></i>'
51      + '</button>'
52      + '<div class="pp-capture-menu" id="pp-capture-menu" aria-label="Görüntü formatı seç">'
53      + '<button type="button" data-pp-capture-format="horizontal">'
54      + '<i class="fas fa-arrows-alt-h" aria-hidden="true"></i><span>Yatay</span></button>'
55      + '<button type="button" data-pp-capture-format="vertical">'
56      + '<i class="fas fa-mobile-alt" aria-hidden="true"></i><span>Dikey Hikaye</span></button>'
57      + '</div></div>'
58      + '<button type="button" id="street-view-menu-btn" class="toggle-btn" title="Sokak Görüntüsü">'
59      + '<i class="fa fa-street-view" aria-hidden="true"></i><span>Sokak Görüntüsü</span></button>'
60      + '<span class="btn-separator" aria-hidden="true"></span>'
61      + '<button type="button" id="hisseli-parsel-btn" class="toggle-btn" title="Hisseli Parsellere Böl">'
62      + '<i class="fa fa-object-group" aria-hidden="true"></i><span>Hisseli Parsellere Böl</span></button>'
63      + '<a href="javascript:void(0)" data-pp-original-href="/3d-editor/" id="pp-3d-editor-toolbar-link" '
64      + 'class="toggle-btn action-bar-link pp-webgl-compat-disabled" style="' + WEBGL_DISABLED_STYLE + '">'
65      + '<i class="fas fa-cube" aria-hidden="true"></i><span>3D Model</span></a>'
66      + '<a href="javascript:void(0)" data-pp-original-href="/bina-ciz/" id="pp-ne-yapilir-btn" '
67      + 'class="toggle-btn action-bar-link pp-webgl-compat-disabled" style="' + WEBGL_DISABLED_STYLE + '" '
68      + 'title="Proje Oluştur — önce haritada parsel seçin">'
69      + '<i class="fas fa-building" aria-hidden="true"></i><span>Proje Oluştur</span></a>'
70      + '<button type="button" id="pp-ai-drone-video-btn" class="toggle-btn" '
71      + 'title="AI Drone Video — önce haritada parsel seçin veya sorgulayın" '
72      + 'data-pp-webgl-pending="1">'
73      + '<i class="fas fa-video" aria-hidden="true"></i><span>AI Drone Video</span></button>';
74  }
75
76  function wireCaptureMenu(panel) {
77    if (!panel || panel.getAttribute('data-pp-capture-wired') === '1') return;
78    panel.setAttribute('data-pp-capture-wired', '1');
79    panel.addEventListener('click', function (e) {
80      var btn = e.target.closest('#pp-screenshot-map-btn');
81      if (btn) {
82        e.preventDefault();
83        e.stopPropagation();
84        if (typeof window.ppToggleCaptureMenu === 'function') {
85          window.ppToggleCaptureMenu(e);
86        }
87        return;
88      }
89      var item = e.target.closest('[data-pp-capture-format]');
90      if (item) {
91        e.preventDefault();
92        e.stopPropagation();
93        var fmt = item.getAttribute('data-pp-capture-format') || 'horizontal';
94        if (typeof window.ppCaptureAndDownloadMap === 'function') {
95          window.ppCaptureAndDownloadMap(fmt);
96        }
97      }
98    });
99  }
100
101  function migrateLegacyAuthToolbar() {
102    if (document.getElementById('pp-screenshot-map-btn')) return false;
103    var panel = document.getElementById('pp-toolbar-extras');
104    if (!panel) return false;
105
106    var gate = document.createElement('div');
107    gate.className = 'pp-toolbar-extras-auth-gate';
108
109    var threeD = document.getElementById('toggle3DMap');
110    var refresh = document.getElementById('action-bar-refresh-btn');
111
112    var sep = panel.querySelector('.pp-toolbar-extras-auth-sep');
113    if (!sep) {
114      sep = document.createElement('span');
115      sep.className = 'btn-separator pp-toolbar-extras-auth-sep';
116      sep.setAttribute('aria-hidden', 'true');
117      if (threeD) panel.insertBefore(sep, threeD);
118      else if (refresh) panel.insertBefore(sep, refresh.nextSibling);
119      else panel.appendChild(sep);
120    }
121
122    if (threeD) {
123      panel.insertBefore(gate, threeD);
124      gate.appendChild(threeD);
125    } else {
126      panel.appendChild(gate);
127    }
128
129    gate.insertAdjacentHTML('afterbegin', buildMissingToolbarMarkup());
130    wireCaptureMenu(gate);
131
132    var streetBtn = document.getElementById('street-view-menu-btn');
133    if (streetBtn && typeof window.openStreetViewModal === 'function') {
134      streetBtn.addEventListener('click', function (e) {
135        e.preventDefault();
136        if (isGuest()) return;
137        if (typeof window.ppRequireFeature === 'function' && !window.ppRequireFeature('street_view')) return;
138        window.openStreetViewModal();
139      });
140    }
141    var hisseliBtn = document.getElementById('hisseli-parsel-btn');
142    if (hisseliBtn && typeof window.openHisseliParselPage === 'function') {
143      hisseliBtn.addEventListener('click', function (e) {
144        e.preventDefault();
145        if (!isGuest()) window.openHisseliParselPage();
146      });
147    }
148
149    return true;
150  }
151
152  function collectLockTargets() {
153    var seen = new Set();
154    var list = [];
155    LOCKED_ROOT_IDS.forEach(function (id) {
156      var el = document.getElementById(id);
157      if (!el || seen.has(el)) return;
158      seen.add(el);
159      list.push(el);
160    });
161    return list;
162  }
163
164  function ensureAuthGate(targets) {
165    var gate = document.querySelector('.pp-toolbar-extras-auth-gate');
166    if (gate) return gate;
167
168    var panel = document.getElementById('pp-toolbar-extras');
169    if (!panel || !targets.length) return null;
170
171    gate = document.createElement('div');
172    gate.className = 'pp-toolbar-extras-auth-gate';
173    panel.insertBefore(gate, targets[0]);
174    targets.forEach(function (node) {
175      if (node.parentNode !== gate) gate.appendChild(node);
176    });
177    return gate;
178  }
179
180  function ensureOverlay(gate) {
181    var overlay = gate.querySelector('.pp-toolbar-extras-auth-overlay');
182    if (overlay) return overlay;
183
184    overlay = document.createElement('div');
185    overlay.className = 'pp-toolbar-extras-auth-overlay';
186    overlay.setAttribute('role', 'status');
187    overlay.setAttribute('aria-live', 'polite');
188    overlay.hidden = true;
189
190    var p = document.createElement('p');
191    p.className = 'pp-toolbar-extras-auth-overlay-text';
192    p.textContent = OVERLAY_TEXT;
193    overlay.appendChild(p);
194
195    overlay.addEventListener('click', function (e) {
196      e.preventDefault();
197      e.stopPropagation();
198      window.location.href = LOGIN_URL;
199    });
200
201    gate.insertBefore(overlay, gate.firstChild);
202    return overlay;
203  }
204
205  function setControlDisabled(el, disabled) {
206    if (!el) return;
207    el.style.removeProperty('display');
208    el.style.removeProperty('visibility');
209    if (el.tagName === 'A') {
210      if (disabled) {
211        if (!el.getAttribute('data-pp-auth-gate-href')) {
212          el.setAttribute('data-pp-auth-gate-href', el.getAttribute('href') || '');
213        }
214        el.setAttribute('href', 'javascript:void(0)');
215        el.setAttribute('aria-disabled', 'true');
216        el.setAttribute('tabindex', '-1');
217      } else {
218        var restore = el.getAttribute('data-pp-auth-gate-href');
219        if (restore) el.setAttribute('href', restore);
220        el.removeAttribute('aria-disabled');
221        el.removeAttribute('tabindex');
222      }
223      return;
224    }
225    if (disabled) {
226      el.setAttribute('disabled', 'disabled');
227      el.setAttribute('aria-disabled', 'true');
228      el.setAttribute('tabindex', '-1');
229    } else {
230      el.removeAttribute('disabled');
231      el.removeAttribute('aria-disabled');
232      el.removeAttribute('tabindex');
233    }
234  }
235
236  function applyGuestLock(locked) {
237    if (!locked) return;
238
239    migrateLegacyAuthToolbar();
240
241    var targets = collectLockTargets();
242    if (!targets.length) return;
243
244    var gate = ensureAuthGate(targets);
245    if (!gate) return;
246
247    gate.classList.add('pp-toolbar-extras-auth-gate--locked');
248
249    var overlay = ensureOverlay(gate);
250    overlay.removeAttribute('hidden');
251    overlay.style.display = 'flex';
252
253    targets.forEach(function (el) {
254      setControlDisabled(el, true);
255      el.querySelectorAll('button, a.toggle-btn, a.action-bar-link').forEach(function (child) {
256        setControlDisabled(child, true);
257      });
258    });
259  }
260
261  function init() {
262    if (isGuest()) {
263      applyGuestLock(true);
264    }
265  }
266
267  if (document.readyState === 'loading') {
268    document.addEventListener('DOMContentLoaded', init);
269  } else {
270    init();
271  }
272
273  window.ppToolbarExtrasAuthGateRefresh = init;
274})();

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.