(function () {
  var getCurrentScript = function (base) {
    if (document.currentScript) {
      return document.currentScript.src // FF,Chrome
    };
    var stack
    try {
      a.b.c() // 强制报错,以便捕获e.stack
    } catch (e) { // safari的错误对象只有line,sourceId,sourceURL
      stack = e.stack;
      if (!stack && window.opera) {
        // opera 9没有e.stack,但有e.Backtrace,但不能直接取得,需要对e对象转字符串进行抽取
        stack = (String(e).match(/of linked script \S+/g) || []).join(' ')
      }
    }
    if (stack) {
      stack = stack.split(/[@ ]/g).pop() // 取得最后一行,最后一个空格或@之后的部分
      stack = stack[0] === '(' ? stack.slice(1, -1) : stack.replace(/\s/, '') // 去掉换行符
      return stack.replace(/(:\d+)?:\d+$/i, '') // 去掉行号与或许存在的出错字符起始位置
    }
    var nodes = (base ? document : document.head).getElementsByTagName('script') // 只在head标签中寻找
    for (var i = nodes.length, node; node = nodes[--i];) {
      if (node.readyState === 'interactive') {
        return node.src
      }
    }
    node = nodes[nodes.length - 1]
    return node.hasAttribute ? node.src : node.getAttribute('src', 4)
  }

  var jspath = getCurrentScript(true)
  jspath = jspath.substr(0, jspath.lastIndexOf('/') + 1)

  window.Weaver = window.Weaver || {
    View: {
      EditorView: {},
      Behavior: {}
    }
  }
  document.write('<script type="text/javascript" src="' + jspath + 'view/Weaver.View.EditorView.Range.js"></script>')
  document.write('<script type="text/javascript" src="' + jspath + 'view/Weaver.View.DropdownSelectbox.js"></script>')
})()
