Advertisement
Guest User

Untitled

a guest
Mar 12th, 2019
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. "use strict";
  2.  
  3. $(document).on("ready", function(){
  4.      
  5.     /*LAYOUT CONTENT SCRIPT*/
  6.     var body_1= $('body');
  7.    
  8.    
  9.    
  10.     if( body_1.hasClass("scroll_header") === true){
  11.        $(window).on("scroll", function(){
  12.             if ($(document).scrollTop() >= 250) {
  13.                 body_1.addClass("active_scroll");
  14.             }else{
  15.                 body_1.removeClass("active_scroll");
  16.             }
  17.         });
  18.     }
  19.    
  20.     $(window).on("load", function(){
  21.  
  22.         /* url  navigation active */
  23.         var url = window.location;        
  24.         function menuitems(){            
  25.             if(body_1.hasClass('horizontal-menu') === false){
  26.                 var element = $('.sidebar-left #side-menu li a').filter(function() {
  27.                     return this.href == url;
  28.                 }).addClass('active').parent("li").addClass('active').closest('.nav').addClass('in').slideDown().prev().addClass('show').closest('.nav').slideDown().addClass('in').prev().addClass('show');
  29.  
  30.                 $('.sidebar-left .nav li a').on('click', function(){
  31.                     if( $(this).hasClass('menudropdown')=== true){
  32.                         $(this).toggleClass("show").next().slideToggle().parent().addClass("in");
  33.                     }
  34.                 });                
  35.             }else {
  36.                 if( $(window).width() >=1020){
  37.                     var element = $('.sidebar-left #side-menu li a').filter(function() {
  38.                         return this.href == url;
  39.                     }).addClass('active').parent("li").addClass('active').closest('.nav').addClass('in').prev().addClass('show').closest('.nav').slideDown().addClass('in').prev().addClass('show');
  40.  
  41.                    
  42.                      // Horizontal menu mouse over effect with click
  43.                    
  44.                     $('.sidebar-left > .nav > li').on('click', function(){    // If you required on hover please checkge 'click' to 'mouseover'
  45.                         if( $(this).find('a:first-of-type').hasClass('menudropdown')==true){
  46.                             $(this).find('a:first-of-type').addClass("show").next().slideDown().parent().addClass("in");
  47.                         }
  48.                     });
  49.                     $('.sidebar-left > .nav > li ').on('mouseleave', function(){
  50.                         if( $(this).find('a:first-of-type').hasClass('menudropdown')==true){
  51.                             $(this).find('a:first-of-type').removeClass("show").next().slideUp().parent().removeClass("in");
  52.                         }
  53.                     });                
  54.                 }
  55.                 else{
  56.                     var element = $('.sidebar-left #side-menu li a').filter(function() {
  57.                         return this.href == url;
  58.                     }).addClass('active').parent("li").addClass('active').closest('.nav').addClass('in').slideDown().prev().addClass('show').closest('.nav').slideDown().addClass('in').prev().addClass('show');
  59.  
  60.                     $('.sidebar-left .nav li a').on('click', function(){
  61.                         if( $(this).hasClass('menudropdown')===true){
  62.                             $(this).toggleClass("show").next().slideToggle().parent().addClass("in");
  63.                         }
  64.                     });              
  65.                 }              
  66.             }
  67.         }
  68.        menuitems();
  69.        
  70.        
  71.         /*Full screen result container show*/
  72.         $('#search_header').on('focus', function(){
  73.             $(".search-block").show();  
  74.             body_1.addClass('searchshow');$('#search_header').focusout();
  75.            
  76.         });
  77.        
  78.         /* Search window screen fullscreen open */
  79.         $('.search-block .close-btn').on('click', function(){
  80.             $(".search-block").slideUp();  
  81.              body_1.removeClass('searchshow');
  82.         });
  83.        
  84.         /* on keypress hide search block which was in fullscreen */
  85.         $(document).keyup(function(e) {
  86.             if (e.keyCode == 27) { // escape key maps to keycode `27`
  87.                 $(".search-block").fadeOut();  
  88.                 body_1.removeClass('searchshow');
  89.                  $('#search_header').focusout();
  90.             }
  91.         });
  92.        
  93.         /* inbox mail page  collapsible */
  94.         $(".inboxmenu").on("click", function(){
  95.             $(".mailboxnav ").toggleClass("mailboxnavopen");
  96.         });
  97.         $(".filemenu_btn").on("click", function(){
  98.             $(".filemenu ").toggleClass("filemenuopen");
  99.         });
  100.        
  101.         /* menu  collapsible */
  102.         $(".menu-collapse").on("click", function(){
  103.             body_1.toggleClass("menuclose");
  104.         });
  105.         $(".menu-collapse-right").on("click", function(){
  106.             body_1.toggleClass("menuclose-right");
  107.         });
  108.         $(".menu-small").on("click",function(){
  109.             body_1.toggleClass("menusmall");
  110.         });
  111.      
  112.        /* loading screen */
  113.         $(".loader_wrapper").fadeOut("slow");
  114.        
  115.     });
  116.     /* Custom css checkbox script */
  117.     $('.form-check-input').on('change', function(){
  118.         $(this).parent().toggleClass("active")
  119.         $(this).closest(".media").toggleClass("active");
  120.     });
  121.    
  122.     /* Card fullscreeen button script */
  123.     $('.fullscreen-btn').on('click', function(){
  124.         $(this).closest(".full-screen-container").toggleClass("fullscreen");
  125.         body_1.toggleClass("fullscreen");
  126.     });
  127.     /* Card fullscreeen button script ends */
  128.    
  129.     /* Card fullscreeen button script */
  130.     $('.push-cookie .alert.top .close, .push-cookie .alert.top .btn-secondary').on('click', function(){
  131.         body_1.removeClass("push-cookie");
  132.     });
  133.    
  134.    
  135.     /* Resposnsive Utility hide menu */
  136.     if($(window).width() >= 1440 && body_1.hasClass("no-menu-show") != true){
  137.         if(  body_1.hasClass("left-menu-only") === true ){
  138.                  body_1.removeClass('menuclose');
  139.             }else if(  body_1.hasClass("horizontal-menu") === true ){                
  140.                  body_1.addClass('menuclose-right');
  141.             }else{
  142.                 body_1.removeClass('menuclose ');
  143.             }              
  144.         }else{
  145.             if(  body_1.hasClass("left-menu-only") === true ){
  146.                  body_1.addClass('menuclose');
  147.             }else{
  148.                 body_1.addClass('menuclose ');
  149.             }
  150.            
  151.             // This script is for body click hide menu //
  152.             $(document).on('click', function(event){ if(event.target.className !== ".menu-collapse,.menu-collapse-right, .sidebar-left,.sidebar-right"){body_1.addClass('menuclose menuclose-right');}});
  153.             $('.menu-collapse,.menu-collapse-right, .sidebar-left,.sidebar-right').on('click', function(event){event.stopPropagation();});
  154.             $('.dropdown-toggle,[data-toggle="dropdown"],.userprofile').dropdown();
  155.             // This script is for body click ends here //        
  156.     }
  157.     $('.dropdown-toggle,[data-toggle="dropdown"],.userprofile').dropdown();
  158.    
  159.     $(window).on('resize', function(){
  160.         if($(window).width() >= 1440 && body_1.hasClass("no-menu-show") != true){  body_1.removeClass('menuclose '); }else{  body_1.addClass('menuclose menuclose-right'); }
  161.     });
  162.    
  163. });
  164.  
  165.      
  166.  
  167. function spincrementElement(htmlElement, isDecimal = false) {
  168.     htmlElement.spincrement({
  169.         from: 0,
  170.         decimalPlaces: (isDecimal) ? 2 : 0,
  171.         thousandSeparator: false,
  172.         duration: 1500, // ms; TOTAL length animation
  173.         leeway: 50, // percent of duraion
  174.         easing: 'spincrementEasing',
  175.         fade: true
  176.     });
  177. }
  178.    
  179. function sendNotify(title = "", msg = "", type = "danger")
  180. {
  181.     $.notify({
  182.         title: title,
  183.         message: msg,
  184.         },{
  185.         // settings
  186.         element: 'body',
  187.         position: null,
  188.         type: type,
  189.         timer: 1000,
  190.         placement: {
  191.             from: "top",
  192.             align: "right"
  193.         }
  194.     });
  195. }
  196.  
  197. function toFixed(num, fixed) {
  198.     var re = new RegExp('^-?\\d+(?:\.\\d{0,' + (fixed || -1) + '})?');
  199.     return parseFloat(num.toString().match(re)[0]).toFixed(fixed);
  200. }
  201.  
  202. function shorten(data, length = 26)
  203. {
  204.     return data.length > length ? data.substr( 0, length ) + '…' : data;
  205. }
  206.  
  207. function copyToClipboard(textToCopy)
  208. {
  209.     var targetId = "_hiddenCopyText_";
  210.  
  211.     target = document.getElementById(targetId);
  212.     if (!target) {
  213.         var target = document.createElement("textarea");
  214.         target.style.position = "absolute";
  215.         target.style.left = "-9999px";
  216.         target.style.top = "0";
  217.         target.id = targetId;
  218.         document.body.appendChild(target);
  219.     }
  220.     target.textContent = textToCopy;
  221.        
  222.     // select the content
  223.     var currentFocus = document.activeElement;
  224.     target.focus();
  225.     target.setSelectionRange(0, target.value.length);
  226.    
  227.     // copy the selection
  228.     var succeed;
  229.     try {
  230.           succeed = document.execCommand("copy");
  231.     } catch(e) {
  232.         succeed = false;
  233.     }
  234.     // restore original focus
  235.     if (currentFocus && typeof currentFocus.focus === "function") {
  236.         currentFocus.focus();
  237.     }
  238.    
  239.     return succeed;
  240. }
  241.  
  242. function formatXLQ(pXLQ, decimals = 8, wrap = false, smallDecimals = false) {
  243.     if(wrap) {
  244.         if(smallDecimals) {
  245.             var x = toFixed((pXLQ/100000000), decimals).toString().split(".");
  246.             var l = x[0];
  247.             var d = x[1];
  248.             return '<p style="display: inline-block;" class="' + ((pXLQ > 0) ? 'XLQGreen' : ((pXLQ < 0) ? 'XLQRed' : '' )) + '">' + l + '<small>.' + d + '</small> XLQ</p>';
  249.         } else
  250.             return '<p style="display: inline-block;" class="' + ((pXLQ > 0) ? 'XLQGreen' : ((pXLQ < 0) ? 'XLQRed' : '' )) + '">' + (pXLQ/100000000).toFixed(decimals) + ' XLQ</p>';
  251.     } else
  252.         return toFixed((pXLQ/100000000), decimals);
  253. }
  254.  
  255. function getExplorerTX(tx, classes="") {
  256.     return '<a target="_blank" href="' + explorerurl + 'tx/' + tx + '">' + shorten(tx) + '</a>';
  257. }
  258.  
  259. function getExplorerWallet(wallet, copyBtn = false, shortWallet = false) {
  260.     if(copyBtn)
  261.         return '<a target="_blank" href="' + explorerurl + 'wallet/' + wallet + '">' + ((shortWallet) ? shorten(wallet, 22) : wallet) + '</a> <p onclick="copyToClipboard(\'' + wallet +'\')" class="fa fa-copy"></p>';
  262.     else return '<a target="_blank" href="' + explorerurl + 'wallet/' + wallet + '">' + ((shortWallet) ? shorten(wallet, 22) : wallet) + '</a>';
  263. }
  264.  
  265. function getOrdinalNum(n) {
  266.   return n + (n > 0 ? ['th', 'st', 'nd', 'rd'][(n > 3 && n < 21) || n % 10 > 3 ? 0 : n % 10] : '');
  267. }
  268. function formatTimeToString(pTimestamp, length = 3){
  269.     //Sun, 19 Nov 2017 08:14:55 GMT
  270.     var days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
  271.     var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',  'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
  272.  
  273.     var n = new Date(pTimestamp * 1000);
  274.     n = new Date(n.getTime() - (n.getTimezoneOffset() * 60000));
  275.     var tmpDateTime = "";
  276.  
  277.     if(length == 1)
  278.             tmpDateTime = getOrdinalNum(n.getUTCDate()) + " " + months[n.getUTCMonth()] + " " + ('0' + n.getUTCHours()).slice(-2) + ":" + ('0' + n.getUTCMinutes()).slice(-2);
  279.  
  280.     if(length == 2)
  281.             tmpDateTime = getOrdinalNum(n.getUTCDate()) + " " + months[n.getUTCMonth()] + " " + n.getUTCFullYear() + " " + ('0' + n.getUTCHours()).slice(-2) + ":" + ('0' + n.getUTCMinutes()).slice(-2) + ":" + ('0' + n.getUTCSeconds()).slice(-2);
  282.  
  283.     if(length == 3)
  284.             tmpDateTime = days[n.getUTCDay()] + ", " + n.getUTCDate() + " " + months[n.getUTCMonth()] + " " + n.getUTCFullYear() + " " + ('0' + n.getUTCHours()).slice(-2) + ":" + ('0' + n.getUTCMinutes()).slice(-2) + ":" + ('0' + n.getUTCSeconds()).slice(-2);
  285.  
  286.     return tmpDateTime;
  287. }
  288. function checkTime(i) {
  289.     if (i < 10) {i = "0" + i};  // add zero in front of numbers < 10
  290.     return i;
  291. }
  292.  
  293. const explorerurl = "https://explorer.alqo.org/";
  294. const apiurl = "https://liberio.app/api/";
  295. const summarytime = 10*1000;
  296. const transactiontime = 10*1000;
  297. const graphtime = 20*1000;
  298. const statstictime = 30*1000;
  299.    
  300. function apiSummary(pFunction){
  301.     $.get(apiurl + "summary", {} ,pFunction);
  302. }  
  303.  
  304. function apiSendSummary(pFunction){
  305.     $.get(apiurl + "sendsummary", {} ,pFunction);
  306. }  
  307.  
  308. function apiGlacierSummary(pFunction){
  309.     $.get(apiurl + "glaciersummary", {} ,pFunction);
  310. }
  311.  
  312. function apiPrivateKeyByUWID(pUWID, pFunction){
  313.     $.get(apiurl + "getprivatekeybyuwid/" + pUWID, {} ,pFunction);
  314. }
  315.  
  316. function apiAddWallet(pFunction){
  317.     $.get(apiurl + "addwallet", {} ,pFunction);
  318. }
  319.  
  320. function apiAddPrivateKey(pPrivateKey, pFunction){
  321.     $.get(apiurl + "addprivatekey/" + pPrivateKey, {} ,pFunction);
  322. }
  323.  
  324. function apiAddWatchonlyKey(pFunction){
  325.     $.get(apiurl + "addwatchonlykey", {} ,pFunction);
  326. }
  327.  
  328.  
  329. function apiGovernance(pVoteID, pVoteOption, pFunction){
  330.     $.get(apiurl + "governance/" + pVoteID + "/" + pVoteOption, {} ,pFunction);
  331. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement