Home जौनपुर khutahn

khutahn

0

 <!– 🔹 स्कूल सर्विस वोटिंग फॉर्म (Blogger Ready Code) –>

<div id=”poll-widget” style=”max-width:850px;margin:auto;padding:25px;border-radius:15px;background:#fff;font-family:Arial,sans-serif;box-shadow:0 8px 35px rgba(0,0,0,0.15);”>

  <h2 style=”text-align:center;color:#222;”>स्कूल सर्विस वोटिंग फॉर्म</h2>

  <p style=”text-align:center;color:#555;font-size:14px;”>कृपया अपने पसंदीदा उम्मीदवार का चयन करें</p>

  <form id=”pollForm” style=”margin-top:25px;”>

    <div style=”display:flex;flex-wrap:wrap;gap:12px;margin-bottom:18px;”>

      <input id=”name” placeholder=”नाम” style=”flex:1;padding:12px;border-radius:8px;border:1px solid #ccc” required/>

      <input id=”village” placeholder=”गाँव” style=”flex:1;padding:12px;border-radius:8px;border:1px solid #ccc” required/>

      <input id=”mobile” placeholder=”मोबाइल नंबर” style=”flex:1;padding:12px;border-radius:8px;border:1px solid #ccc” required/>

    </div>

    <div style=”display:flex;flex-wrap:wrap;gap:12px;margin-bottom:25px;”>

      <label class=”vote-card”><input type=”radio” name=”option” value=”धर्मेंद्र मौर्य” required/> <span>धर्मेंद्र मौर्य</span></label>

      <label class=”vote-card”><input type=”radio” name=”option” value=”सुरेंद्र उर्फ कल्लू लाला”/> <span>सुरेंद्र उर्फ कल्लू लाला</span></label>

      <label class=”vote-card”><input type=”radio” name=”option” value=”शैलेश यादव”/> <span>शैलेश यादव</span></label>

      <label class=”vote-card”><input type=”radio” name=”option” value=”समर बहादुर लोटा”/> <span>समर बहादुर लोटा</span></label>

      <label class=”vote-card”><input type=”radio” name=”option” value=”लालमन यादव”/> <span>लालमन यादव</span></label>

      <label class=”vote-card”><input type=”radio” name=”option” value=”महातम यादव”/> <span>महातम यादव</span></label>

      <label class=”vote-card”><input type=”radio” name=”option” value=”योगेश उर्फ सद्दू”/> <span>योगेश उर्फ सद्दू</span></label>

    </div>

    <div style=”text-align:center;”>

      <button type=”submit” class=”btn” style=”padding:12px 28px;background:#4CAF50;color:white;border:none;border-radius:8px;cursor:pointer;margin-right:10px;”>वोट सबमिट करें</button>

      <button type=”button” id=”showResults” class=”btn” style=”padding:12px 28px;background:#2196F3;color:white;border:none;border-radius:8px;cursor:pointer;”>रिज़ल्ट देखें</button>

    </div>

    <div id=”msg” style=”margin-top:18px;color:#333;font-weight:600;text-align:center;transition:0.4s;”></div>

  </form>

  <div id=”results” style=”margin-top:30px;display:none;”>

    <h3 style=”text-align:center;color:#222;”>वोट परिणाम</h3>

    <canvas id=”pieChart” style=”max-width:100%;height:380px;margin-top:18px;”></canvas>

    <div id=”totalVotes” style=”margin-top:14px;color:#555;font-weight:600;text-align:center;”></div>

    <!– 🔹 Admin Access Section –>

    <div id=”adminAccess” style=”margin-top:20px;text-align:center;display:block;”>

      <input id=”adminMobile” placeholder=”एडमिन मोबाइल नंबर” style=”padding:10px;border:1px solid #ccc;border-radius:8px;margin-right:8px;”>

      <button type=”button” id=”checkAdmin” style=”padding:10px 20px;background:#673AB7;color:white;border:none;border-radius:8px;cursor:pointer;”>पुष्टि करें</button>

      <br><br>

      <button type=”button” id=”downloadCSV” style=”padding:12px 28px;background:#FF5722;color:white;border:none;border-radius:8px;cursor:pointer;display:none;”>वोटर एक्सेल डाउनलोड</button>

    </div>

  </div>

</div>

<style>

.vote-card{

  flex:1 1 calc(33% – 12px);

  background:#fdfdfd;

  border-radius:12px;

  padding:18px;

  text-align:center;

  cursor:pointer;

  transition:0.4s;

  box-shadow:0 3px 12px rgba(0,0,0,0.08);

  position:relative;

}

.vote-card:hover{ background:#e0f7fa; transform:translateY(-4px); box-shadow:0 8px 22px rgba(0,0,0,0.18);}

.vote-card input{ position:absolute; opacity:0; cursor:pointer; }

.vote-card span{ font-weight:600; color:#222; display:block; font-size:15px; transition:0.3s; }

.vote-card input:checked + span{ color:#4CAF50; font-weight:700; }

.btn:hover{ opacity:0.85; transition:0.3s; }

@media(max-width:750px){ .vote-card{flex:1 1 calc(50% – 12px);} }

@media(max-width:500px){ .vote-card{flex:1 1 100%;} }

</style>

<script src=”https://cdn.jsdelivr.net/npm/chart.js”></script>

<script>

const POLL_KEY = ‘school_poll_votes’;

const ADMIN_NUMBER = ‘8808789433’;

const COLORS = [‘#4CAF50′,’#FF9800′,’#03A9F4′,’#E91E63′,’#9C27B0′,’#FFC107’];

function getVotes(){ const data = localStorage.getItem(POLL_KEY); return data ? JSON.parse(data) : []; }

function saveVote(vote){ const votes = getVotes(); votes.push(vote); localStorage.setItem(POLL_KEY, JSON.stringify(votes)); }

function hasVoted(mobile){ const votes = getVotes(); return votes.some(v=>v.mobile===mobile); }

function showMessage(msg,color=’green’){ const el=document.getElementById(‘msg’); el.style.color=color; el.textContent=msg; el.style.opacity=1; setTimeout(()=>{el.style.opacity=0;},4000); }

let pieChartInstance = null;

function renderChart(){

  const votes = getVotes();

  const total = votes.length;

  const counts = {};

  votes.forEach(v=>{ counts[v.option] = (counts[v.option] || 0)+1; });

  const labels = Object.keys(counts);

  const data = labels.map(l=>counts[l]);

  const bgColors = labels.map((l,i)=>COLORS[i%COLORS.length]);

  const ctx = document.getElementById(‘pieChart’).getContext(‘2d’);

  if(pieChartInstance) pieChartInstance.destroy();

  pieChartInstance = new Chart(ctx,{

    type:’pie’,

    data:{labels,datasets:[{data, backgroundColor:bgColors, borderColor:’#fff’, borderWidth:2}]},

    options:{

      responsive:true,

      plugins:{

        legend:{position:’bottom’, labels:{padding:12, font:{size:14}}},

        tooltip:{callbacks:{label:function(ctx){

          const pct = total>0 ? ((ctx.raw/total)*100).toFixed(2) : 0;

          return ctx.label + ‘ — ‘ + ctx.raw + ‘ वोट (‘+pct+’%)’;

        }}}

      }

    }

  });

  document.getElementById(‘totalVotes’).textContent = ‘कुल वोट: ‘ + total;

  document.getElementById(‘results’).style.display=’block’;

}

// 🔹 CSV Download

function downloadCSV(){

  const votes = getVotes();

  if(votes.length===0){ alert(‘कोई वोट नहीं मिला।’); return; }

  let csv = ‘नाम,गाँव,मोबाइल,वोटn’;

  votes.forEach(v=>{

    csv += `”${v.name}”,”${v.village}”,”${v.mobile}”,”${v.option}”n`;

  });

  const blob = new Blob([csv], {type:’text/csv’});

  const a = document.createElement(‘a’);

  a.href = URL.createObjectURL(blob);

  a.download = `voters.csv`;

  a.click();

  URL.revokeObjectURL(a.href);

}

// 🔹 Event Listeners

document.getElementById(‘pollForm’).addEventListener(‘submit’, function(e){

  e.preventDefault();

  const name = document.getElementById(‘name’).value.trim();

  const village = document.getElementById(‘village’).value.trim();

  const mobile = document.getElementById(‘mobile’).value.trim();

  const optionEl = document.querySelector(‘input[name=”option”]:checked’);

  if(!optionEl){ showMessage(‘कृपया उम्मीदवार चुनें।’,’red’); return; }

  const option = optionEl.value;

  const normalized = mobile.replace(/D/g,”);

  if(normalized.length<6){ showMessage(‘कृपया सही मोबाइल नंबर दर्ज करें।’,’red’); return; }

  if(hasVoted(normalized)){ showMessage(‘आप पहले ही वोट दे चुके हैं।’,’red’); return; }

  saveVote({name,village,mobile:normalized,option});

  showMessage(‘धन्यवाद! आपका वोट सफलतापूर्वक दर्ज हो गया है।’);

  renderChart();

});

document.getElementById(‘showResults’).addEventListener(‘click’, renderChart);

document.getElementById(‘checkAdmin’).addEventListener(‘click’, ()=>{

  const adminMobile = document.getElementById(‘adminMobile’).value.trim();

  if(adminMobile===ADMIN_NUMBER){

    document.getElementById(‘downloadCSV’).style.display=’inline-block’;

  } else {

    alert(‘सिर्फ अधिकृत मोबाइल नंबर ही डेटा डाउनलोड कर सकता है।’);

  }

});

document.getElementById(‘downloadCSV’).addEventListener(‘click’, downloadCSV);

</script>

Previous articleखुटहन पोल सर्वे फॉर्म
Next articlekhutahan form