<!DOCTYPE html>
<html lang="ar">
<head>
<meta charset="UTF-8">
<title>منظم المباريات</title>
<style>
body {
font-family: Arial, sans-serif;
background: #111;
color: #fff;
padding: 20px;
}
textarea {
width: 100%;
height: 200px;
background: #222;
color: #fff;
border: 1px solid #444;
padding: 10px;
}
button {
margin: 15px 0;
padding: 10px 20px;
background: #0a84ff;
border: none;
color: #fff;
cursor: pointer;
font-size: 16px;
}
.match {
background: #1c1c1c;
margin-bottom: 15px;
padding: 10px;
border-radius: 6px;
}
.time {
color: #00d084;
font-weight: bold;
}
.links a {
display: inline-block;
margin: 5px 5px 0 0;
color: #0a84ff;
text-decoration: none;
font-size: 14px;
}
</style>
</head>
<body>
<h2>🟢 ضع المباريات هنا</h2>
<textarea id="input"></textarea>
<button onclick="extract()">استخراج وترتيب</button>
<div id="output"></div>
<script>
function extract() {
const text = document.getElementById("input").value;
const lines = text.split(/\s(?=\d{1,2}[:٫]\d{2})|[\n]+/);
const matches = {};
lines.forEach(line => {
const timeMatch = line.match(/(\d{1,2}[:٫]\d{2}|7:00 مساءً)/);
const urlMatch = line.match(/https?:\/\/\S+/);
if (!timeMatch || !urlMatch) return;
const time = timeMatch[0].replace("٫", ":");
const name = line
.replace(timeMatch[0], "")
.replace(urlMatch[0], "")
.replace("|", "")
.trim();
if (!matches[time]) matches[time] = {};
if (!matches[time][name]) matches[time][name] = [];
matches[time][name].push(urlMatch[0]);
});
const sortedTimes = Object.keys(matches).sort((a,b)=>{
return a.localeCompare(b, 'ar', {numeric:true});
});
let html = "";
sortedTimes.forEach(time => {
Object.keys(matches[time]).forEach(name => {
html += `<div class="match">
<div class="time">⏰ ${time}</div>
<div>⚽ ${name}</div>
<div class="links">
${matches[time][name].map(l => `<a href="${l}" target="_blank">مشاهدة</a>`).join("")}
</div>
</div>`;
});
});
document.getElementById("output").innerHTML = html;
}
</script>
</body>
</html>
No comments:
Post a Comment