Skip to main content

So there have been a few posts regarding JavaScript libraries but it never seems like they are conclusive.
I have tried to use a few external JavaScript libraries but they never work, even with CrossSite Scripting turned off (in K2 Five since anything before that does not have that option). My latest attempt is trying to utilize a javascript library called SpaceTime that allows conversion of time to different timezones.
I have attached a really small script for converting the current time to Eastern Time, and the script works if you open it in a browser, and it works anywhere else javascript is interpreted, but if I stick it in a Data Label and set it to Literal, it does not work.

I have also tried to use other external JavaScript libraries before, such as the Google Charts library, Charts.js, and others, but they never work. Am i misusing it somehow or is it just not supported?

You can try downloading the javascript, and place it on the server that is hosting your K2 SmartForms Runtime. Place the js file in <K2 install dir>/K2 SmartForms Runtime/Styles/Themes, then in your <script> src, change it to "="/Runtime/Styles/Themes/spacetime.js".


 


To check if the js file has been loaded, use Chrome, press F12, go to Network tab, start recording, and refresh your form. Once the form is loaded, check the network trace is spacetime.js has been loaded. Check my attachment.


 



Not sure your end goal, but SmartForms controls that are DateTime aware automatically adjust the displayed value for the time zone of the user looking at the page.


My end goal was to have the user select the time and date on a calendar control and then to simuntaneously display other relevant time zones in a different control, such as pictured below.

 

 

 

The reason for doing something like this is because it's a product to schedule event sessions, and there is about 4 different US States involved, so it can become confusing real quick dealing with scheduling things in other timezones

I managed to make it happen but without the use of the SpaceTime JS Library, I ended  up using the native Date().toLocaleString() which I was not aware of.


Reply