Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function (whl, $) {
- whl.readCookie = function (name) {
- var nameEQ = name + "=";
- var ca = document.cookie.split(';');
- for (var i = 0; i < ca.length; i++) {
- var c = ca[i];
- c = c.trim();
- if (c.indexOf(nameEQ) === 0)
- return c.substring(nameEQ.length, c.length);
- }
- return null;
- };
- // STATUS
- whl.status = function (callback) {
- this.status_callback = callback;
- var userId = this.readCookie('userID');
- if (!!userId) {
- var that = this;
- $.ajax({
- type: 'POST',
- url: 'WebsiteService?',
- dataType: "json",
- contentType: "application/json; charset=utf-8",
- //crossDomain: true,
- //dataType: "jsonp",
- //jsonp: false,
- //jsonpCallback: 'jsoncb',
- data: JSON.stringify({
- "req": "isSessionActive",
- "userID": userId
- }),
- success: function (data) {
- that.statusCallback(data);
- },
- failure: function (err) {
- console.log('failure refresh', err);
- }
- });
- }
- };
- whl.statusCallback = function (data) {
- if (this.status_callback) {
- var result = {};
- result.uid = 'uid';
- result.token = 'token';
- result.status = data.StatusCode === 10 ? 'real' : 'anon';
- this.status_callback(result);
- }
- };
- // REFRESH
- whl.refreshSession = function (callback) {
- this.refresh_callback = callback;
- var userId = this.readCookie('userID');
- if (!!userId) {
- var that = this;
- $.ajax({
- type: 'POST',
- url: 'WebsiteService?',
- dataType: "json",
- contentType: "application/json; charset=utf-8",
- //crossDomain: true,
- //dataType: "jsonp",
- //jsonp: false,
- //jsonpCallback: 'jsoncb',
- data: JSON.stringify({
- "req": "isSessionActive",
- "userID": userId
- }),
- success: function (data) {
- console.log('success refresh', data);
- that.refreshToken(data);
- },
- failure: function (err) {
- console.log('failure refresh', err);
- }
- });
- }
- };
- whl.refreshCallback = function (data) {
- if (this.refresh_callback) {
- var result = {};
- if (!!data && data.StatusCode === 10) {
- result.status = "success";
- } else {
- result.status = "failure";
- }
- this.refresh_callback(result);
- }
- };
- whl.setDeviceTypeAndOrientation = function (deviceDetails) {
- console.log("device details", deviceDetails);
- };
- whl.ChangeDeviceTypeandOrientation = function (deviceDetails) {
- console.log("change device details", deviceDetails);
- };
- })(window.whl = window.whl || {}, jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement