<commit_before> var request = require('request');
 describe('Localr API', function() {
     describe('Users', function() {
         describe('create the user', function(done) {
             //             beforeEach(function() {
             //                 var restify = require('restify');
             //                 var test = require('../register.js');
             //                 var server = restify.createServer();
             //                 test.init(server);
             //                 server.listen('8080', 'localhost', function() {
             //                     console.log('%s server listen at %s', server.name, server.url);
             //                 });
             //             })
             it("be able to create a user", function(done) {
                 var url = 'http://api.adam-holt.co.uk/users/register';
                 // getting params
                 var params = {
                     uri: url,
                     headers: {
                         authorization: getBasic('testuser', 'test')
                     }
                 };
                 request.post(params, function(error, response, body) {
                     expect(response.statusCode).toBe(200);
                     if(error) {
                         expect(error.code).not.toBe('ECONNREFUSED');
                     }
                     done();
                 })
             })
             it("be not able to create duplicate user", function(done) {
                 var url = 'http://api.adam-holt.co.uk/users/register';
                 // getting params
                 var params = {
                     uri: url,
                     headers: {
                         authorization: getBasic('testuser', 'test')
                     }
                 };
                 request.post(params, function(error, response, body) {
                     expect(response.statusCode).toBe(409);
                     if(error) {
                         expect(error.code).not.toBe('ECONNREFUSED');
                     }
                     done();
                 })
             })
         })
     })
     describe('checkin', function(done) {
         it("be able to checkin", function(done) {
             var url = 'http://api.adam-holt.co.uk/users/checkin?username=testuser&points=10';
             var doc = {
                 username: "testuser",
                 points: 10
             };
             // getting params
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
                 body: JSON.stringify(doc)
             };
             request.put(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it("check points have been added", function() {
             var url = 'http://api.adam-holt.co.uk/users/testuser';
             // getting params
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 }
             };
             request.get(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 body = JSON.parse(body);
                 expect(body.points).toBe(10);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it("be able to see where you've checked in", function() {})
     })
     describe("groups", function() {
         it("be able to create a group", function() {
             var url = 'http://api.adam-holt.co.uk/users/groups';
             var doc = {
                 username: "testuser",
                 description: "testgroup",
                 competition: "freshers"
             };
             // getting params
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
                 body: JSON.stringify(doc)
             };
             request.post(params, function(error, response, body) {
                 expect(response.statusCode).toBe(201);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it("be able to join a group", function() {
             var url = 'http: //api.adam-holt.co.uk/users/groups/testgroup';
             // getting params
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
             };
             request.put(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it("be able to delete a group", function(done) {
             var url = 'http: //api.adam-holt.co.uk/users/groups';
             var doc = {
                 username: "testuser",
                 groupname: "testgroup",
                 description: "testgroup",
                 competition: "freshers"
             };
             // getting params
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
                 body: JSON.stringify(doc)
             };
             request.del(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
     });
     describe('buisnesses', function() {
         it('able to create new business', function() {})
         it('be able to create an offer', function() {})
         it('cant create duplicate offer', function() {})
     })
     describe('Offers', function() {
         it("Be able to get the latest offers", function(done) {
             var url = 'http: //api.adam-holt.co.uk/business/offers/';
             // getting params
             console.log('get all offers')
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
             };
             request.get(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it("be able to get a businesses offers", function(done) {
             var url = 'http: //api.adam-holt.co.uk/business/offers/testbusiness';
             // getting params
             console.log('get testbusiness offers')
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
             };
             request.get(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
     })
     it("be able to check what offers youve redeemed", function() {})
     describe('delete all', function() {
         it("be able delete the user", function(done) {
             var url = 'http: //api.adam-holt.co.uk/users/testuser';
             // getting params
             console.log('at delete')
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
             };
             request.del(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it('delete business', function() {})
         it('delete offers', function() {})
         it('delete group', function() {})
     })
 });
 getBasic = function(username, password) {
     return "Basic " + new Buffer(username + ":" + password).toString('base64')
 };<commit_msg>Continuing with Jasmine Tests<commit_after> var request = require('request');
 describe('Localr API', function() {
     describe('Users', function() {
         describe('create the user', function(done) {
             //             beforeEach(function() {
             //                 var restify = require('restify');
             //                 var test = require('../register.js');
             //                 var server = restify.createServer();
             //                 test.init(server);
             //                 server.listen('8080', 'localhost', function() {
             //                     console.log('%s server listen at %s', server.name, server.url);
             //                 });
             //             })
             it("be able to create a user", function(done) {
                 var url = 'http://api.adam-holt.co.uk/users/register';
                 // getting params
                 var params = {
                     uri: url,
                     headers: {
                         authorization: getBasic('testuser', 'test')
                     }
                 };
                 request.post(params, function(error, response, body) {
                     expect(response.statusCode).toBe(200);
                     if(error) {
                         expect(error.code).not.toBe('ECONNREFUSED');
                     }
                     done();
                 })
             })
             it("be not able to create duplicate user", function(done) {
                 var url = 'http://api.adam-holt.co.uk/users/register';
                 // getting params
                 var params = {
                     uri: url,
                     headers: {
                         authorization: getBasic('testuser', 'test')
                     }
                 };
                 request.post(params, function(error, response, body) {
                     expect(response.statusCode).toBe(409);
                     if(error) {
                         expect(error.code).not.toBe('ECONNREFUSED');
                     }
                     done();
                 })
             })
         })
     })
     describe('checkin', function(done) {
         it("be able to checkin", function(done) {
             var url = 'http://api.adam-holt.co.uk/users/checkin?username=testuser&points=10';
             var doc = {
                 username: "testuser",
                 points: 10
             };
             // getting params
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
                 body: JSON.stringify(doc)
             };
             request.put(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it("check points have been added", function() {
             var url = 'http://api.adam-holt.co.uk/users/testuser';
             // getting params
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 }
             };
             request.get(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 body = JSON.parse(body);
                 expect(body.points).toBe(10);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it("be able to see where you've checked in", function() {})
     })
     describe("groups", function() {
         it("be able to create a group", function() {
             var url = 'http://api.adam-holt.co.uk/users/groups';
             var doc = {
                 username: "testuser",
                 description: "testgroup",
                 competition: "freshers"
             };
             // getting params
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
                 body: JSON.stringify(doc)
             };
             request.post(params, function(error, response, body) {
                 expect(response.statusCode).toBe(201);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it("be able to join a group", function() {
             var url = 'http: //api.adam-holt.co.uk/users/groups/testgroup';
             // getting params
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
             };
             request.put(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it("be able to delete a group", function(done) {
             var url = 'http: //api.adam-holt.co.uk/users/groups';
             var doc = {
                 username: "testuser",
                 groupname: "testgroup",
                 description: "testgroup",
                 competition: "freshers"
             };
             // getting params
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
                 body: JSON.stringify(doc)
             };
             request.del(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
     });
     describe('businesses', function() {
         it('able to create new business', function() {})

         it('be able to create an offer', function() {})

         it('cant create duplicate offer', function() {})
     })
     describe('Offers', function() {
         it("Be able to get the latest offers", function(done) {
             var url = 'http: //api.adam-holt.co.uk/business/offers/';
             // getting params
             console.log('get all offers')
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
             };
             request.get(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it("be able to get a businesses offers", function(done) {
             var url = 'http: //api.adam-holt.co.uk/business/offers/testbusiness';
             // getting params
             console.log('get testbusiness offers')
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
             };
             request.get(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
     })
     it("be able to check what offers youve redeemed", function() {})
     describe('delete all', function() {
         it("be able delete the user", function(done) {
             var url = 'http://api.adam-holt.co.uk/users/testuser';
             // getting params
             console.log('at delete')
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
             };
             request.del(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it('delete business', function() {})
         it('delete offers', function() {})
         it('delete group', function() {})
     })
 });
 getBasic = function(username, password) {
     return "Basic " + new Buffer(username + ":" + password).toString('base64')
 };<|endoftext|>


<commit_before>/**
 * Created by Gaplo917 on 9/1/2016.
*/
const PROXY_URL = 'https://ionic-reader.xyz'
const BASE_URL = `https://www.hkepc.com`
const BASE_FORUM_URL = `${BASE_URL}/forum`
const IMAGE_URL = 'https://www.hkepc.com/forum'
const VERSION = "v2.0.0"
function getMobileOperatingSystem(userAgent){
  const ua = userAgent || navigator.userAgent || navigator.vendor || window.opera;

  return ua.match(/Windows Phone \d+/i)
      || ua.match( /iPad/i )
      || ua.match( /iPhone/i )
      || ua.match( /iPod/i )
      || ua.match( /Android/i )
      || 'Web'

}
module.exports = {
  userAgent: () => getMobileOperatingSystem(),
  proxy: PROXY_URL,
  baseUrl: BASE_URL,
  baseForumUrl: BASE_FORUM_URL,
  imageUrl:IMAGE_URL,
  version: VERSION,
  forum: {
    index: () => `${BASE_FORUM_URL}/index.php`,
    latestNext: (searchId,page) => {
      return `${BASE_FORUM_URL}/search.php?searchid=${searchId}&orderby=lastpost&ascdesc=desc&searchsubmit=yes&page=${page}`
    },
    search:() => {
      return `${BASE_FORUM_URL}/search.php`
    },
    searchNext: (searchId, page) => {
      return `${BASE_FORUM_URL}/search.php?searchid=${searchId}&orderby=lastpost&ascdesc=desc&searchsubmit=yes&page=${page}`
    },
    topics: (topicId,page,filter,orderby) => {
      return topicId == 'latest'
          ? `${BASE_FORUM_URL}/search.php?srchfrom=12000&searchsubmit=yes&page=${page}`
          : [
              `${BASE_FORUM_URL}/forumdisplay.php?fid=${topicId}`,
              `page=${page}`,
              `filter=${filter >= 0 ? `type&typeid=${filter}` : ''}`,
              `orderby=${orderby||''}`
            ].join("&")
    },
    posts: (topicId,postId,page,orderType,filterOnlyAuthorId) => `${BASE_FORUM_URL}/viewthread.php?fid=${topicId}&tid=${postId}&page=${page}&ordertype=${orderType}&authorid=${filterOnlyAuthorId}`,
    login: () => `${BASE_FORUM_URL}/logging.php?action=login&loginsubmit=yes&loginfield=username`,
    logout: (formhash) => `${BASE_FORUM_URL}/logging.php?action=logout&formhash=${formhash}`,
    news: (page) => `${BASE_URL}/moreNews/page/${page}`,
    replyPage:(reply) => {

      /**
       * reply :{
       *    id: Int,
       *    postId: Int,
       *    topicId: Int,
       *    type: Int ,  1 = None, 2 = Reply , 3 = Quote
       * }
       */

      const url = `${BASE_FORUM_URL}/post.php?action=reply&fid=${reply.topicId}&tid=${reply.postId}`

      switch(reply.type){
        case 1:
          return url
        case 2:
          return `${url}&reppost=${reply.id}`
        case 3:
          return `${url}&repquote=${reply.id}`
        default:
          return url
      }

    },
    reportPage:(topicId,postId,messageId) => `${BASE_FORUM_URL}/misc.php?action=report&fid=${topicId}&tid=${postId}&pid=${messageId}`,
    editMessage:(topicId,postId,messageId) => `${BASE_FORUM_URL}/post.php?action=edit&fid=${topicId}&tid=${postId}&pid=${messageId}`,
    pmList: (page) => `${BASE_FORUM_URL}/pm.php?filter=privatepm&page=${page}`,
    pm: (id) => `${BASE_FORUM_URL}/pm.php?uid=${id}&filter=privatepm&daterange=5#new`,
    notifications: (page) => `${BASE_FORUM_URL}/notice.php?page=${page}`,
    findMessage:(postId,messageId) => `${BASE_FORUM_URL}/redirect.php?goto=findpost&ptid=${postId}&pid=${messageId}`,
    newPost:(fid) => `${BASE_FORUM_URL}/post.php?action=newthread&fid=${fid}`,
    memberCenter: () => `${BASE_FORUM_URL}/memcp.php`,
    checkPM: () => `${BASE_FORUM_URL}/pm.php?checknewpm=0&inajax=1&ajaxtarget=myprompt_check`,
    settings:() => `${BASE_FORUM_URL}/memcp.php?action=profile&typeid=5`,
    subscribeNewReply: (postId) => `${BASE_FORUM_URL}/my.php?item=attention&action=add&tid=${postId}&inajax=1&ajaxtarget=favorite_msg`,
    space: (uid) => `${BASE_FORUM_URL}/space.php?uid=${uid}`,
    myPost: (page) => `${BASE_FORUM_URL}/my.php?item=threads&page=${page}`,
    myReply: (page) => `${BASE_FORUM_URL}/my.php?item=posts&page=${page}`,
  },
  auth:{
    id: 'cdb_sid',
    token: 'cdb_auth',
    expire: 'expires',
    formhash: 'formhash'
  },
  signature: (color) => {
    return `[size=1][color=Silver]via HKEPC IR Pro ${VERSION} - ${getMobileOperatingSystem()}[/color][/size]`
  },
  data:{
    gifs:[
      {
        "code": ":dev:",
        "url": "icon_dev.gif"
      },
      {
        "code": ":loveliness:",
        "url": "loveliness.gif"
      },
      {
        "code": ":wahaha:",
        "url": "icon_clap.gif"
      },
      {
        "code": ":xd:",
        "url": "icon77.gif"
      },
      {
        "code": ":?:",
        "url": "icon_confused.gif"
      },
      {
        "code": ":d:",
        "url": "icon_biggrin.gif"
      },
      {
        "code": ":p:",
        "url": "icon_tongue.gif"
      },
      {
        "code": ":redface:",
        "url": "icon22.gif"
      },
      {
        "code": ":dizzy:",
        "url": "dizzy.gif"
      },
      {
        "code": ":cry:",
        "url": "icon_cry.gif"
      },
      {
        "code": ":help:",
        "url": "icon_help.gif"
      },
      {
        "code": ":naug:",
        "url": "icon_naughty.gif"
      },
      {
        "code": ":good:",
        "url": "icon_good.gif"
      },
      {
        "code": ":discuss:",
        "url": "icon_discuss.gif"
      },
      {
        "code": ":hitwall:",
        "url": "icon_hitwall.gif"
      },
      {
        "code": ":goodjob:",
        "url": "icon_goodjob.gif"
      },
      {
        "code": ":kicking:",
        "url": "icon_kicking.gif"
      },
      {
        "code": ":giveup:",
        "url": "icon_giveup.gif"
      },
      {
        "code": ":shutup:",
        "url": "shutup.gif"
      },
      {
        "code": ":titter:",
        "url": "titter.gif"
      },
      {
        "code": ":cheers:",
        "url": "icon_cheers2.gif"
      },
      {
        "code": ":shifty:",
        "url": "VsX4_shifty_P31Twc0M1TeT.gif"
      },
      {
        "code": ":crybye:",
        "url": "icon_crybye.gif"
      },
      {
        "code": ":agree:",
        "url": "icon_agree.gif"
      },
      {
        "code": ":adore:",
        "url": "icon_adore.gif"
      },
      {
        "code": ":haha:",
        "url": "icon_haha.gif"
      },
      {
        "code": ":silent:",
        "url": "smile_44.gif"
      },
      {
        "code": ":crutch:",
        "url": "icon_crutch.gif"
      },
      {
        "code": ":faint:",
        "url": "smile_27.gif"
      },
      {
        "code": ":drool:",
        "url": "icon_drool.gif"
      },
      {
        "code": ":chair:",
        "url": "icon_chair.gif"
      },
      {
        "code": ":angry:",
        "url": "icon_angry2.gif"
      },
      {
        "code": ":sleep:",
        "url": "icon_sleep.gif"
      },
      {
        "code": ":noway:",
        "url": "noway.gif"
      },
      {
        "code": ":fight:",
        "url": "icon_fight.gif"
      },
      {
        "code": ":smoke:",
        "url": "icon_smoke.gif"
      },
      {
        "code": ":photo:",
        "url": "icon_photo.gif"
      },
      {
        "code": ":baby:",
        "url": "icon_baby.gif"
      },
      {
        "code": ":band:",
        "url": "icon_band.gif"
      },
      {
        "code": ":kiss:",
        "url": "icon_kiss.gif"
      },
      {
        "code": ":nono:",
        "url": "icon_nono.gif"
      },
      {
        "code": ":mad:",
        "url": "icon_mad.gif"
      },
      {
        "code": ":eek:",
        "url": "icon_eek.gif"
      },
      {
        "code": ":gun:",
        "url": "icon_gun2.gif"
      },
      {
        "code": ":ar:",
        "url": "smile_38.gif"
      },
      {
        "code": ":happybday:",
        "url": "icon_happybday.gif"
      }
    ]
  }
}<commit_msg>bump version to 2.0.1<commit_after>/**
 * Created by Gaplo917 on 9/1/2016.
*/
const PROXY_URL = 'https://ionic-reader.xyz'
const BASE_URL = `https://www.hkepc.com`
const BASE_FORUM_URL = `${BASE_URL}/forum`
const IMAGE_URL = 'https://www.hkepc.com/forum'
const VERSION = "v2.0.1"
function getMobileOperatingSystem(userAgent){
  const ua = userAgent || navigator.userAgent || navigator.vendor || window.opera;

  return ua.match(/Windows Phone \d+/i)
      || ua.match( /iPad/i )
      || ua.match( /iPhone/i )
      || ua.match( /iPod/i )
      || ua.match( /Android/i )
      || 'Web'

}
module.exports = {
  userAgent: () => getMobileOperatingSystem(),
  proxy: PROXY_URL,
  baseUrl: BASE_URL,
  baseForumUrl: BASE_FORUM_URL,
  imageUrl:IMAGE_URL,
  version: VERSION,
  forum: {
    index: () => `${BASE_FORUM_URL}/index.php`,
    latestNext: (searchId,page) => {
      return `${BASE_FORUM_URL}/search.php?searchid=${searchId}&orderby=lastpost&ascdesc=desc&searchsubmit=yes&page=${page}`
    },
    search:() => {
      return `${BASE_FORUM_URL}/search.php`
    },
    searchNext: (searchId, page) => {
      return `${BASE_FORUM_URL}/search.php?searchid=${searchId}&orderby=lastpost&ascdesc=desc&searchsubmit=yes&page=${page}`
    },
    topics: (topicId,page,filter,orderby) => {
      return topicId == 'latest'
          ? `${BASE_FORUM_URL}/search.php?srchfrom=12000&searchsubmit=yes&page=${page}`
          : [
              `${BASE_FORUM_URL}/forumdisplay.php?fid=${topicId}`,
              `page=${page}`,
              `filter=${filter >= 0 ? `type&typeid=${filter}` : ''}`,
              `orderby=${orderby||''}`
            ].join("&")
    },
    posts: (topicId,postId,page,orderType,filterOnlyAuthorId) => `${BASE_FORUM_URL}/viewthread.php?fid=${topicId}&tid=${postId}&page=${page}&ordertype=${orderType}&authorid=${filterOnlyAuthorId}`,
    login: () => `${BASE_FORUM_URL}/logging.php?action=login&loginsubmit=yes&loginfield=username`,
    logout: (formhash) => `${BASE_FORUM_URL}/logging.php?action=logout&formhash=${formhash}`,
    news: (page) => `${BASE_URL}/moreNews/page/${page}`,
    replyPage:(reply) => {

      /**
       * reply :{
       *    id: Int,
       *    postId: Int,
       *    topicId: Int,
       *    type: Int ,  1 = None, 2 = Reply , 3 = Quote
       * }
       */

      const url = `${BASE_FORUM_URL}/post.php?action=reply&fid=${reply.topicId}&tid=${reply.postId}`

      switch(reply.type){
        case 1:
          return url
        case 2:
          return `${url}&reppost=${reply.id}`
        case 3:
          return `${url}&repquote=${reply.id}`
        default:
          return url
      }

    },
    reportPage:(topicId,postId,messageId) => `${BASE_FORUM_URL}/misc.php?action=report&fid=${topicId}&tid=${postId}&pid=${messageId}`,
    editMessage:(topicId,postId,messageId) => `${BASE_FORUM_URL}/post.php?action=edit&fid=${topicId}&tid=${postId}&pid=${messageId}`,
    pmList: (page) => `${BASE_FORUM_URL}/pm.php?filter=privatepm&page=${page}`,
    pm: (id) => `${BASE_FORUM_URL}/pm.php?uid=${id}&filter=privatepm&daterange=5#new`,
    notifications: (page) => `${BASE_FORUM_URL}/notice.php?page=${page}`,
    findMessage:(postId,messageId) => `${BASE_FORUM_URL}/redirect.php?goto=findpost&ptid=${postId}&pid=${messageId}`,
    newPost:(fid) => `${BASE_FORUM_URL}/post.php?action=newthread&fid=${fid}`,
    memberCenter: () => `${BASE_FORUM_URL}/memcp.php`,
    checkPM: () => `${BASE_FORUM_URL}/pm.php?checknewpm=0&inajax=1&ajaxtarget=myprompt_check`,
    settings:() => `${BASE_FORUM_URL}/memcp.php?action=profile&typeid=5`,
    subscribeNewReply: (postId) => `${BASE_FORUM_URL}/my.php?item=attention&action=add&tid=${postId}&inajax=1&ajaxtarget=favorite_msg`,
    space: (uid) => `${BASE_FORUM_URL}/space.php?uid=${uid}`,
    myPost: (page) => `${BASE_FORUM_URL}/my.php?item=threads&page=${page}`,
    myReply: (page) => `${BASE_FORUM_URL}/my.php?item=posts&page=${page}`,
  },
  auth:{
    id: 'cdb_sid',
    token: 'cdb_auth',
    expire: 'expires',
    formhash: 'formhash'
  },
  signature: (color) => {
    return `[size=1][color=Silver]via HKEPC IR Pro ${VERSION} - ${getMobileOperatingSystem()}[/color][/size]`
  },
  data:{
    gifs:[
      {
        "code": ":dev:",
        "url": "icon_dev.gif"
      },
      {
        "code": ":loveliness:",
        "url": "loveliness.gif"
      },
      {
        "code": ":wahaha:",
        "url": "icon_clap.gif"
      },
      {
        "code": ":xd:",
        "url": "icon77.gif"
      },
      {
        "code": ":?:",
        "url": "icon_confused.gif"
      },
      {
        "code": ":d:",
        "url": "icon_biggrin.gif"
      },
      {
        "code": ":p:",
        "url": "icon_tongue.gif"
      },
      {
        "code": ":redface:",
        "url": "icon22.gif"
      },
      {
        "code": ":dizzy:",
        "url": "dizzy.gif"
      },
      {
        "code": ":cry:",
        "url": "icon_cry.gif"
      },
      {
        "code": ":help:",
        "url": "icon_help.gif"
      },
      {
        "code": ":naug:",
        "url": "icon_naughty.gif"
      },
      {
        "code": ":good:",
        "url": "icon_good.gif"
      },
      {
        "code": ":discuss:",
        "url": "icon_discuss.gif"
      },
      {
        "code": ":hitwall:",
        "url": "icon_hitwall.gif"
      },
      {
        "code": ":goodjob:",
        "url": "icon_goodjob.gif"
      },
      {
        "code": ":kicking:",
        "url": "icon_kicking.gif"
      },
      {
        "code": ":giveup:",
        "url": "icon_giveup.gif"
      },
      {
        "code": ":shutup:",
        "url": "shutup.gif"
      },
      {
        "code": ":titter:",
        "url": "titter.gif"
      },
      {
        "code": ":cheers:",
        "url": "icon_cheers2.gif"
      },
      {
        "code": ":shifty:",
        "url": "VsX4_shifty_P31Twc0M1TeT.gif"
      },
      {
        "code": ":crybye:",
        "url": "icon_crybye.gif"
      },
      {
        "code": ":agree:",
        "url": "icon_agree.gif"
      },
      {
        "code": ":adore:",
        "url": "icon_adore.gif"
      },
      {
        "code": ":haha:",
        "url": "icon_haha.gif"
      },
      {
        "code": ":silent:",
        "url": "smile_44.gif"
      },
      {
        "code": ":crutch:",
        "url": "icon_crutch.gif"
      },
      {
        "code": ":faint:",
        "url": "smile_27.gif"
      },
      {
        "code": ":drool:",
        "url": "icon_drool.gif"
      },
      {
        "code": ":chair:",
        "url": "icon_chair.gif"
      },
      {
        "code": ":angry:",
        "url": "icon_angry2.gif"
      },
      {
        "code": ":sleep:",
        "url": "icon_sleep.gif"
      },
      {
        "code": ":noway:",
        "url": "noway.gif"
      },
      {
        "code": ":fight:",
        "url": "icon_fight.gif"
      },
      {
        "code": ":smoke:",
        "url": "icon_smoke.gif"
      },
      {
        "code": ":photo:",
        "url": "icon_photo.gif"
      },
      {
        "code": ":baby:",
        "url": "icon_baby.gif"
      },
      {
        "code": ":band:",
        "url": "icon_band.gif"
      },
      {
        "code": ":kiss:",
        "url": "icon_kiss.gif"
      },
      {
        "code": ":nono:",
        "url": "icon_nono.gif"
      },
      {
        "code": ":mad:",
        "url": "icon_mad.gif"
      },
      {
        "code": ":eek:",
        "url": "icon_eek.gif"
      },
      {
        "code": ":gun:",
        "url": "icon_gun2.gif"
      },
      {
        "code": ":ar:",
        "url": "smile_38.gif"
      },
      {
        "code": ":happybday:",
        "url": "icon_happybday.gif"
      }
    ]
  }
}<|endoftext|>


<commit_before>import Matter from 'matter-js'
import R from 'ramda'
const { Engine, Render, World, Bodies, Body, Events, Vector, Bounds, Runner } = Matter

const FRICTION = 0.015
const RESTITUTION = 0.1

const STONE_RADIUS = 31
const HOUSE_RADIUS = 245
const SHEET_WIDTH = 820
const SHEET_HEIGHT = 2460
const BUTTON_Y = 498

// Stones out of bounds are removed from the sheet.
// The simulation is stopped when there are either no stones
// inside bounds or all the stones are slower than MIN_SPEED.
const BOUNDS = {
  min: { x: -SHEET_WIDTH / 2, y: -BUTTON_Y },
  max: { x: SHEET_WIDTH / 2, y: SHEET_HEIGHT - BUTTON_Y }
}
const MIN_SPEED = 0.02
const SIMULATION_STEP_MS = 1000 / 60

// FIXME rename angle to line, speed to weight
const getVelocity = (speed, angle) => {
  const vx = speed * Math.cos(angle * Math.PI / 180)
  const vy = -speed * Math.cos((90 - angle) * Math.PI / 180)
  return Vector.create(vx, vy)
}

const createStone = (x, y, angle, team, sprites, isDelivery) => {
  const options = {
    frictionAir: FRICTION,
    restitution: RESTITUTION,
    angle
  }
  if (sprites !== undefined) {
    options.render = {
      sprite: {
        texture: sprites[team]
      }
    }
  }
  const stone = Bodies.circle(x, y, STONE_RADIUS, options)
  stone.team = team
  stone.isDelivery = isDelivery
  return stone
}

const createStones = (delivery, stones, sprites) => {
  const stationary = stones.map(s => createStone(s.x,
                                                 s.y,
                                                 s.angle,
                                                 s.team,
                                                 sprites,
                                                 false))

  const delivered = createStone(0,
                                BOUNDS.max.y,
                                0,
                                delivery.team,
                                sprites,
                                true)

  Body.setAngularVelocity(delivered, delivery.curl)
  Body.setVelocity(delivered, getVelocity(delivery.speed, delivery.angle))

  return [delivered, ...stationary]
}

const createEngine = matterStones => {
  const engine = Engine.create()
  engine.world.gravity = Vector.create(0, 0)

  World.add(engine.world, matterStones)
  Events.on(engine, 'afterUpdate', () => {
    applyCurl(engine)
    // Remove items that are out of bounds
    engine.world.bodies
      .filter(isOutOfBounds)
      .forEach(stone => World.remove(engine.world, stone))
  })

  return engine
}

const stoneToJson = stone => {
  const { x, y } = stone.position
  const team = stone.team
  const angle = stone.angle
  return { x, y, team, angle }
}

const isOutOfBounds = stone => !Bounds.overlaps(stone.bounds, BOUNDS)

const isMoving = stone => Vector.magnitude(stone.velocity) > MIN_SPEED

const isFinished = engine => (
  engine.world.bodies.length === 0 || !engine.world.bodies.some(isMoving)
)

const applyCurl  = engine => {
  const deliveree = engine.world.bodies.find(x => x.isDelivery === true)
  if (!deliveree || deliveree.speed < MIN_SPEED){
    return
  }
  const baseVector = deliveree.velocity;
  // Base scaling is based on the amount of curl in the stone
  let scaledVector = Vector.mult(baseVector, Math.abs(deliveree.angularVelocity) / 2000)
  // Add some bonus scaling that increments towards the end
  scaledVector = Vector.mult(scaledVector, Math.log(1/deliveree.speed + Math.E))
  const directionAngle = Math.sign(deliveree.angularVelocity) * 0.5 * Math.PI
  const directedVector = Vector.rotate(scaledVector, directionAngle)

  Body.applyForce(deliveree, deliveree.position, directedVector)
}

const simulate = (delivery, stones) => {
  const matterStones = createStones(delivery, stones)
  const engine = createEngine(matterStones)

  const runStep = engine => {
    Events.trigger(engine, 'tick', { timestamp: engine.timing.timestamp })
    Engine.update(engine, SIMULATION_STEP_MS)
    Events.trigger(engine, 'afterTick', { timestamp: engine.timing.timestamp })
    return engine
  }
  R.until(isFinished, runStep)(engine)

  return engine.world.bodies.map(stoneToJson)
}

const createRunner = () => {
  const runnerOptions = {
    isFixed: true,
    delta: SIMULATION_STEP_MS
  }
  return Runner.create(runnerOptions)
}

const createRenderer = (engine, element, background) => {
  const renderer = Render.create({
    element,
    engine,
    bounds: BOUNDS,
    options: {
      hasBounds: true,
      background,
      height: SHEET_HEIGHT,
      width: SHEET_WIDTH,
      wireframes: false
    }
  })

  return renderer
}

const renderSimulation = (delivery, stones, sprites, background, element) => {
  return new Promise((resolve, reject) => {
    let failTimeout;

    const isEmpty = e => !e.hasChildNodes()
    const removeChild = element => {
      element.removeChild(element.firstChild)
      return element
    }
    R.unless(R.isEmpty, R.until(isEmpty, removeChild))(element)

    const matterStones = createStones(delivery, stones, sprites)
    const engine = createEngine(matterStones)
    const runner = createRunner()
    const renderer = createRenderer(engine, element, background)

    failTimeout = setTimeout(reject, 12000);

    Events.on(renderer, 'afterRender', () => {

      if (isFinished(engine)) {
        Render.stop(renderer);
        clearTimeout(failTimeout);
        resolve();
      }
    })

    Runner.run(runner, engine)
    Render.run(renderer)
  })
}

export { simulate, renderSimulation, STONE_RADIUS, HOUSE_RADIUS }<commit_msg>Added end line to end of file<commit_after>import Matter from 'matter-js'
import R from 'ramda'
const { Engine, Render, World, Bodies, Body, Events, Vector, Bounds, Runner } = Matter

const FRICTION = 0.015
const RESTITUTION = 0.1

const STONE_RADIUS = 31
const HOUSE_RADIUS = 245
const SHEET_WIDTH = 820
const SHEET_HEIGHT = 2460
const BUTTON_Y = 498

// Stones out of bounds are removed from the sheet.
// The simulation is stopped when there are either no stones
// inside bounds or all the stones are slower than MIN_SPEED.
const BOUNDS = {
  min: { x: -SHEET_WIDTH / 2, y: -BUTTON_Y },
  max: { x: SHEET_WIDTH / 2, y: SHEET_HEIGHT - BUTTON_Y }
}
const MIN_SPEED = 0.02
const SIMULATION_STEP_MS = 1000 / 60

// FIXME rename angle to line, speed to weight
const getVelocity = (speed, angle) => {
  const vx = speed * Math.cos(angle * Math.PI / 180)
  const vy = -speed * Math.cos((90 - angle) * Math.PI / 180)
  return Vector.create(vx, vy)
}

const createStone = (x, y, angle, team, sprites, isDelivery) => {
  const options = {
    frictionAir: FRICTION,
    restitution: RESTITUTION,
    angle
  }
  if (sprites !== undefined) {
    options.render = {
      sprite: {
        texture: sprites[team]
      }
    }
  }
  const stone = Bodies.circle(x, y, STONE_RADIUS, options)
  stone.team = team
  stone.isDelivery = isDelivery
  return stone
}

const createStones = (delivery, stones, sprites) => {
  const stationary = stones.map(s => createStone(s.x,
                                                 s.y,
                                                 s.angle,
                                                 s.team,
                                                 sprites,
                                                 false))

  const delivered = createStone(0,
                                BOUNDS.max.y,
                                0,
                                delivery.team,
                                sprites,
                                true)

  Body.setAngularVelocity(delivered, delivery.curl)
  Body.setVelocity(delivered, getVelocity(delivery.speed, delivery.angle))

  return [delivered, ...stationary]
}

const createEngine = matterStones => {
  const engine = Engine.create()
  engine.world.gravity = Vector.create(0, 0)

  World.add(engine.world, matterStones)
  Events.on(engine, 'afterUpdate', () => {
    applyCurl(engine)
    // Remove items that are out of bounds
    engine.world.bodies
      .filter(isOutOfBounds)
      .forEach(stone => World.remove(engine.world, stone))
  })

  return engine
}

const stoneToJson = stone => {
  const { x, y } = stone.position
  const team = stone.team
  const angle = stone.angle
  return { x, y, team, angle }
}

const isOutOfBounds = stone => !Bounds.overlaps(stone.bounds, BOUNDS)

const isMoving = stone => Vector.magnitude(stone.velocity) > MIN_SPEED

const isFinished = engine => (
  engine.world.bodies.length === 0 || !engine.world.bodies.some(isMoving)
)

const applyCurl  = engine => {
  const deliveree = engine.world.bodies.find(x => x.isDelivery === true)
  if (!deliveree || deliveree.speed < MIN_SPEED){
    return
  }
  const baseVector = deliveree.velocity;
  // Base scaling is based on the amount of curl in the stone
  let scaledVector = Vector.mult(baseVector, Math.abs(deliveree.angularVelocity) / 2000)
  // Add some bonus scaling that increments towards the end
  scaledVector = Vector.mult(scaledVector, Math.log(1/deliveree.speed + Math.E))
  const directionAngle = Math.sign(deliveree.angularVelocity) * 0.5 * Math.PI
  const directedVector = Vector.rotate(scaledVector, directionAngle)

  Body.applyForce(deliveree, deliveree.position, directedVector)
}

const simulate = (delivery, stones) => {
  const matterStones = createStones(delivery, stones)
  const engine = createEngine(matterStones)

  const runStep = engine => {
    Events.trigger(engine, 'tick', { timestamp: engine.timing.timestamp })
    Engine.update(engine, SIMULATION_STEP_MS)
    Events.trigger(engine, 'afterTick', { timestamp: engine.timing.timestamp })
    return engine
  }
  R.until(isFinished, runStep)(engine)

  return engine.world.bodies.map(stoneToJson)
}

const createRunner = () => {
  const runnerOptions = {
    isFixed: true,
    delta: SIMULATION_STEP_MS
  }
  return Runner.create(runnerOptions)
}

const createRenderer = (engine, element, background) => {
  const renderer = Render.create({
    element,
    engine,
    bounds: BOUNDS,
    options: {
      hasBounds: true,
      background,
      height: SHEET_HEIGHT,
      width: SHEET_WIDTH,
      wireframes: false
    }
  })

  return renderer
}

const renderSimulation = (delivery, stones, sprites, background, element) => {
  return new Promise((resolve, reject) => {
    let failTimeout;

    const isEmpty = e => !e.hasChildNodes()
    const removeChild = element => {
      element.removeChild(element.firstChild)
      return element
    }
    R.unless(R.isEmpty, R.until(isEmpty, removeChild))(element)

    const matterStones = createStones(delivery, stones, sprites)
    const engine = createEngine(matterStones)
    const runner = createRunner()
    const renderer = createRenderer(engine, element, background)

    failTimeout = setTimeout(reject, 12000);

    Events.on(renderer, 'afterRender', () => {

      if (isFinished(engine)) {
        Render.stop(renderer);
        clearTimeout(failTimeout);
        resolve();
      }
    })

    Runner.run(runner, engine)
    Render.run(renderer)
  })
}

export { simulate, renderSimulation, STONE_RADIUS, HOUSE_RADIUS }
<|endoftext|>


<commit_before>/**
 * Created by kelvinzhang on 5/29/17.
 */

var canvas;
var bgCanvas;

var robotX;
var robotY;

var senseCircle = 0;
var senseRadius = 150;

var nLasers = 36;
var scanned = false;

var robotDir = 0;
var dirOffset = 0;

//Results of laser scan
var z = new Array(nLasers);

function click()
{
    var coor = getClickLoc(event);
    robotX = coor.x;
    robotY = coor.y;
    // senseCircle = 0;
    scanned = false;
    update();
    draw(canvas.getContext('2d'));
}

function scan()
{
    //Radian between each laser
    for(var i = 0; i < nLasers; i ++)
    {
        var dir = Math.PI*2 * i / nLasers;

        var s1 = new Point(robotX, robotY);
        var t1 = new Point(robotX + cos(dir)*senseRadius, robotY + sin(dir)*senseRadius);

        //If dir is 90 degrees
        //if i = 1/nLasers or i = (3/4) * nLasers
        //cos(dir) should be 0 in these cases,
        if(i * 4 === nLasers || i * 4 === nLasers * 3)
            t1.x = robotX;
        else if(i * 2 === nLasers)
            t1.y = robotY;

        z[i] = senseRadius + 100;
        for(var j = 0; j < map.length; j ++)
        {
            if(doIntersect(s1, t1, map[j].s, map[j].t))
            {
                // z[i] = senseRadius;
                var p = intersectionPoint(s1, t1, map[j].s, map[j].t);
                var dist = p.distanceTo(new Point(robotX, robotY));
                z[i] = min(z[i], dist);
            }
        }
    }
}

function update()
{
    if(!scanned)
    {
        scan();
        scanned = true;
    }
    // senseCircle++;
    // senseCircle %= senseRadius;
}

function draw(ctx)
{
    ctx.clearRect(0, 0, canvas.width, canvas.height);

    ctx.strokeStyle = 'black';
    ctx.drawRobot(robotX, robotY, robotDir, 20);

    //Radian between each laser
    var rad = Math.PI*2/nLasers;
    for(var index = 0; index < nLasers/2; index ++)
    {
        var i = (index + dirOffset + nLasers - nLasers/4) % nLasers;
        var dir = i * rad;
        var laserLen = senseCircle;
        if(z[i] > senseRadius)
        {
            ctx.strokeStyle = 'grey';
        }else
        {
            laserLen = min(laserLen, z[i]);
            ctx.strokeStyle = 'red';
            ctx.fillStyle = 'red';
            ctx.beginPath();
            ctx.arc(robotX + cos(dir)*z[i], robotY + sin(dir)*z[i], 5, 0, Math.PI*2);
            ctx.fill();
        }
        ctx.beginPath();
        ctx.moveTo(robotX, robotY);
        ctx.lineTo(robotX + cos(dir)*laserLen, robotY + sin(dir)*laserLen);
        ctx.stroke();
    }
}

function frame()
{
    var ctx = canvas.getContext('2d');
    update();
    draw(ctx);
    requestAnimationFrame(frame);
}

function parameterChanged(event)
{
    senseRadius = Number(event.target.value)/0.02;
}

function mouseMotion(event)
{
    var coor = getClickLoc(event);
    var x = coor.x;
    var y = coor.y;

    robotDir = atan2(y-robotY, x-robotX);
    dirOffset = round(robotDir/Math.PI/2 * nLasers);
}

function init()
{
    canvas = document.getElementById('canvas');
    bgCanvas = document.getElementById('background');

    //Draw the map
    var map = getMapForCanvas(canvas);
    drawMap(map, bgCanvas.getContext('2d'));
    robotX = floor(random()*canvas.width);
    robotY = floor(random()*canvas.height);

    //Listen to mouse click events
    background.addEventListener('click', click);
    background.onmousemove = mouseMotion;
    senseRadius = getValue('fogOfWar')/0.02;
    senseCircle = senseRadius;
    requestAnimationFrame(frame);
}<commit_msg>add comments<commit_after>/**
 * Created by kelvinzhang on 5/29/17.
 */

var canvas;
var bgCanvas;

var robotX;
var robotY;

var senseCircle = 0;
var senseRadius = 150;

var nLasers = 36;
var scanned = false;

var robotDir = 0;
var dirOffset = 0;

//Results of laser scan
var z = new Array(nLasers);

function click()
{
    var coor = getClickLoc(event);
    robotX = coor.x;
    robotY = coor.y;
    // senseCircle = 0;
    scanned = false;
    update();
    draw(canvas.getContext('2d'));
}

function scan()
{
    //Radian between each laser
    for(var i = 0; i < nLasers; i ++)
    {
        var dir = Math.PI*2 * i / nLasers;

        var s1 = new Point(robotX, robotY);
        var t1 = new Point(robotX + cos(dir)*senseRadius, robotY + sin(dir)*senseRadius);

        //If dir is 90 degrees
        //if i = 1/nLasers or i = (3/4) * nLasers
        //cos(dir) should be 0 in these cases,
        if(i * 4 === nLasers || i * 4 === nLasers * 3)
            t1.x = robotX;
        else if(i * 2 === nLasers)
            t1.y = robotY;

        z[i] = senseRadius + 100;
        for(var j = 0; j < map.length; j ++)
        {
            if(doIntersect(s1, t1, map[j].s, map[j].t))
            {
                // z[i] = senseRadius;
                var p = intersectionPoint(s1, t1, map[j].s, map[j].t);
                var dist = p.distanceTo(new Point(robotX, robotY));
                z[i] = min(z[i], dist);
            }
        }
    }
}

function update()
{
    if(!scanned)
    {
        scan();
        scanned = true;
    }
    // senseCircle++;
    // senseCircle %= senseRadius;
}

function draw(ctx)
{
    ctx.clearRect(0, 0, canvas.width, canvas.height);

    ctx.strokeStyle = 'black';
    ctx.drawRobot(robotX, robotY, robotDir, 20);

    //Radian between each laser
    var rad = Math.PI*2/nLasers;
    for(var index = 0; index < nLasers/2; index ++)
    {
        //dirOffset is the direction the user's mouse
        //is point at, -nLasers/4 to offset it by 90 degrees,
        //so that laser scan is centered at where the user
        //points to
        var i = (index + dirOffset - nLasers/4);

        //get i stay in bound
        i = (i + nLasers) % nLasers;

        var dir = i * rad;
        var laserLen = senseCircle;
        if(z[i] > senseRadius)
        {
            ctx.strokeStyle = 'grey';
        }else
        {
            laserLen = min(laserLen, z[i]);
            ctx.strokeStyle = 'red';
            ctx.fillStyle = 'red';
            ctx.beginPath();
            ctx.arc(robotX + cos(dir)*z[i], robotY + sin(dir)*z[i], 5, 0, Math.PI*2);
            ctx.fill();
        }
        ctx.beginPath();
        ctx.moveTo(robotX, robotY);
        ctx.lineTo(robotX + cos(dir)*laserLen, robotY + sin(dir)*laserLen);
        ctx.stroke();
    }
}

function frame()
{
    var ctx = canvas.getContext('2d');
    update();
    draw(ctx);
    requestAnimationFrame(frame);
}

function parameterChanged(event)
{
    senseRadius = Number(event.target.value)/0.02;
}

function mouseMotion(event)
{
    var coor = getClickLoc(event);
    var x = coor.x;
    var y = coor.y;

    robotDir = atan2(y-robotY, x-robotX);
    dirOffset = round(robotDir/Math.PI/2 * nLasers);
}

function init()
{
    canvas = document.getElementById('canvas');
    bgCanvas = document.getElementById('background');

    //Draw the map
    var map = getMapForCanvas(canvas);
    drawMap(map, bgCanvas.getContext('2d'));
    robotX = floor(random()*canvas.width);
    robotY = floor(random()*canvas.height);

    //Listen to mouse click events
    background.addEventListener('click', click);
    background.onmousemove = mouseMotion;
    senseRadius = getValue('fogOfWar')/0.02;
    senseCircle = senseRadius;
    requestAnimationFrame(frame);
}<|endoftext|>


<commit_before>require('fileapi');

var backbone = require('backbone');
var backboneBase = require('backbone-base');
var getUri = require('get-uri');
var Goodtables = require('goodtables');
var highlight = require('highlight-redux');
var jsonEditor = require('json-editor');
var jtsInfer = require('jts-infer');
var registry = require('./registry');
var UploadView = require('./upload');
var validator = require('datapackage-validate');
var _ = require('underscore');
var $ = require('jquery');

// Upload data file and populate .resource array with item
DataUploadView = backbone.BaseView.extend({
  events: {
    // Set up and append .resources row
    'change [data-id=input]': function(E) {
      FileAPI.readAsText(FileAPI.getFiles(E.currentTarget)[0], (function (EV) {
        if(EV.type === 'load') {
          getUri(['data', EV.target.type, 'utf-8'].join(':') + ',' + EV.result, (function (E, R) {
            if(E) throw E;

            jtsInfer(R, (function(E, S, SR) {
              if(E) throw E;

              this.options.form.getEditor('root.resources').addRow({
                name: EV.target.name,
                path: EV.target.name,
                schema: S
              });

              // Save data source
              _.last(this.options.form.getEditor('root.resources').rows).dataSource = {schema: S, data: EV.result};
            }).bind(this));
          }).bind(this));
        } else if( EV.type ==='progress' ) {
          this.setProgress(EV.loaded/EV.total * 100);
        } else {
          this.setError('File upload failed');
        }

        this.$(E.currentTarget).val('');
      }).bind(this));
    },

    'click [data-id=upload-data-file]': function() { this.$('[data-id=input]').trigger('click'); }
  },

  render: function() {
    this.$el
      .append('<input data-id="input" type="file" accept="text/csv" style="display: none;">')

      .append(
        $(this.options.form.theme.getButton('Upload data file', '', 'Upload data file'))
          .attr('data-id', 'upload-data-file')
      );

    return this;
  },

  setError: function() { return this; },
  setProgress: function() { return this; }
});

module.exports = {
  DescriptorEditView: backbone.BaseView.extend({
    activate: function(state) {
      backbone.BaseView.prototype.activate.call(this, state);
      this.layout.upload.activate(state);
      return this;
    },

    events: {
      'click #validate-resources': function() {
        var goodTables = new Goodtables({method: 'post', report_type: 'grouped'});

        // Navigate to valifation results just once during series of API calls
        var navigateToResults = _.once(function(id) { window.ROUTER.navigate('/validation-results/' + id, {trigger: true}); });

        window.APP.layout.validationResultList.reset(new backbone.Collection());

        _.each(this.layout.form.getEditor('root.resources').rows, function(R) {
          goodTables.run(R.dataSource.data, JSON.stringify(R.dataSource.schema)).then(
            function(M) {
              // Validation completed
              window.APP.layout.validationResultList.collection

                // Grouped report has complicated structure
                .add(M.getGroupedByRows().map(function(SR) { return _.extend(_.values(SR)[0], {
                  headers: M.getHeaders(),
                  resource_id: R.key
                }); }));

              // Navigate between resources in validation results
              window.APP.layout.validationResultList.layout.tabs.add(new backbone.Model({
                title: R.getValue().path,

                // .key is a unique property among all resources rows
                url: '/validation-results/' + R.key
              }));

              navigateToResults(R.key);
            }
          );
        });
      }
    },

    initialize: function(options) {
      highlight.configure({useBR: true});
      return backbone.BaseView.prototype.initialize.call(this, options);
    },

    render: function() {
      this.layout.upload = new UploadView({el: window.APP.$('#upload-data-package'), parent: this});
      this.layout.registryList = new registry.ListView({el: window.APP.$('#registry-list'), container: '[data-id=list-container]', parent: this});
      return this;
    },

    // Utility method to remove empty values from object recursive
    compactObject: function(data) {
      _.each(data, function(v, k) {
        if(_.isEmpty(v)) {
          delete data[k];
        } else if(_.isArray(v) || _.isObject(v)) {
          v = this.compactObject(v);

          if(_.isArray(v))
            v = _.compact(v);

          if(_.isEmpty(v))
            delete data[k];
          else data[k] = v;
        }
      }, this);

      return data;
    },

    getFilledValues: function() { return this.compactObject(this.layout.form.getValue()); },
    getValue: function () { return this.layout.form.getValue(); },
    hasChanges: function() { return Boolean(this.changed); },

    reset: function(schema) {
      var formData;

      // Clean up previous state
      if(this.layout.form) {
        formData = this.getFilledValues();
        this.layout.form.destroy();
        this.layout.uploadData.undelegateEvents().remove();
      }

      this.layout.form = new JSONEditor(this.$('[data-id=form-container]').get(0), {
        schema: schema,
        theme: 'bootstrap3'
      });

      this.layout.uploadData = (new DataUploadView({
        el: this.layout.form.theme.getHeaderButtonHolder(),
        form: this.layout.form,
        parent: this
      })).render();

      this.layout.form.on('ready', (function() {
        // There is no any good way to bind events to custom button or even add cutsom button
        $(this.layout.form.getEditor('root.resources').container)
          .children('h3').append(this.layout.uploadData.el);

        // Add validation to save JSON action
        _.each(_.filter(this.layout.form.editors, function(E) { return E.editjson_save; }), function(E) {
          E.saveJSON = _.wrap(E.saveJSON, function(saveJSON) {
            validateResult = validator.validate(this.editjson_textarea.value);

            if(!validateResult.valid)
              window.APP.layout.errorList.reset(new backbone.Collection(validateResult.errors));
            else
              return saveJSON.call(this);
          });
        });

        // Detecting changes
        this.changed = false;

        // After `ready` event fired, editor fire `change` event regarding to the initial changes
        this.layout.form.on('change', _.after(2, (function() {
          this.changed = true;
          window.APP.layout.download.reset(this.layout.form.getValue()).activate();
          this.showResult();
        }).bind(this)));

        // If on the previous form was entered values try to apply it to new form
        if(formData) {
          this.layout.form.setValue(_.extend({}, this.layout.form.getValue(formData), formData));

          // Expand editors if it have value
          _.each(this.$('[data-schemapath][data-schemapath!=root]:has(.json-editor-btn-collapse)'), function(E) {
              if(_.isEmpty(this.layout.form.getEditor($(E).data('schemapath')).getValue()))
                $(E).find('.json-editor-btn-collapse').click();
          }, this);
        } else
          // Collapse all
          this.$('.row .json-editor-btn-collapse').click();
      }).bind(this));
    },

    showResult: function() {
      $('#json-code').html(highlight.fixMarkup(
        highlight.highlight('json', JSON.stringify(this.layout.form.getValue(), undefined, 2)).value
      ));

      return this;
    }
  })
};
<commit_msg>This code is never used<commit_after>require('fileapi');

var backbone = require('backbone');
var backboneBase = require('backbone-base');
var getUri = require('get-uri');
var Goodtables = require('goodtables');
var highlight = require('highlight-redux');
var jsonEditor = require('json-editor');
var jtsInfer = require('jts-infer');
var registry = require('./registry');
var UploadView = require('./upload');
var validator = require('datapackage-validate');
var _ = require('underscore');
var $ = require('jquery');

// Upload data file and populate .resource array with item
DataUploadView = backbone.BaseView.extend({
  events: {
    // Set up and append .resources row
    'change [data-id=input]': function(E) {
      FileAPI.readAsText(FileAPI.getFiles(E.currentTarget)[0], (function (EV) {
        if(EV.type === 'load') {
          getUri(['data', EV.target.type, 'utf-8'].join(':') + ',' + EV.result, (function (E, R) {
            if(E) throw E;

            jtsInfer(R, (function(E, S, SR) {
              if(E) throw E;

              this.options.form.getEditor('root.resources').addRow({
                name: EV.target.name,
                path: EV.target.name,
                schema: S
              });

              // Save data source
              _.last(this.options.form.getEditor('root.resources').rows).dataSource = {schema: S, data: EV.result};
            }).bind(this));
          }).bind(this));
        } else if( EV.type ==='progress' ) {
          this.setProgress(EV.loaded/EV.total * 100);
        } else {
          this.setError('File upload failed');
        }

        this.$(E.currentTarget).val('');
      }).bind(this));
    },

    'click [data-id=upload-data-file]': function() { this.$('[data-id=input]').trigger('click'); }
  },

  render: function() {
    this.$el
      .append('<input data-id="input" type="file" accept="text/csv" style="display: none;">')

      .append(
        $(this.options.form.theme.getButton('Upload data file', '', 'Upload data file'))
          .attr('data-id', 'upload-data-file')
      );

    return this;
  },

  setError: function() { return this; },
  setProgress: function() { return this; }
});

module.exports = {
  DescriptorEditView: backbone.BaseView.extend({
    activate: function(state) {
      backbone.BaseView.prototype.activate.call(this, state);
      this.layout.upload.activate(state);
      return this;
    },

    events: {
      'click #validate-resources': function() {
        var goodTables = new Goodtables({method: 'post', report_type: 'grouped'});

        // Navigate to valifation results just once during series of API calls
        var navigateToResults = _.once(function(id) { window.ROUTER.navigate('/validation-results/' + id, {trigger: true}); });

        window.APP.layout.validationResultList.reset(new backbone.Collection());

        _.each(this.layout.form.getEditor('root.resources').rows, function(R) {
          goodTables.run(R.dataSource.data, JSON.stringify(R.dataSource.schema)).then(
            function(M) {
              // Validation completed
              window.APP.layout.validationResultList.collection

                // Grouped report has complicated structure
                .add(M.getGroupedByRows().map(function(SR) { return _.extend(_.values(SR)[0], {
                  headers: M.getHeaders(),
                  resource_id: R.key
                }); }));

              // Navigate between resources in validation results
              window.APP.layout.validationResultList.layout.tabs.add(new backbone.Model({
                title: R.getValue().path,

                // .key is a unique property among all resources rows
                url: '/validation-results/' + R.key
              }));

              navigateToResults(R.key);
            }
          );
        });
      }
    },

    initialize: function(options) {
      highlight.configure({useBR: true});
      return backbone.BaseView.prototype.initialize.call(this, options);
    },

    render: function() {
      this.layout.upload = new UploadView({el: window.APP.$('#upload-data-package'), parent: this});
      this.layout.registryList = new registry.ListView({el: window.APP.$('#registry-list'), container: '[data-id=list-container]', parent: this});
      return this;
    },

    // Utility method to remove empty values from object recursive
    compactObject: function(data) {
      _.each(data, function(v, k) {
        if(_.isEmpty(v)) {
          delete data[k];
        } else if(_.isArray(v) || _.isObject(v)) {
          v = this.compactObject(v);

          if(_.isArray(v))
            v = _.compact(v);

          if(_.isEmpty(v))
            delete data[k];
          else data[k] = v;
        }
      }, this);

      return data;
    },

    getFilledValues: function() { return this.compactObject(this.layout.form.getValue()); },
    getValue: function () { return this.layout.form.getValue(); },
    hasChanges: function() { return Boolean(this.changed); },

    reset: function(schema) {
      var formData;

      // Clean up previous state
      if(this.layout.form) {
        formData = this.getFilledValues();
        this.layout.form.destroy();
        this.layout.uploadData.undelegateEvents().remove();
      }

      this.layout.form = new JSONEditor(this.$('[data-id=form-container]').get(0), {
        schema: schema,
        theme: 'bootstrap3'
      });

      this.layout.uploadData = (new DataUploadView({
        el: this.layout.form.theme.getHeaderButtonHolder(),
        form: this.layout.form,
        parent: this
      })).render();

      this.layout.form.on('ready', (function() {
        // There is no any good way to bind events to custom button or even add cutsom button
        $(this.layout.form.getEditor('root.resources').container)
          .children('h3').append(this.layout.uploadData.el);

        // Detecting changes
        this.changed = false;

        // After `ready` event fired, editor fire `change` event regarding to the initial changes
        this.layout.form.on('change', _.after(2, (function() {
          this.changed = true;
          window.APP.layout.download.reset(this.layout.form.getValue()).activate();
          this.showResult();
        }).bind(this)));

        // If on the previous form was entered values try to apply it to new form
        if(formData) {
          this.layout.form.setValue(_.extend({}, this.layout.form.getValue(formData), formData));

          // Expand editors if it have value
          _.each(this.$('[data-schemapath][data-schemapath!=root]:has(.json-editor-btn-collapse)'), function(E) {
              if(_.isEmpty(this.layout.form.getEditor($(E).data('schemapath')).getValue()))
                $(E).find('.json-editor-btn-collapse').click();
          }, this);
        } else
          // Collapse all
          this.$('.row .json-editor-btn-collapse').click();
      }).bind(this));
    },

    showResult: function() {
      $('#json-code').html(highlight.fixMarkup(
        highlight.highlight('json', JSON.stringify(this.layout.form.getValue(), undefined, 2)).value
      ));

      return this;
    }
  })
};
<|endoftext|>


<commit_before>var getRepoUser = function (url) {
    var splittedUrl = url = url.split("/commit")[0].split('/');
    var repoUser = [];
    repoUser.push(splittedUrl.pop());
    repoUser.push(splittedUrl.pop());
    return repoUser;
}

var callback = function (state, ev) {
    if (!(ev.data && ev.data.html_url)) {
        emit("github-repository-error", "missingCommitOrMessageFound", ev.data);
    } else {
        var repoUser = getRepoUser(ev.data.html_url);
        {
            linkTo('repo-' + repoUser[1] + '-' + repoUser[0], ev);
        }
    }
};
fromStream('github-events')
.whenAny(callback);<commit_msg>S-63428 Deleted unused projection<commit_after><|endoftext|>


<commit_before>var fs = require("fs");
var g = require("../src/gitlet");
var testUtil = require("./test-util");

describe("remote", function() {
  beforeEach(testUtil.initTestDataDir);

  it("should throw if not in repo", function() {
    expect(function() { g.remote(); })
      .toThrow("not a Gitlet repository");
  });

  it("should throw if try to remove origin", function() {
    g.init();
    expect(function() { g.remote("remove"); }).toThrow("unsupported");
  });

  it("should store url when add origin", function() {
    g.init();
    g.remote("add", "origin", "git@origin");
    var configFileLines = fs.readFileSync(".gitlet/config", "utf8").split("\n");
    expect(configFileLines[0]).toEqual("[remote \"origin\"]");
    expect(configFileLines[1]).toEqual("  url = git@origin");
  });

  it("should store remote branch ref location when add origin", function() {
    g.init();
    g.remote("add", "origin", "git@origin");
    var configFileLines = fs.readFileSync(".gitlet/config", "utf8").split("\n");
    expect(configFileLines[0]).toEqual("[remote \"origin\"]");
  });

  it("should return newline when successfully add remote", function() {
    g.init();
    expect(g.remote("add", "origin", "git@origin")).toEqual("\n");
    var configFileLines = fs.readFileSync(".gitlet/config", "utf8").split("\n");
    expect(configFileLines[0]).toEqual("[remote \"origin\"]");
  });

  it("should be able to store more than one remote", function() {
    g.init();
    g.remote("add", "origin", "git@origin");
    g.remote("add", "heroku", "git@heroku");
    g.remote("add", "server", "git@server");
    var configFileLines = fs.readFileSync(".gitlet/config", "utf8").split("\n");
    expect(configFileLines[0]).toEqual("[remote \"origin\"]");
    expect(configFileLines[2]).toEqual("[remote \"heroku\"]");
    expect(configFileLines[4]).toEqual("[remote \"server\"]");
  });

  it("should throw if origin already exists", function() {
    g.init();
    g.remote("add", "origin", "git@origin");
    expect(function() { g.remote("add", "origin", "git@heroku"); })
      .toThrow("remote origin already exists");
  });
});
<commit_msg>Test can add remote to bare repo<commit_after>var fs = require("fs");
var g = require("../src/gitlet");
var testUtil = require("./test-util");

describe("remote", function() {
  beforeEach(testUtil.initTestDataDir);

  it("should throw if not in repo", function() {
    expect(function() { g.remote(); })
      .toThrow("not a Gitlet repository");
  });

  it("should throw if try to remove origin", function() {
    g.init();
    expect(function() { g.remote("remove"); }).toThrow("unsupported");
  });

  it("should store url when add origin", function() {
    g.init();
    g.remote("add", "origin", "git@origin");
    var configFileLines = fs.readFileSync(".gitlet/config", "utf8").split("\n");
    expect(configFileLines[0]).toEqual("[remote \"origin\"]");
    expect(configFileLines[1]).toEqual("  url = git@origin");
  });

  it("should be able to add remote to bare repo", function() {
    g.init({ bare: true });
    g.remote("add", "origin", "git@origin");
    var configFileLines = fs.readFileSync("config", "utf8").split("\n");
    expect(configFileLines[0]).toEqual("[remote \"origin\"]");
    expect(configFileLines[1]).toEqual("  url = git@origin");
  });

  it("should store remote branch ref location when add origin", function() {
    g.init();
    g.remote("add", "origin", "git@origin");
    var configFileLines = fs.readFileSync(".gitlet/config", "utf8").split("\n");
    expect(configFileLines[0]).toEqual("[remote \"origin\"]");
  });

  it("should return newline when successfully add remote", function() {
    g.init();
    expect(g.remote("add", "origin", "git@origin")).toEqual("\n");
    var configFileLines = fs.readFileSync(".gitlet/config", "utf8").split("\n");
    expect(configFileLines[0]).toEqual("[remote \"origin\"]");
  });

  it("should be able to store more than one remote", function() {
    g.init();
    g.remote("add", "origin", "git@origin");
    g.remote("add", "heroku", "git@heroku");
    g.remote("add", "server", "git@server");
    var configFileLines = fs.readFileSync(".gitlet/config", "utf8").split("\n");
    expect(configFileLines[0]).toEqual("[remote \"origin\"]");
    expect(configFileLines[2]).toEqual("[remote \"heroku\"]");
    expect(configFileLines[4]).toEqual("[remote \"server\"]");
  });

  it("should throw if origin already exists", function() {
    g.init();
    g.remote("add", "origin", "git@origin");
    expect(function() { g.remote("add", "origin", "git@heroku"); })
      .toThrow("remote origin already exists");
  });
});
<|endoftext|>


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

  var app = angular.module('radar.sessions');

  function factory(
    notificationService,
    $rootScope,
    adapter,
    $timeout,
    authService,
    $state
  ) {
    // Session length in seconds
    var sessionTimeout = null;

    // Warn user session is about to end
    var warningTimeout = null;
    var warningNotification = null;

    // Logout user just before session expires
    var logoutTimeout = null;

    $rootScope.$on('sessions.login', extend);
    $rootScope.$on('sessions.refresh', extend);
    $rootScope.$on('sessions.logout', cancel);

    return {
      init: init
    };

    function init() {
      adapter.get('/environment').then(function(response) {
        sessionTimeout = response.data.sessionTimeout;
      });
    }

    function extend() {
      cancel();

      if (sessionTimeout !== null) {
        // Warn 3 minutes before session is due to end
        var warningDelay = (sessionTimeout - (3 * 60)) * 1000;

        warningTimeout = $timeout(function() {
          warningNotification = notificationService.warn({
            message: 'Session is about to expire.',
            timeout: 0
          });
        }, warningDelay);

        // Logout 1 minute before session is due to end
        var logoutDelay = (sessionTimeout - 60) * 1000;

        logoutTimeout = $timeout(function() {
          notificationService.info({
            message: 'You were logged out due to inactivity.',
            timeout: 0
          });
          authService.logout();
          $state.go('login');
        }, logoutDelay);
      }
    }

    function cancel() {
      if (warningNotification !== null) {
        warningNotification.remove();
        warningNotification = null;
      }

      if (warningTimeout !== null) {
        $timeout.cancel(warningTimeout);
        warningTimeout = null;
      }

      if (logoutTimeout !== null) {
        $timeout.cancel(logoutTimeout);
        logoutTimeout = null;
      }
    }
  }

  factory.$inject = [
    'notificationService',
    '$rootScope',
    'adapter',
    '$timeout',
    'authService',
    '$state'
  ];

  app.factory('sessionTimeoutService', factory);
})();
<commit_msg>Hide inactivity message on login<commit_after>(function() {
  'use strict';

  var app = angular.module('radar.sessions');

  function factory(
    notificationService,
    $rootScope,
    adapter,
    $timeout,
    authService,
    $state
  ) {
    // Session length in seconds
    var sessionTimeout = null;

    // Warn user session is about to end
    var warningTimeout = null;
    var warningNotification = null;

    // Logout user just before session expires
    var logoutTimeout = null;
    var logoutNotification = null;

    $rootScope.$on('sessions.login', extend);
    $rootScope.$on('sessions.refresh', extend);
    $rootScope.$on('sessions.logout', cancel);

    return {
      init: init
    };

    function init() {
      adapter.get('/environment').then(function(response) {
        sessionTimeout = response.data.sessionTimeout;
      });
    }

    function extend() {
      cancel();

      if (sessionTimeout !== null) {
        // Warn 3 minutes before session is due to end
        var warningDelay = (sessionTimeout - (3 * 60)) * 1000;

        warningTimeout = $timeout(function() {
          warningNotification = notificationService.warn({
            message: 'Session is about to expire.',
            timeout: 0
          });
        }, warningDelay);

        // Logout 1 minute before session is due to end
        var logoutDelay = (sessionTimeout - 60) * 1000;

        logoutTimeout = $timeout(function() {
          logoutNotification = notificationService.info({
            message: 'You were logged out due to inactivity.',
            timeout: 0
          });
          authService.logout();
          $state.go('login');
        }, logoutDelay);
      }
    }

    function cancel() {
      if (warningNotification !== null) {
        warningNotification.remove();
        warningNotification = null;
      }

      if (warningTimeout !== null) {
        $timeout.cancel(warningTimeout);
        warningTimeout = null;
      }

      if (logoutTimeout !== null) {
        $timeout.cancel(logoutTimeout);
        logoutTimeout = null;
      }

      if (logoutNotification !== null) {
        logoutNotification.remove();
        logoutNotification = null;
      }
    }
  }

  factory.$inject = [
    'notificationService',
    '$rootScope',
    'adapter',
    '$timeout',
    'authService',
    '$state'
  ];

  app.factory('sessionTimeoutService', factory);
})();
<|endoftext|>


<commit_before>/*jslint browser: true, plusplus: true */
/*global jQuery, UWCanvas */

// DESIGN TOOLS CONFIG
// Copyright (C) 2016  Utah State University
var DT_variables = {
    iframeID: '',
    // Path to the hosted USU Design Tools
    path: 'https://designtools.ciditools.com/',
    templateCourse: '1190741',
    // OPTIONAL: Button will be hidden from view until launched using shortcut keys
    hideButton: true,
    // OPTIONAL: Limit tools loading by users role
    limitByRole: false, // set to true to limit to roles in the roleArray
    // adjust roles as needed: 'student', 'teacher', ...
    roleArray: [],
    // OPTIONAL: Limit tools to an array of Canvas user IDs
    limitByUser: false, // Change to true to limit by user
    // add users to array (Canvas user ID not SIS user ID)
    userArray: []
};

window.eesyLaunchConfig = {
    host: 'uw.eesysoft.com',
    key: 'yrLJv5Hs',
    supportTab: true
};

(function ($) {
    'use strict';

    var now = new Date().getTime();

    // EesySoft
    $.getScript('//' + window.eesyLaunchConfig.host + '/resources/js/canvas/launch.js?stmp=' + now);

    $(document).ready(function () {
        // Design Tools JS
        $.getScript(DT_variables.path + 'js/master_controls.js');

        // Design Tools Mobile JS
        //$.getScript(DT_variables.path + 'js/tools_liveView_app.js?' + now);

        // Atomic Search JS
        $.getScript('https://d2u53n8918fnto.cloudfront.net/atomic_search_widget.js?ts=' + now);
    });
}(jQuery));
<commit_msg>updates ischool config<commit_after>/*jslint browser: true, plusplus: true */
/*global jQuery, UWCanvas */

// DESIGN TOOLS CONFIG
// Copyright (C) 2016  Utah State University
var DT_variables = {
    iframeID: '',
    // Path to the hosted USU Design Tools
    path: 'https://designtools.ciditools.com/',
    templateCourse: '1190741',
    // OPTIONAL: Button will be hidden from view until launched using shortcut keys
    hideButton: true,
    // OPTIONAL: Limit tools loading by users role
    limitByRole: false, // set to true to limit to roles in the roleArray
    // adjust roles as needed: 'student', 'teacher', ...
    roleArray: [],
    // OPTIONAL: Limit tools to an array of Canvas user IDs
    limitByUser: false, // Change to true to limit by user
    // add users to array (Canvas user ID not SIS user ID)
    userArray: []
};

if (window.location.hostname === 'canvas.uw.edu') {
    window.eesyLaunchConfig = {
        host: 'uw.eesysoft.com',
        key: 'yrLJv5Hs',
        supportTab: true
    };
} else {
    window.eesyLaunchConfig = {
        host: 'uwstaging.eesysoft.com',
        key: '5M2g7rk9',
        supportTab: true
    };
}

(function ($) {
    'use strict';

    var now = new Date().getTime();

    // EesySoft
    $.getScript('//' + window.eesyLaunchConfig.host + '/resources/js/canvas/launch.js?stmp=' + now);

    $(document).ready(function () {
        // Design Tools JS
        $.getScript(DT_variables.path + 'js/master_controls.js');

        // Design Tools Mobile JS
        //$.getScript(DT_variables.path + 'js/tools_liveView_app.js?' + now);

        // Atomic Search JS
        $.getScript('https://d2u53n8918fnto.cloudfront.net/atomic_search_widget.js?ts=' + now);
    });
}(jQuery));
<|endoftext|>


<commit_before>// @flow
import styles from './Highlight.less';
import React from 'react';
import classnames from 'classnames';
import { TONE } from '../private/tone';

type Props = {
  children: React$Node,
  secondary?: boolean,
  className?: string,
  tone: typeof TONE.CRITICAL | typeof TONE.NEUTRAL
};

export default function Highlight(props: Props) {
  const { children, secondary, tone = TONE.NEUTRAL, className, ...restProps } = props;

  return (
    <mark
      {...restProps}
      className={classnames({
        [styles.root]: true,
        [styles.secondaryText]: secondary,
        [styles[tone]]: true,
        ...(className ? { [className]: className } : {})
      })}>
      {children}
    </mark>
  );
}
<commit_msg>fix(Highlight): Do not require tone as it is defaulted (#569)<commit_after>// @flow
import styles from './Highlight.less';
import React from 'react';
import classnames from 'classnames';
import { TONE } from '../private/tone';

type Props = {
  children: React$Node,
  secondary?: boolean,
  className?: string,
  tone?: typeof TONE.CRITICAL | typeof TONE.NEUTRAL
};

export default function Highlight(props: Props) {
  const { children, secondary, tone = TONE.NEUTRAL, className, ...restProps } = props;

  return (
    <mark
      {...restProps}
      className={classnames({
        [styles.root]: true,
        [styles.secondaryText]: secondary,
        [styles[tone]]: true,
        ...(className ? { [className]: className } : {})
      })}>
      {children}
    </mark>
  );
}
<|endoftext|>