src/basis.js
function fetchConfig(){
    var config = __config;

    if (!config)
    {
      if (NODE_ENV)
      {
        // node.js env
        basisFilename = process.basisjsFilename || __filename.replace(/\\/g, '/');

        /** @cut */ if (process.basisjsConfig)
        /** @cut */ {
        /** @cut */   config = process.basisjsConfig;
        /** @cut */   if (typeof config == 'string')
        /** @cut */   {
        /** @cut */     try {
        /** @cut */       config = Function('return{' + config + '}')();
        /** @cut */     } catch(e) {
        /** @cut */       /** @cut */ consoleMethods.error('basis-config: basis.js config parse fault: ' + e);
        /** @cut */     }
        /** @cut */   }
        /** @cut */ }
      }
      else
      {
        // browser env
        var scripts = document.scripts;
        for (var i = 0, scriptEl; scriptEl = scripts[i]; i++)
        {
          var configAttrValue = scriptEl.hasAttribute('basis-config')
            ? scriptEl.getAttribute('basis-config')
            : scriptEl.getAttribute('data-basis-config');

          scriptEl.removeAttribute('basis-config');
          scriptEl.removeAttribute('data-basis-config');

          if (configAttrValue !== null)
          {
            basisFilename = pathUtils.normalize(scriptEl.src);

            try {
              config = Function('return{' + configAttrValue + '}')();
            } catch(e) {
              /** @cut */ consoleMethods.error('basis-config: basis.js config parse fault: ' + e);
            }

            break;
          }
        }

        if (!basisFilename)
        {
          basisFilename = pathUtils.normalize(scripts[0].src);
          /** @cut */ consoleMethods.warn('basis-config: no `basis-config` marker on any script tag is found. All paths will be resolved relative to `src` from the first `script` tag.');
        }
      }
    }

    return processConfig(config);
  }
function fetchConfig(){
    var config = __config;

    if (!config)
    {
      if (NODE_ENV)
      {
        // node.js env
        basisFilename = process.basisjsFilename || __filename.replace(/\\/g, '/');

        /** @cut */ if (process.basisjsConfig)
        /** @cut */ {
        /** @cut */   config = process.basisjsConfig;
        /** @cut */   if (typeof config == 'string')
        /** @cut */   {
        /** @cut */     try {
        /** @cut */       config = Function('return{' + config + '}')();
        /** @cut */     } catch(e) {
        /** @cut */       /** @cut */ consoleMethods.error('basis-config: basis.js config parse fault: ' + e);
        /** @cut */     }
        /** @cut */   }
        /** @cut */ }
      }
      else
      {
        // browser env
        var scripts = document.scripts;
        for (var i = 0, scriptEl; scriptEl = scripts[i]; i++)
        {
          var configAttrValue = scriptEl.hasAttribute('basis-config')
            ? scriptEl.getAttribute('basis-config')
            : scriptEl.getAttribute('data-basis-config');

          scriptEl.removeAttribute('basis-config');
          scriptEl.removeAttribute('data-basis-config');

          if (configAttrValue !== null)
          {
            basisFilename = pathUtils.normalize(scriptEl.src);

            try {
              config = Function('return{' + configAttrValue + '}')();
            } catch(e) {
              /** @cut */ consoleMethods.error('basis-config: basis.js config parse fault: ' + e);
            }

            break;
          }
        }

        if (!basisFilename)
        {
          basisFilename = pathUtils.normalize(scripts[0].src);
          /** @cut */ consoleMethods.warn('basis-config: no `basis-config` marker on any script tag is found. All paths will be resolved relative to `src` from the first `script` tag.');
        }
      }
    }

    return processConfig(config);
  }
function fetchConfig ( ) { var config = __config ; if ( ! config ) { if ( NODE_ENV ) { // node.js env basisFilename = process . basisjsFilename || __filename . replace ( / \\ / g , '/' ) ; /** @cut */ if ( process . basisjsConfig ) /** @cut */ { /** @cut */ config = process . basisjsConfig ; /** @cut */ if ( typeof config == 'string' ) /** @cut */ { /** @cut */ try { /** @cut */ config = Function ( 'return{' + config + '}' ) ( ) ; /** @cut */ } catch ( e ) { /** @cut */ /** @cut */ consoleMethods . error ( 'basis-config: basis.js config parse fault: ' + e ) ; /** @cut */ } /** @cut */ } /** @cut */ } } else { // browser env var scripts = document . scripts ; for ( var i = 0 , scriptEl ; scriptEl = scripts [ i ] ; i ++ ) { var configAttrValue = scriptEl . hasAttribute ( 'basis-config' ) ? scriptEl . getAttribute ( 'basis-config' ) : scriptEl . getAttribute ( 'data-basis-config' ) ; scriptEl . removeAttribute ( 'basis-config' ) ; scriptEl . removeAttribute ( 'data-basis-config' ) ; if ( configAttrValue !== null ) { basisFilename = pathUtils . normalize ( scriptEl . src ) ; try { config = Function ( 'return{' + configAttrValue + '}' ) ( ) ; } catch ( e ) { /** @cut */ consoleMethods . error ( 'basis-config: basis.js config parse fault: ' + e ) ; } break ; } } if ( ! basisFilename ) { basisFilename = pathUtils . normalize ( scripts [ 0 ] . src ) ; /** @cut */ consoleMethods . warn ( 'basis-config: no `basis-config` marker on any script tag is found. All paths will be resolved relative to `src` from the first `script` tag.' ) ; } } } return processConfig ( config ) ; }
Fetch basis.js options from script's `basis-config` or `data-basis-config` attribute.
Fetch basis . js options from script s basis - config or data - basis - config attribute .