<commit_before># Copyright (c) 2012-2013 <NAME>. All rights reserved

d = i: debiki.internal, u: debiki.v0.util
$ = d.i.$;


angularStartup = void


/**
 * Starts AngularJS and initizlizes the root scope.
 *
 * Not called until really needed, for performance reasons (so mobile
 * phones don't need to download and parse the AngularJS lib, and
 * run the page through Angular's template engine).
 */
bootstrapAngularJs = !->
  if angularStartup => return
  angularStartup := $.Deferred!

  cdnDir = 'https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/'

  bootstrapAngular = !->
    # See http://docs.angularjs.org/guide/bootstrap, "Manual Initialization".
    angular.element(document).ready !->
      angular.bootstrap document, ['DebikiPageModule']
      initRootScope!
      angularStartup.resolve!

  Modernizr.load(
    both: [
      cdnDir + 'angular.min.js',
      cdnDir + 'angular-sanitize.min.js',
      d.i.assetsUrlPathStart + 'debiki-dashbar.js']
    complete: bootstrapAngular)



findRootScope = ->
  # (See:
  # http://stackoverflow.com/questions/10490570/
  #   call-angular-js-from-legacy-code )
  return undefined unless angular?
  angular.element($('html')).scope!



!function initRootScope
  $rootScope = findRootScope!

  $pageDataTag = $ '.dw-page'  # or are there > 1 on blog main page?
  $rootScope <<< $pageDataTag.dwPageMeta!

  $rootScope.viewsPageConfigPost =
    $pageDataTag.children('.dw-t').attr('id') == 'dw-t-' + d.i.pageConfigPostId

  $rootScope.setCurrentUser = !(userProps) ->
    $rootScope.currentUser ?= {}
    $rootScope.currentUser <<< userProps

  $rootScope.clearCurrentUser = !->
    $rootScope.currentUser = undefined



/**
 * Executes `f($rootScope)` inside $rootScope.$apply.
 * Bootstraps AngularJS if needed.
 */
d.i.angularApply = !(f) ->
  rootScope = findRootScope!
  if !rootScope
    bootstrapAngularJs!

  angularStartup.done ->
    rootScope = findRootScope!
    rootScope.$apply !->
      f rootScope<commit_msg>Fix two LiveScript deprecation warnings<commit_after># Copyright (c) 2012-2013 <NAME>. All rights reserved

d = i: debiki.internal, u: debiki.v0.util
$ = d.i.$;


angularStartup = void


/**
 * Starts AngularJS and initizlizes the root scope.
 *
 * Not called until really needed, for performance reasons (so mobile
 * phones don't need to download and parse the AngularJS lib, and
 * run the page through Angular's template engine).
 */
bootstrapAngularJs = !->
  if angularStartup => return
  angularStartup := $.Deferred!

  cdnDir = 'https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/'

  bootstrapAngular = !->
    # See http://docs.angularjs.org/guide/bootstrap, "Manual Initialization".
    angular.element(document).ready !->
      angular.bootstrap document, ['DebikiPageModule']
      initRootScope!
      angularStartup.resolve!

  Modernizr.load(
    both: [
      cdnDir + 'angular.min.js',
      cdnDir + 'angular-sanitize.min.js',
      d.i.assetsUrlPathStart + 'debiki-dashbar.js']
    complete: bootstrapAngular)



findRootScope = ->
  # (See:
  # http://stackoverflow.com/questions/10490570/
  #   call-angular-js-from-legacy-code )
  return void unless angular?
  angular.element($('html')).scope!



!function initRootScope
  $rootScope = findRootScope!

  $pageDataTag = $ '.dw-page'  # or are there > 1 on blog main page?
  $rootScope <<< $pageDataTag.dwPageMeta!

  $rootScope.viewsPageConfigPost =
    $pageDataTag.children('.dw-t').attr('id') == 'dw-t-' + d.i.pageConfigPostId

  $rootScope.setCurrentUser = !(userProps) ->
    $rootScope.currentUser ?= {}
    $rootScope.currentUser <<< userProps

  $rootScope.clearCurrentUser = !->
    $rootScope.currentUser = void



/**
 * Executes `f($rootScope)` inside $rootScope.$apply.
 * Bootstraps AngularJS if needed.
 */
d.i.angularApply = !(f) ->
  rootScope = findRootScope!
  if !rootScope
    bootstrapAngularJs!

  angularStartup.done ->
    rootScope = findRootScope!
    rootScope.$apply !->
      f rootScope
{'fraction_non_alphanumeric': 0.13695871097683787, 'fraction_numerical': 0.010574018126888218, 'mean_word_length': 3.449048152295633, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 27, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4721975', 'n_tokens_mistral': 1368, 'n_tokens_neox': 1280, 'n_words': 279}