# SPS Widget

This is a brief description of your project.

## Environment URLs

- **Production URL**: [https://balikomat.sps-sro.sk/widget/v1](https://balikomat.sps-sro.sk/widget/v1)
- **Development URL**: [https://balikomat.sps-sro.sk/widget-test/v1](https://balikomat.sps-sro.sk/widget-test/v1)

## How to install widget

To integrate the widget into your webpage, follow these steps:

### Development Version

For local development, include the following script in your HTML:

```html
<script src="./initialize.js" type="text/javascript" defer></script>

<button onclick="window.initializeWidget(data);">Show map</button>
```

### Production Version

For deploying the widget in a production environment, use this script tag:

```html
<script
  src="https://balikomat.sps-sro.sk/widget/v1/initialize.js"
  type="text/javascript"
  defer></script>
```

### Test Version

For testing purposes, integrate the widget using the test script:

```html
<script
  src="https://balikomat.sps-sro.sk/widget-test/v1/initialize.test.js"
  type="text/javascript"
  defer></script>
```

Define the data object in your script. This object specifies the initial configuration for the widget. You can customize this object as needed. For example:

```javascript
const data = {
  country: 'CZ', // CZ; SK; CZ,SK
  type: 'PT', // PT, PS, null = all
  address: null, // zoom map to this address
  pp_id: null, // by address select PP with detail
  select_pp_by_address: null, // by address select PP with detail
  center: null, // filter center
  embedded_id: null, // osmMap id  -> widget will embed to this element
  losBuild: null, // if true LOS PP
};

window.initializeWidget(data);
```

### Localhost PHP changes

localhost you need to uncomment this line in get-pp-data.php and get-pp-detail.php

```php
// localhost
 $dataPath = $losBuild === true ? "../../test/v2/parsed/alternativneMiesta_" : "../../test/parsed/alternativneMiesta_";

```

### Production PHP changes

production you need to uncomment this line in get-pp-data.php and get-pp-detail.php

```php
// production
$dataPath = $losBuild === true ? "../../../../v2/parsed/alternativneMiesta_" : "../../../../parsed/alternativneMiesta_";

```

## Prerequisites

Before you begin, ensure you have met the following requirements:

- You have installed the latest version of PHP. For Windows, you can download it from the [PHP for Windows download page](https://windows.php.net/download/).

## Installing and Using PHP Server

To install PHP Server, follow these steps:

1. Open Visual Studio Code.
2. Go to the Extensions view (Icon on the side bar).
3. Search for "PHP Server".
4. Click on the first result which is "PHP Server" by brapifra.
5. Click on the Install button.

After installing, you can use PHP Server to run your PHP files. For more information on how to use the extension, you can check out the [PHP Server page](https://marketplace.visualstudio.com/items?itemName=brapifra.phpserver) on the Visual Studio Code marketplace.

For configuring PHP Server in Visual Studio Code, you need to add the following properties to your `settings.json` file:

```json
{
  "phpserver.phpPath": "C:\\path\\to-your\\php-exe\\php.exe",
  "phpserver.port": 5500
}
```

## Local Development and Testing

There are multiple ways of running the PHP server in Visual Studio Code:

1. Use the Command Palette: Press `CTRL + SHIFT + P` to open the Command Palette, then search for the "PHP Server: Serve Project" command and select it.
2. Use the editor button: Click on the PHP Server button (it looks like an elephant) in the top-right corner of the editor.
3. Use the context menu: Right-click in the editor when a `.php` or `.html` file is open, then select "PHP Server: Serve Project" from the context menu.
