Advertisement
web-fx

globals-2.0.0.js

Jan 13th, 2021 (edited)
50
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*-- PUBLIC DOMAIN RELEASE - VERSION 2.0.0 - https://pastebin.com/rzSXKPna */
  2. var G_PagePath = window.location.pathname.toLowerCase ( ); G_PagePath = G_PagePath.replace( 'index.html', '' );
  3. if ( G_PagePath.length > 1 ) { if ( G_PagePath.substring ( G_PagePath.length - 1, G_PagePath.length ) == '/' ) { G_PagePath = G_PagePath.substring ( 0, G_PagePath.length - 1 ); } }
  4.  
  5. // Cookie Array And Index
  6. var G_CookieString = [];
  7. var G_CookieBoolean = [];
  8. var G_CookieNumber = [];
  9. var G_CI_Name = 0;
  10. var G_CI_Default = 1;
  11. var G_CI_Value = 2;
  12.  
  13. // Assignment Operator
  14. var CurrentIndex = -1;
  15.  
  16. // String Variable Index
  17. var G_C_ExampleString = -1;
  18.  
  19. // Boolean Variable Index
  20. var G_C_ExampleBoolean = -1;
  21.  
  22. // Integer Variable Index
  23. var G_C_ExampleNumber = -1;
  24.  
  25. // String Assignments
  26. G_C_ExampleString = G_CookieString.length; CurrentIndex = G_CookieString.length; G_CookieString[CurrentIndex] = []; G_CookieString[CurrentIndex][G_CI_Name] = 'Example String'; G_CookieString[CurrentIndex][G_CI_Default] = 'This string can be for a lot of things.';
  27.  
  28. // Boolean Assignments
  29. G_C_ExampleBoolean = G_CookieBoolean.length; CurrentIndex = G_CookieBoolean.length; G_CookieBoolean[CurrentIndex] = []; G_CookieBoolean[CurrentIndex][G_CI_Name] = 'Example Boolean'; G_CookieBoolean[CurrentIndex][G_CI_Default] = true;
  30.  
  31. // Integer Assignments
  32. G_C_ExampleNumber = G_CookieNumber.length; CurrentIndex = G_CookieNumber.length; G_CookieNumber[CurrentIndex] = []; G_CookieNumber[CurrentIndex][G_CI_Name] = 'Example Integer'; G_CookieNumber[CurrentIndex][G_CI_Default] = 1;
  33.  
  34.  
  35.  
  36.  
  37. var Globals = new function () {
  38.  
  39.  
  40.  
  41.  
  42. this.AddAsset = function ( TypeIn, PathIn, AsyncIn ) {
  43.  
  44.  
  45. if ( TypeIn == 'style' ) {
  46.  
  47. document.write ( '<link rel="stylesheet" href="' + PathIn + '" />' );
  48.  
  49. } else if ( TypeIn == 'script' ) {
  50.  
  51. if ( AsyncIn == false ) {
  52.  
  53. document.write( '<script src="' + PathIn + '"></script>' );
  54.  
  55. } else {
  56.  
  57. document.write( '<script src="' + PathIn + '" async></script>' );
  58.  
  59. }
  60.  
  61. }
  62.  
  63.  
  64. }
  65.  
  66.  
  67.  
  68.  
  69. this.Initialize = function () {
  70.  
  71.  
  72. // Load cookie string array
  73. for ( Count = 0; Count < G_CookieString.length; Count++ ) {
  74.  
  75. G_CookieString[Count][G_CI_Value] = Private.VoidToString ( Cookies.GetCookieAndSetDaily ( G_CookieString[Count][G_CI_Name], G_CookieString[Count][G_CI_Default] ) );
  76.  
  77. }
  78.  
  79. // Load cookie boolean array
  80. for ( Count = 0; Count < G_CookieBoolean.length; Count++ ) {
  81.  
  82. G_CookieBoolean[Count][G_CI_Value] = Private.VoidToBoolean ( Cookies.GetCookieAndSetDaily ( G_CookieBoolean[Count][G_CI_Name], G_CookieBoolean[Count][G_CI_Default] ) );
  83.  
  84. }
  85.  
  86. // Load cookie number array
  87. for ( Count = 0; Count < G_CookieNumber.length; Count++ ) {
  88.  
  89. G_CookieNumber[Count][G_CI_Value] = Private.VoidToNumber ( Cookies.GetCookieAndSetDaily ( G_CookieNumber[Count][G_CI_Name], G_CookieNumber[Count][G_CI_Default] ) );
  90.  
  91. }
  92.  
  93.  
  94. }
  95.  
  96.  
  97.  
  98.  
  99. var Private = {
  100.  
  101.  
  102.  
  103.  
  104. VoidToString: function ( ValueIn, DefaultIn ) {
  105.  
  106.  
  107. var RetVal = '';
  108. var IsInvalid = false;
  109.  
  110. IsInvalid = this.IsInvalidValue ( ValueIn );
  111.  
  112. try {
  113.  
  114. if ( IsInvalid == true ) { RetVal = DefaultIn; }
  115. else { RetVal = ValueIn; }
  116.  
  117. } catch ( error ) { }
  118.  
  119.  
  120.  
  121.  
  122. return RetVal;
  123.  
  124.  
  125. },
  126.  
  127.  
  128.  
  129.  
  130. VoidToBoolean: function ( ValueIn, DefaultIn ) {
  131.  
  132.  
  133. var RetVal = ValueIn;
  134. var IsInvalid = false;
  135.  
  136. if ( typeof ( ValueIn ) == 'string' ) {
  137.  
  138. if ( ValueIn == 'true' || ValueIn == '1' ) { RetVal = true; }
  139. else if ( ValueIn == 'false' || ValueIn == '0' ) { RetVal = false; }
  140.  
  141. }
  142.  
  143. IsInvalid = this.IsInvalidValue ( ValueIn );
  144.  
  145. if ( IsInvalid == true ) { RetVal = DefaultIn; }
  146.  
  147.  
  148.  
  149.  
  150. return RetVal;
  151.  
  152.  
  153. },
  154.  
  155.  
  156.  
  157.  
  158. VoidToNumber: function ( ValueIn, DefaultIn ) {
  159.  
  160.  
  161. var RetVal = null;
  162. var IsInvalid = false;
  163.  
  164. IsInvalid = this.IsInvalidValue ( ValueIn );
  165.  
  166. try {
  167.  
  168. if ( IsInvalid == true ) { RetVal = Number ( DefaultIn ); }
  169. else { RetVal = Number ( ValueIn ); }
  170.  
  171. } catch ( error ) { }
  172.  
  173.  
  174.  
  175.  
  176. return RetVal;
  177.  
  178.  
  179. },
  180.  
  181.  
  182.  
  183.  
  184. IsInvalidValue: function ( ValueIn ) {
  185.  
  186.  
  187. var RetVal = false;
  188.  
  189. if ( ValueIn == null ) { RetVal = true; }
  190. else if ( ValueIn == undefined ) { RetVal = true; }
  191.  
  192.  
  193.  
  194.  
  195. return RetVal;
  196.  
  197.  
  198. }
  199.  
  200.  
  201.  
  202.  
  203. };
  204.  
  205.  
  206.  
  207.  
  208. }
  209.  
  210.  
  211.  
  212.  
  213. Globals.Initialize ( );
Advertisement
RAW Paste Data Copied
Advertisement