<commit_before>// {nex.js} - Unleashing the power of AMD for web applications.
//
// Version: 0.2.0
// 
// The MIT License (MIT)
// Copyright (c) 2014 <NAME>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.

/*global console*/
(function(root, factory) {
  'use strict';

  // UMD (Universal Module Definition)
  if (typeof define === 'function' && define.amd) {
    // AMD. Register as an anonymous module.
    define([], factory);
  } else {
    // Browser globals
    root.Nex = factory(root.b);
  }
}(this, function() {
  'use strict';

  var Nex = {
    // Nex.View
    View: {
      // Extend the base view like this `var MyView = Nex.View.extend({});` where the object being passed in is `extendingView`.
      extend: function extend(extendingView) {
        if (typeof(extendingView) === 'undefined') extendingView = {};

        // Your view's constructor function. Call like this `var view = new MyView();`.
        return function View() {
          var view = this;

          // Allow the implementing view to override extendingView on this object
          for (var property in extendingView) {
            view[property] = extendingView[property];
          }

          // view.tagName - the type of DOM element
          if (typeof(view.tagName) === 'undefined') view.tagName = 'div';

          // view.el - the view's DOM element
          if (typeof(view.el) === 'undefined') view.el = document.createElement(view.tagName);

          // view.layoutView - the layout view contains your site's layout (header, footer, etc.)
          if (typeof(view.layoutView) !== 'undefined') {
            if (!view.layoutView instanceof View) {
              throw 'The `view.layoutView` must be an instance of a View.';
            }
            if (typeof(view.layoutView.contentPlaceholderId) !== 'string') {
              throw 'The layout view must have `view.contentPlaceholderId` specified.';
            }
            // Give the layout view a reference to the child view in case it needs to modify its render method
            view.layoutView.childView = view;
          }

          // view.contentPlaceholderId - the ID of a layout view's content placeholder element
          if (typeof(view.contentPlaceholderId) !== 'undefined' && typeof(view.contentPlaceholderId) !== 'string' ) {
            throw 'The `contentPlaceholderId` must be a string.';
          }

          // view.childView - the child view is attached to the layout if it needs to be re-rendered without re-rendering the child view
          if (typeof(view.childView) !== 'undefined') throw 'You can\'t specify `view.childView`. This is set automatically on the layout when a view specifies `view.layoutView`.';

          // view.outerEl - the view's or layout view's outer most element
          if (typeof(view.outerEl) !== 'undefined') throw '`view.outerEl` is a read only property that is automatically populated.';
          view.outerEl = view.layoutView ? view.layoutView.outerEl : view.el;

          // view.id - the ID of the view's DOM element
          if (typeof(view.id) !== 'undefined') view.el.id = view.id;

          // view.className - the class name(s) of the view's DOM element
          if (typeof(view.className) !== 'undefined') view.el.className = view.className;

          // view.model - the model that gets passed to the template
          if (typeof(view.model) === 'undefined') view.model = {};

          // view.template() - called by view.render() to generate the view's HTML
          // Defaults to work like a precompiled template that returns an empty HTML string.
          if (typeof(view.template) === 'undefined') {
            view.template = function() {
              console.log('You should implement `View.template()`.');
              return '';
            };
          }

          // view.render() - call the template with the view's model and replace view's HTML
          //
          // In order to guarantee that the layout view will be rendered when this view is rendered we need to wrap
          // the `render()` method in a render method that will also render the layout.
          var innerRender = function innerRender() {
            // Allow the model to be defined as a constructor function so that variables don't need to be
            // evaluated until render time
            var model;
            if (typeof(view.model) === 'function') {
              model = new view.model();
            } else {
              model = view.model;
            }

            // Compile the template and set the view's HTML
            if (typeof(view.template) === 'function') {
              // Compiled template
              view.html(view.template({model: model}));
            } else if (typeof(view.template) === 'string') {
              // Simple, non-dynamic HTML
              view.html(view.template);
            }
            
            return view;
          };
          // `innerRender()` is actually overridden by specifying a `view.render()` method
          if (typeof(view.render) !== 'undefined') innerRender = view.render;

          var shouldRenderLayout = view.layoutView ? true : false;
          view.render = function render() {
            // Walk up the view chain rendering layout views on the initial render
            if(shouldRenderLayout) {
              view.layoutView.render();
              shouldRenderLayout = false;
            }

            // Call the method that actually renders the view
            var innerRenderReturnValue = innerRender.call(this, arguments);

            // When a layout view is rendered it should attach it's child to it's content placeholder
            if (view.childView) {
              var contentPlaceholder = view.el.querySelector('#' + view.contentPlaceholderId);
              // IE8 workaround since el.innerHTML fails when an event is currently being triggered on it
              while (contentPlaceholder.firstChild) contentPlaceholder.removeChild(contentPlaceholder.firstChild);
              contentPlaceholder.appendChild(view.childView.el);
            }

            // Return the value from the original render method
            return innerRenderReturnValue;
          };

          // view.html() -  replace `view.el`'s HTML with the htmlString
          view.html = function html(htmlString) {
            // IE8 workaround since el.innerHTML fails when an event is currently being triggered on it. Create a new element
            // and set innerHTML which will work since no event is occurring on this temp element.
            var a = document.createElement('div');
            a.innerHTML = htmlString;

            // Copy the contents of the temp element to a document fragment. This doesn't contain a wrapping div.
            var b = document.createDocumentFragment();
            while (a.firstChild) b.appendChild(a.firstChild);

            // Clear out view.el and attach the new HTML
            while (view.el.firstChild) view.el.removeChild(view.el.firstChild);
            view.el.appendChild(b);
          };<commit_msg>adding arg<commit_after>// {nex.js} - Unleashing the power of AMD for web applications.
//
// Version: 0.2.0
// 
// The MIT License (MIT)
// Copyright (c) 2014 <NAME>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.

/*global console*/
(function(root, factory) {
  'use strict';

  // UMD (Universal Module Definition)
  if (typeof define === 'function' && define.amd) {
    // AMD. Register as an anonymous module.
    define([], factory);
  } else {
    // Browser globals
    root.Nex = factory(root.b);
  }
}(this, function() {
  'use strict';

  var Nex = {
    // Nex.View
    View: {
      // Extend the base view like this `var MyView = Nex.View.extend({});` where the object being passed in is `extendingView`.
      extend: function extend(extendingView) {
        if (typeof(extendingView) === 'undefined') extendingView = {};

        // Your view's constructor function. Call like this `var view = new MyView();`.
        return function View() {
          var view = this;

          // Allow the implementing view to override extendingView on this object
          for (var property in extendingView) {
            view[property] = extendingView[property];
          }

          // view.tagName - the type of DOM element
          if (typeof(view.tagName) === 'undefined') view.tagName = 'div';

          // view.el - the view's DOM element
          if (typeof(view.el) === 'undefined') view.el = document.createElement(view.tagName);

          // view.layoutView - the layout view contains your site's layout (header, footer, etc.)
          if (typeof(view.layoutView) !== 'undefined') {
            if (!view.layoutView instanceof View) {
              throw 'The `view.layoutView` must be an instance of a View.';
            }
            if (typeof(view.layoutView.contentPlaceholderId) !== 'string') {
              throw 'The layout view must have `view.contentPlaceholderId` specified.';
            }
            // Give the layout view a reference to the child view in case it needs to modify its render method
            view.layoutView.childView = view;
          }

          // view.contentPlaceholderId - the ID of a layout view's content placeholder element
          if (typeof(view.contentPlaceholderId) !== 'undefined' && typeof(view.contentPlaceholderId) !== 'string' ) {
            throw 'The `contentPlaceholderId` must be a string.';
          }

          // view.childView - the child view is attached to the layout if it needs to be re-rendered without re-rendering the child view
          if (typeof(view.childView) !== 'undefined') throw 'You can\'t specify `view.childView`. This is set automatically on the layout when a view specifies `view.layoutView`.';

          // view.outerEl - the view's or layout view's outer most element
          if (typeof(view.outerEl) !== 'undefined') throw '`view.outerEl` is a read only property that is automatically populated.';
          view.outerEl = view.layoutView ? view.layoutView.outerEl : view.el;

          // view.id - the ID of the view's DOM element
          if (typeof(view.id) !== 'undefined') view.el.id = view.id;

          // view.className - the class name(s) of the view's DOM element
          if (typeof(view.className) !== 'undefined') view.el.className = view.className;

          // view.model - the model that gets passed to the template
          if (typeof(view.model) === 'undefined') view.model = {};

          // view.template() - called by view.render() to generate the view's HTML
          // Defaults to work like a precompiled template that returns an empty HTML string.
          if (typeof(view.template) === 'undefined') {
            view.template = function() {
              console.log('You should implement `View.template()`.');
              return '';
            };
          }

          // view.render() - call the template with the view's model and replace view's HTML
          //
          // In order to guarantee that the layout view will be rendered when this view is rendered we need to wrap
          // the `render()` method in a render method that will also render the layout.
          var innerRender = function innerRender() {
            // Allow the model to be defined as a constructor function so that variables don't need to be
            // evaluated until render time
            var model;
            if (typeof(view.model) === 'function') {
              model = new view.model();
            } else {
              model = view.model;
            }

            // Compile the template and set the view's HTML
            if (typeof(view.template) === 'function') {
              // Compiled template
              view.html(view.template({model: model}));
            } else if (typeof(view.template) === 'string') {
              // Simple, non-dynamic HTML
              view.html(view.template);
            }
            
            return view;
          };
          // `innerRender()` is actually overridden by specifying a `view.render()` method
          if (typeof(view.render) !== 'undefined') innerRender = view.render;

          var shouldRenderLayout = view.layoutView ? true : false;
          view.render = function render() {
            // Walk up the view chain rendering layout views on the initial render
            if(shouldRenderLayout) {
              view.layoutView.render();
              shouldRenderLayout = false;
            }

            // Call the method that actually renders the view
            var innerRenderReturnValue = innerRender.call(this, arguments);

            // When a layout view is rendered it should attach it's child to it's content placeholder
            if (view.childView) {
              var contentPlaceholder = view.el.querySelector('#' + view.contentPlaceholderId);
              // IE8 workaround since el.innerHTML fails when an event is currently being triggered on it
              while (contentPlaceholder.firstChild) contentPlaceholder.removeChild(contentPlaceholder.firstChild);
              contentPlaceholder.appendChild(view.childView.el);
            }

            // Return the value from the original render method
            return innerRenderReturnValue;
          };

          // view.html(htmlString) -  replace `view.el`'s HTML with the htmlString
          view.html = function html(htmlString) {
            // IE8 workaround since el.innerHTML fails when an event is currently being triggered on it. Create a new element
            // and set innerHTML which will work since no event is occurring on this temp element.
            var a = document.createElement('div');
            a.innerHTML = htmlString;

            // Copy the contents of the temp element to a document fragment. This doesn't contain a wrapping div.
            var b = document.createDocumentFragment();
            while (a.firstChild) b.appendChild(a.firstChild);

            // Clear out view.el and attach the new HTML
            while (view.el.firstChild) view.el.removeChild(view.el.firstChild);
            view.el.appendChild(b);
          };
{'fraction_non_alphanumeric': 0.09813228132897737, 'fraction_numerical': 0.0011095358441718549, 'mean_word_length': 2.2241653418124008, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6016354', 'n_tokens_mistral': 4055, 'n_tokens_neox': 3900, 'n_words': 1613}