daily pastebin goal
83%
SHARE
TWEET

Untitled

a guest Sep 18th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $('.LanguageSelector > ul li a').click(function() {
  2.     var Clicked = $(this).children().first().attr('class');
  3.     var SelectedLanguageUpper = (((Clicked.replace(/flag-icon/g, "")).replace("-", "")).replace(" ", "")).toUpperCase();
  4.     var SelectedLanguageLower = ((Clicked.replace(/flag-icon/g, "")).replace("-", "")).replace(" ", "");
  5. //    $('.LanguageSelector > ul li').show();
  6. //    $(this).parent().hide();
  7.     var obj = LangobjArray.find(function(obj) {
  8.         return obj.flag === SelectedLanguageLower;
  9.     });
  10.  
  11.     Cookies.set('language', obj.lang_code);
  12.     SelectLanguageJSON(obj);
  13.  HideMenuItems();
  14. });
  15.  
  16. function ChangeUrl(langf) {
  17.     var fullUrl = window.location.href;
  18.     var splitFullUrl = fullUrl.split('/');
  19.     splitFullUrl[3] = langf;
  20.     var NewUrl = '';
  21.  
  22.     $.each(splitFullUrl, function(index, value) {
  23.         if (index > 0) {
  24.             NewUrl += '/' + value;
  25.         }
  26.     });
  27.     var cleanedURL = NewUrl.replace(window.location.search + window.location.hash, '');
  28.     NewUrl = getProtocol() + cleanedURL + window.location.search + window.location.hash;
  29.     window.history.replaceState(document.title, document.title, NewUrl);
  30. }
  31.  
  32. function getCurrentLanguage() {
  33.     var fullUrl = window.location.href;
  34.     var splitFullUrl = fullUrl.split('/');
  35.     if (splitFullUrl[3] != '' && splitFullUrl[3].match(/^[a-z]{2,2}$/g)) {
  36.         return splitFullUrl[3];
  37.     }
  38.     // Return default language stored in cookie
  39.     return Cookies('language');
  40. };
  41.  
  42. function SelectLanguageJSON(langObj) {
  43.     //    console.log(getCurrentLanguage());
  44.     var LangOnDisplay = $(".LanguageSelector > a").children().first().attr('class');
  45. //    $(".LanguageSelector > a").children().last().html(langObj.lang_text);
  46.     $(".LanguageSelector > a").children().first().removeClass(LangOnDisplay);
  47.     $(".LanguageSelector > a").children().first().addClass('flag-icon flag-icon-' + langObj.flag);
  48.     $('html').attr('lang', langObj.lang_code);
  49.     $('html').attr('dir', langObj.direction);
  50.  
  51.     if(langObj.direction == 'ltr'){
  52.         $('.ticker').webTicker({
  53.  
  54.         speed: 120,
  55.         duplicate: true,
  56.         direction: 'left',
  57.         startEmpty: false,
  58.         hoverpause:false,
  59.        updatetype: 'update'
  60.     });    
  61.        }else{
  62.        
  63.            $('.ticker').webTicker({
  64.  
  65.         speed: 120,
  66.         duplicate: true,
  67.         direction: 'right',
  68.         startEmpty: false,
  69.         hoverpause:false,
  70.        updatetype: 'update'
  71.     });      
  72.        }
  73.  
  74.     ChangeUrl(langObj.lang_code);
  75.     $('#hsForm_' + $.i18n('email-test')).remove();
  76.     oldICOFormLocale = $.i18n('ico-Form-ID');
  77.     oldInvestFormLocale = $.i18n('invest-formID');
  78.     oldContactFormLocale = $.i18n('Contact-Form-ID');
  79.     oldOTCFormLocale = $.i18n('otc-Form-ID');
  80.     $.i18n().locale = langObj.lang_code;
  81.     $(document).trigger('data-locale-change');
  82.     completeAllRequiredFields = $.i18n('email-test-please-complete-all-required-fields');
  83.     emailMustBeFormattedCorrectly = $.i18n('email-must-be-formatted-correctly');
  84.     CreateEmailKey($.i18n('email-test'), completeAllRequiredFields, emailMustBeFormattedCorrectly);
  85.     $('body').i18n();
  86.     $('#ResultLocale').i18n();
  87. }
  88.  
  89. $('body > nav').ready(function() {
  90.    
  91.  HideMenuItems();
  92.  
  93. });
  94.  
  95.  
  96. function HideMenuItems(){
  97.  
  98.   var LanguageFromUrl = getCurrentLanguage();
  99.  
  100.  var getLangFromArray = LangobjArray.find(function (getLangFromArray) { return getLangFromArray.lang_code === LanguageFromUrl; });
  101.  
  102.   $( ".LanguageSelector > ul li").show();
  103.  
  104.  $( ".LanguageSelector > ul li > a p:contains('" + getLangFromArray.lang_text +"')" ).parent().parent().hide();
  105.  
  106.     switch (LanguageFromUrl) {
  107.     case 'en':
  108.         //Init English Localization
  109.         console.log("Initialized: " + LanguageFromUrl + " language");
  110.         $('[data-item="otc-trading"]').show();
  111.         $('.ctaBox').removeClass('box-russian-fix');  
  112.      
  113.      
  114.         break;
  115.     case 'cn':
  116.         //Init Chinese Localization
  117.         console.log("Initialized: " + LanguageFromUrl + " language");
  118. //        $('[data-item="otc-trading"]').hide();
  119.         $('.ctaBox').removeClass('box-russian-fix');
  120.      
  121.         break;
  122.     case 'ru':
  123.         //Init Portuguese Localization
  124.         console.log("Initialized: " + LanguageFromUrl + " language");
  125.         $('.ctaBox').addClass('box-russian-fix');
  126.        
  127.        
  128.         break;
  129.     case 'vi':
  130.         //Init Russian Localization
  131.         console.log("Initialized: " + LanguageFromUrl + " language");
  132.         $('[data-item="otc-trading"]').show();
  133.         $('.ctaBox').removeClass('box-russian-fix');
  134.        
  135.         break;
  136.     case 'id':
  137.         //Init Spanish Localization
  138.         console.log("Initialized: " + LanguageFromUrl + " language");
  139.         $('[data-item="otc-trading"]').show();
  140.         $('.ctaBox').removeClass('box-russian-fix');
  141.        
  142.         break;
  143.     case 'th':
  144.         //Init Spanish Localization
  145.         console.log("Initialized: " + LanguageFromUrl + " language");
  146.         $('[data-item="otc-trading"]').show();
  147.         $('.ctaBox').removeClass('box-russian-fix');
  148.        
  149.         break;    
  150.     default:
  151.         //Init Default English Localization
  152.         console.log("Initialized: default " + LanguageFromUrl + " language");
  153.         $('[data-item="otc-trading"]').show();
  154.        
  155.        
  156. }
  157. }
  158.  
  159.  
  160. $(document).ready(function() {});
  161.  
  162. var oldICOFormLocale;
  163. var oldInvestFormLocale;
  164. var oldContactFormLocale;
  165. var oldOTCFormLocale;
  166.  
  167. var LangobjArray = [{
  168.         lang_code: 'en',
  169.         lang_text: 'English',
  170.         flag: 'gb',
  171.         direction: 'ltr'
  172.     },
  173.     {
  174.         lang_code: 'cn',
  175.         lang_text: '中文',
  176.         flag: 'cn',
  177.         direction: 'ltr'
  178.     },
  179.     {
  180.         lang_code: 'ru',
  181.         lang_text: 'Русский',
  182.         flag: 'ru',
  183.         direction: 'ltr'
  184.     },
  185.     {
  186.         lang_code: 'vi',
  187.         lang_text: 'Tiếng Việt',
  188.         flag: 'vn',
  189.         direction: 'ltr'
  190.     },
  191.     {
  192.         lang_code: 'pt',
  193.         lang_text: 'Portuguese',
  194.         flag: 'pt',
  195.         direction: 'ltr'
  196.     },
  197.     {
  198.         lang_code: 'id',
  199.         lang_text: 'Indonesia',
  200.         flag: 'id',
  201.         direction: 'ltr'
  202.     },
  203.     {
  204.         lang_code: 'th',
  205.         lang_text: 'ไทย',
  206.         flag: 'th',
  207.         direction: 'ltr'
  208.     },
  209.     {
  210.         lang_code: 'ms',
  211.         lang_text: 'Bahasa Melayu',
  212.         flag: 'my',
  213.         direction: 'ltr'
  214.     },
  215.     {
  216.         lang_code: 'ar',
  217.         lang_text: 'العربية',
  218.         flag: 'sa',
  219.         direction: 'rtl'
  220.     }
  221. ];
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top