<commit_before>import declare from 'dojo/_base/declare';
import lang from 'dojo/_base/lang';
import getResource from 'argos/I18n';
import Application from 'argos/Application';
import ApplicationModule from 'argos/ApplicationModule';
import AccountAssociationModule from './Modules/AccountAssociationModule';
import AccountModule from './Modules/AccountModule';
import BillToAccountModule from './Modules/BillToAccountModule';
import BillToModule from './Modules/BillToModule';
import ContactModule from './Modules/ContactModule';
import ContactAssociationModule from './Modules/ContactAssociationModule';
import HelpModule from './Modules/HelpModule';
import InvoiceLineModule from './Modules/InvoiceLineModule';
import InvoiceModule from './Modules/InvoiceModule';
import OpportunityModule from './Modules/OpportunityModule';
import PayFromModule from './Modules/PayFromModule';
// import PicklistService from './PicklistService';
import ProductModule from './Modules/ProductModule';
import QuoteModule from './Modules/QuoteModule';
import QuotePersonModule from './Modules/QuotePersonModule';
import QuoteLineModule from './Modules/QuoteLineModule';
import ReceivableLineModule from './Modules/ReceivableLineModule';
import ReceivableModule from './Modules/ReceivableModule';
import ReturnLineModule from './Modules/ReturnLineModule';
import ReturnModule from './Modules/ReturnModule';
import SalesOrderItemModule from './Modules/SalesOrderItemModule';
import SalesOrderModule from './Modules/SalesOrderModule';
import ShipmentLineModule from './Modules/ShipmentLineModule';
import ShipmentModule from './Modules/ShipmentModule';
import ShipToAccountModule from './Modules/ShipToAccountModule';
import ShipToModule from './Modules/ShipToModule';
import RecentlyViewedList from '../../Views/RecentlyViewed/List';

import './Models/SyncResult/Offline';
import './Models/SyncResult/SData';
import './Models/BackOffice/Offline';
import './Models/BackOffice/SData';
import './Models/BackOfficeAccountingEntity/Offline';
import './Models/BackOfficeAccountingEntity/SData';
import './Models/Location/Offline';
import './Models/Location/SData';
import './Models/OperatingCompany/Offline';
import './Models/OperatingCompany/SData';
import './Models/UnitOfMeasure/Offline';
import './Models/UnitOfMeasure/SData';
import 'argos/TabWidget';

// const resource = getResource('icboeApplicationModule');

const __class = declare('crm.Integrations.BOE.ApplicationModule', [ApplicationModule], {
  modules: null,
  init: function init() {
    this.inherited(arguments);

    // App.picklistService = PicklistService;
    App.enableDashboards = this.enableDashboards;
    this.modules = [
      new AccountAssociationModule(this),
      new AccountModule(this),
      new BillToAccountModule(this),
      new BillToModule(this),
      new ContactModule(this),
      new ContactAssociationModule(this),
      new HelpModule(this),
      new InvoiceLineModule(this),
      new InvoiceModule(this),
      new OpportunityModule(this),
      new PayFromModule(this),
      new ProductModule(this),
      new QuoteModule(this),
      new QuotePersonModule(this),
      new QuoteLineModule(this),
      new ReceivableLineModule(this),
      new ReceivableModule(this),
      new ReturnLineModule(this),
      new ReturnModule(this),
      new SalesOrderItemModule(this),
      new SalesOrderModule(this),
      new ShipmentLineModule(this),
      new ShipmentModule(this),
      new ShipToAccountModule(this),
      new ShipToModule(this),
    ];

    this.modules.forEach((mod) => {
      mod.init();
    });
  },
  initDynamic: function init() {
    if (!this.isIntegrationEnabled()) {
      return;
    }

    this.modules.forEach((mod) => {
      mod.initDynamic();
    });

    this.inherited(arguments);
  },
  isIntegrationEnabled: function isIntegrationEnabled() {
    const results = this.application.context.integrations.filter(integration => integration.Name === 'Back Office Extension')[0];
    return results && results.Enabled;
  },
  loadViewsDynamic: function loadViewsDynamic() {
    if (!this.isIntegrationEnabled()) {
      return;
    }

    this.modules.forEach((module) => {
      module.loadViews();
    });
  },
  loadCustomizationsDynamic: function loadCustomizations() {
    if (!this.isIntegrationEnabled()) {
      return;
    }

    this.modules.forEach((module) => {
      module.loadCustomizations();
    });
    this.registerDefaultViews();

    lang.extend(argos._ListBase, { // TODO: Avoid global
      navigateToInsertView: function navigateToInsertView(el, additionalOptions) {
        const view = this.app.getView(this.insertView || this.editView);
        let options = {
          detailView: this.detailView,
          returnTo: this.id,
          insert: true,
        };

        // Pass along the selected entry (related list could get it from a quick action)
        if (this.options.selectedEntry) {
          options.selectedEntry = this.options.selectedEntry;
        }

        if (additionalOptions) {
          options = lang.mixin(options, additionalOptions);
        }

        if (view) {
          view.show(options);
        }
      },
    });

    lang.extend(argos._EditBase, {// TODO: Avoid global
      onInsertCompleted: function onInsertCompleted(entry) {
        if (this.options && this.options.detailView) {
          const view = App.getView(this.options.detailView);
          if (view) {
            view.show({
              key: entry.$key,
              title: entry.$descriptor,
              description: entry.$descriptor,
            }, {
              returnTo: -1,
            });
          }
        }
        if (this.options && this.options.returnTo) {
          const returnTo = this.options.returnTo;
          const view = App.getView(returnTo);
          if (view) {
            view.show();
          } else {
            window.location.hash = returnTo;
          }
        } else {
          ReUI.back();
        }
      },
    });

    lang.extend(crm.Views.MetricWidget, {
      itemTemplate: new Simplate([
        '
{%: $$.formatter($.value) %}
',
        '{%: $$.title %}',
      ]),
      setValueColor: function setValueColor(color) {
        this.valueColor = color;
      },
      getValueStyle: function getValueStyle() {
        if (this.valueColor) {
          return `style=color:${this.valueColor}`;
        }
        return '';
      },
    });

    lang.extend(argos.TabWidget, {// TODO: Avoid global
      tabListItemTemplate: new Simplate([
        '
',
        '{%: ($.title || $.options.title) %}',
        '
',
      ]),
    });

    // Recently viewed support
    const originalMappings = RecentlyViewedList.prototype.entityMappings;
    const originalText = RecentlyViewedList.prototype.entityText;

    RecentlyViewedList.prototype.entityText = Object.assign({}, originalText, {
      ERPShipment: getResource('erpShipmentModel').entityDisplayNamePlural,
      SalesOrder: getResource('salesOrderModel').entityDisplayNamePlural,
      ERPReceivable: getResource('erpReceivableModel').entityDisplayNamePlural,
      Quote: getResource('quoteModel').entityDisplayNamePlural,
      ERPInvoice: getResource('erpInvoiceModel').entityDisplayNamePlural,
    });

    RecentlyViewedList.prototype.entityMappings = Object.assign({}, originalMappings, {
      ERPShipment: {
        iconClass: 'warehouse',
      },
      SalesOrder: {
        iconClass: 'cart',
      },
      ERPReceivable: {
        iconClass: 'checkbox',
      },
      Quote: {
        iconClass: 'document',
      },
      ERPInvoice: {
        iconClass: 'document2',
      },
    });
  },
  loadToolbarsDynamic: function loadToolbars() {
    if (!this.isIntegrationEnabled()) {
      return;
    }

    this.modules.forEach((module) => {
      module.loadToolbars();
    });
  },
  loadAppStatePromises: function loadAppStatePromises() {
    this.inherited(arguments);
    // this.registerAppStatePromise({
    //   seq: 2,
    //   description: resource.picklistsText,
    //   items: [{
    //     name: 'picklist-requests',
    //     description: resource.retrievingPicklistsText,
    //     fn: () => {
    //       PicklistService.requestPicklists();
    //     },
    //   }],
    // });
  },
  registerDefaultViews: function registerDefaultViews() {
    const self = this;
    const originalGetDefaultViews = Application.prototype.getDefaultViews;
    lang.extend(Application, {
      getDefaultViews: function getDefaultViews() {
        const views = originalGetDefaultViews.apply(this, arguments) || [];
        self.modules.forEach((module) => {
          module.registerDefaultViews(views);
        });
        return views;
      },
    });
  },
});

lang.setObject('icboe.ApplicationModule', __class);
export default __class;
<commit_msg>INFORCRM-13585: Fix params passed to navigateToInsertView. Additional options is the first param, not the second. This was causing the element to get mixed into options, and not allowing the history state to be serialized.<commit_after>import declare from 'dojo/_base/declare';
import lang from 'dojo/_base/lang';
import getResource from 'argos/I18n';
import Application from 'argos/Application';
import ApplicationModule from 'argos/ApplicationModule';
import AccountAssociationModule from './Modules/AccountAssociationModule';
import AccountModule from './Modules/AccountModule';
import BillToAccountModule from './Modules/BillToAccountModule';
import BillToModule from './Modules/BillToModule';
import ContactModule from './Modules/ContactModule';
import ContactAssociationModule from './Modules/ContactAssociationModule';
import HelpModule from './Modules/HelpModule';
import InvoiceLineModule from './Modules/InvoiceLineModule';
import InvoiceModule from './Modules/InvoiceModule';
import OpportunityModule from './Modules/OpportunityModule';
import PayFromModule from './Modules/PayFromModule';
// import PicklistService from './PicklistService';
import ProductModule from './Modules/ProductModule';
import QuoteModule from './Modules/QuoteModule';
import QuotePersonModule from './Modules/QuotePersonModule';
import QuoteLineModule from './Modules/QuoteLineModule';
import ReceivableLineModule from './Modules/ReceivableLineModule';
import ReceivableModule from './Modules/ReceivableModule';
import ReturnLineModule from './Modules/ReturnLineModule';
import ReturnModule from './Modules/ReturnModule';
import SalesOrderItemModule from './Modules/SalesOrderItemModule';
import SalesOrderModule from './Modules/SalesOrderModule';
import ShipmentLineModule from './Modules/ShipmentLineModule';
import ShipmentModule from './Modules/ShipmentModule';
import ShipToAccountModule from './Modules/ShipToAccountModule';
import ShipToModule from './Modules/ShipToModule';
import RecentlyViewedList from '../../Views/RecentlyViewed/List';

import './Models/SyncResult/Offline';
import './Models/SyncResult/SData';
import './Models/BackOffice/Offline';
import './Models/BackOffice/SData';
import './Models/BackOfficeAccountingEntity/Offline';
import './Models/BackOfficeAccountingEntity/SData';
import './Models/Location/Offline';
import './Models/Location/SData';
import './Models/OperatingCompany/Offline';
import './Models/OperatingCompany/SData';
import './Models/UnitOfMeasure/Offline';
import './Models/UnitOfMeasure/SData';
import 'argos/TabWidget';

// const resource = getResource('icboeApplicationModule');

const __class = declare('crm.Integrations.BOE.ApplicationModule', [ApplicationModule], {
  modules: null,
  init: function init() {
    this.inherited(arguments);

    // App.picklistService = PicklistService;
    App.enableDashboards = this.enableDashboards;
    this.modules = [
      new AccountAssociationModule(this),
      new AccountModule(this),
      new BillToAccountModule(this),
      new BillToModule(this),
      new ContactModule(this),
      new ContactAssociationModule(this),
      new HelpModule(this),
      new InvoiceLineModule(this),
      new InvoiceModule(this),
      new OpportunityModule(this),
      new PayFromModule(this),
      new ProductModule(this),
      new QuoteModule(this),
      new QuotePersonModule(this),
      new QuoteLineModule(this),
      new ReceivableLineModule(this),
      new ReceivableModule(this),
      new ReturnLineModule(this),
      new ReturnModule(this),
      new SalesOrderItemModule(this),
      new SalesOrderModule(this),
      new ShipmentLineModule(this),
      new ShipmentModule(this),
      new ShipToAccountModule(this),
      new ShipToModule(this),
    ];

    this.modules.forEach((mod) => {
      mod.init();
    });
  },
  initDynamic: function init() {
    if (!this.isIntegrationEnabled()) {
      return;
    }

    this.modules.forEach((mod) => {
      mod.initDynamic();
    });

    this.inherited(arguments);
  },
  isIntegrationEnabled: function isIntegrationEnabled() {
    const results = this.application.context.integrations.filter(integration => integration.Name === 'Back Office Extension')[0];
    return results && results.Enabled;
  },
  loadViewsDynamic: function loadViewsDynamic() {
    if (!this.isIntegrationEnabled()) {
      return;
    }

    this.modules.forEach((module) => {
      module.loadViews();
    });
  },
  loadCustomizationsDynamic: function loadCustomizations() {
    if (!this.isIntegrationEnabled()) {
      return;
    }

    this.modules.forEach((module) => {
      module.loadCustomizations();
    });
    this.registerDefaultViews();

    lang.extend(argos._ListBase, { // TODO: Avoid global
      navigateToInsertView: function navigateToInsertView(additionalOptions) {
        const view = this.app.getView(this.insertView || this.editView);
        let options = {
          detailView: this.detailView,
          returnTo: this.id,
          insert: true,
        };

        // Pass along the selected entry (related list could get it from a quick action)
        if (this.options.selectedEntry) {
          options.selectedEntry = this.options.selectedEntry;
        }

        if (additionalOptions) {
          options = lang.mixin(options, additionalOptions);
        }

        if (view) {
          view.show(options);
        }
      },
    });

    lang.extend(argos._EditBase, {// TODO: Avoid global
      onInsertCompleted: function onInsertCompleted(entry) {
        if (this.options && this.options.detailView) {
          const view = App.getView(this.options.detailView);
          if (view) {
            view.show({
              key: entry.$key,
              title: entry.$descriptor,
              description: entry.$descriptor,
            }, {
              returnTo: -1,
            });
          }
        }
        if (this.options && this.options.returnTo) {
          const returnTo = this.options.returnTo;
          const view = App.getView(returnTo);
          if (view) {
            view.show();
          } else {
            window.location.hash = returnTo;
          }
        } else {
          ReUI.back();
        }
      },
    });

    lang.extend(crm.Views.MetricWidget, {
      itemTemplate: new Simplate([
        '
{%: $$.formatter($.value) %}
',
        '{%: $$.title %}',
      ]),
      setValueColor: function setValueColor(color) {
        this.valueColor = color;
      },
      getValueStyle: function getValueStyle() {
        if (this.valueColor) {
          return `style=color:${this.valueColor}`;
        }
        return '';
      },
    });

    lang.extend(argos.TabWidget, {// TODO: Avoid global
      tabListItemTemplate: new Simplate([
        '
',
        '{%: ($.title || $.options.title) %}',
        '
',
      ]),
    });

    // Recently viewed support
    const originalMappings = RecentlyViewedList.prototype.entityMappings;
    const originalText = RecentlyViewedList.prototype.entityText;

    RecentlyViewedList.prototype.entityText = Object.assign({}, originalText, {
      ERPShipment: getResource('erpShipmentModel').entityDisplayNamePlural,
      SalesOrder: getResource('salesOrderModel').entityDisplayNamePlural,
      ERPReceivable: getResource('erpReceivableModel').entityDisplayNamePlural,
      Quote: getResource('quoteModel').entityDisplayNamePlural,
      ERPInvoice: getResource('erpInvoiceModel').entityDisplayNamePlural,
    });

    RecentlyViewedList.prototype.entityMappings = Object.assign({}, originalMappings, {
      ERPShipment: {
        iconClass: 'warehouse',
      },
      SalesOrder: {
        iconClass: 'cart',
      },
      ERPReceivable: {
        iconClass: 'checkbox',
      },
      Quote: {
        iconClass: 'document',
      },
      ERPInvoice: {
        iconClass: 'document2',
      },
    });
  },
  loadToolbarsDynamic: function loadToolbars() {
    if (!this.isIntegrationEnabled()) {
      return;
    }

    this.modules.forEach((module) => {
      module.loadToolbars();
    });
  },
  loadAppStatePromises: function loadAppStatePromises() {
    this.inherited(arguments);
    // this.registerAppStatePromise({
    //   seq: 2,
    //   description: resource.picklistsText,
    //   items: [{
    //     name: 'picklist-requests',
    //     description: resource.retrievingPicklistsText,
    //     fn: () => {
    //       PicklistService.requestPicklists();
    //     },
    //   }],
    // });
  },
  registerDefaultViews: function registerDefaultViews() {
    const self = this;
    const originalGetDefaultViews = Application.prototype.getDefaultViews;
    lang.extend(Application, {
      getDefaultViews: function getDefaultViews() {
        const views = originalGetDefaultViews.apply(this, arguments) || [];
        self.modules.forEach((module) => {
          module.registerDefaultViews(views);
        });
        return views;
      },
    });
  },
});

lang.setObject('icboe.ApplicationModule', __class);
export default __class;
<|endoftext|>


<commit_before>/// <reference path="/umbraco_client/Application/NamespaceManager.js" />

Umbraco.Sys.registerNamespace("Umbraco.Controls");

(function($) {
    Umbraco.Controls.TreePicker = function(clientId, label, itemIdValueClientID, itemTitleClientID, itemPickerUrl, width, height, showHeader, umbracoPath) {
        var obj = {
            _itemPickerUrl: itemPickerUrl,
            _webServiceUrl: umbracoPath + "/webservices/legacyAjaxCalls.asmx/GetNodeBreadcrumbs",
            _label: label,
            _width: width,
            _height: height,
            _itemIdValueClientID: itemIdValueClientID,
            _itemTitleClientID: itemTitleClientID,
            _showHeader: showHeader,
            _clientId: clientId,

            GetValue: function() {
                return $("#" + this._itemIdValueClientID).val();
            },

            LaunchPicker: function() {
                var _this = this;
                UmbClientMgr.openModalWindow(this._itemPickerUrl, this._label, this._showHeader, this._width, this._height, 60, 0, ['#cancelbutton'], function(e) { _this.SaveSelection(e); });
            },

            SaveSelection: function(e) {
                if (!e.outVal) {
                    return;
                }
                $("#" + this._itemIdValueClientID).val(e.outVal);
                var _this = this;
                $.ajax({
                    type: "POST",
                    url: _this._webServiceUrl,
                    data: '{ "nodeId": ' + e.outVal + ' }',
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function(msg) {
                        var a = msg.d;
                        var name = a[a.length - 1];
                        var breadcrumbs = a.join(" > ");
                        $("#" + _this._itemTitleClientID)
                            .html(name)
                            .attr('title', breadcrumbs)
                            .parent()
                                .show();
                    }
                });
            },

            ClearSelection: function() {
                $("#" + this._itemTitleClientID)
                    .attr('title', '')
                    .parent()
                        .hide();
                $("#" + this._itemIdValueClientID).val('');
            }
        };

        //store this instance (by counter and id) so we can retrieve it later if needed
        Umbraco.Controls.TreePicker.inst[++Umbraco.Controls.TreePicker.cntr] = obj;
        Umbraco.Controls.TreePicker.inst[clientId] = obj;

        return obj;
    };

    $(document).ready(function () {
        // Tooltip only Text
        $('.treePickerTitle').hover(function () {
            // Hover over code
            var title = $(this).attr('title');
            $(this).data('tipText', title).removeAttr('title');
            $('

').text(title).appendTo('body').fadeIn('fast');;
        }, function () {
            // Hover out code
            $(this).attr('title', $(this).data('tipText'));
            $('.treePickerTooltip').remove();
        }).mousemove(function (e) {
            var mousex = e.pageX + 10; //Get X coordinates
            var mousey = e.pageY + 5; //Get Y coordinates
            $('.treePickerTooltip').css({ top: mousey, left: mousex });
        });
    });

    // Static methods

    //return the existing picker object based on client id of the control
    Umbraco.Controls.TreePicker.GetPickerById = function(id) {
        return Umbraco.Controls.TreePicker.inst[id] || null;
    };

    // instance manager
    Umbraco.Controls.TreePicker.cntr = 0;
    Umbraco.Controls.TreePicker.inst = {};

})(jQuery);
<commit_msg>Add z-index too treePickerToolTip to get it on top when media picker preview is on<commit_after>/// <reference path="/umbraco_client/Application/NamespaceManager.js" />

Umbraco.Sys.registerNamespace("Umbraco.Controls");

(function($) {
    Umbraco.Controls.TreePicker = function(clientId, label, itemIdValueClientID, itemTitleClientID, itemPickerUrl, width, height, showHeader, umbracoPath) {
        var obj = {
            _itemPickerUrl: itemPickerUrl,
            _webServiceUrl: umbracoPath + "/webservices/legacyAjaxCalls.asmx/GetNodeBreadcrumbs",
            _label: label,
            _width: width,
            _height: height,
            _itemIdValueClientID: itemIdValueClientID,
            _itemTitleClientID: itemTitleClientID,
            _showHeader: showHeader,
            _clientId: clientId,

            GetValue: function() {
                return $("#" + this._itemIdValueClientID).val();
            },

            LaunchPicker: function() {
                var _this = this;
                UmbClientMgr.openModalWindow(this._itemPickerUrl, this._label, this._showHeader, this._width, this._height, 60, 0, ['#cancelbutton'], function(e) { _this.SaveSelection(e); });
            },

            SaveSelection: function(e) {
                if (!e.outVal) {
                    return;
                }
                $("#" + this._itemIdValueClientID).val(e.outVal);
                var _this = this;
                $.ajax({
                    type: "POST",
                    url: _this._webServiceUrl,
                    data: '{ "nodeId": ' + e.outVal + ' }',
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function(msg) {
                        var a = msg.d;
                        var name = a[a.length - 1];
                        var breadcrumbs = a.join(" > ");
                        $("#" + _this._itemTitleClientID)
                            .html(name)
                            .attr('title', breadcrumbs)
                            .parent()
                                .show();
                    }
                });
            },

            ClearSelection: function() {
                $("#" + this._itemTitleClientID)
                    .attr('title', '')
                    .parent()
                        .hide();
                $("#" + this._itemIdValueClientID).val('');
            }
        };

        //store this instance (by counter and id) so we can retrieve it later if needed
        Umbraco.Controls.TreePicker.inst[++Umbraco.Controls.TreePicker.cntr] = obj;
        Umbraco.Controls.TreePicker.inst[clientId] = obj;

        return obj;
    };

    $(document).ready(function () {
        // Tooltip only Text
        $('.treePickerTitle').hover(function () {
            // Hover over code
            var title = $(this).attr('title');
            $(this).data('tipText', title).removeAttr('title');
            $('

').text(title).appendTo('body').fadeIn('fast');;
        }, function () {
            // Hover out code
            $(this).attr('title', $(this).data('tipText'));
            $('.treePickerTooltip').remove();
        }).mousemove(function (e) {
            var mousex = e.pageX + 10; //Get X coordinates
            var mousey = e.pageY + 5; //Get Y coordinates
            $('.treePickerTooltip').css({ top: mousey, left: mousex });
        });
    });

    // Static methods

    //return the existing picker object based on client id of the control
    Umbraco.Controls.TreePicker.GetPickerById = function(id) {
        return Umbraco.Controls.TreePicker.inst[id] || null;
    };

    // instance manager
    Umbraco.Controls.TreePicker.cntr = 0;
    Umbraco.Controls.TreePicker.inst = {};

})(jQuery);
<|endoftext|>


<commit_before>// +-+-+-+-+ +-+-+-+-+-+-+-+-+-+ +-+-+-+-+
// |V|A|S|T| |C|H|A|L|L|E|N|G|E| |2|0|1|7|
// +-+-+-+-+ +-+-+-+-+-+-+-+-+-+ +-+-+-+-+
// PETER VAN TWUYVER, 10872809
// MINOR PROGRAMMEREN UVA 2017
// +-+-+-+-+ +-+-+-+-+-+-+-+-+-+ +-+-+-+-+
function onRectClicked(item) {
    console.log(item);
}
window.onload = function() {
 getOption();
};
// get User selection and select appropriate function to draw svg's
function getOption() {
    var obj = document.getElementById("mySelect");
    if (obj.value == "Campsites") {
      showCampings();
    }
    if (obj.value == "Entrances") {
      console.log("drawEntrances")
    }
    if (obj.value == "Total") {
      showTotal();
    }
}

// show all traffic in te parc, type specific details
function showTotal(){
    // main calendar
    showData("data/busyness_by_type.csv");
    // type-calendars
    var all_types = ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Ranger'];
    // send data from each row to Draw function
    all_types.forEach(function(item) {
     drawType(item);
    });
}

// show all traffic in the campings
function showCampings(){
    //showData("data/fake_all_camps.csv");
    showData("data/all_camps.csv");
    // type-calendars
    //var all_types = ['CampsiteOne','CampsiteTwo','CampsiteThree','CampsiteFour','CampsiteFive','CampsiteSix','CampsiteSeven'];
    var all_types = ['camping0','camping1','camping2','camping3','camping4','camping5','camping6', 'camping7','camping8'];
    // send data from each row to Draw function
    all_types.forEach(function(item) {
     drawLocations(item);
    });
}

// show all traffic at the Entrances
function showEntrances(){
    // add Entrance 1, 2 etc
}

// bind data based on csv file chosen
function showData(csv_file_name) {
    d3.csv(csv_file_name, function(error, csv) {
        if (error) throw error;

        console.log("Read: " + csv_file_name);

        var data = d3.nest()
            .key(function(d) {
                return d.Day;
            })
            .rollup(function(v) {
                // console.log(d3.sum(v, function(d) { return d.Total; }))
                return d3.sum(v, function(d) { return d.Total; });
                //return (d[0].Total)

            })
            .object(csv);
        drawTotalCalendar(data);

        });
}

// draw the main calendar
function drawTotalCalendar(my_data) {

    var width = 960,
        height = 136,
        cellSize = 17;
    // set colorgradient for min/max values
    var max = d3.max(d3.values(my_data));
    var min = d3.min(d3.values(my_data));
    console.log("min/max in Total: ",min,max)
    var color = d3.scaleLinear()
        .domain([min, max])
        .range(["#fee0d2", "#de2d26"]);

    // Root SVG objects within #calendar div
    var cal = d3.select("#calendar")
        .selectAll("svg")
        .data(d3.range(2015, 2017)); // range of years

    cal.exit().remove();

    var svg = cal.enter().append("svg")
        .attr("width", width)
        .attr("height", height)
        .append("g")
        .attr("transform", "translate(" + ((width - cellSize * 53) / 2) + "," + (height - cellSize * 7 - 1) + ")");

    // Defines test for year in calendar
    svg.append("text")
        .attr("transform", "translate(-6," + cellSize * 3.5 + ")rotate(-90)")
        .attr("font-family", "sans-serif")
        .attr("font-size", 10)
        .attr("text-anchor", "middle")
        .text(function(d) {
            return d;
        });

    svg.append("text")
        .attr("font-family", "sans-serif")
        .attr("font-size", 15)
        .attr('x', 10)
        .attr('y', -5)
        .attr("text-anchor", "under")
        .text("Number of unique vehicles ");

    var rectSelect = svg.append("g")
        .attr("fill", "none")
        .attr("stroke", "#ccc")
        .selectAll("rect")
        .data(function(year) {
            return d3.timeDays(new Date(year, 0, 1), new Date(year + 1, 0, 1));
        });

    var rect = rectSelect
        .enter().append("rect")
        .attr("width", cellSize)
        .attr("height", cellSize)
        .attr("x", function(d) {
            return d3.timeWeek.count(d3.timeYear(d), d) * cellSize;
        })
        .attr("y", function(d) {
            return d.getDay() * cellSize;
        })
        .datum(d3.timeFormat("%d/%m/%Y"))
        .on('click', onRectClicked)
        .append('title');

    svg.append("g")
        .attr("fill", "none")
        .attr("stroke", "#000")
        .selectAll("path")
        .data(function(d) {
            return d3.timeMonths(new Date(d, 0, 1), new Date(d + 1, 0, 1));
        })
        .enter().append("path")
        .attr("d", pathMonth);

   d3.select("#calendar").selectAll("rect")
   .attr("fill", function(d) {

                if(d in my_data) {
                      return color(my_data[d]);
                }
                else {
                    return "blue";
                }

            })
    .select("title")
            .text(function(d) {
                if(d in my_data) {
                    return d + ": " + my_data[d];
                }
                else {
                    return "No data";
                }

             });

    // create visual line separating months
    function pathMonth(t0) {
        var t1 = new Date(t0.getFullYear(), t0.getMonth() + 1, 0),
            d0 = t0.getDay(),
            w0 = d3.timeWeek.count(d3.timeYear(t0), t0),
            d1 = t1.getDay(),
            w1 = d3.timeWeek.count(d3.timeYear(t1), t1);
        return "M" + (w0 + 1) * cellSize + "," + d0 * cellSize +
            "H" + w0 * cellSize + "V" + 7 * cellSize +
            "H" + w1 * cellSize + "V" + (d1 + 1) * cellSize +
            "H" + (w1 + 1) * cellSize + "V" + 0 +
            "H" + (w0 + 1) * cellSize + "Z";
    }
};

// draws the sub-calendars
function drawType(which_type) {
    var width = 560,
        height = 136,
        cellSize = 10;

    // append sub-calendars under the main calendar
    var root = d3.select('#subcalendar').append('div');

    var svg = root
        .selectAll("svg")
        .data(d3.range(2015, 2017))
        .enter().append("svg")
        .attr("width", width)
        .attr("height", height)
        .append("g")
        .attr("transform", "translate(" + ((width - cellSize * 53) / 2) + "," + (height - cellSize * 7 - 1) + ")");

    svg.append("text")
        .attr("transform", "translate(-6," + cellSize * 3.5 + ")rotate(-90)")
        .attr("font-family", "sans-serif")
        .attr("font-size", 10)
        .attr("text-anchor", "middle")
        .text(function(d) {
            return d;
        });

    svg.append("text")
        .attr("font-family", "sans-serif")
        .attr("font-size", 15)
        .attr('x', 10)
        .attr('y', -5)
        .attr("text-anchor", "under")
        .text("Total moving vehicles of Type "+ which_type);

    var rect = svg.append("g")
        .attr("fill", "none")
        .attr("stroke", "#ccc")
        .selectAll("rect")
        .data(function(d) {
            return d3.timeDays(new Date(d, 0, 1), new Date(d + 1, 0, 1));
        })
        .enter().append("rect")
        .attr("width", cellSize)
        .attr("height", cellSize)
        .attr("x", function(d) {
            return d3.timeWeek.count(d3.timeYear(d), d) * cellSize;
        })
        .attr("y", function(d) {
            return d.getDay() * cellSize;
        })
        .datum(d3.timeFormat("%d/%m/%Y"))
        .on('click', onRectClicked);

    svg.append("g")
        .attr("fill", "none")
        .attr("stroke", "#000")
        .selectAll("path")
        .data(function(d) {
            return d3.timeMonths(new Date(d, 0, 1), new Date(d + 1, 0, 1));
        })
        .enter().append("path")
        .attr("d", pathMonth);

    d3.csv("data/busyness_by_type.csv", function(error, csv) {
        if (error) throw error;

        var data = d3.nest()
            .key(function(d) {
                console.log(d.Day)
                return d.Day;
            })
            .rollup(function(d) {
                return parseInt(d[0][which_type])
            })
            .object(csv);
     console.log("data in Types: ", data)

// set colorgradient for min/max values
    var max = d3.max(d3.values(data));
    var min = d3.min(d3.values(data));
console.log("min/max for type "+which_type,min,max)

    var color = d3.scaleLinear()
        .domain([min, max])
        .range(["#fee0d2", "#de2d26"]);

        rect.filter(function(d) {
                return d in data;
            })
            .attr("fill", function(d) {
                return color(data[d]);
            })
            .append("title")
            .text(function(d) {
                return d + ": " + data[d];
            });
    });

    function pathMonth(t0) {
        var t1 = new Date(t0.getFullYear(), t0.getMonth() + 1, 0),
            d0 = t0.getDay(),
            w0 = d3.timeWeek.count(d3.timeYear(t0), t0),
            d1 = t1.getDay(),
            w1 = d3.timeWeek.count(d3.timeYear(t1), t1);
        return "M" + (w0 + 1) * cellSize + "," + d0 * cellSize +
            "H" + w0 * cellSize + "V" + 7 * cellSize +
            "H" + w1 * cellSize + "V" + (d1 + 1) * cellSize +
            "H" + (w1 + 1) * cellSize + "V" + 0 +
            "H" + (w0 + 1) * cellSize + "Z";
    }
};

// draws the sub-calendars
function drawLocations(which_location) {

    var width = 560,
        height = 136,
        cellSize = 10;

    var color = d3.scaleLinear()
        .domain([0, 122]) // MUST BE RELATIVE TO MIN AND MAX
        .range(["#fee0d2", "#de2d26"]);

    // append sub-calendars under the main calendar
    var root = d3.select('#subcalendar').append('div');

    var svg = root
        .selectAll("svg")
        .data(d3.range(2015, 2017))
        .enter().append("svg")
        .attr("width", width)
        .attr("height", height)
        .append("g")
        .attr("transform", "translate(" + ((width - cellSize * 53) / 2) + "," + (height - cellSize * 7 - 1) + ")");

    svg.append("text")
        .attr("transform", "translate(-6," + cellSize * 3.5 + ")rotate(-90)")
        .attr("font-family", "sans-serif")
        .attr("font-size", 10)
        .attr("text-anchor", "middle")
        .text(function(d) {
            return d;
        });

    svg.append("text")
        .attr("font-family", "sans-serif")
        .attr("font-size", 15)
        .attr('x', 10)
        .attr('y', -5)
        .attr("text-anchor", "under")
        .text("Moving vehicles in "+ which_location);

    var rect = svg.append("g")
        .attr("fill", "none")
        .attr("stroke", "#ccc")
        .selectAll("rect")
        .data(function(d) {
            return d3.timeDays(new Date(d, 0, 1), new Date(d + 1, 0, 1));
        })
        .enter().append("rect")
        .attr("width", cellSize)
        .attr("height", cellSize)
        .attr("x", function(d) {
            return d3.timeWeek.count(d3.timeYear(d), d) * cellSize;
        })
        .attr("y", function(d) {
            return d.getDay() * cellSize;
        })
        .datum(d3.timeFormat("%d/%m/%Y"))
        .on('click', onRectClicked);

    svg.append("g")
        .attr("fill", "none")
        .attr("stroke", "#000")
        .selectAll("path")
        .data(function(d) {
            return d3.timeMonths(new Date(d, 0, 1), new Date(d + 1, 0, 1));
        })
        .enter().append("path")
        .attr("d", pathMonth);

    d3.csv("data/busylocations.csv", function(error, csv) {
        if (error) throw error;

        var data = d3.nest()
            .key(function(d) {
                console.log(d.Day.length)
                if(d.Day.length == 8) {
                    return d.Day.substring(0,6) + "20" + d.Day.substring(6,8);
                }

                return d.Day;
            })
            .rollup(function(d) {

                return parseInt(d[0][which_location])
            })
            .object(csv);
     console.log("data in Locations: ", data)
// set colorgradient for min/max values
    var max = d3.max(d3.values(data));
    var min = d3.min(d3.values(data));
console.log("min/max for type "+which_location,min,max)

    var color = d3.scaleLinear()
        .domain([min, max])
        .range(["#fee0d2", "#de2d26"]);

        rect.filter(function(d) {
                return d in data;
            })
            .attr("fill", function(d) {
                return color(data[d]);
            })
            .append("title")
            .text(function(d) {
                return d + ": " + data[d];
            });
    });

    function pathMonth(t0) {
        var t1 = new Date(t0.getFullYear(), t0.getMonth() + 1, 0),
            d0 = t0.getDay(),
            w0 = d3.timeWeek.count(d3.timeYear(t0), t0),
            d1 = t1.getDay(),
            w1 = d3.timeWeek.count(d3.timeYear(t1), t1);
        return "M" + (w0 + 1) * cellSize + "," + d0 * cellSize +
            "H" + w0 * cellSize + "V" + 7 * cellSize +
            "H" + w1 * cellSize + "V" + (d1 + 1) * cellSize +
            "H" + (w1 + 1) * cellSize + "V" + 0 +
            "H" + (w0 + 1) * cellSize + "Z";
    }
};<commit_msg>style update<commit_after>// +-+-+-+-+ +-+-+-+-+-+-+-+-+-+ +-+-+-+-+
// |V|A|S|T| |C|H|A|L|L|E|N|G|E| |2|0|1|7|
// +-+-+-+-+ +-+-+-+-+-+-+-+-+-+ +-+-+-+-+
// PETER VAN TWUYVER, 10872809
// MINOR PROGRAMMEREN UVA 2017
// +-+-+-+-+ +-+-+-+-+-+-+-+-+-+ +-+-+-+-+
function onRectClicked(item) {
    console.log(item);
}
window.onload = function() {
    getOption();
};
// get User selection and select appropriate function to draw svg's
function getOption() {
    var obj = document.getElementById("mySelect");
    if (obj.value == "Campsites") {
        //showData("data/fake_all_camps.csv");
        showData("data/all_camps.csv");
        // type-calendars
        //var all_types = ['CampsiteOne','CampsiteTwo','CampsiteThree','CampsiteFour','CampsiteFive','CampsiteSix','CampsiteSeven'];
        var all_types = ['camping0', 'camping1', 'camping2', 'camping3', 'camping4', 'camping5', 'camping6', 'camping7', 'camping8'];
        // send data from each row to Draw function
        all_types.forEach(function(item) {
            drawLocations(item);
        });
    }
    if (obj.value == "Entrances") {
        console.log("drawEntrances")
    }
    if (obj.value == "Total") {
        // main calendar
        showData("data/busyness_by_type.csv");
        // type-calendars
        var all_types = ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Ranger'];
        // send data from each row to Draw function
        all_types.forEach(function(item) {
            drawType(item);
        });
    }
}

// bind data based on csv file chosen
function showData(csv_file_name) {
    d3.csv(csv_file_name, function(error, csv) {
        if (error) throw error;

        console.log("Read: " + csv_file_name);

        var data = d3.nest()
            .key(function(d) {
                return d.Day;
            })
            .rollup(function(v) {
                // console.log(d3.sum(v, function(d) { return d.Total; }))
                return d3.sum(v, function(d) {
                    return d.Total;
                });
                //return (d[0].Total)

            })
            .object(csv);
        drawTotalCalendar(data);

    });
}

// draw the main calendar
function drawTotalCalendar(my_data) {

    var width = 960,
        height = 136,
        cellSize = 17;
    // set colorgradient for min/max values
    var max = d3.max(d3.values(my_data));
    var min = d3.min(d3.values(my_data));
    console.log("min/max in Total: ", min, max)
    var color = d3.scaleLinear()
        .domain([min, max])
        .range(["#fee0d2", "#de2d26"]);

    // Root SVG objects within #calendar div
    var cal = d3.select("#calendar")
        .selectAll("svg")
        .data(d3.range(2015, 2017)); // range of years

    cal.exit().remove();

    var svg = cal.enter().append("svg")
        .attr("width", width)
        .attr("height", height)
        .append("g")
        .attr("transform", "translate(" + ((width - cellSize * 53) / 2) + "," + (height - cellSize * 7 - 1) + ")");

    // Defines test for year in calendar
    svg.append("text")
        .attr("transform", "translate(-6," + cellSize * 3.5 + ")rotate(-90)")
        .attr("font-family", "sans-serif")
        .attr("font-size", 10)
        .attr("text-anchor", "middle")
        .text(function(d) {
            return d;
        });

    svg.append("text")
        .attr("font-family", "sans-serif")
        .attr("font-size", 15)
        .attr('x', 10)
        .attr('y', -5)
        .attr("text-anchor", "under")
        .text("Number of unique vehicles ");

    var rectSelect = svg.append("g")
        .attr("fill", "none")
        .attr("stroke", "#ccc")
        .selectAll("rect")
        .data(function(year) {
            return d3.timeDays(new Date(year, 0, 1), new Date(year + 1, 0, 1));
        });

    var rect = rectSelect
        .enter().append("rect")
        .attr("width", cellSize)
        .attr("height", cellSize)
        .attr("x", function(d) {
            return d3.timeWeek.count(d3.timeYear(d), d) * cellSize;
        })
        .attr("y", function(d) {
            return d.getDay() * cellSize;
        })
        .datum(d3.timeFormat("%d/%m/%Y"))
        .on('click', onRectClicked)
        .append('title');

    svg.append("g")
        .attr("fill", "none")
        .attr("stroke", "#000")
        .selectAll("path")
        .data(function(d) {
            return d3.timeMonths(new Date(d, 0, 1), new Date(d + 1, 0, 1));
        })
        .enter().append("path")
        .attr("d", pathMonth);

    d3.select("#calendar").selectAll("rect")
        .attr("fill", function(d) {

            if (d in my_data) {
                return color(my_data[d]);
            } else {
                return "blue";
            }

        })
        .select("title")
        .text(function(d) {
            if (d in my_data) {
                return d + ": " + my_data[d];
            } else {
                return "No data";
            }

        });

    // create visual line separating months
    function pathMonth(t0) {
        var t1 = new Date(t0.getFullYear(), t0.getMonth() + 1, 0),
            d0 = t0.getDay(),
            w0 = d3.timeWeek.count(d3.timeYear(t0), t0),
            d1 = t1.getDay(),
            w1 = d3.timeWeek.count(d3.timeYear(t1), t1);
        return "M" + (w0 + 1) * cellSize + "," + d0 * cellSize +
            "H" + w0 * cellSize + "V" + 7 * cellSize +
            "H" + w1 * cellSize + "V" + (d1 + 1) * cellSize +
            "H" + (w1 + 1) * cellSize + "V" + 0 +
            "H" + (w0 + 1) * cellSize + "Z";
    }
};

// draws the sub-calendars
function drawType(which_type) {
    var width = 560,
        height = 136,
        cellSize = 10;

    // append sub-calendars under the main calendar
    var root = d3.select('#subcalendar').append('div');

    var svg = root
        .selectAll("svg")
        .data(d3.range(2015, 2017))
        .enter().append("svg")
        .attr("width", width)
        .attr("height", height)
        .append("g")
        .attr("transform", "translate(" + ((width - cellSize * 53) / 2) + "," + (height - cellSize * 7 - 1) + ")");

    svg.append("text")
        .attr("transform", "translate(-6," + cellSize * 3.5 + ")rotate(-90)")
        .attr("font-family", "sans-serif")
        .attr("font-size", 10)
        .attr("text-anchor", "middle")
        .text(function(d) {
            return d;
        });

    svg.append("text")
        .attr("font-family", "sans-serif")
        .attr("font-size", 15)
        .attr('x', 10)
        .attr('y', -5)
        .attr("text-anchor", "under")
        .text("Total moving vehicles of Type " + which_type);

    var rect = svg.append("g")
        .attr("fill", "none")
        .attr("stroke", "#ccc")
        .selectAll("rect")
        .data(function(d) {
            return d3.timeDays(new Date(d, 0, 1), new Date(d + 1, 0, 1));
        })
        .enter().append("rect")
        .attr("width", cellSize)
        .attr("height", cellSize)
        .attr("x", function(d) {
            return d3.timeWeek.count(d3.timeYear(d), d) * cellSize;
        })
        .attr("y", function(d) {
            return d.getDay() * cellSize;
        })
        .datum(d3.timeFormat("%d/%m/%Y"))
        .on('click', onRectClicked);

    svg.append("g")
        .attr("fill", "none")
        .attr("stroke", "#000")
        .selectAll("path")
        .data(function(d) {
            return d3.timeMonths(new Date(d, 0, 1), new Date(d + 1, 0, 1));
        })
        .enter().append("path")
        .attr("d", pathMonth);

    d3.csv("data/busyness_by_type.csv", function(error, csv) {
        if (error) throw error;

        var data = d3.nest()
            .key(function(d) {

                return d.Day;
            })
            .rollup(function(d) {
                return parseInt(d[0][which_type])
            })
            .object(csv);
        console.log("data in Types: ", data)

        // set colorgradient for min/max values
        var max = d3.max(d3.values(data));
        var min = d3.min(d3.values(data));
        console.log("min/max for type " + which_type, min, max)

        var color = d3.scaleLinear()
            .domain([min, max])
            .range(["#fee0d2", "#de2d26"]);

        rect.filter(function(d) {
                return d in data;
            })
            .attr("fill", function(d) {
                return color(data[d]);
            })
            .append("title")
            .text(function(d) {
                return d + ": " + data[d];
            });
    });

    function pathMonth(t0) {
        var t1 = new Date(t0.getFullYear(), t0.getMonth() + 1, 0),
            d0 = t0.getDay(),
            w0 = d3.timeWeek.count(d3.timeYear(t0), t0),
            d1 = t1.getDay(),
            w1 = d3.timeWeek.count(d3.timeYear(t1), t1);
        return "M" + (w0 + 1) * cellSize + "," + d0 * cellSize +
            "H" + w0 * cellSize + "V" + 7 * cellSize +
            "H" + w1 * cellSize + "V" + (d1 + 1) * cellSize +
            "H" + (w1 + 1) * cellSize + "V" + 0 +
            "H" + (w0 + 1) * cellSize + "Z";
    }
};

// draws the sub-calendars
function drawLocations(which_location) {

    var width = 560,
        height = 136,
        cellSize = 10;

    var color = d3.scaleLinear()
        .domain([0, 122]) // MUST BE RELATIVE TO MIN AND MAX
        .range(["#fee0d2", "#de2d26"]);

    // append sub-calendars under the main calendar
    var root = d3.select('#subcalendar').append('div');

    var svg = root
        .selectAll("svg")
        .data(d3.range(2015, 2017))
        .enter().append("svg")
        .attr("width", width)
        .attr("height", height)
        .append("g")
        .attr("transform", "translate(" + ((width - cellSize * 53) / 2) + "," + (height - cellSize * 7 - 1) + ")");

    svg.append("text")
        .attr("transform", "translate(-6," + cellSize * 3.5 + ")rotate(-90)")
        .attr("font-family", "sans-serif")
        .attr("font-size", 10)
        .attr("text-anchor", "middle")
        .text(function(d) {
            return d;
        });

    svg.append("text")
        .attr("font-family", "sans-serif")
        .attr("font-size", 15)
        .attr('x', 10)
        .attr('y', -5)
        .attr("text-anchor", "under")
        .text("Moving vehicles in " + which_location);

    var rect = svg.append("g")
        .attr("fill", "none")
        .attr("stroke", "#ccc")
        .selectAll("rect")
        .data(function(d) {
            return d3.timeDays(new Date(d, 0, 1), new Date(d + 1, 0, 1));
        })
        .enter().append("rect")
        .attr("width", cellSize)
        .attr("height", cellSize)
        .attr("x", function(d) {
            return d3.timeWeek.count(d3.timeYear(d), d) * cellSize;
        })
        .attr("y", function(d) {
            return d.getDay() * cellSize;
        })
        .datum(d3.timeFormat("%d/%m/%Y"))
        .on('click', onRectClicked);

    svg.append("g")
        .attr("fill", "none")
        .attr("stroke", "#000")
        .selectAll("path")
        .data(function(d) {
            return d3.timeMonths(new Date(d, 0, 1), new Date(d + 1, 0, 1));
        })
        .enter().append("path")
        .attr("d", pathMonth);

    d3.csv("data/busylocations.csv", function(error, csv) {
        if (error) throw error;

        var data = d3.nest()
            .key(function(d) {

                if (d.Day.length == 8) {
                    return d.Day.substring(0, 6) + "20" + d.Day.substring(6, 8);
                }

                return d.Day;
            })
            .rollup(function(d) {

                return parseInt(d[0][which_location])
            })
            .object(csv);
        console.log("data in Locations: ", data)
        // set colorgradient for min/max values
        var max = d3.max(d3.values(data));
        var min = d3.min(d3.values(data));
        console.log("min/max for type " + which_location, min, max)

        var color = d3.scaleLinear()
            .domain([min, max])
            .range(["#fee0d2", "#de2d26"]);

        rect.filter(function(d) {
                return d in data;
            })
            .attr("fill", function(d) {
                return color(data[d]);
            })
            .append("title")
            .text(function(d) {
                return d + ": " + data[d];
            });
    });

    function pathMonth(t0) {
        var t1 = new Date(t0.getFullYear(), t0.getMonth() + 1, 0),
            d0 = t0.getDay(),
            w0 = d3.timeWeek.count(d3.timeYear(t0), t0),
            d1 = t1.getDay(),
            w1 = d3.timeWeek.count(d3.timeYear(t1), t1);
        return "M" + (w0 + 1) * cellSize + "," + d0 * cellSize +
            "H" + w0 * cellSize + "V" + 7 * cellSize +
            "H" + w1 * cellSize + "V" + (d1 + 1) * cellSize +
            "H" + (w1 + 1) * cellSize + "V" + 0 +
            "H" + (w0 + 1) * cellSize + "Z";
    }
};<|endoftext|>


<commit_before>var path = require('path'),
    fs = require('fs');

module.exports = function(context) {
    var et = context.requireCordovaModule('elementtree'),
        manifestPath = path.join(context.opts.projectRoot, 'platforms', 'android', 'AndroidManifest.xml'),
        manifestContents = fs.readFileSync(manifestPath, { encoding: 'utf8' }),
        manifest = et.parse(manifestContents),
        versionCode = manifest.getroot().get('android:versionCode') + '',
        buildExtrasPath = path.join(context.opts.projectRoot, 'platforms', 'android', 'build-extras.gradle');

    if (context.opts.cordova.plugins.indexOf('cordova-plugin-crosswalk-webview') === -1) {
        versionCode += '0'
    }
    var data = fs.readFileSync(buildExtrasPath)
    fs.writeFileSync(buildExtrasPath, data+"\next.cdvVersionCode=" + versionCode, { encoding: 'utf8' });
};
<commit_msg>keep version code as per config<commit_after>var path = require('path'),
    fs = require('fs');

module.exports = function(context) {
    var et = context.requireCordovaModule('elementtree'),
        manifestPath = path.join(context.opts.projectRoot, 'platforms', 'android', 'AndroidManifest.xml'),
        manifestContents = fs.readFileSync(manifestPath, { encoding: 'utf8' }),
        manifest = et.parse(manifestContents),
        versionCode = manifest.getroot().get('android:versionCode') + '',
        buildExtrasPath = path.join(context.opts.projectRoot, 'platforms', 'android', 'build-extras.gradle');

    if (context.opts.cordova.plugins.indexOf('cordova-plugin-crosswalk-webview') === -1) {
        versionCode += '0'
    }
    var data = fs.readFileSync(buildExtrasPath)
    //fs.writeFileSync(buildExtrasPath, data+"\next.cdvVersionCode=" + versionCode, { encoding: 'utf8' });
};
<|endoftext|>


<commit_before>/**
 * MARQUEE 3000 MARQUEE 3000 MARQUEE 3000 MARQUEE 3000 MARQUEE 3000
 * http://github.com/ezekielaquino/marquee3000
 * Marquees for the new millenium v1.0
 * MIT License
 */

;(function(root, factory) {
  if (typeof define === 'function' && define.amd) {
    define([], factory);
  } else if (typeof exports === 'object') {
    module.exports = factory();
  } else {
    root.Marquee3k = factory();
  }
}(this, function() {
  'use strict';

  class Marquee3k {
    constructor(element, options) {
      this.element = element;
      this.selector = options.selector;
      this.speed = element.dataset.speed || 0.25;
      this.pausable = element.dataset.pausable;
      this.reverse = element.dataset.reverse;
      this.paused = false;
      this.parent = element.parentElement;
      this.parentProps = this.parent.getBoundingClientRect();
      this.content = element.children[0];
      this.innerContent = this.content.innerHTML;
      this.wrapStyles = '';
      this.offset = 0;

      this._setupWrapper();
      this._setupContent();
      this._setupEvents();

      this.wrapper.appendChild(this.content);
      this.element.appendChild(this.wrapper);
    }

    _setupWrapper() {
      this.wrapper = document.createElement('div');
      this.wrapper.classList.add('marquee3k__wrapper');
      this.wrapper.style.whiteSpace = 'nowrap';
    }

    _setupContent() {
      this.content.classList.add(`${this.selector}__copy`);
      this.content.style.display = 'inline-block';
      this.contentWidth = this.content.offsetWidth;

      this.requiredReps = this.contentWidth > this.parentProps.width ? 2 : Math.ceil((this.parentProps.width - this.contentWidth) / this.contentWidth) + 1;

      for (let i = 0; i < this.requiredReps; i++) {
        this._createClone();
      }

      if (this.reverse) {
        this.offset = this.contentWidth * -1;
      }

      this.element.classList.add('is-init');
    }

    _setupEvents() {
      this.element.addEventListener('mouseenter', () => {
        if (this.pausable) this.paused = true;
      });

      this.element.addEventListener('mouseleave', () => {
        if (this.pausable) this.paused = false;
      });
    }

    _createClone() {
      const clone = this.content.cloneNode(true);
      clone.style.display = 'inline-block';
      clone.classList.add(`${this.selector}__copy`);
      this.wrapper.appendChild(clone);
    }

    animate() {
      if (!this.paused) {
        const isScrolled = this.reverse ? this.offset < 0 : this.offset > this.contentWidth * -1;
        const direction = this.reverse ? -1 : 1;
        const reset = this.reverse ? this.contentWidth * -1 : 0;

        if (isScrolled) this.offset -= this.speed * direction;
        else this.offset = reset;

        this.wrapper.style.whiteSpace = 'nowrap';
        this.wrapper.style.transform = `translate(${this.offset}px, 0) translateZ(0)`;
      }
    }

    _refresh() {
      this.contentWidth = this.content.offsetWidth;
    }

    repopulate(difference, isLarger) {
      this.contentWidth = this.content.offsetWidth;

      if (isLarger) {
        const amount = Math.ceil(difference / this.contentWidth) + 1;

        for (let i = 0; i < amount; i++) {
          this._createClone();
        }
      }
    }

    static refresh(index) {
      MARQUEES[index]._refresh();
    }

    static refreshAll() {
      for (let i = 0; i < MARQUEES.length; i++) {
        MARQUEES[i]._refresh();
      }
    }

    static init(options = { selector: 'marquee3k' }) {
      window.MARQUEES = [];
      const marquees = Array.from(document.querySelectorAll(`.${options.selector}`));
      let previousWidth = window.innerWidth;
      let timer;

      for (let i = 0; i < marquees.length; i++) {
        const marquee = marquees[i];
        const instance = new Marquee3k(marquee, options);
        MARQUEES.push(instance);
      }

      animate();

      function animate() {
        for (let i = 0; i < MARQUEES.length; i++) {
          MARQUEES[i].animate();
        }
        window.requestAnimationFrame(animate);
      }

      window.addEventListener('resize', () => {
        clearTimeout(timer);

        timer = setTimeout(() => {
          const isLarger = previousWidth < window.innerWidth;
          const difference = window.innerWidth - previousWidth;

          for (let i = 0; i < MARQUEES.length; i++) {
            MARQUEES[i].repopulate(difference, isLarger);
          }

          previousWidth = this.innerWidth;
        });
      }, 250);
    }
  }

  return Marquee3k;

}));<commit_msg>Added a function to toggle the pause state programmatically<commit_after>/**
 * MARQUEE 3000 MARQUEE 3000 MARQUEE 3000 MARQUEE 3000 MARQUEE 3000
 * http://github.com/ezekielaquino/marquee3000
 * Marquees for the new millenium v1.0
 * MIT License
 */

;(function(root, factory) {
  if (typeof define === 'function' && define.amd) {
    define([], factory);
  } else if (typeof exports === 'object') {
    module.exports = factory();
  } else {
    root.Marquee3k = factory();
  }
}(this, function() {
  'use strict';

  class Marquee3k {
    constructor(element, options) {
      this.element = element;
      this.selector = options.selector;
      this.speed = element.dataset.speed || 0.25;
      this.pausable = element.dataset.pausable;
      this.reverse = element.dataset.reverse;
      this.paused = false;
      this.parent = element.parentElement;
      this.parentProps = this.parent.getBoundingClientRect();
      this.content = element.children[0];
      this.innerContent = this.content.innerHTML;
      this.wrapStyles = '';
      this.offset = 0;

      this._setupWrapper();
      this._setupContent();
      this._setupEvents();

      this.wrapper.appendChild(this.content);
      this.element.appendChild(this.wrapper);
    }

    _setupWrapper() {
      this.wrapper = document.createElement('div');
      this.wrapper.classList.add('marquee3k__wrapper');
      this.wrapper.style.whiteSpace = 'nowrap';
    }

    _setupContent() {
      this.content.classList.add(`${this.selector}__copy`);
      this.content.style.display = 'inline-block';
      this.contentWidth = this.content.offsetWidth;

      this.requiredReps = this.contentWidth > this.parentProps.width ? 2 : Math.ceil((this.parentProps.width - this.contentWidth) / this.contentWidth) + 1;

      for (let i = 0; i < this.requiredReps; i++) {
        this._createClone();
      }

      if (this.reverse) {
        this.offset = this.contentWidth * -1;
      }

      this.element.classList.add('is-init');
    }

    _setupEvents() {
      this.element.addEventListener('mouseenter', () => {
        if (this.pausable) this.paused = true;
      });

      this.element.addEventListener('mouseleave', () => {
        if (this.pausable) this.paused = false;
      });
    }

    _createClone() {
      const clone = this.content.cloneNode(true);
      clone.style.display = 'inline-block';
      clone.classList.add(`${this.selector}__copy`);
      this.wrapper.appendChild(clone);
    }

    animate() {
      if (!this.paused) {
        const isScrolled = this.reverse ? this.offset < 0 : this.offset > this.contentWidth * -1;
        const direction = this.reverse ? -1 : 1;
        const reset = this.reverse ? this.contentWidth * -1 : 0;

        if (isScrolled) this.offset -= this.speed * direction;
        else this.offset = reset;

        this.wrapper.style.whiteSpace = 'nowrap';
        this.wrapper.style.transform = `translate(${this.offset}px, 0) translateZ(0)`;
      }
    }

    _refresh() {
      this.contentWidth = this.content.offsetWidth;
    }

    repopulate(difference, isLarger) {
      this.contentWidth = this.content.offsetWidth;

      if (isLarger) {
        const amount = Math.ceil(difference / this.contentWidth) + 1;

        for (let i = 0; i < amount; i++) {
          this._createClone();
        }
      }
    }

    static refresh(index) {
      MARQUEES[index]._refresh();
    }

    static refreshAll() {
      for (let i = 0; i < MARQUEES.length; i++) {
        MARQUEES[i]._refresh();
      }
    }

    static toggle() {
      this.paused = !this.paused;
    }

    static init(options = { selector: 'marquee3k' }) {
      window.MARQUEES = [];
      const marquees = Array.from(document.querySelectorAll(`.${options.selector}`));
      let previousWidth = window.innerWidth;
      let timer;

      for (let i = 0; i < marquees.length; i++) {
        const marquee = marquees[i];
        const instance = new Marquee3k(marquee, options);
        MARQUEES.push(instance);
      }

      animate();

      function animate() {
        for (let i = 0; i < MARQUEES.length; i++) {
          MARQUEES[i].animate();
        }
        window.requestAnimationFrame(animate);
      }

      window.addEventListener('resize', () => {
        clearTimeout(timer);

        timer = setTimeout(() => {
          const isLarger = previousWidth < window.innerWidth;
          const difference = window.innerWidth - previousWidth;

          for (let i = 0; i < MARQUEES.length; i++) {
            MARQUEES[i].repopulate(difference, isLarger);
          }

          previousWidth = this.innerWidth;
        });
      }, 250);
    }
  }

  return Marquee3k;

}));
<|endoftext|>


<commit_before>'use strict';

function Floating2DText(w, text, type, scene, current_color) {
    this.__init__(w, text, type, scene, current_color);
}

const TEMP_SMUDGE_FACTOR = .75;

Floating2DText.prototype = {

    material: null,
    dynamic_texture: null,

    get_text_length: function() {
        return this.dynamic_texture.getTextLength(this.text);
    },

    _update_text: function() {
        if (this.type == TYPE_BUTTON || this.type == TYPE_CHECK_BOX || this.type == TYPE_TITLE) {
            this.dynamic_texture.clear('black').drawText(this.text, this.texture_width / 2 - this.get_text_length() / 2, this.font_size * TEMP_SMUDGE_FACTOR, this.current_color, 'black');
        } else {
            this.dynamic_texture.clear('black').drawText(this.text, 0, this.font_size, this.current_color, 'black');
        }
        this.dynamic_texture.needsUpdate = true;
    },

    // NOTE : Values are different for testing purposes.

    _update_color: function() {
        if (this.type == TYPE_BUTTON || this.type == TYPE_CHECK_BOX || this.type == TYPE_TITLE) {
            this.dynamic_texture.clear('black').drawText(this.text, this.texture_width / 2 - this.get_text_length() / 2, this.font_size * TEMP_SMUDGE_FACTOR, this.current_color, 'black');
        } else {
            this.dynamic_texture.clear('black').drawText(this.text, 0, this.font_size * TEMP_SMUDGE_FACTOR, this.current_color, 'black');
        }
        this.dynamic_texture.needsUpdate = true;
    },

    _update_width: function(width) {
        this.width = width;
        this.material.dispose();
        this.geometry.dispose();
        this.mesh.dispose();
        this.object3D.remove(this.mesh);
        this.initialize(false);
    },

    initialize: function(add_to_scene) {
        if (this.type === TYPE_TITLE) {
            this.height = 26;
        } else {
            this.height = 16;
        }

        // PlaneGeometry takes in a width, height, optionalWidthSegments (default 1), optionalHeightSegments (default 1)
        this.geometry = new THREE.PlaneGeometry(this.width, this.height);

        this.texture_width = get_nearest_power_of_two_for_number(this.width * 2);
        var texture_height = get_nearest_power_of_two_for_number(this.height * 2);
        //var font_size = Math.round(texture_height * .8);
        this.font_size = texture_height;

        //l('Font size is : ' + font_size);

        this.dynamic_texture = new THREEx.DynamicTexture(this.texture_width, texture_height);
        if (this.type === TYPE_TITLE) {
            this.dynamic_texture.context.font = 'Bold ' + str(this.font_size) + 'px Arial';
        } else {
            this.dynamic_texture.context.font = str(this.font_size) + 'px Arial';
        }

        this.dynamic_texture.texture.anisotropy = CURRENT_PLAYER.renderer_api.renderer.capabilities.getMaxAnisotropy();

        this.material = new THREE.MeshBasicMaterial({
            map : this.dynamic_texture.texture
        });

        this.material.transparent = false;
        // TODO : Temporary for debugging.
        //this.material.side = THREE.FrontSide;
        this.material.side = THREE.DoubleSide;

        this._update_color();
        this._update_text();

        this.mesh = new THREE.Mesh(this.geometry, this.material);

        this.object3D.add(this.mesh);
        if (!is_defined(add_to_scene)) {
            if (is_defined(this.scene)) {
                this.scene.add(this.object3D);
            }
        } else {
            if (add_to_scene) {
                this.scene.add(this.object3D);
            }
        }
    },

    __init__: function(w, text, type, scene, current_color) {
        this.is_2d_text = true;

        // Inherit from FloatingText.
        FloatingText.call(this, w, text, type, scene, current_color);
        // Inherit from Interactive.
        Interactive.call(this);
        // Inherit from Visibility.
        Visibility.call(this);

        this.final_initialize();
    }

};
<commit_msg>general updating 09<commit_after>'use strict';

function Floating2DText(w, text, type, scene, current_color) {
    this.__init__(w, text, type, scene, current_color);
}

const TEMP_SMUDGE_FACTOR = .75;

Floating2DText.prototype = {

    material: null,
    dynamic_texture: null,

    get_text_length: function() {
        return this.dynamic_texture.getTextLength(this.text);
    },

    _update_text: function() {
        if (this.type === TYPE_BUTTON || this.type === TYPE_CHECK_BOX || this.type === TYPE_TITLE) {
            this.dynamic_texture.clear('black').drawText(this.text, this.texture_width / 2 - this.get_text_length() / 2, this.font_size * TEMP_SMUDGE_FACTOR, this.current_color, 'black');
        } else {
            this.dynamic_texture.clear('black').drawText(this.text, 0, this.font_size * TEMP_SMUDGE_FACTOR, this.current_color, 'black');
        }
        this.dynamic_texture.needsUpdate = true;
    },

    // NOTE : Values are different for testing purposes.

    _update_color: function() {
        if (this.type === TYPE_BUTTON || this.type === TYPE_CHECK_BOX || this.type === TYPE_TITLE) {
            this.dynamic_texture.clear('black').drawText(this.text, this.texture_width / 2 - this.get_text_length() / 2, this.font_size * TEMP_SMUDGE_FACTOR, this.current_color, 'black');
        } else {
            this.dynamic_texture.clear('black').drawText(this.text, 0, this.font_size * TEMP_SMUDGE_FACTOR, this.current_color, 'black');
        }
        this.dynamic_texture.needsUpdate = true;
    },

    _update_width: function(width) {
        this.width = width;
        this.material.dispose();
        this.geometry.dispose();
        this.mesh.dispose();
        this.object3D.remove(this.mesh);
        this.initialize(false);
    },

    initialize: function(add_to_scene) {
        if (this.type === TYPE_TITLE) {
            this.height = 26;
        } else {
            this.height = 16;
        }

        // PlaneGeometry takes in a width, height, optionalWidthSegments (default 1), optionalHeightSegments (default 1)
        this.geometry = new THREE.PlaneGeometry(this.width, this.height);

        this.texture_width = get_nearest_power_of_two_for_number(this.width * 2);
        var texture_height = get_nearest_power_of_two_for_number(this.height * 2);
        //var font_size = Math.round(texture_height * .8);
        this.font_size = texture_height;

        //l('Font size is : ' + font_size);

        this.dynamic_texture = new THREEx.DynamicTexture(this.texture_width, texture_height);
        if (this.type === TYPE_TITLE) {
            this.dynamic_texture.context.font = 'Bold ' + str(this.font_size) + 'px Arial';
        } else {
            this.dynamic_texture.context.font = str(this.font_size) + 'px Arial';
        }

        this.dynamic_texture.texture.anisotropy = CURRENT_PLAYER.renderer_api.renderer.capabilities.getMaxAnisotropy();

        this.material = new THREE.MeshBasicMaterial({
            map : this.dynamic_texture.texture
        });

        this.material.transparent = false;
        // TODO : Temporary for debugging.
        //this.material.side = THREE.FrontSide;
        this.material.side = THREE.DoubleSide;

        this._update_color();
        this._update_text();

        this.mesh = new THREE.Mesh(this.geometry, this.material);

        this.object3D.add(this.mesh);
        if (!is_defined(add_to_scene)) {
            if (is_defined(this.scene)) {
                this.scene.add(this.object3D);
            }
        } else {
            if (add_to_scene) {
                this.scene.add(this.object3D);
            }
        }
    },

    __init__: function(w, text, type, scene, current_color) {
        this.is_2d_text = true;

        // Inherit from FloatingText.
        FloatingText.call(this, w, text, type, scene, current_color);
        // Inherit from Interactive.
        Interactive.call(this);
        // Inherit from Visibility.
        Visibility.call(this);

        this.final_initialize();
    }

};
<|endoftext|>


<commit_before>/*global require, exports */

////////////////////////////////////////////////////////////////////////////////
/// @brief Foxx Preprocessor
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2013 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
///     http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Lucas Dohmen
/// @author Copyright 2013, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////

var Preprocessor,
  preprocess,
  ArrayIterator,
  extend = require("underscore").extend,
  coffeeScript = require("coffee-script");

ArrayIterator = function (arr) {
  'use strict';
  this.array = arr;
  this.currentLineNumber = -1;
};

extend(ArrayIterator.prototype, {
  next: function () {
    'use strict';
    this.currentLineNumber += 1;
    return this.array[this.currentLineNumber];
  },

  current: function () {
    'use strict';
    return this.array[this.currentLineNumber];
  },

  hasNext: function () {
    'use strict';
    return this.currentLineNumber < (this.array.length - 1);
  },

  replaceWith: function (newLine) {
    'use strict';
    this.array[this.currentLineNumber] = newLine;
  },

  entireString: function () {
    'use strict';
    return this.array.join("\n");
  },

  getCurrentLineNumber: function () {
    'use strict';
    if (this.hasNext()) {
      return this.currentLineNumber;
    }
  }
});

Preprocessor = function (input, type) {
  'use strict';

  if (type === 'coffee') {
    input = coffeeScript.compile(input, {bare: true});
  }

  this.iterator = new ArrayIterator(input.replace('\r', '').split("\n"));
  this.inJSDoc = false;
};

extend(Preprocessor.prototype, {
  result: function () {
    'use strict';
    return this.iterator.entireString();
  },

  convert: function () {
    'use strict';
    while (this.searchNext()) {
      this.convertLine();
    }
    return this;
  },

  searchNext: function () {
    'use strict';
    while (this.iterator.hasNext()) {
      if (this.isJSDoc(this.iterator.next())) {
        return true;
      }
    }
  },

  convertLine: function () {
    'use strict';
    this.iterator.replaceWith(
      "applicationContext.comment(\"" + this.stripComment(this.iterator.current()) + "\");"
    );
  },

  getCurrentLineNumber: function () {
    'use strict';
    return this.iterator.getCurrentLineNumber();
  },

  // helper

  stripComment: function (str) {
    'use strict';
    return str.replace(/^\s*\/\*\*/, '').       // start of JSDoc comment
               replace(/^(.*?)\*\/.*$/, '$1').  // end of JSDoc comment
               replace(/^\s*\*/, '').           // continuation of JSDoc comment
               replace(/\\/g, '\\\\').          // replace backslashes
               replace(/"/g, '\\"');            // replace quotes
  },

  isJSDoc: function (str) {
    'use strict';
    var matched;

    if (this.inJSDoc) {
      if (str.match(/\*\//)) {
        // end of multi-line JSDoc comment
        this.inJSDoc = false;
      }
      matched = true;
    } else {
      if (str.match(/^\s*\/\*\*(.*?\*)?\//)) {
        // a single-line JSDoc comment
        matched = true;
      }
      else if (str.match(/^\s*\/\*\*/)) {
        // beginning of a multi-line JSDoc comment
        matched = true;
        this.inJSDoc = true;
      }
    }

    return matched;
  }
});

preprocess = function (input, type) {
  'use strict';
  var processor = new Preprocessor(input, type);
  return processor.convert().result();
};

// Only Exported for Tests, please use `process`
exports.Preprocessor = Preprocessor;

// process(str) returns the processed String
exports.preprocess = preprocess;

// -----------------------------------------------------------------------------
// --SECTION--                                                       END-OF-FILE
// -----------------------------------------------------------------------------

/// Local Variables:
/// mode: outline-minor
/// outline-regexp: "/// @brief\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}\\|/\\*jslint"
/// End:
<commit_msg>The Foxx Comment preprocessor now trimes strings properly<commit_after>/*global require, exports */

////////////////////////////////////////////////////////////////////////////////
/// @brief Foxx Preprocessor
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2013 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
///     http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Lucas Dohmen
/// @author Copyright 2013, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////

var Preprocessor,
  preprocess,
  ArrayIterator,
  extend = require("underscore").extend,
  coffeeScript = require("coffee-script");

ArrayIterator = function (arr) {
  'use strict';
  this.array = arr;
  this.currentLineNumber = -1;
};

extend(ArrayIterator.prototype, {
  next: function () {
    'use strict';
    this.currentLineNumber += 1;
    return this.array[this.currentLineNumber];
  },

  current: function () {
    'use strict';
    return this.array[this.currentLineNumber];
  },

  hasNext: function () {
    'use strict';
    return this.currentLineNumber < (this.array.length - 1);
  },

  replaceWith: function (newLine) {
    'use strict';
    this.array[this.currentLineNumber] = newLine;
  },

  entireString: function () {
    'use strict';
    return this.array.join("\n");
  },

  getCurrentLineNumber: function () {
    'use strict';
    if (this.hasNext()) {
      return this.currentLineNumber;
    }
  }
});

Preprocessor = function (input, type) {
  'use strict';

  if (type === 'coffee') {
    input = coffeeScript.compile(input, {bare: true});
  }

  this.iterator = new ArrayIterator(input.replace('\r', '').split("\n"));
  this.inJSDoc = false;
};

extend(Preprocessor.prototype, {
  result: function () {
    'use strict';
    return this.iterator.entireString();
  },

  convert: function () {
    'use strict';
    while (this.searchNext()) {
      this.convertLine();
    }
    return this;
  },

  searchNext: function () {
    'use strict';
    while (this.iterator.hasNext()) {
      if (this.isJSDoc(this.iterator.next())) {
        return true;
      }
    }
  },

  convertLine: function () {
    'use strict';
    this.iterator.replaceWith(
      "applicationContext.comment(\"" + this.stripComment(this.iterator.current()) + "\");"
    );
  },

  getCurrentLineNumber: function () {
    'use strict';
    return this.iterator.getCurrentLineNumber();
  },

  // helper

  stripComment: function (str) {
    'use strict';
    return str.replace(/^\s*\/\*\*/, '').       // start of JSDoc comment
               replace(/^(.*?)\*\/.*$/, '$1').  // end of JSDoc comment
               replace(/^\s*\*/, '').           // continuation of JSDoc comment
               replace(/\\/g, '\\\\').          // replace backslashes
               replace(/"/g, '\\"').            // replace quotes
               trim();                          // remove leading and trailing spaces
  },

  isJSDoc: function (str) {
    'use strict';
    var matched;

    if (this.inJSDoc) {
      if (str.match(/\*\//)) {
        // end of multi-line JSDoc comment
        this.inJSDoc = false;
      }
      matched = true;
    } else {
      if (str.match(/^\s*\/\*\*(.*?\*)?\//)) {
        // a single-line JSDoc comment
        matched = true;
      }
      else if (str.match(/^\s*\/\*\*/)) {
        // beginning of a multi-line JSDoc comment
        matched = true;
        this.inJSDoc = true;
      }
    }

    return matched;
  }
});

preprocess = function (input, type) {
  'use strict';
  var processor = new Preprocessor(input, type);
  return processor.convert().result();
};

// Only Exported for Tests, please use `process`
exports.Preprocessor = Preprocessor;

// process(str) returns the processed String
exports.preprocess = preprocess;

// -----------------------------------------------------------------------------
// --SECTION--                                                       END-OF-FILE
// -----------------------------------------------------------------------------

/// Local Variables:
/// mode: outline-minor
/// outline-regexp: "/// @brief\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}\\|/\\*jslint"
/// End:
<|endoftext|>


<commit_before>const React = require('react')

class Plugin {
  constructor () {
    this.name = 'reactNavigation'
  }

  load (client) {
    const createNavigationContainer = (NavigationContainer) => React.forwardRef((props, ref) => {
      const { onReady, onStateChange, ...forwardProps } = props
      const navigationRef = ref || React.useRef(null)
      const routeNameRef = React.useRef(undefined)

      const wrappedOnReady = (...args) => {
        const currentRoute = navigationRef.current ? navigationRef.current.getCurrentRoute() : null
        if (currentRoute) {
          routeNameRef.current = currentRoute.name
          client.setContext(currentRoute.name)
        }
        if (typeof onReady === 'function') onReady.apply(this, args)
      }

      const wrappedOnStateChange = (...args) => {
        const previousRouteName = routeNameRef.current
        const currentRoute = navigationRef.current ? navigationRef.current.getCurrentRoute() : null

        if (currentRoute) {
          const currentRouteName = currentRoute.name

          if (previousRouteName !== currentRouteName) {
            client.setContext(currentRouteName)
            if (client._config.enabledBreadcrumbTypes && client._config.enabledBreadcrumbTypes.includes('navigation')) {
              client.leaveBreadcrumb(
                'React Navigation onStateChange',
                { to: currentRouteName, from: previousRouteName },
                'navigation'
              )
            }
          }

          routeNameRef.current = currentRouteName
        }
        if (typeof onStateChange === 'function') onStateChange.apply(this, args)
      }

      return React.createElement(NavigationContainer, {
        ref: navigationRef,
        onReady: wrappedOnReady,
        onStateChange: wrappedOnStateChange,
        ...forwardProps
      })
    })
    return { createNavigationContainer }
  }
}

module.exports = Plugin
<commit_msg>refactor(plugin-react-navigation): Give plugin class a more descriptive name<commit_after>const React = require('react')

class BugsnagPluginReactNavigation {
  constructor () {
    this.name = 'reactNavigation'
  }

  load (client) {
    const createNavigationContainer = (NavigationContainer) => React.forwardRef((props, ref) => {
      const { onReady, onStateChange, ...forwardProps } = props
      const navigationRef = ref || React.useRef(null)
      const routeNameRef = React.useRef(undefined)

      const wrappedOnReady = (...args) => {
        const currentRoute = navigationRef.current ? navigationRef.current.getCurrentRoute() : null
        if (currentRoute) {
          routeNameRef.current = currentRoute.name
          client.setContext(currentRoute.name)
        }
        if (typeof onReady === 'function') onReady.apply(this, args)
      }

      const wrappedOnStateChange = (...args) => {
        const previousRouteName = routeNameRef.current
        const currentRoute = navigationRef.current ? navigationRef.current.getCurrentRoute() : null

        if (currentRoute) {
          const currentRouteName = currentRoute.name

          if (previousRouteName !== currentRouteName) {
            client.setContext(currentRouteName)
            if (client._config.enabledBreadcrumbTypes && client._config.enabledBreadcrumbTypes.includes('navigation')) {
              client.leaveBreadcrumb(
                'React Navigation onStateChange',
                { to: currentRouteName, from: previousRouteName },
                'navigation'
              )
            }
          }

          routeNameRef.current = currentRouteName
        }
        if (typeof onStateChange === 'function') onStateChange.apply(this, args)
      }

      return React.createElement(NavigationContainer, {
        ref: navigationRef,
        onReady: wrappedOnReady,
        onStateChange: wrappedOnStateChange,
        ...forwardProps
      })
    })
    return { createNavigationContainer }
  }
}

module.exports = BugsnagPluginReactNavigation
<|endoftext|>