<commit_before>var mongoose_resource = require('jest'),
    UserResource = require('./UserResources.js'),
    InformationItemResource = require('./InformationItemResource.js'),
    ShoppingCartResource = require('./ShoppingCartResource'),
    DiscussionShoppingCartResource = require('./discussions/DiscussionShoppingCartResource.js'),
//    CycleResource = require('./cycles/CycleResource.js'),
//    CyclePostResource = require('./cycles/CyclePostResource.js'),
//    CycleShoppingCartResource = require('./cycles/CycleShoppingCartResource.js'),
//    CycleTimelineResource = require('./cycles/CycleTimeLineResource.js'),
//    CycleFBPageResource = require('./cycles/CycleFBPageResource.js'),
    OpinionShaperResource = require('./cycles/OpinionShaperResource.js'),
//    ActionShoppingCartResource = require('./actions/ActionShoppingCartResource.js'),
    SubjectResource = require('./SubjectResource'),
    DiscussionResource = require('./discussions/DiscussionResource.js'),
    PostResource = require('./discussions/PostResource.js'),
    PostDiscussionResource = require('./discussions/postDiscussionResource.js'),
    PostOnSuggestionResource = require('./discussions/post_on_suggestion_resource.js'),
    PostOnCommentResource = require('./discussions/post_on_comment_resource.js'),
    SpecialPostsResource = require('./discussions/special_posts_resource.js'),
    DiscussionHistoryResource = require('./discussions/DiscussionHistoryResource.js'),
    PostForumResource = require('./forum/postForumResource.js'),
    PostAttachmentResource = require('./discussions/PostAttachmentResource.js'),
    PostDiscussionAttachmentResource = require('./discussions/PostDiscussionAttachmentResource.js'),
//    PostsActionResource = require('./actions/PostActionResource.js'),
    VoteResource = require('./discussions/VoteResource.js'),
    VoteActionPostResource = require('./actions/VoteActionPostResource'),
    GradeResource = require('./discussions/GradeResource.js'),
    GradeSuggestionResource = require('./GradeSuggestionResource'),
//    GradeActionSuggestionResource = require('./actions/grade_action_suggestion_resource'),
//    GradeActionResource = require('./actions/GradeActionResource'),
    LikeResource = require('./LikeResource'),
//    JoinResource = require('./actions/JoinResource'),
    CategoryResource = require('./CategoryResource'),
    SuggestionResource = require('./suggestionResource.js'),
//    ActionSuggestionResource = require('./actions/ActionSuggestionResource.js'),
//    ActionResourceResource = require('./actions/ActionResourceResource.js'),
//    ActionResource = require('./actions/ActionResource.js'),
//    ActionPopulatedResource = require('./actions/ActionPopulatedResource.js'),
    TagResource = require('./TagResource'),
    HeadlineResource = require('./HeadlineResource'),
    UpdateResource = require('./UpdateResource'),
    HotObjectResource = require('./HotObjectResource'),
    NotificationResource = require('./NotificationResource'),
    UserFollowerResource = require('./UserFollowerResource'),
//    UserProxyResource = require('./UserProxyResource'),
    ItemsCountByTagNameResource = require('./ItemsCountByTagNameResource'),
    FBRequestResource = require('./FBRequestResource'),
    ImageUploadResource = require('./ImageUploadResource'),
    AboutUruTextResource = require('./AboutUruTextResource'),
    AboutUruItemResource = require('./AboutUruItemResource'),
    TeamResource = require('./TeamResource'),
    FounderResource = require('./founder_resource'),
    BringResourceResource = require('./actions/bring_resource_resource'),
    QaResource = require('./QaResource'),
    RegisterResource = require('./register_resource'),
    LoginResource = require('./LoginResource'),
    FbConnectResource = require('./FbConnectResource'),
    AvatarResource = require('./avatar_resource'),
    ResetNotificationResource = require('./reset_notification_resource'),
    CounterResource = require('./CounterResource'),
    OGActionResource = require('./og_action_resource'),
    UserInviteFriendsResource=      require('./UserInviteFriendsResource'),
    UserMailNotificationConfig = require('./user_mail_notification_config_resource');
    LinkResource = require('./LinkResource'),
    SendMailResource =  require('./send_mail_resource'),

module.exports = function(app)
{
    var rest_api = new mongoose_resource.Api('api',app);
    rest_api.register_resource('users',new UserResource());
    rest_api.register_resource('information_items',new InformationItemResource());
    rest_api.register_resource('forum_posts',new PostForumResource());
    rest_api.register_resource('forum_post_attachments',new PostAttachmentResource());
    rest_api.register_resource('headlines',new HeadlineResource());
    rest_api.register_resource('updates',new UpdateResource());
    rest_api.register_resource('shopping_cart',new ShoppingCartResource());
    rest_api.register_resource('discussions_shopping_cart',new DiscussionShoppingCartResource());
//    rest_api.register_resource('cycles_shopping_cart',new CycleShoppingCartResource());
//    rest_api.register_resource('actions_shopping_cart',new ActionShoppingCartResource());
    rest_api.register_resource('subjects', new SubjectResource());
    rest_api.register_resource('discussions', new DiscussionResource());
    rest_api.register_resource('posts', new PostResource());
    rest_api.register_resource('post_discussion', new PostDiscussionResource());
    rest_api.register_resource('post_discussion_attachments',new PostDiscussionAttachmentResource());
    rest_api.register_resource('special_posts', new SpecialPostsResource());
    rest_api.register_resource('suggestion_posts', new PostOnSuggestionResource());
    rest_api.register_resource('posts_on_comment', new PostOnCommentResource());
    rest_api.register_resource('discussions_history', new DiscussionHistoryResource());
//    rest_api.register_resource('posts_of_action', new PostsActionResource());
    rest_api.register_resource('votes', new VoteResource());
    rest_api.register_resource('votes_on_action_post', new VoteActionPostResource());
    rest_api.register_resource('grades', new GradeResource());
    rest_api.register_resource('grades_suggestion', new GradeSuggestionResource());
//    rest_api.register_resource('action_suggestion_grades', new GradeActionSuggestionResource());
//    rest_api.register_resource('action_grades', new GradeActionResource());
//    rest_api.register_resource('action_suggestions', new ActionSuggestionResource());
    rest_api.register_resource('likes', new LikeResource());
//    rest_api.register_resource('join', new JoinResource());
    rest_api.register_resource('suggestions', new SuggestionResource());
    rest_api.register_resource('categories', new CategoryResource());
//    rest_api.register_resource('action_resources', new ActionResourceResource());
//    rest_api.register_resource('actions', new ActionResource());
//    rest_api.register_resource('actions_populated', new ActionPopulatedResource());
//    rest_api.register_resource('cycles', new CycleResource());
//    rest_api.register_resource('cycle_posts', new CyclePostResource());
//    rest_api.register_resource('cycle_timeline', new CycleTimelineResource());
//    rest_api.register_resource('cycle_pages', new CycleFBPageResource());
    rest_api.register_resource('opinion_shapers', new OpinionShaperResource());
    rest_api.register_resource('tags', new TagResource());
    rest_api.register_resource('hot_objects', new HotObjectResource());
    rest_api.register_resource('notifications', new NotificationResource());
    rest_api.register_resource('user_followers', new UserFollowerResource());
//    rest_api.register_resource('user_proxies', new UserProxyResource());
//    rest_api.register_resource('user_proxies', new UserProxyResource());
    rest_api.register_resource('user_invited_friends', new UserInviteFriendsResource());

    rest_api.register_resource('about_uru_texts', new AboutUruTextResource());
        rest_api.register_resource('about_uru_items', new AboutUruItemResource());
    rest_api.register_resource('team', new TeamResource());
    rest_api.register_resource('founders', new FounderResource());
    rest_api.register_resource('user_helps_action', new BringResourceResource());
    rest_api.register_resource('qa', new QaResource());
    rest_api.register_resource('user_mail_notification_config', new UserMailNotificationConfig());

    rest_api.register_resource('login', new LoginResource());
    rest_api.register('register',new RegisterResource());
    rest_api.register_resource('fb_connect', new FbConnectResource());

    rest_api.register_resource('items_count_by_tag_name', new ItemsCountByTagNameResource());
    rest_api.register_resource('fb_request', new FBRequestResource());
    rest_api.register('image_upload',new ImageUploadResource());
    rest_api.register('og_action', new OGActionResource());
    rest_api.register('avatar',new AvatarResource());
    rest_api.register('reset_notification',new ResetNotificationResource());
    rest_api.register_resource('counter', new CounterResource());
    rest_api.register_resource('link', new LinkResource());
    rest_api.register_resource('send_mail', new SendMailResource());
};
<commit_msg>p To P<commit_after>var mongoose_resource = require('jest'),
    UserResource = require('./UserResources.js'),
    InformationItemResource = require('./InformationItemResource.js'),
    ShoppingCartResource = require('./ShoppingCartResource'),
    DiscussionShoppingCartResource = require('./discussions/DiscussionShoppingCartResource.js'),
//    CycleResource = require('./cycles/CycleResource.js'),
//    CyclePostResource = require('./cycles/CyclePostResource.js'),
//    CycleShoppingCartResource = require('./cycles/CycleShoppingCartResource.js'),
//    CycleTimelineResource = require('./cycles/CycleTimeLineResource.js'),
//    CycleFBPageResource = require('./cycles/CycleFBPageResource.js'),
    OpinionShaperResource = require('./cycles/OpinionShaperResource.js'),
//    ActionShoppingCartResource = require('./actions/ActionShoppingCartResource.js'),
    SubjectResource = require('./SubjectResource'),
    DiscussionResource = require('./discussions/DiscussionResource.js'),
    PostResource = require('./discussions/PostResource.js'),
    PostDiscussionResource = require('./discussions/PostDiscussionResource.js'),
    PostOnSuggestionResource = require('./discussions/post_on_suggestion_resource.js'),
    PostOnCommentResource = require('./discussions/post_on_comment_resource.js'),
    SpecialPostsResource = require('./discussions/special_posts_resource.js'),
    DiscussionHistoryResource = require('./discussions/DiscussionHistoryResource.js'),
    PostForumResource = require('./forum/postForumResource.js'),
    PostAttachmentResource = require('./discussions/PostAttachmentResource.js'),
    PostDiscussionAttachmentResource = require('./discussions/PostDiscussionAttachmentResource.js'),
//    PostsActionResource = require('./actions/PostActionResource.js'),
    VoteResource = require('./discussions/VoteResource.js'),
    VoteActionPostResource = require('./actions/VoteActionPostResource'),
    GradeResource = require('./discussions/GradeResource.js'),
    GradeSuggestionResource = require('./GradeSuggestionResource'),
//    GradeActionSuggestionResource = require('./actions/grade_action_suggestion_resource'),
//    GradeActionResource = require('./actions/GradeActionResource'),
    LikeResource = require('./LikeResource'),
//    JoinResource = require('./actions/JoinResource'),
    CategoryResource = require('./CategoryResource'),
    SuggestionResource = require('./suggestionResource.js'),
//    ActionSuggestionResource = require('./actions/ActionSuggestionResource.js'),
//    ActionResourceResource = require('./actions/ActionResourceResource.js'),
//    ActionResource = require('./actions/ActionResource.js'),
//    ActionPopulatedResource = require('./actions/ActionPopulatedResource.js'),
    TagResource = require('./TagResource'),
    HeadlineResource = require('./HeadlineResource'),
    UpdateResource = require('./UpdateResource'),
    HotObjectResource = require('./HotObjectResource'),
    NotificationResource = require('./NotificationResource'),
    UserFollowerResource = require('./UserFollowerResource'),
//    UserProxyResource = require('./UserProxyResource'),
    ItemsCountByTagNameResource = require('./ItemsCountByTagNameResource'),
    FBRequestResource = require('./FBRequestResource'),
    ImageUploadResource = require('./ImageUploadResource'),
    AboutUruTextResource = require('./AboutUruTextResource'),
    AboutUruItemResource = require('./AboutUruItemResource'),
    TeamResource = require('./TeamResource'),
    FounderResource = require('./founder_resource'),
    BringResourceResource = require('./actions/bring_resource_resource'),
    QaResource = require('./QaResource'),
    RegisterResource = require('./register_resource'),
    LoginResource = require('./LoginResource'),
    FbConnectResource = require('./FbConnectResource'),
    AvatarResource = require('./avatar_resource'),
    ResetNotificationResource = require('./reset_notification_resource'),
    CounterResource = require('./CounterResource'),
    OGActionResource = require('./og_action_resource'),
    UserInviteFriendsResource=      require('./UserInviteFriendsResource'),
    UserMailNotificationConfig = require('./user_mail_notification_config_resource');
    LinkResource = require('./LinkResource'),
    SendMailResource =  require('./send_mail_resource'),

module.exports = function(app)
{
    var rest_api = new mongoose_resource.Api('api',app);
    rest_api.register_resource('users',new UserResource());
    rest_api.register_resource('information_items',new InformationItemResource());
    rest_api.register_resource('forum_posts',new PostForumResource());
    rest_api.register_resource('forum_post_attachments',new PostAttachmentResource());
    rest_api.register_resource('headlines',new HeadlineResource());
    rest_api.register_resource('updates',new UpdateResource());
    rest_api.register_resource('shopping_cart',new ShoppingCartResource());
    rest_api.register_resource('discussions_shopping_cart',new DiscussionShoppingCartResource());
//    rest_api.register_resource('cycles_shopping_cart',new CycleShoppingCartResource());
//    rest_api.register_resource('actions_shopping_cart',new ActionShoppingCartResource());
    rest_api.register_resource('subjects', new SubjectResource());
    rest_api.register_resource('discussions', new DiscussionResource());
    rest_api.register_resource('posts', new PostResource());
    rest_api.register_resource('post_discussion', new PostDiscussionResource());
    rest_api.register_resource('post_discussion_attachments',new PostDiscussionAttachmentResource());
    rest_api.register_resource('special_posts', new SpecialPostsResource());
    rest_api.register_resource('suggestion_posts', new PostOnSuggestionResource());
    rest_api.register_resource('posts_on_comment', new PostOnCommentResource());
    rest_api.register_resource('discussions_history', new DiscussionHistoryResource());
//    rest_api.register_resource('posts_of_action', new PostsActionResource());
    rest_api.register_resource('votes', new VoteResource());
    rest_api.register_resource('votes_on_action_post', new VoteActionPostResource());
    rest_api.register_resource('grades', new GradeResource());
    rest_api.register_resource('grades_suggestion', new GradeSuggestionResource());
//    rest_api.register_resource('action_suggestion_grades', new GradeActionSuggestionResource());
//    rest_api.register_resource('action_grades', new GradeActionResource());
//    rest_api.register_resource('action_suggestions', new ActionSuggestionResource());
    rest_api.register_resource('likes', new LikeResource());
//    rest_api.register_resource('join', new JoinResource());
    rest_api.register_resource('suggestions', new SuggestionResource());
    rest_api.register_resource('categories', new CategoryResource());
//    rest_api.register_resource('action_resources', new ActionResourceResource());
//    rest_api.register_resource('actions', new ActionResource());
//    rest_api.register_resource('actions_populated', new ActionPopulatedResource());
//    rest_api.register_resource('cycles', new CycleResource());
//    rest_api.register_resource('cycle_posts', new CyclePostResource());
//    rest_api.register_resource('cycle_timeline', new CycleTimelineResource());
//    rest_api.register_resource('cycle_pages', new CycleFBPageResource());
    rest_api.register_resource('opinion_shapers', new OpinionShaperResource());
    rest_api.register_resource('tags', new TagResource());
    rest_api.register_resource('hot_objects', new HotObjectResource());
    rest_api.register_resource('notifications', new NotificationResource());
    rest_api.register_resource('user_followers', new UserFollowerResource());
//    rest_api.register_resource('user_proxies', new UserProxyResource());
//    rest_api.register_resource('user_proxies', new UserProxyResource());
    rest_api.register_resource('user_invited_friends', new UserInviteFriendsResource());

    rest_api.register_resource('about_uru_texts', new AboutUruTextResource());
        rest_api.register_resource('about_uru_items', new AboutUruItemResource());
    rest_api.register_resource('team', new TeamResource());
    rest_api.register_resource('founders', new FounderResource());
    rest_api.register_resource('user_helps_action', new BringResourceResource());
    rest_api.register_resource('qa', new QaResource());
    rest_api.register_resource('user_mail_notification_config', new UserMailNotificationConfig());

    rest_api.register_resource('login', new LoginResource());
    rest_api.register('register',new RegisterResource());
    rest_api.register_resource('fb_connect', new FbConnectResource());

    rest_api.register_resource('items_count_by_tag_name', new ItemsCountByTagNameResource());
    rest_api.register_resource('fb_request', new FBRequestResource());
    rest_api.register('image_upload',new ImageUploadResource());
    rest_api.register('og_action', new OGActionResource());
    rest_api.register('avatar',new AvatarResource());
    rest_api.register('reset_notification',new ResetNotificationResource());
    rest_api.register_resource('counter', new CounterResource());
    rest_api.register_resource('link', new LinkResource());
    rest_api.register_resource('send_mail', new SendMailResource());
};
<|endoftext|>


<commit_before>(function () {
  function removeIds(elem) {
    elem.removeAttribute("id")
    for (var i=0, n=elem.childElementCount; i < n; ++i)
      removeIds(elem.children[i])
    return elem
  }

  function createMenu() {
    var menu = document.querySelector(".menu")
    if (!menu)
      return
    var menuContents = menu.querySelector(".menu-contents")
    if (!menuContents)
      return
    var contents = document.querySelector("#contents")
    if (!contents)
      return
    var tree = contents.nextElementSibling
    if (!tree)
      return
    menu.onclick = function(e) {
      menu.className = menu.className === "menu" && e.target.tagName === "DIV"
        ? "menu open"
        : "menu"
      e.stopPropagation()
    }
    menuContents.appendChild(removeIds(tree.cloneNode(true)))
  }

  window.addEventListener('load', createMenu)
})()
<commit_msg>Fix menu<commit_after>(function () {
  function removeIds(elem) {
    elem.removeAttribute("id")
    for (var i=0, n=elem.childElementCount; i < n; ++i)
      removeIds(elem.children[i])
    return elem
  }

  function createMenu() {
    var menu = document.querySelector(".menu")
    if (!menu)
      return
    var menuContents = menu.querySelector(".menu-contents")
    if (!menuContents)
      return
    var contents = document.querySelector("#contents")
    if (!contents)
      return
    contents = contents.parentNode
    if (!contents)
      return
    var tree = contents.nextElementSibling
    if (!tree)
      return
    menu.onclick = function(e) {
      menu.className = menu.className === "menu" && e.target.tagName === "DIV"
        ? "menu open"
        : "menu"
      e.stopPropagation()
    }
    menuContents.appendChild(removeIds(tree.cloneNode(true)))
  }

  window.addEventListener('load', createMenu)
})()
<|endoftext|>


<commit_before>/* ESGF Dataset search */

(function($) {
  $.extend({
    EsgDatasetSearch: function(options) {
      var defaults = {
        oid: null,
        url: null,
        constraints: null,
        categories: null,
        keywords: null,
        pinnedFacets: null,
        selectedFacet: 'project',
      };
      var searchOptions = $.extend(defaults, options);
      var selectedFacet = searchOptions.selectedFacet;

      var init = function() {
        initDatasetCollapse();
        init_toggle_collapse();
        init_search_options();
        init_query();
        init_constraints();
        init_facets();
        init_facet_values();
        init_pinned_facets();
        init_time_constraints();
        //init_spatial_constraints();
        //search();
      };

      var initDatasetCollapse = function() {
        $('.dataset').on('show.bs.collapse', function () {
          var _el = $(this);
          var waitDialog = $('#please-wait-dialog');
          waitDialog.modal('show');
          $.getJSON('/esgfsearch/files', function(result) {
            text = '';
            $.each(result.files, function(i, file) {
              text += '
';
              text += file.filename;
              text += '
';
              text += '';
              text += ' Download';
              text += '';
              text += ' OpenDAP';
              text += '
';
              text += '
';
            });
            _el.find('.files').html(text);
            waitDialog.modal('hide');
          });
        })
      };

      var init_toggle_collapse = function() {
        $('a[data-toggle="collapse"]').click(function () {
          $(this).find('i').toggleClass('fa-chevron-right fa-chevron-down');
        })
      };

      // using ctrl for multiple selection of facets
      var ctrlPressed = false;
      $(window).keydown(function(e) {
        if (e.which == 17) { // ctrl
          ctrlPressed = true;
        }
      }).keyup(function(e) {
        if (e.which == 17) { // ctrl
          ctrlPressed = false;
          search();
        }
      });

      // using delete to remove selections of current category
      $(window).keydown(function(e) {
        if (e.which == 46) { // delete
          $(".tm-selection").tagsManager('empty');
          search();
        }
      });

      var killEvent = function (e) {
        e.cancelBubble = true;
        e.returnValue = false;
        e.stopPropagation();
        e.preventDefault();
      };

      var deleted_constraint_handler = function(constraint) {
        $(".tm-selection").tagsManager('limitPopTags');
        search();
      };

      var selected_facet_handler = function (facet) {
        selectedFacet = facet;
        $('#search-label-category').text("KEYWORDS: " + selectedFacet)
        search();
      };

      var selected_facet_value_handler = function (facet_value) {
        value = selectedFacet  + ':' + facet_value;
        $(".tm-selection").tagsManager('limitPushTags');
        $(".tm-selection").tagsManager('pushTag', value);
        if (!ctrlPressed) {
          search();
        }
      };

      var numTags = function(tags) {
        var result = 1;
        if (tags != '') {
          result = tags.split(',').length;
        }
        return result;
      };

      /*
      var update_counts = function(counts) {
        $('#tm-hit-count').text("Total: " + counts);
        $('#' + searchOptions.oid + '-hit-count').val(counts);
      };
      */

      var init_search_options = function() {
        $('#' + searchOptions.oid + '-distrib').click(function () {
          search();
        });

        $('#' + searchOptions.oid + '-replica').click(function () {
          search();
        });

        $('#' + searchOptions.oid + '-latest').click(function () {
          search();
        });

        $('#' + searchOptions.oid + '-temporal').click(function () {
          search();
        });

        /*
        $('#' + searchOptions.oid + '-spatial').click(function () {
          search();
        });
        */
      };

      var init_query = function() {
        $('#' + searchOptions.oid + '-query').keypress(function(e) {
          // disable ENTER
          if (e.which == 13) {
            killEvent(e);
            search();
          };
        });
      };

      var init_time_constraints = function() {
        // start year
        $('#' + searchOptions.oid + '-start').keypress(function(e) {
          // disable ENTER and run search
          if (e.which == 13) {
            killEvent(e);
            search();
          };
        });
        $('#' + searchOptions.oid + '-start').on('change', function(){
          search();
        });

        // end year
        $('#' + searchOptions.oid + '-end').keypress(function(e) {
          // disable ENTER and run search
          if (e.which == 13) {
            killEvent(e);
            search();
          };
        });
        $('#' + searchOptions.oid + '-end').on('change', function(){
          search();
        });
      };

      var init_constraints = function() {
        $(".tm-selection").tagsManager({
          preventSubmitOnEnter: true,
          delimiters: [9, 13, 44],
          //maxTags: 2,
          tagClass: 'tm-tag tm-tag-success',
          hiddenTagListId: searchOptions.oid + '-constraints',
          deleteHandler: deleted_constraint_handler,
          prefilled: searchOptions.constraints,
          maxTags: numTags(searchOptions.constraints),
        });
      };

      var init_spatial_constraints = function() {
        $('#' + searchOptions.oid + '-bbox').keypress(function(e) {
          // disable ENTER
          if (e.which == 13) {
            killEvent(e);
            search();
          };
        });
        $('#' + searchOptions.oid + '-bbox').on('change', function(){
          search();
        });
      };

      var init_facets = function() {
        $(".tm-facets").tagsManager({
          //prefilled: ["hello"],
          preventSubmitOnEnter: true,
          delimiters: [9, 13, 44],
          //maxTags: 1,
          tagClass: 'tm-tag tm-tag-info',
          isSelectable: true,
          selectHandler: selected_facet_handler,
          prefilled: searchOptions.categories,
          maxTags: numTags(searchOptions.categories),
        });
      };

      var init_facet_values = function() {
        $(".tm-facet").tagsManager({
          //prefilled: ["MPI-M", "NCC", "MIROC", "BCC"],
          preventSubmitOnEnter: true,
          delimiters: [9, 13, 44],
          //maxTags: 4,
          tagClass: 'tm-tag tm-tag-warning tm-tag-mini',
          isSelectable: true,
          selectHandler: selected_facet_value_handler,
          prefilled: searchOptions.keywords,
          maxTags: numTags(searchOptions.keywords),
        });
      };

      var init_pinned_facets = function() {
        $(".tm-pinned-facets").tagsManager({
          //prefilled: ["hello"],
          preventSubmitOnEnter: true,
          delimiters: [9, 13, 44],
          tagClass: 'tm-tag tm-tag-disabled',
          isSelectable: false,
          prefilled: searchOptions.pinnedFacets,
          maxTags: numTags(searchOptions.pinnedFacets),
        });
      };

      var buildQuery = function() {
        var searchURL = searchOptions.url + '?';
        var query = searchURL;
        query += 'selected=' + selectedFacet;
        query += '&constraints=' + $("#" + searchOptions.oid + '-constraints').val();

        // search options
        if ($('#' + searchOptions.oid + '-distrib').is(":checked") == true) {
          query += '&distrib=true';
        } else {
          query += '&distrib=false';
        }
        if ($('#' + searchOptions.oid + '-latest').is(":checked") == true) {
          query += '&latest=true';
        } else {
          query += '&latest=false';
        }
        if ($('#' + searchOptions.oid + '-replica').is(":checked") == true) {
          query += '&replica=true';
        } else {
          query += '&replica=false';
        }

        // date options
        query += '&query=' + $('#' + searchOptions.oid + '-query').val();
        if ($('#' + searchOptions.oid + '-temporal').is(":checked") == true) {
          query += '&start=' + $('#' + searchOptions.oid + '-start').val();
          query += '&end=' + $('#' + searchOptions.oid + '-end').val();
        }

        return query;
      };

      var search = function() {
        query = buildQuery();
        // alert("run search: " + query);
        window.location = query;

        /*
        $.getJSON(buildQuery(), function(result) {
          $(".tm-facets").tagsManager('empty');
          $.each(result.facets, function(i, tag) {
            $(".tm-facets").tagsManager('limitPushTags');
            $(".tm-facets").tagsManager('pushTag', tag);
          });

          $(".tm-facet").tagsManager('empty');
          $.each(result.facetValues, function(i,value) {
            $(".tm-facet").tagsManager('limitPushTags');
            $(".tm-facet").tagsManager('pushTag', value);
          });

          $(".tm-pinned-facets").tagsManager('empty');
          $.each(result.pinnedFacets, function(i, tag) {
            selection = $("#" + searchOptions.oid + '-facets').val();
            if (selection.indexOf(tag) < 0) {
              $(".tm-pinned-facets").tagsManager('limitPushTags');
              $(".tm-pinned-facets").tagsManager('pushTag', tag);
            }
          });

          update_counts(result.numFound);
        });
        */
      };

      init();
    },
  });
})(jQuery);
<commit_msg>added inital buildFileSearchQuery<commit_after>/* ESGF Dataset search */

(function($) {
  $.extend({
    EsgDatasetSearch: function(options) {
      var defaults = {
        oid: null,
        url: null,
        constraints: null,
        categories: null,
        keywords: null,
        pinnedFacets: null,
        selectedFacet: 'project',
      };
      var searchOptions = $.extend(defaults, options);
      var selectedFacet = searchOptions.selectedFacet;

      var init = function() {
        initDatasetCollapse();
        init_toggle_collapse();
        init_search_options();
        init_query();
        init_constraints();
        init_facets();
        init_facet_values();
        init_pinned_facets();
        init_time_constraints();
        //init_spatial_constraints();
        //search();
      };

      var initDatasetCollapse = function() {
        $('.dataset').on('show.bs.collapse', function () {
          var _el = $(this);
          var waitDialog = $('#please-wait-dialog');
          waitDialog.modal('show');
          $.getJSON(buildFileSearchQuery(), function(result) {
            text = '';
            $.each(result.files, function(i, file) {
              text += '
';
              text += file.filename;
              text += '
';
              text += '';
              text += ' Download';
              text += '';
              text += ' OpenDAP';
              text += '
';
              text += '
';
            });
            _el.find('.files').html(text);
            waitDialog.modal('hide');
          });
        })
      };

      var init_toggle_collapse = function() {
        $('a[data-toggle="collapse"]').click(function () {
          $(this).find('i').toggleClass('fa-chevron-right fa-chevron-down');
        })
      };

      // using ctrl for multiple selection of facets
      var ctrlPressed = false;
      $(window).keydown(function(e) {
        if (e.which == 17) { // ctrl
          ctrlPressed = true;
        }
      }).keyup(function(e) {
        if (e.which == 17) { // ctrl
          ctrlPressed = false;
          search();
        }
      });

      // using delete to remove selections of current category
      $(window).keydown(function(e) {
        if (e.which == 46) { // delete
          $(".tm-selection").tagsManager('empty');
          search();
        }
      });

      var killEvent = function (e) {
        e.cancelBubble = true;
        e.returnValue = false;
        e.stopPropagation();
        e.preventDefault();
      };

      var deleted_constraint_handler = function(constraint) {
        $(".tm-selection").tagsManager('limitPopTags');
        search();
      };

      var selected_facet_handler = function (facet) {
        selectedFacet = facet;
        $('#search-label-category').text("KEYWORDS: " + selectedFacet)
        search();
      };

      var selected_facet_value_handler = function (facet_value) {
        value = selectedFacet  + ':' + facet_value;
        $(".tm-selection").tagsManager('limitPushTags');
        $(".tm-selection").tagsManager('pushTag', value);
        if (!ctrlPressed) {
          search();
        }
      };

      var numTags = function(tags) {
        var result = 1;
        if (tags != '') {
          result = tags.split(',').length;
        }
        return result;
      };

      /*
      var update_counts = function(counts) {
        $('#tm-hit-count').text("Total: " + counts);
        $('#' + searchOptions.oid + '-hit-count').val(counts);
      };
      */

      var init_search_options = function() {
        $('#' + searchOptions.oid + '-distrib').click(function () {
          search();
        });

        $('#' + searchOptions.oid + '-replica').click(function () {
          search();
        });

        $('#' + searchOptions.oid + '-latest').click(function () {
          search();
        });

        $('#' + searchOptions.oid + '-temporal').click(function () {
          search();
        });

        /*
        $('#' + searchOptions.oid + '-spatial').click(function () {
          search();
        });
        */
      };

      var init_query = function() {
        $('#' + searchOptions.oid + '-query').keypress(function(e) {
          // disable ENTER
          if (e.which == 13) {
            killEvent(e);
            search();
          };
        });
      };

      var init_time_constraints = function() {
        // start year
        $('#' + searchOptions.oid + '-start').keypress(function(e) {
          // disable ENTER and run search
          if (e.which == 13) {
            killEvent(e);
            search();
          };
        });
        $('#' + searchOptions.oid + '-start').on('change', function(){
          search();
        });

        // end year
        $('#' + searchOptions.oid + '-end').keypress(function(e) {
          // disable ENTER and run search
          if (e.which == 13) {
            killEvent(e);
            search();
          };
        });
        $('#' + searchOptions.oid + '-end').on('change', function(){
          search();
        });
      };

      var init_constraints = function() {
        $(".tm-selection").tagsManager({
          preventSubmitOnEnter: true,
          delimiters: [9, 13, 44],
          //maxTags: 2,
          tagClass: 'tm-tag tm-tag-success',
          hiddenTagListId: searchOptions.oid + '-constraints',
          deleteHandler: deleted_constraint_handler,
          prefilled: searchOptions.constraints,
          maxTags: numTags(searchOptions.constraints),
        });
      };

      var init_spatial_constraints = function() {
        $('#' + searchOptions.oid + '-bbox').keypress(function(e) {
          // disable ENTER
          if (e.which == 13) {
            killEvent(e);
            search();
          };
        });
        $('#' + searchOptions.oid + '-bbox').on('change', function(){
          search();
        });
      };

      var init_facets = function() {
        $(".tm-facets").tagsManager({
          //prefilled: ["hello"],
          preventSubmitOnEnter: true,
          delimiters: [9, 13, 44],
          //maxTags: 1,
          tagClass: 'tm-tag tm-tag-info',
          isSelectable: true,
          selectHandler: selected_facet_handler,
          prefilled: searchOptions.categories,
          maxTags: numTags(searchOptions.categories),
        });
      };

      var init_facet_values = function() {
        $(".tm-facet").tagsManager({
          //prefilled: ["MPI-M", "NCC", "MIROC", "BCC"],
          preventSubmitOnEnter: true,
          delimiters: [9, 13, 44],
          //maxTags: 4,
          tagClass: 'tm-tag tm-tag-warning tm-tag-mini',
          isSelectable: true,
          selectHandler: selected_facet_value_handler,
          prefilled: searchOptions.keywords,
          maxTags: numTags(searchOptions.keywords),
        });
      };

      var init_pinned_facets = function() {
        $(".tm-pinned-facets").tagsManager({
          //prefilled: ["hello"],
          preventSubmitOnEnter: true,
          delimiters: [9, 13, 44],
          tagClass: 'tm-tag tm-tag-disabled',
          isSelectable: false,
          prefilled: searchOptions.pinnedFacets,
          maxTags: numTags(searchOptions.pinnedFacets),
        });
      };

      var buildSearchQuery = function() {
        var searchURL = searchOptions.url + '?';
        var query = searchURL;
        query += 'selected=' + selectedFacet;
        query += '&constraints=' + $("#" + searchOptions.oid + '-constraints').val();

        // search options
        if ($('#' + searchOptions.oid + '-distrib').is(":checked") == true) {
          query += '&distrib=true';
        } else {
          query += '&distrib=false';
        }
        if ($('#' + searchOptions.oid + '-latest').is(":checked") == true) {
          query += '&latest=true';
        } else {
          query += '&latest=false';
        }
        if ($('#' + searchOptions.oid + '-replica').is(":checked") == true) {
          query += '&replica=true';
        } else {
          query += '&replica=false';
        }

        // date options
        query += '&query=' + $('#' + searchOptions.oid + '-query').val();
        if ($('#' + searchOptions.oid + '-temporal').is(":checked") == true) {
          query += '&start=' + $('#' + searchOptions.oid + '-start').val();
          query += '&end=' + $('#' + searchOptions.oid + '-end').val();
        }

        return query;
      };

      var buildFileSearchQuery = function() {
        var query = "/esgfsearch/files";
        return query;
      };

      var search = function() {
        query = buildSearchQuery();
        // alert("run search: " + query);
        window.location = query;

        /*
        $.getJSON(buildQuery(), function(result) {
          $(".tm-facets").tagsManager('empty');
          $.each(result.facets, function(i, tag) {
            $(".tm-facets").tagsManager('limitPushTags');
            $(".tm-facets").tagsManager('pushTag', tag);
          });

          $(".tm-facet").tagsManager('empty');
          $.each(result.facetValues, function(i,value) {
            $(".tm-facet").tagsManager('limitPushTags');
            $(".tm-facet").tagsManager('pushTag', value);
          });

          $(".tm-pinned-facets").tagsManager('empty');
          $.each(result.pinnedFacets, function(i, tag) {
            selection = $("#" + searchOptions.oid + '-facets').val();
            if (selection.indexOf(tag) < 0) {
              $(".tm-pinned-facets").tagsManager('limitPushTags');
              $(".tm-pinned-facets").tagsManager('pushTag', tag);
            }
          });

          update_counts(result.numFound);
        });
        */
      };

      init();
    },
  });
})(jQuery);
<|endoftext|>


<commit_before>const React = require('react');
const { Component } = require('react');
const { View, Text, Button } = require('react-native');

const testIDs = require('../testIDs');

const Navigation = require('react-native-navigation');

class WelcomeScreen extends Component {
  static get options() {
    return {
      topBar: {
        largeTitle: false
      }
    };
  }
  constructor(props) {
    super(props);
    this.onClickPush = this.onClickPush.bind(this);
    this.onClickShowModal = this.onClickShowModal.bind(this);
    this.onClickLifecycleScreen = this.onClickLifecycleScreen.bind(this);
    this.onClickPushOptionsScreen = this.onClickPushOptionsScreen.bind(this);
    this.onClickPushOrientationMenuScreen = this.onClickPushOrientationMenuScreen.bind(this);
    this.onClickBackHandler = this.onClickBackHandler.bind(this);
    this.onClickPushTopTabsScreen = this.onClickPushTopTabsScreen.bind(this);
  }

  render() {
    return (
      <View style={styles.root}>
        <Text testID={testIDs.WELCOME_SCREEN_HEADER} style={styles.h1}>{`React Native Navigation!`}</Text>
        <Button title="Switch to tab based app" testID={testIDs.TAB_BASED_APP_BUTTON} onPress={this.onClickSwitchToTabs} />
        <Button title="Switch to app with side menus" testID={testIDs.TAB_BASED_APP_SIDE_BUTTON} onPress={this.onClickSwitchToSideMenus} />
        <Button title="Push Lifecycle Screen" testID={testIDs.PUSH_LIFECYCLE_BUTTON} onPress={this.onClickLifecycleScreen} />
        <Button title="Push" testID={testIDs.PUSH_BUTTON} onPress={this.onClickPush} />
        <Button title="Push Options Screen" testID={testIDs.PUSH_OPTIONS_BUTTON} onPress={this.onClickPushOptionsScreen} />
        <Button title="Push Top Tabs screen" testID={testIDs.PUSH_TOP_TABS_BUTTON} onPress={this.onClickPushTopTabsScreen} />
        <Button title="Back Handler" testID={testIDs.BACK_HANDLER_BUTTON} onPress={this.onClickBackHandler} />
        <Button title="Show Modal" testID={testIDs.SHOW_MODAL_BUTTON} onPress={this.onClickShowModal} />
        <Button title="Show Redbox" testID={testIDs.SHOW_REDBOX_BUTTON} onPress={this.onClickShowRedbox} />
        <Button title="Orientation" testID={testIDs.ORIENTATION_BUTTON} onPress={this.onClickPushOrientationMenuScreen} />
        <Text style={styles.footer}>{`this.props.componentId = ${this.props.componentId}`}</Text>
      </View>
    );
  }

  onClickSwitchToTabs() {
    Navigation.setRoot({
      bottomTabs: {
        children: [
          {
            stack: {
              children: [
                {
                  component: {
                    name: 'navigation.playground.TextScreen',
                    passProps: {
                      text: 'This is tab 1',
                      myFunction: () => 'Hello from a function!'
                    },
                    options: {
                      bottomTab: {
                        title: 'Tab 1',
                        testID: testIDs.FIRST_TAB_BAR_BUTTON
                      }
                    }
                  }
                }
              ]
            }
          },
          {
            stack: {
              children: [
                {
                  component: {
                    name: 'navigation.playground.TextScreen',
                    passProps: {
                      text: 'This is tab 2'
                    },
                    options: {
                      bottomTab: {
                        title: 'Tab 2',
                        testID: testIDs.SECOND_TAB_BAR_BUTTON
                      }
                    }
                  }
                }
              ]
            }
          }
        ]
      }
    });
  }

  onClickSwitchToSideMenus() {
    Navigation.setRoot({
      sideMenu: {
        left: {
          component: {
            name: 'navigation.playground.SideMenuScreen',
            passProps: {
              side: 'left'
            }
          }
        },
        center: {
          bottomTabs: [
            {
              stack: {
                children: [
                  {
                    component: {
                      name: 'navigation.playground.TextScreen',
                      passProps: {
                        text: 'This is a side menu center screen tab 1'
                      }
                    }
                  }
                ]
              }
            },
            {
              stack: {
                children: [
                  {
                    component: {
                      name: 'navigation.playground.TextScreen',
                      passProps: {
                        text: 'This is a side menu center screen tab 2'
                      }
                    }
                  }
                ]
              }
            },
            {
              stack: {
                children: [
                  {
                    component: {
                      name: 'navigation.playground.TextScreen',
                      passProps: {
                        text: 'This is a side menu center screen tab 3'
                      }
                    }
                  }
                ]
              }
            }
          ]
        },
        right: {
          component: {
            name: 'navigation.playground.SideMenuScreen',
            passProps: {
              side: 'right'
            }
          }
        }
      }
    });
  }

  async onClickPush() {
    await Navigation.push(this.props.componentId, {
      component: {
        name: 'navigation.playground.PushedScreen'
      }
    });
  }

  onClickLifecycleScreen() {
    Navigation.push(this.props.componentId, {
      component: {
        name: 'navigation.playground.LifecycleScreen'
      }
    });
  }

  async onClickShowModal() {
    await Navigation.showModal({
      component: {
        name: 'navigation.playground.ModalScreen'
      }
    });
  }

  onClickShowRedbox() {
    undefined();
  }

  onClickPushOptionsScreen() {
    Navigation.push(this.props.componentId, {
      component: {
        name: 'navigation.playground.OptionsScreen'
      }
    });
  }

  onClickPushTopTabsScreen() {
    Navigation.push(this.props.componentId, {
      topTabs: [
        {
          name: 'navigation.playground.TopTabOptionsScreen',
          passProps: {
            title: 'Tab 1',
            text: 'This is top tab 1'
          },
          options: {
            topTab: {
              title: 'Tab 1'
            }
          }
        },
        {
          name: 'navigation.playground.TopTabScreen',
          passProps: {
            title: 'Tab 2',
            text: 'This is top tab 2'
          },
          options: {
            topTab: {
              title: 'Tab 2',
              titleFontFamily: 'HelveticaNeue-Italic'
            }
          }
        },
        {
          name: 'navigation.playground.TopTabScreen',
          passProps: {
            title: 'Tab 3',
            text: 'This is top tab 3'
          },
          options: {
            topTab: {
              title: 'Tab 3'
            }
          }
        }
      ],
      options: {
        topTabs: {
          selectedTabColor: '#12766b',
          unselectedTabColor: 'red',
          fontSize: 6
        }
      }
    });
  }

  onClickBackHandler() {
    Navigation.push(this.props.componentId, {
      component: {
        name: 'navigation.playground.BackHandlerScreen'
      }
    });
  }

  onClickPushOrientationMenuScreen() {
    Navigation.push(this.props.componentId, {
      component: {
        name: 'navigation.playground.OrientationSelectScreen'
      }
    });
  }
}

module.exports = WelcomeScreen;

const styles = {
  root: {
    flexGrow: 1,
    justifyContent: 'center',
    alignItems: 'center'
  },
  h1: {
    fontSize: 24,
    textAlign: 'center',
    margin: 30
  },
  footer: {
    fontSize: 10,
    color: '#888',
    marginTop: 10
  }
};
<commit_msg>fix e2e<commit_after>const React = require('react');
const { Component } = require('react');
const { View, Text, Button } = require('react-native');

const testIDs = require('../testIDs');

const Navigation = require('react-native-navigation');

class WelcomeScreen extends Component {
  static get options() {
    return {
      topBar: {
        largeTitle: false
      }
    };
  }
  constructor(props) {
    super(props);
    this.onClickPush = this.onClickPush.bind(this);
    this.onClickShowModal = this.onClickShowModal.bind(this);
    this.onClickLifecycleScreen = this.onClickLifecycleScreen.bind(this);
    this.onClickPushOptionsScreen = this.onClickPushOptionsScreen.bind(this);
    this.onClickPushOrientationMenuScreen = this.onClickPushOrientationMenuScreen.bind(this);
    this.onClickBackHandler = this.onClickBackHandler.bind(this);
    this.onClickPushTopTabsScreen = this.onClickPushTopTabsScreen.bind(this);
  }

  render() {
    return (
      <View style={styles.root}>
        <Text testID={testIDs.WELCOME_SCREEN_HEADER} style={styles.h1}>{`React Native Navigation!`}</Text>
        <Button title="Switch to tab based app" testID={testIDs.TAB_BASED_APP_BUTTON} onPress={this.onClickSwitchToTabs} />
        <Button title="Switch to app with side menus" testID={testIDs.TAB_BASED_APP_SIDE_BUTTON} onPress={this.onClickSwitchToSideMenus} />
        <Button title="Push Lifecycle Screen" testID={testIDs.PUSH_LIFECYCLE_BUTTON} onPress={this.onClickLifecycleScreen} />
        <Button title="Push" testID={testIDs.PUSH_BUTTON} onPress={this.onClickPush} />
        <Button title="Push Options Screen" testID={testIDs.PUSH_OPTIONS_BUTTON} onPress={this.onClickPushOptionsScreen} />
        <Button title="Push Top Tabs screen" testID={testIDs.PUSH_TOP_TABS_BUTTON} onPress={this.onClickPushTopTabsScreen} />
        <Button title="Back Handler" testID={testIDs.BACK_HANDLER_BUTTON} onPress={this.onClickBackHandler} />
        <Button title="Show Modal" testID={testIDs.SHOW_MODAL_BUTTON} onPress={this.onClickShowModal} />
        <Button title="Show Redbox" testID={testIDs.SHOW_REDBOX_BUTTON} onPress={this.onClickShowRedbox} />
        <Button title="Orientation" testID={testIDs.ORIENTATION_BUTTON} onPress={this.onClickPushOrientationMenuScreen} />
        <Text style={styles.footer}>{`this.props.componentId = ${this.props.componentId}`}</Text>
      </View>
    );
  }

  onClickSwitchToTabs() {
    Navigation.setRoot({
      bottomTabs: {
        children: [
          {
            stack: {
              children: [
                {
                  component: {
                    name: 'navigation.playground.TextScreen',
                    passProps: {
                      text: 'This is tab 1',
                      myFunction: () => 'Hello from a function!'
                    },
                    options: {
                      bottomTab: {
                        title: 'Tab 1',
                        testID: testIDs.FIRST_TAB_BAR_BUTTON
                      }
                    }
                  }
                }
              ]
            }
          },
          {
            stack: {
              children: [
                {
                  component: {
                    name: 'navigation.playground.TextScreen',
                    passProps: {
                      text: 'This is tab 2'
                    },
                    options: {
                      bottomTab: {
                        title: 'Tab 2',
                        testID: testIDs.SECOND_TAB_BAR_BUTTON
                      }
                    }
                  }
                }
              ]
            }
          }
        ]
      }
    });
  }

  onClickSwitchToSideMenus() {
    Navigation.setRoot({
      sideMenu: {
        left: {
          component: {
            name: 'navigation.playground.SideMenuScreen',
            passProps: {
              side: 'left'
            }
          }
        },
        center: {
          bottomTabs: {
            children: [
              {
                stack: {
                  children: [
                    {
                      component: {
                        name: 'navigation.playground.TextScreen',
                        passProps: {
                          text: 'This is a side menu center screen tab 1'
                        }
                      }
                    }
                  ]
                }
              },
              {
                stack: {
                  children: [
                    {
                      component: {
                        name: 'navigation.playground.TextScreen',
                        passProps: {
                          text: 'This is a side menu center screen tab 2'
                        }
                      }
                    }
                  ]
                }
              },
              {
                stack: {
                  children: [
                    {
                      component: {
                        name: 'navigation.playground.TextScreen',
                        passProps: {
                          text: 'This is a side menu center screen tab 3'
                        }
                      }
                    }
                  ]
                }
              }
            ]
          }
        },
        right: {
          component: {
            name: 'navigation.playground.SideMenuScreen',
            passProps: {
              side: 'right'
            }
          }
        }
      }
    });
  }

  async onClickPush() {
    await Navigation.push(this.props.componentId, {
      component: {
        name: 'navigation.playground.PushedScreen'
      }
    });
  }

  onClickLifecycleScreen() {
    Navigation.push(this.props.componentId, {
      component: {
        name: 'navigation.playground.LifecycleScreen'
      }
    });
  }

  async onClickShowModal() {
    await Navigation.showModal({
      component: {
        name: 'navigation.playground.ModalScreen'
      }
    });
  }

  onClickShowRedbox() {
    undefined();
  }

  onClickPushOptionsScreen() {
    Navigation.push(this.props.componentId, {
      component: {
        name: 'navigation.playground.OptionsScreen'
      }
    });
  }

  onClickPushTopTabsScreen() {
    Navigation.push(this.props.componentId, {
      topTabs: [
        {
          name: 'navigation.playground.TopTabOptionsScreen',
          passProps: {
            title: 'Tab 1',
            text: 'This is top tab 1'
          },
          options: {
            topTab: {
              title: 'Tab 1'
            }
          }
        },
        {
          name: 'navigation.playground.TopTabScreen',
          passProps: {
            title: 'Tab 2',
            text: 'This is top tab 2'
          },
          options: {
            topTab: {
              title: 'Tab 2',
              titleFontFamily: 'HelveticaNeue-Italic'
            }
          }
        },
        {
          name: 'navigation.playground.TopTabScreen',
          passProps: {
            title: 'Tab 3',
            text: 'This is top tab 3'
          },
          options: {
            topTab: {
              title: 'Tab 3'
            }
          }
        }
      ],
      options: {
        topTabs: {
          selectedTabColor: '#12766b',
          unselectedTabColor: 'red',
          fontSize: 6
        }
      }
    });
  }

  onClickBackHandler() {
    Navigation.push(this.props.componentId, {
      component: {
        name: 'navigation.playground.BackHandlerScreen'
      }
    });
  }

  onClickPushOrientationMenuScreen() {
    Navigation.push(this.props.componentId, {
      component: {
        name: 'navigation.playground.OrientationSelectScreen'
      }
    });
  }
}

module.exports = WelcomeScreen;

const styles = {
  root: {
    flexGrow: 1,
    justifyContent: 'center',
    alignItems: 'center'
  },
  h1: {
    fontSize: 24,
    textAlign: 'center',
    margin: 30
  },
  footer: {
    fontSize: 10,
    color: '#888',
    marginTop: 10
  }
};
<|endoftext|>


<commit_before>/* returns [0, 1, ..., n-1] */
let range = n => Array.from(Array(n).keys());

/* How should a vecn be composed, e.g. sizes 7 = [3,4] i.e. struct vec7 {vec3 a0, vec4 a1} */
let sizes = n => n <= 4 ? [n] : n == 5 ? [2, 3] : sizes(n - 4).concat([4]);

let computeidx = (k, n) => {
    let s = sizes(n);
    for (let i in s) {
        if (s[i] <= k) k -= s[i];
        else return {
            first: i,
            second: k
        };
    }
    console.error('Accessing index out of range');
};

//get childs of types that are formed from structs
function genchilds(t) {
    let fp = finalparameter(t);
    let d = depth(t);
    if (fp === type.complex) {
        let rt = replaceCbyR(t);
        return (d === 0 ? ["x", "y"] : ["real", "imag"]).map(name => ({
            type: rt,
            name: name
        }));
    } else if (issubtypeof(fp, type.float)) {
        if (d == 1) {
            return sizes(t.length).map((k, i) => ({
                type: type.vec(k),
                name: `a${i}`
            }));
        } else if (d => 2) {
            return range(t.length).map(i => ({
                type: t.parameters,
                name: `a${i}`
            }));
        }
    }
    return [];
}

function createstruct(t, codebuilder) {
    if (isnativeglsl(t)) return;
    let name = webgltype(t);
    codebuilder.add('structs', name, () => `struct ${name} { ${
    genchilds(t).map(ch => createstruct(ch.type, codebuilder) || `${webgltype(ch.type)} ${ch.name};`).join('')
  }};`);

}

function generatematmult(t, modifs, codebuilder) {
  if(isnativeglsl(t)) return;
  let n = t.length;
  let m = t.parameters.length;
    createstruct(type.vec(m), codebuilder);
    createstruct(type.vec(n), codebuilder);
    createstruct(t, codebuilder);
    let name = `mult${n}_${m}`;
    codebuilder.add('functions', name, () =>  `vec${n} mult${n}_${m}(mat${n}_${m} a, vec${m} b){` +
        'return ' + usevec(n)(range(n).map(k => usedot(m)([`a.a${k}`, 'b'], modifs, codebuilder)), modifs, codebuilder) + ';' +
        '}');
}

function generatecmatmult(t, modifs, codebuilder) {
  let n = t.length;
  let m = t.parameters.length;
    createstruct(type.vec(m), codebuilder);
    createstruct(type.vec(n), codebuilder);
    createstruct(t, codebuilder);
    let rt = replaceCbyR(t);
    let name = `cmult${n}_${m}`;
    //(A.real+i*A.imag)*(b.real+i*b.imag) = (A.real*b.real - A.imag*b.imag) + i *(A.real*b.imag+A.imag*b.real)
    // from measurements it turend that this is the fastest for 2x2 matrices (better than component wise complex multiplication or using [[a, -b], [b, a]] submatrices)
    codebuilder.add('functions', name, () =>  `cvec${n} cmult${n}_${m}(cmat${n}_${m} a, cvec${m} b){
      return cvec${n}(${
        usesub(rt.parameters)([
          usemult(rt)(['a.real','b.real'], modifs, codebuilder),
          usemult(rt)(['a.imag','b.imag'], modifs, codebuilder)
        ], modifs, codebuilder)
      },${
        useadd(rt.parameters)([
          usemult(rt)(['a.real','b.imag'], modifs, codebuilder),
          usemult(rt)(['a.imag','b.real'], modifs, codebuilder)
        ], modifs, codebuilder)
      });
    }`);
}

function generatedot(n, codebuilder) {
    if((2 <= n && n<=4)) return;
    createstruct(type.vec(n), codebuilder);
    let name = `dot${n}`;
    codebuilder.add('functions', name, () =>  `float dot${n}(vec${n} a, vec${n} b) {
    return ${ sizes(n).map((size, k) => `dot(a.a${k},b.a${k})`).join('+')}; }`);
}

function generateadd(t, modifs, codebuilder) {
    let name = `add${webgltype(t)}`;
    codebuilder.add('functions', name, () =>  `${webgltype(t)} ${name}(${webgltype(t)} a, ${webgltype(t)} b) {
    return ${webgltype(t)}(${
        genchilds(t).map(ch => `${webgltype(ch.type)}(${
          useadd(ch.type)([`a.${ch.name}`,`b.${ch.name}`], modifs, codebuilder)
        })`).join(',')
      });
    }`);
}

function generatesub(t, modifs, codebuilder) {
    let name = `sub${webgltype(t)}`;
    codebuilder.add('functions', name, () =>  `${webgltype(t)} ${name}(${webgltype(t)} a, ${webgltype(t)} b) {
    return ${webgltype(t)}(${
        genchilds(t).map(ch => `${webgltype(ch.type)}(${
          usesub(ch.type)([`a.${ch.name}`,`b.${ch.name}`], modifs, codebuilder)
        })`).join(',')
      });
    }`);
}

function generatescalarmult(t, modifs, codebuilder) {
    let name = `scalarmult${webgltype(t)}`;
    codebuilder.add('functions', name, () =>  `${webgltype(t)} ${name}(float a, ${webgltype(t)} b) {
    return ${webgltype(t)}(${
          genchilds(t).map(ch => `${webgltype(ch.type)}(${
            usescalarmult(ch.type)([`a`,`b.${ch.name}`], modifs, codebuilder)
          })`).join(',')
        });
    }`);
}

function generatecscalarmult(t, modifs, codebuilder) {
    let name = `cscalarmult${webgltype(t)}`;
    let rt = replaceCbyR(t);

    codebuilder.add('functions', name, () =>  `${webgltype(t)} ${name}(vec2 a, ${webgltype(t)} b) {
    return ${webgltype(t)}(${
      usesub(rt)([
        usescalarmult(rt)(['a.x','b.real'], modifs, codebuilder),
        usescalarmult(rt)(['a.y','b.imag'], modifs, codebuilder)
      ], modifs, codebuilder)
    },${
      useadd(rt)([
        usescalarmult(rt)(['a.x','b.imag'], modifs, codebuilder),
        usescalarmult(rt)(['a.y','b.real'], modifs, codebuilder)
      ], modifs, codebuilder)
    });}`);
}

function usemult(t) {
  if (isnativeglsl(t)) return useinfix('*');
  return (args, modifs, codebuilder) => generatematmult(t, modifs, codebuilder) || `mult${t.length}_${t.parameters.length}(${args.join(',')})`;
}

function usecmult(t) {
return (args, modifs, codebuilder) => generatematmult(t, modifs, codebuilder) || `cmult${t.length}_${t.parameters.length}(${args.join(',')})`;
}

function usedot(n) {
  return (args, modifs, codebuilder) => generatedot(n, codebuilder) || `dot${(2 <= n && n<=4) ? '' : n}(${args.join(',')})`;
}

function useadd(t) {
  if(isnativeglsl(t)) return useinfix('+');
  else return (args, modifs, codebuilder) => generateadd(t, modifs, codebuilder) || `add${webgltype(t)}(${args.join(',')})`;
}

function usesub(t) {
  if(isnativeglsl(t)) return useinfix('-');
  else return (args, modifs, codebuilder) => generatesub(t, modifs, codebuilder) || `sub${webgltype(t)}(${args.join(',')})`;
}

function usevec(n) {
    if(2 <= n && n <= 4) return args => `vec${n}(${args.join(',')})`;
    let cum = 0;
    return (args, modifs, codebuilder) => createstruct(type.vec(n), codebuilder) ||
        `vec${n}(${
        sizes(n).map( s =>
          `vec${s}(${range(s).map(l => ++cum && args[cum-1]).join(',')})`
        ).join(',')
      })`;
}

function usemat(n, m) { //create a nxm matrix by given n row-vectors of length m
    if(n == m && 2 <= n && n <= 4) //transpose by hand as it is not supported in WebGL
      return args => `mat${n}(${range(n).map(k => `vec${n}(${ //col k
      range(n).map(i => `${args[i]}[${k}]`).join(',')
    })`).join(',')}`;
    let cum = 0;
    return (args, modifs, codebuilder) => createstruct(list(n, type.vec(m)), codebuilder) ||
      `cmat${n}_${m}(${
          args.join(',')
      })`;
}

function usecvec(n) {
    return (args, modifs, codebuilder) => createstruct(type.cvec(n), codebuilder) ||
        `cvec${n}(${
          usevec(n)(args.map(a => `(${a}).x`), modifs, codebuilder)
        },${
          usevec(n)(args.map(a => `(${a}).y`), modifs, codebuilder)
        })`;
}

function accessvecbyshifted(n) {
  return (args, modifs, codebuilder) => { //works only for hardcoded glsl
      createstruct(type.vec(n), codebuilder);
      let k = Number(args[1]) - 1;
      if(2 <= n && n <= 4)
          return `(${args[0]})[${k}]`;
      let idx = computeidx(k, n);
      return `(${args[0]}).a${idx.first}[${idx.second}]`;
  };
}

function accesscvecbyshifted(n) {
  return (args, modifs, codebuilder) => { //works only for hardcoded glsl
      return `vec2(${
        accessvecbyshifted(n)([args[0]+'.real', args[1]], modifs, codebuilder)
      },${
        accessvecbyshifted(n)([args[0]+'.imag', args[1]], modifs, codebuilder)
      })`;
  };
}

function usescalarmult(t) { //assume t is a R or C-vectorspace
  if(isnativeglsl(t)) return useinfix('*');
  return (args, modifs, codebuilder) => generatescalarmult(t,modifs, codebuilder) || `scalarmult${webgltype(t)}(${args.join(',')})`;
}

function usecscalarmult(t) { //assume t is a C-vectorspace
  return (args, modifs, codebuilder) => generatecscalarmult(t,modifs, codebuilder) || `cscalarmult${webgltype(t)}(${args.join(',')})`;
}
<commit_msg>Fix bug for Kleinian Groups<commit_after>/* returns [0, 1, ..., n-1] */
let range = n => Array.from(Array(n).keys());

/* How should a vecn be composed, e.g. sizes 7 = [3,4] i.e. struct vec7 {vec3 a0, vec4 a1} */
let sizes = n => n <= 4 ? [n] : n == 5 ? [2, 3] : sizes(n - 4).concat([4]);

let computeidx = (k, n) => {
    let s = sizes(n);
    for (let i in s) {
        if (s[i] <= k) k -= s[i];
        else return {
            first: i,
            second: k
        };
    }
    console.error('Accessing index out of range');
};

//get childs of types that are formed from structs
function genchilds(t) {
    let fp = finalparameter(t);
    let d = depth(t);
    if (fp === type.complex) {
        let rt = replaceCbyR(t);
        return (d === 0 ? ["x", "y"] : ["real", "imag"]).map(name => ({
            type: rt,
            name: name
        }));
    } else if (issubtypeof(fp, type.float)) {
        if (d == 1) {
            return sizes(t.length).map((k, i) => ({
                type: type.vec(k),
                name: `a${i}`
            }));
        } else if (d => 2) {
            return range(t.length).map(i => ({
                type: t.parameters,
                name: `a${i}`
            }));
        }
    }
    return [];
}

function createstruct(t, codebuilder) {
    if (isnativeglsl(t)) return;
    let name = webgltype(t);
    codebuilder.add('structs', name, () => `struct ${name} { ${
    genchilds(t).map(ch => createstruct(ch.type, codebuilder) || `${webgltype(ch.type)} ${ch.name};`).join('')
  }};`);

}

function generatematmult(t, modifs, codebuilder) {
  if(isnativeglsl(t)) return;
  let n = t.length;
  let m = t.parameters.length;
    createstruct(type.vec(m), codebuilder);
    createstruct(type.vec(n), codebuilder);
    createstruct(t, codebuilder);
    let name = `mult${n}_${m}`;
    codebuilder.add('functions', name, () =>  `vec${n} mult${n}_${m}(mat${n}_${m} a, vec${m} b){` +
        'return ' + usevec(n)(range(n).map(k => usedot(m)([`a.a${k}`, 'b'], modifs, codebuilder)), modifs, codebuilder) + ';' +
        '}');
}

function generatecmatmult(t, modifs, codebuilder) {
  let n = t.length;
  let m = t.parameters.length;
    createstruct(type.vec(m), codebuilder);
    createstruct(type.vec(n), codebuilder);
    createstruct(t, codebuilder);
    let rt = replaceCbyR(t);
    let name = `cmult${n}_${m}`;
    //(A.real+i*A.imag)*(b.real+i*b.imag) = (A.real*b.real - A.imag*b.imag) + i *(A.real*b.imag+A.imag*b.real)
    // from measurements it turend that this is the fastest for 2x2 matrices (better than component wise complex multiplication or using [[a, -b], [b, a]] submatrices)
    codebuilder.add('functions', name, () =>  `cvec${n} cmult${n}_${m}(cmat${n}_${m} a, cvec${m} b){
      return cvec${n}(${
        usesub(rt.parameters)([
          usemult(rt)(['a.real','b.real'], modifs, codebuilder),
          usemult(rt)(['a.imag','b.imag'], modifs, codebuilder)
        ], modifs, codebuilder)
      },${
        useadd(rt.parameters)([
          usemult(rt)(['a.real','b.imag'], modifs, codebuilder),
          usemult(rt)(['a.imag','b.real'], modifs, codebuilder)
        ], modifs, codebuilder)
      });
    }`);
}

function generatedot(n, codebuilder) {
    if((2 <= n && n<=4)) return;
    createstruct(type.vec(n), codebuilder);
    let name = `dot${n}`;
    codebuilder.add('functions', name, () =>  `float dot${n}(vec${n} a, vec${n} b) {
    return ${ sizes(n).map((size, k) => `dot(a.a${k},b.a${k})`).join('+')}; }`);
}

function generateadd(t, modifs, codebuilder) {
    let name = `add${webgltype(t)}`;
    codebuilder.add('functions', name, () =>  `${webgltype(t)} ${name}(${webgltype(t)} a, ${webgltype(t)} b) {
    return ${webgltype(t)}(${
        genchilds(t).map(ch => `${webgltype(ch.type)}(${
          useadd(ch.type)([`a.${ch.name}`,`b.${ch.name}`], modifs, codebuilder)
        })`).join(',')
      });
    }`);
}

function generatesub(t, modifs, codebuilder) {
    let name = `sub${webgltype(t)}`;
    codebuilder.add('functions', name, () =>  `${webgltype(t)} ${name}(${webgltype(t)} a, ${webgltype(t)} b) {
    return ${webgltype(t)}(${
        genchilds(t).map(ch => `${webgltype(ch.type)}(${
          usesub(ch.type)([`a.${ch.name}`,`b.${ch.name}`], modifs, codebuilder)
        })`).join(',')
      });
    }`);
}

function generatescalarmult(t, modifs, codebuilder) {
    let name = `scalarmult${webgltype(t)}`;
    codebuilder.add('functions', name, () =>  `${webgltype(t)} ${name}(float a, ${webgltype(t)} b) {
    return ${webgltype(t)}(${
          genchilds(t).map(ch => `${webgltype(ch.type)}(${
            usescalarmult(ch.type)([`a`,`b.${ch.name}`], modifs, codebuilder)
          })`).join(',')
        });
    }`);
}

function generatecscalarmult(t, modifs, codebuilder) {
    let name = `cscalarmult${webgltype(t)}`;
    let rt = replaceCbyR(t);

    codebuilder.add('functions', name, () =>  `${webgltype(t)} ${name}(vec2 a, ${webgltype(t)} b) {
    return ${webgltype(t)}(${
      usesub(rt)([
        usescalarmult(rt)(['a.x','b.real'], modifs, codebuilder),
        usescalarmult(rt)(['a.y','b.imag'], modifs, codebuilder)
      ], modifs, codebuilder)
    },${
      useadd(rt)([
        usescalarmult(rt)(['a.x','b.imag'], modifs, codebuilder),
        usescalarmult(rt)(['a.y','b.real'], modifs, codebuilder)
      ], modifs, codebuilder)
    });}`);
}

function usemult(t) {
  if (isnativeglsl(t)) return useinfix('*');
  let fp = finalparameter(t);
  if(issubtypeof(fp, type.float))
    return (args, modifs, codebuilder) => generatematmult(t, modifs, codebuilder) || `mult${t.length}_${t.parameters.length}(${args.join(',')})`;
  else if(fp === type.complex)
    return (args, modifs, codebuilder) => generatecmatmult(t, modifs, codebuilder) || `cmult${t.length}_${t.parameters.length}(${args.join(',')})`;

}

function usedot(n) {
  return (args, modifs, codebuilder) => generatedot(n, codebuilder) || `dot${(2 <= n && n<=4) ? '' : n}(${args.join(',')})`;
}

function useadd(t) {
  if(isnativeglsl(t)) return useinfix('+');
  else return (args, modifs, codebuilder) => generateadd(t, modifs, codebuilder) || `add${webgltype(t)}(${args.join(',')})`;
}

function usesub(t) {
  if(isnativeglsl(t)) return useinfix('-');
  else return (args, modifs, codebuilder) => generatesub(t, modifs, codebuilder) || `sub${webgltype(t)}(${args.join(',')})`;
}

function usevec(n) {
    if(2 <= n && n <= 4) return args => `vec${n}(${args.join(',')})`;
    let cum = 0;
    return (args, modifs, codebuilder) => createstruct(type.vec(n), codebuilder) ||
        `vec${n}(${
        sizes(n).map( s =>
          `vec${s}(${range(s).map(l => ++cum && args[cum-1]).join(',')})`
        ).join(',')
      })`;
}

function usemat(n, m) { //create a nxm matrix by given n row-vectors of length m
    if(n == m && 2 <= n && n <= 4) //transpose by hand as it is not supported in WebGL
      return args => `mat${n}(${range(n).map(k => `vec${n}(${ //col k
      range(n).map(i => `${args[i]}[${k}]`).join(',')
    })`).join(',')}`;
    let cum = 0;
    return (args, modifs, codebuilder) => createstruct(list(n, type.vec(m)), codebuilder) ||
      `cmat${n}_${m}(${
          args.join(',')
      })`;
}

function usecvec(n) {
    return (args, modifs, codebuilder) => createstruct(type.cvec(n), codebuilder) ||
        `cvec${n}(${
          usevec(n)(args.map(a => `(${a}).x`), modifs, codebuilder)
        },${
          usevec(n)(args.map(a => `(${a}).y`), modifs, codebuilder)
        })`;
}

function accessvecbyshifted(n) {
  return (args, modifs, codebuilder) => { //works only for hardcoded glsl
      createstruct(type.vec(n), codebuilder);
      let k = Number(args[1]) - 1;
      if(2 <= n && n <= 4)
          return `(${args[0]})[${k}]`;
      let idx = computeidx(k, n);
      return `(${args[0]}).a${idx.first}[${idx.second}]`;
  };
}

function accesscvecbyshifted(n) {
  return (args, modifs, codebuilder) => { //works only for hardcoded glsl
      return `vec2(${
        accessvecbyshifted(n)([args[0]+'.real', args[1]], modifs, codebuilder)
      },${
        accessvecbyshifted(n)([args[0]+'.imag', args[1]], modifs, codebuilder)
      })`;
  };
}

function usescalarmult(t) { //assume t is a R or C-vectorspace
  if(isnativeglsl(t)) return useinfix('*');
  return (args, modifs, codebuilder) => generatescalarmult(t,modifs, codebuilder) || `scalarmult${webgltype(t)}(${args.join(',')})`;
}

function usecscalarmult(t) { //assume t is a C-vectorspace
  return (args, modifs, codebuilder) => generatecscalarmult(t,modifs, codebuilder) || `cscalarmult${webgltype(t)}(${args.join(',')})`;
}
<|endoftext|>


<commit_before>'use strict';

var util = require('util'),
  path = require('path'),
  slug = require('slug'),
  yeoman = require('yeoman-generator');

var BespokeGenerator = module.exports = function BespokeGenerator(args, options, config) {
  yeoman.generators.Base.apply(this, arguments);

  this.on('end', function () {
    this.installDependencies({ skipInstall: options['skip-install'] });
  });

  this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json')));
};

util.inherits(BespokeGenerator, yeoman.generators.NamedBase);

BespokeGenerator.prototype.askFor = function askFor() {
  var cb = this.async();

  // welcome message
  var welcome =
    "\n" +
    "\noooooooooo.                                          oooo                          o8o          ".cyan.bold +
    "\n`888'   `Y8b                                         `888                          `\"'          ".cyan.bold +
    "\n 888     888  .ooooo.   .oooo.o oo.ooooo.   .ooooo.   888  oooo   .ooooo.         oooo  .oooo.o ".cyan.bold +
    "\n 888oooo888' d88' `88b d88(  \"8  888' `88b d88' `88b  888 .8P'   d88' `88b        `888 d88(  \"8 ".cyan.bold +
    "\n 888    `88b 888ooo888 `\"Y88b.   888   888 888   888  888888.    888ooo888         888 `\"Y88b.  ".cyan.bold +
    "\n 888    .88P 888    .o o.  )88b  888   888 888   888  888 `88b.  888    .o .o.     888 o.  )88b ".cyan.bold +
    "\no888bood8P'  `Y8bod8P' 8\"\"888P'  888bod8P' `Y8bod8P' o888o o888o `Y8bod8P' Y8P     888 8\"\"888P' ".cyan.bold +
    "\n                                 888                                               888          ".cyan.bold +
    "\n                                o888o                                          .o. 88P          ".cyan.bold +
    "\n                                                                               `Y888P           ".cyan.bold +
    "\n" +
    "Thanks for choosing Bespoke.js for your presentation! :)   -@markdalgleish".green.bold +
    "\n";

  console.log(welcome);

  var prompts = [
    {
      name: 'title',
      message: 'What is the title of your presentation?',
      'default': 'Hello World'
    },
    {
      name: 'bullets',
      message: 'Would you like bullet list support?',
      'default': 'Y/n'
    },
    {
      name: 'hash',
      message: 'Would you like hash routing support?',
      'default': 'Y/n'
    },
    {
      name: 'state',
      message: 'Would you like slide-specific deck styles?',
      'default': 'Y/n'
    },
    {
      name: 'syntax',
      message: 'Would you like syntax highlighting?',
      'default': 'Y/n'
    }
  ];

  this.prompt(prompts, function (err, props) {
    if (err) {
      return this.emit('error', err);
    }

    this.bullets = (/^y/i).test(props.bullets);
    this.hash = (/^y/i).test(props.hash);
    this.state = (/^y/i).test(props.state);
    this.syntax = (/^y/i).test(props.syntax);
    this.title = props.title;
    this.shortName = slug(props.title).toLowerCase();

    cb();
  }.bind(this));
};

BespokeGenerator.prototype.setupProjectFiles = function setupProjectFiles() {
  this.template('Gruntfile.js', 'Gruntfile.js');

  this.copy('bowerrc', '.bowerrc');
  this.copy('gitignore', '.gitignore');
  this.copy('jshintrc', '.jshintrc');
}

BespokeGenerator.prototype.setupPackageJson = function setupPackageJson() {
  var packageJson = {
    'name': this.shortName + '-bespoke',
    'version': '0.0.0',
    'dependencies': {
      'grunt': '~0.4.1',
      'grunt-contrib-clean': '~0.4.0',
      'grunt-contrib-copy': '~0.4.1',
      'grunt-contrib-watch': '~0.5.1',
      'grunt-contrib-jade': '~0.5.0',
      'grunt-contrib-stylus': '~0.5.0',
      'grunt-contrib-coffee': '~0.7.0',
      'grunt-contrib-connect': '~0.3.0',
      'grunt-concurrent': '~0.3.0',
      'connect-livereload': '~0.2.0'
    }
  };
  this.write('package.json', JSON.stringify(packageJson, null, 2));
};

BespokeGenerator.prototype.setupBowerJson = function setupBowerJson() {
  var bowerJson = {
    'name': this.shortName + '-bespoke',
    'version': '0.0.0',
    'dependencies': {
      'bespoke.js': '~0.2.0'
    }
  };
  if (this.bullets) bowerJson.dependencies['bespoke-bullets'] = '~0.2.0';
  if (this.hash) bowerJson.dependencies['bespoke-hash'] = '~0.1.0';
  if (this.state) bowerJson.dependencies['bespoke-state'] = '~0.2.0';
  if (this.syntax) bowerJson.dependencies['prism'] = '*';
  this.write('bower.json', JSON.stringify(bowerJson, null, 2));
};

BespokeGenerator.prototype.setupBowerComponentPaths = function setupBowerComponentPaths() {
  this.bowerComponentPaths = ['bespoke.js/dist/bespoke.min.js'];
  this.bullets && this.bowerComponentPaths.push('bespoke-bullets/dist/bespoke-bullets.min.js');
  this.hash && this.bowerComponentPaths.push('bespoke-hash/dist/bespoke-hash.min.js');
  this.state && this.bowerComponentPaths.push('bespoke-state/dist/bespoke-state.min.js');
  this.syntax && this.bowerComponentPaths.push('prism/prism.js');
};

BespokeGenerator.prototype.setupPlugins = function setupPlugins() {
  var plugins = {};
  if (this.bullets) plugins['bullets'] = 'li, .bullet';
  if (this.hash) plugins['hash'] = true;
  if (this.state) plugins['state'] = true;
  this.hasPlugins = this.bullets || this.hash || this.state;
  this.pluginsJson = JSON.stringify(plugins, null, 2)
    .replace(/\"/g,"'") // Switch to single quotes
    .replace(/\'([a-z0-9_$]+)\'(:)/gi, '$1$2') // Unquote object keys
};

BespokeGenerator.prototype.setupFiles = function setupFiles() {
  this.mkdir('src');
  this.mkdir('src/scripts');
  this.mkdir('src/styles');

  this.template('src/index.jade', 'src/index.jade');
  this.template('src/scripts/main.js', 'src/scripts/main.js');
  this.template('src/styles/main.styl', 'src/styles/main.styl');
};<commit_msg>Switch 'dependencies' to 'devDependencies'<commit_after>'use strict';

var util = require('util'),
  path = require('path'),
  slug = require('slug'),
  yeoman = require('yeoman-generator');

var BespokeGenerator = module.exports = function BespokeGenerator(args, options, config) {
  yeoman.generators.Base.apply(this, arguments);

  this.on('end', function () {
    this.installDependencies({ skipInstall: options['skip-install'] });
  });

  this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json')));
};

util.inherits(BespokeGenerator, yeoman.generators.NamedBase);

BespokeGenerator.prototype.askFor = function askFor() {
  var cb = this.async();

  // welcome message
  var welcome =
    "\n" +
    "\noooooooooo.                                          oooo                          o8o          ".cyan.bold +
    "\n`888'   `Y8b                                         `888                          `\"'          ".cyan.bold +
    "\n 888     888  .ooooo.   .oooo.o oo.ooooo.   .ooooo.   888  oooo   .ooooo.         oooo  .oooo.o ".cyan.bold +
    "\n 888oooo888' d88' `88b d88(  \"8  888' `88b d88' `88b  888 .8P'   d88' `88b        `888 d88(  \"8 ".cyan.bold +
    "\n 888    `88b 888ooo888 `\"Y88b.   888   888 888   888  888888.    888ooo888         888 `\"Y88b.  ".cyan.bold +
    "\n 888    .88P 888    .o o.  )88b  888   888 888   888  888 `88b.  888    .o .o.     888 o.  )88b ".cyan.bold +
    "\no888bood8P'  `Y8bod8P' 8\"\"888P'  888bod8P' `Y8bod8P' o888o o888o `Y8bod8P' Y8P     888 8\"\"888P' ".cyan.bold +
    "\n                                 888                                               888          ".cyan.bold +
    "\n                                o888o                                          .o. 88P          ".cyan.bold +
    "\n                                                                               `Y888P           ".cyan.bold +
    "\n" +
    "Thanks for choosing Bespoke.js for your presentation! :)   -@markdalgleish".green.bold +
    "\n";

  console.log(welcome);

  var prompts = [
    {
      name: 'title',
      message: 'What is the title of your presentation?',
      'default': 'Hello World'
    },
    {
      name: 'bullets',
      message: 'Would you like bullet list support?',
      'default': 'Y/n'
    },
    {
      name: 'hash',
      message: 'Would you like hash routing support?',
      'default': 'Y/n'
    },
    {
      name: 'state',
      message: 'Would you like slide-specific deck styles?',
      'default': 'Y/n'
    },
    {
      name: 'syntax',
      message: 'Would you like syntax highlighting?',
      'default': 'Y/n'
    }
  ];

  this.prompt(prompts, function (err, props) {
    if (err) {
      return this.emit('error', err);
    }

    this.bullets = (/^y/i).test(props.bullets);
    this.hash = (/^y/i).test(props.hash);
    this.state = (/^y/i).test(props.state);
    this.syntax = (/^y/i).test(props.syntax);
    this.title = props.title;
    this.shortName = slug(props.title).toLowerCase();

    cb();
  }.bind(this));
};

BespokeGenerator.prototype.setupProjectFiles = function setupProjectFiles() {
  this.template('Gruntfile.js', 'Gruntfile.js');

  this.copy('bowerrc', '.bowerrc');
  this.copy('gitignore', '.gitignore');
  this.copy('jshintrc', '.jshintrc');
}

BespokeGenerator.prototype.setupPackageJson = function setupPackageJson() {
  var packageJson = {
    'name': this.shortName + '-bespoke',
    'version': '0.0.0',
    'dependencies': {},
    'devDependencies': {
      'grunt': '~0.4.1',
      'grunt-contrib-clean': '~0.4.0',
      'grunt-contrib-copy': '~0.4.1',
      'grunt-contrib-watch': '~0.5.1',
      'grunt-contrib-jade': '~0.5.0',
      'grunt-contrib-stylus': '~0.5.0',
      'grunt-contrib-coffee': '~0.7.0',
      'grunt-contrib-connect': '~0.3.0',
      'grunt-concurrent': '~0.3.0',
      'connect-livereload': '~0.2.0'
    }
  };
  this.write('package.json', JSON.stringify(packageJson, null, 2));
};

BespokeGenerator.prototype.setupBowerJson = function setupBowerJson() {
  var bowerJson = {
    'name': this.shortName + '-bespoke',
    'version': '0.0.0',
    'dependencies': {
      'bespoke.js': '~0.2.0'
    }
  };
  if (this.bullets) bowerJson.dependencies['bespoke-bullets'] = '~0.2.0';
  if (this.hash) bowerJson.dependencies['bespoke-hash'] = '~0.1.0';
  if (this.state) bowerJson.dependencies['bespoke-state'] = '~0.2.0';
  if (this.syntax) bowerJson.dependencies['prism'] = '*';
  this.write('bower.json', JSON.stringify(bowerJson, null, 2));
};

BespokeGenerator.prototype.setupBowerComponentPaths = function setupBowerComponentPaths() {
  this.bowerComponentPaths = ['bespoke.js/dist/bespoke.min.js'];
  this.bullets && this.bowerComponentPaths.push('bespoke-bullets/dist/bespoke-bullets.min.js');
  this.hash && this.bowerComponentPaths.push('bespoke-hash/dist/bespoke-hash.min.js');
  this.state && this.bowerComponentPaths.push('bespoke-state/dist/bespoke-state.min.js');
  this.syntax && this.bowerComponentPaths.push('prism/prism.js');
};

BespokeGenerator.prototype.setupPlugins = function setupPlugins() {
  var plugins = {};
  if (this.bullets) plugins['bullets'] = 'li, .bullet';
  if (this.hash) plugins['hash'] = true;
  if (this.state) plugins['state'] = true;
  this.hasPlugins = this.bullets || this.hash || this.state;
  this.pluginsJson = JSON.stringify(plugins, null, 2)
    .replace(/\"/g,"'") // Switch to single quotes
    .replace(/\'([a-z0-9_$]+)\'(:)/gi, '$1$2') // Unquote object keys
};

BespokeGenerator.prototype.setupFiles = function setupFiles() {
  this.mkdir('src');
  this.mkdir('src/scripts');
  this.mkdir('src/styles');

  this.template('src/index.jade', 'src/index.jade');
  this.template('src/scripts/main.js', 'src/scripts/main.js');
  this.template('src/styles/main.styl', 'src/styles/main.styl');
};<|endoftext|>


<commit_before>
var safariLinks = "https://apple.com/; https://parse.com; https://trello.com/; https://bitbucket.org; https://github.com/; https://sidefield.com; https://news.ycombinator.com; https://www.reddit.com/r/all; https://www.youtube.com/; https://pinboard.in/u:umfana; http://xkcd.com/; https://twitter.com; https://facebook.com; https://dropbox.com; http://getbootstrap.com/; https://mail.google.com; https://buffer.com/; http://facebook.github.io/react/; http://facebook.github.io/react-native/; http://www.munichirishrovers.de/; https://www.bitfountain.io/; http://www.pivotaltracker.com/; https://talky.io/; https://www.evernote.com/; https://c9.io/; https://delicious.com/umfana; http://ionicframework.com/docs/components/; https://www.quora.com/; https://web.whatsapp.com/; https://www.coinbase.com/; https://www.fastmail.com/mail/Inbox/?u=1c944178; http://umfana.github.io/FaviconBar/";

var FaviconLink = React.createClass({
	render: function() {
		var url = this.props.url;
		return (

			{url}
			Edit

);
	}
});

var FaviconSettings = React.createClass({
	render: function() {
		var links = safariLinks.split(";"); // safari.extension.settings.links.split(";");
		var linksHtml = links.map(function(l){
			return (<FaviconLink url={l.trim()} />)
		});

		return (
{linksHtml}
);
	}
});

var FaviconSettingsFactory = React.createFactory(FaviconSettings);

React.render(FaviconSettingsFactory(), document.getElementById("settingsContainer"));<commit_msg>Removed unnecessary factory creation as JSXTransformer does the transform to JS<commit_after>
var safariLinks = "https://apple.com/; https://parse.com; https://trello.com/; https://bitbucket.org; https://github.com/; https://sidefield.com; https://news.ycombinator.com; https://www.reddit.com/r/all; https://www.youtube.com/; https://pinboard.in/u:umfana; http://xkcd.com/; https://twitter.com; https://facebook.com; https://dropbox.com; http://getbootstrap.com/; https://mail.google.com; https://buffer.com/; http://facebook.github.io/react/; http://facebook.github.io/react-native/; http://www.munichirishrovers.de/; https://www.bitfountain.io/; http://www.pivotaltracker.com/; https://talky.io/; https://www.evernote.com/; https://c9.io/; https://delicious.com/umfana; http://ionicframework.com/docs/components/; https://www.quora.com/; https://web.whatsapp.com/; https://www.coinbase.com/; https://www.fastmail.com/mail/Inbox/?u=1c944178; http://umfana.github.io/FaviconBar/";

var FaviconLink = React.createClass({
	render: function() {
		var url = this.props.url;
		return (

			{url}
			Edit

);
	}
});

var FaviconSettings = React.createClass({
	render: function() {
		var links = safariLinks.split(";"); // safari.extension.settings.links.split(";");
		var linksHtml = links.map(function(l){
			return (<FaviconLink url={l.trim()} />)
		});

		return (
{linksHtml}
);
	}
});

React.render(<FaviconSettings/>, document.getElementById("settingsContainer"));<|endoftext|>


<commit_before>'use strict';

/* Controllers */

angular.module('myApp.controllers', []).
  controller('MyCtrl1', ['$scope', '$log', function($s, $log) {

  		//mock data
  		 $s.data={

	  		interval_1h:[
	  			{
	  				time:'14/02/25 15:00-16:00',
	  				activities: ['School', 'Social'],
	  				mood:'5',
	  			},

	  			{
	  				time:'14/02/25 17:00-18:00',
	  				activities: ['School', 'Social', 'loling'],
	  				mood:'2',
	  			},

	  			{
	  				time:'14/02/25 18:00-19:00',
	  				activities: ['School', 'Social', 'rofling'],
	  				mood:'1',
	  			}
	  		],

	  		interval_6h:[
	  			{
	  				activities: ['School', 'Social', 'something else'],
	  				mood:'2',
	  				time:'14/02/25 12:00-18:00'
	  			},

	  			{
	  				activities: ['School', 'work', 'something else'],
	  				mood:'3',
	  				time:'14/02/25 12:00-18:00'
	  			},
	  	]
	  };
  	//init

  		$s.currentIntervals=$s.data.interval_1h
			$log.log($s.displayInterval);
			$s.displayInterval=$s.data.interval_1h[0]
		//

  		$s.chooseInterval = function(interval){
  			$s.displayInterval=interval;
  		};

  		$log.log($s.displayInterval.mood);

  		$s.getColor = function(interval){
  			if(interval.mood==5){
  			return "{backgroundColor:'blue'}";
  			}
  			else return "{backgroundColor:'red'}";
  		};

	  	if($s.displayInterval.mood==2){
	  		$log.log($s.displayInterval.mood);
	  	  $s.moodColor = "{backgroundColor:'blue'}";
	  	}

	}

]);<commit_msg>Intervals have color based on mood<commit_after>'use strict';

/* Controllers */

angular.module('myApp.controllers', []).
  controller('MyCtrl1', ['$scope', '$log', function($s, $log) {

  		//mock data
  		 $s.data={

	  		interval_1h:[
	  			{
	  				time:'14/02/25 15:00-16:00',
	  				activities: ['School', 'Social'],
	  				mood:'5',
	  			},

	  			{
	  				time:'14/02/25 17:00-18:00',
	  				activities: ['School', 'Social', 'loling'],
	  				mood:'4',
	  			},

	  			{
	  				time:'14/02/25 17:00-18:00',
	  				activities: ['School', 'Social', 'loling'],
	  				mood:'3',
	  			},

	  			{
	  				time:'14/02/25 17:00-18:00',
	  				activities: ['School', 'Social', 'loling'],
	  				mood:'2',
	  			},

	  			{
	  				time:'14/02/25 18:00-19:00',
	  				activities: ['School', 'Social', 'rofling'],
	  				mood:'1',
	  			}
	  		],

	  		interval_6h:[
	  			{
	  				activities: ['School', 'Social', 'something else'],
	  				mood:'2',
	  				time:'14/02/25 12:00-18:00'
	  			},

	  			{
	  				activities: ['School', 'work', 'something else'],
	  				mood:'3',
	  				time:'14/02/25 12:00-18:00'
	  			},
	  	]
	  };
  	//init

  		$s.currentIntervals=$s.data.interval_1h
			$log.log($s.displayInterval);
			$s.displayInterval=$s.data.interval_1h[0]
		//

  		$s.chooseInterval = function(interval){
  			$s.displayInterval=interval;
  		};

  		$log.log($s.displayInterval.mood);

  		$s.getColor = function(interval){
  			if(interval.mood==5){
  			return "{backgroundColor:'#39E539'}";
  			};
  			if(interval.mood==4){
  			return "{backgroundColor:'#67E567'}";
  			}
  			if(interval.mood==3){
  			return "{backgroundColor:'#76FF9A'}";
  			};
  			if(interval.mood==2){
  			return "{backgroundColor:'#76FFC4'}";
  			};
  			if(interval.mood==1){
  			return "{backgroundColor:'#B4DFFF'}";
  			};

  		};

	}

]);<|endoftext|>