Getting started with the SDK for Javascript

Cliente Javascript

In the javascript client the content will be load on the client machine. The request load the content that are configured in the params of the request.

Install

For proper operation will be essential load js libraries, together with jquery library and css style sheet provided from S&P.


<link href="/SP_API/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/SP_API/js/sp_api.js"></script>

Then we will tell the API to charge content.

Params

accountID
(string) (required) The user ID provided by S&P

navOptions
(array) (required) Array of values ​​that specify the required language and menu items.

navOptions params
  • ISOlanguage – (string) Language in ISO 639-1.
  • menuItems – (array) title: Title link. url Link relative to baseURL.
  • baseURL – (string) Web address where the links will be pointing.

<script type="text/javascript">
  SP_jsapi.init({
    accountID:'easyvent',
    navOptions:{
      ISOlanguage:'es',
        menuItems:[
        {title: 'Inicio', url:''},
        {title: 'Catálogo', url:'/catalogue'},
        {title: 'Selectores', url:'/selector'},
        {title: 'Proyecto', url:'/project'},
        {title: 'Contacto', url:'/contact'},
        ],
    baseURL: 'http://easyvent.solerpalau.com',
    }
});
</script>

The required containers to be filled by javascript.


<div class="wrapper">
<div id="sp_header">Loading header...</div>

<div id="sp_slider">Loading slider...</div>

<div id="sp_footer">Loading footer...</div>
</div>
Containers

sp_header The id of the div containing the header that will be filled by S&P.
sp_slider The id of the div containing the slider that will be filled by S&P.
sp_footer The id of the div containing the header that will be filled by S&P
sp_tooltipcookie The id of the div containing the tooltip cookie advice that will be filled by S&P
sp_legal The id of the div containing the legal advice that will be filled by S&P

The containers “sp_header”, “sp_slider”, “sp_footer” and “sp_footer” must be presents to be filled by S&P.