Lekhoniya lekhoniya.com Subham Mandal Dhupguri ONE Code ONE ssss web West Bengal India Bangla writing pad Bengali type লেখনীয়া
লেখনীয়া
progarammed by Subham Mandal

Lekhoniya Global

Lekhoniya Global Script - In-depth Guide

Introduction

The Lekhoniya Global Script enhances the collaborative and real-time aspects of Lekhoniya by providing a global platform for users to share content. This guide will walk you through the features and functionalities of the script.

Overview of Global Script

The Global Script is designed to facilitate real-time collaboration and sharing of content among users on Lekhoniya. Users accessing a specific URL (https://lekhoniya.blogspot.com/g/) will be connected to a shared space where updates made by one user are reflected in real-time for others.

Code Explanation

var currentUrl_gtime = window.location.href.substring(0, 33);
var urlToMatch = 'https://lekhoniya.blogspot.com/g/';

if (currentUrl_gtime === urlToMatch) {
console.log('Connecting...');

// Listen for changes in the 'Lekhoniya-Global' Firebase database
firebase.database().ref('Lekhoniya-Global').on("value", function(snapshot) {
var firebaseValue = snapshot.val().user;

// Check and activate the script based on Firebase value
checkAndActivateScript(firebaseValue);
});

function checkAndActivateScript(firebaseValue) {
let localStorageValue = localStorage.getItem('lekhoniya-user');

if (firebaseValue === localStorageValue) {
// User is already connected
} else {
// Update content based on the 'valx' value from Firebase
firebase.database().ref('Lekhoniya-Global').on("value", function(snapshot) {
document.getElementById('editableSpan').innerHTML = snapshot.val().valx;
});
}
}

// Alert and console message to indicate successful connection
alert('Welcome to Global!');
console.log('Lekhoniya Global!');

// Set 'oninput' event for the 'editableSpan'
let editableSpan = document.getElementById('editableSpan');
editableSpan.setAttribute('oninput', 'updateGlobal()');

// Fetch initial content from Firebase
fetch('https://onerealtimeserver-default-rtdb.firebaseio.com/Lekhoniya-Global/valx.json')
.then(response => response.json())
.then(data => {
document.getElementById('editableSpan').innerHTML = data;
});
}

// Function to update global content on user input
function updateGlobal() {
let timeg = new Date().toLocaleTimeString();
let user = localStorage.getItem('lekhoniya-user');
const valx = document.getElementById('editableSpan').innerHTML;

// Update 'Lekhoniya-Global' Firebase database
firebase.database().ref('Lekhoniya-Global').set({ valx, user , timeg });
}

Usage Instructions

  1. Access Global Space:Open the URL https://lekhoniya.blogspot.com/g/ in your web browser.
  2. Real-time Collaboration:Users accessing the global space can collaboratively edit and share content in real-time.
  3. Automatic Updates:Content is automatically updated based on user inputs, providing a seamless collaborative writing experience.
  4. User Connection:User connection is managed through Firebase, ensuring that each user's contributions are reflected in the shared space.
  5. Alerts and Console Messages:Users receive an alert message ("Welcome to Global!") upon successful connection.Connection details are logged to the console for reference.

Conclusion

The Lekhoniya Global Script brings a new dimension to collaborative writing, offering users a shared space for real-time content creation and updates. For questions, feedback, or assistance, feel free to reach out to the Lekhoniya support team. Happy global writing on Lekhoniya!