<commit_before>'use strict'

let cli = require('heroku-cli-util')
let fs = require('fs')
let uuid = require('node-uuid')
let os = require('os')
let path = require('path')
let exec = require('child_process').execSync
let nodeTar = require('../../lib/node_tar')

function compressSource (context, cwd, tempFile) {
  return new Promise(function (resolve, reject) {
    var tar = context.flags['tar'] || 'tar'
    let tarVersion = ''

    try {
      tarVersion = exec(tar + ' --version').toString()
    } catch (err) {
      // tar was not found on the system
    }

    if (tarVersion.match(/GNU tar/)) {
      let includeVcsIgnore = context.flags['include-vcs-ignore']
      let command = tar + ' cz -C ' + cwd + ' --exclude .git --exclude .gitmodules .'

      if (!includeVcsIgnore) {
        command += ' --exclude-vcs-ignores'
      }

      exec(command + ' > ' + tempFile)
      resolve()
    } else {
      cli.warn('Couldn\'t detect GNU tar. Builds could fail due to decompression errors')
      cli.warn('See https://devcenter.heroku.com/articles/platform-api-deploying-slugs#create-slug-archive')
      cli.warn('Please install it, or specify the \'--tar\' option')
      cli.warn('Falling back to node\'s built-in compressor')
      nodeTar.call(cwd, tempFile).then(resolve, reject)
    }
  })
}

function uploadCwdToSource (context, heroku, cwd) {
  return new Promise(function (resolve, reject) {
    let tempFilePath = path.join(os.tmpdir(), uuid.v4() + '.tar.gz')

    heroku.request({
      method: 'POST',
      path: '/sources'
    }).then(function (source) {
      compressSource(context, cwd, tempFilePath).then(function () {
        var stream = fs.createReadStream(tempFilePath)
        stream.on('close', function () {
          fs.unlink(tempFilePath)
        })

        cli.got.put(source.source_blob.put_url, {
          body: stream,
          headers: {
            'Content-Type': '',
            'Content-Length': fs.statSync(tempFilePath).size
          }
        }).then(function () {
          resolve(source.source_blob.get_url)
        }, reject)
      }, reject)
    }, reject)
  })
}

function create (context, heroku) {
  var sourceUrl = context.flags['source-url']
  var cwd = context.flags['cwd'] || process.cwd()

  var sourceUrlPromise = sourceUrl
    ? new Promise(function (resolve) { resolve(sourceUrl) })
    : new Promise(function (resolve, reject) { uploadCwdToSource(context, heroku, cwd).then(resolve, reject) })

  return new Promise(function (resolve, reject) {
    sourceUrlPromise.then(function (sourceGetUrl) {
      heroku.request({
        method: 'POST',
        path: `/apps/${context.app}/builds`,
        body: {
          source_blob: {
            url: sourceGetUrl,
            // TODO provide better default, eg. archive md5
            version: context.flags.version || ''
          }
        }
      }).then(function (build) {
        let stream = cli.got.stream(build.output_stream_url)
        stream.on('error', reject)
        stream.on('end', resolve)
        let piped = stream.pipe(process.stderr)
        piped.on('error', reject)
      }, reject)
    }, reject)
  })
}

module.exports = {
  topic: 'builds',
  command: 'create',
  needsAuth: true,
  needsApp: true,
  help: 'Create build from contents of current dir',
  description: 'create build',
  flags: [
    { name: 'source-url', description: 'source URL that points to the tarball of your application\'s source code', hasValue: true },
    { name: 'cwd', description: 'the local path to build. Defaults to pwd', hasValue: true },
    { name: 'tar', description: 'path to the executable GNU tar', hasValue: true },
    { name: 'version', description: 'description of your new build', hasValue: true },
    { name: 'include-vcs-ignore', description: 'include files ignores by VCS (.gitignore, ...) from the build' }
  ],
  run: cli.command(create)
}
<commit_msg>simplify uploadCwdToSource<commit_after>'use strict'

let cli = require('heroku-cli-util')
let fs = require('fs')
let uuid = require('node-uuid')
let os = require('os')
let path = require('path')
let exec = require('child_process').execSync
let nodeTar = require('../../lib/node_tar')

function compressSource (context, cwd, tempFile) {
  return new Promise(function (resolve, reject) {
    var tar = context.flags['tar'] || 'tar'
    let tarVersion = ''

    try {
      tarVersion = exec(tar + ' --version').toString()
    } catch (err) {
      // tar was not found on the system
    }

    if (tarVersion.match(/GNU tar/)) {
      let includeVcsIgnore = context.flags['include-vcs-ignore']
      let command = tar + ' cz -C ' + cwd + ' --exclude .git --exclude .gitmodules .'

      if (!includeVcsIgnore) {
        command += ' --exclude-vcs-ignores'
      }

      exec(command + ' > ' + tempFile)
      resolve()
    } else {
      cli.warn('Couldn\'t detect GNU tar. Builds could fail due to decompression errors')
      cli.warn('See https://devcenter.heroku.com/articles/platform-api-deploying-slugs#create-slug-archive')
      cli.warn('Please install it, or specify the \'--tar\' option')
      cli.warn('Falling back to node\'s built-in compressor')
      nodeTar.call(cwd, tempFile).then(resolve, reject)
    }
  })
}

async function uploadCwdToSource (context, heroku, cwd) {
  let tempFilePath = path.join(os.tmpdir(), uuid.v4() + '.tar.gz')
  let source = await heroku.post('/sources')
  await compressSource(context, cwd, tempFilePath)
  await cli.got.put(source.source_blob.put_url, {
    body: fs.createReadStream(tempFilePath),
    headers: {
      'Content-Type': '',
      'Content-Length': fs.statSync(tempFilePath).size
    }
  })
  return source.source_blob.get_url
}

function create (context, heroku) {
  var sourceUrl = context.flags['source-url']
  var cwd = context.flags['cwd'] || process.cwd()

  var sourceUrlPromise = sourceUrl
    ? new Promise(function (resolve) { resolve(sourceUrl) })
    : new Promise(function (resolve, reject) { uploadCwdToSource(context, heroku, cwd).then(resolve, reject) })

  return new Promise(function (resolve, reject) {
    sourceUrlPromise.then(function (sourceGetUrl) {
      heroku.request({
        method: 'POST',
        path: `/apps/${context.app}/builds`,
        body: {
          source_blob: {
            url: sourceGetUrl,
            // TODO provide better default, eg. archive md5
            version: context.flags.version || ''
          }
        }
      }).then(function (build) {
        let stream = cli.got.stream(build.output_stream_url)
        stream.on('error', reject)
        stream.on('end', resolve)
        let piped = stream.pipe(process.stderr)
        piped.on('error', reject)
      }, reject)
    }, reject)
  })
}

module.exports = {
  topic: 'builds',
  command: 'create',
  needsAuth: true,
  needsApp: true,
  help: 'Create build from contents of current dir',
  description: 'create build',
  flags: [
    { name: 'source-url', description: 'source URL that points to the tarball of your application\'s source code', hasValue: true },
    { name: 'cwd', description: 'the local path to build. Defaults to pwd', hasValue: true },
    { name: 'tar', description: 'path to the executable GNU tar', hasValue: true },
    { name: 'version', description: 'description of your new build', hasValue: true },
    { name: 'include-vcs-ignore', description: 'include files ignores by VCS (.gitignore, ...) from the build' }
  ],
  run: cli.command(create)
}
<|endoftext|>


<commit_before><commit_msg>...one to many for arc queries as well.<commit_after><|endoftext|>


<commit_before>
//
// Camera and Microphone Authorization
//
/*
cordova.plugins.diagnostic.requestMicrophoneAuthorization(function (status) {
    if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED) {
        console.log('GRANTED');
    } else {
        console.log(new Error('AuthorizationDenied'));
    }
}, function (err) {
    console.log(new Error('AuthorizationFailed: ' + err));
});

cordova.plugins.diagnostic.requestCameraAuthorization(function (status) {
    if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED) {
        console.log('GRANTED');
    } else {
        console.log(new Error('AuthorizationDenied'));
    }
}, function (err) {
    console.log(new Error('AuthorizationFailed: ' + err));
});
*/

var cordova = window.cordova;

// Expose WebRTC Globals
if (cordova && cordova.plugins && cordova.plugins.iosrtc) {
  cordova.plugins.iosrtc.registerGlobals();
}

//
// Container
//

var appContainer = document.querySelector('.appx');
if (!appContainer) {
  document.body.innerHTML = "";
  appContainer = document.body;
}

//
// getUserMedia
//

var localVideoEl = document.createElement('video');
localVideoEl.setAttribute('autoplay', 'autoplay');
localVideoEl.setAttribute('playsinline', 'playsinline');
// Cause zIndex - 1 failure
//localVideoEl.style.backgroundColor = 'purple';
localVideoEl.style.position = 'absolute';
localVideoEl.style.top = 0;
localVideoEl.style.left = 0;
localVideoEl.style.width = "100px";
localVideoEl.style.height = "100px";
localVideoEl.style.transform = "scaleX(-1)";
appContainer.appendChild(localVideoEl);

var localStream;

navigator.mediaDevices.getUserMedia({
  video: true,
  audio: true
}).then(function (stream) {

  localStream = stream;
  localVideoEl.srcObject = localStream;

  if (cordova && cordova.plugins && cordova.plugins.iosrtc) {
    cordova.plugins.iosrtc.observeVideo(localVideoEl);
  }

  //localVideoEl.src = window.URL.createObjectURL(stream);

  TestPluginMediaStreamRenderer(localVideoEl);
  TestRTCPeerConnection(localStream);

}).catch(function (err) {
  console.log('getUserMediaError', err);
});

function TestPluginMediaStreamRenderer(localVideoEl) {

  // Animate video position
  var currentPosition = {
    x: 0,
    y: 0
  };

  var animateTimer;
  function animateVideo() {

    currentPosition.x = currentPosition.x < (window.innerWidth - parseInt(localVideoEl.style.width, 10)) ? currentPosition.x + 1 : 0;
    currentPosition.y = currentPosition.y < (window.innerHeight - parseInt(localVideoEl.style.height, 10)) ? currentPosition.y + 1 : 0;

    localVideoEl.style.top = currentPosition.y + 'px';
    localVideoEl.style.left = currentPosition.x + 'px';

    if (cordova && cordova.plugins && cordova.plugins.iosrtc) {
      cordova.plugins.iosrtc.refreshVideos();
    }

    return animateTimer = requestAnimationFrame(animateVideo);
  }

  animateTimer = animateVideo();

  //
  // Test Video behind Element
  //

  document.body.style.background = "transparent";
  document.documentElement.style.background = "transparent";
  localVideoEl.style.zIndex = -1;

  var overEl = document.createElement('button');
  overEl.style.backgroundColor = 'red';
  overEl.style.position = 'absolute';
  overEl.style.left = 0;
  overEl.style.top = 0;
  overEl.style.width = "100px";
  overEl.style.height = "100px";

  overEl.addEventListener('click', function () {
    overEl.style.backgroundColor = overEl.style.backgroundColor === 'red' ? 'green' : 'red';

    if (overEl.style.backgroundColor === 'red') {
      animateTimer = animateVideo();
    } else {
      cancelAnimationFrame(animateTimer);
    }
  });

  appContainer.appendChild(overEl);

  overEl.style.left = ((window.innerWidth / 2)  - parseInt(overEl.style.width, 10)) + 'px';
  overEl.style.top  = ((window.innerHeight / 2) - parseInt(overEl.style.height, 10)) + 'px';

}

//
// Test RTCPeerConnection
//

var pc1 = new RTCPeerConnection(),
    pc2 = new RTCPeerConnection();

function TestRTCPeerConnection(localStream) {

  pc1.addStream(MediaStream.create(localStream));

  function onAddIceCandidate(pc, can) {
    return can && pc.addIceCandidate(can).catch(function (err) {
      console.log('addIceCandidateError', err);
    });
  };
  pc1.onicecandidate = function (e) {
    return onAddIceCandidate(pc2, e.candidate);
  };
  pc2.onicecandidate = function (e) {
    return onAddIceCandidate(pc1, e.candidate);
  };

  var peerVideoEl = document.createElement('video');
  peerVideoEl.setAttribute('autoplay', 'autoplay');
  peerVideoEl.setAttribute('playsinline', 'playsinline');
  peerVideoEl.style.backgroundColor = 'blue';
  peerVideoEl.style.position = 'fixed';
  peerVideoEl.style.width = "100px";
  peerVideoEl.style.height = "100px";
  peerVideoEl.style.top = 0;
  peerVideoEl.style.left = (window.innerWidth - parseInt(peerVideoEl.style.width, 10)) + 'px';
  appContainer.appendChild(peerVideoEl);

  pc2.onaddstream = function (e) {
    console.log('onAddStream', e);

    peerVideoEl.srcObject = e.stream;

    if (cordova && cordova.plugins && cordova.plugins.iosrtc) {
      cordova.plugins.iosrtc.observeVideo(peerVideoEl);
    }
  };

  pc2.onremovestream = function (e) {
    peerVideoEl.stop();
  };

  pc1.oniceconnectionstatechange = function (e) {
    return console.log('iceConnectionState', pc1.iceConnectionState);
  };

  pc1.onnegotiationneeded = function (e) {
    return pc1.createOffer().then(function (d) {
      return pc1.setLocalDescription(d);
    }).then(function () {
      return pc2.setRemoteDescription(pc1.localDescription);
    }).then(function () {
      return pc2.createAnswer();
    }).then(function (d) {
      return pc2.setLocalDescription(d);
    }).then(function () {
      return pc1.setRemoteDescription(pc2.localDescription);
    }).catch(function (err) {
      console.log('createOfferError', err);
    });
  };
}<commit_msg>fix gulp lint error on extra/renderer-and-libwebrtc-tests.js<commit_after>/* global RTCPeerConnection, MediaStream */

//
// Camera and Microphone Authorization
//

/*
cordova.plugins.diagnostic.requestMicrophoneAuthorization(function (status) {
    if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED) {
        console.log('GRANTED');
    } else {
        console.log(new Error('AuthorizationDenied'));
    }
}, function (err) {
    console.log(new Error('AuthorizationFailed: ' + err));
});

cordova.plugins.diagnostic.requestCameraAuthorization(function (status) {
    if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED) {
        console.log('GRANTED');
    } else {
        console.log(new Error('AuthorizationDenied'));
    }
}, function (err) {
    console.log(new Error('AuthorizationFailed: ' + err));
});
*/

var cordova = window.cordova;

// Expose WebRTC Globals
if (cordova && cordova.plugins && cordova.plugins.iosrtc) {
  cordova.plugins.iosrtc.registerGlobals();
}

//
// Container
//

var appContainer = document.querySelector('.appx');
if (!appContainer) {
  document.body.innerHTML = "";
  appContainer = document.body;
}

//
// getUserMedia
//

var localVideoEl = document.createElement('video');
localVideoEl.setAttribute('autoplay', 'autoplay');
localVideoEl.setAttribute('playsinline', 'playsinline');
// Cause zIndex - 1 failure
//localVideoEl.style.backgroundColor = 'purple';
localVideoEl.style.position = 'absolute';
localVideoEl.style.top = 0;
localVideoEl.style.left = 0;
localVideoEl.style.width = "100px";
localVideoEl.style.height = "100px";
localVideoEl.style.transform = "scaleX(-1)";
appContainer.appendChild(localVideoEl);

var localStream;

navigator.mediaDevices.getUserMedia({
  video: true,
  audio: true
}).then(function (stream) {

  localStream = stream;
  localVideoEl.srcObject = localStream;

  if (cordova && cordova.plugins && cordova.plugins.iosrtc) {
    cordova.plugins.iosrtc.observeVideo(localVideoEl);
  }

  //localVideoEl.src = window.URL.createObjectURL(stream);

  TestPluginMediaStreamRenderer(localVideoEl);
  TestRTCPeerConnection(localStream);

}).catch(function (err) {
  console.log('getUserMediaError', err);
});

function TestPluginMediaStreamRenderer(localVideoEl) {

  // Animate video position
  var currentPosition = {
    x: 0,
    y: 0
  };

  var animateTimer;
  function animateVideo() {

    currentPosition.x = currentPosition.x < (window.innerWidth - parseInt(localVideoEl.style.width, 10)) ? currentPosition.x + 1 : 0;
    currentPosition.y = currentPosition.y < (window.innerHeight - parseInt(localVideoEl.style.height, 10)) ? currentPosition.y + 1 : 0;

    localVideoEl.style.top = currentPosition.y + 'px';
    localVideoEl.style.left = currentPosition.x + 'px';

    if (cordova && cordova.plugins && cordova.plugins.iosrtc) {
      cordova.plugins.iosrtc.refreshVideos();
    }

    return (animateTimer = requestAnimationFrame(animateVideo));
  }

  animateTimer = animateVideo();

  //
  // Test Video behind Element
  //

  document.body.style.background = "transparent";
  document.documentElement.style.background = "transparent";
  localVideoEl.style.zIndex = -1;

  var overEl = document.createElement('button');
  overEl.style.backgroundColor = 'red';
  overEl.style.position = 'absolute';
  overEl.style.left = 0;
  overEl.style.top = 0;
  overEl.style.width = "100px";
  overEl.style.height = "100px";

  overEl.addEventListener('click', function () {
    overEl.style.backgroundColor = overEl.style.backgroundColor === 'red' ? 'green' : 'red';

    if (overEl.style.backgroundColor === 'red') {
      animateTimer = animateVideo();
    } else {
      cancelAnimationFrame(animateTimer);
    }
  });

  appContainer.appendChild(overEl);

  overEl.style.left = ((window.innerWidth / 2)  - parseInt(overEl.style.width, 10)) + 'px';
  overEl.style.top  = ((window.innerHeight / 2) - parseInt(overEl.style.height, 10)) + 'px';

}

//
// Test RTCPeerConnection
//

var pc1 = new RTCPeerConnection(),
    pc2 = new RTCPeerConnection();

function TestRTCPeerConnection(localStream) {

  pc1.addStream(MediaStream.create(localStream));

  function onAddIceCandidate(pc, can) {
    return can && pc.addIceCandidate(can).catch(function (err) {
      console.log('addIceCandidateError', err);
    });
  }

  pc1.onicecandidate = function (e) {
    return onAddIceCandidate(pc2, e.candidate);
  };
  pc2.onicecandidate = function (e) {
    return onAddIceCandidate(pc1, e.candidate);
  };

  var peerVideoEl = document.createElement('video');
  peerVideoEl.setAttribute('autoplay', 'autoplay');
  peerVideoEl.setAttribute('playsinline', 'playsinline');
  peerVideoEl.style.backgroundColor = 'blue';
  peerVideoEl.style.position = 'fixed';
  peerVideoEl.style.width = "100px";
  peerVideoEl.style.height = "100px";
  peerVideoEl.style.top = 0;
  peerVideoEl.style.left = (window.innerWidth - parseInt(peerVideoEl.style.width, 10)) + 'px';
  appContainer.appendChild(peerVideoEl);

  pc2.onaddstream = function (e) {
    console.log('onAddStream', e);

    peerVideoEl.srcObject = e.stream;

    if (cordova && cordova.plugins && cordova.plugins.iosrtc) {
      cordova.plugins.iosrtc.observeVideo(peerVideoEl);
    }
  };

  pc1.oniceconnectionstatechange = function (e) {
    return console.log('iceConnectionState', e, pc1.iceConnectionState);
  };

  pc1.onnegotiationneeded = function (e) {
    console.log('negotiatioNneeded', e);

    return pc1.createOffer().then(function (d) {
      return pc1.setLocalDescription(d);
    }).then(function () {
      return pc2.setRemoteDescription(pc1.localDescription);
    }).then(function () {
      return pc2.createAnswer();
    }).then(function (d) {
      return pc2.setLocalDescription(d);
    }).then(function () {
      return pc1.setRemoteDescription(pc2.localDescription);
    }).catch(function (err) {
      console.log('createOfferError', err);
    });
  };
}<|endoftext|>


<commit_before>(function($) {
   $.jqmCalendar = function(element, options) {

      var defaults = {
         // Array of events
         events : [],
         // Default properties for events
         begin : "begin",
         end : "end",
         summary : "summary",
         // Theme
         theme : "c",
         // Date variable to determine which month to show and which date to select
         date : new Date(),
         // Array of month strings (calendar header)
         months : ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
         // Array of day strings (calendar header)
         days : ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
         // Most months contain 5 weeks, some 6. Set this to six if you don't want the amount of rows to change when switching months.
         weeksInMonth : undefined,
         // [TODO]
         hideWeekends : false,
         // Start the week at the day of your preference, 0 for sunday, 1 for monday, and so on.
         startOfWeek : 0
      }

      var plugin = this;
      plugin.settings = null;

      var $element = $(element).addClass("jq-calendar-wrapper"),
          element = element,
          $table,
          $header,
          $tbody,
          $listview;

      function init() {
         plugin.settings = $.extend({}, defaults, options);
         $table = $("
");

         // Build the header
         var $thead = $("
").appendTo($table),
            $tr = $("
").appendTo($thead),
            $th = $("");

         $previous = $("Previous").click(function(event) {
            refresh(new Date(plugin.settings.date.getFullYear(), plugin.settings.date.getMonth() - 1, plugin.settings.date.getDate()));
         }).appendTo($th);

         $header = $("").appendTo($th);

         $previous = $("Next").click(function(event) {
            refresh(new Date(plugin.settings.date.getFullYear(), plugin.settings.date.getMonth() + 1, plugin.settings.date.getDate()));
         }).appendTo($th);

         $th.appendTo($tr);

         $tr = $("
").appendTo($thead);

         // The way of determing the labels for the days is a bit awkward, but works.
         for ( var i = 0, days = [].concat(plugin.settings.days, plugin.settings.days).splice(plugin.settings.startOfWeek, 7); i < 7; i++ ) {
            $tr.append(""  + days[i] + "	");
         }

         $tbody = $("
").appendTo($table);

         $table.appendTo($element);
         $listview = $("
").insertAfter($table);

         // Call refresh to fill the calendar with dates
         refresh(plugin.settings.date);
      }

      function _firstDayOfMonth(date) {
         // [0-6] Sunday is 0, Monday is 1, and so on.
         return ( new Date(date.getFullYear(), date.getMonth(), 1) ).getDay();
      }

      function _daysBefore(date, fim) {
         // Returns [0-6], 0 when firstDayOfMonth is equal to startOfWeek, else the amount of days of the previous month included in the week.
         var firstDayInMonth = ( fim || _firstDayOfMonth(date) ),
            diff = firstDayInMonth - plugin.settings.startOfWeek;
         return ( diff >= 0 ) ? diff : ( 7 + diff );
      }

      function _daysInMonth(date) {
         // [1-31]
         return ( new Date ( date.getFullYear(), date.getMonth() + 1, 0 )).getDate();
      }

      function _daysAfter(date, wim, dim, db) {
         // Returns [0-6] amount of days from the next month
         return    (( wim || _weeksInMonth(date) ) * 7 ) - ( dim || _daysInMonth(date) ) - ( db || _daysBefore(date));
      }

      function _weeksInMonth(date, dim, db) {
         // Returns [5-6];
         return ( plugin.settings.weeksInMonth ) ? plugin.settings.weeksInMonth : Math.ceil( ( ( dim || _daysInMonth(date) ) + ( db || _daysBefore(date)) ) / 7 );
      }

      function addCell($row, date, hidden, selected) {
         var $td = $("").appendTo($row),
             $a = $("")
                  .html(date.getDate().toString())
                  .data('date', date)
                  .click(cellClickHandler)
                  .appendTo($td);

         if ( selected ) $a.click();

         if ( hidden ) {
             $td.addClass("hidden");
         } else {
            var importance = 0;

            // Find events for this date
            for ( var i = 0,
                      event,
                      begin = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0, 0),
                      end = new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1, 0, 0, 0, 0);
                  event = plugin.settings.events[i]; i++ ) {
               if ( event[plugin.settings.end] > begin && event[plugin.settings.begin] < end ) {
                  importance++;
                  if ( importance > 2 ) break;
               }
            }

            if ( importance > 0 ) {
                $a.append("•").addClass("importance-" + importance.toString() );
            }
         }
      }

      function cellClickHandler(event) {
         var $this = $(this),
            date = $this.data('date');
         $tbody.find("a.ui-btn-active").removeClass("ui-btn-active");
         $this.addClass("ui-btn-active");

         if ( date.getMonth() !== plugin.settings.date.getMonth() ) {
            // Go to previous/next month
            refresh(date);
         } else {
            // Select new date
            $element.trigger('change', date);
         }
      }

      function refresh(date) {
         plugin.settings.date = date = date ||  plugin.settings.date || new Date();

         var year = date.getFullYear(),
            month = date.getMonth(),
            daysBefore = _daysBefore(date),
            daysInMonth = _daysInMonth(date),
            weeksInMonth = _weeksInMonth(date, daysInMonth, daysBefore);

         // Empty the table body, we start all over...
         $tbody.empty();
         // Change the header to match the current month
         $header.html( plugin.settings.months[month] + " " + year.toString() );

         for (    var   weekIndex = 0,
                  daysInMonthCount = 1,
                  daysAfterCount = 1; weekIndex < weeksInMonth; weekIndex++ ) {

            var daysInWeekCount = 0,
               row = $("
").appendTo($tbody);

            // Previous month
            while ( daysBefore > 0 ) {
               addCell(row, new Date(year, month, 1 - daysBefore), true);
               daysBefore--;
               daysInWeekCount++;
            }

            // Current month
            while ( daysInWeekCount < 7 && daysInMonthCount <= daysInMonth ) {
               addCell(row, new Date(year, month, daysInMonthCount), false, daysInMonthCount === date.getDate() );
               daysInWeekCount++;
               daysInMonthCount++;
            }

            // Next month
            while ( daysInMonthCount > daysInMonth && daysInWeekCount < 7 ) {
               addCell(row, new Date(year, month, daysInMonth + daysAfterCount), true);
               daysInWeekCount++;
               daysAfterCount++;
            }
         }

         $element.trigger('create');
      }

      $element.bind('change', function(event, begin) {
         var end = new Date(begin.getFullYear(), begin.getMonth(), begin.getDate() + 1, 0,0,0,0);
         // Empty the list
         $listview.empty();

         // Find events for this date
         for ( var   i = 0, event; event = plugin.settings.events[i]; i++ ) {
            if ( event[plugin.settings.end] > begin && event[plugin.settings.begin] < end ) {
               // Append matches to list
               var summary    = event[plugin.settings.summary],
                   beginTime  = (( event[plugin.settings.begin] > begin ) ? event[plugin.settings.begin] : begin ).toTimeString().substr(0,5),
                   endTime    = (( event[plugin.settings.end] < end ) ? event[plugin.settings.end] : end ).toTimeString().substr(0,5),
                   timeString = beginTime + "-" + endTime;
               $("
" + ( ( timeString != "00:00-00:00" ) ? timeString : "" ) + " " + summary + "
").appendTo($listview);
            }
         }

         $listview.trigger('create').filter(".ui-listview").listview('refresh');
      });

      $element.bind('refresh', function(event, date) {
         refresh(date);
      });

      init();
   }

   $.fn.jqmCalendar = function(options) {
      return this.each(function() {
         if (undefined == $(this).data('jqmCalendar')) {
            var plugin = new $.jqmCalendar(this, options);
         }
      });
   }

})(jQuery);<commit_msg>Issues #1 & #2 fixed<commit_after>(function($) {
   $.jqmCalendar = function(element, options) {

      var defaults = {
         // Array of events
         events : [],
         // Default properties for events
         begin : "begin",
         end : "end",
         summary : "summary",
         // Theme
         theme : "c",
         // Date variable to determine which month to show and which date to select
         date : new Date(),
         // Array of month strings (calendar header)
         months : ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
         // Array of day strings (calendar header)
         days : ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
         // Most months contain 5 weeks, some 6. Set this to six if you don't want the amount of rows to change when switching months.
         weeksInMonth : undefined,
         // [TODO]
         hideWeekends : false,
         // Start the week at the day of your preference, 0 for sunday, 1 for monday, and so on.
         startOfWeek : 0
      }

      var plugin = this;
      plugin.settings = null;

      var $element = $(element).addClass("jq-calendar-wrapper"),
          element = element,
          $table,
          $header,
          $tbody,
          $listview;

      function init() {
         plugin.settings = $.extend({}, defaults, options);
         $table = $("
");

         // Build the header
         var $thead = $("
").appendTo($table),
            $tr = $("
").appendTo($thead),
            $th = $("");

         $previous = $("Previous").click(function(event) {
            refresh(new Date(plugin.settings.date.getFullYear(), plugin.settings.date.getMonth() - 1, plugin.settings.date.getDate()));
         }).appendTo($th);

         $header = $("").appendTo($th);

         $previous = $("Next").click(function(event) {
            refresh(new Date(plugin.settings.date.getFullYear(), plugin.settings.date.getMonth() + 1, plugin.settings.date.getDate()));
         }).appendTo($th);

         $th.appendTo($tr);

         $tr = $("
").appendTo($thead);

         // The way of determing the labels for the days is a bit awkward, but works.
         for ( var i = 0, days = [].concat(plugin.settings.days, plugin.settings.days).splice(plugin.settings.startOfWeek, 7); i < 7; i++ ) {
            $tr.append(""  + days[i] + "	");
         }

         $tbody = $("
").appendTo($table);

         $table.appendTo($element);
         $listview = $("
").insertAfter($table);

         // Call refresh to fill the calendar with dates
         refresh(plugin.settings.date);
      }

      function _firstDayOfMonth(date) {
         // [0-6] Sunday is 0, Monday is 1, and so on.
         return ( new Date(date.getFullYear(), date.getMonth(), 1) ).getDay();
      }

      function _daysBefore(date, fim) {
          // Returns [0-6], 0 when firstDayOfMonth is equal to startOfWeek, else the amount of days of the previous month included in the week.
         var firstDayInMonth = ( fim || _firstDayOfMonth(date) ),
             diff = firstDayInMonth - plugin.settings.startOfWeek;
         return ( diff === 0 ) ? 7 : (( diff > 0 ) ? diff : ( 7 + diff ));
      }

      function _daysInMonth(date) {
         // [1-31]
         return ( new Date ( date.getFullYear(), date.getMonth() + 1, 0 )).getDate();
      }

      function _daysAfter(date, wim, dim, db) {
         // Returns [0-6] amount of days from the next month
         return    (( wim || _weeksInMonth(date) ) * 7 ) - ( dim || _daysInMonth(date) ) - ( db || _daysBefore(date));
      }

      function _weeksInMonth(date, dim, db) {
         // Returns [5-6];
         return ( plugin.settings.weeksInMonth ) ? plugin.settings.weeksInMonth : Math.ceil( ( ( dim || _daysInMonth(date) ) + ( db || _daysBefore(date)) ) / 7 );
      }

      function addCell($row, date, hidden, selected) {
         var $td = $("").appendTo($row),
             $a = $("")
                  .html(date.getDate().toString())
                  .data('date', date)
                  .click(cellClickHandler)
                  .appendTo($td);

         if ( selected ) $a.click();

         if ( hidden ) {
             $td.addClass("hidden");
         } else {
            var importance = 0;

            // Find events for this date
            for ( var i = 0,
                      event,
                      begin = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0, 0),
                      end = new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1, 0, 0, 0, 0);
                  event = plugin.settings.events[i]; i++ ) {
               if ( event[plugin.settings.end] > begin && event[plugin.settings.begin] < end ) {
                  importance++;
                  if ( importance > 2 ) break;
               }
            }

            if ( importance > 0 ) {
                $a.append("•").addClass("importance-" + importance.toString() );
            }
         }
      }

      function cellClickHandler(event) {
         var $this = $(this),
            date = $this.data('date');
         $tbody.find("a.ui-btn-active").removeClass("ui-btn-active");
         $this.addClass("ui-btn-active");

         if ( date.getMonth() !== plugin.settings.date.getMonth() ) {
            // Go to previous/next month
            refresh(date);
         } else {
            // Select new date
            $element.trigger('change', date);
         }
      }

      function refresh(date) {
         plugin.settings.date = date = date ||  plugin.settings.date || new Date();

         var year = date.getFullYear(),
            month = date.getMonth(),
            daysBefore = _daysBefore(date),
            daysInMonth = _daysInMonth(date),
            weeksInMonth = plugin.settings.weeksInMonth || _weeksInMonth(date, daysInMonth, daysBefore);

         if (((daysInMonth + daysBefore) / 7 ) - weeksInMonth === 0)
             weeksInMonth++;

         // Empty the table body, we start all over...
         $tbody.empty();
         // Change the header to match the current month
         $header.html( plugin.settings.months[month] + " " + year.toString() );

         for (    var   weekIndex = 0,
                  daysInMonthCount = 1,
                  daysAfterCount = 1; weekIndex < weeksInMonth; weekIndex++ ) {

            var daysInWeekCount = 0,
               row = $("
").appendTo($tbody);

            // Previous month
            while ( daysBefore > 0 ) {
               addCell(row, new Date(year, month, 1 - daysBefore), true);
               daysBefore--;
               daysInWeekCount++;
            }

            // Current month
            while ( daysInWeekCount < 7 && daysInMonthCount <= daysInMonth ) {
               addCell(row, new Date(year, month, daysInMonthCount), false, daysInMonthCount === date.getDate() );
               daysInWeekCount++;
               daysInMonthCount++;
            }

            // Next month
            while ( daysInMonthCount > daysInMonth && daysInWeekCount < 7 ) {
               addCell(row, new Date(year, month, daysInMonth + daysAfterCount), true);
               daysInWeekCount++;
               daysAfterCount++;
            }
         }

         $element.trigger('create');
      }

      $element.bind('change', function(event, begin) {
         var end = new Date(begin.getFullYear(), begin.getMonth(), begin.getDate() + 1, 0,0,0,0);
         // Empty the list
         $listview.empty();

         // Find events for this date
         for ( var   i = 0, event; event = plugin.settings.events[i]; i++ ) {
            if ( event[plugin.settings.end] > begin && event[plugin.settings.begin] < end ) {
               // Append matches to list
               var summary    = event[plugin.settings.summary],
                   beginTime  = (( event[plugin.settings.begin] > begin ) ? event[plugin.settings.begin] : begin ).toTimeString().substr(0,5),
                   endTime    = (( event[plugin.settings.end] < end ) ? event[plugin.settings.end] : end ).toTimeString().substr(0,5),
                   timeString = beginTime + "-" + endTime;
               $("
" + ( ( timeString != "00:00-00:00" ) ? timeString : "" ) + " " + summary + "
").appendTo($listview);
            }
         }

         $listview.trigger('create').filter(".ui-listview").listview('refresh');
      });

      $element.bind('refresh', function(event, date) {
         refresh(date);
      });

      init();
   }

   $.fn.jqmCalendar = function(options) {
      return this.each(function() {
         if (!$(this).data('jqmCalendar')) {
             $(this).data('jqmCalendar', new $.jqmCalendar(this, options));
         }
      });
   }

})(jQuery);<|endoftext|>


<commit_before>
// Karma Configuration
// Copyright (C) 2017 Google Inc.
// Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>

module.exports = function (config) {
  var configuration = {

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'src/ggrc/assets/js_specs/spec_setup.js',
      'src/ggrc/static/dashboard-templates.js',
      'src/ggrc/static/dashboard.js',
      'src/ggrc/static/dashboard-spec-helpers.js',
      'src/**/*_spec.js'
    ],

    // list of files to exclude
    exclude: [
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress'],

    junitReporter: {
      outputDir: 'test',
      useBrowserName: false
    },

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: [/* 'PhantomJS' */],

    customLaunchers: {
      Chrome_travis_ci: {
        base: 'Chrome',
        flags: ['--no-sandbox']
      }
    },

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false
  };

  if (process.env.TRAVIS) {
    configuration.browsers = ['Chrome_travis_ci'];
  }

  config.set(configuration);
};
<commit_msg>Enable phantomjs in karma.conf.js<commit_after>
// Karma Configuration
// Copyright (C) 2017 Google Inc.
// Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>

module.exports = function (config) {
  var configuration = {

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'src/ggrc/assets/js_specs/spec_setup.js',
      'src/ggrc/static/dashboard-templates.js',
      'src/ggrc/static/dashboard.js',
      'src/ggrc/static/dashboard-spec-helpers.js',
      'src/**/*_spec.js'
    ],

    // list of files to exclude
    exclude: [
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress'],

    junitReporter: {
      outputDir: 'test',
      useBrowserName: false
    },

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher

    customLaunchers: {
      Chrome_travis_ci: {
        base: 'Chrome',
        flags: ['--no-sandbox']
      }
    },
    browsers: ['PhantomJS'],
    concurrency: 1,

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false
  };

  if (process.env.TRAVIS) {
    configuration.browsers = ['Chrome_travis_ci'];
  }

  config.set(configuration);
};
<|endoftext|>


<commit_before><commit_msg>logging change<commit_after><|endoftext|>


<commit_before>import React from "react";
import {ReactComponent, Table, Tag} from "apparena-patterns-react";

export default class ButtonInput extends ReactComponent {
    render() {
        return (

                    Name
                    Type
                    Description
                    Default
                    Options

                    type
                    oneOf
                    Select the type of the button
                    secondary
                    default, primary, secondary, success, info, warning, danger, link, outline-primary,
                        outline-secondary, outline-success, outline-info, outline-warning, outline-danger

                    size
                    oneOf
                    Select the size of the button
                    undefined
                    lg, sm, xs

                    target
                    oneOf
                    Select a target for the button
                    undefined
                    blank, top, self

                    block
                    boolean
                    Decide if the button should be a block or not
                    undefined

                    rounded
                    boolean
                    Decide if the button should have rounded corners or not
                    undefined

                    href
                    string
                    Give the button a reference
                    undefined

                    isActive
                    boolean
                    Decide if the button should be active or not
                    undefined

                    isDisabled
                    boolean
                    Decide if the button should be disabled or not
                    false

                    onClick
                    function
                    Connects the button to a function
                    undefined

                    submit
                    boolean
                    Decide if the button should submit or not
                    undefined

                    state
                    oneOf
                    Select the state of the button
                    default
                    default, loading, success, error, warning

        );
    }
};<commit_msg>added className to table<commit_after>import React from "react";
import {ReactComponent, Table, Tag} from "apparena-patterns-react";

export default class ButtonInput extends ReactComponent {
    render() {
        return (

                    Name
                    Type
                    Description
                    Default
                    Options

                    className
                    string
                    Give the button a classname
                    undefined

                    type
                    oneOf
                    Select the type of the button
                    secondary
                    default, primary, secondary, success, info, warning, danger, link, outline-primary,
                        outline-secondary, outline-success, outline-info, outline-warning, outline-danger

                    size
                    oneOf
                    Select the size of the button
                    undefined
                    lg, sm, xs

                    target
                    oneOf
                    Select a target for the button
                    undefined
                    blank, top, self

                    block
                    boolean
                    Decide if the button should be a block or not
                    undefined

                    rounded
                    boolean
                    Decide if the button should have rounded corners or not
                    undefined

                    href
                    string
                    Give the button a reference
                    undefined

                    isActive
                    boolean
                    Decide if the button should be active or not
                    undefined

                    isDisabled
                    boolean
                    Decide if the button should be disabled or not
                    false

                    onClick
                    function
                    Connects the button to a function
                    undefined

                    submit
                    boolean
                    Decide if the button should submit or not
                    undefined

                    state
                    oneOf
                    Select the state of the button
                    default
                    default, loading, success, error, warning

        );
    }
};<|endoftext|>


<commit_before>module.exports = function(config) {
  config.set({
    basePath: 'tests/',
    browsers: [
      'PhantomJS'
    ],
    files: [
      '**/*.js'
    ],
    frameworks: ['mocha', 'chai', 'sinon-chai'],
    preprocessors: {
      '**/*.js': ['webpack']
    },
    webpack: {
      module: {
        loaders: [{
          test: /\.jsx$/,
          loader: 'jsx-loader'
        }]
      }
    },
    webpackMiddleware: {
      noInfo: true
    }
  });
};
<commit_msg>Whitelist paths for Karma runner #101<commit_after>module.exports = function(config) {
  config.set({
    basePath: 'tests/',
    browsers: [
      'PhantomJS'
    ],
    files: [
      'bind-polyfill.js',
      'cosmos.js',
      'lib/**/*.js',
      'mixins/**/*.js',
      'components/**/*.js'
    ],
    frameworks: ['mocha', 'chai', 'sinon-chai'],
    preprocessors: {
      '**/*.js': ['webpack']
    },
    webpack: {
      module: {
        loaders: [{
          test: /\.jsx$/,
          loader: 'jsx-loader'
        }]
      }
    },
    webpackMiddleware: {
      noInfo: true
    }
  });
};
<|endoftext|>


<commit_before>'use strict';

module.exports = function(config) {
    var browsers,
        reporters = ['dots'];

    if (process.env.KARMA_BROWSERS) {
        browsers = process.env.KARMA_BROWSERS.split(',');
    }

    config.set({
        frameworks: ['jasmine'],
        browsers: browsers,
        files: [
            'dist/loud.js',
            require.resolve('es5-shim'),
            require.resolve('html5shiv/dist/html5shiv'),
            'test/**/*.js'
        ]
    });

    if (process.env.CI && process.env.SAUCE_ACCESS_KEY) {
        var customLaunchers = {
            sauceLabsEdge: {
                base: 'SauceLabs',
                browserName: 'MicrosoftEdge',
                browserVersion: '18.17763',
                platformName: 'Windows 10'
            },
            sauceLabsSafari: {
                base: 'SauceLabs',
                browserName: 'safari',
                browserVersion: '12.0',
                platformName: 'macOS 10.14'
            },
            sauceLabsIOs: {
                base: 'SauceLabs',
                browserName: 'Safari',
                deviceName: 'iPhone X Simulator',
                platformVersion: '13.0',
                platformName: 'iOS'
            },
            sauceLabsAndroid: {
                base: 'SauceLabs',
                browserName: 'android',
                deviceName: 'Android GoogleAPI Emulator',
                version: '7.1'
            },
            sauceLabsIE8: {
                base: 'SauceLabs',
                browserName: 'internet explorer',
                version: 8
            }
        };

        reporters.push('saucelabs');
        config.set({
            browsers: browsers.concat(Object.keys(customLaunchers)),
            captureTimeout: 120000,
            sauceLabs: {
                testName: 'Loud'
            },
            customLaunchers: customLaunchers
        });
    }

    if (process.env.KARMA_COVERAGE) {
        reporters.push('coverage');
        config.set({
            preprocessors: {
                'dist/loud.js': ['sourcemap'],
                'lib/*.js': ['coverage']
            },
            coverageReporter: {
                type: process.env.KARMA_COVERAGE,
                dir: 'coverage/'
            }
        });
    }

    config.set({
        reporters: reporters
    });
};
<commit_msg>Test in modern Android<commit_after>'use strict';

module.exports = function(config) {
    var browsers,
        reporters = ['dots'];

    if (process.env.KARMA_BROWSERS) {
        browsers = process.env.KARMA_BROWSERS.split(',');
    }

    config.set({
        frameworks: ['jasmine'],
        browsers: browsers,
        files: [
            'dist/loud.js',
            require.resolve('es5-shim'),
            require.resolve('html5shiv/dist/html5shiv'),
            'test/**/*.js'
        ]
    });

    if (process.env.CI && process.env.SAUCE_ACCESS_KEY) {
        var customLaunchers = {
            sauceLabsEdge: {
                base: 'SauceLabs',
                browserName: 'MicrosoftEdge',
                browserVersion: '18.17763',
                platformName: 'Windows 10'
            },
            sauceLabsSafari: {
                base: 'SauceLabs',
                browserName: 'safari',
                browserVersion: '12.0',
                platformName: 'macOS 10.14'
            },
            sauceLabsIOs: {
                base: 'SauceLabs',
                browserName: 'Safari',
                deviceName: 'iPhone X Simulator',
                platformVersion: '13.0',
                platformName: 'iOS'
            },
            sauceLabsAndroid: {
                base: 'SauceLabs',
                browserName: 'Chrome',
                deviceName: 'Android GoogleAPI Emulator',
                platformVersion: '9.0',
                platformName: 'Android'
            },
            sauceLabsIE8: {
                base: 'SauceLabs',
                browserName: 'internet explorer',
                version: 8
            }
        };

        reporters.push('saucelabs');
        config.set({
            browsers: browsers.concat(Object.keys(customLaunchers)),
            captureTimeout: 120000,
            sauceLabs: {
                testName: 'Loud'
            },
            customLaunchers: customLaunchers
        });
    }

    if (process.env.KARMA_COVERAGE) {
        reporters.push('coverage');
        config.set({
            preprocessors: {
                'dist/loud.js': ['sourcemap'],
                'lib/*.js': ['coverage']
            },
            coverageReporter: {
                type: process.env.KARMA_COVERAGE,
                dir: 'coverage/'
            }
        });
    }

    config.set({
        reporters: reporters
    });
};
<|endoftext|>


<commit_before>const _ = require('lodash');
const glob = require('glob');
const { readJsonSync } = require('fs-extra');
const {
  join,
  dirname,
  basename
} = require('path');

const APP_CONTEXT_PATH = process.argv[4] || 'myapplication';

const pluginJsFiles = _(glob.sync('plugins/**/*/cumulocity.json'))
  .flatMap(manifestFile =>
    _.map(readJsonSync(manifestFile).js, jsFile =>
      join(dirname(manifestFile), jsFile)))
  .compact()
  .value();

module.exports = (config) => {
  config.set({

    singleRun: true,

    files: [
      'node_modules/cumulocity-ui-build/core/main.js',
      'node_modules/angular-mocks/angular-mocks.js',
      'node_modules/sinon/pkg/sinon.js',
      'node_modules/tentacle.js/dist/tentacle.js',
      'test-helper.js',
      ...pluginJsFiles,
      'plugins/**/*.spec.js',
      'plugins/**/*.html'
    ],

    frameworks: ['jasmine'],

    browsers: ['PhantomJS'],

    plugins: [
      'karma-jasmine',
      'karma-phantomjs-launcher',
      'karma-spec-reporter',
      'karma-ng-html2js-preprocessor',
      { 'preprocessor:c8y-pluginpath': ['factory', c8yPluginPathPreprocessor] }
    ],

    preprocessors: {
      'plugins/{**/,}*.js': ['c8y-pluginpath'],
      'plugins/**/*.html': ['ng-html2js']
    },

    reporters: ['spec'],
    specReporter: {
      maxLogLines: 5,         // limit number of lines logged per test
      suppressErrorSummary: true,  // do not print error summary
      suppressFailed: false,  // do not print information about failed tests
      suppressPassed: false,  // do not print information about passed tests
      suppressSkipped: false,  // do not print information about skipped tests
      showSpecTiming: false // print the time elapsed for each spec
    },

    ngHtml2JsPreprocessor: {
      cacheIdFromPath: filepath => join(computePluginPath(filepath), basename(filepath)),
      moduleName: 'c8yHtml.test'
    },

    logLevel: config.LOG_ERROR,

    client: {
      captureConsole: false
    }
  });
};

function c8yPluginPathPreprocessor() {
  return (content, file, done) => {
    done(content.replace(/:::PLUGIN_PATH:::/g, computePluginPath(file.originalPath)));
  };
}

function computePluginPath(filepath) {
  const pluginName = (/plugins\/(.+?)\/+?/.exec(filepath))[1];
  //const pluginPath = `${APP_CONTEXT_PATH}_${pluginName}`;
  const pluginPath = pluginName;

  return pluginPath;
}
<commit_msg>chore(karma conf): simplify glob of preprocessors a bit<commit_after>const _ = require('lodash');
const glob = require('glob');
const { readJsonSync } = require('fs-extra');
const {
  join,
  dirname,
  basename
} = require('path');

const APP_CONTEXT_PATH = process.argv[4] || 'myapplication';

const pluginJsFiles = _(glob.sync('plugins/**/*/cumulocity.json'))
  .flatMap(manifestFile =>
    _.map(readJsonSync(manifestFile).js, jsFile =>
      join(dirname(manifestFile), jsFile)))
  .compact()
  .value();

module.exports = (config) => {
  config.set({

    singleRun: true,

    files: [
      'node_modules/cumulocity-ui-build/core/main.js',
      'node_modules/angular-mocks/angular-mocks.js',
      'node_modules/sinon/pkg/sinon.js',
      'node_modules/tentacle.js/dist/tentacle.js',
      'test-helper.js',
      ...pluginJsFiles,
      'plugins/**/*.spec.js',
      'plugins/**/*.html'
    ],

    frameworks: ['jasmine'],

    browsers: ['PhantomJS'],

    plugins: [
      'karma-jasmine',
      'karma-phantomjs-launcher',
      'karma-spec-reporter',
      'karma-ng-html2js-preprocessor',
      { 'preprocessor:c8y-pluginpath': ['factory', c8yPluginPathPreprocessor] }
    ],

    preprocessors: {
      'plugins/**/*.js': ['c8y-pluginpath'],
      'plugins/**/*.html': ['ng-html2js']
    },

    reporters: ['spec'],
    specReporter: {
      maxLogLines: 5,         // limit number of lines logged per test
      suppressErrorSummary: true,  // do not print error summary
      suppressFailed: false,  // do not print information about failed tests
      suppressPassed: false,  // do not print information about passed tests
      suppressSkipped: false,  // do not print information about skipped tests
      showSpecTiming: false // print the time elapsed for each spec
    },

    ngHtml2JsPreprocessor: {
      cacheIdFromPath: filepath => join(computePluginPath(filepath), basename(filepath)),
      moduleName: 'c8yHtml.test'
    },

    logLevel: config.LOG_ERROR,

    client: {
      captureConsole: false
    }
  });
};

function c8yPluginPathPreprocessor() {
  return (content, file, done) => {
    done(content.replace(/:::PLUGIN_PATH:::/g, computePluginPath(file.originalPath)));
  };
}

function computePluginPath(filepath) {
  const pluginName = (/plugins\/(.+?)\/+?/.exec(filepath))[1];
  //const pluginPath = `${APP_CONTEXT_PATH}_${pluginName}`;
  const pluginPath = pluginName;

  return pluginPath;
}
<|endoftext|>


<commit_before>'use babel';
import {basename, dirname} from 'path';
import {CompositeDisposable} from 'atom';
import makeTreeViewGitBranchList from './tree-view-git-branch-list.js';
import {addEventListener} from './utils.js';

var repositoryProto = {
  initialize(repository, treeViewEl) {
    this.repository = repository;
    this.projectRoot = this.getProjectRoot(treeViewEl);
    this.branches = makeTreeViewGitBranchList({
      repository: repository,
      icon: 'git-branch',
      title: `branches [${basename(dirname(repository.getPath()))}]`,
    });

    this.update(treeViewEl);
  },

  destroy() {
    this.branches.destroy();
    if (this.disposables) {
      this.disposables.dispose();
    }
    [this.branches, this.disposables,
      this.repository, this.projectRoot] = [];
  },

  update(treeViewEl) {
    switch (atom.config.get('tree-view-git-branch.location')) {
    case 'top':
      this.insertBefore(this.getFirstProjectRoot(treeViewEl));
      if (this.disposables) {
        this.disposables.dispose();
        this.disposables = null;
      }
      break;
    case 'before':
      this.insertBefore(this.projectRoot);
      if (this.disposables) {
        this.disposables.dispose();
        this.disposables = null;
      }
      break;
    case 'inside':
      this.insertBefore(this.getFirstDirectoryEl());

      if (!this.disposables) {
        this.disposables = new CompositeDisposable(
          addEventListener(this.projectRoot, 'click', event => {
            if (event.target.closest('li') != this.projectRoot) {
              return;
            }

            process.nextTick(() => {
              if (!this.projectRoot.classList.contains('collapsed')) {
                this.insertBefore(this.getFirstDirectoryEl());
              }
            });
          }),

          atom.commands.add(treeViewEl, {
            'tree-view:expand-item': () => {
              this.insertBefore(this.getFirstDirectoryEl());
            },
            'tree-view:expand-recursive-directory': () => {
              this.insertBefore(this.getFirstDirectoryEl());
            },
          })
        );
      }
      break;
    }

    this.branches.setEntries(this.repository.getReferences().heads);
  },

  getProjectRoot(treeViewEl) {
    let projectPath = dirname(this.repository.getPath());
    return treeViewEl.querySelector(
      `[data-path^="${projectPath.replace(/\\/g, '\\\\')}"]`
    ).closest('.project-root');
  },

  getFirstProjectRoot(treeViewEl) {
    return treeViewEl.querySelector('.project-root');
  },

  getFirstDirectoryEl() {
    return this.projectRoot.querySelector('[is="tree-view-directory"]');
  },

  setSeparator(show) {
    var addOrRemove = show && atom.config.get('tree-view-git-branch.separator') ? 'add' : 'remove';
    switch (atom.config.get('tree-view-git-branch.location')) {
    case 'top':
      this.branches.classList.remove('separator');
      this.projectRoot.classList.remove('separator');
      break;
    case 'before':
      this.branches.classList[addOrRemove]('separator');
      this.projectRoot.classList.remove('separator');
      break;
    case 'inside':
      this.projectRoot.classList[addOrRemove]('separator');
      this.branches.classList.remove('separator');
      break;
    }
  },

  insertBefore(el) {
    el.parentNode.insertBefore(this.branches, el);
  },
};

export default function makeTreeViewGitRepository(...args) {
  var obj = Object.create(repositoryProto);
  obj.initialize(...args);
  return obj;
}
<commit_msg>subscribe to repository change events<commit_after>'use babel';
import {basename, dirname} from 'path';
import {CompositeDisposable} from 'atom';
import makeTreeViewGitBranchList from './tree-view-git-branch-list.js';
import {addEventListener} from './utils.js';

var repositoryProto = {
  initialize(repository, treeViewEl) {
    this.repository = repository;
    this.projectRoot = this.getProjectRoot(treeViewEl);
    this.branches = makeTreeViewGitBranchList({
      repository: repository,
      icon: 'git-branch',
      title: `branches [${basename(dirname(repository.getPath()))}]`,
    });

    this.update(treeViewEl);

    this.disposables = new CompositeDisposable(
      addEventListener(this.projectRoot, 'click', event => {
        if (event.target.closest('li') == this.projectRoot) {
          this.updateLocation(treeViewEl);
        }
      }),

      atom.commands.add(treeViewEl, {
        'tree-view:expand-item': () => {
          this.updateLocation(treeViewEl);
        },
        'tree-view:expand-recursive-directory': () => {
          this.updateLocation(treeViewEl);
        },
      }),

      repository.onDidChangeStatus(() => {
        this.update(treeViewEl);
      }),

      repository.onDidChangeStatuses(() => {
        this.update(treeViewEl);
      })
    );
  },

  destroy() {
    this.branches.destroy();
    this.disposables.dispose();
    [this.branches, this.disposables,
      this.repository, this.projectRoot] = [];
  },

  update(treeViewEl) {
    var entries = this.repository.getReferences().heads;
    this.branches.setEntries(entries);
    this.updateLocation(treeViewEl);
  },

  getProjectRoot(treeViewEl) {
    let projectPath = dirname(this.repository.getPath());
    return treeViewEl.querySelector(
      `[data-path^="${projectPath.replace(/\\/g, '\\\\')}"]`
    ).closest('.project-root');
  },

  getFirstProjectRoot(treeViewEl) {
    return treeViewEl.querySelector('.project-root');
  },

  getFirstDirectoryEl() {
    return this.projectRoot.querySelector('[is="tree-view-directory"]');
  },

  insertBefore(el) {
    el.parentNode.insertBefore(this.branches, el);
  },

  updateLocation(treeViewEl) {
    switch (atom.config.get('tree-view-git-branch.location')) {
    case 'top':
      this.insertBefore(this.getFirstProjectRoot(treeViewEl));
      break;
    case 'before':
      this.insertBefore(this.projectRoot);
      break;
    case 'inside':
      this.insertBefore(this.getFirstDirectoryEl());
      break;
    }
  },

  setSeparator(show) {
    var addOrRemove = show && atom.config.get('tree-view-git-branch.separator') ? 'add' : 'remove';
    switch (atom.config.get('tree-view-git-branch.location')) {
    case 'top':
      this.branches.classList.remove('separator');
      this.projectRoot.classList.remove('separator');
      break;
    case 'before':
      this.branches.classList[addOrRemove]('separator');
      this.projectRoot.classList.remove('separator');
      break;
    case 'inside':
      this.projectRoot.classList[addOrRemove]('separator');
      this.branches.classList.remove('separator');
      break;
    }
  },
};

export default function makeTreeViewGitRepository(...args) {
  var obj = Object.create(repositoryProto);
  obj.initialize(...args);
  return obj;
}
<|endoftext|>


<commit_before>module.exports = function(karma) {
  karma.set({
    plugins: [
      'karma-browserify',
      'karma-jasmine',
      'karma-phantomjs-launcher'
    ],

    frameworks: ['browserify', 'jasmine'],

    reporters: ['progress'],

    files: [
      'src/**/*.js',
      'test/**/*.js',
      './node_modules/phantomjs-polyfill/bind-polyfill.js'
    ],

    preprocessors: {
      'src/**/*.js' : ['browserify'],
      'test/**/*.test.js': ['browserify']
    },

    browserify: {
      debug: true,
      transform: ['babelify']
    },

    browsers: ['PhantomJS']
  });
};
<commit_msg>Update karma config<commit_after>module.exports = function(karma) {
  karma.set({
    plugins: [
      'karma-browserify',
      'karma-jasmine',
      'karma-phantomjs-launcher'
    ],

    frameworks: ['browserify', 'jasmine'],

    reporters: ['progress'],

    files: [
      'src/**/*.js',
      'test/**/*.js',
      './node_modules/phantomjs-polyfill/bind-polyfill.js'
    ],

    preprocessors: {
      'src/**/*.js' : ['browserify'],
      'test/**/*.test.js': ['browserify']
    },

    browserify: {
      debug: true,
      transform: [
        ['babelify', { presets: ['es2015'] }]
      ]
    },

    browsers: ['PhantomJS']
  });
};
<|endoftext|>


<commit_before>const webpack = require('webpack')
const path = require('path')
const resolve = pkg => path.join(__dirname, './packages', pkg, 'src')
const coverage = String(process.env.COVERAGE) !== 'false'
const ci = String(process.env.CI).match(/^(1|true)$/gi)
const realBrowser = String(process.env.BROWSER).match(/^(1|true)$/gi)
const sauceLabs = realBrowser && ci
const sauceLabsLaunchers = {
  sl_win_chrome: {
    base: 'SauceLabs',
    browserName: 'chrome',
    platform: 'Windows 10'
  },
  sl_mac_chrome: {
    base: 'SauceLabs',
    browserName: 'chrome',
    platform: 'macOS 10.12'
  },
  sl_firefox: {
    base: 'SauceLabs',
    browserName: 'firefox',
    platform: 'Windows 10'
  },
  sl_mac_firfox: {
    base: 'SauceLabs',
    browserName: 'firefox',
    platform: 'macOS 10.12'
  },
  sl_safari: {
    base: 'SauceLabs',
    browserName: 'safari',
    platform: 'macOS 10.12'
  },
  sl_edge: {
    base: 'SauceLabs',
    browserName: 'MicrosoftEdge',
    platform: 'Windows 10'
  },
  sl_ie_11: {
    base: 'SauceLabs',
    browserName: 'internet explorer',
    version: '11.103',
    platform: 'Windows 10'
  },
  sl_ie_10: {
    base: 'SauceLabs',
    browserName: 'internet explorer',
    version: '10.0',
    platform: 'Windows 7'
  },
  sl_ie_9: {
    base: 'SauceLabs',
    browserName: 'internet explorer',
    version: '9.0',
    platform: 'Windows 7'
  },
  sl_ie_8: {
    base: 'SauceLabs',
    browserName: 'internet explorer',
    version: '8.0',
    platform: 'Windows 7'
  }
}

const travisLaunchers = {
  chrome_travis: {
    base: 'Chrome',
    flags: ['--no-sandbox']
  }
}

const localBrowsers = realBrowser ? Object.keys(travisLaunchers) : ['Chrome']

module.exports = function (config) {
  config.set({
    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '.',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine', 'jasmine-matchers'],

    // list of files / patterns to load in the browser
    files: [
      'browsers/karma.js',
      './node_modules/es5-polyfill/dist/polyfill.js',
      // 'browsers/ie8.js',
      // 'browsers/polyfill.js',
      'packages/nerv/__tests__/event.spec.js',
      'packages/*/__tests__/**/*spec.js?(x)'
    ],

    specReporter: {
      suppressFailed: false, // do not print information about failed tests
      suppressPassed: true, // do not print information about passed tests
      suppressSkipped: false // do not print information about skipped tests
    },

    // list of files to exclude
    exclude: [],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      'packages/*/__tests__/**/*spec.js?(x)': ['webpack', 'sourcemap']
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['spec'].concat(
      coverage ? [] : [],
      sauceLabs ? 'saucelabs' : []
    ),

    mochaReporter: {
      showDiff: true
    },

    browserLogOptions: { terminal: true },
    browserConsoleLogOptions: { terminal: true },

    browserNoActivityTimeout: 5 * 60 * 1000,
    browserDisconnectTimeout: 15 * 1000,
    browserDisconnectTolerance: 2,

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: sauceLabs ? Object.keys(sauceLabsLaunchers) : localBrowsers,

    customLaunchers: sauceLabs ? sauceLabsLaunchers : travisLaunchers,

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: 2,

    webpack: {
      devtool: 'inline-source-map',
      resolve: {
        alias: {
          nervjs: resolve('nerv'),
          'nerv-devtools': resolve('nerv-devtools'),
          'nerv-shared': resolve('nerv-shared'),
          'nerv-utils': resolve('nerv-utils'),
          'nerv-server': resolve('nerv-server'),
          'nerv-redux': resolve('nerv-redux')
        },
        extensions: ['.js', '.jsx', '.ts', '.tsx'],
        mainFields: ['main', 'module']
      },
      module: {
        rules: [
          {
            enforce: 'pre',
            test: /\.js$/,
            loader: 'babel-loader',
            exclude: /node_modules/
          },
          {
            test: /\.ts$/,
            loader: 'ts-loader',
            options: {
              transpileOnly: true,
              compilerOptions: {
                target: 'es3',
                module: 'commonjs'
              }
            }
          },
          {
            enforce: 'post',
            test: /.js$/,
            loader: 'es3ify-loader'
          }
        ]
      },
      plugins: [
        new webpack.DefinePlugin({
          coverage: coverage,
          NODE_ENV: JSON.stringify(process.env.NODE_ENV || ''),
          DISABLE_FLAKEY: !!String(process.env.FLAKEY).match(/^(0|false)$/gi)
        })
      ]
    },
    stats: 'errors-only',
    webpackMiddleware: {
      noInfo: true,
      stats: {
        errorDetails: true
      }
    }
  })
}
<commit_msg>test: use promise in karma config<commit_after>const webpack = require('webpack')
const path = require('path')
const resolve = pkg => path.join(__dirname, './packages', pkg, 'src')
const coverage = String(process.env.COVERAGE) !== 'false'
const ci = String(process.env.CI).match(/^(1|true)$/gi)
const realBrowser = String(process.env.BROWSER).match(/^(1|true)$/gi)
const sauceLabs = realBrowser && ci
const sauceLabsLaunchers = {
  sl_win_chrome: {
    base: 'SauceLabs',
    browserName: 'chrome',
    platform: 'Windows 10'
  },
  sl_mac_chrome: {
    base: 'SauceLabs',
    browserName: 'chrome',
    platform: 'macOS 10.12'
  },
  sl_firefox: {
    base: 'SauceLabs',
    browserName: 'firefox',
    platform: 'Windows 10'
  },
  sl_mac_firfox: {
    base: 'SauceLabs',
    browserName: 'firefox',
    platform: 'macOS 10.12'
  },
  sl_safari: {
    base: 'SauceLabs',
    browserName: 'safari',
    platform: 'macOS 10.12'
  },
  sl_edge: {
    base: 'SauceLabs',
    browserName: 'MicrosoftEdge',
    platform: 'Windows 10'
  },
  sl_ie_11: {
    base: 'SauceLabs',
    browserName: 'internet explorer',
    version: '11.103',
    platform: 'Windows 10'
  },
  sl_ie_10: {
    base: 'SauceLabs',
    browserName: 'internet explorer',
    version: '10.0',
    platform: 'Windows 7'
  },
  sl_ie_9: {
    base: 'SauceLabs',
    browserName: 'internet explorer',
    version: '9.0',
    platform: 'Windows 7'
  },
  sl_ie_8: {
    base: 'SauceLabs',
    browserName: 'internet explorer',
    version: '8.0',
    platform: 'Windows 7'
  }
}

const travisLaunchers = {
  chrome_travis: {
    base: 'Chrome',
    flags: ['--no-sandbox']
  }
}

const localBrowsers = realBrowser ? Object.keys(travisLaunchers) : ['Chrome']

module.exports = function (config) {
  config.set({
    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '.',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine', 'jasmine-matchers'],

    // list of files / patterns to load in the browser
    files: [
      'browsers/karma.js',
      './node_modules/es6-promise/dist/es6-promise.auto.min.js',
      './node_modules/es5-polyfill/dist/polyfill.js',
      'browsers/ie8.js',
      'browsers/polyfill.js',
      'packages/nerv/__tests__/event.spec.js',
      'packages/*/__tests__/**/*spec.js?(x)'
    ],

    specReporter: {
      suppressFailed: false, // do not print information about failed tests
      suppressPassed: true, // do not print information about passed tests
      suppressSkipped: false // do not print information about skipped tests
    },

    // list of files to exclude
    exclude: [],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      'packages/*/__tests__/**/*spec.js?(x)': ['webpack', 'sourcemap']
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['spec'].concat(
      coverage ? [] : [],
      sauceLabs ? 'saucelabs' : []
    ),

    mochaReporter: {
      showDiff: true
    },

    browserLogOptions: { terminal: true },
    browserConsoleLogOptions: { terminal: true },

    browserNoActivityTimeout: 5 * 60 * 1000,
    browserDisconnectTimeout: 15 * 1000,
    browserDisconnectTolerance: 2,

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: sauceLabs ? Object.keys(sauceLabsLaunchers) : localBrowsers,

    customLaunchers: sauceLabs ? sauceLabsLaunchers : travisLaunchers,

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: 2,

    webpack: {
      devtool: 'inline-source-map',
      resolve: {
        alias: {
          nervjs: resolve('nerv'),
          'nerv-devtools': resolve('nerv-devtools'),
          'nerv-shared': resolve('nerv-shared'),
          'nerv-utils': resolve('nerv-utils'),
          'nerv-server': resolve('nerv-server'),
          'nerv-redux': resolve('nerv-redux')
        },
        extensions: ['.js', '.jsx', '.ts', '.tsx'],
        mainFields: ['main', 'module']
      },
      module: {
        rules: [
          {
            enforce: 'pre',
            test: /\.js$/,
            loader: 'babel-loader',
            exclude: /node_modules/
          },
          {
            test: /\.ts$/,
            loader: 'ts-loader',
            options: {
              transpileOnly: true,
              compilerOptions: {
                target: 'es3',
                module: 'commonjs'
              }
            }
          },
          {
            enforce: 'post',
            test: /.js$/,
            loader: 'es3ify-loader'
          }
        ]
      },
      plugins: [
        new webpack.DefinePlugin({
          coverage: coverage,
          NODE_ENV: JSON.stringify(process.env.NODE_ENV || ''),
          DISABLE_FLAKEY: !!String(process.env.FLAKEY).match(/^(0|false)$/gi)
        })
      ]
    },
    stats: 'errors-only',
    webpackMiddleware: {
      noInfo: true,
      stats: {
        errorDetails: true
      }
    }
  })
}
<|endoftext|>


<commit_before>// Karma configuration
// Generated on Fri Feb 06 2015 12:01:05 GMT-0600 (CST)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['mocha', 'chai'],

    // list of files / patterns to load in the browser
    files: [
      'public/js/**/*.js',
      'test/spec/**/*.test.js',
      'bower_components/jquery/dist/jquery.min.js',
      'bower_components/async/lib/async.js',
      'bower_components/lodash/lodash.min.js'
    ],

    // list of files to exclude
    exclude: [
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      '**/*.html': ['html2js']
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress'],

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['PhantomJS'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false
  });
};
<commit_msg>remove html2js<commit_after>// Karma configuration
// Generated on Fri Feb 06 2015 12:01:05 GMT-0600 (CST)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['mocha', 'chai'],

    // list of files / patterns to load in the browser
    files: [
      'public/js/**/*.js',
      'test/spec/**/*.test.js',
      'bower_components/jquery/dist/jquery.min.js',
      'bower_components/async/lib/async.js',
      'bower_components/lodash/lodash.min.js'
    ],

    // list of files to exclude
    exclude: [
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress'],

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['PhantomJS'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false
  });
};
<|endoftext|>


<commit_before>module.exports = (config) => {
	config.set({
		urlRoot: '/',
		frameworks: ['jasmine'],
		port: 3002,
		logLevel: config.LOG_INFO,
		reporters: ['dots'],
		browsers: [
			'PhantomJS'
		],
		files: [
			'./build/static/js/polyfill.js',
			'./build/static/js/shim.js',
			'./build/static/js/vendor.client.test.js',
			'./build/static/js/ima.client.js',
			'./build/static/js/locale/cs.js',
			'./build/static/js/app.client.js',
			'./build/static/js/ima.runner.js',
			'./app/**/*Spec.{js,jsx}'
		],
		preprocessors: {
			'./app/**/*Spec.jsx': ['babel']
		//	'./node_modules/ima/**/__tests__/*Spec.js': ['babel']
		},
		babelPreprocessor: {
			options: {
				presets: ['react'],
				sourceMap: 'inline'
			},
			filename: file => file.originalPath.replace(/\.jsx$/, '.js'),
			sourceFileName: file => file.originalPath
		},
		customLaunchers: {
			Chrome_without_security: {
				base: 'Chrome',
				flags: ['--disable-web-security']
			}
		},
		plugins: [
			'karma-phantomjs-launcher',
			'karma-babel-preprocessor',
			'karma-jasmine'
			//'karma-coverage'
		],
		phantomjsLauncher: {
			exitOnResourceError: true
		},
		autoWatch: true,
		singleRun: false,
		colors: true
	});
};
<commit_msg>#! remove ima.client.js file because IMA is contained in vendors<commit_after>module.exports = (config) => {
	config.set({
		urlRoot: '/',
		frameworks: ['jasmine'],
		port: 3002,
		logLevel: config.LOG_INFO,
		reporters: ['dots'],
		browsers: [
			'PhantomJS'
		],
		files: [
			'./build/static/js/polyfill.js',
			'./build/static/js/shim.js',
			'./build/static/js/vendor.client.test.js',
			'./build/static/js/locale/cs.js',
			'./build/static/js/app.client.js',
			'./build/static/js/ima.runner.js',
			'./app/**/*Spec.{js,jsx}'
		],
		preprocessors: {
			'./app/**/*Spec.jsx': ['babel']
		//	'./node_modules/ima/**/__tests__/*Spec.js': ['babel']
		},
		babelPreprocessor: {
			options: {
				presets: ['react'],
				sourceMap: 'inline'
			},
			filename: file => file.originalPath.replace(/\.jsx$/, '.js'),
			sourceFileName: file => file.originalPath
		},
		customLaunchers: {
			Chrome_without_security: {
				base: 'Chrome',
				flags: ['--disable-web-security']
			}
		},
		plugins: [
			'karma-phantomjs-launcher',
			'karma-babel-preprocessor',
			'karma-jasmine'
			//'karma-coverage'
		],
		phantomjsLauncher: {
			exitOnResourceError: true
		},
		autoWatch: true,
		singleRun: false,
		colors: true
	});
};
<|endoftext|>


<commit_before>// Karma configuration
// Generated on Tue May 12 2015 08:48:14 GMT+1000 (AEST)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'easy-date.js',
      'test/**/*Spec.js'
    ],

    // list of files to exclude
    exclude: [
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress'],

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['PhantomJS'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: true
  });
};
<commit_msg>make sure karma will only execute browser tests<commit_after>// Karma configuration
// Generated on Tue May 12 2015 08:48:14 GMT+1000 (AEST)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'easy-date.js',
      'test/*Spec.js'
    ],

    // list of files to exclude
    exclude: [
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress'],

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['PhantomJS'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: true
  });
};
<|endoftext|>


<commit_before>/*
 * Copyright (c) 2010 Kevin Decker (http://www.incaseofstairs.com/)
 * See LICENSE for license information
 */
// TODO : Optimize output
$(document).ready(function() {
    var pathToImage = $("#pathToImage"),
        editorEl = $("#editorEl"),
        imageEl = $("#imageEl"),
        dividers = $(".divider"),
        sliders = $(".slider"),

        state = {
            src: "http://www.css3.info/wp-content/uploads/2007/09/border.png",
            linkBorder: true,
            borderWidth: [0, 0, 0, 0],
            imageOffset: [0, 0, 0, 0],
            scaleFactor: 3
        };

    var sliderMap = {
        imageTop: { array: "imageOffset", index: 0 },
        imageRight: { array: "imageOffset", index: 1 },
        imageBottom: { array: "imageOffset", index: 2 },
        imageLeft: { array: "imageOffset", index: 3 },

        borderTop: { array: "borderWidth", index: 0 },
        borderRight: { array: "borderWidth", index: 1 },
        borderBottom: { array: "borderWidth", index: 2 },
        borderLeft: { array: "borderWidth", index: 3 },
    }, dividerMap = {
        dividerTop: {
            setValue: function(el) { state.imageOffset[0] = calcPixels($(el).position().top) },
            updatePos: function(el) { $(el).css("top", state.imageOffset[0]*state.scaleFactor); }
        },
        dividerRight: {
            setValue: function(el) { state.imageOffset[1] = calcPixels(editorEl.innerWidth() - $(el).position().left + 2) },
            updatePos: function(el) { $(el).css("left", (editorEl.innerWidth() - 2 - state.imageOffset[1]*state.scaleFactor)); }
        },
        dividerBottom: {
            setValue: function(el) { state.imageOffset[2] = calcPixels(editorEl.innerHeight() - $(el).position().top + 2) },
            updatePos: function(el) { $(el).css("top", (editorEl.innerHeight() - 2 - state.imageOffset[2]*state.scaleFactor)); }
        },
        dividerLeft: {
            setValue: function(el) { state.imageOffset[3] = calcPixels($(el).position().left) },
            updatePos: function(el) { $(el).css("left", state.imageOffset[3]*state.scaleFactor); }
        },
    }

    function calcPixels(pos) {
        return (pos / state.scaleFactor) | 0;
    }
    function updateSliders() {
        $(".slider").each(function(index, el) {
            var map = sliderMap[el.id];
            $(el).slider("option", "value", state[map.array][map.index]);
        });
    }
    function updateDividers() {
        dividers.each(function(index, el) {
            dividerMap[el.id].updatePos(el);
        });
    }
    function updateHash() {
        HistoryHandler.store(JSON.stringify(state));
    }
    function updateCSS() {
        var img = "url(" + pathToImage.val() + ")",
            imageOffset = state.imageOffset,
            borderWidth = state.linkBorder ? state.imageOffset : state.borderWidth,
            borderImage = img + " " + imageOffset.join(" "),
            borderWidthStr = borderWidth.join("px ") + "px",
            style = "border-width: " + borderWidthStr + ";\n"
                + "-moz-border-image: " + borderImage + ";\n"
                + "-webkit-border-image: " + borderImage + ";\n"
                + "border-image: " + borderImage + ";";

        $("#cssEl").html(style)
                .css("border-width", borderWidthStr)
                .css("-moz-border-image", borderImage)
                .css("-webkit-border-image", borderImage)
                .css("border-image", borderImage);
    }

    sliders.slider({
        max: 100,
        slide: function(event, ui) {
            var map = sliderMap[event.target.id];
            state[map.array][map.index] = ui.value;

            updateCSS();
            updateDividers();
        },
        stop: function() {
            updateHash();
        }
    });
    dividers.draggable({
        containment: "parent",
        drag: function(event, ui) {
            dividerMap[event.target.id].setValue(event.target);
            updateCSS();
            updateSliders();
        },
        stop: function() {
            updateHash();
        }
    });
    dividers.filter(":even").draggable("option", "axis", "y");
    dividers.filter(":odd").draggable("option", "axis", "x");

    imageEl.load(function() {
        var img = this,
            width = img.naturalWidth*state.scaleFactor,
            height = img.naturalHeight*state.scaleFactor;

        // Correct for any HTTP escaping issues in the input
        state.src = img.src;

        editorEl.width(width).height(height);

        sliders.filter(":odd").slider("option", "max", img.naturalWidth);
        sliders.filter(":even").slider("option", "max", img.naturalHeight);
        updateSliders();
        updateDividers();
        updateCSS();
        updateHash();
    })
    pathToImage.change(function(event) {
        state.src = pathToImage.val();
        imageEl[0].src = state.src;
    });

    $("#borderOptionsExpander").toggle(
        function() {
            $("#borderOptionsExpander > span").removeClass("ui-icon-triangle-1-e").addClass("ui-icon-triangle-1-s");
            $("#borderOptions").show();
            state.linkBorder = false;
            updateCSS();
            updateHash();
        },
        function() {
            $("#borderOptionsExpander > span").removeClass("ui-icon-triangle-1-s").addClass("ui-icon-triangle-1-e");
            $("#borderOptions").hide();
            state.linkBorder = true;
            updateCSS();
            updateHash();
        });
    editorEl.resizable({
        reverseXAxis: true,
        handles: "s, w, sw",
        aspectRatio: true,
        resize: function() {
            state.scaleFactor = editorEl.innerWidth() / imageEl[0].naturalWidth;

            updateSliders();
            updateDividers();
            updateCSS();
        },
        stop: function() {
            updateHash();
        }
    });

    HistoryHandler.init(function(hash) {
        var prevScale = state.scaleFactor;

        if (hash) {
            state = JSON.parse(hash);
        }
        if ($("#borderOptions").is(":visible") === state.linkBorder) {
            $("#borderOptionsExpander").click();
        }

        if (imageEl[0].src !== state.src) {
            // The other values will update when the image loads
            pathToImage.val(state.src);
            pathToImage.change();
        } else if (prevScale !== state.scaleFactor) {
            imageEl.load();
        } else {
            updateSliders();
            updateDividers();
            updateCSS();
        }
    });
});
<commit_msg>Remove default image<commit_after>/*
 * Copyright (c) 2010 Kevin Decker (http://www.incaseofstairs.com/)
 * See LICENSE for license information
 */
// TODO : Optimize output
$(document).ready(function() {
    var pathToImage = $("#pathToImage"),
        editorEl = $("#editorEl"),
        imageEl = $("#imageEl"),
        dividers = $(".divider"),
        sliders = $(".slider"),

        state = {
            src: "",
            linkBorder: true,
            borderWidth: [0, 0, 0, 0],
            imageOffset: [0, 0, 0, 0],
            scaleFactor: 3
        };

    var sliderMap = {
        imageTop: { array: "imageOffset", index: 0 },
        imageRight: { array: "imageOffset", index: 1 },
        imageBottom: { array: "imageOffset", index: 2 },
        imageLeft: { array: "imageOffset", index: 3 },

        borderTop: { array: "borderWidth", index: 0 },
        borderRight: { array: "borderWidth", index: 1 },
        borderBottom: { array: "borderWidth", index: 2 },
        borderLeft: { array: "borderWidth", index: 3 },
    }, dividerMap = {
        dividerTop: {
            setValue: function(el) { state.imageOffset[0] = calcPixels($(el).position().top) },
            updatePos: function(el) { $(el).css("top", state.imageOffset[0]*state.scaleFactor); }
        },
        dividerRight: {
            setValue: function(el) { state.imageOffset[1] = calcPixels(editorEl.innerWidth() - $(el).position().left + 2) },
            updatePos: function(el) { $(el).css("left", (editorEl.innerWidth() - 2 - state.imageOffset[1]*state.scaleFactor)); }
        },
        dividerBottom: {
            setValue: function(el) { state.imageOffset[2] = calcPixels(editorEl.innerHeight() - $(el).position().top + 2) },
            updatePos: function(el) { $(el).css("top", (editorEl.innerHeight() - 2 - state.imageOffset[2]*state.scaleFactor)); }
        },
        dividerLeft: {
            setValue: function(el) { state.imageOffset[3] = calcPixels($(el).position().left) },
            updatePos: function(el) { $(el).css("left", state.imageOffset[3]*state.scaleFactor); }
        },
    }

    function calcPixels(pos) {
        return (pos / state.scaleFactor) | 0;
    }
    function updateSliders() {
        $(".slider").each(function(index, el) {
            var map = sliderMap[el.id];
            $(el).slider("option", "value", state[map.array][map.index]);
        });
    }
    function updateDividers() {
        dividers.each(function(index, el) {
            dividerMap[el.id].updatePos(el);
        });
    }
    function updateHash() {
        HistoryHandler.store(JSON.stringify(state));
    }
    function updateCSS() {
        var img = "url(" + pathToImage.val() + ")",
            imageOffset = state.imageOffset,
            borderWidth = state.linkBorder ? state.imageOffset : state.borderWidth,
            borderImage = img + " " + imageOffset.join(" "),
            borderWidthStr = borderWidth.join("px ") + "px",
            style = "border-width: " + borderWidthStr + ";\n"
                + "-moz-border-image: " + borderImage + ";\n"
                + "-webkit-border-image: " + borderImage + ";\n"
                + "border-image: " + borderImage + ";";

        $("#cssEl").html(style)
                .css("border-width", borderWidthStr)
                .css("-moz-border-image", borderImage)
                .css("-webkit-border-image", borderImage)
                .css("border-image", borderImage);
    }

    sliders.slider({
        max: 100,
        slide: function(event, ui) {
            var map = sliderMap[event.target.id];
            state[map.array][map.index] = ui.value;

            updateCSS();
            updateDividers();
        },
        stop: function() {
            updateHash();
        }
    });
    dividers.draggable({
        containment: "parent",
        drag: function(event, ui) {
            dividerMap[event.target.id].setValue(event.target);
            updateCSS();
            updateSliders();
        },
        stop: function() {
            updateHash();
        }
    });
    dividers.filter(":even").draggable("option", "axis", "y");
    dividers.filter(":odd").draggable("option", "axis", "x");

    imageEl.load(function() {
        var img = this,
            width = img.naturalWidth*state.scaleFactor,
            height = img.naturalHeight*state.scaleFactor;

        // Correct for any HTTP escaping issues in the input
        state.src = img.src;

        editorEl.width(width).height(height);

        sliders.filter(":odd").slider("option", "max", img.naturalWidth);
        sliders.filter(":even").slider("option", "max", img.naturalHeight);
        updateSliders();
        updateDividers();
        updateCSS();
        updateHash();
    })
    pathToImage.change(function(event) {
        state.src = pathToImage.val();
        imageEl[0].src = state.src;
    });

    $("#borderOptionsExpander").toggle(
        function() {
            $("#borderOptionsExpander > span").removeClass("ui-icon-triangle-1-e").addClass("ui-icon-triangle-1-s");
            $("#borderOptions").show();
            state.linkBorder = false;
            updateCSS();
            updateHash();
        },
        function() {
            $("#borderOptionsExpander > span").removeClass("ui-icon-triangle-1-s").addClass("ui-icon-triangle-1-e");
            $("#borderOptions").hide();
            state.linkBorder = true;
            updateCSS();
            updateHash();
        });
    editorEl.resizable({
        reverseXAxis: true,
        handles: "s, w, sw",
        aspectRatio: true,
        resize: function() {
            state.scaleFactor = editorEl.innerWidth() / imageEl[0].naturalWidth;

            updateSliders();
            updateDividers();
            updateCSS();
        },
        stop: function() {
            updateHash();
        }
    });

    HistoryHandler.init(function(hash) {
        var prevScale = state.scaleFactor;

        if (hash) {
            state = JSON.parse(hash);
        }
        if ($("#borderOptions").is(":visible") === state.linkBorder) {
            $("#borderOptionsExpander").click();
        }

        if (imageEl[0].src !== state.src) {
            // The other values will update when the image loads
            pathToImage.val(state.src);
            pathToImage.change();
        } else if (prevScale !== state.scaleFactor) {
            imageEl.load();
        } else {
            updateSliders();
            updateDividers();
            updateCSS();
        }
    });
});
<|endoftext|>