new pisilinux web sites
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,265 @@
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Theme toggle
|
||||
var savedTheme = localStorage.getItem('pisiTheme') || 'dark';
|
||||
document.documentElement.setAttribute('data-theme', savedTheme);
|
||||
var icon = document.getElementById('themeIcon');
|
||||
if (icon) icon.className = savedTheme === 'dark' ? 'fas fa-moon' : 'fas fa-sun';
|
||||
|
||||
var themeBtn = document.getElementById('themeToggle');
|
||||
if (themeBtn) {
|
||||
themeBtn.addEventListener('click', function() {
|
||||
var html = document.documentElement;
|
||||
var current = html.getAttribute('data-theme') || 'dark';
|
||||
var next = current === 'dark' ? 'light' : 'dark';
|
||||
html.setAttribute('data-theme', next);
|
||||
localStorage.setItem('pisiTheme', next);
|
||||
var icon = document.getElementById('themeIcon');
|
||||
if (icon) icon.className = next === 'dark' ? 'fas fa-moon' : 'fas fa-sun';
|
||||
});
|
||||
}
|
||||
|
||||
// Tooltips
|
||||
var tooltips = document.querySelectorAll('[data-bs-toggle="tooltip"]');
|
||||
if (tooltips.length && typeof bootstrap !== 'undefined') {
|
||||
tooltips.forEach(function(el) { new bootstrap.Tooltip(el); });
|
||||
}
|
||||
|
||||
// Download counter
|
||||
document.querySelectorAll('.download').forEach(function(el) {
|
||||
el.addEventListener('click', function(e) {
|
||||
var id = this.dataset.id;
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', 'download/counter', true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
xhr.send('id=' + id);
|
||||
});
|
||||
});
|
||||
|
||||
// Contact form
|
||||
var contactBtn = document.getElementById('contact');
|
||||
if (contactBtn) {
|
||||
contactBtn.addEventListener('click', function(e) {
|
||||
if (contactBtn.disabled) return;
|
||||
var originalText = contactBtn.textContent;
|
||||
contactBtn.disabled = true;
|
||||
contactBtn.textContent = 'Gönderiliyor...';
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', '/contact/send', true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
xhr.onload = function() {
|
||||
contactBtn.disabled = false;
|
||||
contactBtn.textContent = originalText;
|
||||
var data = xhr.responseText.split('&');
|
||||
if (data[0] == 1) {
|
||||
Swal.fire({ text: data[1], icon: 'success', didOpen: function() {
|
||||
document.querySelector('.container').style.filter = 'blur(5px)';
|
||||
}, willClose: function() {
|
||||
document.querySelector('.container').style.filter = 'none';
|
||||
window.location.href = '/';
|
||||
}});
|
||||
} else {
|
||||
Swal.fire({ text: data[1], icon: 'error', didOpen: function() {
|
||||
document.querySelector('.container').style.filter = 'blur(5px)';
|
||||
}, willClose: function() {
|
||||
document.querySelector('.container').style.filter = 'none';
|
||||
}});
|
||||
}
|
||||
};
|
||||
xhr.send('name=' + encodeURIComponent(document.getElementById('name') ? document.getElementById('name').value : '') +
|
||||
'&email=' + encodeURIComponent(document.getElementById('email') ? document.getElementById('email').value : '') +
|
||||
'&message=' + encodeURIComponent(document.getElementById('message') ? document.getElementById('message').value : '') +
|
||||
'&token=' + encodeURIComponent(document.getElementById('token') ? document.getElementById('token').value : ''));
|
||||
});
|
||||
}
|
||||
|
||||
// Register form
|
||||
var registerBtn = document.getElementById('registerSubmit');
|
||||
if (registerBtn) {
|
||||
registerBtn.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var form = document.getElementById('registerForm');
|
||||
var username = document.getElementById('username');
|
||||
var surname = document.getElementById('surname');
|
||||
var email = document.getElementById('email');
|
||||
var password = document.getElementById('password');
|
||||
var password2 = document.getElementById('password2');
|
||||
|
||||
function setError(el, msg) {
|
||||
el.value = '';
|
||||
el.focus();
|
||||
el.placeholder = msg;
|
||||
el.classList.add('error');
|
||||
}
|
||||
|
||||
function clearError(el) { el.classList.remove('error'); }
|
||||
|
||||
if (!username || username.value.length <= 2) { setError(username, 'En az 3 karakter olmalıdır'); return; }
|
||||
clearError(username);
|
||||
if (!surname || surname.value.length <= 2) { setError(surname, 'En az 3 karakter olmalıdır'); return; }
|
||||
clearError(surname);
|
||||
if (!email || email.value === '') { setError(email, 'Geçerli bir e-posta adresi girin'); return; }
|
||||
if (!emailControl(email.value)) { setError(email, 'Geçerli bir e-posta adresi girin'); return; }
|
||||
clearError(email);
|
||||
if (!password || password.value === '') { setError(password, 'Şifre alanı boş olamaz'); return; }
|
||||
if (password.value.length <= 5) { setError(password, 'Şifre en az 6 karakter olmalıdır'); return; }
|
||||
clearError(password);
|
||||
if (!password2 || password2.value === '') { setError(password2, 'Şifre alanı boş olamaz'); return; }
|
||||
if (password.value !== password2.value) { setError(password2, 'Şifreler eşleşmiyor'); return; }
|
||||
clearError(password2);
|
||||
|
||||
var formData = new FormData(form);
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', '/member/emailcontrol', true);
|
||||
xhr.onload = function() {
|
||||
if (xhr.responseText == 1) {
|
||||
setError(email, 'Bu e-posta adresi zaten kullanılıyor');
|
||||
} else {
|
||||
registerBtn.style.display = 'none';
|
||||
var xhr2 = new XMLHttpRequest();
|
||||
xhr2.open('POST', '/member/new_user', true);
|
||||
xhr2.onload = function() {
|
||||
if (xhr2.responseText == 1) {
|
||||
Swal.fire('', 'Kayıt işleminiz başarıyla tamamlandı. Hesabınızı aktif etmek için lütfen e-posta adresinizi kontrol edin.', 'success')
|
||||
.then(function() { window.location.replace('/'); });
|
||||
} else if (xhr2.responseText == 'csrf') {
|
||||
Swal.fire('', 'Güvenlik doğrulaması başarısız. Lütfen sayfayı yenileyip tekrar deneyin.', 'error');
|
||||
} else if (xhr2.responseText == 'captcha') {
|
||||
Swal.fire('', 'Güvenlik kodu hatalı. Lütfen tekrar deneyin.', 'error');
|
||||
} else if (xhr2.responseText == 'match') {
|
||||
Swal.fire('', 'Şifreler eşleşmiyor.', 'error');
|
||||
} else if (xhr2.responseText == 'length') {
|
||||
Swal.fire('', 'Şifre en az 6 karakter olmalıdır.', 'error');
|
||||
} else {
|
||||
Swal.fire('', 'Kayıt sırasında bir hata oluştu, lütfen daha sonra tekrar deneyin', 'error');
|
||||
}
|
||||
};
|
||||
xhr2.send(formData);
|
||||
}
|
||||
};
|
||||
xhr.send('email1=' + encodeURIComponent(email.value));
|
||||
});
|
||||
}
|
||||
|
||||
// Image fluid
|
||||
document.querySelectorAll('img').forEach(function(img) { img.classList.add('img-fluid'); });
|
||||
|
||||
// Carousel first item active
|
||||
var firstCarousel = document.querySelector('div.carousel-item');
|
||||
if (firstCarousel) firstCarousel.classList.add('active');
|
||||
|
||||
// Submit disable (global)
|
||||
var submitBtn = document.getElementById('submit');
|
||||
if (submitBtn) submitBtn.disabled = true;
|
||||
|
||||
// Task redirect
|
||||
var gorevBtn = document.getElementById('gorev');
|
||||
if (gorevBtn) {
|
||||
gorevBtn.addEventListener('click', function() {
|
||||
window.location.replace('https://pisilinux.org/bugs/addtask');
|
||||
});
|
||||
}
|
||||
|
||||
// Forum view change
|
||||
var gorunum = document.getElementById('gorunum');
|
||||
if (gorunum) {
|
||||
gorunum.addEventListener('change', function() {
|
||||
if (this.value == 2) window.location.replace('/question_answer');
|
||||
});
|
||||
}
|
||||
|
||||
// Task type toggle system info
|
||||
var task = document.getElementById('task');
|
||||
var sistem1 = document.getElementById('sistem1');
|
||||
if (task && sistem1) {
|
||||
task.addEventListener('change', function() {
|
||||
sistem1.style.display = this.value == 1 ? 'block' : 'none';
|
||||
});
|
||||
}
|
||||
|
||||
// Nav link active tracking via localStorage
|
||||
document.querySelectorAll('.nav-link').forEach(function(el) {
|
||||
el.addEventListener('click', function() {
|
||||
localStorage.setItem('activeLink', this.getAttribute('href'));
|
||||
});
|
||||
});
|
||||
var activeTab = localStorage.getItem('activeLink');
|
||||
if (activeTab) {
|
||||
var match = document.querySelector('li.nav-item a[href="' + activeTab + '"]');
|
||||
if (match) match.parentElement.classList.add('active');
|
||||
}
|
||||
|
||||
// Scroll to top button & header shadow
|
||||
var header = document.querySelector('.site-header');
|
||||
window.addEventListener('scroll', function() {
|
||||
if (header) {
|
||||
header.classList.toggle('scrolled', window.scrollY > 0);
|
||||
}
|
||||
var imgup = document.querySelector('.imgup');
|
||||
if (imgup) {
|
||||
imgup.style.display = window.scrollY >= 50 ? 'block' : 'none';
|
||||
}
|
||||
});
|
||||
|
||||
// Flag language switcher
|
||||
document.addEventListener('click', function(e) {
|
||||
var flag = e.target.closest('.flags');
|
||||
if (flag) {
|
||||
e.preventDefault();
|
||||
document.cookie = 'country=' + flag.dataset.id;
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
// Bugs form validation
|
||||
var bugsForm = document.getElementById('bugsnew');
|
||||
if (bugsForm) {
|
||||
bugsForm.addEventListener('submit', function(event) {
|
||||
var details = this.querySelector('.details');
|
||||
var uyari = this.querySelector('.detayUyari');
|
||||
if (details && details.value === '') {
|
||||
if (uyari) {
|
||||
uyari.textContent = '( Detaylar alanı boş bırakılamaz...)';
|
||||
uyari.style.display = 'inline';
|
||||
setTimeout(function() { if (uyari) uyari.style.display = 'none'; }, 5000);
|
||||
}
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Bugs close
|
||||
document.querySelectorAll('.bugsClose').forEach(function(el) {
|
||||
el.addEventListener('click', function() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', '/bugs/bugsClose', true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
xhr.onload = function() { location.reload(); };
|
||||
xhr.send('id=' + this.dataset.id + '&status=' + this.dataset.status);
|
||||
});
|
||||
});
|
||||
|
||||
// Username/surname character filter
|
||||
var userFields = ['username', 'surname'];
|
||||
userFields.forEach(function(id) {
|
||||
var el = document.getElementById(id);
|
||||
if (el) {
|
||||
el.addEventListener('keyup', function() {
|
||||
this.value = this.value.replace(/[^a-zA-ZwığüşöçĞÜŞÖÇİ ]/g, '');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Window show
|
||||
window.scrollTo(0, 0);
|
||||
|
||||
});
|
||||
|
||||
function emailControl(email) {
|
||||
return /^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/i.test(email);
|
||||
}
|
||||
|
||||
function customURLConverter(url, node, on_save, name) {
|
||||
return url.substring(0, 7) === '/system' ? 'https://pisilinux.org' + url : url;
|
||||
}
|
||||
Reference in New Issue
Block a user