<commit_before>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require limiter.js
//= require jquery.inview.min.js
//= require social-share-button
//= require_tree .

  //google analytics
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-48009508-1', 'refcod.es');
  ga('send', 'pageview');

  // clicky analytics -->
  var clicky_site_ids = clicky_site_ids || [];
  clicky_site_ids.push(100705761);
  (function() {
    var s = document.createElement('script');
    s.type = 'text/javascript';
    s.async = true;
    s.src = '//static.getclicky.com/js';
    ( document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0] ).appendChild( s );
  })();

  !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');

  // twitter follow button
  !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');

  // UserVoice JavaScript SDK (only needed once on a page) -->
  (function(){var uv=document.createElement('script');uv.type='text/javascript';uv.async=true;uv.src='//widget.uservoice.com/EgD4KZo9EPDjNEajN1qqRA.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(uv,s)})()

// Include the UserVoice JavaScript SDK (only needed once on a page)
UserVoice=window.UserVoice||[];(function(){var uv=document.createElement('script');uv.type='text/javascript';uv.async=true;uv.src='//widget.uservoice.com/EgD4KZo9EPDjNEajN1qqRA.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(uv,s)})();

//
// UserVoice Javascript SDK developer documentation:
// https://www.uservoice.com/o/javascript-sdk
//

// Set colors
UserVoice.push(['set', {
  accent_color: '#448dd6',
  trigger_color: 'white',
  trigger_background_color: 'rgba(46, 49, 51, 0.6)'
}]);

// Identify the user and pass traits
// To enable, replace sample data with actual user traits and uncomment the line
UserVoice.push(['identify', {
  //email:      'john.doe@example.com', // User’s email address
  //name:       'John Doe', // User’s real name
  //created_at: 1364406966, // Unix timestamp for the date the user signed up
  //id:         123, // Optional: Unique id of the user (if set, this should not change)
  //type:       'Owner', // Optional: segment your users by type
  //account: {
  //  id:           123, // Optional: associate multiple users with a single account
  //  name:         'Acme, Co.', // Account name
  //  created_at:   1364406966, // Unix timestamp for the date the account was created
  //  monthly_rate: 9.99, // Decimal; monthly rate of the account
  //  ltv:          1495.00, // Decimal; lifetime value of the account
  //  plan:         'Enhanced' // Plan name for the account
  //}
}]);

// Add default trigger to the bottom-right corner of the window:
UserVoice.push(['addTrigger', { mode: 'contact', trigger_position: 'bottom-right' }]);

// Or, use your own custom trigger:
//UserVoice.push(['addTrigger', '#id', { mode: 'contact' }]);

// Autoprompt for Satisfaction and SmartVote (only displayed under certain conditions)
UserVoice.push(['autoprompt', {}]);<commit_msg>remove social share button from asset pipeline - no longer using it<commit_after>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require limiter.js
//= require jquery.inview.min.js
//= require_tree .

  //google analytics
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-48009508-1', 'refcod.es');
  ga('send', 'pageview');

  // clicky analytics -->
  var clicky_site_ids = clicky_site_ids || [];
  clicky_site_ids.push(100705761);
  (function() {
    var s = document.createElement('script');
    s.type = 'text/javascript';
    s.async = true;
    s.src = '//static.getclicky.com/js';
    ( document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0] ).appendChild( s );
  })();

  !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');

  // twitter follow button
  !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');

  // UserVoice JavaScript SDK (only needed once on a page) -->
  (function(){var uv=document.createElement('script');uv.type='text/javascript';uv.async=true;uv.src='//widget.uservoice.com/EgD4KZo9EPDjNEajN1qqRA.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(uv,s)})()

// Include the UserVoice JavaScript SDK (only needed once on a page)
UserVoice=window.UserVoice||[];(function(){var uv=document.createElement('script');uv.type='text/javascript';uv.async=true;uv.src='//widget.uservoice.com/EgD4KZo9EPDjNEajN1qqRA.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(uv,s)})();

//
// UserVoice Javascript SDK developer documentation:
// https://www.uservoice.com/o/javascript-sdk
//

// Set colors
UserVoice.push(['set', {
  accent_color: '#448dd6',
  trigger_color: 'white',
  trigger_background_color: 'rgba(46, 49, 51, 0.6)'
}]);

// Identify the user and pass traits
// To enable, replace sample data with actual user traits and uncomment the line
UserVoice.push(['identify', {
  //email:      'john.doe@example.com', // User’s email address
  //name:       'John Doe', // User’s real name
  //created_at: 1364406966, // Unix timestamp for the date the user signed up
  //id:         123, // Optional: Unique id of the user (if set, this should not change)
  //type:       'Owner', // Optional: segment your users by type
  //account: {
  //  id:           123, // Optional: associate multiple users with a single account
  //  name:         'Acme, Co.', // Account name
  //  created_at:   1364406966, // Unix timestamp for the date the account was created
  //  monthly_rate: 9.99, // Decimal; monthly rate of the account
  //  ltv:          1495.00, // Decimal; lifetime value of the account
  //  plan:         'Enhanced' // Plan name for the account
  //}
}]);

// Add default trigger to the bottom-right corner of the window:
UserVoice.push(['addTrigger', { mode: 'contact', trigger_position: 'bottom-right' }]);

// Or, use your own custom trigger:
//UserVoice.push(['addTrigger', '#id', { mode: 'contact' }]);

// Autoprompt for Satisfaction and SmartVote (only displayed under certain conditions)
UserVoice.push(['autoprompt', {}]);<|endoftext|>


<commit_before>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require turbolinks
<commit_msg>heroku work<commit_after>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require chatlogs
//= require bootstrap
//= require turbolinks
<|endoftext|>


<commit_before>// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
//
//= require prefix
//= require jquery
//= require jquery_ujs
//= require jquery.cookie
//= require jquery.ui.autocomplete
//= require compat.jquery
//= require mousetrap
//= require cookie
//= require dmail
//= require favorite
//= require forum
//= require user_record
//= require_tree .
<commit_msg>Require I18n-js at application.js<commit_after>// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
//
//= require prefix
//= require jquery
//= require jquery_ujs
//= require jquery.cookie
//= require jquery.ui.autocomplete
//= require compat.jquery
//= require mousetrap
//= require i18n
//= i18n/translations
//= require i18n_scopify
//= require cookie
//= require dmail
//= require favorite
//= require forum
//= require user_record
//= require_tree .
<|endoftext|>


<commit_before>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree
//= require d3
<commit_msg>ADd foundation to application.js and function document foundaiton method<commit_after>// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require foundation
//= require turbolinks
//= require_tree
//= require d3

$(function(){ $(document).foundation(); });
<|endoftext|>


<commit_before>//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .

$(document).ready(function() {
  registerForm()

  renderEditUserForm()
  editUserInfo()

  renderEditOrgInfo()
  editOrganizationInfo()

  renderEditProjectForm()
  editProjectInfo()
  chooseProject()

  bookmarkProject()
  unbookmarkProject()

  completeProject()
  abandonProject()

  orgForm()

  agreementConfirm()
  agreementAlert()
});

function registerForm(){
  $('#dev').click(function() {
    $('#devform').show();
    // $('#panel-dev').css('background-color','blue')
    // $('#devform').css('border-color','red')
    $("html,body").animate({ scrollTop: $('.jumbotron').height() }, "slow");
    $('#orgform').hide();
  })
  $('#org').click(function() {
    $('#orgform').show();
    // $('#orgform').css('border-style','solid')
    // $('#orgform').css('border-color','blue')
    // $(this).css('color','black');
    $("html,body").animate({ scrollTop: $('.jumbotron').height() }, "slow");
    $('#devform').hide();
  })
}

function orgForm(){
    $('html,body').animate({scrollTop: $('#new_org_form').height()}, "slow")
  }

function renderEditUserForm(){
  $('#developer-container').on("click", ".display-edit-developer-form", function(event){
    event.preventDefault()
    var userID = $("input").first().val()
    var request = $.ajax({
      url: "/users/" + userID + "/edit",
      type: "GET"
    })
    request.done(function(response){
      $('#developer-container').html(response)
    })
  })
}

function editUserInfo(){
  $('#developer-container').on("click", ".update-developer-profile", function(event){
    event.preventDefault()
    var userInfo = $(".edit-developer-form").serialize()
    var request = $.ajax({
      url: "/users/:id",
      type: "PUT",
      data: userInfo
    })
    request.done(function(response){
      $('#developer-container').html(response)
    })
  })
}

function renderEditOrgInfo(){
  $('#organization-container').on('click', '.edit-account', function(event){
    event.preventDefault()
    var orgId = $("#organization_id").val()
    var request = $.ajax({
      url: '/organizations/' + orgId + "/edit",
      type: "GET",
    })
    request.done(function(response){
      $('#organization-container').html(response)
    })
  })
}

function editOrganizationInfo(){
  $('#organization-container').on("click", ".update-org", function(event){
    event.preventDefault()
    var orgInfo = $("#edit-org-form").serialize()
    var orgId = $("#organization_id").val()
    var request = $.ajax({
      url: "/organizations/" + orgId,
      type: "PUT",
      data: orgInfo
    })
    request.done(function(response){
      $('#organization-container').html(response)
     })
    })
  }

function renderEditProjectForm(){
  $('#project-container').on("click", "#get-project-edit", function(e){
    e.preventDefault();
    var projectID = $('#project_id').val()
    var request = $.ajax({
      url: "/projects/" + projectID + "/edit",
      type: "GET"
    })
    request.done(function(response){
      $('#project-container').html(response)
    })
  })
}

function editProjectInfo(){
  $('#project-container').on("click", "#submit-project-update", function(e){
    e.preventDefault();
    var projectInfo = $("#project-edit-form").serialize()
    var projectID = $('#project_id').val()
    debugger
    console.log("Got to editProjectInfo")
    var request = $.ajax({
      url: "/projects/" + projectID,
      type: "PUT",
      data: projectInfo
    })
    request.done(function(response){
      $('#project-container').html(response)

    })
  })
}

function chooseProject(){
  $('#project-container').on("click", "#choose-project", function(event){
    event.preventDefault();
    var projectID = $("#project_id").val()
    var currentUserID = $("#current_user_id").val()
    console.log({project: { id: projectID, developer_id: "" } })
    var request = $.ajax({
      url: "/projects/" + projectID,
      type: "PUT",
      data: {project: { id: projectID, developer_id: currentUserID}}
    })
    request.done(function(response){
      $('#project-container').html(response)
    })
  })
}

function completeProject(){
  $('#project-container').on("click", "#complete-project", function(event){
    event.preventDefault();
    var projectID = $("#project_id").val()
    var currentUserID = $("#current_user_id").val()
    var request = $.ajax({
      url: "/projects/" + projectID,
      type: "PUT",
      data: {project: { id: projectID, developer_id: ""}}
    })
    request.done(function(response){
      $('#project-container').html(response)
    })
  })
}

// Not yet sure how this will be different from complete project
function abandonProject(){
  $('#project-container').on("click", "#abandon-project", function(event){
    event.preventDefault();
    var projectID = $("#project_id").val()
    var currentUserID = $("#current_user_id").val()
    var request = $.ajax({
      url: "/projects/" + projectID,
      type: "PUT",
      data: {project: { id: projectID, developer_id: ""}}
    })
    request.done(function(response){
      $('#project-container').html(response)
    })
  })
}
// Possible to refactor chooseProject and editProjectInfo to use the same ajax and such. Identical except for click and projectInfo

function bookmarkProject(){
  $('#projects-container').on('click', '.fa-bookmark-o', function(e){
    e.preventDefault();
    var projectId = $(this).attr('id')
    projectId = projectId.match(/\d+/).join()
    var userId = $(this).parent().parent().attr('id')
    userId = userId.match(/\d+/).join()

    var data = {bookmark: {project_id: projectId, developer_id: userId}}

    var request = $.ajax({
      url: "/bookmarks",
      type: "POST",
      data: data
    })
    request.done(function(response){
      console.log(response)
      var newBookmark = $.parseHTML(response)
      var bookmarkID = $(newBookmark).attr('id')
      $('#' + bookmarkID).children().first().replaceWith(newBookmark)
    })
  })
}

function unbookmarkProject(){
  $('#projects-container').on('click', '.fa-bookmark', function(e){
    e.preventDefault();

    var projectId = $(this).attr('id')
    projectId = projectId.match(/\d+/).join()

    var userId = $(this).parent().parent().attr('id')
    userId = userId.match(/\d+/).join()

    var bookmarkId = $(this).attr('class') //third class listed
    bookmarkId = bookmarkId.split(" ")[2].slice(-2)
    var data = {bookmark: {project_id: projectId, developer_id: userId}}

    var request = $.ajax({
      url: "/bookmarks/" + bookmarkId,
      type: "DELETE",
      data: data
    })
    request.done(function(response){
      newBookmark = $.parseHTML(response)
      bookmarkID = $(newBookmark).attr('id')
      $('#' + bookmarkID).children().first().replaceWith(newBookmark)
      // now target the <li> with id project(numId)
    })
  })
}
  // onsubmit="if(document.getElementById('agree').checked) { return true; } else { alert('Please indicate that you have read and agree to the Terms and Conditions and Privacy Policy'); return false; }

function agreementConfirm(){
  $('.container').on('submit', '.sign-up-form', function(){
    // e.preventDefault();
    if(document.getElementById('agree').checked)
      { return true;
       }
    else { alert('Please indicate that you have read and agree to the Terms and Conditions and Privacy Policy'); return false; }
    });
}

function agreementAlert(){
  $('.container').on('click', '.agreement-alert', function(){
    alert("asdfl;ksadfsadlfkas;dlf;alksdf;lkadsfl;sadfjasdfjas")
  })
}

<commit_msg>Start composing agreements<commit_after>//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .

$(document).ready(function() {
  registerForm()

  renderEditUserForm()
  editUserInfo()

  renderEditOrgInfo()
  editOrganizationInfo()

  renderEditProjectForm()
  editProjectInfo()
  chooseProject()

  bookmarkProject()
  unbookmarkProject()

  completeProject()
  abandonProject()

  orgForm()

  agreementConfirm()
  agreementAlert()
});

function registerForm(){
  $('#dev').click(function() {
    $('#devform').show();
    // $('#panel-dev').css('background-color','blue')
    // $('#devform').css('border-color','red')
    $("html,body").animate({ scrollTop: $('.jumbotron').height() }, "slow");
    $('#orgform').hide();
  })
  $('#org').click(function() {
    $('#orgform').show();
    // $('#orgform').css('border-style','solid')
    // $('#orgform').css('border-color','blue')
    // $(this).css('color','black');
    $("html,body").animate({ scrollTop: $('.jumbotron').height() }, "slow");
    $('#devform').hide();
  })
}

function orgForm(){
    $('html,body').animate({scrollTop: $('#new_org_form').height()}, "slow")
  }

function renderEditUserForm(){
  $('#developer-container').on("click", ".display-edit-developer-form", function(event){
    event.preventDefault()
    var userID = $("input").first().val()
    var request = $.ajax({
      url: "/users/" + userID + "/edit",
      type: "GET"
    })
    request.done(function(response){
      $('#developer-container').html(response)
    })
  })
}

function editUserInfo(){
  $('#developer-container').on("click", ".update-developer-profile", function(event){
    event.preventDefault()
    var userInfo = $(".edit-developer-form").serialize()
    var request = $.ajax({
      url: "/users/:id",
      type: "PUT",
      data: userInfo
    })
    request.done(function(response){
      $('#developer-container').html(response)
    })
  })
}

function renderEditOrgInfo(){
  $('#organization-container').on('click', '.edit-account', function(event){
    event.preventDefault()
    var orgId = $("#organization_id").val()
    var request = $.ajax({
      url: '/organizations/' + orgId + "/edit",
      type: "GET",
    })
    request.done(function(response){
      $('#organization-container').html(response)
    })
  })
}

function editOrganizationInfo(){
  $('#organization-container').on("click", ".update-org", function(event){
    event.preventDefault()
    var orgInfo = $("#edit-org-form").serialize()
    var orgId = $("#organization_id").val()
    var request = $.ajax({
      url: "/organizations/" + orgId,
      type: "PUT",
      data: orgInfo
    })
    request.done(function(response){
      $('#organization-container').html(response)
     })
    })
  }

function renderEditProjectForm(){
  $('#project-container').on("click", "#get-project-edit", function(e){
    e.preventDefault();
    var projectID = $('#project_id').val()
    var request = $.ajax({
      url: "/projects/" + projectID + "/edit",
      type: "GET"
    })
    request.done(function(response){
      $('#project-container').html(response)
    })
  })
}

function editProjectInfo(){
  $('#project-container').on("click", "#submit-project-update", function(e){
    e.preventDefault();
    var projectInfo = $("#project-edit-form").serialize()
    var projectID = $('#project_id').val()
    debugger
    console.log("Got to editProjectInfo")
    var request = $.ajax({
      url: "/projects/" + projectID,
      type: "PUT",
      data: projectInfo
    })
    request.done(function(response){
      $('#project-container').html(response)

    })
  })
}

function chooseProject(){
  $('#project-container').on("click", "#choose-project", function(event){
    event.preventDefault();
    var projectID = $("#project_id").val()
    var currentUserID = $("#current_user_id").val()
    console.log({project: { id: projectID, developer_id: "" } })
    var request = $.ajax({
      url: "/projects/" + projectID,
      type: "PUT",
      data: {project: { id: projectID, developer_id: currentUserID}}
    })
    request.done(function(response){
      $('#project-container').html(response)
    })
  })
}

function completeProject(){
  $('#project-container').on("click", "#complete-project", function(event){
    event.preventDefault();
    var projectID = $("#project_id").val()
    var currentUserID = $("#current_user_id").val()
    var request = $.ajax({
      url: "/projects/" + projectID,
      type: "PUT",
      data: {project: { id: projectID, developer_id: ""}}
    })
    request.done(function(response){
      $('#project-container').html(response)
    })
  })
}

// Not yet sure how this will be different from complete project
function abandonProject(){
  $('#project-container').on("click", "#abandon-project", function(event){
    event.preventDefault();
    var projectID = $("#project_id").val()
    var currentUserID = $("#current_user_id").val()
    var request = $.ajax({
      url: "/projects/" + projectID,
      type: "PUT",
      data: {project: { id: projectID, developer_id: ""}}
    })
    request.done(function(response){
      $('#project-container').html(response)
    })
  })
}
// Possible to refactor chooseProject and editProjectInfo to use the same ajax and such. Identical except for click and projectInfo

function bookmarkProject(){
  $('#projects-container').on('click', '.fa-bookmark-o', function(e){
    e.preventDefault();
    var projectId = $(this).attr('id')
    projectId = projectId.match(/\d+/).join()
    var userId = $(this).parent().parent().attr('id')
    userId = userId.match(/\d+/).join()

    var data = {bookmark: {project_id: projectId, developer_id: userId}}

    var request = $.ajax({
      url: "/bookmarks",
      type: "POST",
      data: data
    })
    request.done(function(response){
      console.log(response)
      var newBookmark = $.parseHTML(response)
      var bookmarkID = $(newBookmark).attr('id')
      $('#' + bookmarkID).children().first().replaceWith(newBookmark)
    })
  })
}

function unbookmarkProject(){
  $('#projects-container').on('click', '.fa-bookmark', function(e){
    e.preventDefault();

    var projectId = $(this).attr('id')
    projectId = projectId.match(/\d+/).join()

    var userId = $(this).parent().parent().attr('id')
    userId = userId.match(/\d+/).join()

    var bookmarkId = $(this).attr('class') //third class listed
    bookmarkId = bookmarkId.split(" ")[2].slice(-2)
    var data = {bookmark: {project_id: projectId, developer_id: userId}}

    var request = $.ajax({
      url: "/bookmarks/" + bookmarkId,
      type: "DELETE",
      data: data
    })
    request.done(function(response){
      newBookmark = $.parseHTML(response)
      bookmarkID = $(newBookmark).attr('id')
      $('#' + bookmarkID).children().first().replaceWith(newBookmark)
      // now target the <li> with id project(numId)
    })
  })
}
  // onsubmit="if(document.getElementById('agree').checked) { return true; } else { alert('Please indicate that you have read and agree to the Terms and Conditions and Privacy Policy'); return false; }

function agreementConfirm(){
  $('.container').on('submit', '.sign-up-form', function(){
    // e.preventDefault();
    if(document.getElementById('agree').checked)
      { return true;
       }
    else { alert('Please indicate that you have read and agree to the Terms and Conditions and Privacy Policy'); return false; }
    });
}

function agreementAlert(){
  $('.container').on('click', '.agreement-alert', function(){
    alert("For organizations that post projects, there are no guarantees that your project will get chosen.  If your project is chosen, it is the responsibility of both parties to communicate about needs and expectations.  Be aware that there are no guarantees of a finished product and no guarantee that an organization will choose to utilize a finished product")
  })
}

<|endoftext|>


<commit_before>getJasmineRequireObj().DelayedFunctionScheduler = function() {
  function DelayedFunctionScheduler() {
    var self = this;
    var scheduledLookup = [];
    var scheduledFunctions = {};
    var currentTime = 0;
    var delayedFnCount = 0;

    self.tick = function(millis) {
      millis = millis || 0;
      var endTime = currentTime + millis;

      runScheduledFunctions(endTime);
      currentTime = endTime;
    };

    self.scheduleFunction = function(funcToCall, millis, params, recurring, timeoutKey, runAtMillis) {
      var f;
      if (typeof(funcToCall) === 'string') {
        /* jshint evil: true */
        f = function() { return eval(funcToCall); };
        /* jshint evil: false */
      } else {
        f = funcToCall;
      }

      millis = millis || 0;
      timeoutKey = timeoutKey || ++delayedFnCount;
      runAtMillis = runAtMillis || (currentTime + millis);

      var funcToSchedule = {
        runAtMillis: runAtMillis,
        funcToCall: f,
        recurring: recurring,
        params: params,
        timeoutKey: timeoutKey,
        millis: millis
      };

      if (runAtMillis in scheduledFunctions) {
        scheduledFunctions[runAtMillis].push(funcToSchedule);
      } else {
        scheduledFunctions[runAtMillis] = [funcToSchedule];
        scheduledLookup.push(runAtMillis);
        scheduledLookup.sort(function (a, b) {
          return a - b;
        });
      }

      return timeoutKey;
    };

    self.removeFunctionWithId = function(timeoutKey) {
      for (var runAtMillis in scheduledFunctions) {
        var funcs = scheduledFunctions[runAtMillis];
        var i = indexOfFirstToPass(funcs, function (func) {
          return func.timeoutKey === timeoutKey;
        });

        if (i > -1) {
          if (funcs.length === 1) {
            delete scheduledFunctions[runAtMillis];
            deleteFromLookup(runAtMillis);
          } else {
            funcs.splice(i, 1);
          }

          // intervals get rescheduled when executed, so there's never more
          // than a single scheduled function with a given timeoutKey
          break;
        }
      }
    };

    self.reset = function() {
      currentTime = 0;
      scheduledLookup = [];
      scheduledFunctions = {};
      delayedFnCount = 0;
    };

    return self;

    function indexOfFirstToPass(array, testFn) {
      var index = -1;

      for (var i = 0; i < array.length; ++i) {
        if (testFn(array[i])) {
          index = i;
          break;
        }
      }

      return index;
    }

    function deleteFromLookup(key) {
      var value = Number(key);
      var i = indexOfFirstToPass(scheduledLookup, function (millis) {
        return millis === value;
      });

      if (i > -1) {
        scheduledLookup.splice(i, 1);
      }
    }

    function reschedule(scheduledFn) {
      self.scheduleFunction(scheduledFn.funcToCall,
        scheduledFn.millis,
        scheduledFn.params,
        true,
        scheduledFn.timeoutKey,
        scheduledFn.runAtMillis + scheduledFn.millis);
    }

    function runScheduledFunctions(endTime) {
      if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) {
        return;
      }

      do {
        currentTime = scheduledLookup.shift();

        var funcsToRun = scheduledFunctions[currentTime];
        delete scheduledFunctions[currentTime];

        for (var i = 0; i < funcsToRun.length; ++i) {
          var funcToRun = funcsToRun[i];
          funcToRun.funcToCall.apply(null, funcToRun.params || []);

          if (funcToRun.recurring) {
            reschedule(funcToRun);
          }
        }
      } while (scheduledLookup.length > 0 &&
              // checking first if we're out of time prevents setTimeout(0)
              // scheduled in a funcToRun from forcing an extra iteration
                 currentTime !== endTime  &&
                 scheduledLookup[0] <= endTime);
    }
  }

  return DelayedFunctionScheduler;
};
<commit_msg>Allow clearInterval to clear it's own interval<commit_after>getJasmineRequireObj().DelayedFunctionScheduler = function() {
  function DelayedFunctionScheduler() {
    var self = this;
    var scheduledLookup = [];
    var scheduledFunctions = {};
    var currentTime = 0;
    var delayedFnCount = 0;

    self.tick = function(millis) {
      millis = millis || 0;
      var endTime = currentTime + millis;

      runScheduledFunctions(endTime);
      currentTime = endTime;
    };

    self.scheduleFunction = function(funcToCall, millis, params, recurring, timeoutKey, runAtMillis) {
      var f;
      if (typeof(funcToCall) === 'string') {
        /* jshint evil: true */
        f = function() { return eval(funcToCall); };
        /* jshint evil: false */
      } else {
        f = funcToCall;
      }

      millis = millis || 0;
      timeoutKey = timeoutKey || ++delayedFnCount;
      runAtMillis = runAtMillis || (currentTime + millis);

      var funcToSchedule = {
        runAtMillis: runAtMillis,
        funcToCall: f,
        recurring: recurring,
        params: params,
        timeoutKey: timeoutKey,
        millis: millis
      };

      if (runAtMillis in scheduledFunctions) {
        scheduledFunctions[runAtMillis].push(funcToSchedule);
      } else {
        scheduledFunctions[runAtMillis] = [funcToSchedule];
        scheduledLookup.push(runAtMillis);
        scheduledLookup.sort(function (a, b) {
          return a - b;
        });
      }

      return timeoutKey;
    };

    self.removeFunctionWithId = function(timeoutKey) {
      for (var runAtMillis in scheduledFunctions) {
        var funcs = scheduledFunctions[runAtMillis];
        var i = indexOfFirstToPass(funcs, function (func) {
          return func.timeoutKey === timeoutKey;
        });

        if (i > -1) {
          if (funcs.length === 1) {
            delete scheduledFunctions[runAtMillis];
            deleteFromLookup(runAtMillis);
          } else {
            funcs.splice(i, 1);
          }

          // intervals get rescheduled when executed, so there's never more
          // than a single scheduled function with a given timeoutKey
          break;
        }
      }
    };

    self.reset = function() {
      currentTime = 0;
      scheduledLookup = [];
      scheduledFunctions = {};
      delayedFnCount = 0;
    };

    return self;

    function indexOfFirstToPass(array, testFn) {
      var index = -1;

      for (var i = 0; i < array.length; ++i) {
        if (testFn(array[i])) {
          index = i;
          break;
        }
      }

      return index;
    }

    function deleteFromLookup(key) {
      var value = Number(key);
      var i = indexOfFirstToPass(scheduledLookup, function (millis) {
        return millis === value;
      });

      if (i > -1) {
        scheduledLookup.splice(i, 1);
      }
    }

    function reschedule(scheduledFn) {
      self.scheduleFunction(scheduledFn.funcToCall,
        scheduledFn.millis,
        scheduledFn.params,
        true,
        scheduledFn.timeoutKey,
        scheduledFn.runAtMillis + scheduledFn.millis);
    }

    function runScheduledFunctions(endTime) {
      if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) {
        return;
      }

      do {
        currentTime = scheduledLookup.shift();

        var funcsToRun = scheduledFunctions[currentTime];
        delete scheduledFunctions[currentTime];

        for (var i = 0; i < funcsToRun.length; ++i) {
          var funcToRun = funcsToRun[i];

          if (funcToRun.recurring) {
            reschedule(funcToRun);
          }

          funcToRun.funcToCall.apply(null, funcToRun.params || []);
        }
      } while (scheduledLookup.length > 0 &&
              // checking first if we're out of time prevents setTimeout(0)
              // scheduled in a funcToRun from forcing an extra iteration
                 currentTime !== endTime  &&
                 scheduledLookup[0] <= endTime);
    }
  }

  return DelayedFunctionScheduler;
};
<|endoftext|>


<commit_before>//
// jQuery
//---------------------------------------------------------------------------//

$(function() {

  // Hide Elements //

  if (!$('#job_blastn_job_attributes_queue').is(':checked')) {
    $('#blastn').hide();
  }

  if (!$('#job_blastx_job_attributes_queue').is(':checked')) {
    $('#blastx').hide();
  }

  if (!$('#job_tblastn_job_attributes_queue').is(':checked')) {
    $('#tblastn').hide();
  }

  if (!$('#job_blastp_job_attributes_queue').is(':checked')) {
    $('#blastp').hide();
  }

  // End Elements //

  // Form //

  var form = $('form :input.auto-hint');
  form.autoHint();

  // Toggle Algorithms //

  $('#job_blastn_job_attributes_queue').change(function() {
    $('#blastn').slideToggle();
  });

  $('#job_blastx_job_attributes_queue').change(function() {
    $('#blastx').slideToggle();
  });

  $('#job_tblastn_job_attributes_queue').change(function() {
    $('#tblastn').slideToggle();
  });

  $('#job_blastp_job_attributes_queue').change(function() {
    $('#blastp').slideToggle();
  });

  // End Algorithms //

  // Disable submit button and remove input values equal to attr title.
  $('form').submit(function() {
    $('input[type=submit]', this).val('Processing...').attr(
      'disabled', 'disabled'
    );

    form.autoHint('removeHints');
  });

  // Reset form.
  $('#quorum_job_reset').click(function() {
    $('textarea').val('');
    $('input:text').val('');
    $('input:file').val('');
    $('input:checkbox').prop('checked', false);
    $('select').val('');

    $('.toggle').each(function() {
      $(this).hide();
    });

    form.autoHint('addHints');
  });

  // End Form //

  // Views //

  // Tabs
  $('#tabs').tabs();

  // End Views //

});

<commit_msg>Enable form submit button on window unload after submit.<commit_after>//
// jQuery
//---------------------------------------------------------------------------//

$(function() {

  // Hide Elements //

  if (!$('#job_blastn_job_attributes_queue').is(':checked')) {
    $('#blastn').hide();
  }

  if (!$('#job_blastx_job_attributes_queue').is(':checked')) {
    $('#blastx').hide();
  }

  if (!$('#job_tblastn_job_attributes_queue').is(':checked')) {
    $('#tblastn').hide();
  }

  if (!$('#job_blastp_job_attributes_queue').is(':checked')) {
    $('#blastp').hide();
  }

  // End Elements //

  // Form //

  var form = $('form :input.auto-hint');
  form.autoHint();

  // Toggle Algorithms //

  $('#job_blastn_job_attributes_queue').change(function() {
    $('#blastn').slideToggle();
  });

  $('#job_blastx_job_attributes_queue').change(function() {
    $('#blastx').slideToggle();
  });

  $('#job_tblastn_job_attributes_queue').change(function() {
    $('#tblastn').slideToggle();
  });

  $('#job_blastp_job_attributes_queue').change(function() {
    $('#blastp').slideToggle();
  });

  // End Algorithms //

  // Disable submit button and remove input values equal to attr title.
  $('form').submit(function() {
    $('input[type=submit]', this).val('Processing...').attr(
      'disabled', 'disabled'
    );

    form.autoHint('removeHints');
  });

  $(window).unload(function() {
    $('input[type=submit]', 'form').val('Submit').removeAttr('disabled');
  });

  // Reset form.
  $('#quorum_job_reset').click(function() {
    $('textarea').val('');
    $('input:text').val('');
    $('input:file').val('');
    $('input:checkbox').prop('checked', false);
    $('select').val('');

    $('.toggle').each(function() {
      $(this).hide();
    });

    form.autoHint('addHints');
  });

  // End Form //

  // Views //

  // Tabs
  $('#tabs').tabs();

  // End Views //

});

<|endoftext|>


<commit_before>(function(){
    'use strict';

    angular
        .module('doi_cms_app')
        .controller('mainCtrl', mainCtrl)
    ;

    function mainCtrl(APIDOIService, client, $scope, $location, $log, $sce) {
        var vm = this;
        vm.tab = "list";
        $scope.base_url = apps_url;
        vm.newdoixml = "";
        vm.pp = 50;

        var app_id = "";
        app_id = $location.search().app_id;
        if (!app_id) app_id = $location.search().app_id_select;

        if ($location.search().tab) vm.tab = $location.search().tab;

        vm.client = client.data.client;

        $scope.$watch('vm.tab', function(newv){
            vm.changeTab(newv);
        });

        vm.changeTab = function(tab) {
            switch (tab) {
                case 'list':
                    vm.refreshDOIs();
                    break;
                case 'log':
                    APIDOIService.getLog(vm.client.app_id).then(function(data){
                        vm.logs = data.data.activities;
                    });
                    break;
                case 'mint':
                    var doi_client_id = vm.client.client_id;
                    if (vm.client.client_id < 10) {
                        doi_client_id = 0+""+vm.client.client_id;
                    }
                    vm.editxml = false;
                    vm.response = false;
                    vm.newdoi_url = '';
                    vm.newdoi_id = vm.client.datacite_prefix + doi_client_id +'/'+ vm.uniqid();
                    vm.newdoixml = APIDOIService.getBlankDataciteXML(vm.newdoi_id);
                    break;
            }
        }

        vm.refreshDOIs = function(search) {
            if (!search) search = false;
            APIDOIService.getDOIList(vm.client.app_id, vm.pp, 0, search).then(function(data){
                vm.dois = data.data.dois;
                vm.total = data.data.total;
                vm.offset = vm.pp;
            });
        }

        vm.doisListNext = function(offset) {
            APIDOIService.getDOIList(vm.client.app_id, vm.pp, offset).then(function(data){
                vm.dois = vm.dois.concat(data.data.dois);
                vm.total = data.data.total;
                vm.offset += vm.pp;
            });
        }

        vm.view = function(doi, keep) {
            if (!keep) {
                vm.response = false;
            }
            vm.editxml = false;
            vm.tab = 'view';
            APIDOIService.getDOI(doi, vm.client.app_id).then(function(data){
                vm.readonly = true;
                $scope.$broadcast('readonly', vm.readonly);
                vm.viewdoi = data.data;
            });
        }

        vm.update = function(doi) {
            vm.editxml = false;
            vm.tab = 'view';
            vm.response = false;
            APIDOIService.getDOI(doi, vm.client.app_id).then(function(data){
                vm.readonly = false;
                $scope.$broadcast('readonly', vm.readonly);
                vm.viewdoi = data.data;
            });
        }

        vm.mint = function() {
            $scope.$broadcast('update');
            var data = {
                xml : vm.stripBlankElements(vm.newdoixml),
                app_id : vm.client.app_id,
                url : vm.newdoi_url,
                doi : vm.newdoi_id,
                client_id: vm.client.client_id
            }
            vm.loading = true;
            vm.response = false;
            APIDOIService.mint(data).then(function(response){
                vm.loading = false;
                vm.response = response.response;
                if (vm.response.doi) {
                    vm.view(vm.response.doi, true);
                }
            });
        }

        vm.cancel = function() {
            vm.viewdoi = false;
            vm.response = false;
            vm.tab = 'list';
        }

        vm.doupdate = function() {
            $scope.$broadcast('update');
            var data = {
                xml : vm.stripBlankElements(vm.viewdoi.datacite_xml),
                app_id : vm.client.app_id,
                url : vm.viewdoi.url,
                doi : vm.viewdoi.doi_id,
                client_id: vm.client.client_id
            }
            vm.loading = true;
            vm.response = false;
            APIDOIService.update(data).then(function(response){
                vm.loading = false;
                vm.response = response.response;
                if (response.response.type!='failure' && vm.response.doi) {
                    vm.view(vm.response.doi, true);
                }
            });
        }

        vm.dodeactivate = function(doi_id) {
            var data = {
                app_id : vm.client.app_id,
                doi : doi_id,
                client_id: vm.client.client_id
            }
            vm.response = {};
            APIDOIService.deactivate(data).then(function(response){
                alert(response.response.message);
                vm.refreshDOIs();
            });
        }

        vm.doactivate = function(doi_id) {
            var data = {
                app_id : vm.client.app_id,
                doi : doi_id,
                client_id: vm.client.client_id
            }
            vm.response = {};
            APIDOIService.activate(data).then(function(response){
                alert(response.response.message);
                vm.refreshDOIs();
            });
        }

        vm.dolinkcheck = function() {
            vm.linkchecking = true;
            APIDOIService.checkLinks(vm.client.app_id).then(function(response){
                vm.linkchecking = false;
                vm.link_checker_result = $sce.trustAsHtml(response.message);
            });
        }

        vm.uniqid = function(prefix, more_entropy) {
          //  discuss at: http://phpjs.org/functions/uniqid/
          // original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
          //  revised by: Kankrelune (http://www.webfaktory.info/)
          //        note: Uses an internal counter (in php_js global) to avoid collision
          //        test: skip
          //   example 1: uniqid();
          //   returns 1: 'a30285b160c14'
          //   example 2: uniqid('foo');
          //   returns 2: 'fooa30285b1cd361'
          //   example 3: uniqid('bar', true);
          //   returns 3: 'bara20285b23dfd1.31879087'

          if (typeof prefix === 'undefined') {
            prefix = '';
          }

          var retId;
          var formatSeed = function(seed, reqWidth) {
            seed = parseInt(seed, 10)
              .toString(16); // to hex str
            if (reqWidth < seed.length) { // so long we split
              return seed.slice(seed.length - reqWidth);
            }
            if (reqWidth > seed.length) { // so short we pad
              return Array(1 + (reqWidth - seed.length))
                .join('0') + seed;
            }
            return seed;
          };

          // BEGIN REDUNDANT
          if (!this.php_js) {
            this.php_js = {};
          }
          // END REDUNDANT
          if (!this.php_js.uniqidSeed) { // init seed with big random int
            this.php_js.uniqidSeed = Math.floor(Math.random() * 0x75bcd15);
          }
          this.php_js.uniqidSeed++;

          retId = prefix; // start with prefix, add current milliseconds hex string
          retId += formatSeed(parseInt(new Date()
            .getTime() / 1000, 10), 8);
          retId += formatSeed(this.php_js.uniqidSeed, 5); // add seed hex string
          if (more_entropy) {
            // for more entropy we add a float lower to 10
            retId += (Math.random() * 10)
              .toFixed(8)
              .toString();
          }

          return retId;
        }

        vm.formatXml = function(xml) {
            var reg = /(>)\s*(<)(\/*)/g; // updated Mar 30, 2015
            var wsexp = / *(.*) +\n/g;
            var contexp = /(<.+>)(.+\n)/g;
            xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
            var pad = 0;
            var formatted = '';
            var lines = xml.split('\n');
            var indent = 0;
            var lastType = 'other';
            // 4 types of tags - single, closing, opening, other (text, doctype, comment) - 4*4 = 16 transitions
            var transitions = {
                'single->single': 0,
                'single->closing': -1,
                'single->opening': 0,
                'single->other': 0,
                'closing->single': 0,
                'closing->closing': -1,
                'closing->opening': 0,
                'closing->other': 0,
                'opening->single': 1,
                'opening->closing': 0,
                'opening->opening': 1,
                'opening->other': 1,
                'other->single': 0,
                'other->closing': -1,
                'other->opening': 0,
                'other->other': 0
            };

            for (var i = 0; i < lines.length; i++) {
                var ln = lines[i];
                var single = Boolean(ln.match(/<.+\/>/)); // is this line a single tag? ex.

                var closing = Boolean(ln.match(/<\/.+>/)); // is this a closing tag? ex.
                var opening = Boolean(ln.match(/<[^!].*>/)); // is this even a tag (that's not <!something>)
                var type = single ? 'single' : closing ? 'closing' : opening ? 'opening' : 'other';
                var fromTo = lastType + '->' + type;
                lastType = type;
                var padding = '';

                indent += transitions[fromTo];
                for (var j = 0; j < indent; j++) {
                    padding += '\t';
                }
                if (fromTo == 'opening->closing')
                    formatted = formatted.substr(0, formatted.length - 1) + ln + '\n'; // substr removes line break (\n) from prev loop
                else
                    formatted += padding + ln + '\n';
            }

            return formatted;
        }

        vm.stripBlankElements = function(xml) {
            try {
                var dom = $.parseXML(xml);
                //$('*:empty', dom).remove();
                $("*", dom).filter(function(){
                    var tagName = $( this ).prop( "tagName" );
                    if (tagName !== "resourceType") {
                        return $.trim(this.textContent) === "";
                    }
                }).remove();
                return (new XMLSerializer()).serializeToString(dom);
            } catch (e) {
                return xml;
            }

        }

    }
})();<commit_msg>MyDOIS. Mint with failure now stopped at the edit screen accordingly.<commit_after>(function(){
    'use strict';

    angular
        .module('doi_cms_app')
        .controller('mainCtrl', mainCtrl)
    ;

    function mainCtrl(APIDOIService, client, $scope, $location, $log, $sce) {
        var vm = this;
        vm.tab = "list";
        $scope.base_url = apps_url;
        vm.newdoixml = "";
        vm.pp = 50;

        var app_id = "";
        app_id = $location.search().app_id;
        if (!app_id) app_id = $location.search().app_id_select;

        if ($location.search().tab) vm.tab = $location.search().tab;

        vm.client = client.data.client;

        $scope.$watch('vm.tab', function(newv){
            vm.changeTab(newv);
        });

        vm.changeTab = function(tab) {
            switch (tab) {
                case 'list':
                    vm.refreshDOIs();
                    break;
                case 'log':
                    APIDOIService.getLog(vm.client.app_id).then(function(data){
                        vm.logs = data.data.activities;
                    });
                    break;
                case 'mint':
                    var doi_client_id = vm.client.client_id;
                    if (vm.client.client_id < 10) {
                        doi_client_id = 0+""+vm.client.client_id;
                    }
                    vm.editxml = false;
                    vm.response = false;
                    vm.newdoi_url = '';
                    vm.newdoi_id = vm.client.datacite_prefix + doi_client_id +'/'+ vm.uniqid();
                    vm.newdoixml = APIDOIService.getBlankDataciteXML(vm.newdoi_id);
                    break;
            }
        }

        vm.refreshDOIs = function(search) {
            if (!search) search = false;
            APIDOIService.getDOIList(vm.client.app_id, vm.pp, 0, search).then(function(data){
                vm.dois = data.data.dois;
                vm.total = data.data.total;
                vm.offset = vm.pp;
            });
        }

        vm.doisListNext = function(offset) {
            APIDOIService.getDOIList(vm.client.app_id, vm.pp, offset).then(function(data){
                vm.dois = vm.dois.concat(data.data.dois);
                vm.total = data.data.total;
                vm.offset += vm.pp;
            });
        }

        vm.view = function(doi, keep) {
            if (!keep) {
                vm.response = false;
            }
            vm.editxml = false;
            vm.tab = 'view';
            APIDOIService.getDOI(doi, vm.client.app_id).then(function(data){
                vm.readonly = true;
                $scope.$broadcast('readonly', vm.readonly);
                vm.viewdoi = data.data;
            });
        }

        vm.update = function(doi) {
            vm.editxml = false;
            vm.tab = 'view';
            vm.response = false;
            APIDOIService.getDOI(doi, vm.client.app_id).then(function(data){
                vm.readonly = false;
                $scope.$broadcast('readonly', vm.readonly);
                vm.viewdoi = data.data;
            });
        }

        vm.mint = function() {
            $scope.$broadcast('update');
            var data = {
                xml : vm.stripBlankElements(vm.newdoixml),
                app_id : vm.client.app_id,
                url : vm.newdoi_url,
                doi : vm.newdoi_id,
                client_id: vm.client.client_id
            }
            vm.loading = true;
            vm.response = false;
            APIDOIService.mint(data).then(function(response){
                vm.loading = false;
                vm.response = response.response;
                if (vm.response.doi && vm.response.type!="failure") {
                    vm.view(vm.response.doi, true);
                }
            });
        }

        vm.cancel = function() {
            vm.viewdoi = false;
            vm.response = false;
            vm.tab = 'list';
        }

        vm.doupdate = function() {
            $scope.$broadcast('update');
            var data = {
                xml : vm.stripBlankElements(vm.viewdoi.datacite_xml),
                app_id : vm.client.app_id,
                url : vm.viewdoi.url,
                doi : vm.viewdoi.doi_id,
                client_id: vm.client.client_id
            }
            vm.loading = true;
            vm.response = false;
            APIDOIService.update(data).then(function(response){
                vm.loading = false;
                vm.response = response.response;
                if (response.response.type!='failure' && vm.response.doi) {
                    vm.view(vm.response.doi, true);
                }
            });
        }

        vm.dodeactivate = function(doi_id) {
            var data = {
                app_id : vm.client.app_id,
                doi : doi_id,
                client_id: vm.client.client_id
            }
            vm.response = {};
            APIDOIService.deactivate(data).then(function(response){
                alert(response.response.message);
                vm.refreshDOIs();
            });
        }

        vm.doactivate = function(doi_id) {
            var data = {
                app_id : vm.client.app_id,
                doi : doi_id,
                client_id: vm.client.client_id
            }
            vm.response = {};
            APIDOIService.activate(data).then(function(response){
                alert(response.response.message);
                vm.refreshDOIs();
            });
        }

        vm.dolinkcheck = function() {
            vm.linkchecking = true;
            APIDOIService.checkLinks(vm.client.app_id).then(function(response){
                vm.linkchecking = false;
                vm.link_checker_result = $sce.trustAsHtml(response.message);
            });
        }

        vm.uniqid = function(prefix, more_entropy) {
          //  discuss at: http://phpjs.org/functions/uniqid/
          // original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
          //  revised by: Kankrelune (http://www.webfaktory.info/)
          //        note: Uses an internal counter (in php_js global) to avoid collision
          //        test: skip
          //   example 1: uniqid();
          //   returns 1: 'a30285b160c14'
          //   example 2: uniqid('foo');
          //   returns 2: 'fooa30285b1cd361'
          //   example 3: uniqid('bar', true);
          //   returns 3: 'bara20285b23dfd1.31879087'

          if (typeof prefix === 'undefined') {
            prefix = '';
          }

          var retId;
          var formatSeed = function(seed, reqWidth) {
            seed = parseInt(seed, 10)
              .toString(16); // to hex str
            if (reqWidth < seed.length) { // so long we split
              return seed.slice(seed.length - reqWidth);
            }
            if (reqWidth > seed.length) { // so short we pad
              return Array(1 + (reqWidth - seed.length))
                .join('0') + seed;
            }
            return seed;
          };

          // BEGIN REDUNDANT
          if (!this.php_js) {
            this.php_js = {};
          }
          // END REDUNDANT
          if (!this.php_js.uniqidSeed) { // init seed with big random int
            this.php_js.uniqidSeed = Math.floor(Math.random() * 0x75bcd15);
          }
          this.php_js.uniqidSeed++;

          retId = prefix; // start with prefix, add current milliseconds hex string
          retId += formatSeed(parseInt(new Date()
            .getTime() / 1000, 10), 8);
          retId += formatSeed(this.php_js.uniqidSeed, 5); // add seed hex string
          if (more_entropy) {
            // for more entropy we add a float lower to 10
            retId += (Math.random() * 10)
              .toFixed(8)
              .toString();
          }

          return retId;
        }

        vm.formatXml = function(xml) {
            var reg = /(>)\s*(<)(\/*)/g; // updated Mar 30, 2015
            var wsexp = / *(.*) +\n/g;
            var contexp = /(<.+>)(.+\n)/g;
            xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
            var pad = 0;
            var formatted = '';
            var lines = xml.split('\n');
            var indent = 0;
            var lastType = 'other';
            // 4 types of tags - single, closing, opening, other (text, doctype, comment) - 4*4 = 16 transitions
            var transitions = {
                'single->single': 0,
                'single->closing': -1,
                'single->opening': 0,
                'single->other': 0,
                'closing->single': 0,
                'closing->closing': -1,
                'closing->opening': 0,
                'closing->other': 0,
                'opening->single': 1,
                'opening->closing': 0,
                'opening->opening': 1,
                'opening->other': 1,
                'other->single': 0,
                'other->closing': -1,
                'other->opening': 0,
                'other->other': 0
            };

            for (var i = 0; i < lines.length; i++) {
                var ln = lines[i];
                var single = Boolean(ln.match(/<.+\/>/)); // is this line a single tag? ex.

                var closing = Boolean(ln.match(/<\/.+>/)); // is this a closing tag? ex.
                var opening = Boolean(ln.match(/<[^!].*>/)); // is this even a tag (that's not <!something>)
                var type = single ? 'single' : closing ? 'closing' : opening ? 'opening' : 'other';
                var fromTo = lastType + '->' + type;
                lastType = type;
                var padding = '';

                indent += transitions[fromTo];
                for (var j = 0; j < indent; j++) {
                    padding += '\t';
                }
                if (fromTo == 'opening->closing')
                    formatted = formatted.substr(0, formatted.length - 1) + ln + '\n'; // substr removes line break (\n) from prev loop
                else
                    formatted += padding + ln + '\n';
            }

            return formatted;
        }

        vm.stripBlankElements = function(xml) {
            try {
                var dom = $.parseXML(xml);
                //$('*:empty', dom).remove();
                $("*", dom).filter(function(){
                    var tagName = $( this ).prop( "tagName" );
                    if (tagName !== "resourceType") {
                        return $.trim(this.textContent) === "";
                    }
                }).remove();
                return (new XMLSerializer()).serializeToString(dom);
            } catch (e) {
                return xml;
            }

        }

    }
})();<|endoftext|>


<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, you can obtain one at http://mozilla.org/MPL/2.0/. */

'use strict';

/* window.thServiceDomain holds a reference to a backend service
 * for result data. This can be one of:
 *
 * -  http://local.treeherder.mozilla.org (local vagrant)
 * -  http://treeherder-dev.allizom.org (dev)
 * -  https://treeherder.allizom.org (stage)
 * -  https://treeherder.mozilla.org (production) */

// By default the service domain is the current host name.
window.thServiceDomain = "";

//treeherder.config(['$logProvider', 'ThLogConfigProvider',
//    function($logProvider, ThLogConfigProvider) {
//
//    // enable or disable debug messages using $log.
//    // comment out the next line to enable them
//    $logProvider.debugEnabled(true);
//
//    // add classes to the blacklist.  all debug messages except
//    // these will print
//    ThLogConfigProvider.setBlacklist([
//        'thRepoDropDown',
//        'RepositoryPanelCtrl',
//        'thWatchedRepo'
//        ...
//    ]);
//
//    // add classes to the whitelist.  Only debug messages with
//    // these classes will print
//    ThLogConfigProvider.setWhitelist([
//        'thRepoDropDown',
//        'RepositoryPanelCtrl',
//        'thWatchedRepo',
//        ...
//    ]);
//}]);
<commit_msg>Bug 1060312 - Improve the API back-end prefs in the sample local config<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, you can obtain one at http://mozilla.org/MPL/2.0/. */

'use strict';

/* window.thServiceDomain holds a reference to a back-end service
 * used to retrieve job result data. Valid settings are  */
var production = "https://treeherder.mozilla.org";
var stage = "https://treeherder.allizom.org";
var dev = "http://treeherder-dev.allizom.org";
var vagrant = "";

// Set the service
window.thServiceDomain = production;

//treeherder.config(['$logProvider', 'ThLogConfigProvider',
//    function($logProvider, ThLogConfigProvider) {
//
//    // enable or disable debug messages using $log.
//    // comment out the next line to enable them
//    $logProvider.debugEnabled(true);
//
//    // add classes to the blacklist.  all debug messages except
//    // these will print
//    ThLogConfigProvider.setBlacklist([
//        'thRepoDropDown',
//        'RepositoryPanelCtrl',
//        'thWatchedRepo'
//        ...
//    ]);
//
//    // add classes to the whitelist.  Only debug messages with
//    // these classes will print
//    ThLogConfigProvider.setWhitelist([
//        'thRepoDropDown',
//        'RepositoryPanelCtrl',
//        'thWatchedRepo',
//        ...
//    ]);
//}]);
<|endoftext|>


<commit_before>'use strict';

// O11S - Alphascape 3.0 Savage
[{
  zoneRegex: /^Alphascape V3.0 \(Savage\)$/,
  timelineFile: 'o11s.txt',
  triggers: [
  ],
}];
<commit_msg>raidboss: initial untested o11s triggers<commit_after>'use strict';

// O11S - Alphascape 3.0 Savage
[{
  zoneRegex: /^Alphascape V3.0 \(Savage\)$/,
  timelineFile: 'o11s.txt',
  triggers: [
    {
      id: 'O11S Mustard Bomb',
      regex: / 14:326D:Omega starts using Mustard Bomb on (\y{Name})/,
      alarmText: function(data, matches) {
        if (matches[1] == data.me) {
          return {
            en: 'Tank Buster on YOU',
            de: 'Tenkbuster auf DIR',
            fr: 'Tankbuster sur VOUS',
          };
        }
        if (data.role == 'healer') {
          return {
            en: 'Buster on ' + data.ShortName(matches[1]),
            de: 'Tenkbuster auf ' + data.ShortName(matches[1]),
            fr: 'Tankbuster sur ' + data.ShortName(matches[1]),
          };
        }
      },
      tts: function(data, matches) {
        if (matches[1] == data.me) {
          return {
            en: 'buster',
            de: 'basta',
            fr: 'tankbuster',
          };
        }
      },
    },
    {
      // Starboard/Larboard Cannon cleanup.
      regex: / 14:326[25]:Omega starts using/,
      delaySeconds: 10,
      run: function(data) {
        delete data.lastWasStarboard;
      },
    },
    {
      id: 'O11S Starboard Cannon 2',
      regex: / 14:3262:Omega starts using Starboard/,
      condition: function(data) {
        return data.lastWasStarboard !== undefined;
      },
      alertText: function(data) {
        if (data.lastWasStarboard) {
          return {
            en: 'Opposite (Left)',
          };
        }
        return {
          en: 'Stay (Right)',
        };
      },
    },
    {
      id: 'O11S Larboard Cannon 2',
      regex: / 14:3265:Omega starts using Larboard/,
      condition: function(data) {
        return data.lastWasStarboard !== undefined;
      },
      alertText: function(data) {
        if (data.lastWasStarboard) {
          return {
            en: 'Stay (Left)',
          };
        }
        return {
          en: 'Opposite (Right)',
        };
      },
    },
    {
      id: 'O11S Starboard Cannon 1',
      regex: / 14:3262:Omega starts using Starboard/,
      suppressSeconds: 10,
      alertText: {
        en: 'Left',
      },
      run: function(data) {
        data.lastWasStarboard = true;
      },
    },
    {
      id: 'O11S Larboard Cannon 1',
      regex: / 14:3265:Omega starts using Larboard/,
      suppressSeconds: 10,
      alertText: {
        en: 'Right',
      },
      run: function(data) {
        data.lastWasStarboard = false;
      },
    },
    {
      id: 'O11S Starboard Surge 2',
      regex: / 14:3266:Omega starts using Starboard/,
      delaySeconds: 4,
      alertText: {
        en: 'Opposite (Left)',
      },
    },
    {
      id: 'O11S Larboard Surge 2',
      regex: / 14:3268:Omega starts using Larboard/,
      delaySeconds: 4,
      alertText: {
        en: 'Opposite (Right)',
      },
    },
    {
      id: 'O11S Starboard Surge 1',
      regex: / 14:3266:Omega starts using Starboard/,
      alertText: {
        en: 'Left (then opposite)',
      },
    },
    {
      id: 'O11S Larboard Surge 1',
      regex: / 14:3268:Omega starts using Larboard/,
      alertText: {
        en: 'Right (then opposite)',
      },
    },
  ],
}];
<|endoftext|>


<commit_before>define(function(require, exports, module) {
    "use strict";

    var app = require("app");
    var AbstractODataCollection = require("modules/collection/AbstractODataCollection");
    var RadiationModel = require("modules/model/radiation/RadiationModel");

    /**
     * 放射線量データのコレクションクラス
     * @class 放射線量データのコレクションクラス
     * @exports RadiationCollection
     * @constructor
     */
    var RadiationCollection = AbstractODataCollection.extend({
        model : RadiationModel,
        entity : "radiation",
        condition : {
            top : 1,
            orderby : "dateTime desc",
            filter : "station eq '浪江町役場'"
        },
        /**
         * 配列をマップに変換する。
         *
         * @param {Object} レスポンス情報
         * @param {Object} オプション
         * @return {Objecy} レスポンス情報
         * @memberOf RadiationCollection#
         */
        parseOData: function (response, options) {
            return response;
        },

        /**
         * GeoJSON形式に変換する。
         * @return {Object}
         * @memberOf RadiationCollection#
         */
        toGeoJSON : function() {
            var geoJSON;
            var features = [];

            this.each(function(model) {
                features.push(model.toGeoJSON());
            });

            geoJSON = {
                    "type": "FeatureCollection",
                    "features": features
            };

            return geoJSON;
        }
    });

    module.exports = RadiationCollection;
});
<commit_msg>NAM-1016 放射線：RadiationCollectionがダミーデータを読み込むようにする<commit_after>define(function(require, exports, module) {
    "use strict";

    var app = require("app");
    var AbstractODataCollection = require("modules/collection/AbstractODataCollection");
    var RadiationModel = require("modules/model/radiation/RadiationModel");

    /**
     * 放射線量データのコレクションクラス
     * @class 放射線量データのコレクションクラス
     * @exports RadiationCollection
     * @constructor
     */
    var RadiationCollection = AbstractODataCollection.extend({
        model : RadiationModel,
        entity : "radiation",
        condition : {
            top : 1,
            orderby : "dateTime desc",
            filter : "station eq '浪江町役場'"
        },
        /**
         * 配列をマップに変換する。
         *
         * @param {Object} レスポンス情報
         * @param {Object} オプション
         * @return {Objecy} レスポンス情報
         * @memberOf RadiationCollection#
         */
        parseOData: function (response, options) {
            return response;
        },

        // TODO: 開発用サーバにデータが入ったらこのメソッドは削除する
        /**
         * 開発用サーバにデータが無いのでダミーのsyncを利用する
         *
         * @return {undefined}
         */
        sync : function (method) {
            var self = this;
            var URL_DUMMY_JSON = "http://www.json-generator.com/api/json/get/cpuAwBZPaW";

            if (method === "read") {
                return $.get(URL_DUMMY_JSON).done(function (data) {
                    self.set(data);
                });
            } else {
                return AbstractODataCollection.prototype.sync.apply(this, arguments);
            }
        },

        /**
         * GeoJSON形式に変換する。
         * @return {Object}
         * @memberOf RadiationCollection#
         */
        toGeoJSON : function() {
            var geoJSON;
            var features = [];

            this.each(function(model) {
                features.push(model.toGeoJSON());
            });

            geoJSON = {
                    "type": "FeatureCollection",
                    "features": features
            };

            return geoJSON;
        }
    });

    module.exports = RadiationCollection;
});
<|endoftext|>


<commit_before>"use strict";

require( `wires` );

const { deBypass, getConfig, isBypass, isExportable, isRoute, isValue } = require( `./lib/loader-utils` );
const { dirname } = require( `path` );
const generateModule = require( `./lib/generateModule` );
const UID = require( `./lib/UID` );

const marker = `\0~wires~${ UID }:`;

const getDirectory = path => ( path ? dirname( path ) : process.cwd() );

module.exports = () => ( {
    load( id ) {
        if ( id.startsWith( marker ) ) {
            const [ directory, expression ] = JSON.parse( id.slice( marker.length ) );
            return generateModule( getConfig( directory ).get( expression, false, true ) );
        }
        if ( isExportable( id ) ) {
            return generateModule( id );
        }
        return null;
    },
    "name": `wires`,
    resolveId( source, importer, options ) {
        if ( isBypass( source ) ) {
            return this.resolve( deBypass( source ), importer, {
                ...options,
                "skipSelf": true,
            } );
        }
        if ( isRoute( source ) ) {
            return this.resolve( getConfig( getDirectory( importer ) ).get( source, true ).getValue(), importer, {
                ...options,
                "skipSelf": true,
            } );
        }
        if ( isValue( source ) ) {
            return `${ marker }${ JSON.stringify( [ getDirectory( importer ), source ] ) }`;
        }
        return null;
    },
} );
<commit_msg>Properly references current wires in rollup plugin. No idea how this worked before.<commit_after>"use strict";

require( `./index.js` );

const { deBypass, getConfig, isBypass, isExportable, isRoute, isValue } = require( `./lib/loader-utils` );
const { dirname } = require( `path` );
const generateModule = require( `./lib/generateModule` );
const UID = require( `./lib/UID` );

const marker = `\0~wires~${ UID }:`;

const getDirectory = path => ( path ? dirname( path ) : process.cwd() );

module.exports = () => ( {
    load( id ) {
        if ( id.startsWith( marker ) ) {
            const [ directory, expression ] = JSON.parse( id.slice( marker.length ) );
            return generateModule( getConfig( directory ).get( expression, false, true ) );
        }
        if ( isExportable( id ) ) {
            return generateModule( id );
        }
        return null;
    },
    "name": `wires`,
    resolveId( source, importer, options ) {
        if ( isBypass( source ) ) {
            return this.resolve( deBypass( source ), importer, {
                ...options,
                "skipSelf": true,
            } );
        }
        if ( isRoute( source ) ) {
            return this.resolve( getConfig( getDirectory( importer ) ).get( source, true ).getValue(), importer, {
                ...options,
                "skipSelf": true,
            } );
        }
        if ( isValue( source ) ) {
            return `${ marker }${ JSON.stringify( [ getDirectory( importer ), source ] ) }`;
        }
        return null;
    },
} );
<|endoftext|>


<commit_before>Template.ListData.helpers({

  /**
   * @returns {[doc]} A (non-reactive) array of objects containing user info.
   */
  userList: function () {
    return _.map(RadGrad.user.find({}, {sort: {lastName: 1}}).fetch(), function(user) {
      // Required fields
      let name = `**${user.firstName} ${user.middleName} ${user.lastName}** `;
      let roles = `(${user.roles}) `;
      let slug = `*Slug:* ${RadGrad.slug.findBySlug(user.slugID).name} `;
      let email = `*Email:* ${RadGrad.user.getEmail(user._id)} `;
      // Optional fields
      let aboutMe = (_.isEmpty(user.aboutMe)) ? "" : `<br>*About me:* ${user.aboutMe} `;
      let degreeGoalNames = _.map(user.degreeGoalIDs, function(degreeGoalID) {
        return RadGrad.degreegoal.findOne(degreeGoalID).name;
      }) ;
      let degreeGoals = (_.isEmpty(degreeGoalNames)) ? "" : `<br>*Degree Goals*: ${degreeGoalNames}`;
      let tagNames = RadGrad.tag.getTagNames(user.interestTagIDs);
      let tags = (_.isEmpty(tagNames)) ? "" : `<br>*Tags:* ${tagNames} `;
      let degreePlanString = (user.degreePlanID) ? RadGrad.degreeplan.toString(user.degreePlanID) : "";
      let degreePlan = (_.isEmpty(degreePlanString)) ? "" : `<br>*Degree Plan:* ${degreePlanString} `;
      let gradSemester = (_.isEmpty(user.semesterID)) ? "" : `<br>*Graduation:* ${RadGrad.semester.toString(user.semesterID)}`;

      return { picture: user.picture,
        description: name + roles + '
' + slug + email + degreeGoals + aboutMe + tags + degreePlan + gradSemester};
    })
  },

  /**
   * @returns {[doc]} Non-reactive array of course info.
   */
  courseList: function() {
    return _.map(RadGrad.course.find().fetch(), function(course) {
      let name = `**(${course.name})**`;
      let number = ` **${course.number}** `;
      let slugName = `<br>*Slug:* ${RadGrad.slug.findBySlug(course.slugID).name}`;
      let tagNames = `<br>*Tags:* ${RadGrad.tag.getTagNames(course.tagIDs)}`;
      let description = `<br>*Description:* ${course.description}`;
      return {description: number + name + slugName + tagNames + description}
    })
  },

  courseInstanceList: function() {
    return _.map(RadGrad.courseinstance.find().fetch(), function(courseInstance) {
      let semester = `${RadGrad.semester.toString(courseInstance.semesterID)}`;
      let course = `${RadGrad.course.findOne(courseInstance.courseID).name}`;
      let verified = `${courseInstance.verified}`;
      let grade = `${courseInstance.grade}`;
      let student = `${RadGrad.user.findOne(courseInstance.studentID).lastName}`;
      let note = courseInstance.note;
      return {semester: semester, course: course, verified: verified, grade: grade, student: student, note: note}
    })
  },

  degreeGoalList: function() {
    return _.map(RadGrad.degreegoal.find().fetch(), function(degreeGoal) {
      let name = `${degreeGoal.name}`;
      let description = `${degreeGoal.description}`;
      let slugName = `${RadGrad.slug.findBySlug(degreeGoal.slugID).name}`;
      return {name: name, slugName: slugName, description: description}
    })
  },

  degreePlanList: function() {
    return _.map(RadGrad.degreeplan.find().fetch(), function(degreePlan) {
      let courseInstances = _.map(degreePlan.courseInstanceIDs, function(courseInstanceID) {
        return RadGrad.courseinstance.toString(courseInstanceID) + " ";
      });
      let courseInstanceString = `*Course Instances:* ${courseInstances}`;

      let opportunityInstances = _.map(degreePlan.opportunityInstanceIDs, function(opportunityInstanceID) {
        return RadGrad.opportunityinstance.toString(opportunityInstanceID) + " ";
      });
      let opportunityInstanceString = `<br>*Opportunity Instances:* ${opportunityInstances}`;

      let workInstances = _.map(degreePlan.workInstanceIDs, function(workInstanceID) {
        return RadGrad.workinstance.toString(workInstanceID) + " ";
      });
      let workInstanceString = `<br>*Work Instances:* ${workInstances}`;
      let student = `<br>*Student:* ${RadGrad.user.findOne(degreePlan.studentID).lastName}`;

      return {description: courseInstanceString + opportunityInstanceString + workInstanceString + student}
    })
  },

  /**
   * @returns {[doc]} A (non-reactive) array of objects containing opportunity info.
   */
  opportunityList: function () {
    return _.map(RadGrad.opportunity.find().fetch(), function(opportunity) {
      // Required fields
      let name = `*Name:* ${opportunity.name}, `;
      let slug = `*Slug:* ${RadGrad.slug.findBySlug(opportunity.slugID).name}, `;
      let opportunityType = `*Type:* ${RadGrad.opportunitytype.findOne(opportunity.opportunityTypeID).name}, `;
      let sponsor = `*Sponsor:* ${RadGrad.user.findOne(opportunity.sponsorID).lastName}`;
      let tags = `<br>*Tags:* ${RadGrad.tag.getTagNames(opportunity.tagIDs)}`;
      let description = `<br>*Description:* ${opportunity.description}`;
      let start = moment(opportunity.startActive).format('MM/DD/YYYY');
      let end = moment(opportunity.endActive).format('MM/DD/YYYY');
      let activeInterval = `<br>*Active Interval:* ${start} - ${end}`;

      return { iconURL: opportunity.iconURL,
        description: name + slug + opportunityType + sponsor + tags + description + activeInterval};
    })
  },

  opportunityInstanceList: function() {
    return _.map(RadGrad.opportunityinstance.find().fetch(), function(opportunityInstance) {
      let semester = `${RadGrad.semester.toString(opportunityInstance.semesterID)}`;
      let opportunity = `${RadGrad.opportunity.findOne(opportunityInstance.opportunityID).name}`;
      let verified = `${opportunityInstance.verified}`;
      let hrswk = `${opportunityInstance.hrswk}`;
      let student = `${RadGrad.user.findOne(opportunityInstance.studentID).lastName}`;
      return {semester: semester, opportunity: opportunity, verified: verified, hrswk: hrswk, student: student}
    })
  },

  /**
   * @returns {[doc]} A (non-reactive) array of objects containing opportunity info.
   */
  opportunityTypeList: function () {
    return _.map(RadGrad.opportunitytype.find().fetch(), function(opportunityType) {
      let name = `${opportunityType.name}`;
      let slug = `${RadGrad.slug.findBySlug(opportunityType.slugID).name} `;
      let description = `${opportunityType.description}`;
      return {name: name, slug: slug, description: description };
    })
  },

  /**
   * @returns {[doc]} A (non-reactive) array of objects containing opportunity info.
   */
  slugList: function () {
    return _.map(RadGrad.slug.find().fetch(), function(slug) {
      let name = `${slug.name}`;
      let entityName = `${slug.entityName} `;
      return {name: name, entityName: entityName};
    })
  },

  /**
   * @returns {[doc]} A (non-reactive) array of objects containing opportunity info.
   */
  tagList: function () {
    return _.map(RadGrad.tag.find().fetch(), function(tag) {
      let name = `${tag.name}`;
      let slug = `${RadGrad.slug.findBySlug(tag.slugID).name} `;
      let description = `${tag.description}`;
      let tagType = `${RadGrad.tagtype.findOne(tag.tagTypeID).name} `;
      return {name: name, slug: slug, description: description, tagType: tagType};
    })
  },

  /**
   * @returns {[doc]} A (non-reactive) array of objects containing tag info.
   */
  tagTypeList: function () {
    return _.map(RadGrad.tagtype.find().fetch(), function(tagType) {
      let name = `${tagType.name}`;
      let slug = `${RadGrad.slug.findBySlug(tagType.slugID).name} `;
      let description = `${tagType.description}`;
      return {name: name, slug: slug, description: description };
    })
  },

  workInstanceList: function() {
    return _.map(RadGrad.workinstance.find().fetch(), function(workInstance) {
      let semester = `${RadGrad.semester.toString(workInstance.semesterID)}`;
      let hrswk = `${workInstance.hrswk}`;
      let student = `${RadGrad.user.findOne(workInstance.studentID).lastName}`;
      return {semester: semester, hrswk: hrswk, student: student}
    })
  }

});

<commit_msg>Initial commit<commit_after>Template.ListData.helpers({

  /**
   * @returns {[doc]} A (non-reactive) array of objects containing user info.
   */
  userList: function () {
    return _.map(RadGrad.user.find({}, {sort: {lastName: 1}}).fetch(), function(user) {
      // Required fields
      let name = `**${user.firstName} ${user.middleName} ${user.lastName}** `;
      let roles = `(${user.roles}) `;
      let slug = `*Slug:* ${RadGrad.slug.findBySlug(user.slugID).name} `;
      let email = `*Email:* ${RadGrad.user.getEmail(user._id)} `;
      // Optional fields
      let aboutMe = (_.isEmpty(user.aboutMe)) ? "" : `<br>*About me:* ${user.aboutMe} `;
      let degreeGoalNames = _.map(user.degreeGoalIDs, function(degreeGoalID) {
        return RadGrad.degreegoal.findOne(degreeGoalID).name;
      }) ;
      let degreeGoals = (_.isEmpty(degreeGoalNames)) ? "" : `<br>*Degree Goals*: ${degreeGoalNames}`;
      let tagNames = RadGrad.tag.getTagNames(user.interestTagIDs);
      let tags = (_.isEmpty(tagNames)) ? "" : `<br>*Tags:* ${tagNames} `;
      let degreePlanString = (user.degreePlanID) ? RadGrad.degreeplan.toString(user.degreePlanID) : "";
      let degreePlan = (_.isEmpty(degreePlanString)) ? "" : `<br>*Degree Plan:* ${degreePlanString} `;
      let gradSemester = (_.isEmpty(user.semesterID)) ? "" : `<br>*Graduation:* ${RadGrad.semester.toString(user.semesterID)}`;

      return { picture: user.picture,
        description: name + roles + '
' + slug + email + degreeGoals + aboutMe + tags + degreePlan + gradSemester};
    })
  },

  /**
   * @returns {[doc]} Non-reactive array of course info.
   */
  courseList: function() {
    return _.map(RadGrad.course.find().fetch(), function(course) {
      let name = `**(${course.name})**`;
      let number = ` **${course.number}** `;
      let slugName = `<br>*Slug:* ${RadGrad.slug.findBySlug(course.slugID).name}`;
      let tagNames = `<br>*Tags:* ${RadGrad.tag.getTagNames(course.tagIDs)}`;
      let description = `<br>*Description:* ${course.description}`;
      return {description: number + name + slugName + tagNames + description}
    })
  },

  courseInstanceList: function() {
    return _.map(RadGrad.courseinstance.find().fetch(), function(courseInstance) {
      let semester = `${RadGrad.semester.toString(courseInstance.semesterID)}`;
      let course = `${RadGrad.course.findOne(courseInstance.courseID).name}`;
      let verified = `${courseInstance.verified}`;
      let grade = `${courseInstance.grade}`;
      let student = `${RadGrad.user.findOne(courseInstance.studentID).lastName}`;
      let note = courseInstance.note;
      return {semester: semester, course: course, verified: verified, grade: grade, student: student, note: note}
    })
  },

  degreeGoalList: function() {
    return _.map(RadGrad.degreegoal.find().fetch(), function(degreeGoal) {
      let name = `${degreeGoal.name}`;
      let description = `${degreeGoal.description}`;
      let slugName = `${RadGrad.slug.findBySlug(degreeGoal.slugID).name}`;
      return {name: name, slugName: slugName, description: description}
    })
  },

  degreePlanList: function() {
    return _.map(RadGrad.degreeplan.find().fetch(), function(degreePlan) {
      let courseInstances = _.map(degreePlan.courseInstanceIDs, function(courseInstanceID) {
        return RadGrad.courseinstance.toString(courseInstanceID) + " ";
      });
      let courseInstanceString = `*Course Instances:* ${courseInstances}`;

      let opportunityInstances = _.map(degreePlan.opportunityInstanceIDs, function(opportunityInstanceID) {
        return RadGrad.opportunityinstance.toString(opportunityInstanceID) + " ";
      });
      let opportunityInstanceString = `<br>*Opportunity Instances:* ${opportunityInstances}`;

      let workInstances = _.map(degreePlan.workInstanceIDs, function(workInstanceID) {
        return RadGrad.workinstance.toString(workInstanceID) + " ";
      });
      let workInstanceString = `<br>*Work Instances:* ${workInstances}`;
      let student = `<br>*Student:* ${RadGrad.user.findOne(degreePlan.studentID).lastName}`;

      return {description: courseInstanceString + opportunityInstanceString + workInstanceString + student}
    })
  },

  /**
   * @returns {[doc]} A (non-reactive) array of objects containing opportunity info.
   */
  opportunityList: function () {
    return _.map(RadGrad.opportunity.find().fetch(), function(opportunity) {
      // Required fields
      let name = `*Name:* ${opportunity.name}, `;
      let slug = `*Slug:* ${RadGrad.slug.findBySlug(opportunity.slugID).name}, `;
      let opportunityType = `*Type:* ${RadGrad.opportunitytype.findOne(opportunity.opportunityTypeID).name}, `;
      let sponsor = `*Sponsor:* ${RadGrad.user.findOne(opportunity.sponsorID).lastName}`;
      let tags = `<br>*Tags:* ${RadGrad.tag.getTagNames(opportunity.tagIDs)}`;
      let description = `<br>*Description:* ${opportunity.description}`;
      let start = moment(opportunity.startActive).format('MM/DD/YYYY');
      let end = moment(opportunity.endActive).format('MM/DD/YYYY');
      let activeInterval = `<br>*Active Interval:* ${start} - ${end}`;

      return { iconURL: opportunity.iconURL,
        description: name + slug + opportunityType + sponsor + tags + description + activeInterval};
    })
  },

  opportunityInstanceList: function() {
    return _.map(RadGrad.opportunityinstance.find().fetch(), function(opportunityInstance) {
      let semester = `${RadGrad.semester.toString(opportunityInstance.semesterID)}`;
      let opportunity = `${RadGrad.opportunity.findOne(opportunityInstance.opportunityID).name}`;
      let verified = `${opportunityInstance.verified}`;
      let hrswk = `${opportunityInstance.hrswk}`;
      let student = `${RadGrad.user.findOne(opportunityInstance.studentID).lastName}`;
      return {semester: semester, opportunity: opportunity, verified: verified, hrswk: hrswk, student: student}
    })
  },

  /**
   * @returns {[doc]} A (non-reactive) array of objects containing opportunity info.
   */
  opportunityTypeList: function () {
    return _.map(RadGrad.opportunitytype.find().fetch(), function(opportunityType) {
      let name = `${opportunityType.name}`;
      let slug = `${RadGrad.slug.findBySlug(opportunityType.slugID).name} `;
      let description = `${opportunityType.description}`;
      return {name: name, slug: slug, description: description };
    })
  },

  /**
   * @returns {[doc]} A (non-reactive) array of objects containing opportunity info.
   */
  slugList: function () {
    return _.map(RadGrad.slug.find().fetch(), function(slug) {
      let name = `${slug.name}`;
      let entityName = `${slug.entityName} `;
      return {name: name, entityName: entityName};
    })
  },

  /**
   * @returns {[doc]} A (non-reactive) array of objects containing opportunity info.
   */
  tagList: function () {
    return _.map(RadGrad.tag.find().fetch(), function(tag) {
      let name = `${tag.name}`;
      let slug = `${RadGrad.slug.findBySlug(tag.slugID).name} `;
      let description = `${tag.description}`;
      let tagType = `${RadGrad.tagtype.findOne(tag.tagTypeID).name} `;
      return {name: name, slug: slug, description: description, tagType: tagType};
    })
  },

  /**
   * @returns {[doc]} A (non-reactive) array of objects containing tag info.
   */
  tagTypeList: function () {
    return _.map(RadGrad.tagtype.find().fetch(), function(tagType) {
      let name = `${tagType.name}`;
      let slug = `${RadGrad.slug.findBySlug(tagType.slugID).name} `;
      let description = `${tagType.description}`;
      return {name: name, slug: slug, description: description };
    })
  },

  workInstanceList: function() {
    return _.map(RadGrad.workinstance.find().fetch(), function(workInstance) {
      let semester = `${RadGrad.semester.toString(workInstance.semesterID)}`;
      let hrswk = `${workInstance.hrswk}`;
      let student = `${RadGrad.user.findOne(workInstance.studentID).lastName}`;
      return {semester: semester, hrswk: hrswk, student: student}
    })
  }

});
<|endoftext|>