Getting Started with the PandaTS Javascript SDK Browser Bundle
Installation
Download the browser.js script and host it. Then include the script in your website's head as close to the end of the </head> as possible.
TIP
Right click on the link above and choose "Save As" to save the file quickly
html
<!doctype html>
<html lang="en">
<head>
...
<script src="path/to/browser.js" type="text/javascript"></script>
</head>
<body>
...
</body>
</html>Usage
Once loaded, a global variable will be exposed as PandaTS (or window.PandaTS) which has the following properties:
| Property | Description | Docs |
|---|---|---|
SocketClient | The Socket IO Client, packaged for use in browser | Socket IO Client Docs |
countries | A list of all countries supported by PandaTS | Countries Constant Docs |
findCountryByAlpha2 | Find a PandaTS country by the alpha2 value | findCountryByAlpha2 Docs |
findCountryByAlpha3 | Find a PandaTS country by the alpha3 value | findCountryByAlpha3 Docs |
findCountryById | Find a PandaTS country by the country id | findCountryById Docs |
findCountryByName | Find a PandaTS country by the name in the system | findCountryByName Docs |
languages | A list of all languages supported by PandaTS | Languages Constant Docs |
findLanguageByEnglishName | Find a PandaTS language by the name in the system | findLanguageByEnglishName Docs |
findLanguageByLocalName | Find a PandaTS language by the localized name (name of the language in the language) | findLanguageByLocalName Docs |
findLanguageByIso2 | Find a PandaTS language by the iso2 value | findLanguageByIso2 Docs |
findLanguageByIso3 | Find a PandaTS language by the iso3 value | findlanguagebyiso3 Docs |
Example Usage
The following example code can be used to show the time according to the Panda TS server:
javascript
const client = new PandaTS.SocketClient('panda-fx')
const element = document.getElementById('div-for-server-time')
client.on('time', (datetime) => {
element.innerHTML = datetime.toSQL()
})
client.connect()