Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/arverma/Bihar-Police-Notebook/llms.txt

Use this file to discover all available pages before exploring further.

All application logic for Bihar Police Notebook lives in editor/js/ as plain ES modules — no bundler, no transpilation step. The browser loads them directly via <script type="module">. This page lists every file, what it owns, and the key symbols it exports.
Modules marked no side-effects are pure-function libraries. All DOM work is centralised in main.js and the two sheet modules.

Orchestrator

main.js

Path: editor/js/main.jsThe single top-level orchestrator. Runs on DOMContentLoaded, wires every other module to the UI, manages the active document state, and owns the autosave timer.Key exports / functions (module-internal, called at init):
SymbolDescription
initApp()Entry point — called once on page load; sets up all event listeners and restores the last open document
runPdfExport()Opens a print window with template HTML + print CSS and triggers window.print()
scheduleSave()Debounces autosave by 600 ms; shows the saving spinner on the PDF button
attachTransliteration(el)Wires input/keydown/click listeners on a text field to fetch Hinglish suggestions
insertDictatedText(text)Inserts voice-dictated text at the tracked caret (works for both plain textareas and Quill editors)
getDictationTarget()Returns the currently focused editable element and its caret range for dictation insertion

Document templates

paged-sheet.js

Path: editor/js/paged-sheet.jsLetter template. Renders plain-text page cards; handles text spill from one page to the next when content overflows.Key exports: initPagedSheet(), letterPagesHtml(), letterPrintCss()

diary-sheet.js

Path: editor/js/diary-sheet.jsFIR Case Diary template. Renders the header (case details) and left/right column diary pages; handles column spill.Key exports: initDiarySheet(), diaryPagesHtml(), normalizeDiaryModel(), diaryPrintCss(), emptyModel()

Rendering and layout

page-scale.js

Path: editor/js/page-scale.jsScales the editor canvas to fit the viewport width. On desktop, a click cycles through zoom levels; on mobile (≤ 768 px) it enables CSS pinch-zoom and collapses the negative margin that normally clips the page shadow.Key exports: initPageScale()

quill-fields.js

Path: editor/js/quill-fields.jsIntegrates Quill rich-text editor instances for the structured diary fields (case summary, officer remarks, etc.) that need bold/italic formatting.Key exports: initQuillToolbar(), getFieldForEditor(), stripHtmlToPlain()

Local storage

store.js

Path: editor/js/store.jsAll IndexedDB CRUD for the bp-writing-tool database (object stores: letter, diary). Rows carry Drive sync metadata (driveFileId, syncedAt, syncError) so the sync layer knows what needs uploading.
ExportDescription
getDocuments(type)List all non-deleted documents of a given type
saveDocumentById(type, doc)Upsert a document; returns the assigned numeric id
softDeleteDocumentById(type, id)Mark a document deleted (keeps row for Drive tombstone)
hardDeleteById(type, id)Permanently remove a row (used for documents never synced)
markSynced(type, id, fields)Record a successful Drive upload; fields is an object with optional driveFileId, syncedAt, syncError, deletedAt keys
listPendingSync(type)Return rows that have not been backed up yet
upsertFromRemote(type, doc)Merge a document pulled from Drive into the local store
getDocumentByUuid(type, uuid)Look up a document by its stable UUID (used during pull/merge)

Google Drive integration

drive-config.js

Path: editor/js/drive-config.jsCompile-time constants for Drive OAuth. No logic — only exports.Key exports: GOOGLE_CLIENT_ID, DRIVE_SCOPE, DRIVE_FOLDER_NAME, DRIVE_API_BASE, DRIVE_UPLOAD_BASE

drive-auth.js

Path: editor/js/drive-auth.jsGoogle Identity Services token client. Caches tokens in the bp-writing-tool-auth IndexedDB for up to 24 hours; silently refreshes when possible.
ExportDescription
connectDrive()Prompt the user to authorise and store the session
disconnectDrive()Revoke the token and clear local session
ensureAccessToken(opts)Return a valid token, refreshing silently or interactively
requestAccessToken()Force an interactive token prompt
isConnected()Whether a Drive session exists in prefs
authHeaders()Return { Authorization: 'Bearer …' } for fetch calls
onAuthChange(fn)Subscribe to connect/disconnect events
invalidateToken()Mark the in-memory token expired

drive-sync.js

Path: editor/js/drive-sync.jsIncremental Drive backup and restore. Documents are stored as JSON files inside the configured Drive folder.
ExportDescription
syncAll()Push pending local changes and pull remote updates
pushPending()Upload only documents not yet backed up
pullAndMerge()Fetch Drive files and merge into IndexedDB
ensureFolder()Create the backup folder if it does not exist
onSyncStatusChange(fn)Subscribe to idle / syncing / error transitions
getSyncState()Return current { state, error }

Typing — transliteration and dictation

translit.js

Path: editor/js/translit.jsFetches Devanagari suggestions from the Google Input Tools API for a Hinglish word. Results are cached in memory for the page session. Upper-case Latin words (acronyms like FIR, IPC) and pure numbers are skipped automatically.Key exports: fetchSuggestions(word), shouldSkipTransliteration(word)

dictation.js

Path: editor/js/dictation.jsWeb Speech API engine. No DOM — emits events through callbacks. Supports on-device and cloud recognition; asks for cloud consent per language before enabling cloud transcription.
ExportDescription
createDictationEngine(callbacks)Create an engine instance with onResult, onStatus, onError callbacks
applyVoiceEdits(text)Replace spoken-punctuation phrases (e.g. “पूर्ण विराम” → )
isDictationSupported()Whether SpeechRecognition is available in this browser
probePackAvailability(lang)Check whether an on-device language pack appears to be installed
hasCloudConsent(lang)Read stored cloud-consent flag for a language
setCloudConsent(lang, bool)Persist cloud-consent choice
LANGSFrozen map { HI: 'hi-IN', EN: 'en-IN' }
DEFAULT_LANG'hi-IN'

dictation-ui.js

Path: editor/js/dictation-ui.jsRenders the dictation floating action button (FAB) and manages its drag-to-reposition behaviour. Hidden on mobile screens.Key exports: initDictation(opts)

punctuation.js

Path: editor/js/punctuation.jsInitialises the draggable Hindi punctuation panel — a floating grid of common Devanagari and English punctuation marks that insert into the focused field on click.Key exports: initPunctuationPanel()

Preferences and utilities

prefs.js

Path: editor/js/prefs.jsThin localStorage wrapper with a bpnt. key prefix. Used by Drive auth, dictation, and any other module that needs to persist small flags across page loads.
ExportDescription
getPref(key, fallback)Read and JSON-parse a preference; returns fallback if absent
setPref(key, value)JSON-stringify and store a value
removePref(key)Delete a stored preference
DICTATION_LANG_KEYConstant — key for the selected dictation language
DICTATION_FAB_POS_KEYConstant — key for the FAB drag position
DICTATION_ONBOARDED_KEYConstant — key for the first-run onboarding flag
cloudConsentKey(lang)Returns the per-language cloud-consent key

utils.js

Path: editor/js/utils.jsShared pure utilities used by multiple modules. Includes getWordBoundaries(text, index), which returns the [start, end] character range of the word under a given cursor position — used by both the transliteration and dictation layers.Key exports: getWordBoundaries()

Build docs developers (and LLMs) love