The code opens a web page in a new tab or window using the TS.screen
function, with customizable parameters such as zoom level, width, and cropping height. The specific URL being opened is 'act.com/nl-nl/producten/act-premium'.
$TS.screen('act.com/nl-nl/producten/act-premium', {zoom: .5, width: 680, 'crop-h': 400});
// constants
const DEFAULT_ZOOM = 0.5;
const DEFAULT_WIDTH = 680;
const DEFAULT_HEIGHT = 400;
// interface for the parameters
interface BrowserWindowOptions {
zoom?: number;
width?: number;
height?: number;
}
// function to open the browser window
function openBrowserWindow(url: string, options: BrowserWindowOptions = {}): void {
// merge default options with provided options
const mergedOptions = { zoom: DEFAULT_ZOOM, width: DEFAULT_WIDTH, height: DEFAULT_HEIGHT,...options };
// validate options
if (mergedOptions.zoom < 0 || mergedOptions.zoom > 1) {
throw new Error('Zoom must be between 0 and 1');
}
if (mergedOptions.width <= 0) {
throw new Error('Width must be a positive number');
}
if (mergedOptions.height <= 0) {
throw new Error('Height must be a positive number');
}
// open the browser window
TS.screen(url, {
zoom: mergedOptions.zoom,
width: mergedOptions.width,
'crop-h': mergedOptions.height,
});
}
// example usage
openBrowserWindow('act.com/nl-nl/producten/act-premium');
The code opens a web page in a new tab or window using the TS.screen
function.
$TS.screen
: The function used to open the web page.'act.com/nl-nl/producten/act-premium'
: The URL of the web page to be opened.Object {zoom:.5, width: 680, 'crop-h': 400}
: An object containing the following parameters for customizing the web page:
zoom:.5
: The zoom level of the page (50% in this case).width: 680
: The width of the page (680 pixels in this case).'crop-h': 400
: The height of the page to be cropped to (400 pixels in this case).