SF.CORE
** This class will not be supported in 2015.
All functionalities of sf.core class are more improved, integrating with CAPH. Therefore sf.core class is not supported since 2015 Smart TV. To use functions of sf.core class, refer to here.
This class defines the Apps Framework basic functions.
Add the following line for sf.core class into a html file your own : <script type="text/javascript" src="$MANAGER_WIDGET/Common/af/2.0.0/loader.js"></script> |
You can declare sf.core class like this : ex) var core = sf.core; |
Contents
Methods
exit | ||
Description | ||
This function terminates the application. | ||
Parameters | ■bEsc - Boolean - Indicates whether to return to TV Screen. | |
Return | ■Void | |
Emulator Support | N | |
SDK Constraint | None | |
Example | ||
handleKeyDown = function (keyCode) { if (keyCode == sf.key.GREEN) { // When green key is pressed, returns to Smart Hub. sf.core.exit(false); } } |
getAppConf | ||
Description | ||
This function gets app information from config.xml file. | ||
Parameters | ■key - String - Key string to get. The config.xml's tag name. | |
Return | ■String - Value of the key | |
Emulator Support | N | |
SDK Constraint | None | |
Example | ||
var width = sf.core.getAppConf('width'); |
getEnvValue | ||
Description | ||
This function gets the TV environment values passed to this application by the GET URL parameter. The Application Manager (Smart Hub) passes the environmental parameters via GET REST parameter (for example, index.html?country=us&lang=en&....). This function parses the parameter from the Application Manager and returns it. | ||
Parameters | ■key - String - The key of the requested value (country, lang, id, pw) | |
Return | ■String - The key value | |
Emulator Support | N | |
SDK Constraint | None | |
Example | ||
// returns current language setting var lang = sf.core.getEnvValue('lang'); |
loadCSS | ||
Description | ||
This function includes the specified CSS files. | ||
Parameters | ■files - Array or String - The CSS file paths | |
Return | ■Void | |
Emulator Support | N | |
SDK Constraint | None | |
Example | ||
sf.core.loadCSS('stylesheets/style.css', function () { // CSS file is loaded }); |
loadJS | ||
Description | ||
This function includes the specified JavaScript files. | ||
Parameters | ■files - Array or String - Javascript file paths ■callback - Function - Called when including the files are completed | |
Return | ■Void | |
Emulator Support | N | |
SDK Constraint | None | |
Example | ||
sf.core.loadJS('app/main.js', function () { // JS file is loaded }); |
localData | ||
Description | ||
This function saves values to the local flash memory and gets the saved data. | ||
Parameters | ■key - String - The name of the config ■value (Optional) - Any types - If this is defined, set this as the value of the key | |
Return | ■Void | |
Emulator Support | N | |
SDK Constraint | None | |
Example | ||
sf.core.localData('myconfig', true); var config = sf.core.localData('myconfig'); // returns true |
mapAliasedKeys | ||
Description | ||
This function converts key code to aliased key code. Some keys have to be aliased. For example, PANEL_VOL_UP and PANEL_VOL_DOWN should work in the same way as RIGHT/LEFT in the Samsung TV specification. If the Scene based architecture is used, this need not be considered. Use the keycode passed to the handleKeyDown method. | ||
Parameters | ■keyCode - Number - The key code entered by user | |
Return | ■Number - Aliased key code. If the key code is not aliased, the keycode parameter returns as it is. | |
Emulator Support | N | |
SDK Constraint | None | |
Example | ||
var key = sf.core.mapAliasedKeys(sf.key.WHEELDOWN); // returns sf.key.LEFT |
plugin | ||
Description | ||
This function gets the TV device plugin object. | ||
Parameters | ■name - String - The name of the requested plugin (TV, TVMW, NNAVI, AUDIO, APPCOMMON, FRONTPANEL, IMAGEVIEWER, PLAYER, and so on) | |
Return | ■Object - The device plugin object | |
Emulator Support | N | |
SDK Constraint | None | |
Example | ||
var pluginNNAVI = sf.core.plugin('NNAVI'); pluginNNAVI.GetDeviceID(); |
readFile | ||
Description | ||
This function reads the file contents and returns a string. | ||
Parameters | ■path - String - The file path to read | |
Return | ■String - The file contents | |
Emulator Support | N | |
SDK Constraint | None | |
Example | ||
var json = sf.core.readFile('app.json'); var appobj = JSON.parse(json); |
sefplugin | ||
Description | ||
This function gets the TV device SEF plugin object. | ||
Parameters | ■name - String - The name of requested plugin (TV, TVMW, NNAVI, AUDIO, APPCOMMON, FRONTPANEL, IMAGEVIEWER, PLAYER, and so on) | |
Return | ■Object - The device plugin object | |
Emulator Support | N | |
SDK Constraint | None | |
Example | ||
var pluginNNAVI = sf.core.sefplugin('NNAVI'); pluginNNAVI.Execute('GetDeviceID'); |
version | ||
Description | ||
This function returns the Apps Framework version. | ||
Parameters | none | |
Return | ■String - Apps Framework version. * (e.g) 1.1.0 | |
Emulator Support | N | |
SDK Constraint | None | |
Example | ||
console.log(sf.core.version); // prints 2.0.X |