Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: None  |  size: 2.16 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /**
  2.  * Copyright (c) 2011 Moritz Mahringer
  3.  *
  4.  * Permission is hereby granted, free of charge, to any person obtaining
  5.  * a copy of this software and associated documentation files (the "Software"),
  6.  * to deal in the Software without restriction, including without limitation
  7.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8.  * and/or sell copies of the Software, and to permit persons to whom the Software
  9.  * is furnished to do so, subject to the following conditions:
  10.  *
  11.  * The above copyright notice and this permission notice shall be included in
  12.  * all copies or substantial portions of the Software.
  13.  *
  14.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  15.  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  16.  * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
  17.  * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  18.  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  19.  */
  20.  
  21. /**
  22.  * Core Loader
  23.  *
  24.  * Created 2011 06 21 - MoMa
  25.  */
  26.  
  27. var core=new Object();
  28. core.loader=new Object();
  29.  
  30. core.loader.onload=function (){}; //Called when Core loaded
  31. core.loader.onerror=function (){}; //Called when Core loading failed
  32. core.loader.readyState=0; //0=Not Loaded 4=Working
  33. core.loader.path="core.js";
  34. core.loader.test=false;
  35.  
  36. core.loader.start=function () {
  37.         core.loader.xhr=new XMLHttpRequest();
  38.         core.loader.xhr.open("GET",core.loader.path,true);
  39.         core.loader.xhr.onreadystatechange=core.loader.rsc;
  40.         core.loader.xhr.send(null);
  41. };
  42.  
  43. core.loader.rsc=function ()
  44. {
  45.         if(core.loader.xhr.readyState==4)
  46.         {
  47.                 if(core.loader.xhr.status==200)
  48.                 {
  49.                         eval(core.loader.xhr.responseText);
  50.                         console.log("{core.js} ||Selftest|| [START]: "+core.loader.test);
  51.                         if(core.loader.test==true)
  52.                         {
  53.                                 core.loader.onload();
  54.                         }else{
  55.                                 core.loader.onerror();
  56.                         }
  57.                 }
  58.         }
  59. };
  60.  
  61.  
  62. //Core Self Test:
  63. //      Der selbst Test funktioniert mit einer in Core.js befindlichen Zeile:
  64. //              core.loader.test=true;
  65. //      sollte also core.loader.test == true sein heißt das, dass die Datei korrekt geparst wurde