home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 2003 November / CD1_JOY_153.iso / demos / NHL2004Demo.exe / fe / COMMON / js / properties.js < prev    next >
Text File  |  2003-08-20  |  1KB  |  44 lines

  1. function EASOProperties (  fileName ) 
  2. {
  3.    this._values = new Array();
  4.    var split     = top.location.href.split(/\b\/fe\/\w/g, 2);
  5.    var installFolder= (split) ? split[0] : "";
  6.    installFolder=unescape(installFolder);
  7.    installFolder= installFolder.substring(8) + "/";
  8.    if (fileName) {
  9.     this.fileName = fileName;
  10.    } else {
  11.     this.fileName = installFolder + "EASOProperties.txt"
  12.    };
  13.    this._loadFile (this.fileName);
  14. };
  15. EASOProperties.prototype.get = function  (propName, defaultValue) 
  16. {
  17.     if (this._values[propName]) {
  18.          return this._values[propName];
  19.     } else {
  20.        return  defaultValue;
  21.     };
  22. };
  23. EASOProperties.prototype.set = function (propName, value) { this._values[propName] = value; };
  24. EASOProperties.prototype._loadFile    = function(name) 
  25. {    
  26.     //var fso        = new ActiveXObject("Scripting.FileSystemObject");
  27.     //var textStream        = fso.OpenTextFile( name);
  28.     //while (! textStream.AtEndOfStream) {
  29.     //    this._parseLine ( textStream.ReadLine() );
  30.     //};
  31.     //textStream.Close();
  32. };
  33. EASOProperties.prototype._parseLine = function(l) 
  34. {
  35.     if (!l) return;
  36.     if (trim(l).charAt(0) =='#') return;
  37.     var delimPos = l.indexOf (":");
  38.     var name = l.substr (0, delimPos );
  39.     var val = l.substr (delimPos+1);
  40.     if ( name && ( val !=null ) ) 
  41.         this._values[ name] = trim ( val ) ; 
  42. };
  43. function trim (s) { return s.replace(/(^\s*)|(\s*$)/g, ""); };
  44. var EASOProps    = new EASOProperties();