सदस्यः:IKHazarika/purvi-nagari.js
सूचना : भवता/भवत्या कृतानि सम्पादनानि संरक्ष्य तानि परिवर्तनेषु द्रष्टुं गवेषकस्य पृष्ठस्य पुनरारोपणम् (reload) आवश्यकं भवति ।
- Firefox / Safari: Shiftकुड्मलेन सह Reloadकुड्मलं नुदतु ।
- Google Chrome: Ctrl-Shift-R नोदनेन पुनरारोपणं भवति । (⌘-R इति Mac तन्त्रांशप्रयोक्तॄभ्यः)
- Internet Explorer: Ctrlकुड्मलेन सह Refreshकुड्मलं नुदतु, Ctrl-F5 नुदतु वा ।
- Opera: Tools → Preferences इत्यत्र गत्वा कर्तुं शक्नोति ।
//This is a script converter that converts between Devanagari and Purvinagari. More specifically, it uses the Kamarupi variant instead of the Gauda variant.
(function() {
// Function to replace characters
function replaceCharacters() {
var walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, false);
var node;
while (node = walker.nextNode()) {
node.nodeValue = node.nodeValue
.replace(/পূৰ্বী-নাগৰী/g, 'pqrxyz')
.replace(/क/g, 'ক')
.replace(/र/g, 'ৰ')
.replace(/ख/g, 'খ')
.replace(/ग/g, 'গ')
.replace(/घ/g, 'ঘ')
.replace(/ङ/g, 'ঙ')
.replace(/च/g, 'চ')
.replace(/छ/g, 'ছ')
.replace(/ज/g, 'জ')
.replace(/झ/g, 'ঝ')
.replace(/ञ/g, 'ঞ')
.replace(/ट/g, 'ট')
.replace(/ठ/g, 'ঠ')
.replace(/ड/g, 'ড')
.replace(/ढ/g, 'ঢ')
.replace(/ण/g, 'ণ')
.replace(/त/g, 'ত')
.replace(/थ/g, 'থ')
.replace(/द/g, 'দ')
.replace(/ध/g, 'ধ')
.replace(/न/g, 'ন')
.replace(/प/g, 'প')
.replace(/फ/g, 'ফ')
.replace(/ब/g, 'ব')
.replace(/भ/g, 'ভ')
.replace(/म/g, 'ম')
.replace(/य/g, 'য')
.replace(/ल/g, 'ল')
.replace(/व/g, 'ৱ')
.replace(/श/g, 'শ')
.replace(/ष/g, 'ষ')
.replace(/स/g, 'স')
.replace(/ह/g, 'হ')
.replace(/अ/g, 'অ')
.replace(/आ/g, 'আ')
.replace(/इ/g, 'ই')
.replace(/ई/g, 'ঈ')
.replace(/उ/g, 'উ')
.replace(/ऊ/g, 'ঊ')
.replace(/ऋ/g, 'ঋ')
.replace(/ए/g, 'এ')
.replace(/ऐ/g, 'ঐ')
.replace(/ओ/g, 'ও')
.replace(/औ/g, 'ঔ')
.replace(/ा/g, 'া')
.replace(/ि/g, 'ি')
.replace(/ी/g, 'ী')
.replace(/ु/g, 'ু')
.replace(/ू/g, 'ূ')
.replace(/ृ/g, 'ৃ')
.replace(/े/g, 'ে')
.replace(/ै/g, 'ৈ')
.replace(/ो/g, 'ো')
.replace(/ौ/g, 'ৌ')
.replace(/ं/g, 'ং')
.replace(/ः/g, 'ঃ')
.replace(/ँ/g, 'ঁ')
.replace(/्/g, '্')
.replace(/pqrxyz/g, 'देवनागरी')
}
}
// Function to undo the replacements
function undoReplacements() {
var walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, false);
var node;
while (node = walker.nextNode()) {
node.nodeValue = node.nodeValue
.replace(/देवनागरी/g, 'pqrxyz')
.replace(/ক/g, 'क')
.replace(/ৰ/g, 'र')
.replace(/খ/g, 'ख')
.replace(/গ/g, 'ग')
.replace(/ঘ/g, 'घ')
.replace(/ঙ/g, 'ङ')
.replace(/চ/g, 'च')
.replace(/ছ/g, 'छ')
.replace(/জ/g, 'ज')
.replace(/ঝ/g, 'झ')
.replace(/ঞ/g, 'ञ')
.replace(/ট/g, 'ट')
.replace(/ঠ/g, 'ठ')
.replace(/ড/g, 'ड')
.replace(/ঢ/g, 'ढ')
.replace(/ণ/g, 'ण')
.replace(/ত/g, 'त')
.replace(/থ/g, 'थ')
.replace(/দ/g, 'द')
.replace(/ধ/g, 'ध')
.replace(/ন/g, 'न')
.replace(/প/g, 'प')
.replace(/ফ/g, 'फ')
.replace(/ব/g, 'ब')
.replace(/ভ/g, 'भ')
.replace(/ম/g, 'म')
.replace(/য/g, 'य')
.replace(/ল/g, 'ल')
.replace(/ৱ/g, 'व')
.replace(/শ/g, 'श')
.replace(/ষ/g, 'ष')
.replace(/স/g, 'स')
.replace(/হ/g, 'ह')
.replace(/অ/g, 'अ')
.replace(/আ/g, 'आ')
.replace(/ই/g, 'इ')
.replace(/ঈ/g, 'ई')
.replace(/উ/g, 'उ')
.replace(/ঊ/g, 'ऊ')
.replace(/ঋ/g, 'ऋ')
.replace(/এ/g, 'ए')
.replace(/ঐ/g, 'ऐ')
.replace(/ও/g, 'ओ')
.replace(/ঔ/g, 'औ')
.replace(/া/g, 'ा')
.replace(/ি/g, 'ि')
.replace(/ী/g, 'ी')
.replace(/ু/g, 'ु')
.replace(/ূ/g, 'ू')
.replace(/ৃ/g, 'ृ')
.replace(/ে/g, 'े')
.replace(/ৈ/g, 'ै')
.replace(/ো/g, 'ो')
.replace(/ৌ/g, 'ौ')
.replace(/ং/g, 'ं')
.replace(/ঃ/g, 'ः')
.replace(/ঁ/g, 'ँ')
.replace(/্/g, '्')
.replace(/pqrxyz/g, 'পূৰ্বী-নাগৰী');
}
}
// Function to create the toggle button
function createToggleButton() {
var button = document.createElement('button');
button.textContent = 'পূৰ্বী-নাগৰী';
button.style.position = 'fixed';
button.style.top = '80px';
button.style.right = '10px';
button.style.zIndex = '1000';
button.style.padding = '10px';
button.style.backgroundColor = '#007bff';
button.style.color = '#ffffff';
button.style.border = 'none';
button.style.borderRadius = '5px';
button.style.cursor = 'pointer';
// Add event listener to toggle the replacements
var isReplaced = false;
button.addEventListener('click', function() {
if (isReplaced) {
undoReplacements();
isReplaced = false;
} else {
replaceCharacters();
isReplaced = true;
}
});
// Append the button to the body
document.body.appendChild(button);
}
// Run the function after the page has fully loaded
setTimeout(createToggleButton, 3000);
//document.addEventListener('DOMContentLoaded', createToggleButton);
})();