<commit_before>!function(t){"use strict";function n(){var t=new ArrayBuffer(4),n=new Uint8Array(t),r=new Uint32Array(t);if(n[0]=161,n[1]=178,n[2]=195,n[3]=212,3569595041===r[0])return i.ENDIANNESS.LITTLE_ENDIAN;if(2712847316===r[0])return i.ENDIANNESS.BIG_ENDIAN;throw new Error("Unrecognized endianness")}function i(t,r,e){return this instanceof i?(this._blob=t,this._position=0,this._queue=[],this._currentEndianness=e||n(),this._dataEndianness=r||this._currentEndianness,this._pendingTask=!1,void(this._currentResult=null)):new i(t,r,e)}function r(){var t=this._queue.shift();if(t){if(this._position+t.count>this._blob.size)throw new Error("Limit reached. Trying to read "+(this._position+t.count)+" bytes out of "+this._blob.size+".");var n=new FileReader;this._pendingTask=!0,n.onload=function(n){var i=n.target.result;this._pendingTask=!1,t.cb(i),r.call(this)}.bind(this),n.onerror=function(){throw new Error("Error while reading the blob")},t.type||(t.type=i.BINARY_STRING),n["readAs"+t.type](this._blob.slice(this._position,this._position+t.count)),this._position+=t.count}}function e(t,n){for(var i=0;i<t.length;i+=1)t[i]=n(t[i]);return t}function s(t,n,i,r){this._currentResult||(this._currentResult={}),n=(n||1)*i;var e=function(n){var e=8*i,s=window["Uint"+e+"Array"];n=new s(n),this._currentEndianness!==r&&(n=o["swap"+e](n)),this._currentResult[t]=n}.bind(this);return this.readArrayBuffer(n,e)}i.ARRAY_BUFFER="ArrayBuffer",i.BINARY_STRING="BinaryString",i.TEXT="Text",i.DATA_URL="DataURL",i.ENDIANNESS={BIG_ENDIAN:"BIG_ENDIAN",LITTLE_ENDIAN:"LITTLE_ENDIAN"},i.prototype.setDataEndianness=function(t){this._dataEndianness=t},i.prototype.read=function(t,n,i){return"string"==typeof t&&(i=n,t=void 0,n=t),void 0===t&&(t=this._blob.size-this._position),"function"==typeof t&&(i=t,n=void 0,t=this._blob.size-this._position),"function"==typeof n&&(i=n,n=void 0),this._queue.push({count:t,cb:i,type:n}),this._pendingTask||r.call(this),this},i.prototype.readText=function(t,n){return this.read(t,i.TEXT,n)},i.prototype.readArrayBuffer=function(t,n){return this.read(t,i.ARRAY_BUFFER,n)},i.prototype.readBinaryString=function(t,n){return this.read(t,i.BINARY_STRING,n)},i.prototype.readDataURL=function(t,n){return this.read(t,i.DATA_URL,n)};var o={swap8:function(t){return e(t,function(t){return t})},swap16:function(t){return e(t,function(t){return(255&t)<<8|t>>8&255})},swap32:function(t){return e(t,function(t){return(255&t)<<24|(65280&t)<<8|t>>8&65280|t>>24&255})}};i.prototype.readUint8=function(t,n,i){return s.call(this,t,n,1,i||this._dataEndianness)},i.prototype.readUint16=function(t,n,i){return s.call(this,t,n,2,i||this._dataEndianness)},i.prototype.readUint32=function(t,n,i){return s.call(this,t,n,4,i||this._dataEndianness)},i.prototype.readBlob=function(t,n){var i=this._blob.slice(this._position,this._position+n);return this._queue.push({count:n,cb:function(){this._currentResult[t]=i}.bind(this)}),this},i.prototype.commit=function(t){if(!this._currentResult)throw new Error("Cannot commit without any reads");var n=this._currentResult,r={count:0,type:i.ARRAY_BUFFER,cb:function(){t(n),this._currentResult=null}.bind(this)};return this._queue.push(r),this},t.BlobReader=i}(window);<commit_msg>Update dist<commit_after>!function(t){"use strict";function n(){var t=new ArrayBuffer(4),n=new Uint8Array(t),r=new Uint32Array(t);if(n[0]=161,n[1]=178,n[2]=195,n[3]=212,3569595041===r[0])return i.ENDIANNESS.LITTLE_ENDIAN;if(2712847316===r[0])return i.ENDIANNESS.BIG_ENDIAN;throw new Error("Unrecognized endianness")}function i(t,r,e){return this instanceof i?(this._blob=t,this._position=0,this._queue=[],this._currentEndianness=e||n(),this._dataEndianness=r||this._currentEndianness,this._pendingTask=!1,void(this._currentResult=null)):new i(t,r,e)}function r(){function t(t){n.cb(t),this._pendingTask=!1,this._position+=n.count,r.call(this)}var n=this._queue.shift();if(n){if(void 0===n.count&&(n.count=this._blob.size-this._position),this._position+n.count>this._blob.size)throw new Error("Limit reached. Trying to read "+(this._position+n.count)+" bytes out of "+this._blob.size+".");n.type||(n.type=i.BINARY_STRING);var e=this._blob.slice(this._position,this._position+n.count);if(n.type===i.BLOB)t.call(this,e);else{var o=new FileReader;this._pendingTask=!0,o.onload=function(n){t.call(this,n.target.result)}.bind(this),o.onerror=function(){throw new Error("Error while reading the blob")},o["readAs"+n.type](e)}}}function e(t,n){for(var i=0;i<t.length;i+=1)t[i]=n(t[i]);return t}function o(t,n,i,r){this._currentResult||(this._currentResult={}),n=(n||1)*i;var e=function(e){var o=8*i,u=window["Uint"+o+"Array"];e=new u(e),this._currentEndianness!==r&&(e=s["swap"+o](e)),n===i&&(e=e[0]),this._currentResult[t]=e}.bind(this);return this.readArrayBuffer(n,e)}i.ARRAY_BUFFER="ArrayBuffer",i.BINARY_STRING="BinaryString",i.TEXT="Text",i.DATA_URL="DataURL",i.BLOB="Blob",i.ENDIANNESS={BIG_ENDIAN:"BIG_ENDIAN",LITTLE_ENDIAN:"LITTLE_ENDIAN"},i.prototype.setDataEndianness=function(t){this._dataEndianness=t},i.prototype.read=function(t,n,i){return"string"==typeof t&&(i=n,t=void 0,n=t),"function"==typeof t&&(i=t,t=void 0),"function"==typeof n&&(i=n,n=void 0),this._queue.push({count:t,cb:i,type:n}),this._pendingTask||r.call(this),this},i.prototype.readText=function(t,n){return this.read(t,i.TEXT,n)},i.prototype.readArrayBuffer=function(t,n){return this.read(t,i.ARRAY_BUFFER,n)},i.prototype.readBinaryString=function(t,n){return this.read(t,i.BINARY_STRING,n)},i.prototype.readDataURL=function(t,n){return this.read(t,i.DATA_URL,n)};var s={swap8:function(t){return e(t,function(t){return t})},swap16:function(t){return e(t,function(t){return(255&t)<<8|t>>8&255})},swap32:function(t){return e(t,function(t){return(255&t)<<24|(65280&t)<<8|t>>8&65280|t>>24&255})}};i.prototype.readUint8=function(t,n,i){return o.call(this,t,n,1,i||this._dataEndianness)},i.prototype.readUint16=function(t,n,i){return o.call(this,t,n,2,i||this._dataEndianness)},i.prototype.readUint32=function(t,n,i){return o.call(this,t,n,4,i||this._dataEndianness)},i.prototype.readBlob=function(t,n){return this._queue.push({count:n,type:i.BLOB,cb:function(n){this._currentResult[t]=n}.bind(this)}),this},i.prototype.skip=function(t){return t=t||1,this._queue.push({count:t,type:i.BLOB,cb:function(){}}),this},i.prototype.commit=function(t){if(!this._currentResult)throw new Error("Cannot commit without any reads");var n=this._currentResult,r={count:0,type:i.BLOB,cb:function(){t(n),this._currentResult=null}.bind(this)};return this._queue.push(r),this},t.BlobReader=i}(window);<|endoftext|>


<commit_before>/**
 * 常用正则
 * */
export default {
  // 整数(包含正负)
  integer: {
    type: 'number',
    regexp: /^-?[1-9]\d*$/
  },
  // 正整数
  positiveInteger: {
    type: 'number',
    regexp: /^[1-9]\d*$/
  },
  // 负整数
  negativeInteger: {
    type: 'number',
    regexp: /^-[1-9]\d*$/
  },
  // 邮箱
  email: {
    type: 'email',
    regexp: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/
  },
  // IP地址
  ip: {
    type: 'number',
    regexp: /(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)/
  },
  // 身份证 text
  idCard: {
    type: 'text',
    regexp (num) {
      if (!num) return false
      num = num.toUpperCase()
      const cityCode = {
        11: '北京',
        12: '天津',
        13: '河北',
        14: '山西',
        15: '内蒙古',
        21: '辽宁',
        22: '吉林',
        23: '黑龙江 ',
        31: '上海',
        32: '江苏',
        33: '浙江',
        34: '安徽',
        35: '福建',
        36: '江西',
        37: '山东',
        41: '河南',
        42: '湖北 ',
        43: '湖南',
        44: '广东',
        45: '广西',
        46: '海南',
        50: '重庆',
        51: '四川',
        52: '贵州',
        53: '云南',
        54: '西藏 ',
        61: '陕西',
        62: '甘肃',
        63: '青海',
        64: '宁夏',
        65: '新疆',
        71: '台湾',
        81: '香港',
        82: '澳门',
        91: '国外 '
      }

      if (!cityCode[num.substr(0, 2)]) {
        console.debug('地址编码错误')
        return false
      }
      // 身份证号码为15位或者18位，15位时全为数字，18位前17位为数字，最后一位是校验位，可能为数字或字符X。
      if (!/(^\d{15}$)|(^\d{17}([0-9]|X)$)/.test(num)) {
        console.debug('输入的身份证号长度不对，或者号码不符合规定！\n15位号码应全为数字，18位号码末位可以为数字或X。')
        return false
      }
      // 校验位按照ISO 7064:1983.MOD 11-2的规定生成，X可以认为是数字10。
      // 下面分别分析出生日期和校验位
      var re, len, arrSplit, dtmBirth, bGoodDay, arrInt, arrCh, nTemp, k
      len = num.length
      /* istanbul ignore if */
      if (len === 15) {
        re = new RegExp(/^(\d{6})(\d{2})(\d{2})(\d{2})(\d{3})$/)
        arrSplit = num.match(re)

        // 检查生日日期是否正确
        dtmBirth = new Date(
          '19' + arrSplit[2] + '/' + arrSplit[3] + '/' + arrSplit[4]
        )
        bGoodDay =
          dtmBirth.getYear() === Number(arrSplit[2]) &&
          dtmBirth.getMonth() + 1 === Number(arrSplit[3]) &&
          dtmBirth.getDate() === Number(arrSplit[4])
        if (!bGoodDay) {
          console.debug('输入的身份证号里出生日期不对！')
          return false
        } else {
          // 将15位身份证转成18位
          // 校验位按照ISO 7064:1983.MOD 11-2的规定生成，X可以认为是数字10。
          arrInt = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
          arrCh = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2']
          nTemp = 0
          num = num.substr(0, 6) + '19' + num.substr(6, num.length - 6)
          for (k = 0; k < 17; k++) {
            nTemp += num.substr(k, 1) * arrInt[k]
          }
          num += arrCh[nTemp % 11]
          return true
        }
      }
      if (len === 18) {
        re = new RegExp(/^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/)
        arrSplit = num.match(re)

        // 检查生日日期是否正确
        dtmBirth = new Date(arrSplit[2] + '/' + arrSplit[3] + '/' + arrSplit[4])
        bGoodDay =
          dtmBirth.getFullYear() === Number(arrSplit[2]) &&
          dtmBirth.getMonth() + 1 === Number(arrSplit[3]) &&
          dtmBirth.getDate() === Number(arrSplit[4])
        if (!bGoodDay) {
          console.debug('输入的身份证号里出生日期不对！')
          return false
        } else {
          // 检验18位身份证的校验码是否正确。
          // 校验位按照ISO 7064:1983.MOD 11-2的规定生成，X可以认为是数字10。
          var valnum
          arrInt = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
          arrCh = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2']
          nTemp = 0
          for (k = 0; k < 17; k++) {
            nTemp += num.substr(k, 1) * arrInt[k]
          }
          valnum = arrCh[nTemp % 11]
          if (valnum !== num.substr(17, 1)) {
            console.debug('18位身份证的校验码不正确！应该为：' + num.substr(17, 1) + '->' + valnum)
            return false
          }
          return true
        }
      }
      /* istanbul ignore next */
      return false
    }
  },
  // 密码需6-18位，以字母开头可含数字
  password: {
    type: 'password',
    regexp: /^[a-zA-Z]\w{5,17}$/
  },
  // 国内电话, 正确格式为：XXXX-XXXXXXX，XXXX- XXXXXXXX，XXX-XXXXXXX，XXX-XXXXXXXX，XXXXXXX，XXXXXXXX。
  tel: {
    type: 'tel',
    regexp: /^(\(\d{3,4}\)|\d{3,4}-)?\d{7,8}$/
  },
  // 国内手机号, 13/14/15/18/17开头
  mobile: {
    type: 'tel',
    regexp: /^((13[0-9])|(14[0-9])|(15[0-9])|(18[0-9])|(17[0-9]))\d{8}$/
  },
  // 验证汉字
  cn: {
    type: 'text',
    regexp: /[\u4e00-\u9fa5]/
  },
  // 验证码, 至少4位
  securityCode: {
    type: 'number',
    regexp: /^\d{4,}$/
  },
  // 昵称: 可由中英文字母、数字、"-"、"_"组成。
  nickName: {
    type: 'text',
    regexp: /[A-Za-z0-9_\-\u4e00-\u9fa5]+/
  },
  // qq: 1-9开头，最少5位。
  qq: {
    type: 'number',
    regexp: /^[1-9][0-9]{4,}$/
  },
  // 网址URL, 必须以(https|http|ftp|rtsp|mms)开头
  url: {
    type: 'url',
    regexp: /^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+/
  }
}
<commit_msg>chore: log信息在非开发模式使用<commit_after>/**
 * 常用正则
 * */
export default {
  // 整数(包含正负)
  integer: {
    type: 'number',
    regexp: /^-?[1-9]\d*$/
  },
  // 正整数
  positiveInteger: {
    type: 'number',
    regexp: /^[1-9]\d*$/
  },
  // 负整数
  negativeInteger: {
    type: 'number',
    regexp: /^-[1-9]\d*$/
  },
  // 邮箱
  email: {
    type: 'email',
    regexp: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/
  },
  // IP地址
  ip: {
    type: 'number',
    regexp: /(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)/
  },
  // 身份证 text
  idCard: {
    type: 'text',
    regexp (num) {
      if (!num) return false
      num = num.toUpperCase()
      const cityCode = {
        11: '北京',
        12: '天津',
        13: '河北',
        14: '山西',
        15: '内蒙古',
        21: '辽宁',
        22: '吉林',
        23: '黑龙江 ',
        31: '上海',
        32: '江苏',
        33: '浙江',
        34: '安徽',
        35: '福建',
        36: '江西',
        37: '山东',
        41: '河南',
        42: '湖北 ',
        43: '湖南',
        44: '广东',
        45: '广西',
        46: '海南',
        50: '重庆',
        51: '四川',
        52: '贵州',
        53: '云南',
        54: '西藏 ',
        61: '陕西',
        62: '甘肃',
        63: '青海',
        64: '宁夏',
        65: '新疆',
        71: '台湾',
        81: '香港',
        82: '澳门',
        91: '国外 '
      }

      if (!cityCode[num.substr(0, 2)]) {
        if (process.env.NODE_ENV !== 'production') {
          console.log('地址编码错误')
        }
        return false
      }
      // 身份证号码为15位或者18位，15位时全为数字，18位前17位为数字，最后一位是校验位，可能为数字或字符X。
      if (!/(^\d{15}$)|(^\d{17}([0-9]|X)$)/.test(num)) {
        if (process.env.NODE_ENV !== 'production') {
          console.log('输入的身份证号长度不对，或者号码不符合规定！\n15位号码应全为数字，18位号码末位可以为数字或X。')
        }
        return false
      }
      // 校验位按照ISO 7064:1983.MOD 11-2的规定生成，X可以认为是数字10。
      // 下面分别分析出生日期和校验位
      var re, len, arrSplit, dtmBirth, bGoodDay, arrInt, arrCh, nTemp, k
      len = num.length
      /* istanbul ignore if */
      if (len === 15) {
        re = new RegExp(/^(\d{6})(\d{2})(\d{2})(\d{2})(\d{3})$/)
        arrSplit = num.match(re)

        // 检查生日日期是否正确
        dtmBirth = new Date(
          '19' + arrSplit[2] + '/' + arrSplit[3] + '/' + arrSplit[4]
        )
        bGoodDay =
          dtmBirth.getYear() === Number(arrSplit[2]) &&
          dtmBirth.getMonth() + 1 === Number(arrSplit[3]) &&
          dtmBirth.getDate() === Number(arrSplit[4])
        if (!bGoodDay) {
          if (process.env.NODE_ENV !== 'production') {
            console.log('输入的身份证号里出生日期不对！')
          }
          return false
        } else {
          // 将15位身份证转成18位
          // 校验位按照ISO 7064:1983.MOD 11-2的规定生成，X可以认为是数字10。
          arrInt = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
          arrCh = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2']
          nTemp = 0
          num = num.substr(0, 6) + '19' + num.substr(6, num.length - 6)
          for (k = 0; k < 17; k++) {
            nTemp += num.substr(k, 1) * arrInt[k]
          }
          num += arrCh[nTemp % 11]
          return true
        }
      }
      if (len === 18) {
        re = new RegExp(/^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/)
        arrSplit = num.match(re)

        // 检查生日日期是否正确
        dtmBirth = new Date(arrSplit[2] + '/' + arrSplit[3] + '/' + arrSplit[4])
        bGoodDay =
          dtmBirth.getFullYear() === Number(arrSplit[2]) &&
          dtmBirth.getMonth() + 1 === Number(arrSplit[3]) &&
          dtmBirth.getDate() === Number(arrSplit[4])
        if (!bGoodDay) {
          if (process.env.NODE_ENV !== 'production') {
            console.log('输入的身份证号里出生日期不对！')
          }
          return false
        } else {
          // 检验18位身份证的校验码是否正确。
          // 校验位按照ISO 7064:1983.MOD 11-2的规定生成，X可以认为是数字10。
          var valnum
          arrInt = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
          arrCh = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2']
          nTemp = 0
          for (k = 0; k < 17; k++) {
            nTemp += num.substr(k, 1) * arrInt[k]
          }
          valnum = arrCh[nTemp % 11]
          if (valnum !== num.substr(17, 1)) {
            if (process.env.NODE_ENV !== 'production') {
              console.log('18位身份证的校验码不正确！应该为：' + num.substr(17, 1) + '->' + valnum)
            }
            return false
          }
          return true
        }
      }
      /* istanbul ignore next */
      return false
    }
  },
  // 密码需6-18位，以字母开头可含数字
  password: {
    type: 'password',
    regexp: /^[a-zA-Z]\w{5,17}$/
  },
  // 国内电话, 正确格式为：XXXX-XXXXXXX，XXXX- XXXXXXXX，XXX-XXXXXXX，XXX-XXXXXXXX，XXXXXXX，XXXXXXXX。
  tel: {
    type: 'tel',
    regexp: /^(\(\d{3,4}\)|\d{3,4}-)?\d{7,8}$/
  },
  // 国内手机号, 13/14/15/18/17开头
  mobile: {
    type: 'tel',
    regexp: /^((13[0-9])|(14[0-9])|(15[0-9])|(18[0-9])|(17[0-9]))\d{8}$/
  },
  // 验证汉字
  cn: {
    type: 'text',
    regexp: /[\u4e00-\u9fa5]/
  },
  // 验证码, 至少4位
  securityCode: {
    type: 'number',
    regexp: /^\d{4,}$/
  },
  // 昵称: 可由中英文字母、数字、"-"、"_"组成。
  nickName: {
    type: 'text',
    regexp: /[A-Za-z0-9_\-\u4e00-\u9fa5]+/
  },
  // qq: 1-9开头，最少5位。
  qq: {
    type: 'number',
    regexp: /^[1-9][0-9]{4,}$/
  },
  // 网址URL, 必须以(https|http|ftp|rtsp|mms)开头
  url: {
    type: 'url',
    regexp: /^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+/
  }
}
<|endoftext|>


<commit_before>odoo.define('pos_multi_session_restaurant', function(require){
    var screens = require('point_of_sale.screens');
    var models = require('point_of_sale.models');
    var floors = require('pos_restaurant.floors');
    var core = require('web.core');
    var gui = require('point_of_sale.gui');

    var FloorScreenWidget;
    console.log('gui', gui.Gui.prototype.screen_classes);
    _.each(gui.Gui.prototype.screen_classes, function(){
        if (this.name == 'floors'){
            FloorScreenWidget = this.widget;
            FloorScreenWidget.include({
                start: function () {
                    var self = this;
                    this._super();
                    this.pos.bind('change:orders-count-on-floor-screen', function () {
                        self.renderElement();
                    })
                }
            })
            return false;
        }
    });
    var _t = core._t;

    screens.OrderWidget.include({
        update_summary: function(){
            var order = this.pos.get('selectedOrder');
            if (order){
                this._super();
            }
        }
    });

    var PosModelSuper = models.PosModel;
    models.PosModel = models.PosModel.extend({
        initialize: function(){
            var self = this;
            PosModelSuper.prototype.initialize.apply(this, arguments)
            this.ms_table = false;
        },
        ms_create_order: function(options){
            var self = this;
            var order = PosModelSuper.prototype.ms_create_order.apply(this, arguments);
            if (options.data.table_id) {
                order.table = self.tables_by_id[options.data.table_id];
                order.customer_count = options.data.customer_count;
                order.save_to_db();
            }
            else if (this.ms_table){
                order.table = this.ms_table;
                order.save_to_db();
            }
            return order;
        },
        ms_do_update: function(order, data){
           PosModelSuper.prototype.ms_do_update.apply(this, arguments);
            if (order) {
                order.customer_count = data.customer_count;
                order.set_customer_count(data.customer_count, true);
                this.gui.screen_instances['products'].action_buttons['guests'].renderElement();
            }
        },
        ms_orders_to_sync: function(){
            var self = this;
            if (!this.ms_table){
                return PosModelSuper.prototype.ms_orders_to_sync.apply(this, arguments)
            }
            return this.get('orders').filter(function(r){
                       return r.table === self.ms_table;
                   })
        },
        ms_on_add_order: function(current_order){
            if (!current_order && this.ms_table){
                // no current_order, because we on floor screen
                _.each(this.get('orders').models, function(o){
                    if (o.table === this.ms_table && o.ms_replace_empty_order && o.is_empty()){
                        o.destroy({'reason': 'abandon'})
                    }
                })
                this.trigger('change:orders-count-on-floor-screen');
            }else{
                PosModelSuper.prototype.ms_on_add_order.apply(this, arguments)
            }
        }
    });

    var OrderSuper = models.Order;
    models.Order = models.Order.extend({
        set_customer_count: function (count, skip_ms_update) {
            OrderSuper.prototype.set_customer_count.apply(this, arguments);
            if (!skip_ms_update) {
                this.ms_update();
            }
        },
    });
});
<commit_msg>[FIX] del row<commit_after>odoo.define('pos_multi_session_restaurant', function(require){
    var screens = require('point_of_sale.screens');
    var models = require('point_of_sale.models');
    var floors = require('pos_restaurant.floors');
    var core = require('web.core');
    var gui = require('point_of_sale.gui');

    var FloorScreenWidget;
    console.log('gui', gui.Gui.prototype.screen_classes);
    _.each(gui.Gui.prototype.screen_classes, function(){
        if (this.name == 'floors'){
            FloorScreenWidget = this.widget;
            FloorScreenWidget.include({
                start: function () {
                    var self = this;
                    this._super();
                    this.pos.bind('change:orders-count-on-floor-screen', function () {
                        self.renderElement();
                    })
                }
            })
            return false;
        }
    });
    var _t = core._t;

    screens.OrderWidget.include({
        update_summary: function(){
            var order = this.pos.get('selectedOrder');
            if (order){
                this._super();
            }
        }
    });

    var PosModelSuper = models.PosModel;
    models.PosModel = models.PosModel.extend({
        initialize: function(){
            var self = this;
            PosModelSuper.prototype.initialize.apply(this, arguments)
            this.ms_table = false;
        },
        ms_create_order: function(options){
            var self = this;
            var order = PosModelSuper.prototype.ms_create_order.apply(this, arguments);
            if (options.data.table_id) {
                order.table = self.tables_by_id[options.data.table_id];
                order.customer_count = options.data.customer_count;
                order.save_to_db();
            }
            else if (this.ms_table){
                order.table = this.ms_table;
                order.save_to_db();
            }
            return order;
        },
        ms_do_update: function(order, data){
           PosModelSuper.prototype.ms_do_update.apply(this, arguments);
            if (order) {
                order.set_customer_count(data.customer_count, true);
                this.gui.screen_instances['products'].action_buttons['guests'].renderElement();
            }
        },
        ms_orders_to_sync: function(){
            var self = this;
            if (!this.ms_table){
                return PosModelSuper.prototype.ms_orders_to_sync.apply(this, arguments)
            }
            return this.get('orders').filter(function(r){
                       return r.table === self.ms_table;
                   })
        },
        ms_on_add_order: function(current_order){
            if (!current_order && this.ms_table){
                // no current_order, because we on floor screen
                _.each(this.get('orders').models, function(o){
                    if (o.table === this.ms_table && o.ms_replace_empty_order && o.is_empty()){
                        o.destroy({'reason': 'abandon'})
                    }
                })
                this.trigger('change:orders-count-on-floor-screen');
            }else{
                PosModelSuper.prototype.ms_on_add_order.apply(this, arguments)
            }
        }
    });

    var OrderSuper = models.Order;
    models.Order = models.Order.extend({
        set_customer_count: function (count, skip_ms_update) {
            OrderSuper.prototype.set_customer_count.apply(this, arguments);
            if (!skip_ms_update) {
                this.ms_update();
            }
        },
    });
});
<|endoftext|>


<commit_before>import { ipcMain as ipc } from 'electron';
import { join } from 'path';

const KERNEL_SPECS = {
  node_nteract: {
    name: 'node_nteract',
    spec: {
      argv: [
        process.execPath,
        join(require.resolve('ijavascript'), '..', 'lib', 'kernel.js'),
        '{connection_file}',
        '--protocol=5.0',
        '--hide-undefined'
      ],
      display_name: 'Node.js (nteract)',
      language: 'javascript',
      env: {
        ELECTRON_RUN_AS_NODE: '1'
      }
    }
  },
  python3: {
    name: 'python3',
    spec: {
      language: 'python',
      display_name: 'Python 3',
      argv: [
        '/Users/phantom/.tellurium/python-3.6.0/bin/python3',
        '-m',
        'ipykernel',
        '-f',
        '{connection_file}'
      ]
    }
  }
};

export default function initializeKernelSpecs(kernelSpecs) {
  // Object.assign(KERNEL_SPECS, kernelSpecs);
  return KERNEL_SPECS;
}

ipc.on('kernel_specs_request', (event) => {
  event.sender.send('kernel_specs_reply', KERNEL_SPECS);
});
<commit_msg>find home directory programmatically for built-in python3 kernel<commit_after>import { app, ipcMain as ipc } from 'electron';
import { join } from 'path';

const KERNEL_SPECS = {
  node_nteract: {
    name: 'node_nteract',
    spec: {
      argv: [
        process.execPath,
        join(require.resolve('ijavascript'), '..', 'lib', 'kernel.js'),
        '{connection_file}',
        '--protocol=5.0',
        '--hide-undefined'
      ],
      display_name: 'Node.js (nteract)',
      language: 'javascript',
      env: {
        ELECTRON_RUN_AS_NODE: '1'
      }
    }
  },
  python3: {
    name: 'python3',
    spec: {
      language: 'python',
      display_name: 'Python 3',
      argv: [
        join(app.getPath('home'),'.tellurium','python-3.6.0','bin','python3'),
        '-m',
        'ipykernel',
        '-f',
        '{connection_file}'
      ]
    }
  }
};

export default function initializeKernelSpecs(kernelSpecs) {
  // Object.assign(KERNEL_SPECS, kernelSpecs);
  return KERNEL_SPECS;
}

ipc.on('kernel_specs_request', (event) => {
  event.sender.send('kernel_specs_reply', KERNEL_SPECS);
});
<|endoftext|>


<commit_before>/* © 2014-2015 Grupo ESOC <www.grupoesoc.es>
 * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
 */

openerp.mail_forward = function (instance) {
    var _t = instance.web._t;
    instance.mail.ThreadMessage.include({
        bind_events: function () {
            this._super.apply(this, arguments);
            this.$('.oe_forward').on('click', this.on_message_forward);
        },

        on_message_forward: function () {
            // Generate email subject as possible from record_name and subject
            var subject = ["FWD"];
            if (this.record_name && (this.show_record_name ||
                                     this.parent_id))
            {
                subject.push(this.record_name);
            }
            if (this.subject) {
                subject.push(this.subject);
            } else if (subject.length < 2) {
                subject.push(_t("(No subject)"));
            }

            // Get only ID from the attachments
            var attachment_ids = [];
            for (n in this.attachment_ids) {
                attachment_ids.push(this.attachment_ids[n].id);
            }

            // Get necessary fields from the forwarded message
            var header = [
                "----------" + _t("Forwarded message") + "----------",
                _t("From: ") + this.author_id[1],
                _t("Date: ") + this.date,
            ];
            if (this.subject) {
                header.push(_t("Subject: ") + this.subject);
            }
            if (this.email_to) {
                header.push(_t("To: ") + this.email_to);
            }
            if (this.email_cc) {
                header.push(_t("CC: ") + this.email_cc);
            }
            header = header.map(_.str.escapeHTML).join("
")

            var context = {
                default_attachment_ids: attachment_ids,
                default_body:
                    "
" + header + "

" +
                    this.body,
                default_model: this.model,
                default_res_id: this.res_id,
                default_subject: subject.join(": "),
            };

            if (this.model && this.res_id) {
                context.default_destination_object_id =
                    [this.model, this.res_id].join();
            }

            // Get the action data and execute it to open the composer wizard
            var do_action = this.do_action;
            this.rpc("/web/action/load", {
                "action_id": "mail_forward.compose_action",
            })
            .done(function(action) {
                action.context = context;
                do_action(action);
            });
        }
    });
};
<commit_msg>Use strict js.<commit_after>/* © 2014-2015 Grupo ESOC <www.grupoesoc.es>
 * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
 */

"use strict";
openerp.mail_forward = function (instance) {
    var _t = instance.web._t;
    instance.mail.ThreadMessage.include({
        bind_events: function () {
            this._super.apply(this, arguments);
            this.$('.oe_forward').on('click', this.on_message_forward);
        },

        on_message_forward: function () {
            // Generate email subject as possible from record_name and subject
            var subject = ["FWD"];
            if (this.record_name && (this.show_record_name ||
                                     this.parent_id))
            {
                subject.push(this.record_name);
            }
            if (this.subject) {
                subject.push(this.subject);
            } else if (subject.length < 2) {
                subject.push(_t("(No subject)"));
            }

            // Get only ID from the attachments
            var attachment_ids = [];
            for (var n in this.attachment_ids) {
                attachment_ids.push(this.attachment_ids[n].id);
            }

            // Get necessary fields from the forwarded message
            var header = [
                "----------" + _t("Forwarded message") + "----------",
                _t("From: ") + this.author_id[1],
                _t("Date: ") + this.date,
            ];
            if (this.subject) {
                header.push(_t("Subject: ") + this.subject);
            }
            if (this.email_to) {
                header.push(_t("To: ") + this.email_to);
            }
            if (this.email_cc) {
                header.push(_t("CC: ") + this.email_cc);
            }
            header = header.map(_.str.escapeHTML).join("
")

            var context = {
                default_attachment_ids: attachment_ids,
                default_body:
                    "
" + header + "

" +
                    this.body,
                default_model: this.model,
                default_res_id: this.res_id,
                default_subject: subject.join(": "),
            };

            if (this.model && this.res_id) {
                context.default_destination_object_id =
                    [this.model, this.res_id].join();
            }

            // Get the action data and execute it to open the composer wizard
            var do_action = this.do_action;
            this.rpc("/web/action/load", {
                "action_id": "mail_forward.compose_action",
            })
            .done(function(action) {
                action.context = context;
                do_action(action);
            });
        }
    });
};
<|endoftext|>


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

var express = require('express');

//--------------------------------------------------------------------------------------------------

$.InitHttpServer = function() {
    var app = express();

// "/"
    app.get('/', function(req, res) {
        $.Tpl.getCharts(req, res, req.get('host') == 'svoyboi.com' ? 'svoyboi' : 'yana_havana');
    });

// "/:user_name"
    app.get('/:user_name', function(req, res) {
        $.Tpl.getCharts(req, res, req.params.user_name);
    });

// "change/:user_name"
    app.get('/change/:user_name', function(req, res) {
        $.Tpl.getChange(req, res, req.params.user_name);
    });

// /user_change/:user_id
    app.get('/user_change/:user_id', function(req, res) {
        $.User.isID(req.params.user_id, function(user_id) {
        // Проверка
            if (!user_id) {
                return res.send(
                    $.Tpl.error('Аккаунт с ID "'+ req.params.user_id +'" не найден!')
                );
            }

        // Json
            var json = {
            // Всего подписчиков
                total: 0,

            // Количество подписчиков за определенное время
                count: {
                    day: [0,0],// За день
                    week: [0,0],// За неделю
                    month: [0,0],// За месяц
                    month3: [0,0]// За три месяца
                },

            // Чарты
                charts: {
                    day: [],// За день
                    week: [],// За неделю
                    month: [],// За месяц
                    month3: []// За три месяца
                }
            };

        // За день
            var sql =
                "SELECT * FROM `count_minute` " +
                "WHERE `user_id` = ? " +
                "ORDER BY `time` ASC";

            $.query(sql, [user_id], function(row, rows) {
                var day = [0,0];

                for (var i = 0; i < rows.length; i++) {
                    day[0] += rows[i].plus;
                    day[1] += rows[i].minus;
                    json.charts.day.push([rows[i].time, day[0], day[1]]);
                    //json.charts.day.push([rows[i].time, rows[i].plus, rows[i].minus]);

                // За последние 60 минут
                    if (rows.length - 61 <= i) {
                        json.count.day[0] += rows[i].plus;
                        json.count.day[1] -= rows[i].minus;
                    }

                // За последние 12 часов
                    if (rows.length - 721 <= i) {
                        json.count.week[0] += rows[i].plus;
                        json.count.week[1] -= rows[i].minus;
                    }

                // За последние 24 часа
                    json.count.month[0] += rows[i].plus;
                    json.count.month[1] -= rows[i].minus;
                }

            // Всего подписчиков
                json.total = json.total || rows[rows.length - 1].count;

            // За неделю
                var sql =
                    "SELECT * FROM `count_hour` " +
                    "WHERE `user_id` = ? " +
                    "ORDER BY `time` DESC LIMIT 168";

                $.query(sql, [user_id], function(row, rows) {
                    var week = [0,0];

                    for (var i = rows.length - 1; i >= 0; i--) {
                        week[0] += rows[i].plus;
                        week[1] += rows[i].minus;
                        json.charts.week.push([rows[i].time, week[0], week[1]]);
                        //json.charts.week.push([rows[i].time, rows[i].plus, rows[i].minus]);

                    // За последние 7 дней
                        json.count.month3[0] += rows[i].plus;
                        json.count.month3[1] -= rows[i].minus;
                    }

                // За месяц
                    var sql =
                        "SELECT * FROM `count_hour` " +
                        "WHERE `user_id` = ? " +
                        "ORDER BY `time` DESC LIMIT 720";

                    $.query(sql, [user_id], function(row, rows) {
                        var month = [0,0];

                        for (var i = rows.length - 1; i >= 0; i--) {
                            month[0] += rows[i].plus;
                            month[1] += rows[i].minus;
                            json.charts.month.push([rows[i].time, month[0], month[1]]);
                            //json.charts.month.push([rows[i].time, rows[i].plus, rows[i].minus]);
                        }

                    // За три месяца
                        var sql =
                            "SELECT * FROM `count_hour` " +
                            "WHERE `user_id` = ? " +
                            "ORDER BY `time` ASC";

                        $.query(sql, [user_id], function(row, rows) {
                            var month3 = [0,0];

                            for (var i = 0; i < rows.length; i++) {
                                month3[0] += rows[i].plus;
                                month3[1] += rows[i].minus;
                                json.charts.month3.push([rows[i].time, month3[0], month3[1]]);
                                //json.charts.month3.push([rows[i].time, rows[i].plus, rows[i].minus]);
                            }

                        // Форматируем
                            for (var t in json.charts) {
                                for (var i = 0; i < json.count[t].length; i++) {
                                    json.count[t][i] =  [(json.count[t][i] >= 0 ? '+' : '–'), Math.abs(json.count[t][i]).toLocaleString()];
                                }
                            }

                            json.total = json.total.toLocaleString();

                            res.send(JSON.stringify(json));
                        });
                    });
                });
            });
        });
    });

// /user/:user_id
    app.get('/user/:user_id', function(req, res) {
        $.User.isID(req.params.user_id, function(user_id) {
        // Проверка
            if (!user_id) {
                return res.send(
                    $.Tpl.error('Аккаунт с ID "'+ req.params.user_id +'" не найден!')
                );
            }

        // Json
            var json = {
            // Всего подписчиков
                total: 0,

            // Количество подписчиков за определенное время
                count: {
                    day: [0,0],// За день
                    week: [0,0],// За неделю
                    month: [0,0],// За месяц
                    month3: [0,0]// За три месяца
                },

            // Чарты
                charts: {
                    day: [],// За день
                    week: [],// За неделю
                    month: [],// За месяц
                    month3: []// За три месяца
                }
            };

        // За день
            var sql =
                "SELECT * FROM `count_minute` " +
                "WHERE `user_id` = ? " +
                "ORDER BY `time` ASC";

            $.query(sql, [user_id], function(row, rows) {
                for (var i = 0; i < rows.length; i++) {
                    json.charts.day.push([rows[i].time, rows[i].count]);
                }

            // Всего подписчиков
                json.total = json.total || rows[rows.length - 1].count;

            // За последние 15 минут
                json.count.day[0] = (rows.length - 16 >= 0 ? json.total - rows[rows.length - 16].count : json.total - rows[0].count);

            // За последние 60 минут
                json.count.day[1] = (rows.length - 61 >= 0 ? json.total - rows[rows.length - 61].count : json.total - rows[0].count);

            // За последние 3 часа
                json.count.week[0] = (rows.length - 181 >= 0 ? json.total - rows[rows.length - 181].count : json.total - rows[0].count);

            // За последние 12 часов
                json.count.week[1] = (rows.length - 721 >= 0 ? json.total - rows[rows.length - 721].count : json.total - rows[0].count);

            // За последний 1 день
                json.count.month[0] = json.total - rows[0].count;

            // За неделю
                var sql =
                    "SELECT * FROM `count_hour` " +
                    "WHERE `user_id` = ? " +
                    "ORDER BY `time` DESC LIMIT 168";

                $.query(sql, [user_id], function(row, rows) {
                    for (var i = rows.length - 1; i >= 0; i--) {
                        json.charts.week.push([rows[i].time, rows[i].count]);
                    }

                // За последние 7 дней
                    json.count.month[1] = json.total - rows[rows.length - 1].count;

                // За месяц
                    var sql =
                        "SELECT * FROM `count_hour` " +
                        "WHERE `user_id` = ? " +
                        "ORDER BY `time` DESC LIMIT 720";

                    $.query(sql, [user_id], function(row, rows) {
                        for (var i = rows.length - 1; i >= 0; i--) {
                            json.charts.month.push([rows[i].time, rows[i].count]);
                        }

                    // За последние 30 дней
                        json.count.month3[0] = json.total - rows[rows.length - 1].count;

                    // За три месяца
                        var sql =
                            "SELECT * FROM `count_hour` " +
                            "WHERE `user_id` = ? " +
                            "ORDER BY `time` ASC";

                        $.query(sql, [user_id], function(row, rows) {
                            for (var i = 0; i < rows.length; i++) {
                                json.charts.month3.push([rows[i].time, rows[i].count]);
                            }

                        // За последние 90 дней
                            json.count.month3[1] = json.total - rows[0].count;

                        // Форматируем
                            for (var t in json.charts) {
                                for (var i = 0; i < json.count[t].length; i++) {
                                    json.count[t][i] =  [(json.count[t][i] >= 0 ? '+' : '–'), Math.abs(json.count[t][i]).toLocaleString()];
                                }
                            }

                            json.total = json.total.toLocaleString();

                            res.send(JSON.stringify(json));
                        });
                    });
                });
            });
        });
    });

    app.listen($.cfg.http.PORT, $.cfg.http.IP);

// Записываем в лог
    $.log('Server running at.');
};

//--------------------------------------------------------------------------------------------------<commit_msg>"update"<commit_after>//--------------------------------------------------------------------------------------------------

var express = require('express');

//--------------------------------------------------------------------------------------------------

$.InitHttpServer = function() {
    var app = express();

// "/"
    app.get('/', function(req, res) {
        $.Tpl.getCharts(req, res, req.get('host') == 'svoyboi.com' ? 'svoyboy' : 'yana_havana');
    });

// "/:user_name"
    app.get('/:user_name', function(req, res) {
        $.Tpl.getCharts(req, res, req.params.user_name);
    });

// "change/:user_name"
    app.get('/change/:user_name', function(req, res) {
        $.Tpl.getChange(req, res, req.params.user_name);
    });

// /user_change/:user_id
    app.get('/user_change/:user_id', function(req, res) {
        $.User.isID(req.params.user_id, function(user_id) {
        // Проверка
            if (!user_id) {
                return res.send(
                    $.Tpl.error('Аккаунт с ID "'+ req.params.user_id +'" не найден!')
                );
            }

        // Json
            var json = {
            // Всего подписчиков
                total: 0,

            // Количество подписчиков за определенное время
                count: {
                    day: [0,0],// За день
                    week: [0,0],// За неделю
                    month: [0,0],// За месяц
                    month3: [0,0]// За три месяца
                },

            // Чарты
                charts: {
                    day: [],// За день
                    week: [],// За неделю
                    month: [],// За месяц
                    month3: []// За три месяца
                }
            };

        // За день
            var sql =
                "SELECT * FROM `count_minute` " +
                "WHERE `user_id` = ? " +
                "ORDER BY `time` ASC";

            $.query(sql, [user_id], function(row, rows) {
                var day = [0,0];

                for (var i = 0; i < rows.length; i++) {
                    day[0] += rows[i].plus;
                    day[1] += rows[i].minus;
                    json.charts.day.push([rows[i].time, day[0], day[1]]);
                    //json.charts.day.push([rows[i].time, rows[i].plus, rows[i].minus]);

                // За последние 60 минут
                    if (rows.length - 61 <= i) {
                        json.count.day[0] += rows[i].plus;
                        json.count.day[1] -= rows[i].minus;
                    }

                // За последние 12 часов
                    if (rows.length - 721 <= i) {
                        json.count.week[0] += rows[i].plus;
                        json.count.week[1] -= rows[i].minus;
                    }

                // За последние 24 часа
                    json.count.month[0] += rows[i].plus;
                    json.count.month[1] -= rows[i].minus;
                }

            // Всего подписчиков
                json.total = json.total || rows[rows.length - 1].count;

            // За неделю
                var sql =
                    "SELECT * FROM `count_hour` " +
                    "WHERE `user_id` = ? " +
                    "ORDER BY `time` DESC LIMIT 168";

                $.query(sql, [user_id], function(row, rows) {
                    var week = [0,0];

                    for (var i = rows.length - 1; i >= 0; i--) {
                        week[0] += rows[i].plus;
                        week[1] += rows[i].minus;
                        json.charts.week.push([rows[i].time, week[0], week[1]]);
                        //json.charts.week.push([rows[i].time, rows[i].plus, rows[i].minus]);

                    // За последние 7 дней
                        json.count.month3[0] += rows[i].plus;
                        json.count.month3[1] -= rows[i].minus;
                    }

                // За месяц
                    var sql =
                        "SELECT * FROM `count_hour` " +
                        "WHERE `user_id` = ? " +
                        "ORDER BY `time` DESC LIMIT 720";

                    $.query(sql, [user_id], function(row, rows) {
                        var month = [0,0];

                        for (var i = rows.length - 1; i >= 0; i--) {
                            month[0] += rows[i].plus;
                            month[1] += rows[i].minus;
                            json.charts.month.push([rows[i].time, month[0], month[1]]);
                            //json.charts.month.push([rows[i].time, rows[i].plus, rows[i].minus]);
                        }

                    // За три месяца
                        var sql =
                            "SELECT * FROM `count_hour` " +
                            "WHERE `user_id` = ? " +
                            "ORDER BY `time` ASC";

                        $.query(sql, [user_id], function(row, rows) {
                            var month3 = [0,0];

                            for (var i = 0; i < rows.length; i++) {
                                month3[0] += rows[i].plus;
                                month3[1] += rows[i].minus;
                                json.charts.month3.push([rows[i].time, month3[0], month3[1]]);
                                //json.charts.month3.push([rows[i].time, rows[i].plus, rows[i].minus]);
                            }

                        // Форматируем
                            for (var t in json.charts) {
                                for (var i = 0; i < json.count[t].length; i++) {
                                    json.count[t][i] =  [(json.count[t][i] >= 0 ? '+' : '–'), Math.abs(json.count[t][i]).toLocaleString()];
                                }
                            }

                            json.total = json.total.toLocaleString();

                            res.send(JSON.stringify(json));
                        });
                    });
                });
            });
        });
    });

// /user/:user_id
    app.get('/user/:user_id', function(req, res) {
        $.User.isID(req.params.user_id, function(user_id) {
        // Проверка
            if (!user_id) {
                return res.send(
                    $.Tpl.error('Аккаунт с ID "'+ req.params.user_id +'" не найден!')
                );
            }

        // Json
            var json = {
            // Всего подписчиков
                total: 0,

            // Количество подписчиков за определенное время
                count: {
                    day: [0,0],// За день
                    week: [0,0],// За неделю
                    month: [0,0],// За месяц
                    month3: [0,0]// За три месяца
                },

            // Чарты
                charts: {
                    day: [],// За день
                    week: [],// За неделю
                    month: [],// За месяц
                    month3: []// За три месяца
                }
            };

        // За день
            var sql =
                "SELECT * FROM `count_minute` " +
                "WHERE `user_id` = ? " +
                "ORDER BY `time` ASC";

            $.query(sql, [user_id], function(row, rows) {
                for (var i = 0; i < rows.length; i++) {
                    json.charts.day.push([rows[i].time, rows[i].count]);
                }

            // Всего подписчиков
                json.total = json.total || rows[rows.length - 1].count;

            // За последние 15 минут
                json.count.day[0] = (rows.length - 16 >= 0 ? json.total - rows[rows.length - 16].count : json.total - rows[0].count);

            // За последние 60 минут
                json.count.day[1] = (rows.length - 61 >= 0 ? json.total - rows[rows.length - 61].count : json.total - rows[0].count);

            // За последние 3 часа
                json.count.week[0] = (rows.length - 181 >= 0 ? json.total - rows[rows.length - 181].count : json.total - rows[0].count);

            // За последние 12 часов
                json.count.week[1] = (rows.length - 721 >= 0 ? json.total - rows[rows.length - 721].count : json.total - rows[0].count);

            // За последний 1 день
                json.count.month[0] = json.total - rows[0].count;

            // За неделю
                var sql =
                    "SELECT * FROM `count_hour` " +
                    "WHERE `user_id` = ? " +
                    "ORDER BY `time` DESC LIMIT 168";

                $.query(sql, [user_id], function(row, rows) {
                    for (var i = rows.length - 1; i >= 0; i--) {
                        json.charts.week.push([rows[i].time, rows[i].count]);
                    }

                // За последние 7 дней
                    json.count.month[1] = json.total - rows[rows.length - 1].count;

                // За месяц
                    var sql =
                        "SELECT * FROM `count_hour` " +
                        "WHERE `user_id` = ? " +
                        "ORDER BY `time` DESC LIMIT 720";

                    $.query(sql, [user_id], function(row, rows) {
                        for (var i = rows.length - 1; i >= 0; i--) {
                            json.charts.month.push([rows[i].time, rows[i].count]);
                        }

                    // За последние 30 дней
                        json.count.month3[0] = json.total - rows[rows.length - 1].count;

                    // За три месяца
                        var sql =
                            "SELECT * FROM `count_hour` " +
                            "WHERE `user_id` = ? " +
                            "ORDER BY `time` ASC";

                        $.query(sql, [user_id], function(row, rows) {
                            for (var i = 0; i < rows.length; i++) {
                                json.charts.month3.push([rows[i].time, rows[i].count]);
                            }

                        // За последние 90 дней
                            json.count.month3[1] = json.total - rows[0].count;

                        // Форматируем
                            for (var t in json.charts) {
                                for (var i = 0; i < json.count[t].length; i++) {
                                    json.count[t][i] =  [(json.count[t][i] >= 0 ? '+' : '–'), Math.abs(json.count[t][i]).toLocaleString()];
                                }
                            }

                            json.total = json.total.toLocaleString();

                            res.send(JSON.stringify(json));
                        });
                    });
                });
            });
        });
    });

    app.listen($.cfg.http.PORT, $.cfg.http.IP);

// Записываем в лог
    $.log('Server running at.');
};

//--------------------------------------------------------------------------------------------------<|endoftext|>


<commit_before>/*
 * Bootstrap Image Gallery 3.0.1
 * https://github.com/blueimp/Bootstrap-Image-Gallery
 *
 * Copyright 2013, Sebastian Tschan
 * https://blueimp.net
 *
 * Licensed under the MIT license:
 * http://www.opensource.org/licenses/MIT
 */

 /*global define, window */

 (function (factory) {
  'use strict';
  if (typeof define === 'function' && define.amd) {
    // AMD. Register as an anonymous this.
    define(['../../base/mink', './blueimp-gallery'], function(mink, blueimp){
      return factory(mink.$, blueimp);
    });
  } else if (typeof exports === 'object') {
    // Node/CommonJS
    var mnk = require('../../base/mink.js');
    var blueimp = require('./blueimp-gallery');
    factory(mnk.$, blueimp);
  } else {
    // Browser globals
    factory(window.mink.$, window.blueimp.Gallery);
  }
}(function ($, BlueImpGallery) {
  'use strict';

  var defaultSettings = {
    name: 'Gallery',
    debug: true,
    verbose: true,
    performance: true,
    namespace: 'minkGallery',

    // ### Optional

    // Error messages returned by the module
    error: {
      method: 'The method you called is not defined.'
    },

    selector: {
      links: '[data-gallery]'
    },

    // Metadata attributes stored or retrieved by your module. `$('.foo').data('value');`
    metadata: {
      container: 'container',
      slidesContainer: 'slidesContainer',
      titleElement: 'titleElement',
      displayClass: 'displayClass',
      controlsClass: 'controlsClass',
      singleClass: 'singleClass',
      leftEdgeClass: 'leftEdgeClass',
      rightEdgeClass: 'rightEdgeClass',
      playingClass: 'playingClass',
      slideClass: 'slideClass',
      slideLoadingClass: 'slideLoadingClass',
      slideErrorClass: 'slideErrorClass',
      slideContentClass: 'slideContentClass',
      toggleClass: 'toggleClass',
      prevClass: 'prevClass',
      nextClass: 'nextClass',
      closeClass: 'closeClass',
      playPauseClass: 'playPauseClass',
      typeProperty: 'typeProperty',
      titleProperty: 'titleProperty',
      urlProperty: 'urlProperty',
      displayTransition: 'displayTransition',
      clearSlides: 'clearSlides',
      stretchImages: 'stretchImages',
      toggleControlsOnReturn: 'toggleControlsOnReturn',
      toggleSlideshowOnSpace: 'toggleSlideshowOnSpace',
      enableKeyboardNavigation: 'enableKeyboardNavigation',
      closeOnEscape: 'closeOnEscape',
      closeOnSlideClick: 'closeOnSlideClick',
      closeOnSwipeUpOrDown: 'closeOnSwipeUpOrDown',
      emulateTouchEvents: 'emulateTouchEvents',
      stopTouchEventsPropagation: 'stopTouchEventsPropagation',
      hidePageScrollbars: 'hidePageScrollbars',
      disableScroll: 'disableScroll',
      carousel: 'carousel',
      continuous: 'continuous',
      unloadElements: 'unloadElements',
      startSlideshow: 'startSlideshow',
      slideshowInterval: 'slideshowInterval',
      index: 'index',
      preloadRange: 'preloadRange',
      transitionSpeed: 'transitionSpeed',
      slideshowTransitionSpeed: 'slideshowTransitionSpeed',
      event: 'event',
      onopen: 'onopen',
      onopened: 'onopened',
      onslide: 'onslide',
      onslideend: 'onslideend',
      onslidecomplete: 'onslidecomplete',
      onclose: 'onclose',
      onclosed: 'onclosed'
    }
  };

  $.extend(BlueImpGallery.prototype.options, {
    useMinkModal: true
  });

  var close = BlueImpGallery.prototype.close,
  imageFactory = BlueImpGallery.prototype.imageFactory,
  videoFactory = BlueImpGallery.prototype.videoFactory,
  textFactory = BlueImpGallery.prototype.textFactory;

  $.extend(BlueImpGallery.prototype, {

    modalFactory: function (obj, callback, factoryInterface, factory) {
      var _this = this;
      var $modalTemplate = $('> .ink-shade', this.container);
      if ( !$modalTemplate.length || !this.options.useMinkModal || factoryInterface) {
        return factory.call(this, obj, callback, factoryInterface);
      }

      var modal = $modalTemplate
      .clone()
      .removeClass('hide-all')
      .on('click', function (event) {
        // Close modal if click is outside of modal-content:
        if (event.target === modal[0] || event.target === modal.children()[0]) {
          event.preventDefault();
          event.stopPropagation();
          _this.close();
        }
      }),
      element = factory.call(this, obj, function (event) {
        callback({
          type: event.type,
          target: modal[0]
        });
        modal.addClass('in');
      }, factoryInterface);
      modal.find('.modal-title').text(element.title || String.fromCharCode(160));
      modal.find('.modal-body').append(element);
      return modal[0];
    },

    imageFactory: function (obj, callback, factoryInterface) {
      return this.modalFactory(obj, callback, factoryInterface, imageFactory);
    },

    videoFactory: function (obj, callback, factoryInterface) {
      return this.modalFactory(obj, callback, factoryInterface, videoFactory);
    },

    textFactory: function (obj, callback, factoryInterface) {
      return this.modalFactory(obj, callback, factoryInterface, textFactory);
    },

    close: function () {
      close.call(this);
    }

  });

  var Gallery = $.fn.mink.factory(defaultSettings);

  $.extend(Gallery.prototype, {
    initialize: function() {
      var module = this;
      this.debug('Initializing module for', this.element);
      this.dataAttributes();
      $(document).on('click' + this.eventNamespace, this.settings.selector.links, $.proxy(this.create, this));
      this.$element.on('click' + this.eventNamespace, '.ink-dismiss', function(){
        module.instance.close();
      });

      this.instantiate();
    },

    instantiate: function () {
      this.verbose('Storing instance of module');
      // The instance is just a copy of the module definition, we store it in metadata so we can use it outside of scope, but also define it for immediate use
      this.instance = this;
      this.$element.data(this.moduleNamespace, this.instance);
    },

    create: function(ev){
      this.debug('Creating the gallery instance');
      var prop = ev ? $(ev.currentTarget).data(this.settings.name.toLowerCase()) : this.settings.selector.links;
      var settings = this.settings;
      var module = this;
      var sel = [];
      var callbacks =  {
        onopen: function () {
          module.$element.trigger('open');
        },
        onopened: function () {
          module.$element.trigger('opened');
        },
        onslide: function (a,b,c) {
          module.$element.trigger('slide', arguments);
        },
        onslideend: function () {
          module.$element.trigger('slideend', arguments);
        },
        onslidecomplete: function () {
          module.$element.trigger('slidecomplete', arguments);
        },
        onclose: function () {
          module.$element.trigger('close');
        },
        onclosed: function () {
          module.$element.trigger('closed').removeData('gallery');
        }
      };
      if( prop && prop.indexOf(',') > -1 ) {
        $.each(prop.split(/[, ]+/g), function(){
          sel.push('[data-' + settings.name.toLowerCase() + '*="' + this + '"]');
        });
      } else {
          sel.push( prop ? '[data-' + settings.name.toLowerCase() + '="' + prop + '"]' : settings.selector.links);
      }

      if(ev) {
        this.settings.event = ev;
        this.settings.index = ev.currentTarget;
        ev.preventDefault();
      } else {
        sel = [this.settings.selector.links];
      }

      this.settings.container = this.element;
      var $elems = $(sel.join());
      var options = $.extend( this.settings, callbacks);
      this.instance = new BlueImpGallery( $elems, this.settings);
    },

    getIndex: function() {
        this.verbose('Getting the current slide index position');
        return this.instance.getIndex();
    },
    getNumber: function() {
      this.verbose('Getting the number of slides in the gallery');
      return this.instance.getNumber();
    },
    getGallery: function() {
      this.verbose('Getting the gallery instance');
      if(!this.instance) {
        this.create();
      }
      return this.instance;
    },
    getInstance: function() {
      this.verbose('Getting the module instance');
      return this.instance;
    },
    prev: function() {
      this.debug('Moving to the previous slide');
      this.instance.prev();
    },
    next: function(interval) {
      this.debug('Moving to the next slide');
      this.instance.next();
    },
    play: function(interval) {
      this.debug('Playing the slideshow in and interval of ', interval);
      this.instance.play(interval);
    },
    pause: function() {
      this.debug('Pausing the slideshow for', this.element);
      this.instance.pause();
    },
    add: function(list){
      this.debug('Adding additional slides for', this.element);
      this.instance.add(list);
    },
    slide: function(index, duration) {
      this.debug('Moving to slide number ', index);
      this.instance.slide(index, duration);
    },
    open: function() {
      this.debug('Opening the gallery for', this.element);
      this.instance.close();
    },
    close: function() {
      this.debug('Closing the gallery for', this.element);
      this.instance.close();
    },

    // #### Destroy
    // Removes all events and the instance copy from metadata
    destroy: function () {
      this.verbose('Destroying previous module for', this.element);
      this.$element.removeData(moduleNamespace).off(this.eventNamespace);
      $(document).off(this.eventNamespace, this.create);
      this.element.removeAttribute('data-' + this.settings.name);
    }
  });

  $.fn.mink.expose('gallery', Gallery);

  return Gallery;

  }));<commit_msg>change: dont pass arguments to the trigger function<commit_after>/*
 * Bootstrap Image Gallery 3.0.1
 * https://github.com/blueimp/Bootstrap-Image-Gallery
 *
 * Copyright 2013, Sebastian Tschan
 * https://blueimp.net
 *
 * Licensed under the MIT license:
 * http://www.opensource.org/licenses/MIT
 */

 /*global define, window */

 (function (factory) {
  'use strict';
  if (typeof define === 'function' && define.amd) {
    // AMD. Register as an anonymous this.
    define(['../../base/mink', './blueimp-gallery'], function(mink, blueimp){
      return factory(mink.$, blueimp);
    });
  } else if (typeof exports === 'object') {
    // Node/CommonJS
    var mnk = require('../../base/mink.js');
    var blueimp = require('./blueimp-gallery');
    factory(mnk.$, blueimp);
  } else {
    // Browser globals
    factory(window.mink.$, window.blueimp.Gallery);
  }
}(function ($, BlueImpGallery) {
  'use strict';

  var defaultSettings = {
    name: 'Gallery',
    debug: true,
    verbose: true,
    performance: true,
    namespace: 'minkGallery',

    // ### Optional

    // Error messages returned by the module
    error: {
      method: 'The method you called is not defined.'
    },

    selector: {
      links: '[data-gallery]'
    },

    // Metadata attributes stored or retrieved by your module. `$('.foo').data('value');`
    metadata: {
      container: 'container',
      slidesContainer: 'slidesContainer',
      titleElement: 'titleElement',
      displayClass: 'displayClass',
      controlsClass: 'controlsClass',
      singleClass: 'singleClass',
      leftEdgeClass: 'leftEdgeClass',
      rightEdgeClass: 'rightEdgeClass',
      playingClass: 'playingClass',
      slideClass: 'slideClass',
      slideLoadingClass: 'slideLoadingClass',
      slideErrorClass: 'slideErrorClass',
      slideContentClass: 'slideContentClass',
      toggleClass: 'toggleClass',
      prevClass: 'prevClass',
      nextClass: 'nextClass',
      closeClass: 'closeClass',
      playPauseClass: 'playPauseClass',
      typeProperty: 'typeProperty',
      titleProperty: 'titleProperty',
      urlProperty: 'urlProperty',
      displayTransition: 'displayTransition',
      clearSlides: 'clearSlides',
      stretchImages: 'stretchImages',
      toggleControlsOnReturn: 'toggleControlsOnReturn',
      toggleSlideshowOnSpace: 'toggleSlideshowOnSpace',
      enableKeyboardNavigation: 'enableKeyboardNavigation',
      closeOnEscape: 'closeOnEscape',
      closeOnSlideClick: 'closeOnSlideClick',
      closeOnSwipeUpOrDown: 'closeOnSwipeUpOrDown',
      emulateTouchEvents: 'emulateTouchEvents',
      stopTouchEventsPropagation: 'stopTouchEventsPropagation',
      hidePageScrollbars: 'hidePageScrollbars',
      disableScroll: 'disableScroll',
      carousel: 'carousel',
      continuous: 'continuous',
      unloadElements: 'unloadElements',
      startSlideshow: 'startSlideshow',
      slideshowInterval: 'slideshowInterval',
      index: 'index',
      preloadRange: 'preloadRange',
      transitionSpeed: 'transitionSpeed',
      slideshowTransitionSpeed: 'slideshowTransitionSpeed',
      event: 'event',
      onopen: 'onopen',
      onopened: 'onopened',
      onslide: 'onslide',
      onslideend: 'onslideend',
      onslidecomplete: 'onslidecomplete',
      onclose: 'onclose',
      onclosed: 'onclosed'
    }
  };

  $.extend(BlueImpGallery.prototype.options, {
    useMinkModal: true
  });

  var close = BlueImpGallery.prototype.close,
  imageFactory = BlueImpGallery.prototype.imageFactory,
  videoFactory = BlueImpGallery.prototype.videoFactory,
  textFactory = BlueImpGallery.prototype.textFactory;

  $.extend(BlueImpGallery.prototype, {

    modalFactory: function (obj, callback, factoryInterface, factory) {
      var _this = this;
      var $modalTemplate = $('> .ink-shade', this.container);
      if ( !$modalTemplate.length || !this.options.useMinkModal || factoryInterface) {
        return factory.call(this, obj, callback, factoryInterface);
      }

      var modal = $modalTemplate
      .clone()
      .removeClass('hide-all')
      .on('click', function (event) {
        // Close modal if click is outside of modal-content:
        if (event.target === modal[0] || event.target === modal.children()[0]) {
          event.preventDefault();
          event.stopPropagation();
          _this.close();
        }
      }),
      element = factory.call(this, obj, function (event) {
        callback({
          type: event.type,
          target: modal[0]
        });
        modal.addClass('in');
      }, factoryInterface);
      modal.find('.modal-title').text(element.title || String.fromCharCode(160));
      modal.find('.modal-body').append(element);
      return modal[0];
    },

    imageFactory: function (obj, callback, factoryInterface) {
      return this.modalFactory(obj, callback, factoryInterface, imageFactory);
    },

    videoFactory: function (obj, callback, factoryInterface) {
      return this.modalFactory(obj, callback, factoryInterface, videoFactory);
    },

    textFactory: function (obj, callback, factoryInterface) {
      return this.modalFactory(obj, callback, factoryInterface, textFactory);
    },

    close: function () {
      close.call(this);
    }

  });

  var Gallery = $.fn.mink.factory(defaultSettings);

  $.extend(Gallery.prototype, {
    initialize: function() {
      var module = this;
      this.debug('Initializing module for', this.element);
      this.dataAttributes();
      $(document).on('click' + this.eventNamespace, this.settings.selector.links, $.proxy(this.create, this));
      this.$element.on('click' + this.eventNamespace, '.ink-dismiss', function(){
        module.instance.close();
      });

      this.instantiate();
    },

    instantiate: function () {
      this.verbose('Storing instance of module');
      // The instance is just a copy of the module definition, we store it in metadata so we can use it outside of scope, but also define it for immediate use
      this.instance = this;
      this.$element.data(this.moduleNamespace, this.instance);
    },

    create: function(ev){
      this.debug('Creating the gallery instance');
      var prop = ev ? $(ev.currentTarget).data(this.settings.name.toLowerCase()) : this.settings.selector.links;
      var settings = this.settings;
      var module = this;
      var sel = [];
      var callbacks =  {
        onopen: function () {
          module.$element.trigger('open');
        },
        onopened: function () {
          module.$element.trigger('opened');
        },
        onslide: function (a,b,c) {
          module.$element.trigger('slide');
        },
        onslideend: function () {
          module.$element.trigger('slideend');
        },
        onslidecomplete: function () {
          module.$element.trigger('slidecomplete');
        },
        onclose: function () {
          module.$element.trigger('close');
        },
        onclosed: function () {
          module.$element.trigger('closed').removeData('gallery');
        }
      };
      if( prop && prop.indexOf(',') > -1 ) {
        $.each(prop.split(/[, ]+/g), function(){
          sel.push('[data-' + settings.name.toLowerCase() + '*="' + this + '"]');
        });
      } else {
          sel.push( prop ? '[data-' + settings.name.toLowerCase() + '="' + prop + '"]' : settings.selector.links);
      }

      if(ev) {
        this.settings.event = ev;
        this.settings.index = ev.currentTarget;
        ev.preventDefault();
      } else {
        sel = [this.settings.selector.links];
      }

      this.settings.container = this.element;
      var $elems = $(sel.join());
      var options = $.extend( this.settings, callbacks);
      this.instance = new BlueImpGallery( $elems, this.settings);
    },

    getIndex: function() {
        this.verbose('Getting the current slide index position');
        return this.instance.getIndex();
    },
    getNumber: function() {
      this.verbose('Getting the number of slides in the gallery');
      return this.instance.getNumber();
    },
    getGallery: function() {
      this.verbose('Getting the gallery instance');
      if(!this.instance) {
        this.create();
      }
      return this.instance;
    },
    getInstance: function() {
      this.verbose('Getting the module instance');
      return this.instance;
    },
    prev: function() {
      this.debug('Moving to the previous slide');
      this.instance.prev();
    },
    next: function(interval) {
      this.debug('Moving to the next slide');
      this.instance.next();
    },
    play: function(interval) {
      this.debug('Playing the slideshow in and interval of ', interval);
      this.instance.play(interval);
    },
    pause: function() {
      this.debug('Pausing the slideshow for', this.element);
      this.instance.pause();
    },
    add: function(list){
      this.debug('Adding additional slides for', this.element);
      this.instance.add(list);
    },
    slide: function(index, duration) {
      this.debug('Moving to slide number ', index);
      this.instance.slide(index, duration);
    },
    open: function() {
      this.debug('Opening the gallery for', this.element);
      this.instance.close();
    },
    close: function() {
      this.debug('Closing the gallery for', this.element);
      this.instance.close();
    },

    // #### Destroy
    // Removes all events and the instance copy from metadata
    destroy: function () {
      this.verbose('Destroying previous module for', this.element);
      this.$element.removeData(moduleNamespace).off(this.eventNamespace);
      $(document).off(this.eventNamespace, this.create);
      this.element.removeAttribute('data-' + this.settings.name);
    }
  });

  $.fn.mink.expose('gallery', Gallery);

  return Gallery;

  }));<|endoftext|>


<commit_before>var app = angular.module('app', ['ngSanitize', 'ui.bootstrap', 'LocalStorageModule',]);

app.controller('HomeController',
  function($scope, $uibModal, localStorageService)
  {

    $scope.btnSaveClicked = function() {
      var modalInstance = $uibModal.open({
        animation: true,
        template:
          '
' +
          '
' +
          '    <button type="button" class="close" ng-click="cancel()">x</button>' +
          '
Save
' +
          '
' +
          '
' +
          '    <input ng-model="input.name" type="text" class="form-control" ng-enter="btnSaveClicked()" focus-me required />' +
          '
' +
          '
' +
          '    <input type="button" value="Save" class="btn btn-primary" ng-click="btnSaveClicked()" />' +
          '    <input type="button" value="Close" class="btn btn-default" ng-click="cancel()" />' +
          '
' +
          '
',
        controller: function($scope, tree, $uibModalInstance) {
          $scope.input = {};
          $scope.btnSaveClicked = function() {
            var names = localStorageService.get('names') || {};
            names[$scope.input.name] = tree;
            localStorageService.set('names', names);
          };
          $scope.cancel = function() {
            $uibModalInstance.dismiss('cancel');
          };
        },
        size: 'sm',
        resolve: {
          tree: function() { return $scope.tree; }
        },
      });
    };

    $scope.btnLoadClicked = function() {
      var modalInstance = $uibModal.open({
        animation: true,
        template:
          '
' +
          '
' +
          '    <button type="button" class="close" ng-click="cancel()">x</button>' +
          '
Load
' +
          '
' +
          '
' +
          '    <select ng-model="input.name" ng-options="name for name in names" class="form-control" ng-enter="btnLoadClicked()" focus-me></select>' +
          '
' +
          '
' +
          '    <input type="button" value="Load" class="btn btn-primary" ng-click="btnLoadClicked()" />' +
          '    <input type="button" value="Close" class="btn btn-default" ng-click="cancel()" />' +
          '
' +
          '
',
        controller: 'LoadModalController',
        size: 'sm',
      }).result.then(function(res) {
        if (res) {
          $scope.tree = res;
        }
      });
    };

    var highlightJson = function(json) {
      json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
      return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function(match) {
        var cls = 'number';
        if (/^"/.test(match)) {
          if (/:$/.test(match)) {
            cls = 'key';
          } else {
            cls = 'string';
          }
        } else if (/true|false/.test(match)) {
          cls = 'boolean';
        } else if (/null/.test(match)) {
          cls = 'null';
        }
        return '' + match + '';
      });
    };

    $scope.highlight = function(obj) {
      return highlightJson(angular.toJson(obj, true))
    };

    (function constructor() {
      $scope.selectedNode = null;
      $scope.tree = [];

      $scope.colors = [
        '#5aa1be',
        '#c065b8',
        '#c0ab5f',
        '#59bc95',
        '#7a63be',
        '#c0615b',
        '#73bb5e',
        '#6ee585',
        '#7088e8',
        '#eb77a3',
        '#c2e675',
      ];

    })();

  }
);
<commit_msg>Add input on home controller<commit_after>var app = angular.module('app', ['ngSanitize', 'ui.bootstrap', 'LocalStorageModule',]);

app.controller('HomeController',
  function($scope, $uibModal, localStorageService)
  {

    $scope.btnSaveClicked = function() {
      var modalInstance = $uibModal.open({
        animation: true,
        template:
          '
' +
          '
' +
          '    <button type="button" class="close" ng-click="cancel()">x</button>' +
          '
Save
' +
          '
' +
          '
' +
          '    <input ng-model="input.name" type="text" class="form-control" ng-enter="btnSaveClicked()" focus-me required />' +
          '
' +
          '
' +
          '    <input type="button" value="Save" class="btn btn-primary" ng-click="btnSaveClicked()" />' +
          '    <input type="button" value="Close" class="btn btn-default" ng-click="cancel()" />' +
          '
' +
          '
',
        controller: function($scope, tree, $uibModalInstance) {
          $scope.input = {};
          $scope.btnSaveClicked = function() {
            var names = localStorageService.get('names') || {};
            names[$scope.input.name] = tree;
            localStorageService.set('names', names);
          };
          $scope.cancel = function() {
            $uibModalInstance.dismiss('cancel');
          };
        },
        size: 'sm',
        resolve: {
          tree: function() { return $scope.tree; }
        },
      });
    };

    $scope.btnLoadClicked = function() {
      var modalInstance = $uibModal.open({
        animation: true,
        template:
          '
' +
          '
' +
          '    <button type="button" class="close" ng-click="cancel()">x</button>' +
          '
Load
' +
          '
' +
          '
' +
          '    <select ng-model="input.name" ng-options="name for name in names" class="form-control" ng-enter="btnLoadClicked()" focus-me></select>' +
          '
' +
          '
' +
          '    <input type="button" value="Load" class="btn btn-primary" ng-click="btnLoadClicked()" />' +
          '    <input type="button" value="Close" class="btn btn-default" ng-click="cancel()" />' +
          '
' +
          '
',
        controller: 'LoadModalController',
        size: 'sm',
      }).result.then(function(res) {
        if (res) {
          $scope.tree = res;
        }
      });
    };

    var highlightJson = function(json) {
      json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
      return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function(match) {
        var cls = 'number';
        if (/^"/.test(match)) {
          if (/:$/.test(match)) {
            cls = 'key';
          } else {
            cls = 'string';
          }
        } else if (/true|false/.test(match)) {
          cls = 'boolean';
        } else if (/null/.test(match)) {
          cls = 'null';
        }
        return '' + match + '';
      });
    };

    $scope.highlight = function(obj) {
      return highlightJson(angular.toJson(obj, true))
    };

    (function constructor() {
      $scope.selectedNode = null;
      $scope.tree = [];
      $scope.input = {};

      $scope.colors = [
        '#5aa1be',
        '#c065b8',
        '#c0ab5f',
        '#59bc95',
        '#7a63be',
        '#c0615b',
        '#73bb5e',
        '#6ee585',
        '#7088e8',
        '#eb77a3',
        '#c2e675',
      ];

    })();

  }
);
<|endoftext|>


<commit_before>!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.hoverintent=e()}}(function(){return function e(t,n,o){function r(u,f){if(!n[u]){if(!t[u]){var s="function"==typeof require&&require;if(!f&&s)return s(u,!0);if(i)return i(u,!0);var c=new Error("Cannot find module '"+u+"'");throw c.code="MODULE_NOT_FOUND",c}var a=n[u]={exports:{}};t[u][0].call(a.exports,function(e){var n=t[u][1][e];return r(n?n:e)},a,a.exports,e,t,n,o)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u<o.length;u++)r(o[u]);return r}({1:[function(e,t,n){!function(n){"use strict";var o=e("xtend"),r=function(e,t,n){function r(e,t,n){return p&&(p=clearTimeout(p)),m=0,t.call(e,n)}function i(t,n,o){var i=function(e){c=e.clientX,a=e.clientY};return p&&(p=clearTimeout(p)),o?(v=t.clientX,l=t.clientY,e.addEventListener("mousemove",i,!1),1!==m&&(p=setTimeout(function(){u(e,n,t)},y.interval))):(e.removeEventListener("mousemove",i,!1),1===m&&(p=setTimeout(function(){r(e,n,t)},y.timeout))),this}function u(e,t,n){return p&&(p=clearTimeout(p)),Math.abs(v-c)+Math.abs(l-a)<y.sensitivity?(m=1,t.call(e,n)):(v=c,l=a,p=setTimeout(function(){u(e,t,n)},y.interval),void 0)}function f(e){i(e,t,!0)}function s(e){i(e,n)}var c,a,v,l,d={},m=0,p=0,y={sensitivity:7,interval:100,timeout:0};return d.options=function(e){return y=o({},y,e),d},d.remove=function(){e&&(e.removeEventListener("mouseover",f,!1),e.removeEventListener("mouseout",s,!1))},e&&(e.addEventListener("mouseover",f,!1),e.addEventListener("mouseout",s,!1)),d};n.hoverintent=r,"undefined"!=typeof t&&t.exports&&(t.exports=r)}(this)},{xtend:2}],2:[function(e,t,n){function o(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var o in n)r.call(n,o)&&(e[o]=n[o])}return e}t.exports=o;var r=Object.prototype.hasOwnProperty},{}]},{},[1])(1)});
<commit_msg>pkg into dist<commit_after>!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.hoverintent=e()}}(function(){return function e(t,n,o){function r(u,f){if(!n[u]){if(!t[u]){var s="function"==typeof require&&require;if(!f&&s)return s(u,!0);if(i)return i(u,!0);var c=new Error("Cannot find module '"+u+"'");throw c.code="MODULE_NOT_FOUND",c}var a=n[u]={exports:{}};t[u][0].call(a.exports,function(e){var n=t[u][1][e];return r(n?n:e)},a,a.exports,e,t,n,o)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u<o.length;u++)r(o[u]);return r}({1:[function(e,t,n){!function(n){"use strict";var o=e("xtend"),r=function(e,t,n){function r(e,t){return p&&(p=clearTimeout(p)),m=0,n.call(e,t)}function i(e){c=e.clientX,a=e.clientY}function u(e,n){return p&&(p=clearTimeout(p)),Math.abs(v-c)+Math.abs(l-a)<y.sensitivity?(m=1,t.call(e,n)):(v=c,l=a,p=setTimeout(function(){u(e,n)},y.interval),void 0)}function f(t){return p&&(p=clearTimeout(p)),e.removeEventListener("mousemove",i,!1),1!==m&&(v=t.clientX,l=t.clientY,e.addEventListener("mousemove",i,!1),p=setTimeout(function(){u(e,t)},y.interval)),this}function s(t){return p&&(p=clearTimeout(p)),e.removeEventListener("mousemove",i,!1),1===m&&(p=setTimeout(function(){r(e,t)},y.timeout)),this}var c,a,v,l,d={},m=0,p=0,y={sensitivity:7,interval:100,timeout:0};return d.options=function(e){return y=o({},y,e),d},d.remove=function(){e&&(e.removeEventListener("mouseover",f,!1),e.removeEventListener("mouseout",s,!1))},e&&(e.addEventListener("mouseover",f,!1),e.addEventListener("mouseout",s,!1)),d};n.hoverintent=r,"undefined"!=typeof t&&t.exports&&(t.exports=r)}(this)},{xtend:2}],2:[function(e,t,n){function o(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var o in n)r.call(n,o)&&(e[o]=n[o])}return e}t.exports=o;var r=Object.prototype.hasOwnProperty},{}]},{},[1])(1)});
<|endoftext|>


<commit_before>define([
	'matreshka_dir/matreshka-magic',
	'matreshka_dir/core/var/sym'
], function(magic, sym) {
	"use strict";
	var toArray = magic.toArray,
		extend = magic.extend;
	/*

	This is the list of methods that inherited from magic. We need a way how to
	inherit them dynamically. method.apply is slow
	"on onDebounce _on once off _off trigger _trigger bindNode bindOptionalNode\
	 unbindNode boundAll $bound bound selectAll $ select _defineSpecial defineGetter\
	 defineSetter mediate fixClassOf linkProps get set remove define delay".split( /\s+/ )
	*/

	return {
		isMK: true,

		on: function(names, callback, triggerOnInit, context, evtData) {
			return magic.on(this, names, callback, triggerOnInit, context, evtData);
		},

		onDebounce: function(names, callback, debounceDelay, triggerOnInit, context, evtData) {
			return magic.onDebounce(this, names, callback, debounceDelay, triggerOnInit, context, evtData);
		},

		once: function(names, callback, context) {
			return magic.once(this, names, callback, context);
		},

		off: function(names, callback, context) {
			return magic.off(this, names, callback, context);
		},

		trigger: function() {
			var args = magic.toArray(arguments);
			args.unshift(this);
			return magic.trigger.apply(magic, args);
		},

		bindNode: function(key, node, binder, evt, optional) {
			return magic.bindNode(this, key, node, binder, evt, optional);
		},

		bindOptionalNode: function(key, node, binder, evt) {
			return magic.bindOptionalNode(this, key, node, binder, evt);
		},

		unbindNode: function(key, node, evt) {
			return magic.unbindNode(this, key, node, evt);
		},

		boundAll: function(key) {
			return magic.boundAll(this, key);
		},

		$bound: function(key) {
			return magic.boundAll(this, key);
		},

		bound: function(key) {
			return magic.bound(this, key);
		},

		selectAll: function(s) {
			return magic.selectAll(this, s);
		},

		$: function(s) {
			return magic.selectAll(this, s);
		},

		select: function(s) {
			return magic.select(this, s);
		},

		eq: function(object) { // @IE8
			return typeof object == 'object' && object !== null && this[sym] && object[sym] && this[sym].id == object[sym].id;
		},

		defineGetter: function(key, getter) {
			return magic.defineGetter(this, key, getter);
		},

		defineSetter: function(key, setter) {
			return magic.defineSetter(this, key, setter);
		},

		mediate: function(keys, mediator) {
			return magic.mediate(this, keys, mediator);
		},

		setClassFor: function(keys, Class, updateFunction) {
			return magic.setClassFor(this, keys, Class, updateFunction);
		},

		linkProps: function(key, keys, getter, setOnInit) {
			return magic.linkProps(this, key, keys, getter, setOnInit);
		},

		get: function(key) {
			return this[key];
		},

		set: function(key, v, evt) {
			return magic.set(this, key, v, evt);
		},

		remove: function(key, evt) {
			return magic.remove(this, key, evt);
		},

		define: function(key, descriptor) {
			return magic.define(this, key, descriptor);
		},

		delay: function(f, delay, thisArg) {
			return magic.delay(this, f, delay, thisArg);
		},

		parseBindings: function(nodes) {
			return magic.parseBindings(this, nodes);
		},

		_initMK: function() {
			var _this = this;

			if (_this[sym]) return _this;

			magic.initMK(_this);

			_this.nodes = {};
			_this.$nodes = {};
			_this.sandbox = null;
			_this.$sandbox = magic.$();

			return _this;
		},

		toString: function() {
			return '[object Matreshka]';
		},

		constructor: function Matreshka() {
			return this._initMK();
		}
	};
});
<commit_msg>minor<commit_after>define([
	'matreshka_dir/matreshka-magic',
	'matreshka_dir/core/var/sym'
], function(magic, sym) {
	"use strict";
	/*

	This is the list of methods that inherited from magic. We need a way how to
	inherit them dynamically. method.apply is slow
	"on onDebounce _on once off _off trigger _trigger bindNode bindOptionalNode\
	 unbindNode boundAll $bound bound selectAll $ select _defineSpecial defineGetter\
	 defineSetter mediate fixClassOf linkProps get set remove define delay".split( /\s+/ )
	*/

	return {
		isMK: true,

		on: function(names, callback, triggerOnInit, context, evtData) {
			return magic.on(this, names, callback, triggerOnInit, context, evtData);
		},

		onDebounce: function(names, callback, debounceDelay, triggerOnInit, context, evtData) {
			return magic.onDebounce(this, names, callback, debounceDelay, triggerOnInit, context, evtData);
		},

		once: function(names, callback, context) {
			return magic.once(this, names, callback, context);
		},

		off: function(names, callback, context) {
			return magic.off(this, names, callback, context);
		},

		trigger: function() {
			var args = magic.toArray(arguments);
			args.unshift(this);
			return magic.trigger.apply(magic, args);
		},

		bindNode: function(key, node, binder, evt, optional) {
			return magic.bindNode(this, key, node, binder, evt, optional);
		},

		bindOptionalNode: function(key, node, binder, evt) {
			return magic.bindOptionalNode(this, key, node, binder, evt);
		},

		unbindNode: function(key, node, evt) {
			return magic.unbindNode(this, key, node, evt);
		},

		boundAll: function(key) {
			return magic.boundAll(this, key);
		},

		$bound: function(key) {
			return magic.boundAll(this, key);
		},

		bound: function(key) {
			return magic.bound(this, key);
		},

		selectAll: function(s) {
			return magic.selectAll(this, s);
		},

		$: function(s) {
			return magic.selectAll(this, s);
		},

		select: function(s) {
			return magic.select(this, s);
		},

		eq: function(object) { // @IE8
			return typeof object == 'object' && object !== null && this[sym] && object[sym] && this[sym].id == object[sym].id;
		},

		defineGetter: function(key, getter) {
			return magic.defineGetter(this, key, getter);
		},

		defineSetter: function(key, setter) {
			return magic.defineSetter(this, key, setter);
		},

		mediate: function(keys, mediator) {
			return magic.mediate(this, keys, mediator);
		},

		setClassFor: function(keys, Class, updateFunction) {
			return magic.setClassFor(this, keys, Class, updateFunction);
		},

		linkProps: function(key, keys, getter, setOnInit) {
			return magic.linkProps(this, key, keys, getter, setOnInit);
		},

		get: function(key) {
			return this[key];
		},

		set: function(key, v, evt) {
			return magic.set(this, key, v, evt);
		},

		remove: function(key, evt) {
			return magic.remove(this, key, evt);
		},

		define: function(key, descriptor) {
			return magic.define(this, key, descriptor);
		},

		delay: function(f, delay, thisArg) {
			return magic.delay(this, f, delay, thisArg);
		},

		parseBindings: function(nodes) {
			return magic.parseBindings(this, nodes);
		},

		_initMK: function() {
			var _this = this;

			if (_this[sym]) return _this;

			magic.initMK(_this);

			_this.nodes = {};
			_this.$nodes = {};
			_this.sandbox = null;
			_this.$sandbox = magic.$();

			return _this;
		},

		toString: function() {
			return '[object Matreshka]';
		},

		constructor: function Matreshka() {
			return this._initMK();
		}
	};
});
<|endoftext|>