File size: 5,294 Bytes
22be3f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
class CustomTabs extends HTMLElement {
  connectedCallback() {
    this.attachShadow({ mode: 'open' });
    this.shadowRoot.innerHTML = `
      <style>
        :host {
          display: block;
          margin-bottom: 1rem;
        }
        .tabs-container {
          display: flex;
          border-bottom: 2px solid #8B0000;
        }
        .tab {
          padding: 0.75rem 1.5rem;
          background: #0F0F0F;
          color: #7F7F7F;
          border: none;
          border-radius: 0.5rem 0.5rem 0 0;
          margin-right: 0.5rem;
          font-weight: 600;
          cursor: pointer;
          transition: all 0.2s;
          display: flex;
          align-items: center;
        }
        .tab:hover {
          color: #FF0000;
        }
        .tab.active {
          background: #8B0000;
          color: white;
        }
        .tab i {
          margin-right: 0.5rem;
        }
        .tab-close {
          margin-left: 0.5rem;
          width: 16px;
          height: 16px;
          display: flex;
          align-items: center;
          justify-content: center;
          border-radius: 50%;
          opacity: 0.7;
        }
        .tab-close:hover {
          background: rgba(255,255,255,0.2);
          opacity: 1;
        }
        .tab-content {
          display: none;
          padding: 1rem;
          background: #0F0F0F;
          border-radius: 0 0.5rem 0.5rem 0.5rem;
        }
        .tab-content.active {
          display: block;
        }
      </style>
      <div class="tabs-container">
        <button class="tab active" data-tab="browser">
          <i data-feather="compass"></i> Browser
        </button>
        <button class="tab" data-tab="settings">
          <i data-feather="settings"></i> Settings
        </button>
        <button class="tab" data-tab="privacy">
          <i data-feather="shield"></i> Privacy
        </button>
      </div>
      
      <div id="browser-content" class="tab-content active">
        <div class="flex mb-4">
          <input 
            type="text" 
            id="url-input" 
            class="flex-1 bg-black border border-blood rounded-l-lg px-4 py-2 text-white focus:outline-none focus:ring-2 focus:ring-blood" 
            placeholder="Enter URL (e.g. https://example.com)"
          >
          <button id="go-button" class="bg-blood px-4 py-2 rounded-r-lg font-bold hover:bg-red-800">
            GO
          </button>
        </div>
      </div>
      
      <div id="settings-content" class="tab-content">
        <div class="space-y-4">
          <div class="flex items-center">
            <input type="checkbox" id="proxy-toggle" class="rounded bg-black border-blood text-blood">
            <label for="proxy-toggle" class="ml-2">Enable Proxy</label>
          </div>
          <div id="proxy-settings" class="hidden">
            <div class="mb-2">
              <label class="block text-sm mb-1">Proxy Server</label>
              <input type="text" id="proxy-server" class="w-full bg-black border border-blood rounded px-3 py-2 text-white">
            </div>
          </div>
        </div>
      </div>
      
      <div id="privacy-content" class="tab-content">
        <div class="space-y-3">
          <button id="clear-data" class="w-full bg-black hover:bg-blood border border-blood rounded px-4 py-2 flex items-center">
            <i data-feather="trash-2" class="mr-2"></i> Clear Browsing Data
          </button>
          <button id="toggle-vpn" class="w-full bg-black hover:bg-blood border border-blood rounded px-4 py-2 flex items-center">
            <i data-feather="lock" class="mr-2"></i> Toggle VPN
          </button>
        </div>
      </div>
    `;

    // Tab switching
    const tabs = this.shadowRoot.querySelectorAll('.tab');
    const contents = this.shadowRoot.querySelectorAll('.tab-content');
    
    tabs.forEach(tab => {
      tab.addEventListener('click', () => {
        tabs.forEach(t => t.classList.remove('active'));
        contents.forEach(c => c.classList.remove('active'));
        
        tab.classList.add('active');
        const tabId = tab.getAttribute('data-tab');
        this.shadowRoot.getElementById(`${tabId}-content`).classList.add('active');
        feather.replace();
      });
    });

    // Proxy toggle
    const proxyToggle = this.shadowRoot.getElementById('proxy-toggle');
    const proxySettings = this.shadowRoot.getElementById('proxy-settings');
    
    proxyToggle.addEventListener('change', () => {
      proxySettings.classList.toggle('hidden', !proxyToggle.checked);
    });

    // URL navigation
    const urlInput = this.shadowRoot.getElementById('url-input');
    const goButton = this.shadowRoot.getElementById('go-button');
    
    const handleNavigation = () => {
      const url = urlInput.value.trim();
      const useProxy = proxyToggle.checked;
      
      if (url) {
        this.dispatchEvent(new CustomEvent('navigate', {
          detail: { url, useProxy },
          bubbles: true,
          composed: true
        }));
      }
    };
    
    goButton.addEventListener('click', handleNavigation);
    urlInput.addEventListener('keypress', (e) => {
      if (e.key === 'Enter') handleNavigation();
    });

    feather.replace();
  }
}

customElements.define('custom-tabs', CustomTabs);