SHARE
TWEET

XD Rezora RESTFUL API

Ranga14 Jan 29th, 2015 (edited) 38 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Insert Headers
  2. $(document).ready(function() {
  3.  
  4.     // Grab the Origin Hostname/URL
  5.     var remoteHostName = 'www.xpressdocs.com';
  6.     var scheme_id = '';
  7.  
  8.     $.getJSON('http://' + remoteHostName + '/next/web_services/restful/json_company_prefs.php?' + 'callback=?', function(data) {
  9.  
  10.         // Pull Scheme ID
  11.         scheme_id = data['id_scheme_code'];
  12.         scheme_id_css = scheme_id.toLowerCase();
  13.  
  14.         // Check to see which Company has a different hostname...
  15.         switch (scheme_id) {
  16.             case '243BREADBO':
  17.                 hostName = 'www.marketingrevolution.com';
  18.                 break;
  19.  
  20.             case '154CHOICEH':
  21.                 hostName = 'choicehotels.xdstorefront.com';
  22.                 break;
  23.  
  24.             case '18KELLERWILLIAMSDF47':
  25.                 hostName = 'kellerwilliams.xdstorefront.com';
  26.                 break;
  27.  
  28.             case '293YELLOWB':
  29.                 hostName = 'www.yellowbook360dm.com';
  30.                 break;
  31.  
  32.             default:
  33.                 hostName = remoteHostName;
  34.         }
  35.  
  36.         //Grab style sheet with correct scheme code
  37.         $('head').append('<link rel="stylesheet" type="text/css" href="http://' + remoteHostName + '/next/css/social_hq_styles.css?schemecode=' + scheme_id_css + '">');
  38.  
  39.         // Grab Session ID
  40.         var session_id = data['uuid'];
  41.  
  42.         // Check to see if a Session ID is set then build navigation...
  43.         if (session_id !== null) {
  44.  
  45.             // Utility Nav Markup
  46.             if (data['status_bar_default_text'] == "" || data['status_bar_default_text'] == null || data['status_bar_default_text'] == "undefined") {
  47.                 var $hdrTop = $('<div id="utility_nav" style="background-color: #000"><ul><li><a href="http://' + hostName + '/next/account/index.php?uuid=' + session_id + '">Account</a></li><li><a href="http://' + hostName + '/next/logout.php?uuid=' + session_id + '">Logout</a></li><li><a href="http://' + hostName + '/next/onlineresources.php?uuid=' + session_id + '">Online Resources</a></li><li><a href="http://' + hostName + '/next/support.php?uuid=' + session_id + '">Support</a></li><li class="chat"><div id="lpButDivID-1283357466"></div></li><li id="companySupportPhone"></li></ul></div>');
  48.             } else {
  49.                 var $hdrTop = $('<div id="utility_nav" style="background: ' + data['status_bar_default_text'] + ' url(http://assets.dev54.xpressdocs.com/next_images/css/main/shine.png) left 50% repeat-x"><ul><li><a href="http://' + hostName + '/next/account/index.php?uuid=' + session_id + '">Account</a></li><li><a href="http://' + hostName + '/next/logout.php?uuid=' + session_id + '">Logout</a></li><li><a href="http://' + hostName + '/next/onlineresources.php?uuid=' + session_id + '">Online Resources</a></li><li><a href="http://' + hostName + '/next/support.php?uuid=' + session_id + '">Support</a></li><li class="chat"><div id="lpButDivID-1283357466"></div></li><li id="companySupportPhone"></li></ul></div>');
  50.             }
  51.  
  52.             // Insert Data into Utility Nav (Won't work with Rezora JQuery version)
  53.             //$hdrTop.find("a").attr("href", function(i, href) {
  54.                 //return href + session_id;
  55.             //});
  56.             $hdrTop.find("#companySupportPhone").text(data['company_support_phone']);
  57.             // Create JavaScript Chat Link
  58.             var script = document.createElement("script");
  59.             script.type = "text/javascript";
  60.             script.src = "https://server.iad.liveperson.net/hc/80105492/?cmd=mTagRepstate&site=80105492&buttonID=7&divID=lpButDivID-1283357466&bt=3&c=1";
  61.             $hdrTop.find(".chat").append(script);
  62.  
  63.             // Main Nav Markup
  64.             var $hdrListStatic = $('<ul><li><a href="http://' + hostName + '/next/index.php?uuid=' + session_id + '">Home</a></li><li><a href="http://' + hostName + '/next/categories.php?uuid=' + session_id + '">Print & Direct Mail</a></li>');
  65.  
  66.             // Brand Essentials Tab Check
  67.             if (data['fasttrac_enable_tab'] == "true" || data['fasttrac_enable_tab'] == 1) {
  68.                 var $hdrListBrand = $('<ul><li><a href="http://' + hostName + '/next/index.php?stationery=true&uuid=' + session_id + '">Brand Essentials</a></li>');
  69.             } else {
  70.                 var $hdrListBrand = $('<li style="display: none;"></li>');
  71.             }
  72.  
  73.             // Stationery Tab Check
  74.             if (data['show_seasonal'] == "true" || data['show_seasonal'] == 1) {
  75.                 var $hdrListStationery = $('<ul><li><a href="http://' + hostName + '/next/seasonal.php?uuid=' + session_id + '">Seasonal<!-- &amp; Holiday --></a></li>');
  76.             } else {
  77.                 var $hdrListStationery = $('<li style="display: none;"></li>');
  78.             }
  79.  
  80.             // Promotional Products Tab Check
  81.             if (data['enable_promotional_products'] == "true" || data['enable_promotional_products'] == 1) {
  82.                 var $hdrListPromo = $('<ul><li><a href="http://' + hostName + '/next/promotional_products.php?uuid=' + session_id + '">Promo Products</a></li>');
  83.             } else {
  84.                 var $hdrListPromo = $('<li style="display: none;"></li>');
  85.             }
  86.  
  87.             // E-Mail Active Tab Check
  88.             if (data['email_active'] == "true" || data['email_active'] == 1) {
  89.                 var $hdrListEmail = $('<ul><li><a href="http://jweb.xpressdocs.com/email/dashboard.do?uuid=' + session_id + '">Email</a></li>');
  90.             } else {
  91.                 var $hdrListEmail = $('<li style="display: none;"></li>');
  92.             }
  93.  
  94.             // New E-Mail Active Tab Check
  95.             if (data['email_new_active'] == "true" || data['email_new_active'] == 1) {
  96.                 var $hdrListEmailActive = $('<ul><li><a href="http://' + hostName + '/next/rezora_sso.php?uuid=' + session_id + '">Email Marketing</a></li>');
  97.             } else {
  98.                 var $hdrListEmailActive = $('<li style="display: none;"></li>');
  99.             }
  100.  
  101.             // Social HQ Tab Check
  102.             if (data['enable_socialmadesimple'] == "true" || data['enable_socialmadesimple'] == 1) {
  103.                 var $hdrListSocialHQ = $('<ul><li><a href="http://' + hostName + '/next/marketing_socialhq.php?uuid=' + session_id + '">Social HQ</a></li>');
  104.             } else {
  105.                 var $hdrListSocialHQ = $('<li style="display: none;"></li>');
  106.             }
  107.  
  108.             // Calendar Tab Check
  109.             if (data['calendar'] == "true" || data['calendar'] == 1) {
  110.                 var $hdrListCalendar = $('<ul><li><a href="http://' + hostName + '/next/calendar.php?uuid=' + session_id + '">Calendar</a></li>');
  111.             } else {
  112.                 var $hdrListCalendar = $('<li style="display: none;"></li>');
  113.             }
  114.  
  115.             // Follow Up Tab Check
  116.             if (data['enable_xpress_connection_program'] == "true" || data['enable_xpress_connection_program'] == 1) {
  117.                 var $hdrListFollowUp = $('<ul><li><a href="http://' + hostName + '/next/xpressconnection/index.php?uuid=' + session_id + '">Follow Up</a></li>');
  118.             } else {
  119.                 var $hdrListFollowUp = $('<li style="display: none;"></li>');
  120.             }
  121.  
  122.             // Build HTML for Main Header Navigation
  123.             var $hdrHTML = $hdrListStatic.html() + '' + $hdrListBrand.html() + '' + $hdrListStationery.html() + '' + $hdrListPromo.html() + '' + $hdrListEmail.html() + '' + $hdrListEmailActive.html() + '' + $hdrListSocialHQ.html() + '' + $hdrListCalendar.html() + '' + $hdrListFollowUp.html();
  124.  
  125.             var $logoStyle = 'url(http://assets.xpressdocs.com/next_images/company/' + scheme_id_css + '/logocell.gif)';
  126.             //var $headerStyle = '' + data['status_bar_default_text'] + ' url(http://assets.xpressdocs.com/next_images/company/' + data['id_scheme_code'] + '/logocell_back.gif) repeat-x 0 34px';
  127.  
  128.             // Output Main Header Navigation
  129.             $('#header').prepend( '<div class="wrapWS"><div id="logo" style="background-image: '+ $logoStyle +'"></div><div id="topnav"><ul>' + $hdrHTML + '</ul></div></div></div>');
  130.  
  131.             // Insert before Main Header
  132.             $('body').prepend($hdrTop);
  133.  
  134.             // Overwrite Utility Holder Styles
  135.             $('#header .wrapper').css({'clear' : 'both' , 'width' : 'auto'});
  136.             $('#utility-holder').css({'margin' : '0 auto' , 'width' : '950px' , 'float' : 'none'});
  137.             $('#utility').css('margin', '7px 0 0');
  138.             $('#welcome-admin, #welcome').css({'margin' : '29px 5px 3px 0' , 'font-size' : '12px' , 'line-height' : '12px'});
  139.  
  140.         // Output Header if there is no registered user (no session)...
  141.         } else {
  142.  
  143.             var reBack = 'http://' + hostName + '/next/logout.php?action=logout';
  144.  
  145.             // Redirect them back to XD login page...
  146.             window.location = reBack;
  147.  
  148.         }
  149.  
  150.     });
  151.  
  152. });// JavaScript Document
RAW Paste Data
Want to get better at JavaScript?
Learn to code JavaScript in 2017
Top