<commit_before>/* global window */
'use strict'
var assert = require('assert')
var sinon = require('sinon')
require('./_fakeDom.js')
require('../lib/pageLoadStats.js')
var transport = require('../lib/transport.js')

describe('Testing pageLoadStats', function () {
  before(function () {
    sinon.stub(transport, 'timing')
    window.barometer.pageStartedAt = 6
    window.trigger('load')
  })
  after(function () {
    transport.timing.restore()
  })

  it('should timing page load times', function () {
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="unloadEventStart"}', 1)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="unloadEventEnd"}', 2)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="redirectStart"}', 3)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="redirectEnd"}', 4)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="fetchStart"}', 5)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="domainLookupStart"}', 6)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="domainLookupEnd"}', 7)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="connectStart"}', 8)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="connectEnd"}', 9)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="secureConnectionStart"}', 10)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="requestStart"}', 11)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="responseStart"}', 12)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="responseEnd"}', 13)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="domLoading"}', 14)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="domInteractive"}', 15)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="domContentLoadedEventStart"}', 16)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="domContentLoadedEventEnd"}', 17)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="domComplete"}', 18)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="loadEventStart"}', 19)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="loadEventEnd"}', 20)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="timeToFirstScript"}', 5)
    assert.equal(transport.timing.callCount, 22)
  })
})
<commit_msg>Use the latest barometer<commit_after>/* global window */
'use strict'
var assert = require('assert')
var sinon = require('sinon')
require('./_fakeDom.js')
require('../lib/pageLoadStats.js')
var transport = require('../lib/transport.js')

describe('Testing pageLoadStats', function () {
  before(function () {
    sinon.stub(transport, 'timing')
    window.barometer.pageStartedAt = 6
    window.trigger('load')
  })
  after(function () {
    transport.timing.restore()
  })

  it('should timing page load times', function () {
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="unloadEventStart"}', 1)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="unloadEventEnd"}', 2)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="redirectStart"}', 3)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="redirectEnd"}', 4)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="fetchStart"}', 5)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="domainLookupStart"}', 6)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="domainLookupEnd"}', 7)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="connectStart"}', 8)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="connectEnd"}', 9)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="secureConnectionStart"}', 10)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="requestStart"}', 11)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="responseStart"}', 12)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="responseEnd"}', 13)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="domLoading"}', 14)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="domInteractive"}', 15)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="domContentLoadedEventStart"}', 16)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="domContentLoadedEventEnd"}', 17)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="domComplete"}', 18)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="loadEventStart"}', 19)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="loadEventEnd"}', 20)
    sinon.assert.calledWith(transport.timing, 'client_pageload_seconds{host="localhost:9876",path="context.html",measure="timeToFirstScript"}', 5)
    assert.equal(transport.timing.callCount, 21)
  })
})
<|endoftext|>


<commit_before>$.fn.autolist = function(action, param) {
    box = this;
    container = box.find('.autolist-container');
    line_url = box.attr('data-line-url');

    // Event
    // Click remove button
    $(document).on('click', '.autolist .remove-line', function() {
        var line = $(this).closest('.autolist-line');

        line.find('.destroy_input').val('true');
        line.find('input, select').addClass('jvalidate_ignore');
        line.hide();
    });
    // Click add button
    $(document).on('click', '.autolist .add-line', function() {
        $.ajax({
            url: line_url,
            method: 'GET'
        }).done(function( row ) {
            container.append( row );
            jsForAjaxContent(container.find('.autolist-line').last());
        });
    });
    // Auto update line
    $(document).on('change', '.autolist select, .autolist input', function() {
        var input = $(this);
        var line = input.closest('.autolist-line');

        setTimeout(function() {
            var formData = new FormData();
            line.find('input, select, textarea').each(function() {
                formData.append($(this).attr('name'), $(this).val());
            });
            line.css('opacity', 0.5);

            $.ajax({
                url: line_url,
                method: 'POST',
                data: formData,
                processData: false,
                contentType: false,
            }).done(function( row ) {
                line.html( $('<div>').html(row).find('.autolist-line').html() );

                line.css('opacity', 1);

                jsForAjaxContent(line);
            });
        }, 150);
    });

    // action / param
    if (typeof(action) !== 'undefined') {
        switch(action) {
            // Update value for dataselect
            case 'val':

                break;
        }

        return;
    }

    return box;
};
<commit_msg>update current_control for autolist js<commit_after>$.fn.autolist = function(action, param) {
    box = this;
    container = box.find('.autolist-container');
    line_url = box.attr('data-line-url');

    // Event
    // Click remove button
    $(document).on('click', '.autolist .remove-line', function() {
        var line = $(this).closest('.autolist-line');

        line.find('.destroy_input').val('true');
        line.find('input, select').addClass('jvalidate_ignore');
        line.hide();
    });
    // Click add button
    $(document).on('click', '.autolist .add-line', function() {
        $.ajax({
            url: line_url,
            method: 'GET'
        }).done(function( row ) {
            container.append( row );
            jsForAjaxContent(container.find('.autolist-line').last());
        });
    });
    // Auto update line
    $(document).on('change', '.autolist select, .autolist input', function() {
        var input = $(this);
        var line = input.closest('.autolist-line');

        setTimeout(function() {
            var formData = new FormData();
            line.find('input, select, textarea').each(function() {
                formData.append($(this).attr('name'), $(this).val());
            });
            line.css('opacity', 0.5);

            formData.append('current_control', input.attr('name'));

            $.ajax({
                url: line_url,
                method: 'POST',
                data: formData,
                processData: false,
                contentType: false,
            }).done(function( row ) {
                line.html( $('<div>').html(row).find('.autolist-line').html() );

                line.css('opacity', 1);

                jsForAjaxContent(line);
            });
        }, 150);
    });

    // action / param
    if (typeof(action) !== 'undefined') {
        switch(action) {
            // Update value for dataselect
            case 'val':

                break;
        }

        return;
    }

    return box;
};
<|endoftext|>


<commit_before>module.exports = {
   "projects": [
    {"name": "apache/incubator-systemml", "type": "repo"},
    {"name": "litong01/Object-Storage-for-Bluemix", "type": "repo"},
    {"name": "node-red/node-red", "type": "repo"},
    {"name": "iqbalmohomed/clampify", "type": "repo"},
    {"name": "ibm-design/ios-animations", "type": "repo"},
    {"name": "ibm-design/web-animations", "type": "repo"},
    {"name": "jasnell/activitystrea.ms", "type": "repo"},
    {"name": "openstack/storlets", "type": "repo"},
    {"name": "ibm-cds-labs/pipes", "type": "repo"},
    {"name": "ibm-cds-labs/metrics-collector", "type": "repo"},
    {"name": "ibm-cds-labs/metrics-analytics", "type": "repo"},
    {"name": "maximilien/i18n4go", "type": "repo"},
    {"name": "ibm-et/spark-kernel", "type": "repo"},
    {"name": "RuntimeTools/appmetrics", "type": "repo"},
    {"name": "gaiandb/gaiandb", "type": "repo"},
    {"name": "cloudviz/agentless-system-crawler", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Banking", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Retail", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Healthcare", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Insurance", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Loyalty", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Telecommunications", "type": "repo"},
	{"name": "IBM-MIL/IBM-Ready-App-for-Venue", "type": "repo"},
	{"name": "IBM-MIL/IBM-Ready-App-for-Travel", "type": "repo"},
    {"name": "shmul/mule", "type": "repo"},
    {"name": "ibm-bluemix-mobile-services/bms-clientsdk-android-core", "type": "repo"},
    {"name": "ibm-bluemix-mobile-services/bms-clientsdk-android-push", "type": "repo"},
    {"name": "ibm-bluemix-mobile-services/bms-clientsdk-android-security-googleauthentication", "type": "repo"},
    {"name": "ibm-bluemix-mobile-services/bms-clientsdk-android-security-facebookauthentication", "type": "repo"},
    {"name": "cognitive-catalyst/cognitive-catalyst", "type": "repo"},
    {"name": "cognitive-catalyst/document-segmenter", "type": "repo"},
    {"name": "cognitive-catalyst/retrieve-and-rank-ground-truth-tooling", "type": "repo"},
    {"name": "cognitive-catalyst/Lightning", "type": "repo"},
    {"name": "cognitive-catalyst/JumpQA", "type": "repo"},
    {"name": "cognitive-catalyst/xml-to-html", "type": "repo"},
    {"name": "cognitive-catalyst/x2sj", "type": "repo"},
    {"name": "cognitive-catalyst/rr-bash-tools", "type": "repo"},
    {"name": "cognitive-catalyst/qa-safe-strings", "type": "repo"},
    {"name": "Brunel-Visualization/Brunel", "type": "repo"},
    {"name": "watson-developer-cloud/node-sdk", "type": "repo"},
    {"name": "watson-developer-cloud/speech-android-sdk", "type": "repo"},
    {"name": "watson-developer-cloud/speech-ios-sdk", "type": "repo"},
    {"name": "J9Java/panama-layout-prototype", "type": "repo"},
    {"name": "bradleyjeck/epanetReader", "type": "repo"},
    {"name": "andybalaam/git-history-data", "type": "repo"},
    {"name": "xdevops/ibm-containers-emulator", "type": "repo"},
    {"name": "presence-insights/pi-clientsdk-android", "type": "repo"},
    {"name": "ibm-security-innovation/libsecurity-go", "type": "repo"},
    {"name": "ibm-security-innovation/crosscoap", "type": "repo"},
    {"name": "nadgowdas/cargo", "type": "repo"},
    {"name": "ibmalchemy/cadf", "type": "repo"},
    {"name": "watson-developer-cloud/ios-sdk", "type": "repo"},
    {"name": "watson-developer-cloud/unity-sdk", "type": "repo"},
    {"name": "watson-developer-cloud/java-sdk, "type": "repo"}
  ]
};
<commit_msg>minor bugfix<commit_after>module.exports = {
   "projects": [
    {"name": "apache/incubator-systemml", "type": "repo"},
    {"name": "litong01/Object-Storage-for-Bluemix", "type": "repo"},
    {"name": "node-red/node-red", "type": "repo"},
    {"name": "iqbalmohomed/clampify", "type": "repo"},
    {"name": "ibm-design/ios-animations", "type": "repo"},
    {"name": "ibm-design/web-animations", "type": "repo"},
    {"name": "jasnell/activitystrea.ms", "type": "repo"},
    {"name": "openstack/storlets", "type": "repo"},
    {"name": "ibm-cds-labs/pipes", "type": "repo"},
    {"name": "ibm-cds-labs/metrics-collector", "type": "repo"},
    {"name": "ibm-cds-labs/metrics-analytics", "type": "repo"},
    {"name": "maximilien/i18n4go", "type": "repo"},
    {"name": "ibm-et/spark-kernel", "type": "repo"},
    {"name": "RuntimeTools/appmetrics", "type": "repo"},
    {"name": "gaiandb/gaiandb", "type": "repo"},
    {"name": "cloudviz/agentless-system-crawler", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Banking", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Retail", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Healthcare", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Insurance", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Loyalty", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Telecommunications", "type": "repo"},
	{"name": "IBM-MIL/IBM-Ready-App-for-Venue", "type": "repo"},
	{"name": "IBM-MIL/IBM-Ready-App-for-Travel", "type": "repo"},
    {"name": "shmul/mule", "type": "repo"},
    {"name": "ibm-bluemix-mobile-services/bms-clientsdk-android-core", "type": "repo"},
    {"name": "ibm-bluemix-mobile-services/bms-clientsdk-android-push", "type": "repo"},
    {"name": "ibm-bluemix-mobile-services/bms-clientsdk-android-security-googleauthentication", "type": "repo"},
    {"name": "ibm-bluemix-mobile-services/bms-clientsdk-android-security-facebookauthentication", "type": "repo"},
    {"name": "cognitive-catalyst/cognitive-catalyst", "type": "repo"},
    {"name": "cognitive-catalyst/document-segmenter", "type": "repo"},
    {"name": "cognitive-catalyst/retrieve-and-rank-ground-truth-tooling", "type": "repo"},
    {"name": "cognitive-catalyst/Lightning", "type": "repo"},
    {"name": "cognitive-catalyst/JumpQA", "type": "repo"},
    {"name": "cognitive-catalyst/xml-to-html", "type": "repo"},
    {"name": "cognitive-catalyst/x2sj", "type": "repo"},
    {"name": "cognitive-catalyst/rr-bash-tools", "type": "repo"},
    {"name": "cognitive-catalyst/qa-safe-strings", "type": "repo"},
    {"name": "Brunel-Visualization/Brunel", "type": "repo"},
    {"name": "watson-developer-cloud/node-sdk", "type": "repo"},
    {"name": "watson-developer-cloud/speech-android-sdk", "type": "repo"},
    {"name": "watson-developer-cloud/speech-ios-sdk", "type": "repo"},
    {"name": "J9Java/panama-layout-prototype", "type": "repo"},
    {"name": "bradleyjeck/epanetReader", "type": "repo"},
    {"name": "andybalaam/git-history-data", "type": "repo"},
    {"name": "xdevops/ibm-containers-emulator", "type": "repo"},
    {"name": "presence-insights/pi-clientsdk-android", "type": "repo"},
    {"name": "ibm-security-innovation/libsecurity-go", "type": "repo"},
    {"name": "ibm-security-innovation/crosscoap", "type": "repo"},
    {"name": "nadgowdas/cargo", "type": "repo"},
    {"name": "ibmalchemy/cadf", "type": "repo"},
    {"name": "watson-developer-cloud/ios-sdk", "type": "repo"},
    {"name": "watson-developer-cloud/unity-sdk", "type": "repo"},
    {"name": "watson-developer-cloud/java-sdk", "type": "repo"}
  ]
};
<|endoftext|>


<commit_before>module.exports = {
   "projects": [
    {"name": "apache/incubator-systemml", "type": "repo"},
    {"name": "node-red/node-red", "type": "repo"},
    {"name": "Brunel-Visualization/Brunel", "type": "repo"},
    {"name": "J9Java/panama-layout-prototype", "type": "repo"},
    {"name": "bradleyjeck/epanetReader", "type": "repo"},
    {"name": "andybalaam/git-history-data", "type": "repo"},
    {"name": "xdevops/ibm-containers-emulator", "type": "repo"},
    {"name": "nadgowdas/cargo", "type": "repo"},
    {"name": "ibmalchemy/cadf", "type": "repo"},
    {"name": "jasnell/activitystrea.ms", "type": "repo"},
    {"name": "openstack/storlets", "type": "repo"},
    {"name": "maximilien/i18n4go", "type": "repo"},
    {"name": "ibm-et/spark-kernel", "type": "repo"},
    {"name": "RuntimeTools/appmetrics", "type": "repo"},
    {"name": "gaiandb/gaiandb", "type": "repo"},
    {"name": "cloudviz/agentless-system-crawler", "type": "repo"},
    {"name": "shmul/mule", "type": "repo"},
    {"name": "ibmstorage/jcadf", "type": "repo"},
    {"name": "djwillia/solo5", "type": "repo"},
    {"name": "quarks-edge/quarks", "type": "repo"},
    {"name": "jamiejennings/rosie-pattern-language", "type": "repo"},
    {"name": "openblockchain/obc-peer", "type": "repo"},
    {"name": "openwhisk/openwhisk", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Banking", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Retail", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Healthcare", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Insurance", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Loyalty", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Telecommunications", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Venue", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Travel", "type": "repo"},
    {"name": "cognitive-catalyst/cognitive-catalyst", "type": "repo"},
    {"name": "cognitive-catalyst/document-segmenter", "type": "repo"},
    {"name": "cognitive-catalyst/retrieve-and-rank-ground-truth-tooling", "type": "repo"},
    {"name": "cognitive-catalyst/Lightning", "type": "repo"},
    {"name": "cognitive-catalyst/JumpQA", "type": "repo"},
    {"name": "cognitive-catalyst/xml-to-html", "type": "repo"},
    {"name": "cognitive-catalyst/x2sj", "type": "repo"},
    {"name": "cognitive-catalyst/rr-bash-tools", "type": "repo"},
    {"name": "cognitive-catalyst/qa-safe-strings", "type": "repo"},
    {"name": "watson-developer-cloud/node-sdk", "type": "repo"},
    {"name": "watson-developer-cloud/speech-android-sdk", "type": "repo"},
    {"name": "watson-developer-cloud/java-sdk", "type": "repo"},
    {"name": "watson-developer-cloud/ios-sdk", "type": "repo"},
    {"name": "watson-developer-cloud/unity-sdk", "type": "repo"},
    {"name": "ibm-design/ios-animations", "type": "repo"},
    {"name": "ibm-design/web-animations", "type": "repo"},
    {"name": "presence-insights/pi-clientsdk-android", "type": "repo"},
    {"name": "presence-insights/pi-clientsdk-ios", "type": "repo"},
    {"name": "ibm-bluemix-mobile-services/bms-clientsdk-android-core", "type": "repo"},
    {"name": "ibm-bluemix-mobile-services/bms-clientsdk-android-push", "type": "repo"},
    {"name": "ibm-bluemix-mobile-services/bms-clientsdk-android-security-googleauthentication", "type": "repo"},
    {"name": "ibm-bluemix-mobile-services/bms-clientsdk-android-security-facebookauthentication", "type": "repo"},
    {"name": "ibm-cds-labs/pipes", "type": "repo"},
    {"name": "ibm-cds-labs/metrics-collector", "type": "repo"},
    {"name": "ibm-cds-labs/metrics-analytics", "type": "repo"},
    {"name": "ibm-security-innovation/libsecurity-go", "type": "repo"},
    {"name": "ibm-security-innovation/crosscoap", "type": "repo"},
    {"name": "ibm-security-innovation/goldy", "type": "repo"},
    {"name": "ibm-security-innovation/menagerie", "type": "repo"}
  ]
};
<commit_msg>added ibm-research/iostash and aruniyengar/storage-client-library<commit_after>module.exports = {
   "projects": [
    {"name": "apache/incubator-systemml", "type": "repo"},
    {"name": "node-red/node-red", "type": "repo"},
    {"name": "Brunel-Visualization/Brunel", "type": "repo"},
    {"name": "J9Java/panama-layout-prototype", "type": "repo"},
    {"name": "bradleyjeck/epanetReader", "type": "repo"},
    {"name": "andybalaam/git-history-data", "type": "repo"},
    {"name": "xdevops/ibm-containers-emulator", "type": "repo"},
    {"name": "nadgowdas/cargo", "type": "repo"},
    {"name": "ibmalchemy/cadf", "type": "repo"},
    {"name": "jasnell/activitystrea.ms", "type": "repo"},
    {"name": "openstack/storlets", "type": "repo"},
    {"name": "maximilien/i18n4go", "type": "repo"},
    {"name": "ibm-et/spark-kernel", "type": "repo"},
    {"name": "RuntimeTools/appmetrics", "type": "repo"},
    {"name": "gaiandb/gaiandb", "type": "repo"},
    {"name": "cloudviz/agentless-system-crawler", "type": "repo"},
    {"name": "shmul/mule", "type": "repo"},
    {"name": "ibmstorage/jcadf", "type": "repo"},
    {"name": "djwillia/solo5", "type": "repo"},
    {"name": "quarks-edge/quarks", "type": "repo"},
    {"name": "jamiejennings/rosie-pattern-language", "type": "repo"},
    {"name": "openblockchain/obc-peer", "type": "repo"},
    {"name": "openwhisk/openwhisk", "type": "repo"},
    {"name": "ibm-research/iostash", "type": "repo"},
    {"name": "aruniyengar/storage-client-library", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Banking", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Retail", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Healthcare", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Insurance", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Loyalty", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Telecommunications", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Venue", "type": "repo"},
    {"name": "IBM-MIL/IBM-Ready-App-for-Travel", "type": "repo"},
    {"name": "cognitive-catalyst/cognitive-catalyst", "type": "repo"},
    {"name": "cognitive-catalyst/document-segmenter", "type": "repo"},
    {"name": "cognitive-catalyst/retrieve-and-rank-ground-truth-tooling", "type": "repo"},
    {"name": "cognitive-catalyst/Lightning", "type": "repo"},
    {"name": "cognitive-catalyst/JumpQA", "type": "repo"},
    {"name": "cognitive-catalyst/xml-to-html", "type": "repo"},
    {"name": "cognitive-catalyst/x2sj", "type": "repo"},
    {"name": "cognitive-catalyst/rr-bash-tools", "type": "repo"},
    {"name": "cognitive-catalyst/qa-safe-strings", "type": "repo"},
    {"name": "watson-developer-cloud/node-sdk", "type": "repo"},
    {"name": "watson-developer-cloud/speech-android-sdk", "type": "repo"},
    {"name": "watson-developer-cloud/java-sdk", "type": "repo"},
    {"name": "watson-developer-cloud/ios-sdk", "type": "repo"},
    {"name": "watson-developer-cloud/unity-sdk", "type": "repo"},
    {"name": "ibm-design/ios-animations", "type": "repo"},
    {"name": "ibm-design/web-animations", "type": "repo"},
    {"name": "presence-insights/pi-clientsdk-android", "type": "repo"},
    {"name": "presence-insights/pi-clientsdk-ios", "type": "repo"},
    {"name": "ibm-bluemix-mobile-services/bms-clientsdk-android-core", "type": "repo"},
    {"name": "ibm-bluemix-mobile-services/bms-clientsdk-android-push", "type": "repo"},
    {"name": "ibm-bluemix-mobile-services/bms-clientsdk-android-security-googleauthentication", "type": "repo"},
    {"name": "ibm-bluemix-mobile-services/bms-clientsdk-android-security-facebookauthentication", "type": "repo"},
    {"name": "ibm-cds-labs/pipes", "type": "repo"},
    {"name": "ibm-cds-labs/metrics-collector", "type": "repo"},
    {"name": "ibm-cds-labs/metrics-analytics", "type": "repo"},
    {"name": "ibm-security-innovation/libsecurity-go", "type": "repo"},
    {"name": "ibm-security-innovation/crosscoap", "type": "repo"},
    {"name": "ibm-security-innovation/goldy", "type": "repo"},
    {"name": "ibm-security-innovation/menagerie", "type": "repo"}
  ]
};
<|endoftext|>


<commit_before>jQuery(function($) {
  $(".lead-button").live('click', function(){
    article_id = this.getAttribute("article_id");
    $(this).toggleClass('icon-add').toggleClass('icon-remove');
    $(article_id).slideToggle();
    return false;
  })
  $("#body-button").click(function(){
    $(this).toggleClass('icon-add').toggleClass('icon-remove');
    $('#article-body-field').slideToggle();
    return false;
  })

  $("#textile-quickref-show").click(function(){
    $('#textile-quickref-hide').show();
    $(this).hide();
    $('#textile-quickref').slideToggle();
    return false;
  })
  $("#textile-quickref-hide").click(function(){
    $('#textile-quickref-show').show();
    $(this).hide();
    $('#textile-quickref').slideToggle();
    return false;
  })

  var button_add = $('.text-editor-sidebar meta[name=button.add]').attr('value');
  var button_zoom = $('.text-editor-sidebar meta[name=button.zoom]').attr('value');

  function add_to_text_button() {
    return '' + button_add + '';
  }

  function add_to_text_link() {
    return '' + button_add + '';
  }

  function zoom_button() {
    return '' + button_zoom + '';
  }

  function list_items(items, selector) {
    var html_for_items = '';

    var images  = [];
    var files   = [];
    var errors  = [];

    $.each(items, function(i, item) {
      if (item.error) {
        errors.push(item);
        return;
      }
      if (item.content_type && item.content_type.match(/^image/)) {
        images.push(item);
      } else {
        files.push(item);
      }
    });

    $.each(images, function(i, item) {
      html_for_items += '

' + add_to_text_button() + zoom_button() + '

';
    });

    $.each(files, function(i, item) {
      html_for_items += '

' + item.title + '

' + add_to_text_button() + '

';
    });

    $.each(errors, function(i, item) {
      html_for_items += '
' + item.error + '
';
    });

    $(selector).html(html_for_items);
  }

  $('.controls a.add-to-text').live('click', function() {
    var $item = $(this).closest('.item');
    var html_selector = $item.attr('data-item');
    insert_item_in_text($item.find(html_selector));
    $.colorbox.close();
    return false;
  });
  $('.controls a.zoom').live('click', function() {
    var $item = $(this).closest('.item');
    var html_selector = $item.attr('data-item');
    var img = $item.find(html_selector).find('img').attr('src');
    $.colorbox({ html: '

' + '
' + add_to_text_link() + '

', maxWidth: '640px', maxHeight: '670px', scrolling: false });
    return false;
  });

  // FIXME the user may also want to add the item to the abstract textarea!
  var text_field = 'article_body';

  function insert_item_in_text($wrapper) {
    if (window.tinymce) {

      var html = $wrapper.html();

      var editor = tinymce.get(text_field);

      editor.setContent(editor.getContent() + html);

    } else {
      // simple text editor
      var text = $('#' + text_field).val();
      var $item = $wrapper.children().first();
      if ($item.attr('src')) {
        $('#article_body').val(text + '!' + $item.attr('src') + '!');
      }
      if ($item.attr('href')) {
        $('#article_body').val(text + $item.attr('href'));
      }
    }
  }

  $('#media-search-button').click(function() {
    var query = '*' + $('#media-search-query').val() + '*';
    var $button = $(this);
    $('#media-search-box .header').toggleClass('icon-loading');
    $.get($(this).parent().attr('action'), { 'q': query }, function(data) {
      list_items(data, '#media-search-results .items');
      if (data.length && data.length > 0) {
        $('#media-search-results').slideDown();
      }
    $('#media-search-box .header').toggleClass('icon-loading');
    });
    return false;
  });

  $('#media-upload-form form').ajaxForm({
    dataType: 'json',
    resetForm: true,
    beforeSubmit:
      function() {
        $('#media-upload-form').slideUp();
        $('#media-upload-box .header').toggleClass('icon-loading');
      },
    success:
      function(data) {
        list_items(data, '#media-upload-results .items');
        if (data.length && data.length > 0) {
          $('#media-upload-results').slideDown();
        }
        $('#media-upload-box .header').toggleClass('icon-loading');
      }
  });

  $('#media-upload-more-files').click(function() {
    $('#media-upload-results').hide();
    $('#media-upload-form').show();
  });

});
<commit_msg>When uploading, add images directly to the text<commit_after>jQuery(function($) {
  $(".lead-button").live('click', function(){
    article_id = this.getAttribute("article_id");
    $(this).toggleClass('icon-add').toggleClass('icon-remove');
    $(article_id).slideToggle();
    return false;
  })
  $("#body-button").click(function(){
    $(this).toggleClass('icon-add').toggleClass('icon-remove');
    $('#article-body-field').slideToggle();
    return false;
  })

  $("#textile-quickref-show").click(function(){
    $('#textile-quickref-hide').show();
    $(this).hide();
    $('#textile-quickref').slideToggle();
    return false;
  })
  $("#textile-quickref-hide").click(function(){
    $('#textile-quickref-show').show();
    $(this).hide();
    $('#textile-quickref').slideToggle();
    return false;
  })

  var button_add = $('.text-editor-sidebar meta[name=button.add]').attr('value');
  var button_zoom = $('.text-editor-sidebar meta[name=button.zoom]').attr('value');

  function add_to_text_button() {
    return '' + button_add + '';
  }

  function add_to_text_link() {
    return '' + button_add + '';
  }

  function zoom_button() {
    return '' + button_zoom + '';
  }

  function list_items(items, selector, auto_add) {
    var html_for_items = '';

    var images  = [];
    var files   = [];
    var errors  = [];

    $.each(items, function(i, item) {
      if (item.error) {
        errors.push(item);
        return;
      }
      if (item.content_type && item.content_type.match(/^image/)) {
        images.push(item);
      } else {
        files.push(item);
      }
    });

    $.each(images, function(i, item) {
      html_for_items += '

' + add_to_text_button() + zoom_button() + '

';
    });

    $.each(files, function(i, item) {
      html_for_items += '

' + item.title + '

' + add_to_text_button() + '

';
    });

    $.each(errors, function(i, item) {
      html_for_items += '
' + item.error + '
';
    });

    $(selector).html(html_for_items);

    if (auto_add) {
      $(selector).find('a.add-to-text').click();
    }
  }

  $('.controls a.add-to-text').live('click', function() {
    var $item = $(this).closest('.item');
    var html_selector = $item.attr('data-item');
    insert_item_in_text($item.find(html_selector));
    $.colorbox.close();
    return false;
  });
  $('.controls a.zoom').live('click', function() {
    var $item = $(this).closest('.item');
    var html_selector = $item.attr('data-item');
    var img = $item.find(html_selector).find('img').attr('src');
    $.colorbox({ html: '

' + '
' + add_to_text_link() + '

', maxWidth: '640px', maxHeight: '670px', scrolling: false });
    return false;
  });

  // FIXME the user may also want to add the item to the abstract textarea!
  var text_field = 'article_body';

  function insert_item_in_text($wrapper) {
    if (window.tinymce) {

      var html = $wrapper.html();

      var editor = tinymce.get(text_field);

      editor.setContent(editor.getContent() + html);

    } else {
      // simple text editor
      var text = $('#' + text_field).val();
      var $item = $wrapper.children().first();
      if ($item.attr('src')) {
        $('#article_body').val(text + '!' + $item.attr('src') + '!');
      }
      if ($item.attr('href')) {
        $('#article_body').val(text + $item.attr('href'));
      }
    }
  }

  $('#media-search-button').click(function() {
    var query = '*' + $('#media-search-query').val() + '*';
    var $button = $(this);
    $('#media-search-box .header').toggleClass('icon-loading');
    $.get($(this).parent().attr('action'), { 'q': query }, function(data) {
      list_items(data, '#media-search-results .items', false);
      if (data.length && data.length > 0) {
        $('#media-search-results').slideDown();
      }
    $('#media-search-box .header').toggleClass('icon-loading');
    });
    return false;
  });

  $('#media-upload-form form').ajaxForm({
    dataType: 'json',
    resetForm: true,
    beforeSubmit:
      function() {
        $('#media-upload-form').slideUp();
        $('#media-upload-box .header').toggleClass('icon-loading');
      },
    success:
      function(data) {
        list_items(data, '#media-upload-results .items', true);
        if (data.length && data.length > 0) {
          $('#media-upload-results').slideDown();
        }
        $('#media-upload-box .header').toggleClass('icon-loading');
      }
  });

  $('#media-upload-more-files').click(function() {
    $('#media-upload-results').hide();
    $('#media-upload-form').show();
  });

});
<|endoftext|>


<commit_before>var STORIES;
var PIVOTAL_VOTE_FAILED;
var PIVOTAL_STORY_FAILED;
var PIVOTAL_COMMENT_FAILED;
var PIVOTAL_STORY_LOADING;

var CUR_LABEL = "all";
var CUR_STORY = null;

function click_on_label(label) {
  var old_stories = STORIES[CUR_LABEL] || [];
  var new_stories = STORIES[label]     || [];
  var state = {};
  var i, j, e;
  if (CUR_STORY)
    click_on_story(CUR_STORY);
  for (i=0; i<old_stories.length; i++) {
    j = old_stories[i];
    state[j] = true;
  }
  for (i=0; i<new_stories.length; i++) {
    j = new_stories[i];
    if (!state[j]) {
      $("pivotal_" + j).show();
    } else {
      state[j] = false;
    }
  }
  for (i=0; i<old_stories.length; i++) {
    j = old_stories[i];
    if (state[j]) {
      $("pivotal_" + j).hide();
    }
  }
  CUR_LABEL = label;
  Element.ensureVisible($("pivotal_stories"));
}

function vote_on_story(story, user, value) {
  var div = $("pivotal_votes_" + story);
  new Ajax.Request("/ajax/pivotal/vote/" + story + "?value=" + value, {//
    asynchronous: true,//
    onComplete: function(request) {//
      if (request.status == 200) {//
        div.innerHTML = request.responseText;//
      } else {//
        alert(PIVOTAL_VOTE_FAILED + request.responseText);//
      }//
    }//
  });//
  $("pivotal_vote_num_" + story).innerHTML = //
    '';//
}

function click_on_story(story) {
  var div = $("pivotal_body_" + story);
  if (CUR_STORY)
    $("pivotal_body_" + CUR_STORY).hide();
  if (CUR_STORY === story) {
    CUR_STORY = null;
    return;
  }
  CUR_STORY = story
  new Ajax.Request("/ajax/pivotal/story/" + story, {
    asynchronous: true,
    onComplete: function(request) {
      if (request.status == 200) {
        div.innerHTML = request.responseText;
        Element.ensureVisible($("pivotal_" + story));
      } else {
        div.innerHTML = '';
        div.hide();
        alert(PIVOTAL_STORY_FAILED + request.responseText);
        CUR_STORY = null;
      }
    }
  });
  div.innerHTML = '' +
    PIVOTAL_STORY_LOADING +
    ' ' +
    '';
  div.show();
  Element.ensureVisible($("pivotal_" + story));
}

function post_comment(story) {
  var value = $("pivotal_comment").value;
  var popup = $("pivotal_popup");
  var num;
  new Ajax.Request("/ajax/pivotal/comment/" + story + "?value=" + escape(value), {
    asynchronous: true,
    onComplete: function(request) {
      popup.hide();
      if (request.status == 200) {
        num = $("pivotal_num_comments_" + story);
        num.innerHTML = parseInt(num.innerHTML) + 1;
        $("pivotal_comments").innerHTML += request.responseText;
        $("pivotal_comment").value = "";
      } else {
        alert(PIVOTAL_COMMENT_FAILED + request.responseText);
      }
    }
  });
  Element.center(popup);
  popup.show();
}

<commit_msg>Cleaning up javascript using jslint...<commit_after>var STORIES;
var PIVOTAL_VOTE_FAILED;
var PIVOTAL_STORY_FAILED;
var PIVOTAL_COMMENT_FAILED;
var PIVOTAL_STORY_LOADING;

var CUR_LABEL = "all";
var CUR_STORY = null;

function click_on_label(label) {
  var old_stories = STORIES[CUR_LABEL] || [];
  var new_stories = STORIES[label]     || [];
  var state = {};
  var i, j, e;
  if (CUR_STORY) {
    click_on_story(CUR_STORY);
  }
  for (i=0; i<old_stories.length; i++) {
    j = old_stories[i];
    state[j] = true;
  }
  for (i=0; i<new_stories.length; i++) {
    j = new_stories[i];
    if (!state[j]) {
      $("pivotal_" + j).show();
    } else {
      state[j] = false;
    }
  }
  for (i=0; i<old_stories.length; i++) {
    j = old_stories[i];
    if (state[j]) {
      $("pivotal_" + j).hide();
    }
  }
  CUR_LABEL = label;
  Element.ensureVisible($("pivotal_stories"));
}

function vote_on_story(story, user, value) {
  var div = $("pivotal_votes_" + story);
  new Ajax.Request("/ajax/pivotal/vote/" + story + "?value=" + value, {
    asynchronous: true,
    onComplete: function(request) {
      if (request.status == 200) {
        div.innerHTML = request.responseText;
      } else {
        alert(PIVOTAL_VOTE_FAILED + request.responseText);
      }
    }
  });
  $("pivotal_vote_num_" + story).innerHTML =
    '';
}

function click_on_story(story) {
  var div = $("pivotal_body_" + story);
  if (CUR_STORY) {
    $("pivotal_body_" + CUR_STORY).hide();
  }
  if (CUR_STORY === story) {
    CUR_STORY = null;
    return;
  }
  CUR_STORY = story;
  new Ajax.Request("/ajax/pivotal/story/" + story, {
    asynchronous: true,
    onComplete: function(request) {
      if (request.status == 200) {
        div.innerHTML = request.responseText;
        Element.ensureVisible($("pivotal_" + story));
      } else {
        div.innerHTML = '';
        div.hide();
        alert(PIVOTAL_STORY_FAILED + request.responseText);
        CUR_STORY = null;
      }
    }
  });
  div.innerHTML = '' +
    PIVOTAL_STORY_LOADING +
    ' ' +
    '';
  div.show();
  Element.ensureVisible($("pivotal_" + story));
}

function post_comment(story) {
  var value = $("pivotal_comment").value;
  var popup = $("pivotal_popup");
  var num;
  new Ajax.Request("/ajax/pivotal/comment/" + story + "?value=" + escape(value), {
    asynchronous: true,
    onComplete: function(request) {
      popup.hide();
      if (request.status == 200) {
        num = $("pivotal_num_comments_" + story);
        num.innerHTML = parseInt(num.innerHTML) + 1;
        $("pivotal_comments").innerHTML += request.responseText;
        $("pivotal_comment").value = "";
      } else {
        alert(PIVOTAL_COMMENT_FAILED + request.responseText);
      }
    }
  });
  Element.center(popup);
  popup.show();
}

<|endoftext|>


<commit_before>$('.btn-shorten').on('click', function () {

    $.ajax({
      url: '/api/shorten',
      type: 'POST',
      dataType: 'JSON',
      data: { url: $('#url-field').val() },
      success: function (data) {
        var resultHTML = ''
          + data.shortUrl + ' <button type="button" class="btn" data-clipboard-text="' + data.shortUrl + '">' +
          ' Copy to clipboard' +
            '</button>';
        $('#link').html(resultHTML);
        $('#link').hide().fadeIn('slow');
      }
    });

  });

<commit_msg>target blank<commit_after>$('.btn-shorten').on('click', function () {

    $.ajax({
      url: '/api/shorten',
      type: 'POST',
      dataType: 'JSON',
      data: { url: $('#url-field').val() },
      success: function (data) {
        var resultHTML = ''
          + data.shortUrl + ' <button type="button" class="btn" data-clipboard-text="' + data.shortUrl + '">' +
          ' Copy to clipboard' +
            '</button>';
        $('#link').html(resultHTML);
        $('#link').hide().fadeIn('slow');
      }
    });

  });

<|endoftext|>


<commit_before>var sops_assets=new Array();
var models_assets=new Array();
var assays=new Array();
var data_files_assets=new Array();

function postInvestigationData() {
    request = new Ajax.Request(CREATE_INVESTIGATION_LINK,
    {
        method: 'post',
        parameters: {
            id: $('study_investigation_id').value,  // empty ID will be submitted on "create" action, but it doesn't make a difference
            title: $('title').value,
            project_id: $('project_id').value
        },
        onSuccess: function(transport){
            var data = transport.responseText.evalJSON(true);

            if (data.status==200){
                addNewInvestigation(data.new_investigation);
                RedBox.close();
            }
            if (data.status==406) {
                $('errorExplanation').innerHTML=data.error_messages;
                $('errorExplanation').show();
            }

            return (true);
        },
        onFailure: function(transport){
            alert('Something went wrong, please try again...');
            return(false);
        }
    });

}

function addNewInvestigation(new_investigation) {
    selectObj=$('study_investigation_id');
    selectObj.options[select.options.length]=new Option(new_investigation[1],new_investigation[0],false,true);
    selectObj.disabled=false;
}

function addSop(title,id) {
    sops_assets.push([title,id]);
}

function addSelectedSop() {
    selected_option_index=$("possible_sops").selectedIndex;
    selected_option=$("possible_sops").options[selected_option_index];
    title=selected_option.text;
    id=selected_option.value;

    if(checkNotInList(id,sops_assets)) {
        addSop(title,id);
        updateSops();
    }
    else {
        alert('The following Sop had already been added:\n\n' +
            title);
    }
}

function removeSop(id) {
    // remove the actual record for the attribution
    for(var i = 0; i < sops_assets.length; i++)
        if(sops_assets[i][1] == id) {
            sops_assets.splice(i, 1);
            break;
        }

    // update the page
    updateSops();
}

function updateSops() {
    sop_text='
';

    sop_ids=new Array();

    for (var i=0;i<sops_assets.length;i++) {
        sop=sops_assets[i];
        title=sop[0];
        id=sop[1];
        titleText = '' + title.truncate(30) + '';
        sop_text += '
' + titleText +
          '   ' +
          '[remove]
';
        sop_ids.push(id);
    }

    sop_text += '
';

    // update the page
    if(sops_assets.length == 0) {
        $('sop_to_list').innerHTML = 'No sops';
    }
    else {
        $('sop_to_list').innerHTML = sop_text;
    }

    clearList('assay_sop_asset_ids');

    select=$('assay_sop_asset_ids')
    for (i=0;i<sop_ids.length;i++) {
        id=sop_ids[i];
        o=document.createElement('option');
        o.value=id;
        o.text=id;
        o.selected=true;
        try {
            select.add(o); //for older IE version
        }
        catch (ex) {
            select.add(o,null);
        }
    }
}

//Data files
function addDataFile(title,id,relationshipType) {
    data_files_assets.push([title,id,relationshipType]);
}

function addSelectedDataFile() {
    selected_option_index=$("possible_data_files").selectedIndex;
    selected_option=$("possible_data_files").options[selected_option_index];
    title=selected_option.text;
    id=selected_option.value;
    if ($("data_file_relationship_type")) {
        relationshipType = $("data_file_relationship_type").options[$("data_file_relationship_type").selectedIndex].text;
    }
    else
    {
        relationshipType="None"
    }

    if(checkNotInList(id,data_files_assets)) {
        addDataFile(title,id,relationshipType);
        updateDataFiles();
    }
    else {
        alert('The following Data file had already been added:\n\n' +
            title);
    }
}

function removeDataFile(id) {
    // remove the actual record for the attribution
    for(var i = 0; i < data_files_assets.length; i++)
        if(data_files_assets[i][1] == id) {
            data_files_assets.splice(i, 1);
            break;
        }

    // update the page
    updateDataFiles();
}

function updateDataFiles() {
    data_file_text='
'

    for (var i=0;i<data_files_assets.length;i++) {
        data_file=data_files_assets[i];
        title=data_file[0];
        id=data_file[1];
        relationshipType = data_file[2];
        relationshipText = (relationshipType == 'None') ? '' : ' (' + relationshipType + ')';
        titleText = '' + title.truncate(30) + '';
        data_file_text += '
' + titleText + relationshipText +
        '   '
        + '[remove]
';
    }

    data_file_text += '
';

    // update the page
    if(data_files_assets.length == 0) {
        $('data_file_to_list').innerHTML = 'No data files';
    }
    else {
        $('data_file_to_list').innerHTML = data_file_text;
    }

    clearList('assay_data_file_asset_ids');

    select=$('assay_data_file_asset_ids');
    for (i=0;i<data_files_assets.length;i++) {
        id=data_files_assets[i][1];
        relationshipType=data_files_assets[i][2];
        o=document.createElement('option');
        o.value=id + "," + relationshipType;
        o.text=id;
        o.selected=true;
        try {
            select.add(o); //for older IE version
        }
        catch (ex) {
            select.add(o,null);
        }
    }
}

//Models
function addModel(title,id) {
    models_assets.push([title,id]);
}

function addSelectedModel() {
    selected_option_index=$("possible_models").selectedIndex;
    selected_option=$("possible_models").options[selected_option_index];
    title=selected_option.text;
    id=selected_option.value;

    if(checkNotInList(id,models_assets)) {
        addModel(title,id);
        updateModels();
    }
    else {
        alert('The following Model had already been added:\n\n' +
            title);
    }
}

function removeModel(id) {
    // remove the actual record for the attribution
    for(var i = 0; i < models_assets.length; i++)
        if(models_assets[i][1] == id) {
            models_assets.splice(i, 1);
            break;
        }

    // update the page
    updateModels();
}

function updateModels() {
    model_text='
';
    type="Model";
    model_ids=new Array();

    for (var i=0;i<models_assets.length;i++) {
        model=models_assets[i];
        title=model[0];
        id=model[1];
        titleText = '' + title.truncate(30) + '';
        model_text += '
' + titleText
        //+ "  (" + contributor + ")"
        + '   '
        + '[remove]
';
        model_ids.push(id);
    }

    model_text += '
';

    // update the page
    if(models_assets.length == 0) {
        $('model_to_list').innerHTML = 'No models';
    }
    else {
        $('model_to_list').innerHTML = model_text;
    }

    clearList('assay_model_asset_ids');

    select=$('assay_model_asset_ids');
    for (i=0;i<model_ids.length;i++) {
        id=model_ids[i];
        o=document.createElement('option');
        o.value=id;
        o.text=id;
        o.selected=true;
        try {
            select.add(o); //for older IE version
        }
        catch (ex) {
            select.add(o,null);
        }
    }
}

//Assays
function addSelectedAssay() {
    selected_option_index=$("possible_assays").selectedIndex;
    selected_option=$("possible_assays").options[selected_option_index];
    title=selected_option.text;
    id=selected_option.value;

    if(checkNotInList(id,assays)) {
        addAssay(title,id);
        updateAssays();
    }
    else {
        alert('The following Assay had already been added:\n\n' +
            title);
    }
}

function removeAssay(id) {
    // remove the actual record for the attribution
    for(var i = 0; i < assays.length; i++)
        if(assays[i][1] == id) {
            assays.splice(i, 1);
            break;
        }

    // update the page
    updateAssays();
}

function updateAssays() {
    assay_text='';
    type="Assay";
    assay_ids=new Array();

    for (var i=0;i<assays.length;i++) {
        assay=assays[i];
        title=assay[0];
        id=assay[1];
        assay_text += '' + type + ': ' + title
        //+ "  (" + contributor + ")"
        + '   '
        + '[remove]
';
        assay_ids.push(id);
    }

    // remove the last line break
    if(assay_text.length > 0) {
        assay_text = assay_text.slice(0,-5);
    }

    // update the page
    if(assay_text.length == 0) {
        $('assay_to_list').innerHTML = 'No assays';
    }
    else {
        $('assay_to_list').innerHTML = assay_text;
    }

    clearList('study_assay_ids');

    select=$('study_assay_ids');
    for (i=0;i<assay_ids.length;i++) {
        id=assay_ids[i];
        o=document.createElement('option');
        o.value=id;
        o.text=id;
        o.selected=true;
        try {
            select.add(o); //for older IE version
        }
        catch (ex) {
            select.add(o,null);
        }
    }
}

function addAssay(title,id) {
    assays.push([title,id]);
}<commit_msg>increased length of text for selected sops, models and data in assay creation form<commit_after>var sops_assets=new Array();
var models_assets=new Array();
var assays=new Array();
var data_files_assets=new Array();

function postInvestigationData() {
    request = new Ajax.Request(CREATE_INVESTIGATION_LINK,
    {
        method: 'post',
        parameters: {
            id: $('study_investigation_id').value,  // empty ID will be submitted on "create" action, but it doesn't make a difference
            title: $('title').value,
            project_id: $('project_id').value
        },
        onSuccess: function(transport){
            var data = transport.responseText.evalJSON(true);

            if (data.status==200){
                addNewInvestigation(data.new_investigation);
                RedBox.close();
            }
            if (data.status==406) {
                $('errorExplanation').innerHTML=data.error_messages;
                $('errorExplanation').show();
            }

            return (true);
        },
        onFailure: function(transport){
            alert('Something went wrong, please try again...');
            return(false);
        }
    });

}

function addNewInvestigation(new_investigation) {
    selectObj=$('study_investigation_id');
    selectObj.options[select.options.length]=new Option(new_investigation[1],new_investigation[0],false,true);
    selectObj.disabled=false;
}

function addSop(title,id) {
    sops_assets.push([title,id]);
}

function addSelectedSop() {
    selected_option_index=$("possible_sops").selectedIndex;
    selected_option=$("possible_sops").options[selected_option_index];
    title=selected_option.text;
    id=selected_option.value;

    if(checkNotInList(id,sops_assets)) {
        addSop(title,id);
        updateSops();
    }
    else {
        alert('The following Sop had already been added:\n\n' +
            title);
    }
}

function removeSop(id) {
    // remove the actual record for the attribution
    for(var i = 0; i < sops_assets.length; i++)
        if(sops_assets[i][1] == id) {
            sops_assets.splice(i, 1);
            break;
        }

    // update the page
    updateSops();
}

function updateSops() {
    sop_text='
';

    sop_ids=new Array();

    for (var i=0;i<sops_assets.length;i++) {
        sop=sops_assets[i];
        title=sop[0];
        id=sop[1];
        titleText = '' + title.truncate(100) + '';
        sop_text += '
' + titleText +
          '   ' +
          '[remove]
';
        sop_ids.push(id);
    }

    sop_text += '
';

    // update the page
    if(sops_assets.length == 0) {
        $('sop_to_list').innerHTML = 'No sops';
    }
    else {
        $('sop_to_list').innerHTML = sop_text;
    }

    clearList('assay_sop_asset_ids');

    select=$('assay_sop_asset_ids')
    for (i=0;i<sop_ids.length;i++) {
        id=sop_ids[i];
        o=document.createElement('option');
        o.value=id;
        o.text=id;
        o.selected=true;
        try {
            select.add(o); //for older IE version
        }
        catch (ex) {
            select.add(o,null);
        }
    }
}

//Data files
function addDataFile(title,id,relationshipType) {
    data_files_assets.push([title,id,relationshipType]);
}

function addSelectedDataFile() {
    selected_option_index=$("possible_data_files").selectedIndex;
    selected_option=$("possible_data_files").options[selected_option_index];
    title=selected_option.text;
    id=selected_option.value;
    if ($("data_file_relationship_type")) {
        relationshipType = $("data_file_relationship_type").options[$("data_file_relationship_type").selectedIndex].text;
    }
    else
    {
        relationshipType="None"
    }

    if(checkNotInList(id,data_files_assets)) {
        addDataFile(title,id,relationshipType);
        updateDataFiles();
    }
    else {
        alert('The following Data file had already been added:\n\n' +
            title);
    }
}

function removeDataFile(id) {
    // remove the actual record for the attribution
    for(var i = 0; i < data_files_assets.length; i++)
        if(data_files_assets[i][1] == id) {
            data_files_assets.splice(i, 1);
            break;
        }

    // update the page
    updateDataFiles();
}

function updateDataFiles() {
    data_file_text='
'

    for (var i=0;i<data_files_assets.length;i++) {
        data_file=data_files_assets[i];
        title=data_file[0];
        id=data_file[1];
        relationshipType = data_file[2];
        relationshipText = (relationshipType == 'None') ? '' : ' (' + relationshipType + ')';
        titleText = '' + title.truncate(100) + '';
        data_file_text += '
' + titleText + relationshipText +
        '   '
        + '[remove]
';
    }

    data_file_text += '
';

    // update the page
    if(data_files_assets.length == 0) {
        $('data_file_to_list').innerHTML = 'No data files';
    }
    else {
        $('data_file_to_list').innerHTML = data_file_text;
    }

    clearList('assay_data_file_asset_ids');

    select=$('assay_data_file_asset_ids');
    for (i=0;i<data_files_assets.length;i++) {
        id=data_files_assets[i][1];
        relationshipType=data_files_assets[i][2];
        o=document.createElement('option');
        o.value=id + "," + relationshipType;
        o.text=id;
        o.selected=true;
        try {
            select.add(o); //for older IE version
        }
        catch (ex) {
            select.add(o,null);
        }
    }
}

//Models
function addModel(title,id) {
    models_assets.push([title,id]);
}

function addSelectedModel() {
    selected_option_index=$("possible_models").selectedIndex;
    selected_option=$("possible_models").options[selected_option_index];
    title=selected_option.text;
    id=selected_option.value;

    if(checkNotInList(id,models_assets)) {
        addModel(title,id);
        updateModels();
    }
    else {
        alert('The following Model had already been added:\n\n' +
            title);
    }
}

function removeModel(id) {
    // remove the actual record for the attribution
    for(var i = 0; i < models_assets.length; i++)
        if(models_assets[i][1] == id) {
            models_assets.splice(i, 1);
            break;
        }

    // update the page
    updateModels();
}

function updateModels() {
    model_text='
';
    type="Model";
    model_ids=new Array();

    for (var i=0;i<models_assets.length;i++) {
        model=models_assets[i];
        title=model[0];
        id=model[1];
        titleText = '' + title.truncate(100) + '';
        model_text += '
' + titleText
        //+ "  (" + contributor + ")"
        + '   '
        + '[remove]
';
        model_ids.push(id);
    }

    model_text += '
';

    // update the page
    if(models_assets.length == 0) {
        $('model_to_list').innerHTML = 'No models';
    }
    else {
        $('model_to_list').innerHTML = model_text;
    }

    clearList('assay_model_asset_ids');

    select=$('assay_model_asset_ids');
    for (i=0;i<model_ids.length;i++) {
        id=model_ids[i];
        o=document.createElement('option');
        o.value=id;
        o.text=id;
        o.selected=true;
        try {
            select.add(o); //for older IE version
        }
        catch (ex) {
            select.add(o,null);
        }
    }
}

//Assays
function addSelectedAssay() {
    selected_option_index=$("possible_assays").selectedIndex;
    selected_option=$("possible_assays").options[selected_option_index];
    title=selected_option.text;
    id=selected_option.value;

    if(checkNotInList(id,assays)) {
        addAssay(title,id);
        updateAssays();
    }
    else {
        alert('The following Assay had already been added:\n\n' +
            title);
    }
}

function removeAssay(id) {
    // remove the actual record for the attribution
    for(var i = 0; i < assays.length; i++)
        if(assays[i][1] == id) {
            assays.splice(i, 1);
            break;
        }

    // update the page
    updateAssays();
}

function updateAssays() {
    assay_text='';
    type="Assay";
    assay_ids=new Array();

    for (var i=0;i<assays.length;i++) {
        assay=assays[i];
        title=assay[0];
        id=assay[1];
        assay_text += '' + type + ': ' + title
        //+ "  (" + contributor + ")"
        + '   '
        + '[remove]
';
        assay_ids.push(id);
    }

    // remove the last line break
    if(assay_text.length > 0) {
        assay_text = assay_text.slice(0,-5);
    }

    // update the page
    if(assay_text.length == 0) {
        $('assay_to_list').innerHTML = 'No assays';
    }
    else {
        $('assay_to_list').innerHTML = assay_text;
    }

    clearList('study_assay_ids');

    select=$('study_assay_ids');
    for (i=0;i<assay_ids.length;i++) {
        id=assay_ids[i];
        o=document.createElement('option');
        o.value=id;
        o.text=id;
        o.selected=true;
        try {
            select.add(o); //for older IE version
        }
        catch (ex) {
            select.add(o,null);
        }
    }
}

function addAssay(title,id) {
    assays.push([title,id]);
}<|endoftext|>


<commit_before>$(document).ready(function(){
	$(".acciones").on('click', function(){

		var modal = $("#modal");
		var url = 'http://'+location.host +'/dashboard/'+$("#modulo").val()+'/'+$("#programa").val()
		url+='/'+$(this).attr('role')

		if( $(this).attr('role') == 'reportes' ){
			$("#reportes").removeClass('hidden')
			$("#salvar").addClass('hidden')
			url+='?viaje_id='+(($(this).attr('id-transporte') == undefined)? 0 : $(this).attr('id-transporte'));
		}
		else{
			$("#reportes").addClass('hidden')
			$("#salvar").removeClass('hidden')
		}

		$.getJSON(url, {}, function(resp){
			modal.modal({show: true})
			$("#form-modal").html(resp.formulario)
		})
	} ) ;

	$("#reportes").on('click', function(){
		var datos = $("#form-modal").serialize()
		if( document.getElementById('tipo_reporte').value == '' ){
			alert("DEBE SELECCIONAR UN TIPO DE REPORTE")
			return false;
		}
		else{
			var url = 'http://'+location.host+'/dashboard/'+$("#modulo").val()+'/'+$("#programa").val()+'/imprimir';
			url+= '?'+datos;
			window.open(url, 'REPORTES DE TRANSPORTE', 'width=750,height=950');
		}
	})

	$(".factura").on('click', function(){
		var url = 'http://'+location.host+'/dashboard/'+$("#modulo").val()+'/'+$("#programa").val()+'/factura';
		url+= '?viaje_id='+$(this).attr('id-transporte')
		window.open(url, 'RECIBO', 'width=750,height=950');
	})
})

function cargar_vehiculo(e, boton){

	location.href = 'http://'+location.host+'/dashboard/'+$("#modulo").val()+'/'+$("#programa").val()+'/cargar_vehiculo?id='+boton.getAttribute('data-id')

}

function agregar_persona(event, boton){
	boton.classList.add('disabled')
	$("#persona_id").val(boton.getAttribute('data-id'));
	$("#persona").html(boton.getAttribute('nombre'))
}

function calcularCombustible(){
	var precio_combustible = document.getElementById('precio_x_lts_combustible')
	var lts_usados = document.getElementById('combustible_viaje')

	document.getElementById('precio_combustible').value = parseFloat(precio_combustible.value) * parseFloat(lts_usados.value)
}

function calcularPeso(){
	var kgs = document.getElementById('kilo_viajes')
	var precio =document.getElementById('precio_kilo')

	document.getElementById('total_peso_viaje').value = parseFloat(kgs.value) * parseFloat(precio.value)
}

function calcularMaterial(){
	var kgs = document.getElementById('total_kilo_material')
	var precio =document.getElementById('total_kilo_viaje_material')

	document.getElementById('total_viaje_kilos').value = parseFloat(kgs.value) * parseFloat(precio.value)
}<commit_msg>ARREGLADO EL PROBLEMA DE LAS VENTANAS MODALES DEL MODULO DE TRANSPORTE<commit_after>$(document).ready(function(){
	$(".acciones").on('click', function(){

		var modal = $("#modal");
		var url = 'http://'+location.host +'/index.php/dashboard/'+$("#modulo").val()+'/'+$("#programa").val()
		url+='/'+$(this).attr('role')

		if( $(this).attr('role') == 'reportes' ){
			$("#reportes").removeClass('hidden')
			$("#salvar").addClass('hidden')
			url+='?viaje_id='+(($(this).attr('id-transporte') == undefined)? 0 : $(this).attr('id-transporte'));
		}
		else{
			$("#reportes").addClass('hidden')
			$("#salvar").removeClass('hidden')
		}

		$.getJSON(url, {}, function(resp){
			modal.modal({show: true})
			$("#form-modal").html(resp.formulario)
		})
	} ) ;

	$("#reportes").on('click', function(){
		var datos = $("#form-modal").serialize()
		if( document.getElementById('tipo_reporte').value == '' ){
			alert("DEBE SELECCIONAR UN TIPO DE REPORTE")
			return false;
		}
		else{
			var url = 'http://'+location.host+'/index.php/dashboard/'+$("#modulo").val()+'/'+$("#programa").val()+'/imprimir';
			url+= '?'+datos;
			window.open(url, 'REPORTES DE TRANSPORTE', 'width=750,height=950');
		}
	})

	$(".factura").on('click', function(){
		var url = 'http://'+location.host+'/index.php/dashboard/'+$("#modulo").val()+'/'+$("#programa").val()+'/factura';
		url+= '?viaje_id='+$(this).attr('id-transporte')
		window.open(url, 'RECIBO', 'width=750,height=950');
	})
})

function cargar_vehiculo(e, boton){

	location.href = 'http://'+location.host+'/index.php/dashboard/'+$("#modulo").val()+'/'+$("#programa").val()+'/cargar_vehiculo?id='+boton.getAttribute('data-id')

}

function agregar_persona(event, boton){
	boton.classList.add('disabled')
	$("#persona_id").val(boton.getAttribute('data-id'));
	$("#persona").html(boton.getAttribute('nombre'))
}

function calcularCombustible(){
	var precio_combustible = document.getElementById('precio_x_lts_combustible')
	var lts_usados = document.getElementById('combustible_viaje')

	document.getElementById('precio_combustible').value = parseFloat(precio_combustible.value) * parseFloat(lts_usados.value)
}

function calcularPeso(){
	var kgs = document.getElementById('kilo_viajes')
	var precio =document.getElementById('precio_kilo')

	document.getElementById('total_peso_viaje').value = parseFloat(kgs.value) * parseFloat(precio.value)
}

function calcularMaterial(){
	var kgs = document.getElementById('total_kilo_material')
	var precio =document.getElementById('total_kilo_viaje_material')

	document.getElementById('total_viaje_kilos').value = parseFloat(kgs.value) * parseFloat(precio.value)
}<|endoftext|>


<commit_before>// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
// MIT License. See license.txt

wn.ui.form.Comments = Class.extend({
	init: function(opts) {
		$.extend(this, opts);
		this.make();
	},
	make: function() {
		var me = this;
		this.wrapper =this.parent;
		this.row = $("
").appendTo(this.parent);
		this.input = $('
\
			<textarea rows="3" class="form-control"></textarea>
')
			.appendTo(this.row)
			.find("textarea");
		this.button = $('
\
			<button class="btn btn-default btn-go" class="col-md-1">\
				</button>\

')
			.appendTo(this.row)
			.find("button")
			.click(function() {
				me.add_comment();
			});
		this.list = $('

')
			.appendTo(this.parent);
	},
	get_comments: function() {
		return this.frm.get_docinfo().comments;
	},
	refresh: function() {
		var me = this;
		if(this.frm.doc.__islocal) {
			this.wrapper.toggle(false);
			return;
		}
		this.wrapper.toggle(true);
		this.list.empty();
		var comments = this.get_comments();
		$.each(comments, function(i, c) {
			if(wn.model.can_delete("Comment")) {
				c["delete"] = '×';
			} else {
				c["delete"] = "";
			}
			c.image = wn.user_info(c.comment_by).image;
			c.comment_on = dateutil.comment_when(c.creation);
			c.fullname = wn.user_info(c.comment_by).fullname;

			$(repl('
\

\

\
						\

\

\
						%(comment)s%(delete)s
\
						%(fullname)s / %(comment_on)s\

\

\

', c))
				.appendTo(me.list)
				.on("click", ".close", function() {
					var name = $(this).parents(".comment:first").attr("data-name");
					me.delete_comment(name);
					return false;
				})

		});
	},
	add_comment: function() {
		var me = this,
			txt = me.input.val();

		if(txt) {
			var comment = {
				doctype: "Comment",
				comment_doctype: me.frm.doctype,
				comment_docname: me.frm.docname,
				comment: txt,
				comment_by: user
			};

			return wn.call({
				method: "webnotes.widgets.form.utils.add_comment",
				args: {
					doclist:[comment]
				},
				callback: function(r) {
					if(!r.exc) {
						me.frm.get_docinfo().comments =
							r.message.concat(me.get_comments());
						me.frm.toolbar.show_infobar();
						me.input.val("");
						me.refresh();
					}
				}
			});
		}
	},
	delete_comment: function(name) {
		var me = this;
		return wn.call({
			method: "webnotes.client.delete",
			args: {
				doctype: "Comment",
				name: name
			},
			callback: function(r) {
				if(!r.exc) {
					me.frm.get_docinfo().comments =
						$.map(me.frm.get_docinfo().comments,
							function(v) {
								if(v.name==name) return null;
								else return v;
							}
						);
					me.refresh();
					me.frm.toolbar.show_infobar();
				}
			}
		});
	}
})<commit_msg>[fix] [minor] show for comment in alert-warning<commit_after>// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
// MIT License. See license.txt

wn.ui.form.Comments = Class.extend({
	init: function(opts) {
		$.extend(this, opts);
		this.make();
	},
	make: function() {
		var me = this;
		this.wrapper =this.parent;
		this.row = $("
").appendTo(this.parent);
		this.input = $('
\
			<textarea rows="3" class="form-control"></textarea>
')
			.appendTo(this.row)
			.find("textarea");
		this.button = $('
\
			<button class="btn btn-default btn-go" class="col-md-1">\
				</button>\

')
			.appendTo(this.row)
			.find("button")
			.click(function() {
				me.add_comment(this);
			});
		this.list = $('

')
			.appendTo(this.parent);
	},
	get_comments: function() {
		return this.frm.get_docinfo().comments;
	},
	refresh: function() {
		var me = this;
		if(this.frm.doc.__islocal) {
			this.wrapper.toggle(false);
			return;
		}
		this.wrapper.toggle(true);
		this.list.empty();
		var comments = this.get_comments();
		$.each(comments, function(i, c) {
			if(wn.model.can_delete("Comment")) {
				c["delete"] = '×';
			} else {
				c["delete"] = "";
			}
			c.image = wn.user_info(c.comment_by).image;
			c.comment_on = dateutil.comment_when(c.creation);
			c.fullname = wn.user_info(c.comment_by).fullname;

			$(repl('
\

\

\
						\

\

\
						%(comment)s%(delete)s
\
						%(fullname)s / %(comment_on)s\

\

\

', c))
				.appendTo(me.list)
				.on("click", ".close", function() {
					var name = $(this).parents(".comment:first").attr("data-name");
					me.delete_comment(name);
					return false;
				})

		});
	},
	add_comment: function(btn) {
		var me = this,
			txt = me.input.val();

		if(txt) {
			var comment = {
				doctype: "Comment",
				comment_doctype: me.frm.doctype,
				comment_docname: me.frm.docname,
				comment: txt,
				comment_by: user
			};

			return wn.call({
				method: "webnotes.widgets.form.utils.add_comment",
				args: {
					doclist:[comment]
				},
				btn: btn,
				callback: function(r) {
					if(!r.exc) {
						me.frm.get_docinfo().comments =
							r.message.concat(me.get_comments());
						me.frm.toolbar.show_infobar();
						me.input.val("");
						me.refresh();
					}
				}
			});
		}
	},
	delete_comment: function(name) {
		var me = this;
		return wn.call({
			method: "webnotes.client.delete",
			args: {
				doctype: "Comment",
				name: name
			},
			callback: function(r) {
				if(!r.exc) {
					me.frm.get_docinfo().comments =
						$.map(me.frm.get_docinfo().comments,
							function(v) {
								if(v.name==name) return null;
								else return v;
							}
						);
					me.refresh();
					me.frm.toolbar.show_infobar();
				}
			}
		});
	}
})<|endoftext|>


<commit_before>var test = require('tape');
var toDo = require('../libs/to-do-handler');

test('shouldGetToDoListForUsername', function(t) {
  t.plan(2);

  toDo.getToDoListForUsername('bhish',
    function(result) {
      var parsedToDo = result;
      var expected = [
        ['Make to-do app', 'A to-do application should be made for doing fun to-do type doing stuff. And it should be done before xmas!', '20151224'],
        ['Admire to-do app', 'And then he read his to-dos, and, behold, it was very good.', '20151225']
      ];
      t.deepEqual(parsedToDo, expected);
    });

  toDo.getToDoListForUsername('bart',
    function(result) {
      var parsedToDo = result;
      var expected = [
        ['FLAnnoy Homer', 'Annoy him really badly', '20160101'],
        ['Laugh at Milhouse', 'Because, why not?', '20160101']
      ];
      t.deepEqual(parsedToDo, expected);
    });

});<commit_msg>Revert "Breaking change to test Travis"<commit_after>var test = require('tape');
var toDo = require('../libs/to-do-handler');

test('shouldGetToDoListForUsername', function(t) {
  t.plan(2);

  toDo.getToDoListForUsername('bhish',
    function(result) {
      var parsedToDo = result;
      var expected = [
        ['Make to-do app', 'A to-do application should be made for doing fun to-do type doing stuff. And it should be done before xmas!', '20151224'],
        ['Admire to-do app', 'And then he read his to-dos, and, behold, it was very good.', '20151225']
      ];
      t.deepEqual(parsedToDo, expected);
    });

  toDo.getToDoListForUsername('bart',
    function(result) {
      var parsedToDo = result;
      var expected = [
        ['Annoy Homer', 'Annoy him really badly', '20160101'],
        ['Laugh at Milhouse', 'Because, why not?', '20160101']
      ];
      t.deepEqual(parsedToDo, expected);
    });

});<|endoftext|>


<commit_before>var React    = require('react'),
    ReactDOM = require('react-dom'),
    sampleData = [{}],//require('../../sample-data-reviews.js'),
    sampleDataUpdated = [{}];//require('../../sample-data-reviews-updated.js');

// hiii
var Container = React.createClass({
  getInitialState: function(){
    return {
      lat: 0,
      lng: 0,
      locations: [],
      loggedIn: false
    }
  },
  createMap: function() {
    var self  = this;
    var state = this.state;
    // set up the map
    state.map = new GMaps({
      div: '#map',
      lat: state.lat,
      lng: state.lng,
      idle: function(){
        // function to make [AJAX] call and grab locations
        // console.log('idle!!!');
      }
    });

    this.setState(state);

  },
  setPosition: function(lat, lng){
    var self = this;
    var state = this.state;
    state.lat = lat;
    state.lng = lng;

    $.ajax({
      method: 'post',
      url: 'http://localhost:3000/search',
      data: { lat: lat, lng: lng, radius: 10 },
      success: function(returnedLocations){
        state.locations = returnedLocations;
        self.setState(state);
      },
      error: function(err){
        console.log(err);
      }
    })

  },

  render: function(){
    return(

        <Buttons />
        <FeedContainer />
        <GoogleMap  lat={ this.state.lat }
                    lng={ this.state.lng }
                    locations={ this.state.locations }
                    setPosition={ this.setPosition }
                    createMap = { this.createMap }
                    map={ this.state.map }/>

    )
  }
})

var GoogleMap = React.createClass({
  centerMap: function(lat, lng){
    this.props.setPosition(lat, lng); // function from container to set location globally
    this.props.map.setCenter(lat, lng);
    this.props.map.addMarker({
        lat: lat,
        lng: lng
      })
  },
  addMarkers: function(){
    var self = this;
    this.props.locations.forEach(function(location){
      // console.log(location);
      self.props.map.addMarker({
        lat: location.lat,
        lng: location.lng,
        infoWindow: {
          content: ('
' + location.placeName+ '

' + location.comment + '
')
        }
      });

    })
  },
  componentDidMount: function(){
    var self = this;
    this.props.createMap();

    // show "loading" here

    // find user's position
    GMaps.geolocate({
      success: function(position) {
        // hide "loading" here
        self.centerMap(position.coords.latitude, position.coords.longitude);
      },
      error: function(error) {
        console.log('Geolocation failed: ' + error.message);
      },
      not_supported: function() {
        console.log("Your browser does not support geolocation");
      },
      always: function() {
        console.log("Done!");
      }
    });
  },

  render: function(){
    this.addMarkers();
    return(

        <AddressSearch
          centerMap={ this.centerMap }/>

    )
  }
})

var AddressSearch = React.createClass({
  componentDidMount: function(){
    var self = this;
    $('#address-search-button').click(function(e){
      e.preventDefault();
      var address = $('#address-search').val();

      if (address){
        // ajax to google places api on the server
        // returns its best guess of a location
        // depending on what the user enters
        $.ajax({
          method: 'post',
          url: '/location',
          data: { place: address },
          success: function(data){
            // function to make [AJAX] call and grab locations
            // take the address and center the map at that location
            GMaps.geocode({
              address: data,
              callback: function(results, status) {
                if (status == 'OK') {
                  // console.log(results);
                  var latlng = results[0].geometry.location;
                  self.props.centerMap(latlng.lat(), latlng.lng());
                }
              }
            });

          },
          error: function(err){
            console.log(err);
          }
        })
      }

    })
  },
  render: function(){
    return(
      <form>
        <input id="address-search" type="text"></input>

        <button id="address-search-button" type="button">Seach Address</button>
      </form>
    )
  }
})

var FeedContainer = React.createClass({
  getInitialState: function(){
    return { displayWelcome: false,
             displayFeed: true,
             displayPost: false
             }
  },
  changeToFeed: function(){
    var state = { displayWelcome: false,
                  displayFeed: true,
                  displayPost: false }
    this.setState(state);
  },
  changeToPost: function(){
    var state = { displayWelcome: false,
                  displayFeed: false,
                  displayPost: true }
    this.setState(state);
  },
  render: function(){
    return(

guhhhh

        { this.state.displayWelcome ? <Welcome /> : null }
        { this.state.displayFeed ? <Feed /> : null }
        { this.state.displayPost ? <Post /> : null }
        { this.state.displayPost ? <button onClick={ this.changeToFeed }>RESULTS</button> : null }
        { this.state.displayFeed ? <button onClick={ this.changeToPost }>POST</button> : null }

    )
  }
})

var Feed = React.createClass({
  getInitialState: function(){
    // return { locations: this.props.locations }
    // using our test data:
    return { locations: sampleData }
  },
  updateFeedItems: function(){
    var state;
    // this will be ajax to api
    state = { locations: sampleDataUpdated }
    this.setState(state);
  },
  render: function(){
    var self = this;
    var locations = this.state.locations.map(function(location, i){
      return(
          <FeedItem
            key={ i }
            name={ location.placeName }
            comment={ location.comment }
            updateFeedItems={ self.updateFeedItems }/>
      )
    })
    return(

Here's what we found...

        { locations }

    )
  }
})

var FeedItem = React.createClass({
  clickHandler: function(e){
    console.log('you clicked a list item!');
    // function to update feed so it shows only items for that location
    this.props.updateFeedItems();

  },
  render: function(){
    return(

{ this.props.name }

{ this.props.comment }

    )
  }
})

var Welcome = React.createClass({
  render: function(){
    return (

          Welcome to PROJECT NAME! The place to see and share what's going on in your city.
          Share pictures, comments and more to the interactive map where others can catch a short lived glimpse
          of your activity. Search the map to see other posts to help you get off the couch and explore the city!

          Enter an address or press search to get started!

    )
  }
})

var Post = React.createClass({
  getInitialState: function(){
    return{
      comment: '',
      picture: ''
    }
  },
  postHandler: function(e){
    e.preventDefault();
    var state = this.state;
    state.time = Date.now();
    console.log(state);
    $.ajax({
      method: 'post',
      url: 'http://localhost:3000/create', // whatever this route is supposed to be
      data: state,
      success: function(data){
        console.log(data);
      },
      error: function(err){
        console.log(err);
      }
    });
  },
  textChange: function(e){
    var state = this.state;
    state[e.target.name] = e.target.value;
    this.setState(state);
  },
  imageChange: function(event){
    var input = $('#imgUpload')[0].files[0];
    var reader = new FileReader();
    var state = this.state;
    var self = this;

    reader.onload = function (e) {
      // console.log(e.target.result);
      state.picture = e.target.result;
      self.setState(state);
      $("#images").val(e.target.result);
    // console.log($('#myImage').val())
    };

    reader.readAsDataURL(input);
  },
  render: function(){
    return (

Upload Image

        <form onSubmit={ this.postHandler }>
          <input id="imgUpload" type="file" name="image" onChange={this.imageChange}/>
          Comment:
          <input className="comment" type="text" name="comment" onChange={ this.textChange }></input>
          Name:
          <input className="name" type="text" name="userName" onChange={ this.textChange }></input>
          <button type="submit">Upload</button>
        </form>

    )
  }
})

var Buttons = React.createClass({
  getInitialState: function(){
    return {
      welcomeScreen: true,
      userLoggedIn: false,
    }
  },
  handleLoggedIn: function(logged){
    if(logged){
      var state = this.state
      state.userLoggedIn = true
      this.setState(state)
      console.log(this.state)
    }
  },
  handleLoggedOut: function(logged){
    if(logged){
      var state = this.state
      state.userLoggedIn = false
      this.setState(state)
      console.log(this.state)
    }
  },
  render: function(){
    return (

          {this.state.userLoggedIn ? <LogOut handleLoggedOut={this.handleLoggedOut} /> :  <LogIn handleLoggedIn={this.handleLoggedIn} handleLoggedOut={this.handleLoggedOut}/>  }

    )
  },
})

var LogIn = React.createClass({
  getInitialState: function(){
    return{
      username: '',
      email: '',
      password: ''
    }
  },
  loginHandler: function(e){
    e.preventDefault();
    var state = this.state;
    $.ajax({
      method: 'post',
      url: 'http://localhost:3000/users/login',
      data: state,
      success: function(data){
        console.log(data);
      },
      error: function(err){
        console.log(err);
      }
    });
  },
  registerHandler: function(e){
    e.preventDefault();
    var state = this.state;
    $.ajax({
      method: 'post',
      url: 'http://localhost:3000/users/signup',
      data: state,
      success: function(data){
        console.log(data);
      },
      error: function(err){
        console.log(err);
      }
    });
  },
  textChange: function(e){
    var state = this.state;
    state[e.target.name] = e.target.value;
    this.setState(state);
  },
  handleLoginClick: function(event){
    this.props.handleLoggedIn(true)
    //event.target.value will get you values of inputs
    //this will need to be an ajax call for users log in
    console.log('ATTEMPTED LOGIN!')
  },
  render: function(){
    return(

        <form onSubmit={ this.loginHandler }>
          Email:
          <input class="email" type="text" name="email" onChange={ this.textChange }></input>
          Password:
          <input class="password" type="password" name="password" onChange={ this.textChange }></input>
          <button onClick={this.handleLoginClick} type="submit">LOGIN</button>
        </form>

          Not Registered? Sign Up!

Register

                ×
                <form onSubmit={ this.registerHandler }>

                      Username:
                      <input className="name" type="text" name="username" onChange={ this.textChange }></input>

                      Email:
                      <input className="email" type="text" name="email" onChange={ this.textChange }></input>

                      Password:
                      <input className="password" type="password" name="password" onChange={ this.textChange }></input>

                      Re-Confirm Password:
                      <input className="password" type="password" name="reconfirmpassword" onChange={ this.textChange }></input>

                      Default Address:
                      <input className="address" type="text" name="default_address" onChange={ this.textChange }></input>

                      <button onClick={this.handleLoginClick} type="submit">REGISTER</button>

                </form>

    )
  }
})

var LogOut = React.createClass({
  handleLogoutClick: function(event){
    this.props.handleLoggedOut(true)
    console.log('ATTEMPTED LOGOUT!')
  },
  render: function(){
    return(

        Welcome User
        <button onClick={this.handleLogoutClick} type="button">LOGOUT</button>

    )
  }
})

ReactDOM.render(<Container />, document.querySelector('main'));
<commit_msg>working on ajax<commit_after>var React    = require('react'),
    ReactDOM = require('react-dom'),
    sampleData = [{}],//require('../../sample-data-reviews.js'),
    sampleDataUpdated = [{}];//require('../../sample-data-reviews-updated.js');

// hiii
var Container = React.createClass({
  getInitialState: function(){
    return {
      lat: 0,
      lng: 0,
      locations: [],
      loggedIn: false
    }
  },
  createMap: function() {
    var self  = this;
    var state = this.state;
    // set up the map
    state.map = new GMaps({
      div: '#map',
      lat: state.lat,
      lng: state.lng,
      idle: function(){
        // function to make [AJAX] call and grab locations
        // console.log('idle!!!');
      }
    });

    this.setState(state);

  },
  setPosition: function(lat, lng){
    var self = this;
    var state = this.state;
    state.lat = lat;
    state.lng = lng;

    $.ajax({
      method: 'post',
      url: 'http://localhost:3000/search',
      data: { lat: lat, lng: lng, radius: 10 },
      success: function(returnedLocations){
        state.locations = returnedLocations;
        self.setState(state);
      },
      error: function(err){
        console.log(err);
      }
    })

  },

  render: function(){
    return(

        <Buttons />
        <FeedContainer lat={ this.state.lat }
                       lng={ this.state.lng }/>

        <GoogleMap  lat={ this.state.lat }
                    lng={ this.state.lng }
                    locations={ this.state.locations }
                    setPosition={ this.setPosition }
                    createMap = { this.createMap }
                    map={ this.state.map }/>

    )
  }
})

var GoogleMap = React.createClass({
  centerMap: function(lat, lng){
    this.props.setPosition(lat, lng); // function from container to set location globally
    this.props.map.setCenter(lat, lng);
    this.props.map.addMarker({
        lat: lat,
        lng: lng
      })
  },
  addMarkers: function(){
    var self = this;
    this.props.locations.forEach(function(location){
      // console.log(location);
      self.props.map.addMarker({
        lat: location.lat,
        lng: location.lng,
        infoWindow: {
          content: ('
' + location.placeName+ '

' + location.comment + '
')
        }
      });

    })
  },
  componentDidMount: function(){
    var self = this;
    this.props.createMap();

    // show "loading" here

    // find user's position
    GMaps.geolocate({
      success: function(position) {
        // hide "loading" here
        self.centerMap(position.coords.latitude, position.coords.longitude);
      },
      error: function(error) {
        console.log('Geolocation failed: ' + error.message);
      },
      not_supported: function() {
        console.log("Your browser does not support geolocation");
      },
      always: function() {
        console.log("Done!");
      }
    });
  },

  render: function(){
    this.addMarkers();
    return(

        <AddressSearch
          centerMap={ this.centerMap }/>

    )
  }
})

var AddressSearch = React.createClass({
  componentDidMount: function(){
    var self = this;
    $('#address-search-button').click(function(e){
      e.preventDefault();
      var address = $('#address-search').val();

      if (address){
        // ajax to google places api on the server
        // returns its best guess of a location
        // depending on what the user enters
        $.ajax({
          method: 'post',
          url: '/location',
          data: { place: address },
          success: function(data){
            // function to make [AJAX] call and grab locations
            // take the address and center the map at that location
            GMaps.geocode({
              address: data,
              callback: function(results, status) {
                if (status == 'OK') {
                  // console.log(results);
                  var latlng = results[0].geometry.location;
                  self.props.centerMap(latlng.lat(), latlng.lng());
                }
              }
            });

          },
          error: function(err){
            console.log(err);
          }
        })
      }

    })
  },
  render: function(){
    return(
      <form>
        <input id="address-search" type="text"></input>

        <button id="address-search-button" type="button">Seach Address</button>
      </form>
    )
  }
})

var FeedContainer = React.createClass({
  getInitialState: function(){
    return { displayWelcome: false,
             displayFeed: true,
             displayPost: false
             }
  },
  changeToFeed: function(){
    var state = { displayWelcome: false,
                  displayFeed: true,
                  displayPost: false }
    this.setState(state);
  },
  changeToPost: function(){
    var state = { displayWelcome: false,
                  displayFeed: false,
                  displayPost: true }
    this.setState(state);
  },
  render: function(){
    return(

guhhhh

        { this.state.displayWelcome ? <Welcome /> : null }
        { this.state.displayFeed ? <Feed /> : null }
        { this.state.displayPost ? <Post /> : null }
        { this.state.displayPost ? <button onClick={ this.changeToFeed }>RESULTS</button> : null }
        { this.state.displayFeed ? <button onClick={ this.changeToPost }>POST</button> : null }

    )
  }
})

var Feed = React.createClass({
  getInitialState: function(){
    // return { locations: this.props.locations }
    // using our test data:
    return { locations: sampleData }
  },
  updateFeedItems: function(){
    var state;
    // this will be ajax to api
    state = { locations: sampleDataUpdated }
    this.setState(state);
  },
  render: function(){
    var self = this;
    var locations = this.state.locations.map(function(location, i){
      return(
          <FeedItem
            key={ i }
            name={ location.placeName }
            comment={ location.comment }
            updateFeedItems={ self.updateFeedItems }/>
      )
    })
    return(

Here's what we found...

        { locations }

    )
  }
})

var FeedItem = React.createClass({
  clickHandler: function(e){
    console.log('you clicked a list item!');
    // function to update feed so it shows only items for that location
    this.props.updateFeedItems();

  },
  render: function(){
    return(

{ this.props.name }

{ this.props.comment }

    )
  }
})

var Welcome = React.createClass({
  render: function(){
    return (

          Welcome to PROJECT NAME! The place to see and share what's going on in your city.
          Share pictures, comments and more to the interactive map where others can catch a short lived glimpse
          of your activity. Search the map to see other posts to help you get off the couch and explore the city!

          Enter an address or press search to get started!

    )
  }
})

var Post = React.createClass({
  getInitialState: function(){
    return{
      comment: '',
      picture: ''
    }
  },
  postHandler: function(e){
    e.preventDefault();
    var state = this.state;
    state.time = Date.now();
    console.log(state);
    $.ajax({
      method: 'post',
      url: 'http://localhost:3000/create', // whatever this route is supposed to be
      data: state,
      success: function(data){
        console.log(data);
      },
      error: function(err){
        console.log(err);
      }
    });
  },
  textChange: function(e){
    var state = this.state;
    state[e.target.name] = e.target.value;
    this.setState(state);
  },
  imageChange: function(event){
    var input = $('#imgUpload')[0].files[0];
    var reader = new FileReader();
    var state = this.state;
    var self = this;

    reader.onload = function (e) {
      // console.log(e.target.result);
      state.picture = e.target.result;
      self.setState(state);
      $("#images").val(e.target.result);
    // console.log($('#myImage').val())
    };

    reader.readAsDataURL(input);
  },
  render: function(){
    return (

Upload Image

        <form onSubmit={ this.postHandler }>
          <input id="imgUpload" type="file" name="image" onChange={this.imageChange}/>
          Comment:
          <input className="comment" type="text" name="comment" onChange={ this.textChange }></input>
          Name:
          <input className="name" type="text" name="userName" onChange={ this.textChange }></input>
          <button type="submit">Upload</button>
        </form>

    )
  }
})

var Buttons = React.createClass({
  getInitialState: function(){
    return {
      welcomeScreen: true,
      userLoggedIn: false,
    }
  },
  handleLoggedIn: function(logged){
    if(logged){
      var state = this.state
      state.userLoggedIn = true
      this.setState(state)
      console.log(this.state)
    }
  },
  handleLoggedOut: function(logged){
    if(logged){
      var state = this.state
      state.userLoggedIn = false
      this.setState(state)
      console.log(this.state)
    }
  },
  render: function(){
    return (

          {this.state.userLoggedIn ? <LogOut handleLoggedOut={this.handleLoggedOut} /> :  <LogIn handleLoggedIn={this.handleLoggedIn} handleLoggedOut={this.handleLoggedOut}/>  }

    )
  },
})

var LogIn = React.createClass({
  getInitialState: function(){
    return{
      username: '',
      email: '',
      password: ''
    }
  },
  loginHandler: function(e){
    e.preventDefault();
    var state = this.state;
    $.ajax({
      method: 'post',
      url: 'http://localhost:3000/users/login',
      data: state,
      success: function(data){
        console.log(data);
      },
      error: function(err){
        console.log(err);
      }
    });
  },
  registerHandler: function(e){
    e.preventDefault();
    var state = this.state;
    $.ajax({
      method: 'post',
      url: 'http://localhost:3000/users/signup',
      data: state,
      success: function(data){
        console.log(data);
      },
      error: function(err){
        console.log(err);
      }
    });
  },
  textChange: function(e){
    var state = this.state;
    state[e.target.name] = e.target.value;
    this.setState(state);
  },
  handleLoginClick: function(event){
    this.props.handleLoggedIn(true)
    //event.target.value will get you values of inputs
    //this will need to be an ajax call for users log in
    console.log('ATTEMPTED LOGIN!')
  },
  render: function(){
    return(

        <form onSubmit={ this.loginHandler }>
          Email:
          <input class="email" type="text" name="email" onChange={ this.textChange }></input>
          Password:
          <input class="password" type="password" name="password" onChange={ this.textChange }></input>
          <button onClick={this.handleLoginClick} type="submit">LOGIN</button>
        </form>

          Not Registered? Sign Up!

Register

                ×
                <form onSubmit={ this.registerHandler }>

                      Username:
                      <input className="name" type="text" name="username" onChange={ this.textChange }></input>

                      Email:
                      <input className="email" type="text" name="email" onChange={ this.textChange }></input>

                      Password:
                      <input className="password" type="password" name="password" onChange={ this.textChange }></input>

                      Re-Confirm Password:
                      <input className="password" type="password" name="reconfirmpassword" onChange={ this.textChange }></input>

                      Default Address:
                      <input className="address" type="text" name="default_address" onChange={ this.textChange }></input>

                      <button onClick={this.handleLoginClick} type="submit">REGISTER</button>

                </form>

    )
  }
})

var LogOut = React.createClass({
  handleLogoutClick: function(event){
    this.props.handleLoggedOut(true)
    console.log('ATTEMPTED LOGOUT!')
  },
  render: function(){
    return(

        Welcome User
        <button onClick={this.handleLogoutClick} type="button">LOGOUT</button>

    )
  }
})

ReactDOM.render(<Container />, document.querySelector('main'));
<|endoftext|>