Skip to content

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:

PropertyDescriptionDocs
SocketClientThe Socket IO Client, packaged for use in browserSocket IO Client Docs
countriesA list of all countries supported by PandaTSCountries Constant Docs
findCountryByAlpha2Find a PandaTS country by the alpha2 valuefindCountryByAlpha2 Docs
findCountryByAlpha3Find a PandaTS country by the alpha3 valuefindCountryByAlpha3 Docs
findCountryByIdFind a PandaTS country by the country idfindCountryById Docs
findCountryByNameFind a PandaTS country by the name in the systemfindCountryByName Docs
languagesA list of all languages supported by PandaTSLanguages Constant Docs
findLanguageByEnglishNameFind a PandaTS language by the name in the systemfindLanguageByEnglishName Docs
findLanguageByLocalNameFind a PandaTS language by the localized name (name of the language in the language)findLanguageByLocalName Docs
findLanguageByIso2Find a PandaTS language by the iso2 valuefindLanguageByIso2 Docs
findLanguageByIso3Find a PandaTS language by the iso3 valuefindlanguagebyiso3 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()