Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>Opti SnippetsNew to Visual Studio Code? Get it now.
Opti Snippets

Opti Snippets

Dave Bennett

|
48 installs
| (0) | Free
Snippets for the Optimisation team
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

OptiSnippets

Repo for VSCode snippets

gbl

declare global {
	interface Window {
		store?: any;
		utag?: any;
		dataLayer?: any;
		packageSearchPanelStore?: any;
	}
}

ifee

(() => {
	"use strict";

})();

ifeeint

(() => {
	"use strict";
	const myInterval = setInterval(() => {
	const myElement = document.querySelector<HTMLElement>('selector');
		if (myElement) {
			clearInterval(myInterval);

	}
	}, 300);

	setTimeout(function() {
		if(myInterval) {
			clearInterval(myInterval)
		}
	}, 15000)
})();

ifeenr

(() => {
	'use strict';
	const lang = getLanguage();
	const trackingNo = lang == 'uk' ? 6 : 37;
	const myInterval = setInterval(() => {
		const myElement = document.querySelector<HTMLElement>('selector');
		if (myElement && window?.utag?.link) {
			clearInterval(myInterval);
		}
	}, 300);

	setTimeout(function () {
		if (myInterval) {
			clearInterval(myInterval);
		}
	}, 15000);

	const tracking = (text: string): void => {
		window.utag.link(
			{
				eventAction: 'Optimisation Event',
				eventCategory: 'Optimisation',
				eventName: `[ticket] ${text}`,
				event: 'tiq.on',
			},
			'',
			[trackingNo]
		);
	};

	function getLanguage(): string {
		return window.location.hostname.match(/(uk|se|fi|no|dk)/i)[1];
	};
})();

utag

window.utag.link(
    {
        eventAction: "Optimisation Event",
        eventCategory: "Optimisation",
        eventName: "",
        event: "tiq.on",
    },
    "",
    []
);

stg

window.store.getState()

std

window.store.dispatch({

})

sts

window.store.subscribe(() => {

})

pstg

window.packageSearchPanelStore.getState()

pstd

window.packageSearchPanelStore.dispatch({

})

psts

window.packageSearchPanelStore.subscribe(function() {

})

getlang

const getLanguage = (): string => {
	return window.location.hostname.match(/(uk|se|fi|no|dk)/i)[1];
}

debounce

const debounce = (func: Function, wait = 300, immediate = false) => {
	var timeout;
	return function () {
		var context = this,
		args = arguments;
		var later = function () {
			timeout = null;
			if (!immediate) func.apply(context, args);
		};
		var callNow = immediate && !timeout;
		clearTimeout(timeout);
		timeout = setTimeout(later, wait);
		if (callNow) func.apply(context, args);
	};
}

tracking

const tracking = (text: string): void => {
	window.utag.link(
		{
			eventAction: 'Optimisation Event',
			eventCategory: 'Optimisation',
			eventName: `[ticket] ${text}`,
			event: 'tiq.on',
		},
		'',
		[]
	);
};
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft