void init()

in web/viewer.dart [95:174]


void init() {
  HistoryState.setup(_switchSlide, _animationTime);
  _noSlide();
  _switchSlide('load');

  bool alreadyLoaded = false;

  var dragDrop = querySelector('drag-drop-view') as DragDropView;
  var dependencyView = querySelector('dependency-view') as DependencyView;
  var diffView = querySelector('diff-view') as DiffView;
  var hierarchyView = querySelector('hierarchy-view') as HierarchyView;
  var programInfoView = querySelector('program-info-view') as ProgramInfoView;

  var tabs = querySelectorAll('paper-tab');
  for (PaperTab tab in tabs) {
    tab.onClick.listen((_) {
      String link = tab.attributes['slide'];
      HistoryState.switchTo(new HistoryState(link));
    });
  }

  void loadJson(String jsonString) {
    var json;
    try {
      json = JSON.decode(jsonString) as Map<String, dynamic>;
    } catch (e) {
      window.console.error("Error parsing json");
      window.console.error(e);
      return;
    }
    document.querySelector('core-toolbar').style.top = "0";

    var info = new InfoHelper.fromJson(json);

    diffView.currentlyLoaded = info;

    if (alreadyLoaded) {
      hierarchyView.clear();
    } else {
      HistoryState.switchTo(new HistoryState('info'));
    }

    var dumpVersion = info.dumpVersion as num;

    if (dumpVersion < 1 || dumpVersion > 5) {
      window.alert('Unknown dump-info version: $dumpVersion');
      return;
    }

    dependencyView.dumpInfo = info;
    hierarchyView.dumpInfo = info;
    programInfoView.dumpInfo = info;

    alreadyLoaded = true;
    _updateButton();
  }

  // When a file is loaded
  dragDrop.onFile.listen((json) {
    try {
      _setCache(json);
    } catch (e) {
      window.console.error(
          'Could not populate cache. May be too big. Try the clear button.');
      window.console.error(e);
    }
    loadJson(json);
  });

  _clearCacheButton.onClick.listen((_) {
    window.localStorage.clear();
    _updateButton();
  });

  _useLastButton.onClick.listen((_) {
    loadJson(_getCache());
  });

  _updateButton();
}