Specifies the current operating system.
lt.LTOS = {unknown: 0,windows: 1,mac: 2,iOS: 3,android: 4,linux: 5,blackberry: 6,webOS: 7,windows7: 8,windows8: 9,windows10: 10}
|
0 |
Unknown |
(0)Unknown operating system. |
|
1 |
Windows |
(1)Generic Microsoft Windows. |
|
2 |
Mac |
(2)Apple Mac OS X. |
|
3 |
iOS |
(3)Apple iOS. |
|
4 |
Android |
(4)Android |
|
5 |
Linux |
(5)Linux |
|
6 |
Blackberry |
(6)Blackberry OS. |
|
7 |
WebOS |
(7)Web OS. |
|
8 |
Windows7 |
(8)Microsoft Windows 7 |
|
9 |
Windows8 |
(9)Microsoft Windows 8 |
|
10 |
Windows10 |
(10)Microsoft Windows 10 |
export class LTHelperExample {constructor() {lt.RasterSupport.setLicenseUri("https://demo.leadtools.com/licenses/js/LEADTOOLSEVAL.txt", "EVAL", null);}public run = (buttonId: string, outputId: string) => {const button = document.getElementById(buttonId);button.onclick = () => {const lines: string[] = this.getInfo();// Logconsole.log(lines);// Create a table from the infoconst table = document.getElementById(outputId);lines.forEach((line) => {const row = document.createElement("tr");// [0] is nameconst name = document.createElement("th");name.innerHTML = line[0];// [1] is contentconst content = document.createElement("td");content.innerHTML = line[1];row.appendChild(name);row.appendChild(content);//output.appendChild(row);table.appendChild(row);});}}public getInfo = (): string[] => {// This will hold tuples like ["OS", "Windows"]let lines = [];// Show the Operating Systemconst osMap = {};osMap[lt.LTOS.unknown] = "Unknown";osMap[lt.LTOS.windows] = "Windows";osMap[lt.LTOS.mac] = "Mac OS";osMap[lt.LTOS.iOS] = "iOS";osMap[lt.LTOS.android] = "Android";osMap[lt.LTOS.linux] = "Linux";osMap[lt.LTOS.blackberry] = "Blackberry";osMap[lt.LTOS.webOS] = "Web OS";osMap[lt.LTOS.windows7] = "Windows 7";osMap[lt.LTOS.windows8] = "Windows 8";osMap[lt.LTOS.windows10] = "Windows 10";const os = osMap[lt.LTHelper.OS];lines.push(["OS", os]);// Show the Deviceconst deviceMap = {};deviceMap[lt.LTDevice.unknown] = "Unknown";deviceMap[lt.LTDevice.desktop] = "Desktop";deviceMap[lt.LTDevice.mobile] = "Mobile";deviceMap[lt.LTDevice.tablet] = "Tablet";const device = deviceMap[lt.LTHelper.device];lines.push(["Device", device]);// Show the Browserconst browserMap = {};browserMap[lt.LTBrowser.unknown] = "Unknown";browserMap[lt.LTBrowser.internetExplorer] = "Internet Explorer";browserMap[lt.LTBrowser.firefox] = "Firefox";browserMap[lt.LTBrowser.chrome] = "Chrome";browserMap[lt.LTBrowser.safari] = "Safari";browserMap[lt.LTBrowser.opera] = "Opera";browserMap[lt.LTBrowser.android] = "Android Browser";browserMap[lt.LTBrowser.edge] = "Edge";const browser = browserMap[lt.LTHelper.browser];lines.push(["Browser", browser]);// Show version and vendorlines.push(["Browser Version", lt.LTHelper.version]);lines.push(["Browser Vendor", lt.LTHelper.vendor]);// Show the "Supports" capabilities by getting keys// and looking at properties that start with "supports"// (Can also directly access as shown above with version and vendor)const keys: string[] = Object.keys(lt.LTHelper);const supportsKeyword: string = "supports";keys.forEach((key) => {const supportsIndex = key.indexOf(supportsKeyword);if (supportsIndex === 0) {// Starts with "supports", get the valueconst name: string = key.substr(supportsKeyword.length);const isSupported: boolean = lt.LTHelper[key];lines.push(["Supports " + name, isSupported]);}});return lines;}}