diff --git a/Message/Request/BrowserType.enum.js b/Message/Request/BrowserType.enum.js new file mode 100644 index 0000000..68e58fe --- /dev/null +++ b/Message/Request/BrowserType.enum.js @@ -0,0 +1,21 @@ +/** + * Request data enum. + * + * @author OMS Development Team + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 * @since 1.0.0 + */ +(function (jsOMS, undefined) +{ + jsOMS.EnumBrowserType = Object.freeze({ + OPERA: 'opera', + FIREFOX: 'firefox', + SAFARI: 'safari', + IE: 'msie', + EDGE: 'edge', + CHROME: 'chrome', + BLINK: 'blink', + }); +}(window.jsOMS = window.jsOMS || {})); diff --git a/Message/Request/OSType.enum.js b/Message/Request/OSType.enum.js new file mode 100644 index 0000000..8f33a69 --- /dev/null +++ b/Message/Request/OSType.enum.js @@ -0,0 +1,37 @@ +/** + * Request data enum. + * + * @author OMS Development Team + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 * @since 1.0.0 + */ +(function (jsOMS, undefined) +{ + jsOMS.EnumOSType = Object.freeze({ + WINDOWS_81: 'windows nt 6.3'; /* Windows 8.1 */ + WINDOWS_8: 'windows nt 6.2'; /* Windows 8 */ + WINDOWS_7: 'windows nt 6.1'; /* Windows 7 */ + WINDOWS_VISTA: 'windows nt 6.0'; /* Windows Vista */ + WINDOWS_SERVER: 'windows nt 5.2'; /* Windows Server 2003/XP x64 */ + WINDOWS_XP: 'windows nt 5.1'; /* Windows XP */ + WINDOWS_XP_2: 'windows xp'; /* Windows XP */ + WINDOWS_2000: 'windows nt 5.0'; /* Windows 2000 */ + WINDOWS_ME: 'windows me'; /* Windows ME */ + WINDOWS_98: 'win98'; /* Windows 98 */ + WINDOWS_95: 'win95'; /* Windows 95 */ + WINDOWS_311: 'win16'; /* Windows 3.11 */ + MAC_OS_X: 'macintosh'; /* Mac OS X */ + MAC_OS_X_2: 'mac os x'; /* Mac OS X */ + MAC_OS_9: 'mac_powerpc'; /* Mac OS 9 */ + LINUX : 'linux'; /* Linux */ + UBUNTU: 'ubuntu'; /* Ubuntu */ + IPHONE: 'iphone'; /* IPhone */ + IPOD: 'ipod'; /* IPod */ + IPAD: 'ipad'; /* IPad */ + ANDROID: 'android'; /* Android */ + BLACKBERRY: 'blackberry'; /* Blackberry */ + MOBILE: 'webos'; /* Mobile */ + }); +}(window.jsOMS = window.jsOMS || {})); diff --git a/Message/Request/Request.js b/Message/Request/Request.js index 750e0bb..fb706a9 100644 --- a/Message/Request/Request.js +++ b/Message/Request/Request.js @@ -22,7 +22,7 @@ this.method = typeof method !== 'undefined' ? method : jsOMS.EnumRequestMethod.GET; this.requestHeader = []; this.success = null; - this.type = typeof type !== 'undefined' ? type : 'json'; + this.type = typeof type !== 'undefined' ? type : jsOMS.EnumResponseType.JSON; this.data = {}; @@ -30,6 +30,34 @@ this.xhr = new XMLHttpRequest(); }; + jsOMS.Request.getBrowser = function() + { + if((!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0) { + return jsOMS.EnumBrowser.OPERA; + } else if(typeof InstallTrigger !== 'undefined') { + return jsOMS.EnumBrowser.FIREFOX; + } else if(Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0) { + return return jsOMS.EnumBrowser.SAFARI; + } else if(/*@cc_on!@*/false || !!document.documentMode) { + return jsOMS.EnumBrowser.IE; + } else if(!isIE && !!window.StyleMedia) { + return jsOMS.EnumBrowser.EDGE; + } else if(!!window.chrome && !!window.chrome.webstore) { + return jsOMS.EnumBrowser.CHROME; + } else if((isChrome || isOpera) && !!window.CSS) { + return jsOMS.EnumBrowser.BLINK; + } + }; + + jsOMS.Request.getOS = function() + { + for(let os in jsOMS.EnumOSType) { + if(navigator.appversion.indexOf(jsOMS.EnumOSType[os]) !== -1) { + return jsOMS.EnumOSType[os]; + } + } + }; + /** * Set request method. *