diff --git "a/2020/02/29/git-\346\234\254\345\234\260\351\241\271\347\233\256\345\222\214\350\277\234\347\250\213\347\251\272\351\241\271\347\233\256\345\205\263\350\201\224/index.html" "b/2020/02/29/git-\346\234\254\345\234\260\351\241\271\347\233\256\345\222\214\350\277\234\347\250\213\347\251\272\351\241\271\347\233\256\345\205\263\350\201\224/index.html" new file mode 100644 index 0000000..e66c4ca --- /dev/null +++ "b/2020/02/29/git-\346\234\254\345\234\260\351\241\271\347\233\256\345\222\214\350\277\234\347\250\213\347\251\272\351\241\271\347\233\256\345\205\263\350\201\224/index.html" @@ -0,0 +1,1139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 使用git让本地项目和远程空项目关联 · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + 使用git让本地项目和远程空项目关联 + + +

+ +

+ + + + + +

+ + +
+ + +
+ + + + + +
+ + +
+ 字数统计: 329阅读时长: 1 min +
+ +
+ + 2020/02/29 + + + + + + + + + Share +
    + +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+ + +
+
+
+
+

本文为搬运文章

+

作者:没有名字愿做一尘埃
链接:https://www.jianshu.com/p/dc730295e356
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

+
+

1、(先进入项目文件夹)通过命令 git init 把这个目录变成git可以管理的仓库

+
1
git init
+ +

2、把文件添加到版本库中,使用命令 git add .添加到暂存区里面去,不要忘记后面的小数点“.”,意为添加文件夹下的所有文件

+
1
git add .
+ +

3、用命令 git commit告诉Git,把文件提交到仓库。引号内为提交说明(linux为单引号;window为双引号)

+
1
git commit -m 'first commit' || git commit -m "first commit"
+ +

4、关联到远程库git remote add origin 你的远程库地址,如:

+
1
git remote add origin https://github.com/cade8800/ionic-demo.git
+ +

5、获取远程库与本地同步合并(如果远程库不为空必须做这一步,否则后面的提交会失败)

+
1
git pull --rebase origin master
+ +

6、把本地库的内容推送到远程,使用 git push命令,实际上是把当前分支master推送到远程。执行此命令后会要求输入用户名、密码,验证通过后即开始上传。

+
1
git push -u origin master
+ + + +
+ + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+
+ CATALOG +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/2020/02/29/\346\254\242\350\277\216\346\235\245\345\210\260\346\210\221\347\232\204\345\215\232\345\256\242/index.html" "b/2020/02/29/\346\254\242\350\277\216\346\235\245\345\210\260\346\210\221\347\232\204\345\215\232\345\256\242/index.html" new file mode 100644 index 0000000..c3e3b16 --- /dev/null +++ "b/2020/02/29/\346\254\242\350\277\216\346\235\245\345\210\260\346\210\221\347\232\204\345\215\232\345\256\242/index.html" @@ -0,0 +1,1123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 欢迎来到我的博客 · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + 欢迎来到我的博客 + + +

+ +

+ + + + + +

+ + +
+ + +
+ + + +
+ + +
+ 字数统计: 158阅读时长: 1 min +
+ +
+ + 2020/02/29 + + + + + + + + + Share +
    + +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+ + +
+
+
+

你好陌生人,感谢你浏览我的博客。

+

我是 DayDay ,一个刚起步、工作经验只有一年的菜鸟前端工程师。

+

在我的博客里,你会看到我的一些学习笔记,我工作时遇到的问题的解决方案,也有可能会出现我的日志,许多问题的解决方案我会直接搬运,这样自己比较省力✌️

+

当然,我也是一个游戏迷,特别喜欢宝可梦,会偶尔发布一些关于游戏的攻略等一些七七八八的东西。

+

以上,希望你能看的开心,love & peace!❤️

+ +
+ + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+
+ CATALOG +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/2020/03/03/JavaScript-\345\216\237\345\236\213\351\223\276\345\222\214-ES6-\347\232\204-Class-\347\232\204\345\214\272\345\210\253/index.html" "b/2020/03/03/JavaScript-\345\216\237\345\236\213\351\223\276\345\222\214-ES6-\347\232\204-Class-\347\232\204\345\214\272\345\210\253/index.html" new file mode 100644 index 0000000..353bd80 --- /dev/null +++ "b/2020/03/03/JavaScript-\345\216\237\345\236\213\351\223\276\345\222\214-ES6-\347\232\204-Class-\347\232\204\345\214\272\345\210\253/index.html" @@ -0,0 +1,1134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JavaScript 原型链和 ES6 的 Class 的区别 · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + JavaScript 原型链和 ES6 的 Class 的区别 + + +

+ +

+ + + + + +

+ + +
+ + +
+ + + + + + + +
+ + +
+ 字数统计: 242阅读时长: 1 min +
+ +
+ + 2020/03/03 + + + + + + + + + Share +
    + +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+ + +
+
+
+

区别

目前只整理出如下区别:

+
    +
  1. 原型链的使用逃不开函数的使用,而函数的声明会被提升;ES6 Class(后面称为 类) 的声明不会提升,真正执行声明语句之前,它们会一直存在于临时死区中。
  2. +
  3. 类声明中的所有代码将自动运行在严格模式下,而且无法强行代码脱离严格模式下运行。
  4. +
  5. 类中所有的方法都是不可枚举的,原型链要借助 Object.defineProperty() 方法实现方法的不可枚举。
  6. +
  7. 每个类都有一个名为 Construct 的内部方法,通过关键字 new 调用那些不含 Construct 的方法会导致程序抛出错误。
  8. +
  9. 使用除关键字 new 以外的方式调用类的构造函数会导致程序抛出错误。
  10. +
  11. 在类中修改类名会导致程序错误。
  12. +
+

其他

查看这篇文章了解原型链:原型链

+ +
+ + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+
+ CATALOG +
+
  1. 1. 区别
  2. 2. 其他
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/2020/03/03/React-diff-\347\232\204\347\220\206\350\247\243/index.html" "b/2020/03/03/React-diff-\347\232\204\347\220\206\350\247\243/index.html" new file mode 100644 index 0000000..82580b4 --- /dev/null +++ "b/2020/03/03/React-diff-\347\232\204\347\220\206\350\247\243/index.html" @@ -0,0 +1,1122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + React diff 的理解 · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + React diff 的理解 + + +

+ +

+ + + + + +

+ + +
+ + +
+ + + + + +
+ + +
+ 字数统计: 12阅读时长: 1 min +
+ +
+ + 2020/03/03 + + + + + + + + + Share +
    + +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+ + +
+
+
+

查看这篇文章找到答案:原文

+ +
+ + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+
+ CATALOG +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/2020/03/03/SVG-\345\222\214-Canvas-\347\232\204\345\214\272\345\210\253/index.html" "b/2020/03/03/SVG-\345\222\214-Canvas-\347\232\204\345\214\272\345\210\253/index.html" new file mode 100644 index 0000000..abd70f6 --- /dev/null +++ "b/2020/03/03/SVG-\345\222\214-Canvas-\347\232\204\345\214\272\345\210\253/index.html" @@ -0,0 +1,1131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SVG 和 Canvas 的区别 · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + SVG 和 Canvas 的区别 + + +

+ +

+ + + + + +

+ + +
+ + +
+ + + + + + + + + + + +
+ + +
+ 字数统计: 12阅读时长: 1 min +
+ +
+ + 2020/03/03 + + + + + + + + + Share +
    + +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+ + +
+
+
+

查看这篇文章找到答案:原文

+ +
+ + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+
+ CATALOG +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/2020/03/03/jQuery-\345\257\271\350\261\241\345\222\214-DOM-\345\257\271\350\261\241\347\232\204\347\233\270\344\272\222\350\275\254\346\215\242/index.html" "b/2020/03/03/jQuery-\345\257\271\350\261\241\345\222\214-DOM-\345\257\271\350\261\241\347\232\204\347\233\270\344\272\222\350\275\254\346\215\242/index.html" new file mode 100644 index 0000000..aecedf4 --- /dev/null +++ "b/2020/03/03/jQuery-\345\257\271\350\261\241\345\222\214-DOM-\345\257\271\350\261\241\347\232\204\347\233\270\344\272\222\350\275\254\346\215\242/index.html" @@ -0,0 +1,1125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jQuery 对象和 DOM 对象的相互转换 · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + jQuery 对象和 DOM 对象的相互转换 + + +

+ +

+ + + + + +

+ + +
+ + +
+ + + + + + + +
+ + +
+ 字数统计: 12阅读时长: 1 min +
+ +
+ + 2020/03/03 + + + + + + + + + Share +
    + +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+ + +
+
+
+

查看这篇文章找到答案:原文

+ +
+ + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+
+ CATALOG +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/2020/03/03/vue-\344\270\255-v-if-\345\222\214-v-show-\347\232\204\345\214\272\345\210\253/index.html" "b/2020/03/03/vue-\344\270\255-v-if-\345\222\214-v-show-\347\232\204\345\214\272\345\210\253/index.html" new file mode 100644 index 0000000..bb77605 --- /dev/null +++ "b/2020/03/03/vue-\344\270\255-v-if-\345\222\214-v-show-\347\232\204\345\214\272\345\210\253/index.html" @@ -0,0 +1,1122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + vue 中 v-if 和 v-show 的区别 · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + vue 中 v-if 和 v-show 的区别 + + +

+ +

+ + + + + +

+ + +
+ + +
+ + + + + +
+ + +
+ 字数统计: 12阅读时长: 1 min +
+ +
+ + 2020/03/03 + + + + + + + + + Share +
    + +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+ + +
+
+
+

查看这篇文章找到答案:原文

+ +
+ + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+
+ CATALOG +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/2020/03/03/\345\257\271\350\267\250\345\237\237\347\232\204\347\233\270\345\205\263\347\237\245\350\257\206/index.html" "b/2020/03/03/\345\257\271\350\267\250\345\237\237\347\232\204\347\233\270\345\205\263\347\237\245\350\257\206/index.html" new file mode 100644 index 0000000..f6e55f0 --- /dev/null +++ "b/2020/03/03/\345\257\271\350\267\250\345\237\237\347\232\204\347\233\270\345\205\263\347\237\245\350\257\206/index.html" @@ -0,0 +1,1119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 对跨域的相关知识 · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + 对跨域的相关知识 + + +

+ +

+ + + + + +

+ + +
+ + +
+ + + +
+ + +
+ 字数统计: 12阅读时长: 1 min +
+ +
+ + 2020/03/03 + + + + + + + + + Share +
    + +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+ + +
+
+
+

查看这篇文章找到答案:原文

+ +
+ + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+
+ CATALOG +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/2020/03/03/\345\257\271\351\227\255\345\214\205\347\232\204\347\220\206\350\247\243/index.html" "b/2020/03/03/\345\257\271\351\227\255\345\214\205\347\232\204\347\220\206\350\247\243/index.html" new file mode 100644 index 0000000..c8c0db4 --- /dev/null +++ "b/2020/03/03/\345\257\271\351\227\255\345\214\205\347\232\204\347\220\206\350\247\243/index.html" @@ -0,0 +1,1122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 对闭包的理解 · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + 对闭包的理解 + + +

+ +

+ + + + + +

+ + +
+ + +
+ + + + + +
+ + +
+ 字数统计: 20阅读时长: 1 min +
+ +
+ + 2020/03/03 + + + + + + + + + Share +
    + +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+ + +
+
+
+

MDN 上有关于闭包的详细内容,点击链接进行查看

+ +
+ + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+
+ CATALOG +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/2020/03/10/React-Native-\346\226\207\346\241\243\345\237\272\347\241\200\351\203\250\345\210\206\345\260\217\347\273\223/index.html" "b/2020/03/10/React-Native-\346\226\207\346\241\243\345\237\272\347\241\200\351\203\250\345\210\206\345\260\217\347\273\223/index.html" new file mode 100644 index 0000000..6a82621 --- /dev/null +++ "b/2020/03/10/React-Native-\346\226\207\346\241\243\345\237\272\347\241\200\351\203\250\345\210\206\345\260\217\347\273\223/index.html" @@ -0,0 +1,1182 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + React Native 文档基础部分小结 · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + React Native 文档基础部分小结 + + +

+ +

+ + + + + +

+ + +
+ + +
+ + + +
+ + +
+ 字数统计: 585阅读时长: 2 min +
+ +
+ + 2020/03/10 + + + + + + + + + Share +
    + +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+ + +
+
+
+

非常鼓励看原文文档,目前文档内容特别完善。以下是我在看文档的基础部分的时候顺手记录的内容。

+

使用的脚手架

官方文档提示有两种选择

+
    +
  • expo cli
  • +
  • react native cli
  • +
+

虽然 expo cli 的安装上比较麻烦,但是从开发的角度来看,expo cli 方便很多,在手机上的预览完全可以依靠 Expo App 来实现,完全不需要再在电脑上下载模拟器。

+

React Native Component

React 没有自己的元件,但是 React Native 有,借助这些基础元件帮助我们实现快速开发,实现网页端和手机端的互通。

+

Style

React Native 对这部分内容有扩充:

+
    +
  • 新增了 StyleSheet.create,方便对组件样式的统一管理
      +
    • 其中 key 的名字参考 css 的样式名,只不过要修改成驼峰型,value 参照 css 的值。
    • +
    +
  • +
  • React Native 基础组件都有 style prop,用来设定组件的样式
      +
    • 这个 prop 的值可以是 Object,也可以是一个 Array。如果是 Array,越靠后的样式级别越高。
    • +
    +
  • +
+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';

const styles = StyleSheet.create({
bigBlue: {
color: 'blue',
fontWeight: 'bold',
fontSize: 30,
},
red: {
color: 'red',
},
});

export default class LotsOfStyles extends Component {
render() {
return (
<View>
<Text style={styles.red}>just red</Text>
<Text style={styles.bigBlue}>just bigBlue</Text>
<Text style={[styles.bigBlue, styles.red]}>bigBlue, then red</Text>
<Text style={[styles.red, styles.bigBlue]}>red, then bigBlue</Text>
</View>
);
}
}

+ + + +

Height and Width

主要介绍两种方式来设定组件的大小,知道 css 的话这部分内容就很好理解:

+
    +
  • 设定固定值:
      +
    • 设定 stylewidthheight
    • +
    +
  • +
  • 动态设定:
      +
    • flex 进行设定
    • +
    +
  • +
+

Layout with Flexbox

主要详细说明 flex 的相关设定,知道 css 的 flex 的话这部分内容就很好理解。主要区别如下:

+
    +
  • React Native 中的 flexDirection 默认为 column
  • +
  • React Native 中的 flex 只能接受一个数字作为其值
  • +
+

这里还介绍了 widthheight 的值的类型(和 传统 css 有出入)

+
    +
  • auto
      +
    • 默认值
    • +
    +
  • +
  • 像素
  • +
  • 百分数
  • +
+

这里还介绍了 position 的值(和传统 css 有出入)

+
    +
  • absolute
  • +
  • relative
      +
    • 默认值。这里需要注意,传统的 css,staitc 才是默认值
    • +
    +
  • +
+ +
+ + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+
+ CATALOG +
+
  1. 1. 使用的脚手架
  2. 2. React Native Component
  3. 3. Style
  4. 4. Height and Width
  5. 5. Layout with Flexbox
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/2020/03/14/Apple-Music-\350\265\204\346\272\220\345\272\223\346\225\260\346\215\256\344\270\242\345\244\261\350\247\243\345\206\263\346\226\271\346\241\210/IMG_134B49C070A5-1.jpeg" "b/2020/03/14/Apple-Music-\350\265\204\346\272\220\345\272\223\346\225\260\346\215\256\344\270\242\345\244\261\350\247\243\345\206\263\346\226\271\346\241\210/IMG_134B49C070A5-1.jpeg" new file mode 100644 index 0000000..13fb268 Binary files /dev/null and "b/2020/03/14/Apple-Music-\350\265\204\346\272\220\345\272\223\346\225\260\346\215\256\344\270\242\345\244\261\350\247\243\345\206\263\346\226\271\346\241\210/IMG_134B49C070A5-1.jpeg" differ diff --git "a/2020/03/14/Apple-Music-\350\265\204\346\272\220\345\272\223\346\225\260\346\215\256\344\270\242\345\244\261\350\247\243\345\206\263\346\226\271\346\241\210/IMG_25AB96DA0F97-1.jpeg" "b/2020/03/14/Apple-Music-\350\265\204\346\272\220\345\272\223\346\225\260\346\215\256\344\270\242\345\244\261\350\247\243\345\206\263\346\226\271\346\241\210/IMG_25AB96DA0F97-1.jpeg" new file mode 100644 index 0000000..946678c Binary files /dev/null and "b/2020/03/14/Apple-Music-\350\265\204\346\272\220\345\272\223\346\225\260\346\215\256\344\270\242\345\244\261\350\247\243\345\206\263\346\226\271\346\241\210/IMG_25AB96DA0F97-1.jpeg" differ diff --git "a/2020/03/14/Apple-Music-\350\265\204\346\272\220\345\272\223\346\225\260\346\215\256\344\270\242\345\244\261\350\247\243\345\206\263\346\226\271\346\241\210/index.html" "b/2020/03/14/Apple-Music-\350\265\204\346\272\220\345\272\223\346\225\260\346\215\256\344\270\242\345\244\261\350\247\243\345\206\263\346\226\271\346\241\210/index.html" new file mode 100644 index 0000000..4fd3490 --- /dev/null +++ "b/2020/03/14/Apple-Music-\350\265\204\346\272\220\345\272\223\346\225\260\346\215\256\344\270\242\345\244\261\350\247\243\345\206\263\346\226\271\346\241\210/index.html" @@ -0,0 +1,1149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Apple Music 资源库数据丢失解决方案 · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + Apple Music 资源库数据丢失解决方案 + + +

+ +

+ + + + + +

+ + +
+ + +
+ + + + + +
+ + +
+ 字数统计: 198阅读时长: 1 min +
+ +
+ + 2020/03/14 + + + + + + + + + Share +
    + +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+ + +
+
+
+

现象

Apple Music 资源库中的资料只有近期的,并不完整。

+

手机设备

本人的手机设备是 iphone 11,系统为ios 13.3.1

+

解决方案

思路就是把现有 Apple Music 资源库数据删掉,然后从 iCloud 上重新获取一次,具体操作如下:

+
    +
  1. 【设置】-> 下滑找到 【音乐】并点击进入
  2. +
+IMG_25AB96DA0F97-1 + +
    +
  1. 看到 【同步资料库】开关,把它先关掉(ps:关掉后可以去 Apple Music 中检查,此时的资料库会一点数据都没有)
  2. +
+IMG_134B49C070A5-1 + +
    +
  1. 最后一个步骤,就是再把 【同步资料库】 开关打开,这样 Apple Music 就会重新到 iCloud 获取数据。
  2. +
+

结语

目前我亲测只有这个方法对我有效,如果有其他的办法欢迎评论留言讨论。

+ +
+ + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+
+ CATALOG +
+
  1. 1. 现象
  2. 2. 手机设备
  3. 3. 解决方案
  4. 4. 结语
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/2020/10/26/GitHub-Pages-\345\217\221\345\270\203\351\201\207\345\210\260\347\232\204\351\227\256\351\242\230/index.html" "b/2020/10/26/GitHub-Pages-\345\217\221\345\270\203\351\201\207\345\210\260\347\232\204\351\227\256\351\242\230/index.html" new file mode 100644 index 0000000..05c8c76 --- /dev/null +++ "b/2020/10/26/GitHub-Pages-\345\217\221\345\270\203\351\201\207\345\210\260\347\232\204\351\227\256\351\242\230/index.html" @@ -0,0 +1,1132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GitHub Pages 发布遇到的问题 · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + GitHub Pages 发布遇到的问题 + + +

+ +

+ + + + + +

+ + +
+ + +
+ + + + + +
+ + +
+ 字数统计: 185阅读时长: 1 min +
+ +
+ + 2020/10/26 + + + + + + + + + Share +
    + +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+ + +
+
+
+

GitHub Packages 的发布

+

参考这篇文章,并补充一部分自己实际操作中发现的内容

+
+

关于文件名称

假设要发布的这个包叫 mypackages, 然后我们 GitHub 的用户名为 myname,那么 package.jsonname 属性的值就会是 @myname/mypackages

+

关于登录命令

参考文章中说需要执行这样的代码进行登录:

+
1
npm login --registry=https://npm.pkg.github.com --scope=@trcat
+ +

但我们如果按照前面设定好包的名称,登录命令直接用下面这个就可以了

+
1
npm login --registry=https://npm.pkg.github.com
+ +

其他

目前不知道为啥,虽然看上去 github 和 npm 有联动,但实际上,发布到 github 上的包在 npm 中是搜不到的。

+ +
+ + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+
+ CATALOG +
+
  1. 1. GitHub Packages 的发布
  2. 2. 关于文件名称
  3. 3. 关于登录命令
  4. 4. 其他
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/2020/10/26/JavaScript-\350\216\267\345\217\226-Element-\347\232\204\345\256\275\345\272\246\347\232\204\345\244\232\347\247\215\345\247\277\345\212\277/index.html" "b/2020/10/26/JavaScript-\350\216\267\345\217\226-Element-\347\232\204\345\256\275\345\272\246\347\232\204\345\244\232\347\247\215\345\247\277\345\212\277/index.html" new file mode 100644 index 0000000..dce2ca3 --- /dev/null +++ "b/2020/10/26/JavaScript-\350\216\267\345\217\226-Element-\347\232\204\345\256\275\345\272\246\347\232\204\345\244\232\347\247\215\345\247\277\345\212\277/index.html" @@ -0,0 +1,1149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JavaScript 获取 Element 的宽度的多种姿势 · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + JavaScript 获取 Element 的宽度的多种姿势 + + +

+ +

+ + + + + +

+ + +
+ + +
+ + + + + +
+ + +
+ 字数统计: 344阅读时长: 1 min +
+ +
+ + 2020/10/26 + + + + + + + + + Share +
    + +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+ + +
+
+
+

JavaScript 获取 Element 的宽度的多种姿势

最近在写一个小组件,涉及到获取 Element 的宽度,就顺便整理了一些

+

clientWidth & offsetWidth

如果 Element 的宽度是写在 css 文件中的,比较常见的方法就是通过 HTMLElement.clientWidthHTMLElement.offsetWidth 来获得。

+

两则的区别很明显:

+
    +
  • 前者得到的宽度是 内容区宽度 + padding
  • +
  • 后者得到的宽度是 内容区宽度 + padding + border + margin
  • +
+

但是如果元素添加了 display: none 的样式, 那么上面两种方法得到的值都会是 0

+

那要怎么获得隐藏起来的元素的宽度?

虽然上述的两种方式不适用于 display:none 的情况,但是适用于 visibility:hidden 的情况。

+

如果想获取 display: none 元素的宽度,目前我是用一下两种方式的:

+
    +
  • 第一种,元素的宽度用内联样式定义,然后通过 HTMLElement.style.width 获得宽度
  • +
  • 第二种,通过 window.getComputedStyle() 来获得
      +
    • window.getComputedStyle(target).width,需要注意的是,得到的宽度是一个字符串,例如 100PX
    • +
    • 获得的宽度值会受 box-sizing 样式的影响
    • +
    • 无论是宽度是内联样式定义的还是外联样式定义的,都可以获取到
    • +
    +
  • +
+

个人非常喜欢第二种方式,目前看来在各种情况下都能拿到我想要的宽度!

+ +
+ + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+
+ CATALOG +
+
  1. 1. JavaScript 获取 Element 的宽度的多种姿势
    1. 1.1. clientWidth & offsetWidth
    2. 1.2. 那要怎么获得隐藏起来的元素的宽度?
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/2020/10/26/\345\261\205\344\270\255\345\233\276\347\211\207\347\232\204\345\244\232\347\247\215\345\247\277\345\212\277/index.html" "b/2020/10/26/\345\261\205\344\270\255\345\233\276\347\211\207\347\232\204\345\244\232\347\247\215\345\247\277\345\212\277/index.html" new file mode 100644 index 0000000..bebd88b --- /dev/null +++ "b/2020/10/26/\345\261\205\344\270\255\345\233\276\347\211\207\347\232\204\345\244\232\347\247\215\345\247\277\345\212\277/index.html" @@ -0,0 +1,1170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 居中图片的多种姿势 · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + 居中图片的多种姿势 + + +

+ +

+ + + + + +

+ + +
+ + +
+ + + + + + + +
+ + +
+ 字数统计: 638阅读时长: 2 min +
+ +
+ + 2020/10/26 + + + + + + + + + Share +
    + +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+ + +
+
+
+

居中图片的多种姿势

集合目前能想到的居中图片的做法并区分

+

通过 margin 实现

实现方式

<img> 包在 <div> 中, 然后设置 <div> 的样式如下:

+
1
2
3
4
div {
width: 1000px; // 图片大小
margin: 0 auto;
}
+ +

效果

    +
  1. 当视窗宽度大于 <div> 宽度时, 图片完全显示, 且图片呈现为居中状态
  2. +
  3. 当视窗宽度小于等于 <div> 宽度时候, 图片部分显示, 且显示的部分也不是图片中间部分
  4. +
+

通过 text-align 实现

实现方式

通过设定 <img> 父元素的 text-align css 样式为 center 实现:

+
1
2
3
body {
text-align: center;
}
+ +

效果

    +
  1. 当视窗宽度大于 <img> 宽度时, 图片完全显示, 且图片呈现为居中状态
  2. +
  3. 当视窗宽度小于等于 <img> 宽度时候, 图片部分显示, 且显示的部分也不是图片中间部分
  4. +
+

通过 flex 实现

实现方式

<img> 父元素设定为 flex box实现, 具体 css 如下:

+
1
2
3
4
body {
display: flex;
justify-content: center;
}
+ +

效果

    +
  1. 当视窗宽度大于 <img> 宽度时, 图片完全显示, 且图片呈现为居中状态
  2. +
  3. 当视窗宽度小于等于 <img> 宽度时候, 图片依然完全显示, 但是图片会等比例缩小
  4. +
+

通过 background 实现

实现方式

图片设置为 div 的背景图片, 并将其设置为居中, 具体 css 如下:

+
1
2
3
4
5
div {
width: 100%; // 整个视窗的宽度
height: 650px; // 图片的高度
background: url(./product3.jpg) no-repeat center
}
+ +

效果

    +
  1. 当视窗宽度大于 <img> 宽度时, 图片完全显示, 且图片呈现为居中状态
  2. +
  3. 当视窗宽度小于等于 <img> 宽度时候, 图片部分显示, 显示部分始终为图片的中间部分!
  4. +
+

通过 position 实现

实现方式

将图片左移自身宽度一半的距离, 然后在向右移动视窗一半的距离, 具体 css 如下:

+
1
2
3
4
5
img {
margin-left: -500px; // 图片宽度的一半
position: relative;
left: 50%; // 百分比基准值为视窗相等的值
}
+ +

效果

    +
  1. 当视窗宽度大于 <img> 宽度时, 图片完全显示, 且图片呈现为居中状态
  2. +
  3. 当视窗宽度小于等于 <img> 宽度时候, 图片部分显示, 显示部分始终为图片的中间部分!
  4. +
+

总结

就目前来看, 实现图片居中的最好方式, 是使用 positionbackground 实现!

+

实验文件

+ +
+ + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+
+ CATALOG +
+
  1. 1. 居中图片的多种姿势
    1. 1.1. 通过 margin 实现
      1. 1.1.1. 实现方式
      2. 1.1.2. 效果
    2. 1.2. 通过 text-align 实现
      1. 1.2.1. 实现方式
      2. 1.2.2. 效果
    3. 1.3. 通过 flex 实现
      1. 1.3.1. 实现方式
      2. 1.3.2. 效果
    4. 1.4. 通过 background 实现
      1. 1.4.1. 实现方式
      2. 1.4.2. 效果
    5. 1.5. 通过 position 实现
      1. 1.5.1. 实现方式
      2. 1.5.2. 效果
    6. 1.6. 总结
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/2020/10/28/\345\246\202\344\275\225\345\210\244\346\226\255\345\275\223\345\211\215\351\241\265\351\235\242\346\230\257\345\220\246\350\242\253-iframe-\346\240\207\347\255\276\345\274\225\347\224\250/index.html" "b/2020/10/28/\345\246\202\344\275\225\345\210\244\346\226\255\345\275\223\345\211\215\351\241\265\351\235\242\346\230\257\345\220\246\350\242\253-iframe-\346\240\207\347\255\276\345\274\225\347\224\250/index.html" new file mode 100644 index 0000000..b64be1d --- /dev/null +++ "b/2020/10/28/\345\246\202\344\275\225\345\210\244\346\226\255\345\275\223\345\211\215\351\241\265\351\235\242\346\230\257\345\220\246\350\242\253-iframe-\346\240\207\347\255\276\345\274\225\347\224\250/index.html" @@ -0,0 +1,1134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 如何判断当前页面是否被 iframe 标签引用 · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + 如何判断当前页面是否被 iframe 标签引用 + + +

+ +

+ + + + + +

+ + +
+ + +
+ + + + + + + +
+ + +
+ 字数统计: 59阅读时长: 1 min +
+ +
+ + 2020/10/28 + + + + + + + + + Share +
    + +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+ + +
+
+
+
+

参考文档

+
+

只需要比对window.topwindow.self 是否一样,如果一样,则说明没有被引用,反之则说明被引用了。

+

实例代码如下:

+
1
2
3
if (window.top !== window.self) {
// 当前被 iframe 引用了
}
+ + + + + +
+ + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+
+ CATALOG +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/2020/12/28/IcoMoon\345\210\235\344\275\223\351\252\214/icomoon_useage.png" "b/2020/12/28/IcoMoon\345\210\235\344\275\223\351\252\214/icomoon_useage.png" new file mode 100644 index 0000000..79ee1d3 Binary files /dev/null and "b/2020/12/28/IcoMoon\345\210\235\344\275\223\351\252\214/icomoon_useage.png" differ diff --git "a/2020/12/28/IcoMoon\345\210\235\344\275\223\351\252\214/icon1.png" "b/2020/12/28/IcoMoon\345\210\235\344\275\223\351\252\214/icon1.png" new file mode 100644 index 0000000..c8fd9ac Binary files /dev/null and "b/2020/12/28/IcoMoon\345\210\235\344\275\223\351\252\214/icon1.png" differ diff --git "a/2020/12/28/IcoMoon\345\210\235\344\275\223\351\252\214/icon2-1.png" "b/2020/12/28/IcoMoon\345\210\235\344\275\223\351\252\214/icon2-1.png" new file mode 100644 index 0000000..abe1b7e Binary files /dev/null and "b/2020/12/28/IcoMoon\345\210\235\344\275\223\351\252\214/icon2-1.png" differ diff --git "a/2020/12/28/IcoMoon\345\210\235\344\275\223\351\252\214/icon2-2.png" "b/2020/12/28/IcoMoon\345\210\235\344\275\223\351\252\214/icon2-2.png" new file mode 100644 index 0000000..bbfac6e Binary files /dev/null and "b/2020/12/28/IcoMoon\345\210\235\344\275\223\351\252\214/icon2-2.png" differ diff --git "a/2020/12/28/IcoMoon\345\210\235\344\275\223\351\252\214/icon2.png" "b/2020/12/28/IcoMoon\345\210\235\344\275\223\351\252\214/icon2.png" new file mode 100644 index 0000000..b8f8da1 Binary files /dev/null and "b/2020/12/28/IcoMoon\345\210\235\344\275\223\351\252\214/icon2.png" differ diff --git "a/2020/12/28/IcoMoon\345\210\235\344\275\223\351\252\214/index.html" "b/2020/12/28/IcoMoon\345\210\235\344\275\223\351\252\214/index.html" new file mode 100644 index 0000000..e9985df --- /dev/null +++ "b/2020/12/28/IcoMoon\345\210\235\344\275\223\351\252\214/index.html" @@ -0,0 +1,1160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IcoMoon初体验 · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + IcoMoon初体验 + + +

+ +

+ + + + + +

+ + +
+ + +
+ + + + + + + + + +
+ + +
+ 字数统计: 389阅读时长: 1 min +
+ +
+ + 2020/12/28 + + + + + + + + + Share +
    + +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+ + +
+
+
+

IcoMoon

icoMoon工具网址

+

这是一个可以将 SVG 格式的文件转换为 web font (即使用字体显示图标)的神奇网站工具,工具的使用非常简单,基本操作如下图所示:

+

icomoon_useage

+

优势

使用 web font 的形式来显示图标最大的优势就是,若要修改图标的颜色,只需要调整 css color 的值就可以了:

+
1
2
.icon1 {color:black;} // 图标会变成黑色
.icon2 {color:red;} // 图标会变成红色
+ + + +

唯一且最大的难点

icoMoon 工具使用起来非常非常的简单,唯一且最大的难点,就是 svg 文件的取得。

+

一般情况下,我们前端从设计师的 psd 文件中切图后,得到的图标都是 png 格式的,所以我们要想办法将 png 格式转换成 svg 格式。

+

很不幸,目前我并没有十全十美的转换方案,稍微复杂一些的 png 转换成 svg 后,要么 icoMoon 工具无法识别,要么就是转换后图标面目全非,就像下面两张图所示,图1为转换前,图2为转换后:

+

icon1——-png转换为svg————>icon2

+

但是相对简单的图像问题就不是很大:

+

icon2-1——–简单图片差别就不大————–icon2-2

+

所以还算有一线生机,这边还是有必要说下目前可行的 png 转 svg 的流程

+

转换流程

    +
  1. 用 ps 的切图功能切下想要的图标,并保存为 png 格式,
  2. +
  3. 然后用这个 在线工具 将 png 转换成 svg,并下载。
  4. +
+ +
+ + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+
+ CATALOG +
+
  1. 1. IcoMoon
    1. 1.1. 优势
    2. 1.2. 唯一且最大的难点
      1. 1.2.1. 转换流程
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/2020/12/28/\345\252\222\344\275\223\350\207\252\345\212\250\346\222\255\346\224\276/img.png" "b/2020/12/28/\345\252\222\344\275\223\350\207\252\345\212\250\346\222\255\346\224\276/img.png" new file mode 100644 index 0000000..9e24284 Binary files /dev/null and "b/2020/12/28/\345\252\222\344\275\223\350\207\252\345\212\250\346\222\255\346\224\276/img.png" differ diff --git "a/2020/12/28/\345\252\222\344\275\223\350\207\252\345\212\250\346\222\255\346\224\276/index.html" "b/2020/12/28/\345\252\222\344\275\223\350\207\252\345\212\250\346\222\255\346\224\276/index.html" new file mode 100644 index 0000000..571a6fc --- /dev/null +++ "b/2020/12/28/\345\252\222\344\275\223\350\207\252\345\212\250\346\222\255\346\224\276/index.html" @@ -0,0 +1,1135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 媒体自动播放 · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + 媒体自动播放 + + +

+ +

+ + + + + +

+ + +
+ + +
+ + + + + +
+ + +
+ 字数统计: 132阅读时长: 1 min +
+ +
+ + 2020/12/28 + + + + + + + + + Share +
    + +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+ + +
+
+
+

媒体自动播放

设置必要属性

需要给 <audio><video> 设置 mutedplaysinlinepreload 属性,如下图所示:

+

img

+

绑定点击事件

<audio><video> 绑定点击事件,事件执行媒体标签自生的 play()函数,并在页面完成渲染的时候触发媒体标签的点击事件,实现自动播放。

+

缺点

<video> 是视频,静音播放没有什么问题,但是 <audio> 是音频,静音播放可能就难受了

+ +
+ + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+
+ CATALOG +
+
  1. 1. 媒体自动播放
    1. 1.1. 设置必要属性
    2. 1.2. 绑定点击事件
    3. 1.3. 缺点
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/2021/04/04/Echarts-Custom-Series/demo.png b/2021/04/04/Echarts-Custom-Series/demo.png new file mode 100644 index 0000000..7b727d4 Binary files /dev/null and b/2021/04/04/Echarts-Custom-Series/demo.png differ diff --git a/2021/04/04/Echarts-Custom-Series/index.html b/2021/04/04/Echarts-Custom-Series/index.html new file mode 100644 index 0000000..7efe962 --- /dev/null +++ b/2021/04/04/Echarts-Custom-Series/index.html @@ -0,0 +1,1153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Echarts Custom Series · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + Echarts Custom Series + + +

+ +

+ + + + + +

+ + +
+ + +
+ + + + + +
+ + +
+ 字数统计: 816阅读时长: 3 min +
+ +
+ + 2021/04/04 + + + + + + + + + Share +
    + +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+ + +
+
+
+

Echarts Custom series

工作上一直都有在用 Echarts,但是基本上都是使用 Echarts 预设好的 series,例如 barlinepie,然而最近因为工作需要,尝试使用了 custom 自定义图表,有必要记录一下。

+

renderItem

custom series 大致设定上与其他 series 区别不大,详情可看配置项文档,最关键的设定就是 renderItem,全靠它实现我们的自定义图像渲染逻辑。

+

renderItem 是一个函数,依据传入 series 的 data ,遍历并返回对应的渲染逻辑,它包含 paramsapi 这两个参数,需要当前数据属性坐标系属性就从 params 中拿,需要获取当前数据维度值或将数据映射到坐标系中就从api 中拿对应的函数。

+

如官方配置项文档所说,api.coordapi.size 这两个函数很常用,前者传入数据得到对应映射到坐标系的坐标点,后者传入数据得到对应映射到坐标系的长度,当然还有 api.value ,可以通过这个拿到当前数据value

+

除了数据映射之外,我们还需要通过 echarts.graphic 中的函数生成要渲染的图形,例如想渲染矩形则使用 echarts.graphic.clipRectByRect

+

准备好上述内容之后,就可以设定 返回值了,可以返回 rectline 等。

+

关于数据映射的理解

自己写的时候对文档中描述的数据映射的概念特别模糊,但后面想想其实很简单,示例代码如下:

+
1
2
3
4
5
renderItem(params, api) {
var coord = api.coord([0, 1]);
console.log(coord[0]) // x 轴上第一个刻度的坐标点的横坐标值
console.log(coord[1]) // y 轴为第二个刻度的坐标点的纵坐标值
}
+ +

上述代码我将[0, 1] 作为参数传入 api.coord 中,分别得到 x 轴上第一个刻度的坐标点的横坐标值和 y 轴为第二个刻度的坐标点的纵坐标值。

+

需要留意的地方

    +
  • 0 作为参数传入 api.coordapi.size ,会返回 x 轴或 y 轴第一个刻度的数据信息,并不是原点。
  • +
  • 把非整数作为参数传入 api.coordapi.size ,参数会先进行取整,再进行换算,例如,00.5 得到的结果是一样的。
  • +
  • api.value 的参数不能超过 3,无论当前 data 的 value 数组的长度是否超过 3
  • +
+

series

Custom Series 大致设定与其他 Series 类似,但需特别注意 encode 的设定,这个设定非常重要,忽略这个设定可能会导致绘制的图片超出坐标系范围,造成图像的缺失。

+

encode教程 中也有说明,实例代码如下:

+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
option = {
series: [{
type: 'custom',
renderItem: function () {
...
},
encode: {
// data 中『维度1』和『维度2』对应到 X 轴
x: [1, 2],
// data 中『维度0』对应到 Y 轴
y: 0
},
data: [
// 维度0 维度1 维度2 维度3
[ 12, 44, 55, 60 ], // 这是第一个 dataItem
[ 53, 31, 21, 56 ], // 这是第二个 dataItem
[ 71, 33, 10, 20 ], // 这是第三个 dataItem
...
]
}]
};
+ + + +

案例

这边自己写了一个 demo,生成如下图表,看过源码之后会对上述内容有更好的理解:
demo

+ +
+ + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+
+ CATALOG +
+
  1. 1. Echarts Custom series
    1. 1.1. renderItem
      1. 1.1.1. 关于数据映射的理解
      2. 1.1.2. 需要留意的地方
    2. 1.2. series
    3. 1.3. 案例
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/2021/06/08/CSS3-\345\217\230\351\207\217/index.html" "b/2021/06/08/CSS3-\345\217\230\351\207\217/index.html" new file mode 100644 index 0000000..ec3b4b2 --- /dev/null +++ "b/2021/06/08/CSS3-\345\217\230\351\207\217/index.html" @@ -0,0 +1,1182 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CSS3 变量 · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + CSS3 变量 + + +

+ +

+ + + + + +

+ + +
+ + +
+ + + +
+ + +
+ 字数统计: 817阅读时长: 4 min +
+ +
+ + 2021/06/08 + + + + + + + + + Share +
    + +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+ + +
+
+
+

CSS3 变量

在 SCSS 中使用

基本使用

1
2
3
4
5
6
7
8
9
$--font-size: 20px;

:root {
--font-size: #{$--font-size};
}

.app {
font-size: var(--font-size);
}
+ +

bootstrap 中使用案例

通过 @each 遍历 list 变量并在 :root 中声明

+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$colors: (
"blue": $blue,
"indigo": $indigo,
"purple": $purple,
"pink": $pink,
"red": $red,
"orange": $orange,
"yellow": $yellow,
"green": $green,
"teal": $teal,
"cyan": $cyan,
"white": $white,
"gray": $gray-600,
"gray-dark": $gray-800
) !default;

:root {
@each $color, $value in $colors {
--#{$variable-prefix}#{$color}: #{$value};
}
}
+ +

scss 文件中既有用到 scss 变量也有用到 css 变量定义样式,js 通过 getPropertyValue 获取变量的值

+
1
2
3
4
.navbar-nav-scroll {
max-height: var(--#{$variable-prefix}scroll-height, 75vh);
overflow-y: auto;
}
+ +
1
const isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end';
+ + + +
+

个人猜测,使用时方便全局修改的用 css 变量赋值。

+
+

ant design 中的使用

1
2
3
4
html {
--antd-wave-shadow-color: @primary-color;
--scroll-bar: 0;
}
+ +

主要用在 less 文件中,在组件中时候是也存在通过 javascript 修改变量的情况

+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function renderCloseIcon() {
return (
closable && (
<button
type="button"
onClick={onClose}
aria-label="Close"
className={`${prefixCls}-close`}
style={
{
'--scroll-bar': `${getScrollBarSize()}px`,
} as any
}
>
{closeIcon}
</button>
)
);
}
+ +

优先级

css 变量的优先级规则和 selector 的一样

+
1
2
3
4
5
6
7
8
9
10
:root{
--font-size: 12px;
}

body {
--font-size: 20px;
div {
font-size: var(--font-size) // 20px
}
}
+ + + +

目前发现的使用上的限制

在 scss 文件中使用 css 变量和在 css 文件中使用 css 变量是不一样的

+

字符串的拼接

css 变量进行字符串拼接目前发现只能在 content 中使用。

+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// 源码
body {
font-family: var(--font-family)" New"; // "Courier New"
&:before {
content: var(--css-prefix) "ed" // red
}
}
// 编译后
body {
font-family: var(--font-family) " New"; // 无效
}
body:before {
content: var(--css-prefix) "ed"; // red
}
+ + + +

默认值

var(<custom-property-name>, <declaration-value>) 可以传入两个参数,第一个参数就是自定义属性值,第二个为回退值,当自定义属性值无效时使用回退值。

+
1
2
3
4
5
6
7
8
9
10
.component .header {
color: var(--header-color, blue); /* header-color isn’t set, and so remains blue, the fallback value */
background-image:var(--bg-img, url(./one.png), url(./two.png));
}

// 结果为
.component .header {
color: blue;
background-image: url(./one.png), url(./two.png)
}
+ + + +

兼容性处理

1
2
3
4
5
6

a {
color: #7F583F;
color: var(--primary);
}

+ +
1
2
3
4
5
6
7
8
9
10
11

@supports ( (--a: 0)) {
/* supported */
}

@supports ( not (--a: 0)) {
/* not supported */
}

/* @supports IE 也不支持 */

+ + + +

参考文献

+

字体主题修改方案

./src/index.scss 文件夹中在 :root 上定义变量

+
1
2
3
4
5
6
// index.scss
:root {
--font-size-small: #{$--theme-font-size-small};
--font-size-default: #{$--theme-font-size-default};
--font-size-large: #{$--theme-font-size-large};
}
+ +

使用时,还是要和之前一样,建立主题文档,并走 gulp 编译,这样:root 中的变量也会随之修改。

+

考虑到兼容性问题,能获取到 scss 变量的还是使用 scss 变量,否则则在项目中通过 var() 使用 css 变量:

+
1
2
3
4
selector {
font-size: 14px; // 避免浏览器不支持
font-size: var(--font-size, 14px); // 第二个参数防止没有设定变量
}
+ +

方案优化

    +
  • 考虑能否优化在 scss 中声明 css 变量的方式
  • +
+ +
+ + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+
+ CATALOG +
+
  1. 1. CSS3 变量
    1. 1.1. 在 SCSS 中使用
      1. 1.1.1. 基本使用
      2. 1.1.2. bootstrap 中使用案例
      3. 1.1.3. ant design 中的使用
      4. 1.1.4. 优先级
      5. 1.1.5. 目前发现的使用上的限制
        1. 1.1.5.1. 字符串的拼接
    2. 1.2. 默认值
    3. 1.3. 兼容性处理
    4. 1.4. 参考文献
    5. 1.5. 字体主题修改方案
      1. 1.5.1. 方案优化
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/2021/06/08/\346\200\247\350\203\275\346\265\213\350\257\225\345\267\245\345\205\267/1.png" "b/2021/06/08/\346\200\247\350\203\275\346\265\213\350\257\225\345\267\245\345\205\267/1.png" new file mode 100644 index 0000000..ec11ccc Binary files /dev/null and "b/2021/06/08/\346\200\247\350\203\275\346\265\213\350\257\225\345\267\245\345\205\267/1.png" differ diff --git "a/2021/06/08/\346\200\247\350\203\275\346\265\213\350\257\225\345\267\245\345\205\267/2.png" "b/2021/06/08/\346\200\247\350\203\275\346\265\213\350\257\225\345\267\245\345\205\267/2.png" new file mode 100644 index 0000000..badd7eb Binary files /dev/null and "b/2021/06/08/\346\200\247\350\203\275\346\265\213\350\257\225\345\267\245\345\205\267/2.png" differ diff --git "a/2021/06/08/\346\200\247\350\203\275\346\265\213\350\257\225\345\267\245\345\205\267/index.html" "b/2021/06/08/\346\200\247\350\203\275\346\265\213\350\257\225\345\267\245\345\205\267/index.html" new file mode 100644 index 0000000..4598dcc --- /dev/null +++ "b/2021/06/08/\346\200\247\350\203\275\346\265\213\350\257\225\345\267\245\345\205\267/index.html" @@ -0,0 +1,1149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 性能测试工具 · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + 性能测试工具 + + +

+ +

+ + + + + +

+ + +
+ + +
+ + + + + +
+ + +
+ 字数统计: 362阅读时长: 1 min +
+ +
+ + 2021/06/08 + + + + + + + + + Share +
    + +
  • +
  • +
  • +
  • +
+
+
+
+ +
+
+ + +
+
+
+

性能测试工具

Chrome performance 工具

需要打开 vue 的 performance 后组件的性能情况才会被 chrome performance 工具记录。

+
1
vue.config.performance = true;
+ +

示例

截屏2021-06-08 下午3.35.19

+

初次进入页面,然后打开 chrome performance 工具,点击左上角 reload 按钮,几秒钟后我们就能看到初次渲染的性能情况。主要关注工具中的 Timings,找到对应组件查看不同阶段性能情况,可以看到有三个指标:

+
    +
  • Init:创建组件实例需要的时间
  • +
  • Render:创建VDom结构需要的时间
  • +
  • Patch:把VDom应用到实际Dom的时间
  • +
+

缺点

使用起来稍微麻烦一点,没有 Vue Devtool 直观。

+

Vue Devtool(推荐)

Vue Devtool 有一个 Performance 页,可以检测组件的性能。

+

截屏2021-06-08 下午3.20.42

+

使用方法

    +
  1. 进入 performance 页,并选中 Component render 标签
  2. +
  3. 点击 start 按钮就开始记录,然后点击侧边栏中对呀组件查看性能情况。
  4. +
+

缺点

如果 Vue Devtool 当前处于记录状态,此时刷新页面插件就会崩坏,这给我们测试组件出初次渲染的性能增加了难度。

+

但也是有办法补救,一种是初次渲染通过 chrome performance 工具来测试,另一种就是先将目标组件隐藏(v-if = false),然后点击 start 按钮再将目标组件显示(v-if=true)就能测得初次渲染性能

+

参考文档

+ +
+ + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+
+ CATALOG +
+
  1. 1. 性能测试工具
    1. 1.1. Chrome performance 工具
      1. 1.1.1. 示例
      2. 1.1.2. 缺点
    2. 1.2. Vue Devtool(推荐)
      1. 1.2.1. 使用方法
      2. 1.2.2. 缺点
    3. 1.3. 参考文档
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/404.html b/404.html new file mode 100644 index 0000000..a87b61d --- /dev/null +++ b/404.html @@ -0,0 +1,990 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 诶呀,出错了! · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + 诶呀,出错了! + + +

+ +

+ + + 本博客没有你在着的内容 :) + +

+ + +
+
+ + +
+ + + + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/about/index.html b/about/index.html new file mode 100644 index 0000000..4fa7223 --- /dev/null +++ b/about/index.html @@ -0,0 +1,997 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 感谢你浏览我的博客 · DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + DayDay's Studio. +
+
+
+ + + + + +
+
+
+ +

+ + + 感谢你浏览我的博客 + +

+ +

+ + +

+ + +
+
+ + +
+ +
+
+

你好陌生人,感谢你浏览我的博客。

+

我是 DayDay ,一个刚起步、工作经验只有一年的菜鸟前端工程师。

+

在我的博客里,你会看到我的一些学习笔记,我工作时遇到的问题的解决方案,也有可能会出现我的日志。

+

当然,我也是一个游戏迷,特别喜欢宝可梦,会偶尔发布一些关于游戏的攻略等一些七七八八的东西。

+

以上,希望你能看的开心,love & peace!

+ +
+
+ + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archives/2020/02/index.html b/archives/2020/02/index.html new file mode 100644 index 0000000..6e5b260 --- /dev/null +++ b/archives/2020/02/index.html @@ -0,0 +1,1043 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + DayDay's Studio. +
+
+
+ + + +
+
+
+ +

+ + +

+ +

+ + +

+ + +
+
+ + +
+
+ + + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archives/2020/03/index.html b/archives/2020/03/index.html new file mode 100644 index 0000000..6878da8 --- /dev/null +++ b/archives/2020/03/index.html @@ -0,0 +1,1266 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + DayDay's Studio. +
+
+
+ + + +
+
+
+ +

+ + +

+ +

+ + +

+ + +
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archives/2020/10/index.html b/archives/2020/10/index.html new file mode 100644 index 0000000..3359651 --- /dev/null +++ b/archives/2020/10/index.html @@ -0,0 +1,1109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + DayDay's Studio. +
+
+
+ + + +
+
+
+ +

+ + +

+ +

+ + +

+ + +
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archives/2020/12/index.html b/archives/2020/12/index.html new file mode 100644 index 0000000..661de4b --- /dev/null +++ b/archives/2020/12/index.html @@ -0,0 +1,1047 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + DayDay's Studio. +
+
+
+ + + +
+
+
+ +

+ + +

+ +

+ + +

+ + +
+
+ + +
+
+ + + + + + + + + + + + + +
+ + + 媒体自动播放 + +
+ 前几天工作上遇到需要自动播放视频的需求,在自己搜索和亲友团的帮助下,整理处以下内容。 +
+ +
+ + + +
+ + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archives/2020/index.html b/archives/2020/index.html new file mode 100644 index 0000000..04e13c3 --- /dev/null +++ b/archives/2020/index.html @@ -0,0 +1,1303 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + DayDay's Studio. +
+
+
+ + + +
+
+
+ +

+ + +

+ +

+ + +

+ + +
+
+ + +
+
+ + + + + + + + + + + + + +
+ + + 媒体自动播放 + +
+ 前几天工作上遇到需要自动播放视频的需求,在自己搜索和亲友团的帮助下,整理处以下内容。 +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archives/2020/page/2/index.html b/archives/2020/page/2/index.html new file mode 100644 index 0000000..2ae2c3b --- /dev/null +++ b/archives/2020/page/2/index.html @@ -0,0 +1,1208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + DayDay's Studio. +
+
+
+ + + +
+
+
+ +

+ + +

+ +

+ + +

+ + +
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archives/2021/04/index.html b/archives/2021/04/index.html new file mode 100644 index 0000000..1ab3c80 --- /dev/null +++ b/archives/2021/04/index.html @@ -0,0 +1,1012 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + DayDay's Studio. +
+
+
+ + + +
+
+
+ +

+ + +

+ +

+ + +

+ + +
+
+ + +
+
+ + + + + + + + + + +
+ + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archives/2021/06/index.html b/archives/2021/06/index.html new file mode 100644 index 0000000..d463734 --- /dev/null +++ b/archives/2021/06/index.html @@ -0,0 +1,1041 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + DayDay's Studio. +
+
+
+ + + +
+
+
+ +

+ + +

+ +

+ + +

+ + +
+
+ + +
+
+ + + + + + + + + + + + + +
+ + + CSS3 变量 + +
+ 工作需要了解了一下CSS3变量内容,简单记录一下。 +
+ +
+ + + +
+ + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archives/2021/index.html b/archives/2021/index.html new file mode 100644 index 0000000..3dba534 --- /dev/null +++ b/archives/2021/index.html @@ -0,0 +1,1072 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + DayDay's Studio. +
+
+
+ + + +
+
+
+ +

+ + +

+ +

+ + +

+ + +
+
+ + +
+
+ + + + + + + + + + + + + +
+ + + CSS3 变量 + +
+ 工作需要了解了一下CSS3变量内容,简单记录一下。 +
+ +
+ + + + + + + + + + +
+ + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archives/index.html b/archives/index.html new file mode 100644 index 0000000..0dbcd84 --- /dev/null +++ b/archives/index.html @@ -0,0 +1,1301 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + DayDay's Studio. +
+
+
+ + + +
+
+
+ +

+ + +

+ +

+ + +

+ + +
+
+ + +
+
+ + + + + + + + + + + + + +
+ + + CSS3 变量 + +
+ 工作需要了解了一下CSS3变量内容,简单记录一下。 +
+ +
+ + + + + + + + + + + + + + + + + + + + +
+ + + 媒体自动播放 + +
+ 前几天工作上遇到需要自动播放视频的需求,在自己搜索和亲友团的帮助下,整理处以下内容。 +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archives/page/2/index.html b/archives/page/2/index.html new file mode 100644 index 0000000..8efbf04 --- /dev/null +++ b/archives/page/2/index.html @@ -0,0 +1,1301 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + DayDay's Studio. +
+
+
+ + + +
+
+
+ +

+ + +

+ +

+ + +

+ + +
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/algolia/algoliasearch.js b/assets/algolia/algoliasearch.js new file mode 100644 index 0000000..7707138 --- /dev/null +++ b/assets/algolia/algoliasearch.js @@ -0,0 +1,7190 @@ +/*! algoliasearch 3.35.1 | © 2014, 2015 Algolia SAS | github.com/algolia/algoliasearch-client-js */ +(function(f){var g;if(typeof window!=='undefined'){g=window}else if(typeof self!=='undefined'){g=self}g.ALGOLIA_MIGRATION_LAYER=f()})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;owindow.ALGOLIA_SUPPORTS_DOCWRITE = true\x3C/script>'); + + if (window.ALGOLIA_SUPPORTS_DOCWRITE === true) { + document.write('\x3Cscript src="' + v2ScriptUrl + '">\x3C/script>'); + scriptLoaded('document.write')(); + } else { + loadScript(v2ScriptUrl, scriptLoaded('DOMElement')); + } + } catch (e) { + loadScript(v2ScriptUrl, scriptLoaded('DOMElement')); + } +} + +function scriptLoaded(method) { + return function log() { + var message = 'AlgoliaSearch: loaded V2 script using ' + method; + + if (window.console && window.console.log) { + window.console.log(message); + } + }; +} + +},{"1":1}],4:[function(require,module,exports){ +'use strict'; + +/* eslint no-unused-vars: [2, {"vars": "local"}] */ + +module.exports = oldGlobals; + +// put old window.AlgoliaSearch.. into window. again so that +// users upgrading to V3 without changing their code, will be warned +function oldGlobals() { + var message = '-- AlgoliaSearch V2 => V3 error --\n' + + 'You are trying to use a new version of the AlgoliaSearch JavaScript client with an old notation.\n' + + 'Please read our migration guide at https://github.com/algolia/algoliasearch-client-js/wiki/Migration-guide-from-2.x.x-to-3.x.x\n' + + '-- /AlgoliaSearch V2 => V3 error --'; + + window.AlgoliaSearch = function() { + throw new Error(message); + }; + + window.AlgoliaSearchHelper = function() { + throw new Error(message); + }; + + window.AlgoliaExplainResults = function() { + throw new Error(message); + }; +} + +},{}],5:[function(require,module,exports){ +'use strict'; + +// This script will be browserified and prepended to the normal build +// directly in window, not wrapped in any module definition +// To avoid cases where we are loaded with /latest/ along with +migrationLayer("algoliasearch"); + +// Now onto the V2 related code: +// If the client is using /latest/$BUILDNAME.min.js, load V2 of the library +// +// Otherwise, setup a migration layer that will throw on old constructors like +// new AlgoliaSearch(). +// So that users upgrading from v2 to v3 will have a clear information +// message on what to do if they did not read the migration guide +function migrationLayer(buildName) { + var isUsingLatest = require(2); + var loadV2 = require(3); + var oldGlobals = require(4); + + if (isUsingLatest(buildName)) { + loadV2(buildName); + } else { + oldGlobals(); + } +} + +},{"2":2,"3":3,"4":4}]},{},[5])(5) +});(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.algoliasearch = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= v31, + * and the Firebug extension (any Firefox version) are known + * to support "%c" CSS customizations. + * + * TODO: add a `localStorage` variable to explicitly enable/disable colors + */ + +function useColors() { + // NB: In an Electron preload script, document will be defined but not fully + // initialized. Since we know we're in Chrome, we'll just detect this case + // explicitly + if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { + return true; + } + + // is webkit? http://stackoverflow.com/a/16459606/376773 + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || + // is firebug? http://stackoverflow.com/a/398120/376773 + (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || + // is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + // double check webkit in userAgent just in case we are in a worker + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); +} + +/** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ + +exports.formatters.j = function(v) { + try { + return JSON.stringify(v); + } catch (err) { + return '[UnexpectedJSONParseError]: ' + err.message; + } +}; + + +/** + * Colorize log arguments if enabled. + * + * @api public + */ + +function formatArgs(args) { + var useColors = this.useColors; + + args[0] = (useColors ? '%c' : '') + + this.namespace + + (useColors ? ' %c' : ' ') + + args[0] + + (useColors ? '%c ' : ' ') + + '+' + exports.humanize(this.diff); + + if (!useColors) return; + + var c = 'color: ' + this.color; + args.splice(1, 0, c, 'color: inherit') + + // the final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + var index = 0; + var lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, function(match) { + if ('%%' === match) return; + index++; + if ('%c' === match) { + // we only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); + + args.splice(lastC, 0, c); +} + +/** + * Invokes `console.log()` when available. + * No-op when `console.log` is not a "function". + * + * @api public + */ + +function log() { + // this hackery is required for IE8/9, where + // the `console.log` function doesn't have 'apply' + return 'object' === typeof console + && console.log + && Function.prototype.apply.call(console.log, console, arguments); +} + +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ + +function save(namespaces) { + try { + if (null == namespaces) { + exports.storage.removeItem('debug'); + } else { + exports.storage.debug = namespaces; + } + } catch(e) {} +} + +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ + +function load() { + var r; + try { + r = exports.storage.debug; + } catch(e) {} + + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG + if (!r && typeof process !== 'undefined' && 'env' in process) { + r = process.env.DEBUG; + } + + return r; +} + +/** + * Enable namespaces listed in `localStorage.debug` initially. + */ + +exports.enable(load()); + +/** + * Localstorage attempts to return the localstorage. + * + * This is necessary because safari throws + * when a user disables cookies/localstorage + * and you attempt to access it. + * + * @return {LocalStorage} + * @api private + */ + +function localstorage() { + try { + return window.localStorage; + } catch (e) {} +} + +}).call(this,require(12)) +},{"12":12,"2":2}],2:[function(require,module,exports){ + +/** + * This is the common logic for both the Node.js and web browser + * implementations of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; +exports.coerce = coerce; +exports.disable = disable; +exports.enable = enable; +exports.enabled = enabled; +exports.humanize = require(9); + +/** + * The currently active debug mode names, and names to skip. + */ + +exports.names = []; +exports.skips = []; + +/** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". + */ + +exports.formatters = {}; + +/** + * Previous log timestamp. + */ + +var prevTime; + +/** + * Select a color. + * @param {String} namespace + * @return {Number} + * @api private + */ + +function selectColor(namespace) { + var hash = 0, i; + + for (i in namespace) { + hash = ((hash << 5) - hash) + namespace.charCodeAt(i); + hash |= 0; // Convert to 32bit integer + } + + return exports.colors[Math.abs(hash) % exports.colors.length]; +} + +/** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + +function createDebug(namespace) { + + function debug() { + // disabled? + if (!debug.enabled) return; + + var self = debug; + + // set `diff` timestamp + var curr = +new Date(); + var ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; + + // turn the `arguments` into a proper Array + var args = new Array(arguments.length); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i]; + } + + args[0] = exports.coerce(args[0]); + + if ('string' !== typeof args[0]) { + // anything else let's inspect with %O + args.unshift('%O'); + } + + // apply any `formatters` transformations + var index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { + // if we encounter an escaped % then don't increase the array index + if (match === '%%') return match; + index++; + var formatter = exports.formatters[format]; + if ('function' === typeof formatter) { + var val = args[index]; + match = formatter.call(self, val); + + // now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); + + // apply env-specific formatting (colors, etc.) + exports.formatArgs.call(self, args); + + var logFn = debug.log || exports.log || console.log.bind(console); + logFn.apply(self, args); + } + + debug.namespace = namespace; + debug.enabled = exports.enabled(namespace); + debug.useColors = exports.useColors(); + debug.color = selectColor(namespace); + + // env-specific initialization logic for debug instances + if ('function' === typeof exports.init) { + exports.init(debug); + } + + return debug; +} + +/** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + +function enable(namespaces) { + exports.save(namespaces); + + exports.names = []; + exports.skips = []; + + var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); + var len = split.length; + + for (var i = 0; i < len; i++) { + if (!split[i]) continue; // ignore empty strings + namespaces = split[i].replace(/\*/g, '.*?'); + if (namespaces[0] === '-') { + exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); + } else { + exports.names.push(new RegExp('^' + namespaces + '$')); + } + } +} + +/** + * Disable debug output. + * + * @api public + */ + +function disable() { + exports.enable(''); +} + +/** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + +function enabled(name) { + var i, len; + for (i = 0, len = exports.skips.length; i < len; i++) { + if (exports.skips[i].test(name)) { + return false; + } + } + for (i = 0, len = exports.names.length; i < len; i++) { + if (exports.names[i].test(name)) { + return true; + } + } + return false; +} + +/** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + +function coerce(val) { + if (val instanceof Error) return val.stack || val.message; + return val; +} + +},{"9":9}],3:[function(require,module,exports){ +(function (process,global){ +/*! + * @overview es6-promise - a tiny implementation of Promises/A+. + * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) + * @license Licensed under MIT license + * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE + * @version 4.1.1 + */ + +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global.ES6Promise = factory()); +}(this, (function () { 'use strict'; + +function objectOrFunction(x) { + var type = typeof x; + return x !== null && (type === 'object' || type === 'function'); +} + +function isFunction(x) { + return typeof x === 'function'; +} + +var _isArray = undefined; +if (Array.isArray) { + _isArray = Array.isArray; +} else { + _isArray = function (x) { + return Object.prototype.toString.call(x) === '[object Array]'; + }; +} + +var isArray = _isArray; + +var len = 0; +var vertxNext = undefined; +var customSchedulerFn = undefined; + +var asap = function asap(callback, arg) { + queue[len] = callback; + queue[len + 1] = arg; + len += 2; + if (len === 2) { + // If len is 2, that means that we need to schedule an async flush. + // If additional callbacks are queued before the queue is flushed, they + // will be processed by this flush that we are scheduling. + if (customSchedulerFn) { + customSchedulerFn(flush); + } else { + scheduleFlush(); + } + } +}; + +function setScheduler(scheduleFn) { + customSchedulerFn = scheduleFn; +} + +function setAsap(asapFn) { + asap = asapFn; +} + +var browserWindow = typeof window !== 'undefined' ? window : undefined; +var browserGlobal = browserWindow || {}; +var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; +var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]'; + +// test for web worker but not in IE10 +var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; + +// node +function useNextTick() { + // node version 0.10.x displays a deprecation warning when nextTick is used recursively + // see https://github.com/cujojs/when/issues/410 for details + return function () { + return process.nextTick(flush); + }; +} + +// vertx +function useVertxTimer() { + if (typeof vertxNext !== 'undefined') { + return function () { + vertxNext(flush); + }; + } + + return useSetTimeout(); +} + +function useMutationObserver() { + var iterations = 0; + var observer = new BrowserMutationObserver(flush); + var node = document.createTextNode(''); + observer.observe(node, { characterData: true }); + + return function () { + node.data = iterations = ++iterations % 2; + }; +} + +// web worker +function useMessageChannel() { + var channel = new MessageChannel(); + channel.port1.onmessage = flush; + return function () { + return channel.port2.postMessage(0); + }; +} + +function useSetTimeout() { + // Store setTimeout reference so es6-promise will be unaffected by + // other code modifying setTimeout (like sinon.useFakeTimers()) + var globalSetTimeout = setTimeout; + return function () { + return globalSetTimeout(flush, 1); + }; +} + +var queue = new Array(1000); +function flush() { + for (var i = 0; i < len; i += 2) { + var callback = queue[i]; + var arg = queue[i + 1]; + + callback(arg); + + queue[i] = undefined; + queue[i + 1] = undefined; + } + + len = 0; +} + +function attemptVertx() { + try { + var r = require; + var vertx = r('vertx'); + vertxNext = vertx.runOnLoop || vertx.runOnContext; + return useVertxTimer(); + } catch (e) { + return useSetTimeout(); + } +} + +var scheduleFlush = undefined; +// Decide what async method to use to triggering processing of queued callbacks: +if (isNode) { + scheduleFlush = useNextTick(); +} else if (BrowserMutationObserver) { + scheduleFlush = useMutationObserver(); +} else if (isWorker) { + scheduleFlush = useMessageChannel(); +} else if (browserWindow === undefined && typeof require === 'function') { + scheduleFlush = attemptVertx(); +} else { + scheduleFlush = useSetTimeout(); +} + +function then(onFulfillment, onRejection) { + var _arguments = arguments; + + var parent = this; + + var child = new this.constructor(noop); + + if (child[PROMISE_ID] === undefined) { + makePromise(child); + } + + var _state = parent._state; + + if (_state) { + (function () { + var callback = _arguments[_state - 1]; + asap(function () { + return invokeCallback(_state, child, callback, parent._result); + }); + })(); + } else { + subscribe(parent, child, onFulfillment, onRejection); + } + + return child; +} + +/** + `Promise.resolve` returns a promise that will become resolved with the + passed `value`. It is shorthand for the following: + + ```javascript + let promise = new Promise(function(resolve, reject){ + resolve(1); + }); + + promise.then(function(value){ + // value === 1 + }); + ``` + + Instead of writing the above, your code now simply becomes the following: + + ```javascript + let promise = Promise.resolve(1); + + promise.then(function(value){ + // value === 1 + }); + ``` + + @method resolve + @static + @param {Any} value value that the returned promise will be resolved with + Useful for tooling. + @return {Promise} a promise that will become fulfilled with the given + `value` +*/ +function resolve$1(object) { + /*jshint validthis:true */ + var Constructor = this; + + if (object && typeof object === 'object' && object.constructor === Constructor) { + return object; + } + + var promise = new Constructor(noop); + resolve(promise, object); + return promise; +} + +var PROMISE_ID = Math.random().toString(36).substring(16); + +function noop() {} + +var PENDING = void 0; +var FULFILLED = 1; +var REJECTED = 2; + +var GET_THEN_ERROR = new ErrorObject(); + +function selfFulfillment() { + return new TypeError("You cannot resolve a promise with itself"); +} + +function cannotReturnOwn() { + return new TypeError('A promises callback cannot return that same promise.'); +} + +function getThen(promise) { + try { + return promise.then; + } catch (error) { + GET_THEN_ERROR.error = error; + return GET_THEN_ERROR; + } +} + +function tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) { + try { + then$$1.call(value, fulfillmentHandler, rejectionHandler); + } catch (e) { + return e; + } +} + +function handleForeignThenable(promise, thenable, then$$1) { + asap(function (promise) { + var sealed = false; + var error = tryThen(then$$1, thenable, function (value) { + if (sealed) { + return; + } + sealed = true; + if (thenable !== value) { + resolve(promise, value); + } else { + fulfill(promise, value); + } + }, function (reason) { + if (sealed) { + return; + } + sealed = true; + + reject(promise, reason); + }, 'Settle: ' + (promise._label || ' unknown promise')); + + if (!sealed && error) { + sealed = true; + reject(promise, error); + } + }, promise); +} + +function handleOwnThenable(promise, thenable) { + if (thenable._state === FULFILLED) { + fulfill(promise, thenable._result); + } else if (thenable._state === REJECTED) { + reject(promise, thenable._result); + } else { + subscribe(thenable, undefined, function (value) { + return resolve(promise, value); + }, function (reason) { + return reject(promise, reason); + }); + } +} + +function handleMaybeThenable(promise, maybeThenable, then$$1) { + if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) { + handleOwnThenable(promise, maybeThenable); + } else { + if (then$$1 === GET_THEN_ERROR) { + reject(promise, GET_THEN_ERROR.error); + GET_THEN_ERROR.error = null; + } else if (then$$1 === undefined) { + fulfill(promise, maybeThenable); + } else if (isFunction(then$$1)) { + handleForeignThenable(promise, maybeThenable, then$$1); + } else { + fulfill(promise, maybeThenable); + } + } +} + +function resolve(promise, value) { + if (promise === value) { + reject(promise, selfFulfillment()); + } else if (objectOrFunction(value)) { + handleMaybeThenable(promise, value, getThen(value)); + } else { + fulfill(promise, value); + } +} + +function publishRejection(promise) { + if (promise._onerror) { + promise._onerror(promise._result); + } + + publish(promise); +} + +function fulfill(promise, value) { + if (promise._state !== PENDING) { + return; + } + + promise._result = value; + promise._state = FULFILLED; + + if (promise._subscribers.length !== 0) { + asap(publish, promise); + } +} + +function reject(promise, reason) { + if (promise._state !== PENDING) { + return; + } + promise._state = REJECTED; + promise._result = reason; + + asap(publishRejection, promise); +} + +function subscribe(parent, child, onFulfillment, onRejection) { + var _subscribers = parent._subscribers; + var length = _subscribers.length; + + parent._onerror = null; + + _subscribers[length] = child; + _subscribers[length + FULFILLED] = onFulfillment; + _subscribers[length + REJECTED] = onRejection; + + if (length === 0 && parent._state) { + asap(publish, parent); + } +} + +function publish(promise) { + var subscribers = promise._subscribers; + var settled = promise._state; + + if (subscribers.length === 0) { + return; + } + + var child = undefined, + callback = undefined, + detail = promise._result; + + for (var i = 0; i < subscribers.length; i += 3) { + child = subscribers[i]; + callback = subscribers[i + settled]; + + if (child) { + invokeCallback(settled, child, callback, detail); + } else { + callback(detail); + } + } + + promise._subscribers.length = 0; +} + +function ErrorObject() { + this.error = null; +} + +var TRY_CATCH_ERROR = new ErrorObject(); + +function tryCatch(callback, detail) { + try { + return callback(detail); + } catch (e) { + TRY_CATCH_ERROR.error = e; + return TRY_CATCH_ERROR; + } +} + +function invokeCallback(settled, promise, callback, detail) { + var hasCallback = isFunction(callback), + value = undefined, + error = undefined, + succeeded = undefined, + failed = undefined; + + if (hasCallback) { + value = tryCatch(callback, detail); + + if (value === TRY_CATCH_ERROR) { + failed = true; + error = value.error; + value.error = null; + } else { + succeeded = true; + } + + if (promise === value) { + reject(promise, cannotReturnOwn()); + return; + } + } else { + value = detail; + succeeded = true; + } + + if (promise._state !== PENDING) { + // noop + } else if (hasCallback && succeeded) { + resolve(promise, value); + } else if (failed) { + reject(promise, error); + } else if (settled === FULFILLED) { + fulfill(promise, value); + } else if (settled === REJECTED) { + reject(promise, value); + } +} + +function initializePromise(promise, resolver) { + try { + resolver(function resolvePromise(value) { + resolve(promise, value); + }, function rejectPromise(reason) { + reject(promise, reason); + }); + } catch (e) { + reject(promise, e); + } +} + +var id = 0; +function nextId() { + return id++; +} + +function makePromise(promise) { + promise[PROMISE_ID] = id++; + promise._state = undefined; + promise._result = undefined; + promise._subscribers = []; +} + +function Enumerator$1(Constructor, input) { + this._instanceConstructor = Constructor; + this.promise = new Constructor(noop); + + if (!this.promise[PROMISE_ID]) { + makePromise(this.promise); + } + + if (isArray(input)) { + this.length = input.length; + this._remaining = input.length; + + this._result = new Array(this.length); + + if (this.length === 0) { + fulfill(this.promise, this._result); + } else { + this.length = this.length || 0; + this._enumerate(input); + if (this._remaining === 0) { + fulfill(this.promise, this._result); + } + } + } else { + reject(this.promise, validationError()); + } +} + +function validationError() { + return new Error('Array Methods must be provided an Array'); +} + +Enumerator$1.prototype._enumerate = function (input) { + for (var i = 0; this._state === PENDING && i < input.length; i++) { + this._eachEntry(input[i], i); + } +}; + +Enumerator$1.prototype._eachEntry = function (entry, i) { + var c = this._instanceConstructor; + var resolve$$1 = c.resolve; + + if (resolve$$1 === resolve$1) { + var _then = getThen(entry); + + if (_then === then && entry._state !== PENDING) { + this._settledAt(entry._state, i, entry._result); + } else if (typeof _then !== 'function') { + this._remaining--; + this._result[i] = entry; + } else if (c === Promise$2) { + var promise = new c(noop); + handleMaybeThenable(promise, entry, _then); + this._willSettleAt(promise, i); + } else { + this._willSettleAt(new c(function (resolve$$1) { + return resolve$$1(entry); + }), i); + } + } else { + this._willSettleAt(resolve$$1(entry), i); + } +}; + +Enumerator$1.prototype._settledAt = function (state, i, value) { + var promise = this.promise; + + if (promise._state === PENDING) { + this._remaining--; + + if (state === REJECTED) { + reject(promise, value); + } else { + this._result[i] = value; + } + } + + if (this._remaining === 0) { + fulfill(promise, this._result); + } +}; + +Enumerator$1.prototype._willSettleAt = function (promise, i) { + var enumerator = this; + + subscribe(promise, undefined, function (value) { + return enumerator._settledAt(FULFILLED, i, value); + }, function (reason) { + return enumerator._settledAt(REJECTED, i, reason); + }); +}; + +/** + `Promise.all` accepts an array of promises, and returns a new promise which + is fulfilled with an array of fulfillment values for the passed promises, or + rejected with the reason of the first passed promise to be rejected. It casts all + elements of the passed iterable to promises as it runs this algorithm. + + Example: + + ```javascript + let promise1 = resolve(1); + let promise2 = resolve(2); + let promise3 = resolve(3); + let promises = [ promise1, promise2, promise3 ]; + + Promise.all(promises).then(function(array){ + // The array here would be [ 1, 2, 3 ]; + }); + ``` + + If any of the `promises` given to `all` are rejected, the first promise + that is rejected will be given as an argument to the returned promises's + rejection handler. For example: + + Example: + + ```javascript + let promise1 = resolve(1); + let promise2 = reject(new Error("2")); + let promise3 = reject(new Error("3")); + let promises = [ promise1, promise2, promise3 ]; + + Promise.all(promises).then(function(array){ + // Code here never runs because there are rejected promises! + }, function(error) { + // error.message === "2" + }); + ``` + + @method all + @static + @param {Array} entries array of promises + @param {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} promise that is fulfilled when all `promises` have been + fulfilled, or rejected if any of them become rejected. + @static +*/ +function all$1(entries) { + return new Enumerator$1(this, entries).promise; +} + +/** + `Promise.race` returns a new promise which is settled in the same way as the + first passed promise to settle. + + Example: + + ```javascript + let promise1 = new Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 1'); + }, 200); + }); + + let promise2 = new Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 2'); + }, 100); + }); + + Promise.race([promise1, promise2]).then(function(result){ + // result === 'promise 2' because it was resolved before promise1 + // was resolved. + }); + ``` + + `Promise.race` is deterministic in that only the state of the first + settled promise matters. For example, even if other promises given to the + `promises` array argument are resolved, but the first settled promise has + become rejected before the other promises became fulfilled, the returned + promise will become rejected: + + ```javascript + let promise1 = new Promise(function(resolve, reject){ + setTimeout(function(){ + resolve('promise 1'); + }, 200); + }); + + let promise2 = new Promise(function(resolve, reject){ + setTimeout(function(){ + reject(new Error('promise 2')); + }, 100); + }); + + Promise.race([promise1, promise2]).then(function(result){ + // Code here never runs + }, function(reason){ + // reason.message === 'promise 2' because promise 2 became rejected before + // promise 1 became fulfilled + }); + ``` + + An example real-world use case is implementing timeouts: + + ```javascript + Promise.race([ajax('foo.json'), timeout(5000)]) + ``` + + @method race + @static + @param {Array} promises array of promises to observe + Useful for tooling. + @return {Promise} a promise which settles in the same way as the first passed + promise to settle. +*/ +function race$1(entries) { + /*jshint validthis:true */ + var Constructor = this; + + if (!isArray(entries)) { + return new Constructor(function (_, reject) { + return reject(new TypeError('You must pass an array to race.')); + }); + } else { + return new Constructor(function (resolve, reject) { + var length = entries.length; + for (var i = 0; i < length; i++) { + Constructor.resolve(entries[i]).then(resolve, reject); + } + }); + } +} + +/** + `Promise.reject` returns a promise rejected with the passed `reason`. + It is shorthand for the following: + + ```javascript + let promise = new Promise(function(resolve, reject){ + reject(new Error('WHOOPS')); + }); + + promise.then(function(value){ + // Code here doesn't run because the promise is rejected! + }, function(reason){ + // reason.message === 'WHOOPS' + }); + ``` + + Instead of writing the above, your code now simply becomes the following: + + ```javascript + let promise = Promise.reject(new Error('WHOOPS')); + + promise.then(function(value){ + // Code here doesn't run because the promise is rejected! + }, function(reason){ + // reason.message === 'WHOOPS' + }); + ``` + + @method reject + @static + @param {Any} reason value that the returned promise will be rejected with. + Useful for tooling. + @return {Promise} a promise rejected with the given `reason`. +*/ +function reject$1(reason) { + /*jshint validthis:true */ + var Constructor = this; + var promise = new Constructor(noop); + reject(promise, reason); + return promise; +} + +function needsResolver() { + throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); +} + +function needsNew() { + throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); +} + +/** + Promise objects represent the eventual result of an asynchronous operation. The + primary way of interacting with a promise is through its `then` method, which + registers callbacks to receive either a promise's eventual value or the reason + why the promise cannot be fulfilled. + + Terminology + ----------- + + - `promise` is an object or function with a `then` method whose behavior conforms to this specification. + - `thenable` is an object or function that defines a `then` method. + - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). + - `exception` is a value that is thrown using the throw statement. + - `reason` is a value that indicates why a promise was rejected. + - `settled` the final resting state of a promise, fulfilled or rejected. + + A promise can be in one of three states: pending, fulfilled, or rejected. + + Promises that are fulfilled have a fulfillment value and are in the fulfilled + state. Promises that are rejected have a rejection reason and are in the + rejected state. A fulfillment value is never a thenable. + + Promises can also be said to *resolve* a value. If this value is also a + promise, then the original promise's settled state will match the value's + settled state. So a promise that *resolves* a promise that rejects will + itself reject, and a promise that *resolves* a promise that fulfills will + itself fulfill. + + + Basic Usage: + ------------ + + ```js + let promise = new Promise(function(resolve, reject) { + // on success + resolve(value); + + // on failure + reject(reason); + }); + + promise.then(function(value) { + // on fulfillment + }, function(reason) { + // on rejection + }); + ``` + + Advanced Usage: + --------------- + + Promises shine when abstracting away asynchronous interactions such as + `XMLHttpRequest`s. + + ```js + function getJSON(url) { + return new Promise(function(resolve, reject){ + let xhr = new XMLHttpRequest(); + + xhr.open('GET', url); + xhr.onreadystatechange = handler; + xhr.responseType = 'json'; + xhr.setRequestHeader('Accept', 'application/json'); + xhr.send(); + + function handler() { + if (this.readyState === this.DONE) { + if (this.status === 200) { + resolve(this.response); + } else { + reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); + } + } + }; + }); + } + + getJSON('/posts.json').then(function(json) { + // on fulfillment + }, function(reason) { + // on rejection + }); + ``` + + Unlike callbacks, promises are great composable primitives. + + ```js + Promise.all([ + getJSON('/posts'), + getJSON('/comments') + ]).then(function(values){ + values[0] // => postsJSON + values[1] // => commentsJSON + + return values; + }); + ``` + + @class Promise + @param {function} resolver + Useful for tooling. + @constructor +*/ +function Promise$2(resolver) { + this[PROMISE_ID] = nextId(); + this._result = this._state = undefined; + this._subscribers = []; + + if (noop !== resolver) { + typeof resolver !== 'function' && needsResolver(); + this instanceof Promise$2 ? initializePromise(this, resolver) : needsNew(); + } +} + +Promise$2.all = all$1; +Promise$2.race = race$1; +Promise$2.resolve = resolve$1; +Promise$2.reject = reject$1; +Promise$2._setScheduler = setScheduler; +Promise$2._setAsap = setAsap; +Promise$2._asap = asap; + +Promise$2.prototype = { + constructor: Promise$2, + + /** + The primary way of interacting with a promise is through its `then` method, + which registers callbacks to receive either a promise's eventual value or the + reason why the promise cannot be fulfilled. + + ```js + findUser().then(function(user){ + // user is available + }, function(reason){ + // user is unavailable, and you are given the reason why + }); + ``` + + Chaining + -------- + + The return value of `then` is itself a promise. This second, 'downstream' + promise is resolved with the return value of the first promise's fulfillment + or rejection handler, or rejected if the handler throws an exception. + + ```js + findUser().then(function (user) { + return user.name; + }, function (reason) { + return 'default name'; + }).then(function (userName) { + // If `findUser` fulfilled, `userName` will be the user's name, otherwise it + // will be `'default name'` + }); + + findUser().then(function (user) { + throw new Error('Found user, but still unhappy'); + }, function (reason) { + throw new Error('`findUser` rejected and we're unhappy'); + }).then(function (value) { + // never reached + }, function (reason) { + // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. + // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. + }); + ``` + If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. + + ```js + findUser().then(function (user) { + throw new PedagogicalException('Upstream error'); + }).then(function (value) { + // never reached + }).then(function (value) { + // never reached + }, function (reason) { + // The `PedgagocialException` is propagated all the way down to here + }); + ``` + + Assimilation + ------------ + + Sometimes the value you want to propagate to a downstream promise can only be + retrieved asynchronously. This can be achieved by returning a promise in the + fulfillment or rejection handler. The downstream promise will then be pending + until the returned promise is settled. This is called *assimilation*. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // The user's comments are now available + }); + ``` + + If the assimliated promise rejects, then the downstream promise will also reject. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // If `findCommentsByAuthor` fulfills, we'll have the value here + }, function (reason) { + // If `findCommentsByAuthor` rejects, we'll have the reason here + }); + ``` + + Simple Example + -------------- + + Synchronous Example + + ```javascript + let result; + + try { + result = findResult(); + // success + } catch(reason) { + // failure + } + ``` + + Errback Example + + ```js + findResult(function(result, err){ + if (err) { + // failure + } else { + // success + } + }); + ``` + + Promise Example; + + ```javascript + findResult().then(function(result){ + // success + }, function(reason){ + // failure + }); + ``` + + Advanced Example + -------------- + + Synchronous Example + + ```javascript + let author, books; + + try { + author = findAuthor(); + books = findBooksByAuthor(author); + // success + } catch(reason) { + // failure + } + ``` + + Errback Example + + ```js + + function foundBooks(books) { + + } + + function failure(reason) { + + } + + findAuthor(function(author, err){ + if (err) { + failure(err); + // failure + } else { + try { + findBoooksByAuthor(author, function(books, err) { + if (err) { + failure(err); + } else { + try { + foundBooks(books); + } catch(reason) { + failure(reason); + } + } + }); + } catch(error) { + failure(err); + } + // success + } + }); + ``` + + Promise Example; + + ```javascript + findAuthor(). + then(findBooksByAuthor). + then(function(books){ + // found books + }).catch(function(reason){ + // something went wrong + }); + ``` + + @method then + @param {Function} onFulfilled + @param {Function} onRejected + Useful for tooling. + @return {Promise} + */ + then: then, + + /** + `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same + as the catch block of a try/catch statement. + + ```js + function findAuthor(){ + throw new Error('couldn't find that author'); + } + + // synchronous + try { + findAuthor(); + } catch(reason) { + // something went wrong + } + + // async with promises + findAuthor().catch(function(reason){ + // something went wrong + }); + ``` + + @method catch + @param {Function} onRejection + Useful for tooling. + @return {Promise} + */ + 'catch': function _catch(onRejection) { + return this.then(null, onRejection); + } +}; + +/*global self*/ +function polyfill$1() { + var local = undefined; + + if (typeof global !== 'undefined') { + local = global; + } else if (typeof self !== 'undefined') { + local = self; + } else { + try { + local = Function('return this')(); + } catch (e) { + throw new Error('polyfill failed because global object is unavailable in this environment'); + } + } + + var P = local.Promise; + + if (P) { + var promiseToString = null; + try { + promiseToString = Object.prototype.toString.call(P.resolve()); + } catch (e) { + // silently ignored + } + + if (promiseToString === '[object Promise]' && !P.cast) { + return; + } + } + + local.Promise = Promise$2; +} + +// Strange compat.. +Promise$2.polyfill = polyfill$1; +Promise$2.Promise = Promise$2; + +return Promise$2; + +}))); + + + +}).call(this,require(12),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"12":12}],4:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +function EventEmitter() { + this._events = this._events || {}; + this._maxListeners = this._maxListeners || undefined; +} +module.exports = EventEmitter; + +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; + +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._maxListeners = undefined; + +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +EventEmitter.defaultMaxListeners = 10; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function(n) { + if (!isNumber(n) || n < 0 || isNaN(n)) + throw TypeError('n must be a positive number'); + this._maxListeners = n; + return this; +}; + +EventEmitter.prototype.emit = function(type) { + var er, handler, len, args, i, listeners; + + if (!this._events) + this._events = {}; + + // If there is no 'error' event listener then throw. + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { + er = arguments[1]; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; + } + } + } + + handler = this._events[type]; + + if (isUndefined(handler)) + return false; + + if (isFunction(handler)) { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + args = Array.prototype.slice.call(arguments, 1); + handler.apply(this, args); + } + } else if (isObject(handler)) { + args = Array.prototype.slice.call(arguments, 1); + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); + } + + return true; +}; + +EventEmitter.prototype.addListener = function(type, listener) { + var m; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events) + this._events = {}; + + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); + + if (!this._events[type]) + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; + + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; + } else { + m = EventEmitter.defaultMaxListeners; + } + + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); + } + } + } + + return this; +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + var fired = false; + + function g() { + this.removeListener(type, g); + + if (!fired) { + fired = true; + listener.apply(this, arguments); + } + } + + g.listener = listener; + this.on(type, g); + + return this; +}; + +// emits a 'removeListener' event iff the listener was removed +EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events || !this._events[type]) + return this; + + list = this._events[type]; + length = list.length; + position = -1; + + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); + + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; + } + } + + if (position < 0) + return this; + + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); + } + + if (this._events.removeListener) + this.emit('removeListener', type, listener); + } + + return this; +}; + +EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; + + if (!this._events) + return this; + + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; + } + + listeners = this._events[type]; + + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else if (listeners) { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); + } + delete this._events[type]; + + return this; +}; + +EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; + else + ret = this._events[type].slice(); + return ret; +}; + +EventEmitter.prototype.listenerCount = function(type) { + if (this._events) { + var evlistener = this._events[type]; + + if (isFunction(evlistener)) + return 1; + else if (evlistener) + return evlistener.length; + } + return 0; +}; + +EventEmitter.listenerCount = function(emitter, type) { + return emitter.listenerCount(type); +}; + +function isFunction(arg) { + return typeof arg === 'function'; +} + +function isNumber(arg) { + return typeof arg === 'number'; +} + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} + +function isUndefined(arg) { + return arg === void 0; +} + +},{}],5:[function(require,module,exports){ + +var hasOwn = Object.prototype.hasOwnProperty; +var toString = Object.prototype.toString; + +module.exports = function forEach (obj, fn, ctx) { + if (toString.call(fn) !== '[object Function]') { + throw new TypeError('iterator must be a function'); + } + var l = obj.length; + if (l === +l) { + for (var i = 0; i < l; i++) { + fn.call(ctx, obj[i], i, obj); + } + } else { + for (var k in obj) { + if (hasOwn.call(obj, k)) { + fn.call(ctx, obj[k], k, obj); + } + } + } +}; + + +},{}],6:[function(require,module,exports){ +(function (global){ +var win; + +if (typeof window !== "undefined") { + win = window; +} else if (typeof global !== "undefined") { + win = global; +} else if (typeof self !== "undefined"){ + win = self; +} else { + win = {}; +} + +module.exports = win; + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],7:[function(require,module,exports){ +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } +} + +},{}],8:[function(require,module,exports){ +var toString = {}.toString; + +module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; + +},{}],9:[function(require,module,exports){ +/** + * Helpers. + */ + +var s = 1000; +var m = s * 60; +var h = m * 60; +var d = h * 24; +var y = d * 365.25; + +/** + * Parse or format the given `val`. + * + * Options: + * + * - `long` verbose formatting [false] + * + * @param {String|Number} val + * @param {Object} [options] + * @throws {Error} throw an error if val is not a non-empty string or a number + * @return {String|Number} + * @api public + */ + +module.exports = function(val, options) { + options = options || {}; + var type = typeof val; + if (type === 'string' && val.length > 0) { + return parse(val); + } else if (type === 'number' && isNaN(val) === false) { + return options.long ? fmtLong(val) : fmtShort(val); + } + throw new Error( + 'val is not a non-empty string or a valid number. val=' + + JSON.stringify(val) + ); +}; + +/** + * Parse the given `str` and return milliseconds. + * + * @param {String} str + * @return {Number} + * @api private + */ + +function parse(str) { + str = String(str); + if (str.length > 100) { + return; + } + var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec( + str + ); + if (!match) { + return; + } + var n = parseFloat(match[1]); + var type = (match[2] || 'ms').toLowerCase(); + switch (type) { + case 'years': + case 'year': + case 'yrs': + case 'yr': + case 'y': + return n * y; + case 'days': + case 'day': + case 'd': + return n * d; + case 'hours': + case 'hour': + case 'hrs': + case 'hr': + case 'h': + return n * h; + case 'minutes': + case 'minute': + case 'mins': + case 'min': + case 'm': + return n * m; + case 'seconds': + case 'second': + case 'secs': + case 'sec': + case 's': + return n * s; + case 'milliseconds': + case 'millisecond': + case 'msecs': + case 'msec': + case 'ms': + return n; + default: + return undefined; + } +} + +/** + * Short format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function fmtShort(ms) { + if (ms >= d) { + return Math.round(ms / d) + 'd'; + } + if (ms >= h) { + return Math.round(ms / h) + 'h'; + } + if (ms >= m) { + return Math.round(ms / m) + 'm'; + } + if (ms >= s) { + return Math.round(ms / s) + 's'; + } + return ms + 'ms'; +} + +/** + * Long format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function fmtLong(ms) { + return plural(ms, d, 'day') || + plural(ms, h, 'hour') || + plural(ms, m, 'minute') || + plural(ms, s, 'second') || + ms + ' ms'; +} + +/** + * Pluralization helper. + */ + +function plural(ms, n, name) { + if (ms < n) { + return; + } + if (ms < n * 1.5) { + return Math.floor(ms / n) + ' ' + name; + } + return Math.ceil(ms / n) + ' ' + name + 's'; +} + +},{}],10:[function(require,module,exports){ +'use strict'; + +// modified from https://github.com/es-shims/es5-shim +var has = Object.prototype.hasOwnProperty; +var toStr = Object.prototype.toString; +var slice = Array.prototype.slice; +var isArgs = require(11); +var isEnumerable = Object.prototype.propertyIsEnumerable; +var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString'); +var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype'); +var dontEnums = [ + 'toString', + 'toLocaleString', + 'valueOf', + 'hasOwnProperty', + 'isPrototypeOf', + 'propertyIsEnumerable', + 'constructor' +]; +var equalsConstructorPrototype = function (o) { + var ctor = o.constructor; + return ctor && ctor.prototype === o; +}; +var excludedKeys = { + $console: true, + $external: true, + $frame: true, + $frameElement: true, + $frames: true, + $innerHeight: true, + $innerWidth: true, + $outerHeight: true, + $outerWidth: true, + $pageXOffset: true, + $pageYOffset: true, + $parent: true, + $scrollLeft: true, + $scrollTop: true, + $scrollX: true, + $scrollY: true, + $self: true, + $webkitIndexedDB: true, + $webkitStorageInfo: true, + $window: true +}; +var hasAutomationEqualityBug = (function () { + /* global window */ + if (typeof window === 'undefined') { return false; } + for (var k in window) { + try { + if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') { + try { + equalsConstructorPrototype(window[k]); + } catch (e) { + return true; + } + } + } catch (e) { + return true; + } + } + return false; +}()); +var equalsConstructorPrototypeIfNotBuggy = function (o) { + /* global window */ + if (typeof window === 'undefined' || !hasAutomationEqualityBug) { + return equalsConstructorPrototype(o); + } + try { + return equalsConstructorPrototype(o); + } catch (e) { + return false; + } +}; + +var keysShim = function keys(object) { + var isObject = object !== null && typeof object === 'object'; + var isFunction = toStr.call(object) === '[object Function]'; + var isArguments = isArgs(object); + var isString = isObject && toStr.call(object) === '[object String]'; + var theKeys = []; + + if (!isObject && !isFunction && !isArguments) { + throw new TypeError('Object.keys called on a non-object'); + } + + var skipProto = hasProtoEnumBug && isFunction; + if (isString && object.length > 0 && !has.call(object, 0)) { + for (var i = 0; i < object.length; ++i) { + theKeys.push(String(i)); + } + } + + if (isArguments && object.length > 0) { + for (var j = 0; j < object.length; ++j) { + theKeys.push(String(j)); + } + } else { + for (var name in object) { + if (!(skipProto && name === 'prototype') && has.call(object, name)) { + theKeys.push(String(name)); + } + } + } + + if (hasDontEnumBug) { + var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object); + + for (var k = 0; k < dontEnums.length; ++k) { + if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) { + theKeys.push(dontEnums[k]); + } + } + } + return theKeys; +}; + +keysShim.shim = function shimObjectKeys() { + if (Object.keys) { + var keysWorksWithArguments = (function () { + // Safari 5.0 bug + return (Object.keys(arguments) || '').length === 2; + }(1, 2)); + if (!keysWorksWithArguments) { + var originalKeys = Object.keys; + Object.keys = function keys(object) { + if (isArgs(object)) { + return originalKeys(slice.call(object)); + } else { + return originalKeys(object); + } + }; + } + } else { + Object.keys = keysShim; + } + return Object.keys || keysShim; +}; + +module.exports = keysShim; + +},{"11":11}],11:[function(require,module,exports){ +'use strict'; + +var toStr = Object.prototype.toString; + +module.exports = function isArguments(value) { + var str = toStr.call(value); + var isArgs = str === '[object Arguments]'; + if (!isArgs) { + isArgs = str !== '[object Array]' && + value !== null && + typeof value === 'object' && + typeof value.length === 'number' && + value.length >= 0 && + toStr.call(value.callee) === '[object Function]'; + } + return isArgs; +}; + +},{}],12:[function(require,module,exports){ +// shim for using process in browser +var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + +},{}],13:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +'use strict'; + +// If obj.hasOwnProperty has been overridden, then calling +// obj.hasOwnProperty(prop) will break. +// See: https://github.com/joyent/node/issues/1707 +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + +module.exports = function(qs, sep, eq, options) { + sep = sep || '&'; + eq = eq || '='; + var obj = {}; + + if (typeof qs !== 'string' || qs.length === 0) { + return obj; + } + + var regexp = /\+/g; + qs = qs.split(sep); + + var maxKeys = 1000; + if (options && typeof options.maxKeys === 'number') { + maxKeys = options.maxKeys; + } + + var len = qs.length; + // maxKeys <= 0 means that we should not limit keys count + if (maxKeys > 0 && len > maxKeys) { + len = maxKeys; + } + + for (var i = 0; i < len; ++i) { + var x = qs[i].replace(regexp, '%20'), + idx = x.indexOf(eq), + kstr, vstr, k, v; + + if (idx >= 0) { + kstr = x.substr(0, idx); + vstr = x.substr(idx + 1); + } else { + kstr = x; + vstr = ''; + } + + k = decodeURIComponent(kstr); + v = decodeURIComponent(vstr); + + if (!hasOwnProperty(obj, k)) { + obj[k] = v; + } else if (isArray(obj[k])) { + obj[k].push(v); + } else { + obj[k] = [obj[k], v]; + } + } + + return obj; +}; + +var isArray = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; +}; + +},{}],14:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +'use strict'; + +var stringifyPrimitive = function(v) { + switch (typeof v) { + case 'string': + return v; + + case 'boolean': + return v ? 'true' : 'false'; + + case 'number': + return isFinite(v) ? v : ''; + + default: + return ''; + } +}; + +module.exports = function(obj, sep, eq, name) { + sep = sep || '&'; + eq = eq || '='; + if (obj === null) { + obj = undefined; + } + + if (typeof obj === 'object') { + return map(objectKeys(obj), function(k) { + var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; + if (isArray(obj[k])) { + return map(obj[k], function(v) { + return ks + encodeURIComponent(stringifyPrimitive(v)); + }).join(sep); + } else { + return ks + encodeURIComponent(stringifyPrimitive(obj[k])); + } + }).join(sep); + + } + + if (!name) return ''; + return encodeURIComponent(stringifyPrimitive(name)) + eq + + encodeURIComponent(stringifyPrimitive(obj)); +}; + +var isArray = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; +}; + +function map (xs, f) { + if (xs.map) return xs.map(f); + var res = []; + for (var i = 0; i < xs.length; i++) { + res.push(f(xs[i], i)); + } + return res; +} + +var objectKeys = Object.keys || function (obj) { + var res = []; + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key); + } + return res; +}; + +},{}],15:[function(require,module,exports){ +'use strict'; + +exports.decode = exports.parse = require(13); +exports.encode = exports.stringify = require(14); + +},{"13":13,"14":14}],16:[function(require,module,exports){ +module.exports = AlgoliaSearch; + +var Index = require(18); +var deprecate = require(28); +var deprecatedMessage = require(29); +var AlgoliaSearchCore = require(17); +var inherits = require(7); +var errors = require(30); + +function AlgoliaSearch() { + AlgoliaSearchCore.apply(this, arguments); +} + +inherits(AlgoliaSearch, AlgoliaSearchCore); + +/* + * Delete an index + * + * @param indexName the name of index to delete + * @param callback the result callback called with two arguments + * error: null or Error('message') + * content: the server answer that contains the task ID + */ +AlgoliaSearch.prototype.deleteIndex = function(indexName, callback) { + return this._jsonRequest({ + method: 'DELETE', + url: '/1/indexes/' + encodeURIComponent(indexName), + hostType: 'write', + callback: callback + }); +}; + +/** + * Move an existing index. + * @param srcIndexName the name of index to copy. + * @param dstIndexName the new index name that will contains a copy of + * srcIndexName (destination will be overriten if it already exist). + * @param callback the result callback called with two arguments + * error: null or Error('message') + * content: the server answer that contains the task ID + */ +AlgoliaSearch.prototype.moveIndex = function(srcIndexName, dstIndexName, callback) { + var postObj = { + operation: 'move', destination: dstIndexName + }; + return this._jsonRequest({ + method: 'POST', + url: '/1/indexes/' + encodeURIComponent(srcIndexName) + '/operation', + body: postObj, + hostType: 'write', + callback: callback + }); +}; + +/** + * Copy an existing index. + * @param srcIndexName the name of index to copy. + * @param dstIndexName the new index name that will contains a copy + * of srcIndexName (destination will be overriten if it already exist). + * @param scope an array of scopes to copy: ['settings', 'synonyms', 'rules'] + * @param callback the result callback called with two arguments + * error: null or Error('message') + * content: the server answer that contains the task ID + */ +AlgoliaSearch.prototype.copyIndex = function(srcIndexName, dstIndexName, scopeOrCallback, _callback) { + var postObj = { + operation: 'copy', + destination: dstIndexName + }; + var callback = _callback; + if (typeof scopeOrCallback === 'function') { + // oops, old behaviour of third argument being a function + callback = scopeOrCallback; + } else if (Array.isArray(scopeOrCallback) && scopeOrCallback.length > 0) { + postObj.scope = scopeOrCallback; + } else if (typeof scopeOrCallback !== 'undefined') { + throw new Error('the scope given to `copyIndex` was not an array with settings, synonyms or rules'); + } + return this._jsonRequest({ + method: 'POST', + url: '/1/indexes/' + encodeURIComponent(srcIndexName) + '/operation', + body: postObj, + hostType: 'write', + callback: callback + }); +}; + +/** + * Return last log entries. + * @param offset Specify the first entry to retrieve (0-based, 0 is the most recent log entry). + * @param length Specify the maximum number of entries to retrieve starting + * at offset. Maximum allowed value: 1000. + * @param type Specify the maximum number of entries to retrieve starting + * at offset. Maximum allowed value: 1000. + * @param callback the result callback called with two arguments + * error: null or Error('message') + * content: the server answer that contains the task ID + */ +AlgoliaSearch.prototype.getLogs = function(offset, length, callback) { + var clone = require(26); + var params = {}; + if (typeof offset === 'object') { + // getLogs(params) + params = clone(offset); + callback = length; + } else if (arguments.length === 0 || typeof offset === 'function') { + // getLogs([cb]) + callback = offset; + } else if (arguments.length === 1 || typeof length === 'function') { + // getLogs(1, [cb)] + callback = length; + params.offset = offset; + } else { + // getLogs(1, 2, [cb]) + params.offset = offset; + params.length = length; + } + + if (params.offset === undefined) params.offset = 0; + if (params.length === undefined) params.length = 10; + + return this._jsonRequest({ + method: 'GET', + url: '/1/logs?' + this._getSearchParams(params, ''), + hostType: 'read', + callback: callback + }); +}; + +/* + * List all existing indexes (paginated) + * + * @param page The page to retrieve, starting at 0. + * @param callback the result callback called with two arguments + * error: null or Error('message') + * content: the server answer with index list + */ +AlgoliaSearch.prototype.listIndexes = function(page, callback) { + var params = ''; + + if (page === undefined || typeof page === 'function') { + callback = page; + } else { + params = '?page=' + page; + } + + return this._jsonRequest({ + method: 'GET', + url: '/1/indexes' + params, + hostType: 'read', + callback: callback + }); +}; + +/* + * Get the index object initialized + * + * @param indexName the name of index + * @param callback the result callback with one argument (the Index instance) + */ +AlgoliaSearch.prototype.initIndex = function(indexName) { + return new Index(this, indexName); +}; + +AlgoliaSearch.prototype.initAnalytics = function(opts) { + // the actual require must be inside the function, when put outside then you have a cyclic dependency + // not well resolved that ends up making the main "./index.js" (main module, the agloliasearch function) + // export an object instead of a function + // Other workarounds: + // - rewrite the lib in ES6, cyclic dependencies may be better supported + // - move initAnalytics to a property on the main module (algoliasearch.initAnalytics), + // same as places. + // The current API was made mostly to mimic the one made in PHP + var createAnalyticsClient = require(27); + return createAnalyticsClient(this.applicationID, this.apiKey, opts); +}; + +/* + * @deprecated use client.listApiKeys + */ +AlgoliaSearch.prototype.listUserKeys = deprecate(function(callback) { + return this.listApiKeys(callback); +}, deprecatedMessage('client.listUserKeys()', 'client.listApiKeys()')); + +/* + * List all existing api keys with their associated ACLs + * + * @param callback the result callback called with two arguments + * error: null or Error('message') + * content: the server answer with api keys list + */ +AlgoliaSearch.prototype.listApiKeys = function(callback) { + return this._jsonRequest({ + method: 'GET', + url: '/1/keys', + hostType: 'read', + callback: callback + }); +}; + +/* + * @deprecated see client.getApiKey + */ +AlgoliaSearch.prototype.getUserKeyACL = deprecate(function(key, callback) { + return this.getApiKey(key, callback); +}, deprecatedMessage('client.getUserKeyACL()', 'client.getApiKey()')); + +/* + * Get an API key + * + * @param key + * @param callback the result callback called with two arguments + * error: null or Error('message') + * content: the server answer with the right API key + */ +AlgoliaSearch.prototype.getApiKey = function(key, callback) { + return this._jsonRequest({ + method: 'GET', + url: '/1/keys/' + key, + hostType: 'read', + callback: callback + }); +}; + +/* + * @deprecated see client.deleteApiKey + */ +AlgoliaSearch.prototype.deleteUserKey = deprecate(function(key, callback) { + return this.deleteApiKey(key, callback); +}, deprecatedMessage('client.deleteUserKey()', 'client.deleteApiKey()')); + +/* + * Delete an existing API key + * @param key + * @param callback the result callback called with two arguments + * error: null or Error('message') + * content: the server answer with the date of deletion + */ +AlgoliaSearch.prototype.deleteApiKey = function(key, callback) { + return this._jsonRequest({ + method: 'DELETE', + url: '/1/keys/' + key, + hostType: 'write', + callback: callback + }); +}; + +/** + * Restore a deleted API key + * + * @param {String} key - The key to restore + * @param {Function} callback - The result callback called with two arguments + * error: null or Error('message') + * content: the server answer with the restored API key + * @return {Promise|undefined} Returns a promise if no callback given + * @example + * client.restoreApiKey('APIKEY') + * @see {@link https://www.algolia.com/doc/rest-api/search/#restore-api-key|Algolia REST API Documentation} + */ +AlgoliaSearch.prototype.restoreApiKey = function(key, callback) { + return this._jsonRequest({ + method: 'POST', + url: '/1/keys/' + key + '/restore', + hostType: 'write', + callback: callback + }); +}; + +/* + @deprecated see client.addApiKey + */ +AlgoliaSearch.prototype.addUserKey = deprecate(function(acls, params, callback) { + return this.addApiKey(acls, params, callback); +}, deprecatedMessage('client.addUserKey()', 'client.addApiKey()')); + +/* + * Add a new global API key + * + * @param {string[]} acls - The list of ACL for this key. Defined by an array of strings that + * can contains the following values: + * - search: allow to search (https and http) + * - addObject: allows to add/update an object in the index (https only) + * - deleteObject : allows to delete an existing object (https only) + * - deleteIndex : allows to delete index content (https only) + * - settings : allows to get index settings (https only) + * - editSettings : allows to change index settings (https only) + * @param {Object} [params] - Optionnal parameters to set for the key + * @param {number} params.validity - Number of seconds after which the key will be automatically removed (0 means no time limit for this key) + * @param {number} params.maxQueriesPerIPPerHour - Number of API calls allowed from an IP address per hour + * @param {number} params.maxHitsPerQuery - Number of hits this API key can retrieve in one call + * @param {string[]} params.indexes - Allowed targeted indexes for this key + * @param {string} params.description - A description for your key + * @param {string[]} params.referers - A list of authorized referers + * @param {Object} params.queryParameters - Force the key to use specific query parameters + * @param {Function} callback - The result callback called with two arguments + * error: null or Error('message') + * content: the server answer with the added API key + * @return {Promise|undefined} Returns a promise if no callback given + * @example + * client.addApiKey(['search'], { + * validity: 300, + * maxQueriesPerIPPerHour: 2000, + * maxHitsPerQuery: 3, + * indexes: ['fruits'], + * description: 'Eat three fruits', + * referers: ['*.algolia.com'], + * queryParameters: { + * tagFilters: ['public'], + * } + * }) + * @see {@link https://www.algolia.com/doc/rest_api#AddKey|Algolia REST API Documentation} + */ +AlgoliaSearch.prototype.addApiKey = function(acls, params, callback) { + var isArray = require(8); + var usage = 'Usage: client.addApiKey(arrayOfAcls[, params, callback])'; + + if (!isArray(acls)) { + throw new Error(usage); + } + + if (arguments.length === 1 || typeof params === 'function') { + callback = params; + params = null; + } + + var postObj = { + acl: acls + }; + + if (params) { + postObj.validity = params.validity; + postObj.maxQueriesPerIPPerHour = params.maxQueriesPerIPPerHour; + postObj.maxHitsPerQuery = params.maxHitsPerQuery; + postObj.indexes = params.indexes; + postObj.description = params.description; + + if (params.queryParameters) { + postObj.queryParameters = this._getSearchParams(params.queryParameters, ''); + } + + postObj.referers = params.referers; + } + + return this._jsonRequest({ + method: 'POST', + url: '/1/keys', + body: postObj, + hostType: 'write', + callback: callback + }); +}; + +/** + * @deprecated Please use client.addApiKey() + */ +AlgoliaSearch.prototype.addUserKeyWithValidity = deprecate(function(acls, params, callback) { + return this.addApiKey(acls, params, callback); +}, deprecatedMessage('client.addUserKeyWithValidity()', 'client.addApiKey()')); + +/** + * @deprecated Please use client.updateApiKey() + */ +AlgoliaSearch.prototype.updateUserKey = deprecate(function(key, acls, params, callback) { + return this.updateApiKey(key, acls, params, callback); +}, deprecatedMessage('client.updateUserKey()', 'client.updateApiKey()')); + +/** + * Update an existing API key + * @param {string} key - The key to update + * @param {string[]} acls - The list of ACL for this key. Defined by an array of strings that + * can contains the following values: + * - search: allow to search (https and http) + * - addObject: allows to add/update an object in the index (https only) + * - deleteObject : allows to delete an existing object (https only) + * - deleteIndex : allows to delete index content (https only) + * - settings : allows to get index settings (https only) + * - editSettings : allows to change index settings (https only) + * @param {Object} [params] - Optionnal parameters to set for the key + * @param {number} params.validity - Number of seconds after which the key will be automatically removed (0 means no time limit for this key) + * @param {number} params.maxQueriesPerIPPerHour - Number of API calls allowed from an IP address per hour + * @param {number} params.maxHitsPerQuery - Number of hits this API key can retrieve in one call + * @param {string[]} params.indexes - Allowed targeted indexes for this key + * @param {string} params.description - A description for your key + * @param {string[]} params.referers - A list of authorized referers + * @param {Object} params.queryParameters - Force the key to use specific query parameters + * @param {Function} callback - The result callback called with two arguments + * error: null or Error('message') + * content: the server answer with the modified API key + * @return {Promise|undefined} Returns a promise if no callback given + * @example + * client.updateApiKey('APIKEY', ['search'], { + * validity: 300, + * maxQueriesPerIPPerHour: 2000, + * maxHitsPerQuery: 3, + * indexes: ['fruits'], + * description: 'Eat three fruits', + * referers: ['*.algolia.com'], + * queryParameters: { + * tagFilters: ['public'], + * } + * }) + * @see {@link https://www.algolia.com/doc/rest_api#UpdateIndexKey|Algolia REST API Documentation} + */ +AlgoliaSearch.prototype.updateApiKey = function(key, acls, params, callback) { + var isArray = require(8); + var usage = 'Usage: client.updateApiKey(key, arrayOfAcls[, params, callback])'; + + if (!isArray(acls)) { + throw new Error(usage); + } + + if (arguments.length === 2 || typeof params === 'function') { + callback = params; + params = null; + } + + var putObj = { + acl: acls + }; + + if (params) { + putObj.validity = params.validity; + putObj.maxQueriesPerIPPerHour = params.maxQueriesPerIPPerHour; + putObj.maxHitsPerQuery = params.maxHitsPerQuery; + putObj.indexes = params.indexes; + putObj.description = params.description; + + if (params.queryParameters) { + putObj.queryParameters = this._getSearchParams(params.queryParameters, ''); + } + + putObj.referers = params.referers; + } + + return this._jsonRequest({ + method: 'PUT', + url: '/1/keys/' + key, + body: putObj, + hostType: 'write', + callback: callback + }); +}; + +/** + * Initialize a new batch of search queries + * @deprecated use client.search() + */ +AlgoliaSearch.prototype.startQueriesBatch = deprecate(function startQueriesBatchDeprecated() { + this._batch = []; +}, deprecatedMessage('client.startQueriesBatch()', 'client.search()')); + +/** + * Add a search query in the batch + * @deprecated use client.search() + */ +AlgoliaSearch.prototype.addQueryInBatch = deprecate(function addQueryInBatchDeprecated(indexName, query, args) { + this._batch.push({ + indexName: indexName, + query: query, + params: args + }); +}, deprecatedMessage('client.addQueryInBatch()', 'client.search()')); + +/** + * Launch the batch of queries using XMLHttpRequest. + * @deprecated use client.search() + */ +AlgoliaSearch.prototype.sendQueriesBatch = deprecate(function sendQueriesBatchDeprecated(callback) { + return this.search(this._batch, callback); +}, deprecatedMessage('client.sendQueriesBatch()', 'client.search()')); + +/** + * Perform write operations across multiple indexes. + * + * To reduce the amount of time spent on network round trips, + * you can create, update, or delete several objects in one call, + * using the batch endpoint (all operations are done in the given order). + * + * Available actions: + * - addObject + * - updateObject + * - partialUpdateObject + * - partialUpdateObjectNoCreate + * - deleteObject + * + * https://www.algolia.com/doc/rest_api#Indexes + * @param {Object[]} operations An array of operations to perform + * @return {Promise|undefined} Returns a promise if no callback given + * @example + * client.batch([{ + * action: 'addObject', + * indexName: 'clients', + * body: { + * name: 'Bill' + * } + * }, { + * action: 'udpateObject', + * indexName: 'fruits', + * body: { + * objectID: '29138', + * name: 'banana' + * } + * }], cb) + */ +AlgoliaSearch.prototype.batch = function(operations, callback) { + var isArray = require(8); + var usage = 'Usage: client.batch(operations[, callback])'; + + if (!isArray(operations)) { + throw new Error(usage); + } + + return this._jsonRequest({ + method: 'POST', + url: '/1/indexes/*/batch', + body: { + requests: operations + }, + hostType: 'write', + callback: callback + }); +}; + +/** + * Assign or Move a userID to a cluster + * + * @param {string} data.userID The userID to assign to a new cluster + * @param {string} data.cluster The cluster to assign the user to + * @return {Promise|undefined} Returns a promise if no callback given + * @example + * client.assignUserID({ cluster: 'c1-test', userID: 'some-user' }); + */ +AlgoliaSearch.prototype.assignUserID = function(data, callback) { + if (!data.userID || !data.cluster) { + throw new errors.AlgoliaSearchError('You have to provide both a userID and cluster', data); + } + return this._jsonRequest({ + method: 'POST', + url: '/1/clusters/mapping', + hostType: 'write', + body: {cluster: data.cluster}, + callback: callback, + headers: { + 'x-algolia-user-id': data.userID + } + }); +}; + +/** + * Assign a array of userIDs to a cluster. + * + * @param {Array} data.userIDs The array of userIDs to assign to a new cluster + * @param {string} data.cluster The cluster to assign the user to + * @return {Promise|undefined} Returns a promise if no callback given + * @example + * client.assignUserIDs({ cluster: 'c1-test', userIDs: ['some-user-1', 'some-user-2'] }); + */ +AlgoliaSearch.prototype.assignUserIDs = function(data, callback) { + if (!data.userIDs || !data.cluster) { + throw new errors.AlgoliaSearchError('You have to provide both an array of userIDs and cluster', data); + } + return this._jsonRequest({ + method: 'POST', + url: '/1/clusters/mapping/batch', + hostType: 'write', + body: { + cluster: data.cluster, + users: data.userIDs + }, + callback: callback + }); +}; + +/** + * Get the top userIDs + * + * (the callback is the second argument) + * + * @return {Promise|undefined} Returns a promise if no callback given + * @example + * client.getTopUserID(); + */ +AlgoliaSearch.prototype.getTopUserID = function(callback) { + return this._jsonRequest({ + method: 'GET', + url: '/1/clusters/mapping/top', + hostType: 'read', + callback: callback + }); +}; + +/** + * Get userID + * + * @param {string} data.userID The userID to get info about + * @return {Promise|undefined} Returns a promise if no callback given + * @example + * client.getUserID({ userID: 'some-user' }); + */ +AlgoliaSearch.prototype.getUserID = function(data, callback) { + if (!data.userID) { + throw new errors.AlgoliaSearchError('You have to provide a userID', {debugData: data}); + } + return this._jsonRequest({ + method: 'GET', + url: '/1/clusters/mapping/' + data.userID, + hostType: 'read', + callback: callback + }); +}; + +/** + * List all the clusters + * + * (the callback is the second argument) + * + * @return {Promise|undefined} Returns a promise if no callback given + * @example + * client.listClusters(); + */ +AlgoliaSearch.prototype.listClusters = function(callback) { + return this._jsonRequest({ + method: 'GET', + url: '/1/clusters', + hostType: 'read', + callback: callback + }); +}; + +/** + * List the userIDs + * + * (the callback is the second argument) + * + * @param {string} data.hitsPerPage How many hits on every page + * @param {string} data.page The page to retrieve + * @return {Promise|undefined} Returns a promise if no callback given + * @example + * client.listClusters(); + * client.listClusters({ page: 3, hitsPerPage: 30}); + */ +AlgoliaSearch.prototype.listUserIDs = function(data, callback) { + return this._jsonRequest({ + method: 'GET', + url: '/1/clusters/mapping', + body: data, + hostType: 'read', + callback: callback + }); +}; + +/** + * Remove an userID + * + * @param {string} data.userID The userID to assign to a new cluster + * @return {Promise|undefined} Returns a promise if no callback given + * @example + * client.removeUserID({ userID: 'some-user' }); + */ +AlgoliaSearch.prototype.removeUserID = function(data, callback) { + if (!data.userID) { + throw new errors.AlgoliaSearchError('You have to provide a userID', {debugData: data}); + } + return this._jsonRequest({ + method: 'DELETE', + url: '/1/clusters/mapping', + hostType: 'write', + callback: callback, + headers: { + 'x-algolia-user-id': data.userID + } + }); +}; + +/** + * Search for userIDs + * + * @param {string} data.cluster The cluster to target + * @param {string} data.query The query to execute + * @param {string} data.hitsPerPage How many hits on every page + * @param {string} data.page The page to retrieve + * @return {Promise|undefined} Returns a promise if no callback given + * @example + * client.searchUserIDs({ cluster: 'c1-test', query: 'some-user' }); + * client.searchUserIDs({ + * cluster: "c1-test", + * query: "some-user", + * page: 3, + * hitsPerPage: 2 + * }); + */ +AlgoliaSearch.prototype.searchUserIDs = function(data, callback) { + return this._jsonRequest({ + method: 'POST', + url: '/1/clusters/mapping/search', + body: data, + hostType: 'read', + callback: callback + }); +}; + +/** + * Set strategy for personalization + * + * @param {Object} data + * @param {Object} data.eventsScoring Associate a score to an event + * @param {Object} data.eventsScoring. The name of the event + * @param {Number} data.eventsScoring..score The score to associate to + * @param {String} data.eventsScoring..type Either "click", "conversion" or "view" + * @param {Object} data.facetsScoring Associate a score to a facet + * @param {Object} data.facetsScoring. The name of the facet + * @param {Number} data.facetsScoring..score The score to associate to + * @return {Promise|undefined} Returns a promise if no callback given + * @example + * client.setPersonalizationStrategy({ + * eventsScoring: { + * "Add to cart": { score: 50, type: "conversion" }, + * Purchase: { score: 100, type: "conversion" } + * }, + * facetsScoring: { + * brand: { score: 100 }, + * categories: { score: 10 } + * } + * }); + */ +AlgoliaSearch.prototype.setPersonalizationStrategy = function(data, callback) { + return this._jsonRequest({ + method: 'POST', + url: '/1/recommendation/personalization/strategy', + body: data, + hostType: 'write', + callback: callback + }); +}; + +/** + * Get strategy for personalization + * + * @return {Promise|undefined} Returns a promise if no callback given + * @example + * client.getPersonalizationStrategy(); + */ + +AlgoliaSearch.prototype.getPersonalizationStrategy = function(callback) { + return this._jsonRequest({ + method: 'GET', + url: '/1/recommendation/personalization/strategy', + hostType: 'read', + callback: callback + }); +}; + +// environment specific methods +AlgoliaSearch.prototype.destroy = notImplemented; +AlgoliaSearch.prototype.enableRateLimitForward = notImplemented; +AlgoliaSearch.prototype.disableRateLimitForward = notImplemented; +AlgoliaSearch.prototype.useSecuredAPIKey = notImplemented; +AlgoliaSearch.prototype.disableSecuredAPIKey = notImplemented; +AlgoliaSearch.prototype.generateSecuredApiKey = notImplemented; +AlgoliaSearch.prototype.getSecuredApiKeyRemainingValidity = notImplemented; + +function notImplemented() { + var message = 'Not implemented in this environment.\n' + + 'If you feel this is a mistake, write to support@algolia.com'; + + throw new errors.AlgoliaSearchError(message); +} + +},{"17":17,"18":18,"26":26,"27":27,"28":28,"29":29,"30":30,"7":7,"8":8}],17:[function(require,module,exports){ +(function (process){ +module.exports = AlgoliaSearchCore; + +var errors = require(30); +var exitPromise = require(31); +var IndexCore = require(20); +var store = require(36); + +// We will always put the API KEY in the JSON body in case of too long API KEY, +// to avoid query string being too long and failing in various conditions (our server limit, browser limit, +// proxies limit) +var MAX_API_KEY_LENGTH = 500; +var RESET_APP_DATA_TIMER = + process.env.RESET_APP_DATA_TIMER && parseInt(process.env.RESET_APP_DATA_TIMER, 10) || + 60 * 2 * 1000; // after 2 minutes reset to first host + +/* + * Algolia Search library initialization + * https://www.algolia.com/ + * + * @param {string} applicationID - Your applicationID, found in your dashboard + * @param {string} apiKey - Your API key, found in your dashboard + * @param {Object} [opts] + * @param {number} [opts.timeout=2000] - The request timeout set in milliseconds, + * another request will be issued after this timeout + * @param {string} [opts.protocol='https:'] - The protocol used to query Algolia Search API. + * Set to 'http:' to force using http. + * @param {Object|Array} [opts.hosts={ + * read: [this.applicationID + '-dsn.algolia.net'].concat([ + * this.applicationID + '-1.algolianet.com', + * this.applicationID + '-2.algolianet.com', + * this.applicationID + '-3.algolianet.com'] + * ]), + * write: [this.applicationID + '.algolia.net'].concat([ + * this.applicationID + '-1.algolianet.com', + * this.applicationID + '-2.algolianet.com', + * this.applicationID + '-3.algolianet.com'] + * ]) - The hosts to use for Algolia Search API. + * If you provide them, you will less benefit from our HA implementation + */ +function AlgoliaSearchCore(applicationID, apiKey, opts) { + var debug = require(1)('algoliasearch'); + + var clone = require(26); + var isArray = require(8); + var map = require(32); + + var usage = 'Usage: algoliasearch(applicationID, apiKey, opts)'; + + if (opts._allowEmptyCredentials !== true && !applicationID) { + throw new errors.AlgoliaSearchError('Please provide an application ID. ' + usage); + } + + if (opts._allowEmptyCredentials !== true && !apiKey) { + throw new errors.AlgoliaSearchError('Please provide an API key. ' + usage); + } + + this.applicationID = applicationID; + this.apiKey = apiKey; + + this.hosts = { + read: [], + write: [] + }; + + opts = opts || {}; + + this._timeouts = opts.timeouts || { + connect: 1 * 1000, // 500ms connect is GPRS latency + read: 2 * 1000, + write: 30 * 1000 + }; + + // backward compat, if opts.timeout is passed, we use it to configure all timeouts like before + if (opts.timeout) { + this._timeouts.connect = this._timeouts.read = this._timeouts.write = opts.timeout; + } + + var protocol = opts.protocol || 'https:'; + // while we advocate for colon-at-the-end values: 'http:' for `opts.protocol` + // we also accept `http` and `https`. It's a common error. + if (!/:$/.test(protocol)) { + protocol = protocol + ':'; + } + + if (protocol !== 'http:' && protocol !== 'https:') { + throw new errors.AlgoliaSearchError('protocol must be `http:` or `https:` (was `' + opts.protocol + '`)'); + } + + this._checkAppIdData(); + + if (!opts.hosts) { + var defaultHosts = map(this._shuffleResult, function(hostNumber) { + return applicationID + '-' + hostNumber + '.algolianet.com'; + }); + + // no hosts given, compute defaults + var mainSuffix = (opts.dsn === false ? '' : '-dsn') + '.algolia.net'; + this.hosts.read = [this.applicationID + mainSuffix].concat(defaultHosts); + this.hosts.write = [this.applicationID + '.algolia.net'].concat(defaultHosts); + } else if (isArray(opts.hosts)) { + // when passing custom hosts, we need to have a different host index if the number + // of write/read hosts are different. + this.hosts.read = clone(opts.hosts); + this.hosts.write = clone(opts.hosts); + } else { + this.hosts.read = clone(opts.hosts.read); + this.hosts.write = clone(opts.hosts.write); + } + + // add protocol and lowercase hosts + this.hosts.read = map(this.hosts.read, prepareHost(protocol)); + this.hosts.write = map(this.hosts.write, prepareHost(protocol)); + + this.extraHeaders = {}; + + // In some situations you might want to warm the cache + this.cache = opts._cache || {}; + + this._ua = opts._ua; + this._useCache = opts._useCache === undefined || opts._cache ? true : opts._useCache; + this._useRequestCache = this._useCache && opts._useRequestCache; + this._useFallback = opts.useFallback === undefined ? true : opts.useFallback; + + this._setTimeout = opts._setTimeout; + + debug('init done, %j', this); +} + +/* + * Get the index object initialized + * + * @param indexName the name of index + * @param callback the result callback with one argument (the Index instance) + */ +AlgoliaSearchCore.prototype.initIndex = function(indexName) { + return new IndexCore(this, indexName); +}; + +/** +* Add an extra field to the HTTP request +* +* @param name the header field name +* @param value the header field value +*/ +AlgoliaSearchCore.prototype.setExtraHeader = function(name, value) { + this.extraHeaders[name.toLowerCase()] = value; +}; + +/** +* Get the value of an extra HTTP header +* +* @param name the header field name +*/ +AlgoliaSearchCore.prototype.getExtraHeader = function(name) { + return this.extraHeaders[name.toLowerCase()]; +}; + +/** +* Remove an extra field from the HTTP request +* +* @param name the header field name +*/ +AlgoliaSearchCore.prototype.unsetExtraHeader = function(name) { + delete this.extraHeaders[name.toLowerCase()]; +}; + +/** +* Augment sent x-algolia-agent with more data, each agent part +* is automatically separated from the others by a semicolon; +* +* @param algoliaAgent the agent to add +*/ +AlgoliaSearchCore.prototype.addAlgoliaAgent = function(algoliaAgent) { + var algoliaAgentWithDelimiter = '; ' + algoliaAgent; + + if (this._ua.indexOf(algoliaAgentWithDelimiter) === -1) { + this._ua += algoliaAgentWithDelimiter; + } +}; + +/* + * Wrapper that try all hosts to maximize the quality of service + */ +AlgoliaSearchCore.prototype._jsonRequest = function(initialOpts) { + this._checkAppIdData(); + + var requestDebug = require(1)('algoliasearch:' + initialOpts.url); + + + var body; + var cacheID; + var additionalUA = initialOpts.additionalUA || ''; + var cache = initialOpts.cache; + var client = this; + var tries = 0; + var usingFallback = false; + var hasFallback = client._useFallback && client._request.fallback && initialOpts.fallback; + var headers; + + if ( + this.apiKey.length > MAX_API_KEY_LENGTH && + initialOpts.body !== undefined && + (initialOpts.body.params !== undefined || // index.search() + initialOpts.body.requests !== undefined) // client.search() + ) { + initialOpts.body.apiKey = this.apiKey; + headers = this._computeRequestHeaders({ + additionalUA: additionalUA, + withApiKey: false, + headers: initialOpts.headers + }); + } else { + headers = this._computeRequestHeaders({ + additionalUA: additionalUA, + headers: initialOpts.headers + }); + } + + if (initialOpts.body !== undefined) { + body = safeJSONStringify(initialOpts.body); + } + + requestDebug('request start'); + var debugData = []; + + + function doRequest(requester, reqOpts) { + client._checkAppIdData(); + + var startTime = new Date(); + + if (client._useCache && !client._useRequestCache) { + cacheID = initialOpts.url; + } + + // as we sometime use POST requests to pass parameters (like query='aa'), + // the cacheID must also include the body to be different between calls + if (client._useCache && !client._useRequestCache && body) { + cacheID += '_body_' + reqOpts.body; + } + + // handle cache existence + if (isCacheValidWithCurrentID(!client._useRequestCache, cache, cacheID)) { + requestDebug('serving response from cache'); + + var responseText = cache[cacheID]; + + // Cache response must match the type of the original one + return client._promise.resolve({ + body: JSON.parse(responseText), + responseText: responseText + }); + } + + // if we reached max tries + if (tries >= client.hosts[initialOpts.hostType].length) { + if (!hasFallback || usingFallback) { + requestDebug('could not get any response'); + // then stop + return client._promise.reject(new errors.AlgoliaSearchError( + 'Cannot connect to the AlgoliaSearch API.' + + ' Send an email to support@algolia.com to report and resolve the issue.' + + ' Application id was: ' + client.applicationID, {debugData: debugData} + )); + } + + requestDebug('switching to fallback'); + + // let's try the fallback starting from here + tries = 0; + + // method, url and body are fallback dependent + reqOpts.method = initialOpts.fallback.method; + reqOpts.url = initialOpts.fallback.url; + reqOpts.jsonBody = initialOpts.fallback.body; + if (reqOpts.jsonBody) { + reqOpts.body = safeJSONStringify(reqOpts.jsonBody); + } + // re-compute headers, they could be omitting the API KEY + headers = client._computeRequestHeaders({ + additionalUA: additionalUA, + headers: initialOpts.headers + }); + + reqOpts.timeouts = client._getTimeoutsForRequest(initialOpts.hostType); + client._setHostIndexByType(0, initialOpts.hostType); + usingFallback = true; // the current request is now using fallback + return doRequest(client._request.fallback, reqOpts); + } + + var currentHost = client._getHostByType(initialOpts.hostType); + + var url = currentHost + reqOpts.url; + var options = { + body: reqOpts.body, + jsonBody: reqOpts.jsonBody, + method: reqOpts.method, + headers: headers, + timeouts: reqOpts.timeouts, + debug: requestDebug, + forceAuthHeaders: reqOpts.forceAuthHeaders + }; + + requestDebug('method: %s, url: %s, headers: %j, timeouts: %d', + options.method, url, options.headers, options.timeouts); + + if (requester === client._request.fallback) { + requestDebug('using fallback'); + } + + // `requester` is any of this._request or this._request.fallback + // thus it needs to be called using the client as context + return requester.call(client, url, options).then(success, tryFallback); + + function success(httpResponse) { + // compute the status of the response, + // + // When in browser mode, using XDR or JSONP, we have no statusCode available + // So we rely on our API response `status` property. + // But `waitTask` can set a `status` property which is not the statusCode (it's the task status) + // So we check if there's a `message` along `status` and it means it's an error + // + // That's the only case where we have a response.status that's not the http statusCode + var status = httpResponse && httpResponse.body && httpResponse.body.message && httpResponse.body.status || + + // this is important to check the request statusCode AFTER the body eventual + // statusCode because some implementations (jQuery XDomainRequest transport) may + // send statusCode 200 while we had an error + httpResponse.statusCode || + + // When in browser mode, using XDR or JSONP + // we default to success when no error (no response.status && response.message) + // If there was a JSON.parse() error then body is null and it fails + httpResponse && httpResponse.body && 200; + + requestDebug('received response: statusCode: %s, computed statusCode: %d, headers: %j', + httpResponse.statusCode, status, httpResponse.headers); + + var httpResponseOk = Math.floor(status / 100) === 2; + + var endTime = new Date(); + debugData.push({ + currentHost: currentHost, + headers: removeCredentials(headers), + content: body || null, + contentLength: body !== undefined ? body.length : null, + method: reqOpts.method, + timeouts: reqOpts.timeouts, + url: reqOpts.url, + startTime: startTime, + endTime: endTime, + duration: endTime - startTime, + statusCode: status + }); + + if (httpResponseOk) { + if (client._useCache && !client._useRequestCache && cache) { + cache[cacheID] = httpResponse.responseText; + } + + return { + responseText: httpResponse.responseText, + body: httpResponse.body + }; + } + + var shouldRetry = Math.floor(status / 100) !== 4; + + if (shouldRetry) { + tries += 1; + return retryRequest(); + } + + requestDebug('unrecoverable error'); + + // no success and no retry => fail + var unrecoverableError = new errors.AlgoliaSearchError( + httpResponse.body && httpResponse.body.message, {debugData: debugData, statusCode: status} + ); + + return client._promise.reject(unrecoverableError); + } + + function tryFallback(err) { + // error cases: + // While not in fallback mode: + // - CORS not supported + // - network error + // While in fallback mode: + // - timeout + // - network error + // - badly formatted JSONP (script loaded, did not call our callback) + // In both cases: + // - uncaught exception occurs (TypeError) + requestDebug('error: %s, stack: %s', err.message, err.stack); + + var endTime = new Date(); + debugData.push({ + currentHost: currentHost, + headers: removeCredentials(headers), + content: body || null, + contentLength: body !== undefined ? body.length : null, + method: reqOpts.method, + timeouts: reqOpts.timeouts, + url: reqOpts.url, + startTime: startTime, + endTime: endTime, + duration: endTime - startTime + }); + + if (!(err instanceof errors.AlgoliaSearchError)) { + err = new errors.Unknown(err && err.message, err); + } + + tries += 1; + + // stop the request implementation when: + if ( + // we did not generate this error, + // it comes from a throw in some other piece of code + err instanceof errors.Unknown || + + // server sent unparsable JSON + err instanceof errors.UnparsableJSON || + + // max tries and already using fallback or no fallback + tries >= client.hosts[initialOpts.hostType].length && + (usingFallback || !hasFallback)) { + // stop request implementation for this command + err.debugData = debugData; + return client._promise.reject(err); + } + + // When a timeout occurred, retry by raising timeout + if (err instanceof errors.RequestTimeout) { + return retryRequestWithHigherTimeout(); + } + + return retryRequest(); + } + + function retryRequest() { + requestDebug('retrying request'); + client._incrementHostIndex(initialOpts.hostType); + return doRequest(requester, reqOpts); + } + + function retryRequestWithHigherTimeout() { + requestDebug('retrying request with higher timeout'); + client._incrementHostIndex(initialOpts.hostType); + client._incrementTimeoutMultipler(); + reqOpts.timeouts = client._getTimeoutsForRequest(initialOpts.hostType); + return doRequest(requester, reqOpts); + } + } + + function isCacheValidWithCurrentID( + useRequestCache, + currentCache, + currentCacheID + ) { + return ( + client._useCache && + useRequestCache && + currentCache && + currentCache[currentCacheID] !== undefined + ); + } + + + function interopCallbackReturn(request, callback) { + if (isCacheValidWithCurrentID(client._useRequestCache, cache, cacheID)) { + request.catch(function() { + // Release the cache on error + delete cache[cacheID]; + }); + } + + if (typeof initialOpts.callback === 'function') { + // either we have a callback + request.then(function okCb(content) { + exitPromise(function() { + initialOpts.callback(null, callback(content)); + }, client._setTimeout || setTimeout); + }, function nookCb(err) { + exitPromise(function() { + initialOpts.callback(err); + }, client._setTimeout || setTimeout); + }); + } else { + // either we are using promises + return request.then(callback); + } + } + + if (client._useCache && client._useRequestCache) { + cacheID = initialOpts.url; + } + + // as we sometime use POST requests to pass parameters (like query='aa'), + // the cacheID must also include the body to be different between calls + if (client._useCache && client._useRequestCache && body) { + cacheID += '_body_' + body; + } + + if (isCacheValidWithCurrentID(client._useRequestCache, cache, cacheID)) { + requestDebug('serving request from cache'); + + var maybePromiseForCache = cache[cacheID]; + + // In case the cache is warmup with value that is not a promise + var promiseForCache = typeof maybePromiseForCache.then !== 'function' + ? client._promise.resolve({responseText: maybePromiseForCache}) + : maybePromiseForCache; + + return interopCallbackReturn(promiseForCache, function(content) { + // In case of the cache request, return the original value + return JSON.parse(content.responseText); + }); + } + + var request = doRequest( + client._request, { + url: initialOpts.url, + method: initialOpts.method, + body: body, + jsonBody: initialOpts.body, + timeouts: client._getTimeoutsForRequest(initialOpts.hostType), + forceAuthHeaders: initialOpts.forceAuthHeaders + } + ); + + if (client._useCache && client._useRequestCache && cache) { + cache[cacheID] = request; + } + + return interopCallbackReturn(request, function(content) { + // In case of the first request, return the JSON value + return content.body; + }); +}; + +/* +* Transform search param object in query string +* @param {object} args arguments to add to the current query string +* @param {string} params current query string +* @return {string} the final query string +*/ +AlgoliaSearchCore.prototype._getSearchParams = function(args, params) { + if (args === undefined || args === null) { + return params; + } + for (var key in args) { + if (key !== null && args[key] !== undefined && args.hasOwnProperty(key)) { + params += params === '' ? '' : '&'; + params += key + '=' + encodeURIComponent(Object.prototype.toString.call(args[key]) === '[object Array]' ? safeJSONStringify(args[key]) : args[key]); + } + } + return params; +}; + +/** + * Compute the headers for a request + * + * @param [string] options.additionalUA semi-colon separated string with other user agents to add + * @param [boolean=true] options.withApiKey Send the api key as a header + * @param [Object] options.headers Extra headers to send + */ +AlgoliaSearchCore.prototype._computeRequestHeaders = function(options) { + var forEach = require(5); + + var ua = options.additionalUA ? + this._ua + '; ' + options.additionalUA : + this._ua; + + var requestHeaders = { + 'x-algolia-agent': ua, + 'x-algolia-application-id': this.applicationID + }; + + // browser will inline headers in the url, node.js will use http headers + // but in some situations, the API KEY will be too long (big secured API keys) + // so if the request is a POST and the KEY is very long, we will be asked to not put + // it into headers but in the JSON body + if (options.withApiKey !== false) { + requestHeaders['x-algolia-api-key'] = this.apiKey; + } + + if (this.userToken) { + requestHeaders['x-algolia-usertoken'] = this.userToken; + } + + if (this.securityTags) { + requestHeaders['x-algolia-tagfilters'] = this.securityTags; + } + + forEach(this.extraHeaders, function addToRequestHeaders(value, key) { + requestHeaders[key] = value; + }); + + if (options.headers) { + forEach(options.headers, function addToRequestHeaders(value, key) { + requestHeaders[key] = value; + }); + } + + return requestHeaders; +}; + +/** + * Search through multiple indices at the same time + * @param {Object[]} queries An array of queries you want to run. + * @param {string} queries[].indexName The index name you want to target + * @param {string} [queries[].query] The query to issue on this index. Can also be passed into `params` + * @param {Object} queries[].params Any search param like hitsPerPage, .. + * @param {Function} callback Callback to be called + * @return {Promise|undefined} Returns a promise if no callback given + */ +AlgoliaSearchCore.prototype.search = function(queries, opts, callback) { + var isArray = require(8); + var map = require(32); + + var usage = 'Usage: client.search(arrayOfQueries[, callback])'; + + if (!isArray(queries)) { + throw new Error(usage); + } + + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } else if (opts === undefined) { + opts = {}; + } + + var client = this; + + var postObj = { + requests: map(queries, function prepareRequest(query) { + var params = ''; + + // allow query.query + // so we are mimicing the index.search(query, params) method + // {indexName:, query:, params:} + if (query.query !== undefined) { + params += 'query=' + encodeURIComponent(query.query); + } + + return { + indexName: query.indexName, + params: client._getSearchParams(query.params, params) + }; + }) + }; + + var JSONPParams = map(postObj.requests, function prepareJSONPParams(request, requestId) { + return requestId + '=' + + encodeURIComponent( + '/1/indexes/' + encodeURIComponent(request.indexName) + '?' + + request.params + ); + }).join('&'); + + var url = '/1/indexes/*/queries'; + + if (opts.strategy !== undefined) { + postObj.strategy = opts.strategy; + } + + return this._jsonRequest({ + cache: this.cache, + method: 'POST', + url: url, + body: postObj, + hostType: 'read', + fallback: { + method: 'GET', + url: '/1/indexes/*', + body: { + params: JSONPParams + } + }, + callback: callback + }); +}; + +/** +* Search for facet values +* https://www.algolia.com/doc/rest-api/search#search-for-facet-values +* This is the top-level API for SFFV. +* +* @param {object[]} queries An array of queries to run. +* @param {string} queries[].indexName Index name, name of the index to search. +* @param {object} queries[].params Query parameters. +* @param {string} queries[].params.facetName Facet name, name of the attribute to search for values in. +* Must be declared as a facet +* @param {string} queries[].params.facetQuery Query for the facet search +* @param {string} [queries[].params.*] Any search parameter of Algolia, +* see https://www.algolia.com/doc/api-client/javascript/search#search-parameters +* Pagination is not supported. The page and hitsPerPage parameters will be ignored. +*/ +AlgoliaSearchCore.prototype.searchForFacetValues = function(queries) { + var isArray = require(8); + var map = require(32); + + var usage = 'Usage: client.searchForFacetValues([{indexName, params: {facetName, facetQuery, ...params}}, ...queries])'; // eslint-disable-line max-len + + if (!isArray(queries)) { + throw new Error(usage); + } + + var client = this; + + return client._promise.all(map(queries, function performQuery(query) { + if ( + !query || + query.indexName === undefined || + query.params.facetName === undefined || + query.params.facetQuery === undefined + ) { + throw new Error(usage); + } + + var clone = require(26); + var omit = require(34); + + var indexName = query.indexName; + var params = query.params; + + var facetName = params.facetName; + var filteredParams = omit(clone(params), function(keyName) { + return keyName === 'facetName'; + }); + var searchParameters = client._getSearchParams(filteredParams, ''); + + return client._jsonRequest({ + cache: client.cache, + method: 'POST', + url: + '/1/indexes/' + + encodeURIComponent(indexName) + + '/facets/' + + encodeURIComponent(facetName) + + '/query', + hostType: 'read', + body: {params: searchParameters} + }); + })); +}; + +/** + * Set the extra security tagFilters header + * @param {string|array} tags The list of tags defining the current security filters + */ +AlgoliaSearchCore.prototype.setSecurityTags = function(tags) { + if (Object.prototype.toString.call(tags) === '[object Array]') { + var strTags = []; + for (var i = 0; i < tags.length; ++i) { + if (Object.prototype.toString.call(tags[i]) === '[object Array]') { + var oredTags = []; + for (var j = 0; j < tags[i].length; ++j) { + oredTags.push(tags[i][j]); + } + strTags.push('(' + oredTags.join(',') + ')'); + } else { + strTags.push(tags[i]); + } + } + tags = strTags.join(','); + } + + this.securityTags = tags; +}; + +/** + * Set the extra user token header + * @param {string} userToken The token identifying a uniq user (used to apply rate limits) + */ +AlgoliaSearchCore.prototype.setUserToken = function(userToken) { + this.userToken = userToken; +}; + +/** + * Clear all queries in client's cache + * @return undefined + */ +AlgoliaSearchCore.prototype.clearCache = function() { + this.cache = {}; +}; + +/** +* Set the number of milliseconds a request can take before automatically being terminated. +* @deprecated +* @param {Number} milliseconds +*/ +AlgoliaSearchCore.prototype.setRequestTimeout = function(milliseconds) { + if (milliseconds) { + this._timeouts.connect = this._timeouts.read = this._timeouts.write = milliseconds; + } +}; + +/** +* Set the three different (connect, read, write) timeouts to be used when requesting +* @param {Object} timeouts +*/ +AlgoliaSearchCore.prototype.setTimeouts = function(timeouts) { + this._timeouts = timeouts; +}; + +/** +* Get the three different (connect, read, write) timeouts to be used when requesting +* @param {Object} timeouts +*/ +AlgoliaSearchCore.prototype.getTimeouts = function() { + return this._timeouts; +}; + +AlgoliaSearchCore.prototype._getAppIdData = function() { + var data = store.get(this.applicationID); + if (data !== null) this._cacheAppIdData(data); + return data; +}; + +AlgoliaSearchCore.prototype._setAppIdData = function(data) { + data.lastChange = (new Date()).getTime(); + this._cacheAppIdData(data); + return store.set(this.applicationID, data); +}; + +AlgoliaSearchCore.prototype._checkAppIdData = function() { + var data = this._getAppIdData(); + var now = (new Date()).getTime(); + if (data === null || now - data.lastChange > RESET_APP_DATA_TIMER) { + return this._resetInitialAppIdData(data); + } + + return data; +}; + +AlgoliaSearchCore.prototype._resetInitialAppIdData = function(data) { + var newData = data || {}; + newData.hostIndexes = {read: 0, write: 0}; + newData.timeoutMultiplier = 1; + newData.shuffleResult = newData.shuffleResult || shuffle([1, 2, 3]); + return this._setAppIdData(newData); +}; + +AlgoliaSearchCore.prototype._cacheAppIdData = function(data) { + this._hostIndexes = data.hostIndexes; + this._timeoutMultiplier = data.timeoutMultiplier; + this._shuffleResult = data.shuffleResult; +}; + +AlgoliaSearchCore.prototype._partialAppIdDataUpdate = function(newData) { + var foreach = require(5); + var currentData = this._getAppIdData(); + foreach(newData, function(value, key) { + currentData[key] = value; + }); + + return this._setAppIdData(currentData); +}; + +AlgoliaSearchCore.prototype._getHostByType = function(hostType) { + return this.hosts[hostType][this._getHostIndexByType(hostType)]; +}; + +AlgoliaSearchCore.prototype._getTimeoutMultiplier = function() { + return this._timeoutMultiplier; +}; + +AlgoliaSearchCore.prototype._getHostIndexByType = function(hostType) { + return this._hostIndexes[hostType]; +}; + +AlgoliaSearchCore.prototype._setHostIndexByType = function(hostIndex, hostType) { + var clone = require(26); + var newHostIndexes = clone(this._hostIndexes); + newHostIndexes[hostType] = hostIndex; + this._partialAppIdDataUpdate({hostIndexes: newHostIndexes}); + return hostIndex; +}; + +AlgoliaSearchCore.prototype._incrementHostIndex = function(hostType) { + return this._setHostIndexByType( + (this._getHostIndexByType(hostType) + 1) % this.hosts[hostType].length, hostType + ); +}; + +AlgoliaSearchCore.prototype._incrementTimeoutMultipler = function() { + var timeoutMultiplier = Math.max(this._timeoutMultiplier + 1, 4); + return this._partialAppIdDataUpdate({timeoutMultiplier: timeoutMultiplier}); +}; + +AlgoliaSearchCore.prototype._getTimeoutsForRequest = function(hostType) { + return { + connect: this._timeouts.connect * this._timeoutMultiplier, + complete: this._timeouts[hostType] * this._timeoutMultiplier + }; +}; + +function prepareHost(protocol) { + return function prepare(host) { + return protocol + '//' + host.toLowerCase(); + }; +} + +// Prototype.js < 1.7, a widely used library, defines a weird +// Array.prototype.toJSON function that will fail to stringify our content +// appropriately +// refs: +// - https://groups.google.com/forum/#!topic/prototype-core/E-SAVvV_V9Q +// - https://github.com/sstephenson/prototype/commit/038a2985a70593c1a86c230fadbdfe2e4898a48c +// - http://stackoverflow.com/a/3148441/147079 +function safeJSONStringify(obj) { + /* eslint no-extend-native:0 */ + + if (Array.prototype.toJSON === undefined) { + return JSON.stringify(obj); + } + + var toJSON = Array.prototype.toJSON; + delete Array.prototype.toJSON; + var out = JSON.stringify(obj); + Array.prototype.toJSON = toJSON; + + return out; +} + +function shuffle(array) { + var currentIndex = array.length; + var temporaryValue; + var randomIndex; + + // While there remain elements to shuffle... + while (currentIndex !== 0) { + // Pick a remaining element... + randomIndex = Math.floor(Math.random() * currentIndex); + currentIndex -= 1; + + // And swap it with the current element. + temporaryValue = array[currentIndex]; + array[currentIndex] = array[randomIndex]; + array[randomIndex] = temporaryValue; + } + + return array; +} + +function removeCredentials(headers) { + var newHeaders = {}; + + for (var headerName in headers) { + if (Object.prototype.hasOwnProperty.call(headers, headerName)) { + var value; + + if (headerName === 'x-algolia-api-key' || headerName === 'x-algolia-application-id') { + value = '**hidden for security purposes**'; + } else { + value = headers[headerName]; + } + + newHeaders[headerName] = value; + } + } + + return newHeaders; +} + +}).call(this,require(12)) +},{"1":1,"12":12,"20":20,"26":26,"30":30,"31":31,"32":32,"34":34,"36":36,"5":5,"8":8}],18:[function(require,module,exports){ +var inherits = require(7); +var IndexCore = require(20); +var deprecate = require(28); +var deprecatedMessage = require(29); +var exitPromise = require(31); +var errors = require(30); + +var deprecateForwardToSlaves = deprecate( + function() {}, + deprecatedMessage('forwardToSlaves', 'forwardToReplicas') +); + +module.exports = Index; + +function Index() { + IndexCore.apply(this, arguments); +} + +inherits(Index, IndexCore); + +/* +* Add an object in this index +* +* @param content contains the javascript object to add inside the index +* @param objectID (optional) an objectID you want to attribute to this object +* (if the attribute already exist the old object will be overwrite) +* @param callback (optional) the result callback called with two arguments: +* error: null or Error('message') +* content: the server answer that contains 3 elements: createAt, taskId and objectID +*/ +Index.prototype.addObject = function(content, objectID, callback) { + var indexObj = this; + + if (arguments.length === 1 || typeof objectID === 'function') { + callback = objectID; + objectID = undefined; + } + + return this.as._jsonRequest({ + method: objectID !== undefined ? + 'PUT' : // update or create + 'POST', // create (API generates an objectID) + url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + // create + (objectID !== undefined ? '/' + encodeURIComponent(objectID) : ''), // update or create + body: content, + hostType: 'write', + callback: callback + }); +}; + +/* +* Add several objects +* +* @param objects contains an array of objects to add +* @param callback (optional) the result callback called with two arguments: +* error: null or Error('message') +* content: the server answer that updateAt and taskID +*/ +Index.prototype.addObjects = function(objects, callback) { + var isArray = require(8); + var usage = 'Usage: index.addObjects(arrayOfObjects[, callback])'; + + if (!isArray(objects)) { + throw new Error(usage); + } + + var indexObj = this; + var postObj = { + requests: [] + }; + for (var i = 0; i < objects.length; ++i) { + var request = { + action: 'addObject', + body: objects[i] + }; + postObj.requests.push(request); + } + return this.as._jsonRequest({ + method: 'POST', + url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/batch', + body: postObj, + hostType: 'write', + callback: callback + }); +}; + +/* +* Update partially an object (only update attributes passed in argument) +* +* @param partialObject contains the javascript attributes to override, the +* object must contains an objectID attribute +* @param createIfNotExists (optional) if false, avoid an automatic creation of the object +* @param callback (optional) the result callback called with two arguments: +* error: null or Error('message') +* content: the server answer that contains 3 elements: createAt, taskId and objectID +*/ +Index.prototype.partialUpdateObject = function(partialObject, createIfNotExists, callback) { + if (arguments.length === 1 || typeof createIfNotExists === 'function') { + callback = createIfNotExists; + createIfNotExists = undefined; + } + + var indexObj = this; + var url = '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/' + encodeURIComponent(partialObject.objectID) + '/partial'; + if (createIfNotExists === false) { + url += '?createIfNotExists=false'; + } + + return this.as._jsonRequest({ + method: 'POST', + url: url, + body: partialObject, + hostType: 'write', + callback: callback + }); +}; + +/* +* Partially Override the content of several objects +* +* @param objects contains an array of objects to update (each object must contains a objectID attribute) +* @param callback (optional) the result callback called with two arguments: +* error: null or Error('message') +* content: the server answer that updateAt and taskID +*/ +Index.prototype.partialUpdateObjects = function(objects, createIfNotExists, callback) { + if (arguments.length === 1 || typeof createIfNotExists === 'function') { + callback = createIfNotExists; + createIfNotExists = true; + } + + var isArray = require(8); + var usage = 'Usage: index.partialUpdateObjects(arrayOfObjects[, callback])'; + + if (!isArray(objects)) { + throw new Error(usage); + } + + var indexObj = this; + var postObj = { + requests: [] + }; + for (var i = 0; i < objects.length; ++i) { + var request = { + action: createIfNotExists === true ? 'partialUpdateObject' : 'partialUpdateObjectNoCreate', + objectID: objects[i].objectID, + body: objects[i] + }; + postObj.requests.push(request); + } + return this.as._jsonRequest({ + method: 'POST', + url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/batch', + body: postObj, + hostType: 'write', + callback: callback + }); +}; + +/* +* Override the content of object +* +* @param object contains the javascript object to save, the object must contains an objectID attribute +* @param callback (optional) the result callback called with two arguments: +* error: null or Error('message') +* content: the server answer that updateAt and taskID +*/ +Index.prototype.saveObject = function(object, callback) { + var indexObj = this; + return this.as._jsonRequest({ + method: 'PUT', + url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/' + encodeURIComponent(object.objectID), + body: object, + hostType: 'write', + callback: callback + }); +}; + +/* +* Override the content of several objects +* +* @param objects contains an array of objects to update (each object must contains a objectID attribute) +* @param callback (optional) the result callback called with two arguments: +* error: null or Error('message') +* content: the server answer that updateAt and taskID +*/ +Index.prototype.saveObjects = function(objects, callback) { + var isArray = require(8); + var usage = 'Usage: index.saveObjects(arrayOfObjects[, callback])'; + + if (!isArray(objects)) { + throw new Error(usage); + } + + var indexObj = this; + var postObj = { + requests: [] + }; + for (var i = 0; i < objects.length; ++i) { + var request = { + action: 'updateObject', + objectID: objects[i].objectID, + body: objects[i] + }; + postObj.requests.push(request); + } + return this.as._jsonRequest({ + method: 'POST', + url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/batch', + body: postObj, + hostType: 'write', + callback: callback + }); +}; + +/* +* Delete an object from the index +* +* @param objectID the unique identifier of object to delete +* @param callback (optional) the result callback called with two arguments: +* error: null or Error('message') +* content: the server answer that contains 3 elements: createAt, taskId and objectID +*/ +Index.prototype.deleteObject = function(objectID, callback) { + if (typeof objectID === 'function' || typeof objectID !== 'string' && typeof objectID !== 'number') { + var err = new errors.AlgoliaSearchError( + objectID && typeof objectID !== 'function' + ? 'ObjectID must be a string' + : 'Cannot delete an object without an objectID' + ); + callback = objectID; + if (typeof callback === 'function') { + return callback(err); + } + + return this.as._promise.reject(err); + } + + var indexObj = this; + return this.as._jsonRequest({ + method: 'DELETE', + url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/' + encodeURIComponent(objectID), + hostType: 'write', + callback: callback + }); +}; + +/* +* Delete several objects from an index +* +* @param objectIDs contains an array of objectID to delete +* @param callback (optional) the result callback called with two arguments: +* error: null or Error('message') +* content: the server answer that contains 3 elements: createAt, taskId and objectID +*/ +Index.prototype.deleteObjects = function(objectIDs, callback) { + var isArray = require(8); + var map = require(32); + + var usage = 'Usage: index.deleteObjects(arrayOfObjectIDs[, callback])'; + + if (!isArray(objectIDs)) { + throw new Error(usage); + } + + var indexObj = this; + var postObj = { + requests: map(objectIDs, function prepareRequest(objectID) { + return { + action: 'deleteObject', + objectID: objectID, + body: { + objectID: objectID + } + }; + }) + }; + + return this.as._jsonRequest({ + method: 'POST', + url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/batch', + body: postObj, + hostType: 'write', + callback: callback + }); +}; + +/* +* Delete all objects matching a query +* +* @param query the query string +* @param params the optional query parameters +* @param callback (optional) the result callback called with one argument +* error: null or Error('message') +* @deprecated see index.deleteBy +*/ +Index.prototype.deleteByQuery = deprecate(function(query, params, callback) { + var clone = require(26); + var map = require(32); + + var indexObj = this; + var client = indexObj.as; + + if (arguments.length === 1 || typeof params === 'function') { + callback = params; + params = {}; + } else { + params = clone(params); + } + + params.attributesToRetrieve = 'objectID'; + params.hitsPerPage = 1000; + params.distinct = false; + + // when deleting, we should never use cache to get the + // search results + this.clearCache(); + + // there's a problem in how we use the promise chain, + // see how waitTask is done + var promise = this + .search(query, params) + .then(stopOrDelete); + + function stopOrDelete(searchContent) { + // stop here + if (searchContent.nbHits === 0) { + // return indexObj.as._request.resolve(); + return searchContent; + } + + // continue and do a recursive call + var objectIDs = map(searchContent.hits, function getObjectID(object) { + return object.objectID; + }); + + return indexObj + .deleteObjects(objectIDs) + .then(waitTask) + .then(doDeleteByQuery); + } + + function waitTask(deleteObjectsContent) { + return indexObj.waitTask(deleteObjectsContent.taskID); + } + + function doDeleteByQuery() { + return indexObj.deleteByQuery(query, params); + } + + if (!callback) { + return promise; + } + + promise.then(success, failure); + + function success() { + exitPromise(function exit() { + callback(null); + }, client._setTimeout || setTimeout); + } + + function failure(err) { + exitPromise(function exit() { + callback(err); + }, client._setTimeout || setTimeout); + } +}, deprecatedMessage('index.deleteByQuery()', 'index.deleteBy()')); + +/** +* Delete all objects matching a query +* +* the query parameters that can be used are: +* - filters (numeric, facet, tag) +* - geo +* +* you can not send an empty query or filters +* +* @param params the optional query parameters +* @param callback (optional) the result callback called with one argument +* error: null or Error('message') +*/ +Index.prototype.deleteBy = function(params, callback) { + var indexObj = this; + return this.as._jsonRequest({ + method: 'POST', + url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/deleteByQuery', + body: {params: indexObj.as._getSearchParams(params, '')}, + hostType: 'write', + callback: callback + }); +}; + +/* +* Browse all content from an index using events. Basically this will do +* .browse() -> .browseFrom -> .browseFrom -> .. until all the results are returned +* +* @param {string} query - The full text query +* @param {Object} [queryParameters] - Any search query parameter +* @return {EventEmitter} +* @example +* var browser = index.browseAll('cool songs', { +* tagFilters: 'public,comments', +* hitsPerPage: 500 +* }); +* +* browser.on('result', function resultCallback(content) { +* console.log(content.hits); +* }); +* +* // if any error occurs, you get it +* browser.on('error', function(err) { +* throw err; +* }); +* +* // when you have browsed the whole index, you get this event +* browser.on('end', function() { +* console.log('finished'); +* }); +* +* // at any point if you want to stop the browsing process, you can stop it manually +* // otherwise it will go on and on +* browser.stop(); +* +* @see {@link https://www.algolia.com/doc/rest_api#Browse|Algolia REST API Documentation} +*/ +Index.prototype.browseAll = function(query, queryParameters) { + if (typeof query === 'object') { + queryParameters = query; + query = undefined; + } + + var merge = require(33); + + var IndexBrowser = require(19); + + var browser = new IndexBrowser(); + var client = this.as; + var index = this; + var params = client._getSearchParams( + merge({}, queryParameters || {}, { + query: query + }), '' + ); + + // start browsing + browseLoop(); + + function browseLoop(cursor) { + if (browser._stopped) { + return; + } + + var body; + + if (cursor !== undefined) { + body = { + cursor: cursor + }; + } else { + body = { + params: params + }; + } + + client._jsonRequest({ + method: 'POST', + url: '/1/indexes/' + encodeURIComponent(index.indexName) + '/browse', + hostType: 'read', + body: body, + callback: browseCallback + }); + } + + function browseCallback(err, content) { + if (browser._stopped) { + return; + } + + if (err) { + browser._error(err); + return; + } + + browser._result(content); + + // no cursor means we are finished browsing + if (content.cursor === undefined) { + browser._end(); + return; + } + + browseLoop(content.cursor); + } + + return browser; +}; + +/* +* Get a Typeahead.js adapter +* @param searchParams contains an object with query parameters (see search for details) +*/ +Index.prototype.ttAdapter = deprecate(function(params) { + var self = this; + return function ttAdapter(query, syncCb, asyncCb) { + var cb; + + if (typeof asyncCb === 'function') { + // typeahead 0.11 + cb = asyncCb; + } else { + // pre typeahead 0.11 + cb = syncCb; + } + + self.search(query, params, function searchDone(err, content) { + if (err) { + cb(err); + return; + } + + cb(content.hits); + }); + }; +}, +'ttAdapter is not necessary anymore and will be removed in the next version,\n' + +'have a look at autocomplete.js (https://github.com/algolia/autocomplete.js)'); + +/* +* Wait the publication of a task on the server. +* All server task are asynchronous and you can check with this method that the task is published. +* +* @param taskID the id of the task returned by server +* @param callback the result callback with with two arguments: +* error: null or Error('message') +* content: the server answer that contains the list of results +*/ +Index.prototype.waitTask = function(taskID, callback) { + // wait minimum 100ms before retrying + var baseDelay = 100; + // wait maximum 5s before retrying + var maxDelay = 5000; + var loop = 0; + + // waitTask() must be handled differently from other methods, + // it's a recursive method using a timeout + var indexObj = this; + var client = indexObj.as; + + var promise = retryLoop(); + + function retryLoop() { + return client._jsonRequest({ + method: 'GET', + hostType: 'read', + url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/task/' + taskID + }).then(function success(content) { + loop++; + var delay = baseDelay * loop * loop; + if (delay > maxDelay) { + delay = maxDelay; + } + + if (content.status !== 'published') { + return client._promise.delay(delay).then(retryLoop); + } + + return content; + }); + } + + if (!callback) { + return promise; + } + + promise.then(successCb, failureCb); + + function successCb(content) { + exitPromise(function exit() { + callback(null, content); + }, client._setTimeout || setTimeout); + } + + function failureCb(err) { + exitPromise(function exit() { + callback(err); + }, client._setTimeout || setTimeout); + } +}; + +/* +* This function deletes the index content. Settings and index specific API keys are kept untouched. +* +* @param callback (optional) the result callback called with two arguments +* error: null or Error('message') +* content: the settings object or the error message if a failure occurred +*/ +Index.prototype.clearIndex = function(callback) { + var indexObj = this; + return this.as._jsonRequest({ + method: 'POST', + url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/clear', + hostType: 'write', + callback: callback + }); +}; + +/* +* Get settings of this index +* +* @param opts an object of options to add +* @param opts.advanced get more settings like nbShards (useful for Enterprise) +* @param callback (optional) the result callback called with two arguments +* error: null or Error('message') +* content: the settings object or the error message if a failure occurred +*/ +Index.prototype.getSettings = function(opts, callback) { + if (arguments.length === 1 && typeof opts === 'function') { + callback = opts; + opts = {}; + } + opts = opts || {}; + + var indexName = encodeURIComponent(this.indexName); + return this.as._jsonRequest({ + method: 'GET', + url: + '/1/indexes/' + + indexName + + '/settings?getVersion=2' + + (opts.advanced ? '&advanced=' + opts.advanced : ''), + hostType: 'read', + callback: callback + }); +}; + +Index.prototype.searchSynonyms = function(params, callback) { + if (typeof params === 'function') { + callback = params; + params = {}; + } else if (params === undefined) { + params = {}; + } + + return this.as._jsonRequest({ + method: 'POST', + url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/synonyms/search', + body: params, + hostType: 'read', + callback: callback + }); +}; + +function exportData(method, _hitsPerPage, callback) { + function search(page, _previous) { + var options = { + page: page || 0, + hitsPerPage: _hitsPerPage || 100 + }; + var previous = _previous || []; + + return method(options).then(function(result) { + var hits = result.hits; + var nbHits = result.nbHits; + var current = hits.map(function(s) { + delete s._highlightResult; + return s; + }); + var synonyms = previous.concat(current); + if (synonyms.length < nbHits) { + return search(options.page + 1, synonyms); + } + return synonyms; + }); + } + return search().then(function(data) { + if (typeof callback === 'function') { + callback(data); + return undefined; + } + return data; + }); +} + +/** + * Retrieve all the synonyms in an index + * @param [number=100] hitsPerPage The amount of synonyms to retrieve per batch + * @param [function] callback will be called after all synonyms are retrieved + */ +Index.prototype.exportSynonyms = function(hitsPerPage, callback) { + return exportData(this.searchSynonyms.bind(this), hitsPerPage, callback); +}; + +Index.prototype.saveSynonym = function(synonym, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } else if (opts === undefined) { + opts = {}; + } + + if (opts.forwardToSlaves !== undefined) deprecateForwardToSlaves(); + var forwardToReplicas = (opts.forwardToSlaves || opts.forwardToReplicas) ? 'true' : 'false'; + + return this.as._jsonRequest({ + method: 'PUT', + url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/synonyms/' + encodeURIComponent(synonym.objectID) + + '?forwardToReplicas=' + forwardToReplicas, + body: synonym, + hostType: 'write', + callback: callback + }); +}; + +Index.prototype.getSynonym = function(objectID, callback) { + return this.as._jsonRequest({ + method: 'GET', + url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/synonyms/' + encodeURIComponent(objectID), + hostType: 'read', + callback: callback + }); +}; + +Index.prototype.deleteSynonym = function(objectID, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } else if (opts === undefined) { + opts = {}; + } + + if (opts.forwardToSlaves !== undefined) deprecateForwardToSlaves(); + var forwardToReplicas = (opts.forwardToSlaves || opts.forwardToReplicas) ? 'true' : 'false'; + + return this.as._jsonRequest({ + method: 'DELETE', + url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/synonyms/' + encodeURIComponent(objectID) + + '?forwardToReplicas=' + forwardToReplicas, + hostType: 'write', + callback: callback + }); +}; + +Index.prototype.clearSynonyms = function(opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } else if (opts === undefined) { + opts = {}; + } + + if (opts.forwardToSlaves !== undefined) deprecateForwardToSlaves(); + var forwardToReplicas = (opts.forwardToSlaves || opts.forwardToReplicas) ? 'true' : 'false'; + + return this.as._jsonRequest({ + method: 'POST', + url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/synonyms/clear' + + '?forwardToReplicas=' + forwardToReplicas, + hostType: 'write', + callback: callback + }); +}; + +Index.prototype.batchSynonyms = function(synonyms, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } else if (opts === undefined) { + opts = {}; + } + + if (opts.forwardToSlaves !== undefined) deprecateForwardToSlaves(); + var forwardToReplicas = (opts.forwardToSlaves || opts.forwardToReplicas) ? 'true' : 'false'; + + return this.as._jsonRequest({ + method: 'POST', + url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/synonyms/batch' + + '?forwardToReplicas=' + forwardToReplicas + + '&replaceExistingSynonyms=' + (opts.replaceExistingSynonyms ? 'true' : 'false'), + hostType: 'write', + body: synonyms, + callback: callback + }); +}; + +Index.prototype.searchRules = function(params, callback) { + if (typeof params === 'function') { + callback = params; + params = {}; + } else if (params === undefined) { + params = {}; + } + + return this.as._jsonRequest({ + method: 'POST', + url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/rules/search', + body: params, + hostType: 'read', + callback: callback + }); +}; +/** + * Retrieve all the query rules in an index + * @param [number=100] hitsPerPage The amount of query rules to retrieve per batch + * @param [function] callback will be called after all query rules are retrieved + * error: null or Error('message') + */ +Index.prototype.exportRules = function(hitsPerPage, callback) { + return exportData(this.searchRules.bind(this), hitsPerPage, callback); +}; + +Index.prototype.saveRule = function(rule, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } else if (opts === undefined) { + opts = {}; + } + + if (!rule.objectID) { + throw new errors.AlgoliaSearchError('Missing or empty objectID field for rule'); + } + + var forwardToReplicas = opts.forwardToReplicas === true ? 'true' : 'false'; + + return this.as._jsonRequest({ + method: 'PUT', + url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/rules/' + encodeURIComponent(rule.objectID) + + '?forwardToReplicas=' + forwardToReplicas, + body: rule, + hostType: 'write', + callback: callback + }); +}; + +Index.prototype.getRule = function(objectID, callback) { + return this.as._jsonRequest({ + method: 'GET', + url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/rules/' + encodeURIComponent(objectID), + hostType: 'read', + callback: callback + }); +}; + +Index.prototype.deleteRule = function(objectID, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } else if (opts === undefined) { + opts = {}; + } + + var forwardToReplicas = opts.forwardToReplicas === true ? 'true' : 'false'; + + return this.as._jsonRequest({ + method: 'DELETE', + url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/rules/' + encodeURIComponent(objectID) + + '?forwardToReplicas=' + forwardToReplicas, + hostType: 'write', + callback: callback + }); +}; + +Index.prototype.clearRules = function(opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } else if (opts === undefined) { + opts = {}; + } + + var forwardToReplicas = opts.forwardToReplicas === true ? 'true' : 'false'; + + return this.as._jsonRequest({ + method: 'POST', + url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/rules/clear' + + '?forwardToReplicas=' + forwardToReplicas, + hostType: 'write', + callback: callback + }); +}; + +Index.prototype.batchRules = function(rules, opts, callback) { + if (typeof opts === 'function') { + callback = opts; + opts = {}; + } else if (opts === undefined) { + opts = {}; + } + + var forwardToReplicas = opts.forwardToReplicas === true ? 'true' : 'false'; + + return this.as._jsonRequest({ + method: 'POST', + url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/rules/batch' + + '?forwardToReplicas=' + forwardToReplicas + + '&clearExistingRules=' + (opts.clearExistingRules === true ? 'true' : 'false'), + hostType: 'write', + body: rules, + callback: callback + }); +}; + +Index.prototype.exists = function(callback) { + var result = this.getSettings().then(function() { + return true; + }).catch(function(err) { + if (err instanceof errors.AlgoliaSearchError && err.statusCode === 404) { + return false; + } + + throw err; + }); + + if (typeof callback !== 'function') { + return result; + } + + result.then(function(res) { + callback(null, res); + }).catch(function(err) { + callback(err); + }); +}; + +Index.prototype.findObject = function(findCallback, requestOptions, callback) { + requestOptions = requestOptions === undefined ? {} : requestOptions; + var paginate = requestOptions.paginate !== undefined ? requestOptions.paginate : true; + var query = requestOptions.query !== undefined ? requestOptions.query : ''; + + var that = this; + var page = 0; + + var paginateLoop = function() { + requestOptions.page = page; + + return that.search(query, requestOptions).then(function(result) { + var hits = result.hits; + + for (var position = 0; position < hits.length; position++) { + var hit = hits[position]; + if (findCallback(hit)) { + return { + object: hit, + position: position, + page: page + }; + } + } + + page += 1; + + // paginate if option was set and has next page + if (!paginate || page >= result.nbPages) { + throw new errors.ObjectNotFound('Object not found'); + } + + return paginateLoop(); + }); + }; + + var promise = paginateLoop(page); + + if (callback === undefined) { + return promise; + } + + promise + .then(function(res) { + callback(null, res); + }) + .catch(function(err) { + callback(err); + }); +}; + +Index.prototype.getObjectPosition = function(result, objectID) { + var hits = result.hits; + + for (var position = 0; position < hits.length; position++) { + if (hits[position].objectID === objectID) { + return position; + } + } + + return -1; +}; + +/* +* Set settings for this index +* +* @param settings the settings object that can contains : +* - minWordSizefor1Typo: (integer) the minimum number of characters to accept one typo (default = 3). +* - minWordSizefor2Typos: (integer) the minimum number of characters to accept two typos (default = 7). +* - hitsPerPage: (integer) the number of hits per page (default = 10). +* - attributesToRetrieve: (array of strings) default list of attributes to retrieve in objects. +* If set to null, all attributes are retrieved. +* - attributesToHighlight: (array of strings) default list of attributes to highlight. +* If set to null, all indexed attributes are highlighted. +* - attributesToSnippet**: (array of strings) default list of attributes to snippet alongside the number +* of words to return (syntax is attributeName:nbWords). +* By default no snippet is computed. If set to null, no snippet is computed. +* - attributesToIndex: (array of strings) the list of fields you want to index. +* If set to null, all textual and numerical attributes of your objects are indexed, +* but you should update it to get optimal results. +* This parameter has two important uses: +* - Limit the attributes to index: For example if you store a binary image in base64, +* you want to store it and be able to +* retrieve it but you don't want to search in the base64 string. +* - Control part of the ranking*: (see the ranking parameter for full explanation) +* Matches in attributes at the beginning of +* the list will be considered more important than matches in attributes further down the list. +* In one attribute, matching text at the beginning of the attribute will be +* considered more important than text after, you can disable +* this behavior if you add your attribute inside `unordered(AttributeName)`, +* for example attributesToIndex: ["title", "unordered(text)"]. +* - attributesForFaceting: (array of strings) The list of fields you want to use for faceting. +* All strings in the attribute selected for faceting are extracted and added as a facet. +* If set to null, no attribute is used for faceting. +* - attributeForDistinct: (string) The attribute name used for the Distinct feature. +* This feature is similar to the SQL "distinct" keyword: when enabled +* in query with the distinct=1 parameter, all hits containing a duplicate +* value for this attribute are removed from results. +* For example, if the chosen attribute is show_name and several hits have +* the same value for show_name, then only the best one is kept and others are removed. +* - ranking: (array of strings) controls the way results are sorted. +* We have six available criteria: +* - typo: sort according to number of typos, +* - geo: sort according to decreassing distance when performing a geo-location based search, +* - proximity: sort according to the proximity of query words in hits, +* - attribute: sort according to the order of attributes defined by attributesToIndex, +* - exact: +* - if the user query contains one word: sort objects having an attribute +* that is exactly the query word before others. +* For example if you search for the "V" TV show, you want to find it +* with the "V" query and avoid to have all popular TV +* show starting by the v letter before it. +* - if the user query contains multiple words: sort according to the +* number of words that matched exactly (and not as a prefix). +* - custom: sort according to a user defined formula set in **customRanking** attribute. +* The standard order is ["typo", "geo", "proximity", "attribute", "exact", "custom"] +* - customRanking: (array of strings) lets you specify part of the ranking. +* The syntax of this condition is an array of strings containing attributes +* prefixed by asc (ascending order) or desc (descending order) operator. +* For example `"customRanking" => ["desc(population)", "asc(name)"]` +* - queryType: Select how the query words are interpreted, it can be one of the following value: +* - prefixAll: all query words are interpreted as prefixes, +* - prefixLast: only the last word is interpreted as a prefix (default behavior), +* - prefixNone: no query word is interpreted as a prefix. This option is not recommended. +* - highlightPreTag: (string) Specify the string that is inserted before +* the highlighted parts in the query result (default to ""). +* - highlightPostTag: (string) Specify the string that is inserted after +* the highlighted parts in the query result (default to ""). +* - optionalWords: (array of strings) Specify a list of words that should +* be considered as optional when found in the query. +* @param callback (optional) the result callback called with two arguments +* error: null or Error('message') +* content: the server answer or the error message if a failure occurred +*/ +Index.prototype.setSettings = function(settings, opts, callback) { + if (arguments.length === 1 || typeof opts === 'function') { + callback = opts; + opts = {}; + } + + if (opts.forwardToSlaves !== undefined) deprecateForwardToSlaves(); + var forwardToReplicas = (opts.forwardToSlaves || opts.forwardToReplicas) ? 'true' : 'false'; + + var indexObj = this; + return this.as._jsonRequest({ + method: 'PUT', + url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/settings?forwardToReplicas=' + + forwardToReplicas, + hostType: 'write', + body: settings, + callback: callback + }); +}; + +/* +* @deprecated see client.listApiKeys() +*/ +Index.prototype.listUserKeys = deprecate(function(callback) { + return this.listApiKeys(callback); +}, deprecatedMessage('index.listUserKeys()', 'client.listApiKeys()')); + +/* +* List all existing API keys to this index +* +* @param callback the result callback called with two arguments +* error: null or Error('message') +* content: the server answer with API keys belonging to the index +* +* @deprecated see client.listApiKeys() +*/ +Index.prototype.listApiKeys = deprecate(function(callback) { + var indexObj = this; + return this.as._jsonRequest({ + method: 'GET', + url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/keys', + hostType: 'read', + callback: callback + }); +}, deprecatedMessage('index.listApiKeys()', 'client.listApiKeys()')); + +/* +* @deprecated see client.getApiKey() +*/ +Index.prototype.getUserKeyACL = deprecate(function(key, callback) { + return this.getApiKey(key, callback); +}, deprecatedMessage('index.getUserKeyACL()', 'client.getApiKey()')); + + +/* +* Get an API key from this index +* +* @param key +* @param callback the result callback called with two arguments +* error: null or Error('message') +* content: the server answer with the right API key +* +* @deprecated see client.getApiKey() +*/ +Index.prototype.getApiKey = deprecate(function(key, callback) { + var indexObj = this; + return this.as._jsonRequest({ + method: 'GET', + url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/keys/' + key, + hostType: 'read', + callback: callback + }); +}, deprecatedMessage('index.getApiKey()', 'client.getApiKey()')); + +/* +* @deprecated see client.deleteApiKey() +*/ +Index.prototype.deleteUserKey = deprecate(function(key, callback) { + return this.deleteApiKey(key, callback); +}, deprecatedMessage('index.deleteUserKey()', 'client.deleteApiKey()')); + +/* +* Delete an existing API key associated to this index +* +* @param key +* @param callback the result callback called with two arguments +* error: null or Error('message') +* content: the server answer with the deletion date +* +* @deprecated see client.deleteApiKey() +*/ +Index.prototype.deleteApiKey = deprecate(function(key, callback) { + var indexObj = this; + return this.as._jsonRequest({ + method: 'DELETE', + url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/keys/' + key, + hostType: 'write', + callback: callback + }); +}, deprecatedMessage('index.deleteApiKey()', 'client.deleteApiKey()')); + +/* +* @deprecated see client.addApiKey() +*/ +Index.prototype.addUserKey = deprecate(function(acls, params, callback) { + return this.addApiKey(acls, params, callback); +}, deprecatedMessage('index.addUserKey()', 'client.addApiKey()')); + +/* +* Add a new API key to this index +* +* @param {string[]} acls - The list of ACL for this key. Defined by an array of strings that +* can contains the following values: +* - search: allow to search (https and http) +* - addObject: allows to add/update an object in the index (https only) +* - deleteObject : allows to delete an existing object (https only) +* - deleteIndex : allows to delete index content (https only) +* - settings : allows to get index settings (https only) +* - editSettings : allows to change index settings (https only) +* @param {Object} [params] - Optionnal parameters to set for the key +* @param {number} params.validity - Number of seconds after which the key will +* be automatically removed (0 means no time limit for this key) +* @param {number} params.maxQueriesPerIPPerHour - Number of API calls allowed from an IP address per hour +* @param {number} params.maxHitsPerQuery - Number of hits this API key can retrieve in one call +* @param {string} params.description - A description for your key +* @param {string[]} params.referers - A list of authorized referers +* @param {Object} params.queryParameters - Force the key to use specific query parameters +* @param {Function} callback - The result callback called with two arguments +* error: null or Error('message') +* content: the server answer with the added API key +* @return {Promise|undefined} Returns a promise if no callback given +* @example +* index.addUserKey(['search'], { +* validity: 300, +* maxQueriesPerIPPerHour: 2000, +* maxHitsPerQuery: 3, +* description: 'Eat three fruits', +* referers: ['*.algolia.com'], +* queryParameters: { +* tagFilters: ['public'], +* } +* }) +* @see {@link https://www.algolia.com/doc/rest_api#AddIndexKey|Algolia REST API Documentation} +* +* @deprecated see client.addApiKey() +*/ +Index.prototype.addApiKey = deprecate(function(acls, params, callback) { + var isArray = require(8); + var usage = 'Usage: index.addApiKey(arrayOfAcls[, params, callback])'; + + if (!isArray(acls)) { + throw new Error(usage); + } + + if (arguments.length === 1 || typeof params === 'function') { + callback = params; + params = null; + } + + var postObj = { + acl: acls + }; + + if (params) { + postObj.validity = params.validity; + postObj.maxQueriesPerIPPerHour = params.maxQueriesPerIPPerHour; + postObj.maxHitsPerQuery = params.maxHitsPerQuery; + postObj.description = params.description; + + if (params.queryParameters) { + postObj.queryParameters = this.as._getSearchParams(params.queryParameters, ''); + } + + postObj.referers = params.referers; + } + + return this.as._jsonRequest({ + method: 'POST', + url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/keys', + body: postObj, + hostType: 'write', + callback: callback + }); +}, deprecatedMessage('index.addApiKey()', 'client.addApiKey()')); + +/** +* @deprecated use client.addApiKey() +*/ +Index.prototype.addUserKeyWithValidity = deprecate(function deprecatedAddUserKeyWithValidity(acls, params, callback) { + return this.addApiKey(acls, params, callback); +}, deprecatedMessage('index.addUserKeyWithValidity()', 'client.addApiKey()')); + +/* +* @deprecated see client.updateApiKey() +*/ +Index.prototype.updateUserKey = deprecate(function(key, acls, params, callback) { + return this.updateApiKey(key, acls, params, callback); +}, deprecatedMessage('index.updateUserKey()', 'client.updateApiKey()')); + +/** +* Update an existing API key of this index +* @param {string} key - The key to update +* @param {string[]} acls - The list of ACL for this key. Defined by an array of strings that +* can contains the following values: +* - search: allow to search (https and http) +* - addObject: allows to add/update an object in the index (https only) +* - deleteObject : allows to delete an existing object (https only) +* - deleteIndex : allows to delete index content (https only) +* - settings : allows to get index settings (https only) +* - editSettings : allows to change index settings (https only) +* @param {Object} [params] - Optionnal parameters to set for the key +* @param {number} params.validity - Number of seconds after which the key will +* be automatically removed (0 means no time limit for this key) +* @param {number} params.maxQueriesPerIPPerHour - Number of API calls allowed from an IP address per hour +* @param {number} params.maxHitsPerQuery - Number of hits this API key can retrieve in one call +* @param {string} params.description - A description for your key +* @param {string[]} params.referers - A list of authorized referers +* @param {Object} params.queryParameters - Force the key to use specific query parameters +* @param {Function} callback - The result callback called with two arguments +* error: null or Error('message') +* content: the server answer with user keys list +* @return {Promise|undefined} Returns a promise if no callback given +* @example +* index.updateApiKey('APIKEY', ['search'], { +* validity: 300, +* maxQueriesPerIPPerHour: 2000, +* maxHitsPerQuery: 3, +* description: 'Eat three fruits', +* referers: ['*.algolia.com'], +* queryParameters: { +* tagFilters: ['public'], +* } +* }) +* @see {@link https://www.algolia.com/doc/rest_api#UpdateIndexKey|Algolia REST API Documentation} +* +* @deprecated see client.updateApiKey() +*/ +Index.prototype.updateApiKey = deprecate(function(key, acls, params, callback) { + var isArray = require(8); + var usage = 'Usage: index.updateApiKey(key, arrayOfAcls[, params, callback])'; + + if (!isArray(acls)) { + throw new Error(usage); + } + + if (arguments.length === 2 || typeof params === 'function') { + callback = params; + params = null; + } + + var putObj = { + acl: acls + }; + + if (params) { + putObj.validity = params.validity; + putObj.maxQueriesPerIPPerHour = params.maxQueriesPerIPPerHour; + putObj.maxHitsPerQuery = params.maxHitsPerQuery; + putObj.description = params.description; + + if (params.queryParameters) { + putObj.queryParameters = this.as._getSearchParams(params.queryParameters, ''); + } + + putObj.referers = params.referers; + } + + return this.as._jsonRequest({ + method: 'PUT', + url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/keys/' + key, + body: putObj, + hostType: 'write', + callback: callback + }); +}, deprecatedMessage('index.updateApiKey()', 'client.updateApiKey()')); + +},{"19":19,"20":20,"26":26,"28":28,"29":29,"30":30,"31":31,"32":32,"33":33,"7":7,"8":8}],19:[function(require,module,exports){ +'use strict'; + +// This is the object returned by the `index.browseAll()` method + +module.exports = IndexBrowser; + +var inherits = require(7); +var EventEmitter = require(4).EventEmitter; + +function IndexBrowser() { +} + +inherits(IndexBrowser, EventEmitter); + +IndexBrowser.prototype.stop = function() { + this._stopped = true; + this._clean(); +}; + +IndexBrowser.prototype._end = function() { + this.emit('end'); + this._clean(); +}; + +IndexBrowser.prototype._error = function(err) { + this.emit('error', err); + this._clean(); +}; + +IndexBrowser.prototype._result = function(content) { + this.emit('result', content); +}; + +IndexBrowser.prototype._clean = function() { + this.removeAllListeners('stop'); + this.removeAllListeners('end'); + this.removeAllListeners('error'); + this.removeAllListeners('result'); +}; + +},{"4":4,"7":7}],20:[function(require,module,exports){ +var buildSearchMethod = require(25); +var deprecate = require(28); +var deprecatedMessage = require(29); + +module.exports = IndexCore; + +/* +* Index class constructor. +* You should not use this method directly but use initIndex() function +*/ +function IndexCore(algoliasearch, indexName) { + this.indexName = indexName; + this.as = algoliasearch; + this.typeAheadArgs = null; + this.typeAheadValueOption = null; + + // make sure every index instance has it's own cache + this.cache = {}; +} + +/* +* Clear all queries in cache +*/ +IndexCore.prototype.clearCache = function() { + this.cache = {}; +}; + +/* +* Search inside the index using XMLHttpRequest request (Using a POST query to +* minimize number of OPTIONS queries: Cross-Origin Resource Sharing). +* +* @param {string} [query] the full text query +* @param {object} [args] (optional) if set, contains an object with query parameters: +* - page: (integer) Pagination parameter used to select the page to retrieve. +* Page is zero-based and defaults to 0. Thus, +* to retrieve the 10th page you need to set page=9 +* - hitsPerPage: (integer) Pagination parameter used to select the number of hits per page. Defaults to 20. +* - attributesToRetrieve: a string that contains the list of object attributes +* you want to retrieve (let you minimize the answer size). +* Attributes are separated with a comma (for example "name,address"). +* You can also use an array (for example ["name","address"]). +* By default, all attributes are retrieved. You can also use '*' to retrieve all +* values when an attributesToRetrieve setting is specified for your index. +* - attributesToHighlight: a string that contains the list of attributes you +* want to highlight according to the query. +* Attributes are separated by a comma. You can also use an array (for example ["name","address"]). +* If an attribute has no match for the query, the raw value is returned. +* By default all indexed text attributes are highlighted. +* You can use `*` if you want to highlight all textual attributes. +* Numerical attributes are not highlighted. +* A matchLevel is returned for each highlighted attribute and can contain: +* - full: if all the query terms were found in the attribute, +* - partial: if only some of the query terms were found, +* - none: if none of the query terms were found. +* - attributesToSnippet: a string that contains the list of attributes to snippet alongside +* the number of words to return (syntax is `attributeName:nbWords`). +* Attributes are separated by a comma (Example: attributesToSnippet=name:10,content:10). +* You can also use an array (Example: attributesToSnippet: ['name:10','content:10']). +* By default no snippet is computed. +* - minWordSizefor1Typo: the minimum number of characters in a query word to accept one typo in this word. +* Defaults to 3. +* - minWordSizefor2Typos: the minimum number of characters in a query word +* to accept two typos in this word. Defaults to 7. +* - getRankingInfo: if set to 1, the result hits will contain ranking +* information in _rankingInfo attribute. +* - aroundLatLng: search for entries around a given +* latitude/longitude (specified as two floats separated by a comma). +* For example aroundLatLng=47.316669,5.016670). +* You can specify the maximum distance in meters with the aroundRadius parameter (in meters) +* and the precision for ranking with aroundPrecision +* (for example if you set aroundPrecision=100, two objects that are distant of +* less than 100m will be considered as identical for "geo" ranking parameter). +* At indexing, you should specify geoloc of an object with the _geoloc attribute +* (in the form {"_geoloc":{"lat":48.853409, "lng":2.348800}}) +* - insideBoundingBox: search entries inside a given area defined by the two extreme points +* of a rectangle (defined by 4 floats: p1Lat,p1Lng,p2Lat,p2Lng). +* For example insideBoundingBox=47.3165,4.9665,47.3424,5.0201). +* At indexing, you should specify geoloc of an object with the _geoloc attribute +* (in the form {"_geoloc":{"lat":48.853409, "lng":2.348800}}) +* - numericFilters: a string that contains the list of numeric filters you want to +* apply separated by a comma. +* The syntax of one filter is `attributeName` followed by `operand` followed by `value`. +* Supported operands are `<`, `<=`, `=`, `>` and `>=`. +* You can have multiple conditions on one attribute like for example numericFilters=price>100,price<1000. +* You can also use an array (for example numericFilters: ["price>100","price<1000"]). +* - tagFilters: filter the query by a set of tags. You can AND tags by separating them by commas. +* To OR tags, you must add parentheses. For example, tags=tag1,(tag2,tag3) means tag1 AND (tag2 OR tag3). +* You can also use an array, for example tagFilters: ["tag1",["tag2","tag3"]] +* means tag1 AND (tag2 OR tag3). +* At indexing, tags should be added in the _tags** attribute +* of objects (for example {"_tags":["tag1","tag2"]}). +* - facetFilters: filter the query by a list of facets. +* Facets are separated by commas and each facet is encoded as `attributeName:value`. +* For example: `facetFilters=category:Book,author:John%20Doe`. +* You can also use an array (for example `["category:Book","author:John%20Doe"]`). +* - facets: List of object attributes that you want to use for faceting. +* Comma separated list: `"category,author"` or array `['category','author']` +* Only attributes that have been added in **attributesForFaceting** index setting +* can be used in this parameter. +* You can also use `*` to perform faceting on all attributes specified in **attributesForFaceting**. +* - queryType: select how the query words are interpreted, it can be one of the following value: +* - prefixAll: all query words are interpreted as prefixes, +* - prefixLast: only the last word is interpreted as a prefix (default behavior), +* - prefixNone: no query word is interpreted as a prefix. This option is not recommended. +* - optionalWords: a string that contains the list of words that should +* be considered as optional when found in the query. +* Comma separated and array are accepted. +* - distinct: If set to 1, enable the distinct feature (disabled by default) +* if the attributeForDistinct index setting is set. +* This feature is similar to the SQL "distinct" keyword: when enabled +* in a query with the distinct=1 parameter, +* all hits containing a duplicate value for the attributeForDistinct attribute are removed from results. +* For example, if the chosen attribute is show_name and several hits have +* the same value for show_name, then only the best +* one is kept and others are removed. +* - restrictSearchableAttributes: List of attributes you want to use for +* textual search (must be a subset of the attributesToIndex index setting) +* either comma separated or as an array +* @param {function} [callback] the result callback called with two arguments: +* error: null or Error('message'). If false, the content contains the error. +* content: the server answer that contains the list of results. +*/ +IndexCore.prototype.search = buildSearchMethod('query'); + +/* +* -- BETA -- +* Search a record similar to the query inside the index using XMLHttpRequest request (Using a POST query to +* minimize number of OPTIONS queries: Cross-Origin Resource Sharing). +* +* @param {string} [query] the similar query +* @param {object} [args] (optional) if set, contains an object with query parameters. +* All search parameters are supported (see search function), restrictSearchableAttributes and facetFilters +* are the two most useful to restrict the similar results and get more relevant content +*/ +IndexCore.prototype.similarSearch = deprecate( + buildSearchMethod('similarQuery'), + deprecatedMessage( + 'index.similarSearch(query[, callback])', + 'index.search({ similarQuery: query }[, callback])' + ) +); + +/* +* Browse index content. The response content will have a `cursor` property that you can use +* to browse subsequent pages for this query. Use `index.browseFrom(cursor)` when you want. +* +* @param {string} query - The full text query +* @param {Object} [queryParameters] - Any search query parameter +* @param {Function} [callback] - The result callback called with two arguments +* error: null or Error('message') +* content: the server answer with the browse result +* @return {Promise|undefined} Returns a promise if no callback given +* @example +* index.browse('cool songs', { +* tagFilters: 'public,comments', +* hitsPerPage: 500 +* }, callback); +* @see {@link https://www.algolia.com/doc/rest_api#Browse|Algolia REST API Documentation} +*/ +IndexCore.prototype.browse = function(query, queryParameters, callback) { + var merge = require(33); + + var indexObj = this; + + var page; + var hitsPerPage; + + // we check variadic calls that are not the one defined + // .browse()/.browse(fn) + // => page = 0 + if (arguments.length === 0 || arguments.length === 1 && typeof arguments[0] === 'function') { + page = 0; + callback = arguments[0]; + query = undefined; + } else if (typeof arguments[0] === 'number') { + // .browse(2)/.browse(2, 10)/.browse(2, fn)/.browse(2, 10, fn) + page = arguments[0]; + if (typeof arguments[1] === 'number') { + hitsPerPage = arguments[1]; + } else if (typeof arguments[1] === 'function') { + callback = arguments[1]; + hitsPerPage = undefined; + } + query = undefined; + queryParameters = undefined; + } else if (typeof arguments[0] === 'object') { + // .browse(queryParameters)/.browse(queryParameters, cb) + if (typeof arguments[1] === 'function') { + callback = arguments[1]; + } + queryParameters = arguments[0]; + query = undefined; + } else if (typeof arguments[0] === 'string' && typeof arguments[1] === 'function') { + // .browse(query, cb) + callback = arguments[1]; + queryParameters = undefined; + } + + // otherwise it's a .browse(query)/.browse(query, queryParameters)/.browse(query, queryParameters, cb) + + // get search query parameters combining various possible calls + // to .browse(); + queryParameters = merge({}, queryParameters || {}, { + page: page, + hitsPerPage: hitsPerPage, + query: query + }); + + var params = this.as._getSearchParams(queryParameters, ''); + + return this.as._jsonRequest({ + method: 'POST', + url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/browse', + body: {params: params}, + hostType: 'read', + callback: callback + }); +}; + +/* +* Continue browsing from a previous position (cursor), obtained via a call to `.browse()`. +* +* @param {string} query - The full text query +* @param {Object} [queryParameters] - Any search query parameter +* @param {Function} [callback] - The result callback called with two arguments +* error: null or Error('message') +* content: the server answer with the browse result +* @return {Promise|undefined} Returns a promise if no callback given +* @example +* index.browseFrom('14lkfsakl32', callback); +* @see {@link https://www.algolia.com/doc/rest_api#Browse|Algolia REST API Documentation} +*/ +IndexCore.prototype.browseFrom = function(cursor, callback) { + return this.as._jsonRequest({ + method: 'POST', + url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/browse', + body: {cursor: cursor}, + hostType: 'read', + callback: callback + }); +}; + +/* +* Search for facet values +* https://www.algolia.com/doc/rest-api/search#search-for-facet-values +* +* @param {string} params.facetName Facet name, name of the attribute to search for values in. +* Must be declared as a facet +* @param {string} params.facetQuery Query for the facet search +* @param {string} [params.*] Any search parameter of Algolia, +* see https://www.algolia.com/doc/api-client/javascript/search#search-parameters +* Pagination is not supported. The page and hitsPerPage parameters will be ignored. +* @param callback (optional) +*/ +IndexCore.prototype.searchForFacetValues = function(params, callback) { + var clone = require(26); + var omit = require(34); + var usage = 'Usage: index.searchForFacetValues({facetName, facetQuery, ...params}[, callback])'; + + if (params.facetName === undefined || params.facetQuery === undefined) { + throw new Error(usage); + } + + var facetName = params.facetName; + var filteredParams = omit(clone(params), function(keyName) { + return keyName === 'facetName'; + }); + var searchParameters = this.as._getSearchParams(filteredParams, ''); + + return this.as._jsonRequest({ + method: 'POST', + url: '/1/indexes/' + + encodeURIComponent(this.indexName) + '/facets/' + encodeURIComponent(facetName) + '/query', + hostType: 'read', + body: {params: searchParameters}, + callback: callback + }); +}; + +IndexCore.prototype.searchFacet = deprecate(function(params, callback) { + return this.searchForFacetValues(params, callback); +}, deprecatedMessage( + 'index.searchFacet(params[, callback])', + 'index.searchForFacetValues(params[, callback])' +)); + +IndexCore.prototype._search = function(params, url, callback, additionalUA) { + return this.as._jsonRequest({ + cache: this.cache, + method: 'POST', + url: url || '/1/indexes/' + encodeURIComponent(this.indexName) + '/query', + body: {params: params}, + hostType: 'read', + fallback: { + method: 'GET', + url: '/1/indexes/' + encodeURIComponent(this.indexName), + body: {params: params} + }, + callback: callback, + additionalUA: additionalUA + }); +}; + +/* +* Get an object from this index +* +* @param objectID the unique identifier of the object to retrieve +* @param attrs (optional) if set, contains the array of attribute names to retrieve +* @param callback (optional) the result callback called with two arguments +* error: null or Error('message') +* content: the object to retrieve or the error message if a failure occurred +*/ +IndexCore.prototype.getObject = function(objectID, attrs, callback) { + var indexObj = this; + + if (arguments.length === 1 || typeof attrs === 'function') { + callback = attrs; + attrs = undefined; + } + + var params = ''; + if (attrs !== undefined) { + params = '?attributes='; + for (var i = 0; i < attrs.length; ++i) { + if (i !== 0) { + params += ','; + } + params += attrs[i]; + } + } + + return this.as._jsonRequest({ + method: 'GET', + url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/' + encodeURIComponent(objectID) + params, + hostType: 'read', + callback: callback + }); +}; + +/* +* Get several objects from this index +* +* @param objectIDs the array of unique identifier of objects to retrieve +*/ +IndexCore.prototype.getObjects = function(objectIDs, attributesToRetrieve, callback) { + var isArray = require(8); + var map = require(32); + + var usage = 'Usage: index.getObjects(arrayOfObjectIDs[, callback])'; + + if (!isArray(objectIDs)) { + throw new Error(usage); + } + + var indexObj = this; + + if (arguments.length === 1 || typeof attributesToRetrieve === 'function') { + callback = attributesToRetrieve; + attributesToRetrieve = undefined; + } + + var body = { + requests: map(objectIDs, function prepareRequest(objectID) { + var request = { + indexName: indexObj.indexName, + objectID: objectID + }; + + if (attributesToRetrieve) { + request.attributesToRetrieve = attributesToRetrieve.join(','); + } + + return request; + }) + }; + + return this.as._jsonRequest({ + method: 'POST', + url: '/1/indexes/*/objects', + hostType: 'read', + body: body, + callback: callback + }); +}; + +IndexCore.prototype.as = null; +IndexCore.prototype.indexName = null; +IndexCore.prototype.typeAheadArgs = null; +IndexCore.prototype.typeAheadValueOption = null; + +},{"25":25,"26":26,"28":28,"29":29,"32":32,"33":33,"34":34,"8":8}],21:[function(require,module,exports){ +'use strict'; + +var AlgoliaSearch = require(16); +var createAlgoliasearch = require(22); + +module.exports = createAlgoliasearch(AlgoliaSearch, 'Browser'); + +},{"16":16,"22":22}],22:[function(require,module,exports){ +(function (process){ +'use strict'; + +var global = require(6); +var Promise = global.Promise || require(3).Promise; + +// This is the standalone browser build entry point +// Browser implementation of the Algolia Search JavaScript client, +// using XMLHttpRequest, XDomainRequest and JSONP as fallback +module.exports = function createAlgoliasearch(AlgoliaSearch, uaSuffix) { + var inherits = require(7); + var errors = require(30); + var inlineHeaders = require(23); + var jsonpRequest = require(24); + var places = require(35); + uaSuffix = uaSuffix || ''; + + if (process.env.NODE_ENV === 'debug') { + require(1).enable('algoliasearch*'); + } + + function algoliasearch(applicationID, apiKey, opts) { + var cloneDeep = require(26); + + opts = cloneDeep(opts || {}); + + opts._ua = opts._ua || algoliasearch.ua; + + return new AlgoliaSearchBrowser(applicationID, apiKey, opts); + } + + algoliasearch.version = require(37); + + algoliasearch.ua = + 'Algolia for JavaScript (' + algoliasearch.version + '); ' + uaSuffix; + + algoliasearch.initPlaces = places(algoliasearch); + + // we expose into window no matter how we are used, this will allow + // us to easily debug any website running algolia + global.__algolia = { + debug: require(1), + algoliasearch: algoliasearch + }; + + var support = { + hasXMLHttpRequest: 'XMLHttpRequest' in global, + hasXDomainRequest: 'XDomainRequest' in global + }; + + if (support.hasXMLHttpRequest) { + support.cors = 'withCredentials' in new XMLHttpRequest(); + } + + function AlgoliaSearchBrowser() { + // call AlgoliaSearch constructor + AlgoliaSearch.apply(this, arguments); + } + + inherits(AlgoliaSearchBrowser, AlgoliaSearch); + + AlgoliaSearchBrowser.prototype._request = function request(url, opts) { + return new Promise(function wrapRequest(resolve, reject) { + // no cors or XDomainRequest, no request + if (!support.cors && !support.hasXDomainRequest) { + // very old browser, not supported + reject(new errors.Network('CORS not supported')); + return; + } + + url = inlineHeaders(url, opts.headers); + + var body = opts.body; + var req = support.cors ? new XMLHttpRequest() : new XDomainRequest(); + var reqTimeout; + var timedOut; + var connected = false; + + reqTimeout = setTimeout(onTimeout, opts.timeouts.connect); + // we set an empty onprogress listener + // so that XDomainRequest on IE9 is not aborted + // refs: + // - https://github.com/algolia/algoliasearch-client-js/issues/76 + // - https://social.msdn.microsoft.com/Forums/ie/en-US/30ef3add-767c-4436-b8a9-f1ca19b4812e/ie9-rtm-xdomainrequest-issued-requests-may-abort-if-all-event-handlers-not-specified?forum=iewebdevelopment + req.onprogress = onProgress; + if ('onreadystatechange' in req) req.onreadystatechange = onReadyStateChange; + req.onload = onLoad; + req.onerror = onError; + + // do not rely on default XHR async flag, as some analytics code like hotjar + // breaks it and set it to false by default + if (req instanceof XMLHttpRequest) { + req.open(opts.method, url, true); + + // The Analytics API never accepts Auth headers as query string + // this option exists specifically for them. + if (opts.forceAuthHeaders) { + req.setRequestHeader( + 'x-algolia-application-id', + opts.headers['x-algolia-application-id'] + ); + req.setRequestHeader( + 'x-algolia-api-key', + opts.headers['x-algolia-api-key'] + ); + } + } else { + req.open(opts.method, url); + } + + // headers are meant to be sent after open + if (support.cors) { + if (body) { + if (opts.method === 'POST') { + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Simple_requests + req.setRequestHeader('content-type', 'application/x-www-form-urlencoded'); + } else { + req.setRequestHeader('content-type', 'application/json'); + } + } + req.setRequestHeader('accept', 'application/json'); + } + + if (body) { + req.send(body); + } else { + req.send(); + } + + // event object not received in IE8, at least + // but we do not use it, still important to note + function onLoad(/* event */) { + // When browser does not supports req.timeout, we can + // have both a load and timeout event, since handled by a dumb setTimeout + if (timedOut) { + return; + } + + clearTimeout(reqTimeout); + + var out; + + try { + out = { + body: JSON.parse(req.responseText), + responseText: req.responseText, + statusCode: req.status, + // XDomainRequest does not have any response headers + headers: req.getAllResponseHeaders && req.getAllResponseHeaders() || {} + }; + } catch (e) { + out = new errors.UnparsableJSON({ + more: req.responseText + }); + } + + if (out instanceof errors.UnparsableJSON) { + reject(out); + } else { + resolve(out); + } + } + + function onError(event) { + if (timedOut) { + return; + } + + clearTimeout(reqTimeout); + + // error event is trigerred both with XDR/XHR on: + // - DNS error + // - unallowed cross domain request + reject( + new errors.Network({ + more: event + }) + ); + } + + function onTimeout() { + timedOut = true; + req.abort(); + + reject(new errors.RequestTimeout()); + } + + function onConnect() { + connected = true; + clearTimeout(reqTimeout); + reqTimeout = setTimeout(onTimeout, opts.timeouts.complete); + } + + function onProgress() { + if (!connected) onConnect(); + } + + function onReadyStateChange() { + if (!connected && req.readyState > 1) onConnect(); + } + }); + }; + + AlgoliaSearchBrowser.prototype._request.fallback = function requestFallback(url, opts) { + url = inlineHeaders(url, opts.headers); + + return new Promise(function wrapJsonpRequest(resolve, reject) { + jsonpRequest(url, opts, function jsonpRequestDone(err, content) { + if (err) { + reject(err); + return; + } + + resolve(content); + }); + }); + }; + + AlgoliaSearchBrowser.prototype._promise = { + reject: function rejectPromise(val) { + return Promise.reject(val); + }, + resolve: function resolvePromise(val) { + return Promise.resolve(val); + }, + delay: function delayPromise(ms) { + return new Promise(function resolveOnTimeout(resolve/* , reject*/) { + setTimeout(resolve, ms); + }); + }, + all: function all(promises) { + return Promise.all(promises); + } + }; + + return algoliasearch; +}; + +}).call(this,require(12)) +},{"1":1,"12":12,"23":23,"24":24,"26":26,"3":3,"30":30,"35":35,"37":37,"6":6,"7":7}],23:[function(require,module,exports){ +'use strict'; + +module.exports = inlineHeaders; + +var encode = require(14); + +function inlineHeaders(url, headers) { + if (/\?/.test(url)) { + url += '&'; + } else { + url += '?'; + } + + return url + encode(headers); +} + +},{"14":14}],24:[function(require,module,exports){ +'use strict'; + +module.exports = jsonpRequest; + +var errors = require(30); + +var JSONPCounter = 0; + +function jsonpRequest(url, opts, cb) { + if (opts.method !== 'GET') { + cb(new Error('Method ' + opts.method + ' ' + url + ' is not supported by JSONP.')); + return; + } + + opts.debug('JSONP: start'); + + var cbCalled = false; + var timedOut = false; + + JSONPCounter += 1; + var head = document.getElementsByTagName('head')[0]; + var script = document.createElement('script'); + var cbName = 'algoliaJSONP_' + JSONPCounter; + var done = false; + + window[cbName] = function(data) { + removeGlobals(); + + if (timedOut) { + opts.debug('JSONP: Late answer, ignoring'); + return; + } + + cbCalled = true; + + clean(); + + cb(null, { + body: data, + responseText: JSON.stringify(data)/* , + // We do not send the statusCode, there's no statusCode in JSONP, it will be + // computed using data.status && data.message like with XDR + statusCode*/ + }); + }; + + // add callback by hand + url += '&callback=' + cbName; + + // add body params manually + if (opts.jsonBody && opts.jsonBody.params) { + url += '&' + opts.jsonBody.params; + } + + var ontimeout = setTimeout(timeout, opts.timeouts.complete); + + // script onreadystatechange needed only for + // <= IE8 + // https://github.com/angular/angular.js/issues/4523 + script.onreadystatechange = readystatechange; + script.onload = success; + script.onerror = error; + + script.async = true; + script.defer = true; + script.src = url; + head.appendChild(script); + + function success() { + opts.debug('JSONP: success'); + + if (done || timedOut) { + return; + } + + done = true; + + // script loaded but did not call the fn => script loading error + if (!cbCalled) { + opts.debug('JSONP: Fail. Script loaded but did not call the callback'); + clean(); + cb(new errors.JSONPScriptFail()); + } + } + + function readystatechange() { + if (this.readyState === 'loaded' || this.readyState === 'complete') { + success(); + } + } + + function clean() { + clearTimeout(ontimeout); + script.onload = null; + script.onreadystatechange = null; + script.onerror = null; + head.removeChild(script); + } + + function removeGlobals() { + try { + delete window[cbName]; + delete window[cbName + '_loaded']; + } catch (e) { + window[cbName] = window[cbName + '_loaded'] = undefined; + } + } + + function timeout() { + opts.debug('JSONP: Script timeout'); + timedOut = true; + clean(); + cb(new errors.RequestTimeout()); + } + + function error() { + opts.debug('JSONP: Script error'); + + if (done || timedOut) { + return; + } + + clean(); + cb(new errors.JSONPScriptError()); + } +} + +},{"30":30}],25:[function(require,module,exports){ +module.exports = buildSearchMethod; + +var errors = require(30); + +/** + * Creates a search method to be used in clients + * @param {string} queryParam the name of the attribute used for the query + * @param {string} url the url + * @return {function} the search method + */ +function buildSearchMethod(queryParam, url) { + /** + * The search method. Prepares the data and send the query to Algolia. + * @param {string} query the string used for query search + * @param {object} args additional parameters to send with the search + * @param {function} [callback] the callback to be called with the client gets the answer + * @return {undefined|Promise} If the callback is not provided then this methods returns a Promise + */ + return function search(query, args, callback) { + // warn V2 users on how to search + if (typeof query === 'function' && typeof args === 'object' || + typeof callback === 'object') { + // .search(query, params, cb) + // .search(cb, params) + throw new errors.AlgoliaSearchError('index.search usage is index.search(query, params, cb)'); + } + + // Normalizing the function signature + if (arguments.length === 0 || typeof query === 'function') { + // Usage : .search(), .search(cb) + callback = query; + query = ''; + } else if (arguments.length === 1 || typeof args === 'function') { + // Usage : .search(query/args), .search(query, cb) + callback = args; + args = undefined; + } + // At this point we have 3 arguments with values + + // Usage : .search(args) // careful: typeof null === 'object' + if (typeof query === 'object' && query !== null) { + args = query; + query = undefined; + } else if (query === undefined || query === null) { // .search(undefined/null) + query = ''; + } + + var params = ''; + + if (query !== undefined) { + params += queryParam + '=' + encodeURIComponent(query); + } + + var additionalUA; + if (args !== undefined) { + if (args.additionalUA) { + additionalUA = args.additionalUA; + delete args.additionalUA; + } + // `_getSearchParams` will augment params, do not be fooled by the = versus += from previous if + params = this.as._getSearchParams(args, params); + } + + + return this._search(params, url, callback, additionalUA); + }; +} + +},{"30":30}],26:[function(require,module,exports){ +module.exports = function clone(obj) { + return JSON.parse(JSON.stringify(obj)); +}; + +},{}],27:[function(require,module,exports){ +module.exports = createAnalyticsClient; + +var algoliasearch = require(21); + +function createAnalyticsClient(appId, apiKey, opts) { + var analytics = {}; + + opts = opts || {}; + // there need to be 4 hosts, like on the client, since if requests fail, + // the counter goes up by 1, so we need to have the same amount of hosts + // 4 because: -dsn, -1, -2, -3 + // This is done because the APPID used for search will be the same for the analytics client created, + // and since the state of available hosts is shared by APPID globally for the module, we had issues + // where the hostIndex would be 1 while the array was only one entry (you got an empty host) + opts.hosts = opts.hosts || [ + 'analytics.algolia.com', + 'analytics.algolia.com', + 'analytics.algolia.com', + 'analytics.algolia.com' + ]; + opts.protocol = opts.protocol || 'https:'; + + analytics.as = algoliasearch(appId, apiKey, opts); + + analytics.getABTests = function(_params, callback) { + var params = params || {}; + var offset = params.offset || 0; + var limit = params.limit || 10; + + return this.as._jsonRequest({ + method: 'GET', + url: '/2/abtests?offset=' + encodeURIComponent(offset) + '&limit=' + encodeURIComponent(limit), + hostType: 'read', + forceAuthHeaders: true, + callback: callback + }); + }; + + analytics.getABTest = function(abTestID, callback) { + return this.as._jsonRequest({ + method: 'GET', + url: '/2/abtests/' + encodeURIComponent(abTestID), + hostType: 'read', + forceAuthHeaders: true, + callback: callback + }); + }; + + analytics.addABTest = function(abTest, callback) { + return this.as._jsonRequest({ + method: 'POST', + url: '/2/abtests', + body: abTest, + hostType: 'read', + forceAuthHeaders: true, + callback: callback + }); + }; + + analytics.stopABTest = function(abTestID, callback) { + return this.as._jsonRequest({ + method: 'POST', + url: '/2/abtests/' + encodeURIComponent(abTestID) + '/stop', + hostType: 'read', + forceAuthHeaders: true, + callback: callback + }); + }; + + analytics.deleteABTest = function(abTestID, callback) { + return this.as._jsonRequest({ + method: 'DELETE', + url: '/2/abtests/' + encodeURIComponent(abTestID), + hostType: 'write', + forceAuthHeaders: true, + callback: callback + }); + }; + + analytics.waitTask = function(indexName, taskID, callback) { + return this.as.initIndex(indexName).waitTask(taskID, callback); + }; + + return analytics; +} + +},{"21":21}],28:[function(require,module,exports){ +module.exports = function deprecate(fn, message) { + var warned = false; + + function deprecated() { + if (!warned) { + /* eslint no-console:0 */ + console.warn(message); + warned = true; + } + + return fn.apply(this, arguments); + } + + return deprecated; +}; + +},{}],29:[function(require,module,exports){ +module.exports = function deprecatedMessage(previousUsage, newUsage) { + var githubAnchorLink = previousUsage.toLowerCase() + .replace(/[\.\(\)]/g, ''); + + return 'algoliasearch: `' + previousUsage + '` was replaced by `' + newUsage + + '`. Please see https://github.com/algolia/algoliasearch-client-javascript/wiki/Deprecated#' + githubAnchorLink; +}; + +},{}],30:[function(require,module,exports){ +'use strict'; + +// This file hosts our error definitions +// We use custom error "types" so that we can act on them when we need it +// e.g.: if error instanceof errors.UnparsableJSON then.. + +var inherits = require(7); + +function AlgoliaSearchError(message, extraProperties) { + var forEach = require(5); + + var error = this; + + // try to get a stacktrace + if (typeof Error.captureStackTrace === 'function') { + Error.captureStackTrace(this, this.constructor); + } else { + error.stack = (new Error()).stack || 'Cannot get a stacktrace, browser is too old'; + } + + this.name = 'AlgoliaSearchError'; + this.message = message || 'Unknown error'; + + if (extraProperties) { + forEach(extraProperties, function addToErrorObject(value, key) { + error[key] = value; + }); + } +} + +inherits(AlgoliaSearchError, Error); + +function createCustomError(name, message) { + function AlgoliaSearchCustomError() { + var args = Array.prototype.slice.call(arguments, 0); + + // custom message not set, use default + if (typeof args[0] !== 'string') { + args.unshift(message); + } + + AlgoliaSearchError.apply(this, args); + this.name = 'AlgoliaSearch' + name + 'Error'; + } + + inherits(AlgoliaSearchCustomError, AlgoliaSearchError); + + return AlgoliaSearchCustomError; +} + +// late exports to let various fn defs and inherits take place +module.exports = { + AlgoliaSearchError: AlgoliaSearchError, + UnparsableJSON: createCustomError( + 'UnparsableJSON', + 'Could not parse the incoming response as JSON, see err.more for details' + ), + RequestTimeout: createCustomError( + 'RequestTimeout', + 'Request timed out before getting a response' + ), + Network: createCustomError( + 'Network', + 'Network issue, see err.more for details' + ), + JSONPScriptFail: createCustomError( + 'JSONPScriptFail', + '"),window.ALGOLIA_SUPPORTS_DOCWRITE===!0?(document.write(''),n("document.write")()):r(o,n("DOMElement"))}catch(s){r(o,n("DOMElement"))}}function n(e){return function(){var t="AlgoliaSearch: loaded V2 script using "+e;window.console&&window.console.log&&window.console.log(t)}}t.exports=o},{1:1}],4:[function(e,t,r){"use strict";function o(){var e="-- AlgoliaSearch V2 => V3 error --\nYou are trying to use a new version of the AlgoliaSearch JavaScript client with an old notation.\nPlease read our migration guide at https://github.com/algolia/algoliasearch-client-js/wiki/Migration-guide-from-2.x.x-to-3.x.x\n-- /AlgoliaSearch V2 => V3 error --";window.AlgoliaSearch=function(){throw new Error(e)},window.AlgoliaSearchHelper=function(){throw new Error(e)},window.AlgoliaExplainResults=function(){throw new Error(e)}}t.exports=o},{}],5:[function(e,t,r){"use strict";function o(t){var r=e(2),o=e(3),n=e(4);r(t)?o(t):n()}o("algoliasearch")},{2:2,3:3,4:4}]},{},[5])(5)}),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.algoliasearch=e()}}(function(){var e;return function t(e,r,o){function n(s,a){if(!r[s]){if(!e[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var l=r[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return n(r?r:t)},l,l.exports,t,e,r,o)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(e){var t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+r.humanize(this.diff),t){var o="color: "+this.color;e.splice(1,0,o,"color: inherit");var n=0,i=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(n++,"%c"===e&&(i=n))}),e.splice(i,0,o)}}function s(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(e){try{null==e?r.storage.removeItem("debug"):r.storage.debug=e}catch(t){}}function c(){var e;try{e=r.storage.debug}catch(t){}return!e&&"undefined"!=typeof o&&"env"in o&&(e=o.env.DEBUG),e}function u(){try{return window.localStorage}catch(e){}}r=t.exports=e(2),r.log=s,r.formatArgs=i,r.save=a,r.load=c,r.useColors=n,r.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:u(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},r.enable(c())}).call(this,e(12))},{12:12,2:2}],2:[function(e,t,r){function o(e){var t,o=0;for(t in e)o=(o<<5)-o+e.charCodeAt(t),o|=0;return r.colors[Math.abs(o)%r.colors.length]}function n(e){function t(){if(t.enabled){var e=t,o=+new Date,n=o-(u||o);e.diff=n,e.prev=u,e.curr=o,u=o;for(var i=new Array(arguments.length),s=0;s0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},o.prototype.on=o.prototype.addListener,o.prototype.once=function(e,t){function r(){this.removeListener(e,r),o||(o=!0,t.apply(this,arguments))}if(!n(t))throw TypeError("listener must be a function");var o=!1;return r.listener=t,this.on(e,r),this},o.prototype.removeListener=function(e,t){var r,o,i,a;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],i=r.length,o=-1,r===t||n(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(r)){for(a=i;a-- >0;)if(r[a]===t||r[a].listener&&r[a].listener===t){o=a;break}if(o<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},o.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],n(r))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},o.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?n(this._events[e])?[this._events[e]]:this._events[e].slice():[]},o.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(n(t))return 1;if(t)return t.length}return 0},o.listenerCount=function(e,t){return e.listenerCount(t)}},{}],5:[function(e,t,r){var o=Object.prototype.hasOwnProperty,n=Object.prototype.toString;t.exports=function(e,t,r){if("[object Function]"!==n.call(t))throw new TypeError("iterator must be a function");var i=e.length;if(i===+i)for(var s=0;s100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),o=(t[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return r*p;case"days":case"day":case"d":return r*l;case"hours":case"hour":case"hrs":case"hr":case"h":return r*u;case"minutes":case"minute":case"mins":case"min":case"m":return r*c;case"seconds":case"second":case"secs":case"sec":case"s":return r*a;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function n(e){return e>=l?Math.round(e/l)+"d":e>=u?Math.round(e/u)+"h":e>=c?Math.round(e/c)+"m":e>=a?Math.round(e/a)+"s":e+"ms"}function i(e){return s(e,l,"day")||s(e,u,"hour")||s(e,c,"minute")||s(e,a,"second")||e+" ms"}function s(e,t,r){if(!(e0)return o(e);if("number"===r&&isNaN(e)===!1)return t["long"]?i(e):n(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],10:[function(e,t,r){"use strict";var o=Object.prototype.hasOwnProperty,n=Object.prototype.toString,i=Array.prototype.slice,s=e(11),a=Object.prototype.propertyIsEnumerable,c=!a.call({toString:null},"toString"),u=a.call(function(){},"prototype"),l=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],p=function(e){var t=e.constructor;return t&&t.prototype===e},d={$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},h=function(){if("undefined"==typeof window)return!1;for(var e in window)try{if(!d["$"+e]&&o.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{p(window[e])}catch(t){return!0}}catch(t){return!0}return!1}(),f=function(e){if("undefined"==typeof window||!h)return p(e);try{return p(e)}catch(t){return!1}},y=function(e){var t=null!==e&&"object"==typeof e,r="[object Function]"===n.call(e),i=s(e),a=t&&"[object String]"===n.call(e),p=[];if(!t&&!r&&!i)throw new TypeError("Object.keys called on a non-object");var d=u&&r;if(a&&e.length>0&&!o.call(e,0))for(var h=0;h0)for(var y=0;y=0&&"[object Function]"===o.call(e.callee)),r}},{}],12:[function(e,t,r){function o(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function i(e){if(p===setTimeout)return setTimeout(e,0);if((p===o||!p)&&setTimeout)return p=setTimeout,setTimeout(e,0);try{return p(e,0)}catch(t){try{return p.call(null,e,0)}catch(t){return p.call(this,e,0)}}}function s(e){if(d===clearTimeout)return clearTimeout(e);if((d===n||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(e);try{return d(e)}catch(t){try{return d.call(null,e)}catch(t){return d.call(this,e)}}}function a(){m&&f&&(m=!1,f.length?y=f.concat(y):v=-1,y.length&&c())}function c(){if(!m){var e=i(a);m=!0;for(var t=y.length;t;){for(f=y,y=[];++v1)for(var r=1;r0&&u>c&&(u=c);for(var l=0;l=0?(p=y.substr(0,m),d=y.substr(m+1)):(p=y,d=""),h=decodeURIComponent(p),f=decodeURIComponent(d),o(s,h)?n(s[h])?s[h].push(f):s[h]=[s[h],f]:s[h]=f}return s};var n=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],14:[function(e,t,r){"use strict";function o(e,t){if(e.map)return e.map(t);for(var r=[],o=0;o0)n.scope=r;else if("undefined"!=typeof r)throw new Error("the scope given to `copyIndex` was not an array with settings, synonyms or rules");return this._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(e)+"/operation",body:n,hostType:"write",callback:i})},o.prototype.getLogs=function(t,r,o){var n=e(26),i={};return"object"==typeof t?(i=n(t),o=r):0===arguments.length||"function"==typeof t?o=t:1===arguments.length||"function"==typeof r?(o=r,i.offset=t):(i.offset=t,i.length=r),void 0===i.offset&&(i.offset=0),void 0===i.length&&(i.length=10),this._jsonRequest({method:"GET",url:"/1/logs?"+this._getSearchParams(i,""),hostType:"read",callback:o})},o.prototype.listIndexes=function(e,t){var r="";return void 0===e||"function"==typeof e?t=e:r="?page="+e,this._jsonRequest({method:"GET",url:"/1/indexes"+r,hostType:"read",callback:t})},o.prototype.initIndex=function(e){return new i(this,e)},o.prototype.initAnalytics=function(t){var r=e(27);return r(this.applicationID,this.apiKey,t)},o.prototype.listUserKeys=s(function(e){return this.listApiKeys(e)},a("client.listUserKeys()","client.listApiKeys()")),o.prototype.listApiKeys=function(e){return this._jsonRequest({method:"GET",url:"/1/keys",hostType:"read",callback:e})},o.prototype.getUserKeyACL=s(function(e,t){return this.getApiKey(e,t)},a("client.getUserKeyACL()","client.getApiKey()")),o.prototype.getApiKey=function(e,t){return this._jsonRequest({method:"GET",url:"/1/keys/"+e,hostType:"read",callback:t})},o.prototype.deleteUserKey=s(function(e,t){return this.deleteApiKey(e,t)},a("client.deleteUserKey()","client.deleteApiKey()")),o.prototype.deleteApiKey=function(e,t){return this._jsonRequest({method:"DELETE",url:"/1/keys/"+e,hostType:"write",callback:t})},o.prototype.restoreApiKey=function(e,t){return this._jsonRequest({method:"POST",url:"/1/keys/"+e+"/restore",hostType:"write",callback:t})},o.prototype.addUserKey=s(function(e,t,r){return this.addApiKey(e,t,r)},a("client.addUserKey()","client.addApiKey()")),o.prototype.addApiKey=function(t,r,o){var n=e(8),i="Usage: client.addApiKey(arrayOfAcls[, params, callback])";if(!n(t))throw new Error(i);1!==arguments.length&&"function"!=typeof r||(o=r,r=null);var s={acl:t};return r&&(s.validity=r.validity,s.maxQueriesPerIPPerHour=r.maxQueriesPerIPPerHour,s.maxHitsPerQuery=r.maxHitsPerQuery,s.indexes=r.indexes,s.description=r.description,r.queryParameters&&(s.queryParameters=this._getSearchParams(r.queryParameters,"")),s.referers=r.referers),this._jsonRequest({method:"POST",url:"/1/keys",body:s,hostType:"write",callback:o})},o.prototype.addUserKeyWithValidity=s(function(e,t,r){return this.addApiKey(e,t,r)},a("client.addUserKeyWithValidity()","client.addApiKey()")),o.prototype.updateUserKey=s(function(e,t,r,o){return this.updateApiKey(e,t,r,o)},a("client.updateUserKey()","client.updateApiKey()")),o.prototype.updateApiKey=function(t,r,o,n){var i=e(8),s="Usage: client.updateApiKey(key, arrayOfAcls[, params, callback])";if(!i(r))throw new Error(s);2!==arguments.length&&"function"!=typeof o||(n=o,o=null);var a={acl:r};return o&&(a.validity=o.validity,a.maxQueriesPerIPPerHour=o.maxQueriesPerIPPerHour,a.maxHitsPerQuery=o.maxHitsPerQuery,a.indexes=o.indexes,a.description=o.description,o.queryParameters&&(a.queryParameters=this._getSearchParams(o.queryParameters,"")),a.referers=o.referers),this._jsonRequest({method:"PUT",url:"/1/keys/"+t,body:a,hostType:"write",callback:n})},o.prototype.startQueriesBatch=s(function(){this._batch=[]},a("client.startQueriesBatch()","client.search()")),o.prototype.addQueryInBatch=s(function(e,t,r){this._batch.push({indexName:e,query:t,params:r})},a("client.addQueryInBatch()","client.search()")),o.prototype.sendQueriesBatch=s(function(e){return this.search(this._batch,e)},a("client.sendQueriesBatch()","client.search()")),o.prototype.batch=function(t,r){var o=e(8),n="Usage: client.batch(operations[, callback])";if(!o(t))throw new Error(n);return this._jsonRequest({method:"POST",url:"/1/indexes/*/batch",body:{requests:t},hostType:"write",callback:r})},o.prototype.assignUserID=function(e,t){if(!e.userID||!e.cluster)throw new l.AlgoliaSearchError("You have to provide both a userID and cluster",e);return this._jsonRequest({method:"POST",url:"/1/clusters/mapping",hostType:"write",body:{cluster:e.cluster},callback:t,headers:{"x-algolia-user-id":e.userID}})},o.prototype.assignUserIDs=function(e,t){if(!e.userIDs||!e.cluster)throw new l.AlgoliaSearchError("You have to provide both an array of userIDs and cluster",e);return this._jsonRequest({method:"POST",url:"/1/clusters/mapping/batch",hostType:"write",body:{cluster:e.cluster,users:e.userIDs},callback:t})},o.prototype.getTopUserID=function(e){return this._jsonRequest({method:"GET",url:"/1/clusters/mapping/top",hostType:"read",callback:e})},o.prototype.getUserID=function(e,t){if(!e.userID)throw new l.AlgoliaSearchError("You have to provide a userID",{debugData:e});return this._jsonRequest({method:"GET",url:"/1/clusters/mapping/"+e.userID,hostType:"read",callback:t})},o.prototype.listClusters=function(e){return this._jsonRequest({method:"GET",url:"/1/clusters",hostType:"read",callback:e})},o.prototype.listUserIDs=function(e,t){return this._jsonRequest({method:"GET",url:"/1/clusters/mapping",body:e,hostType:"read",callback:t})},o.prototype.removeUserID=function(e,t){if(!e.userID)throw new l.AlgoliaSearchError("You have to provide a userID",{debugData:e});return this._jsonRequest({method:"DELETE",url:"/1/clusters/mapping",hostType:"write",callback:t,headers:{"x-algolia-user-id":e.userID}})},o.prototype.searchUserIDs=function(e,t){return this._jsonRequest({method:"POST",url:"/1/clusters/mapping/search",body:e,hostType:"read",callback:t})},o.prototype.setPersonalizationStrategy=function(e,t){return this._jsonRequest({method:"POST",url:"/1/recommendation/personalization/strategy",body:e,hostType:"write",callback:t})},o.prototype.getPersonalizationStrategy=function(e){return this._jsonRequest({method:"GET",url:"/1/recommendation/personalization/strategy",hostType:"read",callback:e})},o.prototype.destroy=n,o.prototype.enableRateLimitForward=n,o.prototype.disableRateLimitForward=n,o.prototype.useSecuredAPIKey=n,o.prototype.disableSecuredAPIKey=n,o.prototype.generateSecuredApiKey=n,o.prototype.getSecuredApiKeyRemainingValidity=n},{17:17,18:18,26:26,27:27,28:28,29:29,30:30,7:7,8:8}],17:[function(e,t,r){ +(function(r){function o(t,r,o){var i=e(1)("algoliasearch"),s=e(26),a=e(8),u=e(32),l="Usage: algoliasearch(applicationID, apiKey, opts)";if(o._allowEmptyCredentials!==!0&&!t)throw new c.AlgoliaSearchError("Please provide an application ID. "+l);if(o._allowEmptyCredentials!==!0&&!r)throw new c.AlgoliaSearchError("Please provide an API key. "+l);this.applicationID=t,this.apiKey=r,this.hosts={read:[],write:[]},o=o||{},this._timeouts=o.timeouts||{connect:1e3,read:2e3,write:3e4},o.timeout&&(this._timeouts.connect=this._timeouts.read=this._timeouts.write=o.timeout);var p=o.protocol||"https:";if(/:$/.test(p)||(p+=":"),"http:"!==p&&"https:"!==p)throw new c.AlgoliaSearchError("protocol must be `http:` or `https:` (was `"+o.protocol+"`)");if(this._checkAppIdData(),o.hosts)a(o.hosts)?(this.hosts.read=s(o.hosts),this.hosts.write=s(o.hosts)):(this.hosts.read=s(o.hosts.read),this.hosts.write=s(o.hosts.write));else{var d=u(this._shuffleResult,function(e){return t+"-"+e+".algolianet.com"}),h=(o.dsn===!1?"":"-dsn")+".algolia.net";this.hosts.read=[this.applicationID+h].concat(d),this.hosts.write=[this.applicationID+".algolia.net"].concat(d)}this.hosts.read=u(this.hosts.read,n(p)),this.hosts.write=u(this.hosts.write,n(p)),this.extraHeaders={},this.cache=o._cache||{},this._ua=o._ua,this._useCache=!(void 0!==o._useCache&&!o._cache)||o._useCache,this._useRequestCache=this._useCache&&o._useRequestCache,this._useFallback=void 0===o.useFallback||o.useFallback,this._setTimeout=o._setTimeout,i("init done, %j",this)}function n(e){return function(t){return e+"//"+t.toLowerCase()}}function i(e){if(void 0===Array.prototype.toJSON)return JSON.stringify(e);var t=Array.prototype.toJSON;delete Array.prototype.toJSON;var r=JSON.stringify(e);return Array.prototype.toJSON=t,r}function s(e){for(var t,r,o=e.length;0!==o;)r=Math.floor(Math.random()*o),o-=1,t=e[o],e[o]=e[r],e[r]=t;return e}function a(e){var t={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var o;o="x-algolia-api-key"===r||"x-algolia-application-id"===r?"**hidden for security purposes**":e[r],t[r]=o}return t}t.exports=o;var c=e(30),u=e(31),l=e(20),p=e(36),d=500,h=r.env.RESET_APP_DATA_TIMER&&parseInt(r.env.RESET_APP_DATA_TIMER,10)||12e4;o.prototype.initIndex=function(e){return new l(this,e)},o.prototype.setExtraHeader=function(e,t){this.extraHeaders[e.toLowerCase()]=t},o.prototype.getExtraHeader=function(e){return this.extraHeaders[e.toLowerCase()]},o.prototype.unsetExtraHeader=function(e){delete this.extraHeaders[e.toLowerCase()]},o.prototype.addAlgoliaAgent=function(e){var t="; "+e;this._ua.indexOf(t)===-1&&(this._ua+=t)},o.prototype._jsonRequest=function(t){function r(e,n){function u(e){var t=e&&e.body&&e.body.message&&e.body.status||e.statusCode||e&&e.body&&200;h("received response: statusCode: %s, computed statusCode: %d, headers: %j",e.statusCode,t,e.headers);var r=2===Math.floor(t/100),o=new Date;if(w.push({currentHost:A,headers:a(p),content:s||null,contentLength:void 0!==s?s.length:null,method:n.method,timeouts:n.timeouts,url:n.url,startTime:x,endTime:o,duration:o-x,statusCode:t}),r)return m._useCache&&!m._useRequestCache&&y&&(y[l]=e.responseText),{responseText:e.responseText,body:e.body};var i=4!==Math.floor(t/100);if(i)return v+=1,_();h("unrecoverable error");var u=new c.AlgoliaSearchError(e.body&&e.body.message,{debugData:w,statusCode:t});return m._promise.reject(u)}function d(e){h("error: %s, stack: %s",e.message,e.stack);var r=new Date;return w.push({currentHost:A,headers:a(p),content:s||null,contentLength:void 0!==s?s.length:null,method:n.method,timeouts:n.timeouts,url:n.url,startTime:x,endTime:r,duration:r-x}),e instanceof c.AlgoliaSearchError||(e=new c.Unknown(e&&e.message,e)),v+=1,e instanceof c.Unknown||e instanceof c.UnparsableJSON||v>=m.hosts[t.hostType].length&&(g||!b)?(e.debugData=w,m._promise.reject(e)):e instanceof c.RequestTimeout?T():_()}function _(){return h("retrying request"),m._incrementHostIndex(t.hostType),r(e,n)}function T(){return h("retrying request with higher timeout"),m._incrementHostIndex(t.hostType),m._incrementTimeoutMultipler(),n.timeouts=m._getTimeoutsForRequest(t.hostType),r(e,n)}m._checkAppIdData();var x=new Date;if(m._useCache&&!m._useRequestCache&&(l=t.url),m._useCache&&!m._useRequestCache&&s&&(l+="_body_"+n.body),o(!m._useRequestCache,y,l)){h("serving response from cache");var R=y[l];return m._promise.resolve({body:JSON.parse(R),responseText:R})}if(v>=m.hosts[t.hostType].length)return!b||g?(h("could not get any response"),m._promise.reject(new c.AlgoliaSearchError("Cannot connect to the AlgoliaSearch API. Send an email to support@algolia.com to report and resolve the issue. Application id was: "+m.applicationID,{debugData:w}))):(h("switching to fallback"),v=0,n.method=t.fallback.method,n.url=t.fallback.url,n.jsonBody=t.fallback.body,n.jsonBody&&(n.body=i(n.jsonBody)),p=m._computeRequestHeaders({additionalUA:f,headers:t.headers}),n.timeouts=m._getTimeoutsForRequest(t.hostType),m._setHostIndexByType(0,t.hostType),g=!0,r(m._request.fallback,n));var A=m._getHostByType(t.hostType),j=A+n.url,S={body:n.body,jsonBody:n.jsonBody,method:n.method,headers:p,timeouts:n.timeouts,debug:h,forceAuthHeaders:n.forceAuthHeaders};return h("method: %s, url: %s, headers: %j, timeouts: %d",S.method,j,S.headers,S.timeouts),e===m._request.fallback&&h("using fallback"),e.call(m,j,S).then(u,d)}function o(e,t,r){return m._useCache&&e&&t&&void 0!==t[r]}function n(e,r){return o(m._useRequestCache,y,l)&&e["catch"](function(){delete y[l]}),"function"!=typeof t.callback?e.then(r):void e.then(function(e){u(function(){t.callback(null,r(e))},m._setTimeout||setTimeout)},function(e){u(function(){t.callback(e)},m._setTimeout||setTimeout)})}this._checkAppIdData();var s,l,p,h=e(1)("algoliasearch:"+t.url),f=t.additionalUA||"",y=t.cache,m=this,v=0,g=!1,b=m._useFallback&&m._request.fallback&&t.fallback;this.apiKey.length>d&&void 0!==t.body&&(void 0!==t.body.params||void 0!==t.body.requests)?(t.body.apiKey=this.apiKey,p=this._computeRequestHeaders({additionalUA:f,withApiKey:!1,headers:t.headers})):p=this._computeRequestHeaders({additionalUA:f,headers:t.headers}),void 0!==t.body&&(s=i(t.body)),h("request start");var w=[];if(m._useCache&&m._useRequestCache&&(l=t.url),m._useCache&&m._useRequestCache&&s&&(l+="_body_"+s),o(m._useRequestCache,y,l)){h("serving request from cache");var _=y[l],T="function"!=typeof _.then?m._promise.resolve({responseText:_}):_;return n(T,function(e){return JSON.parse(e.responseText)})}var x=r(m._request,{url:t.url,method:t.method,body:s,jsonBody:t.body,timeouts:m._getTimeoutsForRequest(t.hostType),forceAuthHeaders:t.forceAuthHeaders});return m._useCache&&m._useRequestCache&&y&&(y[l]=x),n(x,function(e){return e.body})},o.prototype._getSearchParams=function(e,t){if(void 0===e||null===e)return t;for(var r in e)null!==r&&void 0!==e[r]&&e.hasOwnProperty(r)&&(t+=""===t?"":"&",t+=r+"="+encodeURIComponent("[object Array]"===Object.prototype.toString.call(e[r])?i(e[r]):e[r]));return t},o.prototype._computeRequestHeaders=function(t){var r=e(5),o=t.additionalUA?this._ua+"; "+t.additionalUA:this._ua,n={"x-algolia-agent":o,"x-algolia-application-id":this.applicationID};return t.withApiKey!==!1&&(n["x-algolia-api-key"]=this.apiKey),this.userToken&&(n["x-algolia-usertoken"]=this.userToken),this.securityTags&&(n["x-algolia-tagfilters"]=this.securityTags),r(this.extraHeaders,function(e,t){n[t]=e}),t.headers&&r(t.headers,function(e,t){n[t]=e}),n},o.prototype.search=function(t,r,o){var n=e(8),i=e(32),s="Usage: client.search(arrayOfQueries[, callback])";if(!n(t))throw new Error(s);"function"==typeof r?(o=r,r={}):void 0===r&&(r={});var a=this,c={requests:i(t,function(e){var t="";return void 0!==e.query&&(t+="query="+encodeURIComponent(e.query)),{indexName:e.indexName,params:a._getSearchParams(e.params,t)}})},u=i(c.requests,function(e,t){return t+"="+encodeURIComponent("/1/indexes/"+encodeURIComponent(e.indexName)+"?"+e.params)}).join("&"),l="/1/indexes/*/queries";return void 0!==r.strategy&&(c.strategy=r.strategy),this._jsonRequest({cache:this.cache,method:"POST",url:l,body:c,hostType:"read",fallback:{method:"GET",url:"/1/indexes/*",body:{params:u}},callback:o})},o.prototype.searchForFacetValues=function(t){var r=e(8),o=e(32),n="Usage: client.searchForFacetValues([{indexName, params: {facetName, facetQuery, ...params}}, ...queries])";if(!r(t))throw new Error(n);var i=this;return i._promise.all(o(t,function(t){if(!t||void 0===t.indexName||void 0===t.params.facetName||void 0===t.params.facetQuery)throw new Error(n);var r=e(26),o=e(34),s=t.indexName,a=t.params,c=a.facetName,u=o(r(a),function(e){return"facetName"===e}),l=i._getSearchParams(u,"");return i._jsonRequest({cache:i.cache,method:"POST",url:"/1/indexes/"+encodeURIComponent(s)+"/facets/"+encodeURIComponent(c)+"/query",hostType:"read",body:{params:l}})}))},o.prototype.setSecurityTags=function(e){if("[object Array]"===Object.prototype.toString.call(e)){for(var t=[],r=0;rh?this._resetInitialAppIdData(e):e},o.prototype._resetInitialAppIdData=function(e){var t=e||{};return t.hostIndexes={read:0,write:0},t.timeoutMultiplier=1,t.shuffleResult=t.shuffleResult||s([1,2,3]),this._setAppIdData(t)},o.prototype._cacheAppIdData=function(e){this._hostIndexes=e.hostIndexes,this._timeoutMultiplier=e.timeoutMultiplier,this._shuffleResult=e.shuffleResult},o.prototype._partialAppIdDataUpdate=function(t){var r=e(5),o=this._getAppIdData();return r(t,function(e,t){o[t]=e}),this._setAppIdData(o)},o.prototype._getHostByType=function(e){return this.hosts[e][this._getHostIndexByType(e)]},o.prototype._getTimeoutMultiplier=function(){return this._timeoutMultiplier},o.prototype._getHostIndexByType=function(e){return this._hostIndexes[e]},o.prototype._setHostIndexByType=function(t,r){var o=e(26),n=o(this._hostIndexes);return n[r]=t,this._partialAppIdDataUpdate({hostIndexes:n}),t},o.prototype._incrementHostIndex=function(e){return this._setHostIndexByType((this._getHostIndexByType(e)+1)%this.hosts[e].length,e)},o.prototype._incrementTimeoutMultipler=function(){var e=Math.max(this._timeoutMultiplier+1,4);return this._partialAppIdDataUpdate({timeoutMultiplier:e})},o.prototype._getTimeoutsForRequest=function(e){return{connect:this._timeouts.connect*this._timeoutMultiplier,complete:this._timeouts[e]*this._timeoutMultiplier}}}).call(this,e(12))},{1:1,12:12,20:20,26:26,30:30,31:31,32:32,34:34,36:36,5:5,8:8}],18:[function(e,t,r){function o(){s.apply(this,arguments)}function n(e,t,r){function o(r,n){var i={page:r||0,hitsPerPage:t||100},s=n||[];return e(i).then(function(e){var t=e.hits,r=e.nbHits,n=t.map(function(e){return delete e._highlightResult,e}),a=s.concat(n);return a.lengths&&(t=s),"published"!==e.status?l._promise.delay(t).then(r):e})}function o(e){u(function(){t(null,e)},l._setTimeout||setTimeout)}function n(e){u(function(){t(e)},l._setTimeout||setTimeout)}var i=100,s=5e3,a=0,c=this,l=c.as,p=r();return t?void p.then(o,n):p},o.prototype.clearIndex=function(e){var t=this;return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(t.indexName)+"/clear",hostType:"write",callback:e})},o.prototype.getSettings=function(e,t){1===arguments.length&&"function"==typeof e&&(t=e,e={}),e=e||{};var r=encodeURIComponent(this.indexName);return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+r+"/settings?getVersion=2"+(e.advanced?"&advanced="+e.advanced:""),hostType:"read",callback:t})},o.prototype.searchSynonyms=function(e,t){return"function"==typeof e?(t=e,e={}):void 0===e&&(e={}),this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/search",body:e,hostType:"read",callback:t})},o.prototype.exportSynonyms=function(e,t){return n(this.searchSynonyms.bind(this),e,t)},o.prototype.saveSynonym=function(e,t,r){"function"==typeof t?(r=t,t={}):void 0===t&&(t={}),void 0!==t.forwardToSlaves&&p();var o=t.forwardToSlaves||t.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/"+encodeURIComponent(e.objectID)+"?forwardToReplicas="+o,body:e,hostType:"write",callback:r})},o.prototype.getSynonym=function(e,t){return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/"+encodeURIComponent(e),hostType:"read",callback:t})},o.prototype.deleteSynonym=function(e,t,r){"function"==typeof t?(r=t,t={}):void 0===t&&(t={}),void 0!==t.forwardToSlaves&&p();var o=t.forwardToSlaves||t.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/"+encodeURIComponent(e)+"?forwardToReplicas="+o,hostType:"write",callback:r})},o.prototype.clearSynonyms=function(e,t){"function"==typeof e?(t=e,e={}):void 0===e&&(e={}),void 0!==e.forwardToSlaves&&p();var r=e.forwardToSlaves||e.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/clear?forwardToReplicas="+r,hostType:"write",callback:t})},o.prototype.batchSynonyms=function(e,t,r){"function"==typeof t?(r=t,t={}):void 0===t&&(t={}),void 0!==t.forwardToSlaves&&p();var o=t.forwardToSlaves||t.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/batch?forwardToReplicas="+o+"&replaceExistingSynonyms="+(t.replaceExistingSynonyms?"true":"false"),hostType:"write",body:e,callback:r})},o.prototype.searchRules=function(e,t){return"function"==typeof e?(t=e,e={}):void 0===e&&(e={}),this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/search",body:e,hostType:"read",callback:t})},o.prototype.exportRules=function(e,t){return n(this.searchRules.bind(this),e,t)},o.prototype.saveRule=function(e,t,r){if("function"==typeof t?(r=t,t={}):void 0===t&&(t={}),!e.objectID)throw new l.AlgoliaSearchError("Missing or empty objectID field for rule");var o=t.forwardToReplicas===!0?"true":"false";return this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/"+encodeURIComponent(e.objectID)+"?forwardToReplicas="+o,body:e,hostType:"write",callback:r})},o.prototype.getRule=function(e,t){return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/"+encodeURIComponent(e),hostType:"read",callback:t})},o.prototype.deleteRule=function(e,t,r){"function"==typeof t?(r=t,t={}):void 0===t&&(t={});var o=t.forwardToReplicas===!0?"true":"false";return this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/"+encodeURIComponent(e)+"?forwardToReplicas="+o,hostType:"write",callback:r})},o.prototype.clearRules=function(e,t){"function"==typeof e?(t=e,e={}):void 0===e&&(e={});var r=e.forwardToReplicas===!0?"true":"false";return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/clear?forwardToReplicas="+r,hostType:"write",callback:t})},o.prototype.batchRules=function(e,t,r){"function"==typeof t?(r=t,t={}):void 0===t&&(t={});var o=t.forwardToReplicas===!0?"true":"false";return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/batch?forwardToReplicas="+o+"&clearExistingRules="+(t.clearExistingRules===!0?"true":"false"),hostType:"write",body:e,callback:r})},o.prototype.exists=function(e){var t=this.getSettings().then(function(){return!0})["catch"](function(e){if(e instanceof l.AlgoliaSearchError&&404===e.statusCode)return!1;throw e});return"function"!=typeof e?t:void t.then(function(t){e(null,t)})["catch"](function(t){e(t)})},o.prototype.findObject=function(e,t,r){t=void 0===t?{}:t;var o=void 0===t.paginate||t.paginate,n=void 0!==t.query?t.query:"",i=this,s=0,a=function(){return t.page=s,i.search(n,t).then(function(t){for(var r=t.hits,n=0;n=t.nbPages)throw new l.ObjectNotFound("Object not found");return a()})},c=a(s);return void 0===r?c:void c.then(function(e){r(null,e)})["catch"](function(e){r(e)})},o.prototype.getObjectPosition=function(e,t){for(var r=e.hits,o=0;o1&&a()}if(!h.cors&&!h.hasXDomainRequest)return void o(new u.Network("CORS not supported"));e=l(e,t.headers);var d,f,y=t.body,m=h.cors?new XMLHttpRequest:new XDomainRequest,v=!1;d=setTimeout(s,t.timeouts.connect),m.onprogress=c,"onreadystatechange"in m&&(m.onreadystatechange=p),m.onload=n,m.onerror=i,m instanceof XMLHttpRequest?(m.open(t.method,e,!0),t.forceAuthHeaders&&(m.setRequestHeader("x-algolia-application-id",t.headers["x-algolia-application-id"]),m.setRequestHeader("x-algolia-api-key",t.headers["x-algolia-api-key"]))):m.open(t.method,e),h.cors&&(y&&("POST"===t.method?m.setRequestHeader("content-type","application/x-www-form-urlencoded"):m.setRequestHeader("content-type","application/json")),m.setRequestHeader("accept","application/json")),y?m.send(y):m.send()})},a.prototype._request.fallback=function(e,t){return e=l(e,t.headers),new n(function(r,o){p(e,t,function(e,t){return e?void o(e):void r(t)})})},a.prototype._promise={reject:function(e){return n.reject(e)},resolve:function(e){return n.resolve(e)},delay:function(e){return new n(function(t){setTimeout(t,e)})},all:function(e){return n.all(e)}},s}}).call(this,e(12))},{1:1,12:12,23:23,24:24,26:26,3:3,30:30,35:35,37:37,6:6,7:7}],23:[function(e,t,r){"use strict";function o(e,t){return e+=/\?/.test(e)?"&":"?",e+n(t)}t.exports=o;var n=e(14)},{14:14}],24:[function(e,t,r){"use strict";function o(e,t,r){function o(){t.debug("JSONP: success"),m||d||(m=!0,p||(t.debug("JSONP: Fail. Script loaded but did not call the callback"), +a(),r(new n.JSONPScriptFail)))}function s(){"loaded"!==this.readyState&&"complete"!==this.readyState||o()}function a(){clearTimeout(v),f.onload=null,f.onreadystatechange=null,f.onerror=null,h.removeChild(f)}function c(){try{delete window[y],delete window[y+"_loaded"]}catch(e){window[y]=window[y+"_loaded"]=void 0}}function u(){t.debug("JSONP: Script timeout"),d=!0,a(),r(new n.RequestTimeout)}function l(){t.debug("JSONP: Script error"),m||d||(a(),r(new n.JSONPScriptError))}if("GET"!==t.method)return void r(new Error("Method "+t.method+" "+e+" is not supported by JSONP."));t.debug("JSONP: start");var p=!1,d=!1;i+=1;var h=document.getElementsByTagName("head")[0],f=document.createElement("script"),y="algoliaJSONP_"+i,m=!1;window[y]=function(e){return c(),d?void t.debug("JSONP: Late answer, ignoring"):(p=!0,a(),void r(null,{body:e,responseText:JSON.stringify(e)}))},e+="&callback="+y,t.jsonBody&&t.jsonBody.params&&(e+="&"+t.jsonBody.params);var v=setTimeout(u,t.timeouts.complete);f.onreadystatechange=s,f.onload=o,f.onerror=l,f.async=!0,f.defer=!0,f.src=e,h.appendChild(f)}t.exports=o;var n=e(30),i=0},{30:30}],25:[function(e,t,r){function o(e,t){return function(r,o,i){if("function"==typeof r&&"object"==typeof o||"object"==typeof i)throw new n.AlgoliaSearchError("index.search usage is index.search(query, params, cb)");0===arguments.length||"function"==typeof r?(i=r,r=""):1!==arguments.length&&"function"!=typeof o||(i=o,o=void 0),"object"==typeof r&&null!==r?(o=r,r=void 0):void 0!==r&&null!==r||(r="");var s="";void 0!==r&&(s+=e+"="+encodeURIComponent(r));var a;return void 0!==o&&(o.additionalUA&&(a=o.additionalUA,delete o.additionalUA),s=this.as._getSearchParams(o,s)),this._search(s,t,i,a)}}t.exports=o;var n=e(30)},{30:30}],26:[function(e,t,r){t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],27:[function(e,t,r){function o(e,t,r){var o={};return r=r||{},r.hosts=r.hosts||["analytics.algolia.com","analytics.algolia.com","analytics.algolia.com","analytics.algolia.com"],r.protocol=r.protocol||"https:",o.as=n(e,t,r),o.getABTests=function(e,t){var r=r||{},o=r.offset||0,n=r.limit||10;return this.as._jsonRequest({method:"GET",url:"/2/abtests?offset="+encodeURIComponent(o)+"&limit="+encodeURIComponent(n),hostType:"read",forceAuthHeaders:!0,callback:t})},o.getABTest=function(e,t){return this.as._jsonRequest({method:"GET",url:"/2/abtests/"+encodeURIComponent(e),hostType:"read",forceAuthHeaders:!0,callback:t})},o.addABTest=function(e,t){return this.as._jsonRequest({method:"POST",url:"/2/abtests",body:e,hostType:"read",forceAuthHeaders:!0,callback:t})},o.stopABTest=function(e,t){return this.as._jsonRequest({method:"POST",url:"/2/abtests/"+encodeURIComponent(e)+"/stop",hostType:"read",forceAuthHeaders:!0,callback:t})},o.deleteABTest=function(e,t){return this.as._jsonRequest({method:"DELETE",url:"/2/abtests/"+encodeURIComponent(e),hostType:"write",forceAuthHeaders:!0,callback:t})},o.waitTask=function(e,t,r){return this.as.initIndex(e).waitTask(t,r)},o}t.exports=o;var n=e(21)},{21:21}],28:[function(e,t,r){t.exports=function(e,t){function r(){return o||(console.warn(t),o=!0),e.apply(this,arguments)}var o=!1;return r}},{}],29:[function(e,t,r){t.exports=function(e,t){var r=e.toLowerCase().replace(/[\.\(\)]/g,"");return"algoliasearch: `"+e+"` was replaced by `"+t+"`. Please see https://github.com/algolia/algoliasearch-client-javascript/wiki/Deprecated#"+r}},{}],30:[function(e,t,r){"use strict";function o(t,r){var o=e(5),n=this;"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):n.stack=(new Error).stack||"Cannot get a stacktrace, browser is too old",this.name="AlgoliaSearchError",this.message=t||"Unknown error",r&&o(r,function(e,t){n[t]=e})}function n(e,t){function r(){var r=Array.prototype.slice.call(arguments,0);"string"!=typeof r[0]&&r.unshift(t),o.apply(this,r),this.name="AlgoliaSearch"+e+"Error"}return i(r,o),r}var i=e(7);i(o,Error),t.exports={AlgoliaSearchError:o,UnparsableJSON:n("UnparsableJSON","Could not parse the incoming response as JSON, see err.more for details"),RequestTimeout:n("RequestTimeout","Request timed out before getting a response"),Network:n("Network","Network issue, see err.more for details"),JSONPScriptFail:n("JSONPScriptFail"," + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + DayDay's Studio. +
+
+
+ + + +
+
+
+ +

+ + +

+ +

+ + +

+ + +
+
+ + +
+
+ + + + + + + + + + +
+ + +
+
+ + + + + + + + +
+ + + PV: :) + +
+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/categories/\347\275\256\351\241\266/index.html" "b/categories/\347\275\256\351\241\266/index.html" new file mode 100644 index 0000000..6f27274 --- /dev/null +++ "b/categories/\347\275\256\351\241\266/index.html" @@ -0,0 +1,1012 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + DayDay's Studio. +
+
+
+ + + +
+
+
+ +

+ + +

+ +

+ + +

+ + +
+
+ + +
+
+ + + + + + + + + + +
+ + +
+
+ + + + + + + + +
+ + + PV: :) + +
+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/categories/\350\256\241\347\256\227\346\234\272\346\212\200\346\234\257/index.html" "b/categories/\350\256\241\347\256\227\346\234\272\346\212\200\346\234\257/index.html" new file mode 100644 index 0000000..895c762 --- /dev/null +++ "b/categories/\350\256\241\347\256\227\346\234\272\346\212\200\346\234\257/index.html" @@ -0,0 +1,1299 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + DayDay's Studio. +
+
+
+ + + +
+
+
+ +

+ + +

+ +

+ + +

+ + +
+
+ + +
+
+ + + + + + + + + + + + + +
+ + + CSS3 变量 + +
+ 工作需要了解了一下CSS3变量内容,简单记录一下。 +
+ +
+ + + + + + + + + + + + + + + + + + + + +
+ + + 媒体自动播放 + +
+ 前几天工作上遇到需要自动播放视频的需求,在自己搜索和亲友团的帮助下,整理处以下内容。 +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + + + + + + + +
+ + + PV: :) + +
+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/categories/\350\256\241\347\256\227\346\234\272\346\212\200\346\234\257/page/2/index.html" "b/categories/\350\256\241\347\256\227\346\234\272\346\212\200\346\234\257/page/2/index.html" new file mode 100644 index 0000000..c16cb29 --- /dev/null +++ "b/categories/\350\256\241\347\256\227\346\234\272\346\212\200\346\234\257/page/2/index.html" @@ -0,0 +1,1241 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + DayDay's Studio. +
+
+
+ + + +
+
+
+ +

+ + +

+ +

+ + +

+ + +
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + + + + + + + +
+ + + PV: :) + +
+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/categories/\351\227\262\350\260\210/index.html" "b/categories/\351\227\262\350\260\210/index.html" new file mode 100644 index 0000000..a6cce06 --- /dev/null +++ "b/categories/\351\227\262\350\260\210/index.html" @@ -0,0 +1,1012 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + DayDay's Studio. +
+
+
+ + + +
+
+
+ +

+ + +

+ +

+ + +

+ + +
+
+ + +
+
+ + + + + + + + + + +
+ + +
+
+ + + + + + + + +
+ + + PV: :) + +
+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/content.json b/content.json new file mode 100644 index 0000000..457e2f7 --- /dev/null +++ b/content.json @@ -0,0 +1 @@ +{"meta":{"title":"【DayDay】卡比兽之巢","subtitle":"鲤鱼王型前端程序员成长历程","description":"记录开发中遇到的问题,主要是给自己看到,目前专注前端方面内容,哈哈哈。","author":"DayDay","url":"https://trcat.github.io","root":"/"},"posts":[{"title":"性能测试工具","date":"2021-06-08T12:22:26.000Z","path":"2021/06/08/性能测试工具/","permalink":"https://trcat.github.io/2021/06/08/%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%95%E5%B7%A5%E5%85%B7/","categories":[{"name":"计算机技术","slug":"计算机技术","permalink":"https://trcat.github.io/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%8A%80%E6%9C%AF/"}],"tags":[{"name":"前端","slug":"前端","permalink":"https://trcat.github.io/tags/%E5%89%8D%E7%AB%AF/"},{"name":"工具","slug":"工具","permalink":"https://trcat.github.io/tags/%E5%B7%A5%E5%85%B7/"}]},{"title":"CSS3 变量","date":"2021-06-08T12:18:06.000Z","path":"2021/06/08/CSS3-变量/","permalink":"https://trcat.github.io/2021/06/08/CSS3-%E5%8F%98%E9%87%8F/","categories":[{"name":"计算机技术","slug":"计算机技术","permalink":"https://trcat.github.io/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%8A%80%E6%9C%AF/"}],"tags":[{"name":"css","slug":"css","permalink":"https://trcat.github.io/tags/css/"}]},{"title":"Echarts Custom Series","date":"2021-04-04T14:56:38.000Z","path":"2021/04/04/Echarts-Custom-Series/","permalink":"https://trcat.github.io/2021/04/04/Echarts-Custom-Series/","categories":[{"name":"计算机技术","slug":"计算机技术","permalink":"https://trcat.github.io/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%8A%80%E6%9C%AF/"}],"tags":[{"name":"前端","slug":"前端","permalink":"https://trcat.github.io/tags/%E5%89%8D%E7%AB%AF/"},{"name":"echarts","slug":"echarts","permalink":"https://trcat.github.io/tags/echarts/"}]},{"title":"IcoMoon初体验","date":"2020-12-28T12:41:08.000Z","path":"2020/12/28/IcoMoon初体验/","permalink":"https://trcat.github.io/2020/12/28/IcoMoon%E5%88%9D%E4%BD%93%E9%AA%8C/","categories":[{"name":"计算机技术","slug":"计算机技术","permalink":"https://trcat.github.io/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%8A%80%E6%9C%AF/"}],"tags":[{"name":"前端","slug":"前端","permalink":"https://trcat.github.io/tags/%E5%89%8D%E7%AB%AF/"},{"name":"SVG","slug":"SVG","permalink":"https://trcat.github.io/tags/SVG/"},{"name":"WebFont","slug":"WebFont","permalink":"https://trcat.github.io/tags/WebFont/"},{"name":"工具","slug":"工具","permalink":"https://trcat.github.io/tags/%E5%B7%A5%E5%85%B7/"}]},{"title":"媒体自动播放","date":"2020-12-28T12:32:22.000Z","path":"2020/12/28/媒体自动播放/","permalink":"https://trcat.github.io/2020/12/28/%E5%AA%92%E4%BD%93%E8%87%AA%E5%8A%A8%E6%92%AD%E6%94%BE/","categories":[{"name":"计算机技术","slug":"计算机技术","permalink":"https://trcat.github.io/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%8A%80%E6%9C%AF/"}],"tags":[{"name":"前端","slug":"前端","permalink":"https://trcat.github.io/tags/%E5%89%8D%E7%AB%AF/"},{"name":"javascript","slug":"javascript","permalink":"https://trcat.github.io/tags/javascript/"}]},{"title":"如何判断当前页面是否被 iframe 标签引用","date":"2020-10-28T14:17:55.000Z","path":"2020/10/28/如何判断当前页面是否被-iframe-标签引用/","permalink":"https://trcat.github.io/2020/10/28/%E5%A6%82%E4%BD%95%E5%88%A4%E6%96%AD%E5%BD%93%E5%89%8D%E9%A1%B5%E9%9D%A2%E6%98%AF%E5%90%A6%E8%A2%AB-iframe-%E6%A0%87%E7%AD%BE%E5%BC%95%E7%94%A8/","categories":[{"name":"计算机技术","slug":"计算机技术","permalink":"https://trcat.github.io/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%8A%80%E6%9C%AF/"}],"tags":[{"name":"javascript","slug":"javascript","permalink":"https://trcat.github.io/tags/javascript/"},{"name":"html","slug":"html","permalink":"https://trcat.github.io/tags/html/"},{"name":"转载","slug":"转载","permalink":"https://trcat.github.io/tags/%E8%BD%AC%E8%BD%BD/"}]},{"title":"JavaScript 获取 Element 的宽度的多种姿势","date":"2020-10-26T14:20:39.000Z","path":"2020/10/26/JavaScript-获取-Element-的宽度的多种姿势/","permalink":"https://trcat.github.io/2020/10/26/JavaScript-%E8%8E%B7%E5%8F%96-Element-%E7%9A%84%E5%AE%BD%E5%BA%A6%E7%9A%84%E5%A4%9A%E7%A7%8D%E5%A7%BF%E5%8A%BF/","categories":[{"name":"计算机技术","slug":"计算机技术","permalink":"https://trcat.github.io/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%8A%80%E6%9C%AF/"}],"tags":[{"name":"前端","slug":"前端","permalink":"https://trcat.github.io/tags/%E5%89%8D%E7%AB%AF/"},{"name":"javascript","slug":"javascript","permalink":"https://trcat.github.io/tags/javascript/"}]},{"title":"居中图片的多种姿势","date":"2020-10-26T14:17:20.000Z","path":"2020/10/26/居中图片的多种姿势/","permalink":"https://trcat.github.io/2020/10/26/%E5%B1%85%E4%B8%AD%E5%9B%BE%E7%89%87%E7%9A%84%E5%A4%9A%E7%A7%8D%E5%A7%BF%E5%8A%BF/","categories":[{"name":"计算机技术","slug":"计算机技术","permalink":"https://trcat.github.io/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%8A%80%E6%9C%AF/"}],"tags":[{"name":"css","slug":"css","permalink":"https://trcat.github.io/tags/css/"},{"name":"前端","slug":"前端","permalink":"https://trcat.github.io/tags/%E5%89%8D%E7%AB%AF/"},{"name":"html","slug":"html","permalink":"https://trcat.github.io/tags/html/"}]},{"title":"GitHub Pages 发布遇到的问题","date":"2020-10-26T13:20:14.000Z","path":"2020/10/26/GitHub-Pages-发布遇到的问题/","permalink":"https://trcat.github.io/2020/10/26/GitHub-Pages-%E5%8F%91%E5%B8%83%E9%81%87%E5%88%B0%E7%9A%84%E9%97%AE%E9%A2%98/","categories":[{"name":"计算机技术","slug":"计算机技术","permalink":"https://trcat.github.io/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%8A%80%E6%9C%AF/"}],"tags":[{"name":"Git","slug":"Git","permalink":"https://trcat.github.io/tags/Git/"},{"name":"搬运","slug":"搬运","permalink":"https://trcat.github.io/tags/%E6%90%AC%E8%BF%90/"}]},{"title":"Apple Music 资源库数据丢失解决方案","date":"2020-03-14T08:24:38.000Z","path":"2020/03/14/Apple-Music-资源库数据丢失解决方案/","permalink":"https://trcat.github.io/2020/03/14/Apple-Music-%E8%B5%84%E6%BA%90%E5%BA%93%E6%95%B0%E6%8D%AE%E4%B8%A2%E5%A4%B1%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88/","categories":[{"name":"手机应用","slug":"手机应用","permalink":"https://trcat.github.io/categories/%E6%89%8B%E6%9C%BA%E5%BA%94%E7%94%A8/"}],"tags":[{"name":"Apple Music","slug":"Apple-Music","permalink":"https://trcat.github.io/tags/Apple-Music/"},{"name":"iPhone","slug":"iPhone","permalink":"https://trcat.github.io/tags/iPhone/"}]},{"title":"React Native 文档基础部分小结","date":"2020-03-10T11:52:25.000Z","path":"2020/03/10/React-Native-文档基础部分小结/","permalink":"https://trcat.github.io/2020/03/10/React-Native-%E6%96%87%E6%A1%A3%E5%9F%BA%E7%A1%80%E9%83%A8%E5%88%86%E5%B0%8F%E7%BB%93/","categories":[{"name":"计算机技术","slug":"计算机技术","permalink":"https://trcat.github.io/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%8A%80%E6%9C%AF/"}],"tags":[{"name":"react-native","slug":"react-native","permalink":"https://trcat.github.io/tags/react-native/"}]},{"title":"React diff 的理解","date":"2020-03-03T13:59:41.000Z","path":"2020/03/03/React-diff-的理解/","permalink":"https://trcat.github.io/2020/03/03/React-diff-%E7%9A%84%E7%90%86%E8%A7%A3/","categories":[{"name":"计算机技术","slug":"计算机技术","permalink":"https://trcat.github.io/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%8A%80%E6%9C%AF/"}],"tags":[{"name":"搬运","slug":"搬运","permalink":"https://trcat.github.io/tags/%E6%90%AC%E8%BF%90/"},{"name":"react","slug":"react","permalink":"https://trcat.github.io/tags/react/"}]},{"title":"jQuery 对象和 DOM 对象的相互转换","date":"2020-03-03T13:57:49.000Z","path":"2020/03/03/jQuery-对象和-DOM-对象的相互转换/","permalink":"https://trcat.github.io/2020/03/03/jQuery-%E5%AF%B9%E8%B1%A1%E5%92%8C-DOM-%E5%AF%B9%E8%B1%A1%E7%9A%84%E7%9B%B8%E4%BA%92%E8%BD%AC%E6%8D%A2/","categories":[{"name":"计算机技术","slug":"计算机技术","permalink":"https://trcat.github.io/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%8A%80%E6%9C%AF/"}],"tags":[{"name":"搬运","slug":"搬运","permalink":"https://trcat.github.io/tags/%E6%90%AC%E8%BF%90/"},{"name":"html","slug":"html","permalink":"https://trcat.github.io/tags/html/"},{"name":"jquery","slug":"jquery","permalink":"https://trcat.github.io/tags/jquery/"}]},{"title":"SVG 和 Canvas 的区别","date":"2020-03-03T13:55:18.000Z","path":"2020/03/03/SVG-和-Canvas-的区别/","permalink":"https://trcat.github.io/2020/03/03/SVG-%E5%92%8C-Canvas-%E7%9A%84%E5%8C%BA%E5%88%AB/","categories":[{"name":"计算机技术","slug":"计算机技术","permalink":"https://trcat.github.io/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%8A%80%E6%9C%AF/"}],"tags":[{"name":"搬运","slug":"搬运","permalink":"https://trcat.github.io/tags/%E6%90%AC%E8%BF%90/"},{"name":"javascript","slug":"javascript","permalink":"https://trcat.github.io/tags/javascript/"},{"name":"html","slug":"html","permalink":"https://trcat.github.io/tags/html/"},{"name":"svg","slug":"svg","permalink":"https://trcat.github.io/tags/svg/"},{"name":"canvas","slug":"canvas","permalink":"https://trcat.github.io/tags/canvas/"}]},{"title":"对闭包的理解","date":"2020-03-03T13:52:59.000Z","path":"2020/03/03/对闭包的理解/","permalink":"https://trcat.github.io/2020/03/03/%E5%AF%B9%E9%97%AD%E5%8C%85%E7%9A%84%E7%90%86%E8%A7%A3/","categories":[{"name":"计算机技术","slug":"计算机技术","permalink":"https://trcat.github.io/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%8A%80%E6%9C%AF/"}],"tags":[{"name":"搬运","slug":"搬运","permalink":"https://trcat.github.io/tags/%E6%90%AC%E8%BF%90/"},{"name":"javascript","slug":"javascript","permalink":"https://trcat.github.io/tags/javascript/"}]},{"title":"JavaScript 原型链和 ES6 的 Class 的区别","date":"2020-03-03T13:39:27.000Z","path":"2020/03/03/JavaScript-原型链和-ES6-的-Class-的区别/","permalink":"https://trcat.github.io/2020/03/03/JavaScript-%E5%8E%9F%E5%9E%8B%E9%93%BE%E5%92%8C-ES6-%E7%9A%84-Class-%E7%9A%84%E5%8C%BA%E5%88%AB/","categories":[{"name":"计算机技术","slug":"计算机技术","permalink":"https://trcat.github.io/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%8A%80%E6%9C%AF/"}],"tags":[{"name":"搬运","slug":"搬运","permalink":"https://trcat.github.io/tags/%E6%90%AC%E8%BF%90/"},{"name":"javascript","slug":"javascript","permalink":"https://trcat.github.io/tags/javascript/"},{"name":"es6","slug":"es6","permalink":"https://trcat.github.io/tags/es6/"}]},{"title":"对跨域的相关知识","date":"2020-03-03T13:37:09.000Z","path":"2020/03/03/对跨域的相关知识/","permalink":"https://trcat.github.io/2020/03/03/%E5%AF%B9%E8%B7%A8%E5%9F%9F%E7%9A%84%E7%9B%B8%E5%85%B3%E7%9F%A5%E8%AF%86/","categories":[{"name":"计算机技术","slug":"计算机技术","permalink":"https://trcat.github.io/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%8A%80%E6%9C%AF/"}],"tags":[{"name":"搬运","slug":"搬运","permalink":"https://trcat.github.io/tags/%E6%90%AC%E8%BF%90/"}]},{"title":"vue 中 v-if 和 v-show 的区别","date":"2020-03-03T13:28:27.000Z","path":"2020/03/03/vue-中-v-if-和-v-show-的区别/","permalink":"https://trcat.github.io/2020/03/03/vue-%E4%B8%AD-v-if-%E5%92%8C-v-show-%E7%9A%84%E5%8C%BA%E5%88%AB/","categories":[{"name":"计算机技术","slug":"计算机技术","permalink":"https://trcat.github.io/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%8A%80%E6%9C%AF/"}],"tags":[{"name":"搬运","slug":"搬运","permalink":"https://trcat.github.io/tags/%E6%90%AC%E8%BF%90/"},{"name":"vue","slug":"vue","permalink":"https://trcat.github.io/tags/vue/"}]},{"title":"欢迎来到我的博客","date":"2020-02-29T06:40:33.000Z","path":"2020/02/29/欢迎来到我的博客/","permalink":"https://trcat.github.io/2020/02/29/%E6%AC%A2%E8%BF%8E%E6%9D%A5%E5%88%B0%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/","categories":[{"name":"闲谈","slug":"闲谈","permalink":"https://trcat.github.io/categories/%E9%97%B2%E8%B0%88/"},{"name":"置顶","slug":"置顶","permalink":"https://trcat.github.io/categories/%E7%BD%AE%E9%A1%B6/"}],"tags":[{"name":"欢迎","slug":"欢迎","permalink":"https://trcat.github.io/tags/%E6%AC%A2%E8%BF%8E/"}]},{"title":"使用git让本地项目和远程空项目关联","date":"2020-02-29T03:59:47.000Z","path":"2020/02/29/git-本地项目和远程空项目关联/","permalink":"https://trcat.github.io/2020/02/29/git-%E6%9C%AC%E5%9C%B0%E9%A1%B9%E7%9B%AE%E5%92%8C%E8%BF%9C%E7%A8%8B%E7%A9%BA%E9%A1%B9%E7%9B%AE%E5%85%B3%E8%81%94/","categories":[{"name":"计算机技术","slug":"计算机技术","permalink":"https://trcat.github.io/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%8A%80%E6%9C%AF/"}],"tags":[{"name":"Git","slug":"Git","permalink":"https://trcat.github.io/tags/Git/"},{"name":"搬运","slug":"搬运","permalink":"https://trcat.github.io/tags/%E6%90%AC%E8%BF%90/"}]}],"categories":[{"name":"计算机技术","slug":"计算机技术","permalink":"https://trcat.github.io/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%8A%80%E6%9C%AF/"},{"name":"手机应用","slug":"手机应用","permalink":"https://trcat.github.io/categories/%E6%89%8B%E6%9C%BA%E5%BA%94%E7%94%A8/"},{"name":"闲谈","slug":"闲谈","permalink":"https://trcat.github.io/categories/%E9%97%B2%E8%B0%88/"},{"name":"置顶","slug":"置顶","permalink":"https://trcat.github.io/categories/%E7%BD%AE%E9%A1%B6/"}],"tags":[{"name":"前端","slug":"前端","permalink":"https://trcat.github.io/tags/%E5%89%8D%E7%AB%AF/"},{"name":"工具","slug":"工具","permalink":"https://trcat.github.io/tags/%E5%B7%A5%E5%85%B7/"},{"name":"css","slug":"css","permalink":"https://trcat.github.io/tags/css/"},{"name":"echarts","slug":"echarts","permalink":"https://trcat.github.io/tags/echarts/"},{"name":"SVG","slug":"SVG","permalink":"https://trcat.github.io/tags/SVG/"},{"name":"WebFont","slug":"WebFont","permalink":"https://trcat.github.io/tags/WebFont/"},{"name":"javascript","slug":"javascript","permalink":"https://trcat.github.io/tags/javascript/"},{"name":"html","slug":"html","permalink":"https://trcat.github.io/tags/html/"},{"name":"转载","slug":"转载","permalink":"https://trcat.github.io/tags/%E8%BD%AC%E8%BD%BD/"},{"name":"Git","slug":"Git","permalink":"https://trcat.github.io/tags/Git/"},{"name":"搬运","slug":"搬运","permalink":"https://trcat.github.io/tags/%E6%90%AC%E8%BF%90/"},{"name":"Apple Music","slug":"Apple-Music","permalink":"https://trcat.github.io/tags/Apple-Music/"},{"name":"iPhone","slug":"iPhone","permalink":"https://trcat.github.io/tags/iPhone/"},{"name":"react-native","slug":"react-native","permalink":"https://trcat.github.io/tags/react-native/"},{"name":"react","slug":"react","permalink":"https://trcat.github.io/tags/react/"},{"name":"jquery","slug":"jquery","permalink":"https://trcat.github.io/tags/jquery/"},{"name":"svg","slug":"svg","permalink":"https://trcat.github.io/tags/svg/"},{"name":"canvas","slug":"canvas","permalink":"https://trcat.github.io/tags/canvas/"},{"name":"es6","slug":"es6","permalink":"https://trcat.github.io/tags/es6/"},{"name":"vue","slug":"vue","permalink":"https://trcat.github.io/tags/vue/"},{"name":"欢迎","slug":"欢迎","permalink":"https://trcat.github.io/tags/%E6%AC%A2%E8%BF%8E/"}]} \ No newline at end of file diff --git a/css/mobile.css b/css/mobile.css new file mode 100644 index 0000000..87c32bf --- /dev/null +++ b/css/mobile.css @@ -0,0 +1 @@ +@font-face{font-family:'iconfont-archer';src:url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.eot");src:url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.eot?#iefix") format("embedded-opentype"),url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.woff") format("woff"),url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.ttf") format("truetype"),url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.svg#iconfont-archer") format("svg")}.iconfont-archer{font-family:'iconfont-archer' !important;font-size:1rem;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.container{flex-direction:column-reverse;margin:0 auto;width:100%;padding:1rem 0 0 0;align-items:center}.profile{margin:1rem auto}.profile .profile-avatar{width:60%;margin:0 auto}.profile .profile-social{display:none}.toc-wrapper{display:none}.footer{padding-top:0}.post-page{padding-bottom:0}.main{width:92%;min-width:0;margin:0}*{-webkit-tap-highlight-color:transparent}.home-body .site-intro-meta{width:100%}.home-body .intro-title{font-size:3rem;line-height:2.8rem}.home-body .intro-subtitle{font-size:1.5rem;white-space:normal;max-width:90%}.about-body .site-intro-meta,.post-body .site-intro-meta{min-width:0;width:80%}.about-body .intro-title,.post-body .intro-title{font-size:2.6rem;line-height:2.8rem}.about-body .intro-subtitle,.post-body .intro-subtitle{font-size:1.5rem;white-space:normal;max-width:90%}.about-body .main,.post-body .main{width:86%}.blog-title{display:none}.home-link{right:1rem}.post-paginator .previous,.post-paginator .next{float:none;margin:0 auto}.article-entry blockquote{margin:0.8rem 0}.sidebar{width:300px}.wrapper-sidebar-active{transform:translate3d(300px, 0, 0)}.header-sidebar-active{transform:translate3d(300px, 0, 0)}.tab-name{font-size:1.2rem}.sidebar-archive{-webkit-overflow-scrolling:touch}.archive-year,.total-archive{font-size:1.4rem}.sidebar-tags{-webkit-overflow-scrolling:touch}.footer{margin-top:0}.footer .social .iconfont-archer{display:inline-block;text-align:center}.footer .social .iconfont-archer::before{display:inline-block;color:#777;font-size:1.5rem;margin:0 .2rem 0 0}.footer .social .iconfont-archer:last-of-child::before{margin:0}.footer .social .email{top:1.5px}.footer .social .email::before{content:'\e642'}.footer .social .email:hover::before{color:#0cb49d}.footer .social .github::before{font-size:1.6rem;content:'\e69f'}.footer .social .github:hover::before{color:#24292e}.footer .social .wechat{top:2px}.footer .social .wechat::before{font-size:1.4rem;content:'\ec7d'}.footer .social .wechat:hover::before{color:#42ae3c}.footer .social .qq{top:2px}.footer .social .qq::before{font-size:1.4rem;content:'\e61d'}.footer .social .qq:hover::before{color:#4f4e71}.footer .social .telegram{top:2px}.footer .social .telegram::before{font-size:1.3rem;content:'\e731'}.footer .social .telegram:hover::before{color:#36a1d3}.footer .social .weibo::before{font-size:1.6rem;content:'\e619'}.footer .social .weibo:hover::before{color:#d52a2a}.footer .social .zhihu{top:1.5px}.footer .social .zhihu::before{font-size:1.35rem;content:'\e61a'}.footer .social .zhihu:hover::before{color:#0f88eb}.footer .social .douban{top:1px}.footer .social .douban::before{font-size:1.25rem;content:'\e605'}.footer .social .douban:hover::before{color:#007711}.footer .social .facebook{top:2px}.footer .social .facebook::before{font-size:1.5rem;content:'\e67a'}.footer .social .facebook:hover::before{color:#3b5998}.footer .social .twitter::before{content:'\e634'}.footer .social .twitter:hover::before{color:#1da1f2}.footer .social .instagram{top:1px}.footer .social .instagram::before{content:'\e79d';font-size:1.4rem}.footer .social .instagram:hover::before{color:#8042b6}.footer .social .stack-overflow::before{font-size:1.15rem;content:'\e80b'}.footer .social .stack-overflow:hover::before{color:#f37f23}.footer .social .segmentFault{top:1.5px}.footer .social .segmentFault::before{font-size:1.5rem;content:'\e60c'}.footer .social .segmentFault:hover::before{color:#f37f23}.footer .social .juejin::before{font-size:1.35rem;content:'\e60b'}.footer .social .juejin:hover::before{color:#f37f23}.footer .social .v2ex::before{font-size:1.1rem;content:'\e663'}.footer .social .v2ex:hover::before{color:#171718}.footer .social .bilibili{top:2px}.footer .social .bilibili::before{font-size:1.75rem;content:'\e64e'}.footer .social .bilibili:hover::before{color:#2cb2f9}.footer .social .linkedin{top:-.5px}.footer .social .linkedin::before{font-size:1.25rem;content:'\e695'}.footer .social .linkedin:hover::before{color:#0077b5}.footer .social .steam{top:-.5px}.footer .social .steam::before{font-size:1.25rem;content:'\f23b'}.footer .social .steam:hover::before{color:#010101}.footer .social .others{top:-.5px}.footer .social .others::before{font-size:1.1rem;content:'\e64a'}.footer .social .others:hover::before{color:#8090b0}.footer .social .rss::before{font-size:1.05rem;content:'\e652'}.footer .social .rss:hover::before{color:#e53935}.footer .copyright{margin:0.5rem auto 0.5rem auto}#busuanzi_container_site_pv,#busuanzi_container_site_uv{font:1rem "Oswald-Regular"} diff --git a/css/style.css b/css/style.css new file mode 100644 index 0000000..17cdb22 --- /dev/null +++ b/css/style.css @@ -0,0 +1 @@ +@font-face{font-family:'iconfont-archer';src:url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.eot");src:url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.eot?#iefix") format("embedded-opentype"),url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.woff") format("woff"),url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.ttf") format("truetype"),url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.svg#iconfont-archer") format("svg")}.iconfont-archer{font-family:'iconfont-archer' !important;font-size:1rem;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}/*! normalize.css v3.0.2 | MIT License | git.io/normalize */html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:0.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace, monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type='checkbox'],input[type='radio']{box-sizing:border-box;padding:0}input[type='number']::-webkit-inner-spin-button,input[type='number']::-webkit-outer-spin-button{height:auto}input[type='searcher']{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type='searcher']::-webkit-searcher-cancel-button,input[type='searcher']::-webkit-searcher-decoration{-webkit-appearance:none}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:bold}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}html{font-size:16px;font-family:-apple-system,BlinkMacSystemFont,"Helvetica Neue",Arial,"PingFang SC","Hiragino Sans GB",STHeiti,"Microsoft YaHei","Microsoft JhengHei","Source Han Sans SC","Noto Sans CJK SC","Source Han Sans CN","Noto Sans SC","Source Han Sans TC","Noto Sans CJK TC","WenQuanYi Micro Hei",SimSun,sans-serif;overflow-x:hidden}*{font-family:inherit}body{z-index:100;position:relative;background-color:#fff;overflow-x:hidden}.wrapper{z-index:1;display:flex;flex-direction:column;width:100%;min-height:100vh;transition:all 0.3s ease-in 0s;transform:translate3d(0, 0, 0);position:relative;box-shadow:-3px 0 2px 0 rgba(0,0,0,0.6)}.wrapper-sidebar-active{transform:translate3d(400px, 0, 0)}.main{order:1;width:50%;min-width:42.8125rem;flex-grow:0;padding:0 0 0 0;margin-left:3rem}.container{display:flex;padding:3rem 0 0 0;position:relative;background-color:#fff;top:0;left:0;align-items:flex-start;justify-content:center;width:100%;overflow:hidden;transition:all 0.5s ease-out 0s;opacity:1;transform:translate3d(0, 0, 0)}.container-unloaded{opacity:0;transform:translate3d(0, 1rem, 0)}a{text-decoration:none}ul,li{list-style-type:none}.back-top{position:fixed;display:block;left:1rem;bottom:1rem;z-index:10;opacity:0;width:1.5rem;height:1.5rem;text-align:center;line-height:1.5rem;border:2px solid #000;background-color:rgba(255,255,255,0.8);cursor:pointer}.back-top:hover{background-color:#000;color:#fff}.back-top-show{opacity:1;pointer-events:initial}::selection{background:#f75357;color:#eee}::-moz-selection{background:#f75357;color:#eee}::-webkit-selection{background:#f75357;color:#eee}.fancy-link{padding:0 !important;margin:0 !important}.site-intro-img{position:absolute;z-index:-1;top:0;left:0;height:calc(100% + 1px);width:100%;filter:brightness(0.5);-webkit-filter:brightness(0.5);-moz-filter:brightness(0.5);background-repeat:no-repeat;background-position:center center;background-size:cover;background-color:transparent}.site-intro-meta{width:100%;height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center}.intro-title,.intro-subtitle{font-family:"Oswald-Regular";color:#fff;margin:0;opacity:0;transition:all 0.5s ease-out 0s;transform:translate(0, -1rem)}.intro-title{font-size:4rem}.intro-subtitle{font-size:2rem;transition-delay:0.5s}.intro-fade-in{opacity:1;transform:translate(0, 0)}.header{position:fixed;top:0;width:100%;height:3.5rem;overflow:hidden;z-index:10;transform:translate3d(0, 0, 0);transition:transform 0.3s ease-in 0s}.header-sidebar-active{transform:translate3d(400px, 0, 0)}.read-progress{width:100%;position:absolute;top:0;left:0;height:3px;background-color:rgba(0,0,0,0.7);transition:transform 0.1s ease-out 0s;transform:translate3d(-100%, 0, 0);z-index:99999}.banner{position:relative;width:100%;margin:0 auto;height:calc(100% - 1px);border-bottom:1px solid rgba(0,0,0,0.8);background-color:rgba(255,255,255,0.8);transform:translate3d(0, -100%, 0);transition:transform 0.3s ease-out 0s}.banner-show{transform:translate3d(0, 0, 0)}.post-title{display:flex;justify-content:center;align-items:center;height:100%;width:70%;margin-left:15%}.post-title a{white-space:nowrap;color:rgba(0,0,0,0.8);line-height:100%;max-width:100%;text-overflow:ellipsis;overflow:hidden;padding-bottom:0.2rem;text-align:center;font-size:1.5rem}.blog-title{display:flex;position:absolute;right:2.5rem;top:50%;transform:translate(0, -50%);justify-content:center;align-items:center;height:100%}.blog-title a{vertical-align:top;white-space:nowrap;color:#000;font:1rem/1rem "Oswald-Regular"}.blog-title a:hover{color:#f75357}.header-sidebar-menu{position:absolute;left:1rem;top:50%;border:2px solid #fff;width:1.5rem;height:1.5rem;transform:translate(0, -50%);transition:transform 0.3s ease;font-family:'iconfont-archer';color:#fff;text-align:center;line-height:1.5rem;z-index:21;cursor:pointer}.header-sidebar-menu:hover{background-color:#fff;color:#000;transform:translate(0, -50%)}.header-sidebar-menu-active{transform:translate(0, -50%) rotate(180deg) !important;transition:transform 0.3s ease}.header-sidebar-menu-black{color:#000;background-color:#fff;border-color:#000}.header-sidebar-menu-black:hover{background-color:#000;color:#fff}.home-link{position:absolute;right:2.5rem;top:50%;transform:translate(0, -50%);font-family:"Oswald-Regular";color:#fff;cursor:pointer}.home-link:hover{color:#f75357}.home-link-hide{display:none}.profile{order:0;vertical-align:top;flex-shrink:0;margin:4px 0 0 0;width:200px;font:1rem "Oswald-Regular";border-bottom:1px solid rgba(0,0,0,0.1);padding-bottom:0.5rem}.profile *{color:#777}.profile>*:last-child{border-bottom:none;padding-bottom:0}.profile-avatar{display:block;border-radius:1rem;width:100%;box-shadow:0 0 2px 0 rgba(0,0,0,0.6)}.profile-name{font-size:2rem;line-height:3rem;padding:0.5rem 0 0 0;color:#333;text-align:center}.profile-signature{font-size:1rem;text-align:center}.profile-social{position:relative;width:100%;text-align:left;line-height:1.7rem;padding:0.5rem 0;border-bottom:1px solid rgba(0,0,0,0.1)}.profile-social .iconfont-archer{position:relative}.profile-social .iconfont-archer{display:inline-block;text-align:center}.profile-social .iconfont-archer::before{display:inline-block;color:#777;font-size:1.5rem;margin:0 .4rem 0 0}.profile-social .iconfont-archer:last-of-child::before{margin:0}.profile-social .email{top:1.5px}.profile-social .email::before{content:'\e642'}.profile-social .email:hover::before{color:#0cb49d}.profile-social .github::before{font-size:1.6rem;content:'\e69f'}.profile-social .github:hover::before{color:#24292e}.profile-social .wechat{top:2px}.profile-social .wechat::before{font-size:1.4rem;content:'\ec7d'}.profile-social .wechat:hover::before{color:#42ae3c}.profile-social .qq{top:2px}.profile-social .qq::before{font-size:1.4rem;content:'\e61d'}.profile-social .qq:hover::before{color:#4f4e71}.profile-social .telegram{top:2px}.profile-social .telegram::before{font-size:1.3rem;content:'\e731'}.profile-social .telegram:hover::before{color:#36a1d3}.profile-social .weibo::before{font-size:1.6rem;content:'\e619'}.profile-social .weibo:hover::before{color:#d52a2a}.profile-social .zhihu{top:1.5px}.profile-social .zhihu::before{font-size:1.35rem;content:'\e61a'}.profile-social .zhihu:hover::before{color:#0f88eb}.profile-social .douban{top:1px}.profile-social .douban::before{font-size:1.25rem;content:'\e605'}.profile-social .douban:hover::before{color:#007711}.profile-social .facebook{top:2px}.profile-social .facebook::before{font-size:1.5rem;content:'\e67a'}.profile-social .facebook:hover::before{color:#3b5998}.profile-social .twitter::before{content:'\e634'}.profile-social .twitter:hover::before{color:#1da1f2}.profile-social .instagram{top:1px}.profile-social .instagram::before{content:'\e79d';font-size:1.4rem}.profile-social .instagram:hover::before{color:#8042b6}.profile-social .stack-overflow::before{font-size:1.15rem;content:'\e80b'}.profile-social .stack-overflow:hover::before{color:#f37f23}.profile-social .segmentFault{top:1.5px}.profile-social .segmentFault::before{font-size:1.5rem;content:'\e60c'}.profile-social .segmentFault:hover::before{color:#f37f23}.profile-social .juejin::before{font-size:1.35rem;content:'\e60b'}.profile-social .juejin:hover::before{color:#f37f23}.profile-social .v2ex::before{font-size:1.1rem;content:'\e663'}.profile-social .v2ex:hover::before{color:#171718}.profile-social .bilibili{top:2px}.profile-social .bilibili::before{font-size:1.75rem;content:'\e64e'}.profile-social .bilibili:hover::before{color:#2cb2f9}.profile-social .linkedin{top:-.5px}.profile-social .linkedin::before{font-size:1.25rem;content:'\e695'}.profile-social .linkedin:hover::before{color:#0077b5}.profile-social .steam{top:-.5px}.profile-social .steam::before{font-size:1.25rem;content:'\f23b'}.profile-social .steam:hover::before{color:#010101}.profile-social .others{top:-.5px}.profile-social .others::before{font-size:1.1rem;content:'\e64a'}.profile-social .others:hover::before{color:#8090b0}.profile-social .rss::before{font-size:1.05rem;content:'\e652'}.profile-social .rss:hover::before{color:#e53935}.wechat,.qq{cursor:pointer}.wechat:hover .profile-qr,.qq:hover .profile-qr{opacity:1;visibility:visible}.profile-qr{visibility:hidden;position:absolute;left:0;bottom:2.5rem;border:3px solid #fff;border-radius:3px;z-index:99;background-color:#fff;width:7rem;opacity:0;transition:all 0.1s ease-in 0s}.friends{padding:0.5rem 0;border-bottom:1px solid rgba(0,0,0,0.1);text-align:left}.friends div{font-size:1.2rem;text-align:left;font-weight:bold}.friends a{margin-right:0.6rem}.about-me{padding:0.5rem 0;border-bottom:1px solid rgba(0,0,0,0.1)}.about-me a{font-size:1.2rem;font-weight:bold}.footer{flex-grow:1;display:flex;flex-direction:column;justify-content:flex-end;padding:2.5rem 0 1.5rem 0;background-color:#fff}.social{text-align:center;vertical-align:text-bottom}.social .iconfont-archer{position:relative}.social .iconfont-archer{display:inline-block;text-align:center}.social .iconfont-archer::before{display:inline-block;color:#777;font-size:2.4rem;margin:0 .5rem 0 0}.social .iconfont-archer:last-of-child::before{margin:0}.social .email{top:2.4px}.social .email::before{content:'\e642'}.social .email:hover::before{color:#0cb49d}.social .github::before{font-size:2.56rem;content:'\e69f'}.social .github:hover::before{color:#24292e}.social .wechat{top:3.2px}.social .wechat::before{font-size:2.24rem;content:'\ec7d'}.social .wechat:hover::before{color:#42ae3c}.social .qq{top:3.2px}.social .qq::before{font-size:2.24rem;content:'\e61d'}.social .qq:hover::before{color:#4f4e71}.social .telegram{top:3.2px}.social .telegram::before{font-size:2.08rem;content:'\e731'}.social .telegram:hover::before{color:#36a1d3}.social .weibo::before{font-size:2.56rem;content:'\e619'}.social .weibo:hover::before{color:#d52a2a}.social .zhihu{top:2.4px}.social .zhihu::before{font-size:2.16rem;content:'\e61a'}.social .zhihu:hover::before{color:#0f88eb}.social .douban{top:1.6px}.social .douban::before{font-size:2rem;content:'\e605'}.social .douban:hover::before{color:#007711}.social .facebook{top:3.2px}.social .facebook::before{font-size:2.4rem;content:'\e67a'}.social .facebook:hover::before{color:#3b5998}.social .twitter::before{content:'\e634'}.social .twitter:hover::before{color:#1da1f2}.social .instagram{top:1.6px}.social .instagram::before{content:'\e79d';font-size:2.24rem}.social .instagram:hover::before{color:#8042b6}.social .stack-overflow::before{font-size:1.84rem;content:'\e80b'}.social .stack-overflow:hover::before{color:#f37f23}.social .segmentFault{top:2.4px}.social .segmentFault::before{font-size:2.4rem;content:'\e60c'}.social .segmentFault:hover::before{color:#f37f23}.social .juejin::before{font-size:2.16rem;content:'\e60b'}.social .juejin:hover::before{color:#f37f23}.social .v2ex::before{font-size:1.76rem;content:'\e663'}.social .v2ex:hover::before{color:#171718}.social .bilibili{top:3.2px}.social .bilibili::before{font-size:2.8rem;content:'\e64e'}.social .bilibili:hover::before{color:#2cb2f9}.social .linkedin{top:-.8px}.social .linkedin::before{font-size:2rem;content:'\e695'}.social .linkedin:hover::before{color:#0077b5}.social .steam{top:-.8px}.social .steam::before{font-size:2rem;content:'\f23b'}.social .steam:hover::before{color:#010101}.social .others{top:-.8px}.social .others::before{font-size:1.76rem;content:'\e64a'}.social .others:hover::before{color:#8090b0}.social .rss::before{font-size:1.68rem;content:'\e652'}.social .rss:hover::before{color:#e53935}.copyright{font-family:"Oswald-Regular";margin:0.5rem auto;text-align:center;color:#777}.copyright a{color:#f75357}.power{position:relative;vertical-align:baseline;font-size:1rem;padding:0 0.2rem}.busuanzi-container{text-align:center}#busuanzi_container_site_pv,#busuanzi_container_site_uv{display:block;text-align:center;font:0.6rem "Oswald-Regular";color:#ddd}.page-nav{padding:1rem 0 0.5rem 0;display:flex;justify-content:center}.page-nav>*{font:1.4rem "Oswald-Regular";color:#252525;vertical-align:middle;margin-right:0.5rem;text-align:center}.page-nav a{position:relative;color:#ccc;overflow:visible}.page-nav a::after{content:'';position:absolute;left:calc((100% - 98%) / 2);bottom:-15%;transition:all 0.15s ease-in;width:98%;height:2px;transform:translate(0, 0);background-color:#ccc;opacity:0}.page-nav a:hover::after{transform:translate(0, -2px);opacity:1}@font-face{font-family:'iconfont-archer';src:url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.eot");src:url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.eot?#iefix") format("embedded-opentype"),url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.woff") format("woff"),url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.ttf") format("truetype"),url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.svg#iconfont-archer") format("svg")}.iconfont-archer{font-family:'iconfont-archer' !important;font-size:1rem;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.popup{display:none;position:fixed;top:10%;left:50%;width:700px;height:80%;margin-left:-350px;padding:3px 0 0 10px;background:#fff;color:#333;z-index:9999;box-shadow:0px 0px 10px rgba(0,0,0,0.5);border-radius:5px}@media (max-width: 767px){.popup{padding:3px;top:0;left:0;margin:0;width:100%;height:100%;border-radius:0px}}.popoverlay{position:fixed;width:100%;height:100%;top:0px;left:0px;z-index:2080;background-color:rgba(0,0,0,0.3)}.popup-btn-close{position:absolute;top:6px;right:14px;color:#f75357;cursor:pointer}.popup-btn-close .iconfont-archer{font-size:20px}.algolia-popup{overflow:hidden;padding:0}.algolia-popup .popup-btn-close{padding-left:15px;border-left:1px solid #eee;top:10px}.algolia-popup .popup-btn-close .fa{color:#999;font-size:18px}.algolia-popup .popup-btn-close:hover .fa{color:#222}.algolia-search{padding:10px 15px 5px;max-height:50px;border-bottom:1px solid #ccc;background:#f5f5f5;border-top-left-radius:5px;border-top-right-radius:5px}.algolia-search-input-icon{display:inline-block;width:20px}.algolia-search-input-icon .fa{font-size:18px}.algolia-search-input{display:inline-block;width:calc(90% - 20px)}.algolia-search-input input{padding:5px 0;width:100%;outline:none;border:none;background:transparent}.algolia-powered{float:right}.algolia-powered img{display:inline-block;height:18px;vertical-align:middle}.algolia-results{position:relative;overflow:auto;padding:10px 30px;height:calc(100% - 50px)}.algolia-results hr{margin:10px 0}.algolia-results .highlight{font-style:normal;margin:0;padding:0 2px;font-size:inherit;color:#f00}.algolia-hits{margin-top:20px}.algolia-hit-item{margin:15px 0}.algolia-hit-item-link{color:#555;padding:0 0 2px 0;display:block;border-bottom:1px dashed #ccc;transition-duration:0.2s;transition-timing-function:ease-in-out;transition-delay:0s}.algolia-hit-item-link em{font-style:normal;color:#f75357}.ais-search-box--reset-wrapper,.ais-search-box--magnifier-wrapper{display:none !important}.ais-pagination{display:flex;justify-content:center;padding:0;margin:40px 0 0 0;border-top:none}.ais-pagination--item{display:inline-block;margin:0 5px}.ais-pagination--item a{color:#f75357}.ais-pagination--item__active a{pointer-events:none;cursor:auto;color:#222}.ais-pagination--item__page{border-top:none}.ais-pagination--item__page:hover{border-bottom:1px solid #222}.algolia-pagination .disabled-item{visibility:hidden}html::-webkit-scrollbar,.sidebar-panel-archives::-webkit-scrollbar,.sidebar-tags-list::-webkit-scrollbar,.sidebar-categories-list::-webkit-scrollbar,.highlight::-webkit-scrollbar{background-color:rgba(0,0,0,0.5);width:5px}html::-webkit-scrollbar-corner,.sidebar-panel-archives::-webkit-scrollbar-corner,.sidebar-tags-list::-webkit-scrollbar-corner,.sidebar-categories-list::-webkit-scrollbar-corner,.highlight::-webkit-scrollbar-corner{display:none}html::-webkit-scrollbar-button,.sidebar-panel-archives::-webkit-scrollbar-button,.sidebar-tags-list::-webkit-scrollbar-button,.sidebar-categories-list::-webkit-scrollbar-button,.highlight::-webkit-scrollbar-button{display:none}html::-webkit-scrollbar-button:start:increment,html::-webkit-scrollbar-button:end:decrement,.sidebar-panel-archives::-webkit-scrollbar-button:start:increment,.sidebar-panel-archives::-webkit-scrollbar-button:end:decrement,.sidebar-tags-list::-webkit-scrollbar-button:start:increment,.sidebar-tags-list::-webkit-scrollbar-button:end:decrement,.sidebar-categories-list::-webkit-scrollbar-button:start:increment,.sidebar-categories-list::-webkit-scrollbar-button:end:decrement,.highlight::-webkit-scrollbar-button:start:increment,.highlight::-webkit-scrollbar-button:end:decrement{display:none}html::-webkit-scrollbar-thumb,.sidebar-panel-archives::-webkit-scrollbar-thumb,.sidebar-tags-list::-webkit-scrollbar-thumb,.sidebar-categories-list::-webkit-scrollbar-thumb,.highlight::-webkit-scrollbar-thumb{border-radius:8px;background-color:rgba(0,0,0,0.2)}html::-webkit-scrollbar-track,html::-webkit-scrollbar-thumb,.sidebar-panel-archives::-webkit-scrollbar-track,.sidebar-panel-archives::-webkit-scrollbar-thumb,.sidebar-tags-list::-webkit-scrollbar-track,.sidebar-tags-list::-webkit-scrollbar-thumb,.sidebar-categories-list::-webkit-scrollbar-track,.sidebar-categories-list::-webkit-scrollbar-thumb,.highlight::-webkit-scrollbar-track,.highlight::-webkit-scrollbar-thumb{border:none}html::-webkit-scrollbar-thumb,.sidebar-panel-archives::-webkit-scrollbar-thumb,.sidebar-tags-list::-webkit-scrollbar-thumb,.sidebar-categories-list::-webkit-scrollbar-thumb,.highlight::-webkit-scrollbar-thumb{background-color:rgba(255,255,255,0.2);border-radius:0px}html::-webkit-scrollbar-track:hover,.sidebar-panel-archives::-webkit-scrollbar-track:hover,.sidebar-tags-list::-webkit-scrollbar-track:hover,.sidebar-categories-list::-webkit-scrollbar-track:hover,.highlight::-webkit-scrollbar-track:hover{background-color:rgba(0,0,0,0.1)}.sidebar-archive::-webkit-scrollbar-thumb,.sidebar-tags-list::-webkit-scrollbar-thumb,.sidebar-categories-list::-webkit-scrollbar-thumb{border-radius:8px;background-color:rgba(255,255,255,0.7)}.sidebar-archive::-webkit-scrollbar-thumb,.sidebar-tags-list::-webkit-scrollbar-thumb,.sidebar-categories-list::-webkit-scrollbar-thumb{background-color:rgba(255,255,255,0.7);border-radius:0px}.sidebar-archive::-webkit-scrollbar-track:hover,.sidebar-tags-list::-webkit-scrollbar-track:hover,.sidebar-categories-list::-webkit-scrollbar-track:hover{background-color:rgba(255,255,255,0.7)}.highlight::-webkit-scrollbar{height:5px}.highlight::-webkit-scrollbar-thumb{border-radius:8px;background-color:rgba(255,255,255,0.3)}.highlight::-webkit-scrollbar-thumb{background-color:rgba(255,255,255,0.3);border-radius:0px}.highlight::-webkit-scrollbar-track:hover{background-color:rgba(255,255,255,0.3)}@font-face{font-family:'iconfont-archer';src:url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.eot");src:url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.eot?#iefix") format("embedded-opentype"),url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.woff") format("woff"),url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.ttf") format("truetype"),url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.svg#iconfont-archer") format("svg")}.iconfont-archer{font-family:'iconfont-archer' !important;font-size:1rem;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.abstract-content pre,.abstract-content .highlight,.article-entry pre,.article-entry .highlight{margin:0.8rem 0;padding:0.7rem 0.7rem;overflow:auto;font-size:0.9rem;line-height:1.3rem}.abstract-content .highlight .gutter pre,.abstract-content .highlight .gutter pre .line,.abstract-content .gist .gist-file .gist-data .line-numbers,.article-entry .highlight .gutter pre,.article-entry .highlight .gutter pre .line,.article-entry .gist .gist-file .gist-data .line-numbers{color:#666}.abstract-content pre,.abstract-content code,.article-entry pre,.article-entry code{font-family:'Source Code Pro', Consolas, Menlo, Monaco, 'Courier New', monospace;font-weight:400}.abstract-content code,.article-entry code{background:#eee;padding:1px 0.4rem;border-radius:2px;margin:0 0.2rem;border:none}.abstract-content pre code,.article-entry pre code{background:none;text-shadow:none;padding:0;color:#657b83}.abstract-content .highlight,.article-entry .highlight{border-radius:4px}.abstract-content .highlight pre,.article-entry .highlight pre{border:none;margin:0;padding:0}.abstract-content .highlight table,.article-entry .highlight table{margin:0;width:auto}.abstract-content .highlight td,.article-entry .highlight td{border:none;padding:0}.abstract-content .highlight figcaption,.article-entry .highlight figcaption{color:highlight-comment;line-height:1em;margin-bottom:1em}.abstract-content .highlight figcaption:before,.abstract-content .highlight figcaption:after,.article-entry .highlight figcaption:before,.article-entry .highlight figcaption:after{content:'';display:table}.abstract-content .highlight figcaption:after,.article-entry .highlight figcaption:after{clear:both}.abstract-content .highlight figcaption a,.article-entry .highlight figcaption a{float:right}.abstract-content .highlight .gutter pre,.article-entry .highlight .gutter pre{text-align:right;padding-right:20px}.abstract-content .highlight .gutter pre .line,.article-entry .highlight .gutter pre .line{text-shadow:none}.abstract-content .highlight .line,.article-entry .highlight .line{min-height:19px}.abstract-content .highlight,.abstract-content pre,.article-entry .highlight,.article-entry pre{color:#abb2bf;background:#282c34}.abstract-content .highlight pre .comment,.abstract-content .highlight pre .quote,.article-entry .highlight pre .comment,.article-entry .highlight pre .quote{color:#5c6370;font-style:italic}.abstract-content .highlight pre .doctag,.abstract-content .highlight pre .keyword,.abstract-content .highlight pre .formula,.article-entry .highlight pre .doctag,.article-entry .highlight pre .keyword,.article-entry .highlight pre .formula{color:#c678dd}.abstract-content .highlight pre .section,.abstract-content .highlight pre .name,.abstract-content .highlight pre .selector-tag,.abstract-content .highlight pre .deletion,.abstract-content .highlight pre .subst,.article-entry .highlight pre .section,.article-entry .highlight pre .name,.article-entry .highlight pre .selector-tag,.article-entry .highlight pre .deletion,.article-entry .highlight pre .subst{color:#e06c75}.abstract-content .highlight pre .literal,.article-entry .highlight pre .literal{color:#56b6c2}.abstract-content .highlight pre .string,.abstract-content .highlight pre .regexp,.abstract-content .highlight pre .addition,.abstract-content .highlight pre .attribute,.abstract-content .highlight pre .meta-string,.article-entry .highlight pre .string,.article-entry .highlight pre .regexp,.article-entry .highlight pre .addition,.article-entry .highlight pre .attribute,.article-entry .highlight pre .meta-string{color:#98c379}.abstract-content .highlight pre .built_in,.abstract-content .highlight pre .class pre .title,.article-entry .highlight pre .built_in,.article-entry .highlight pre .class pre .title{color:#e6c07b}.abstract-content .highlight pre .attr,.abstract-content .highlight pre .variable,.abstract-content .highlight pre .template-variable,.abstract-content .highlight pre .type,.abstract-content .highlight pre .selector-class,.abstract-content .highlight pre .selector-attr,.abstract-content .highlight pre .selector-pseudo,.abstract-content .highlight pre .number,.article-entry .highlight pre .attr,.article-entry .highlight pre .variable,.article-entry .highlight pre .template-variable,.article-entry .highlight pre .type,.article-entry .highlight pre .selector-class,.article-entry .highlight pre .selector-attr,.article-entry .highlight pre .selector-pseudo,.article-entry .highlight pre .number{color:#d19a66}.abstract-content .highlight pre .symbol,.abstract-content .highlight pre .bullet,.abstract-content .highlight pre .link,.abstract-content .highlight pre .meta,.abstract-content .highlight pre .selector-id,.abstract-content .highlight pre .title,.article-entry .highlight pre .symbol,.article-entry .highlight pre .bullet,.article-entry .highlight pre .link,.article-entry .highlight pre .meta,.article-entry .highlight pre .selector-id,.article-entry .highlight pre .title{color:#61aeee}.abstract-content .highlight pre .emphasis,.article-entry .highlight pre .emphasis{font-style:italic}.abstract-content .highlight pre .strong,.article-entry .highlight pre .strong{font-weight:bold}.abstract-content .highlight pre .link,.article-entry .highlight pre .link{text-decoration:underline}.abstract-content .gist,.article-entry .gist{margin:0 -20px;border-style:solid;border-color:#ddd;border-width:1px 0;background:#272822;padding:15px 20px 15px 0}.abstract-content .gist .gist-file,.article-entry .gist .gist-file{border:none;font-family:'Source Code Pro', Consolas, Monaco, Menlo, Consolas, monospace;margin:0}.abstract-content .gist .gist-file .gist-data,.article-entry .gist .gist-file .gist-data{background:none;border:none}.abstract-content .gist .gist-file .gist-data .line-numbers,.article-entry .gist .gist-file .gist-data .line-numbers{background:none;border:none;padding:0 20px 0 0}.abstract-content .gist .gist-file .gist-data .line-data,.article-entry .gist .gist-file .gist-data .line-data{padding:0 !important}.abstract-content .gist .gist-file .highlight,.article-entry .gist .gist-file .highlight{margin:0;padding:0;border:none}.abstract-content .gist .gist-file .gist-meta,.article-entry .gist .gist-file .gist-meta{background:#272822;color:highlight-comment;font:0.85em 'Helvetica Neue', Helvetica, Arial, sans-serif;text-shadow:0 0;padding:0;margin-top:1em;margin-left:20px}.abstract-content .gist .gist-file .gist-meta a,.article-entry .gist .gist-file .gist-meta a{color:#258fb8;font-weight:normal}.abstract-content .gist .gist-file .gist-meta a:hover,.article-entry .gist .gist-file .gist-meta a:hover{text-decoration:underline}@font-face{font-family:'iconfont-archer';src:url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.eot");src:url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.eot?#iefix") format("embedded-opentype"),url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.woff") format("woff"),url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.ttf") format("truetype"),url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.svg#iconfont-archer") format("svg")}.iconfont-archer{font-family:'iconfont-archer' !important;font-size:1rem;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.sidebar-panel-archives{padding:1rem}.sidebar-panel-archives ul{padding:0;margin:0}.ps__rail-x,.ps__rail-y{display:none !important}.post-archive{overflow-y:auto}.archive-post-item,.meta-post-item{vertical-align:middle;border-left:1px solid #bbb;margin-left:0.3rem;padding:0.1rem 0 0.1rem 0.5rem;box-sizing:border-box}.archive-post-item:hover,.meta-post-item:hover{border-left-color:#f75357}.archive-post-item:hover .archive-post-date,.meta-post-item:hover .archive-post-date,.archive-post-item:hover .meta-post-date,.meta-post-item:hover .meta-post-date,.archive-post-item:hover .archive-post-title,.meta-post-item:hover .archive-post-title,.archive-post-item:hover .meta-post-title,.meta-post-item:hover .meta-post-title{color:#f75357}.total-and-search{display:flex}.site-search{cursor:pointer}.site-search .search-icon{color:#f75357;line-height:1.9rem;font-size:1.5rem;position:relative;margin-left:0.5rem}.archive-year,.total-archive{font:1.2rem "Oswald-Regular";color:#f75357}.archive-year{font-size:1rem;margin-bottom:0.3rem}.archive-post-date,.meta-post-date{font:0.9rem/1rem "Oswald-Regular";color:#999}.archive-post-title,.meta-post-title{font-size:1rem;margin-left:0.8rem;text-align:left;color:#ccc}.sidebar-panel-tags,.sidebar-panel-categories{padding:1rem 1rem 5px 1rem;position:relative;display:flex;flex-direction:column}.sidebar-tags-name,.sidebar-categories-name{flex-grow:0;width:100%;padding:0 0 1rem 0;max-height:28rem;overflow:auto}.sidebar-tag-name,.sidebar-category-name{display:inline-block;border:1px solid #fff;border-radius:5rem;padding:0.07rem 0.4rem 0.1rem 0.4rem;margin:0.2rem 0;white-space:nowrap;font-size:1rem;cursor:pointer;color:#fff}.sidebar-tag-name:hover,.sidebar-category-name:hover{border-color:#f75357;color:#f75357}.sidebar-tag-name .iconfont-archer,.sidebar-category-name .iconfont-archer{pointer-events:none;transform:translateY(-1rem);font-size:0.6rem;margin:0 0.3rem 0 0.1rem}.sidebar-category-name .iconfont-archer{font-size:16px}.sidebar-tags-empty,.sidebar-categories-empty{display:none}.sidebar-tags-empty-active,.sidebar-categories-empty-active{display:block;font-size:6rem !important;margin-top:7rem;user-select:none;text-align:center;color:#fff}.sidebar-label-focus{border-color:#f75357;color:#f75357}.sidebar-tags-list,.sidebar-categories-list{flex-grow:1;padding:1rem 1rem 0 0;overflow-y:auto}.sidebar{position:fixed;display:flex;flex-direction:column;left:0;top:0;z-index:0;height:100%;width:400px;transition:all 0.3s ease-in 0s;overflow-x:hidden;background-color:#222}.sidebar-hide{display:none}.sidebar-tabs{display:flex;position:relative;padding:0;margin:0;height:4rem;width:100%;z-index:1001;justify-content:space-around;align-items:flex-start;font-family:"Oswald-Regular";flex-grow:0;color:#eee;border-bottom:2px solid #666}.sidebar-tabs::after{content:'';position:absolute;width:33.33%;height:2px;left:0;top:100%;background-color:#f75357;transform:translate3d(0, 0, 0);transition:transform 0.2s ease-out 0s}.sidebar-tab-archives,.sidebar-tab-tags,.sidebar-tab-categories{display:flex;align-items:center;justify-content:center;font-size:1.3rem;width:33.333%;height:100%;cursor:pointer}.sidebar-tab-archives .iconfont-archer,.sidebar-tab-tags .iconfont-archer,.sidebar-tab-categories .iconfont-archer{pointer-events:none;margin:0 0.5rem 0 0rem;font-size:1.5rem}.tab-name{pointer-events:none;font-size:1.5rem;margin-left:0.2rem}.sidebar-tabs-active-0::after{transform:translate3d(0, 0, 0)}.sidebar-tabs-active-1::after{transform:translate3d(100%, 0, 0)}.sidebar-tabs-active-2::after{transform:translate3d(200%, 0, 0)}.sidebar-content{position:relative;display:flex;width:300%;height:calc(100% - 4rem);top:0;left:0;transition:transform 0.3s ease-out 0s;overflow-x:hidden;transform:translate3d(0, 0, 0)}.sidebar-panel-archives,.sidebar-panel-tags,.sidebar-panel-categories{overflow-x:hidden;overflow-y:auto;flex-shrink:0;width:calc(33.33% - 2rem);-webkit-overflow-scrolling:touch;overflow-scrolling:touch}.sidebar-content-active-0{transform:translate3d(0, 0, 0)}.sidebar-content-active-1{transform:translate3d(-33.33%, 0, 0)}.sidebar-content-active-2{transform:translate3d(-66.67%, 0, 0)}.index-post{position:relative;padding:1rem 0rem 1rem 0rem;border-bottom:1px dashed rgba(0,0,0,0.2);z-index:3}.index-post .abstract-content{color:#9c9c9c;font-size:1rem;line-height:1.6rem;font-weight:lighter;word-break:break-word}.index-post .abstract-content img{max-width:100%;box-shadow:none}.abstract-title{line-height:2.5rem;color:#787878;padding-bottom:0.5rem}.abstract-title span:last-of-type{transition:color 0.1s ease-in;font-size:1.7rem}.abstract-title span:last-of-type:hover{color:#f75357}.stick-top{font-size:1.3rem;margin-right:0.2rem}.abstract-post-meta{display:flex;justify-content:space-between;padding:0.5rem 0 0 0;font-family:"Oswald-Regular";color:#aaa;height:1.5rem}.post-tag{font-size:1rem;position:relative;color:#aaa;margin-left:0.4rem;font-weight:lighter}.post-tag::before{margin-right:2px;content:'#'}.post-tag::after{content:'';position:absolute;left:calc((100% - 98%) / 2);bottom:-15%;transition:all 0.15s ease-in;width:98%;height:2px;transform:translate(0, 0);background-color:#aaa;opacity:0}.post-tag:hover::after{transform:translate(0, -2px);opacity:1}.abstract-calander{position:relative;top:-0.1rem;margin-right:0.3rem;font-size:1rem}@font-face{font-family:'iconfont-archer';src:url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.eot");src:url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.eot?#iefix") format("embedded-opentype"),url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.woff") format("woff"),url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.ttf") format("truetype"),url("//at.alicdn.com/t/font_327081_s1wbjxwfu9c.svg#iconfont-archer") format("svg")}.iconfont-archer{font-family:'iconfont-archer' !important;font-size:1rem;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.post-body main,.about-body main{margin:0}.anchorjs-archer{color:#f75357;border:none !important}.post-body .site-intro-meta,.about-body .site-intro-meta{width:50%;min-width:42.8125rem;margin:0 auto;align-items:flex-start}.post-body .intro-title,.about-body .intro-title{font:4rem/5.3rem "Oswald-Regular";color:#fff;margin:0}.post-intros{opacity:0;transition:all 0.5s ease-out 0.5s;transform:translate3d(0, -1rem, 0)}.post-intro-tags{font:1.2rem "Oswald-Regular"}.post-intro-tags .post-tag{position:relative;margin-left:0;margin-right:0.5rem;font-size:1.2rem;color:#fff}.post-intro-tags .post-tag::after{content:'';position:absolute;left:calc((100% - 98%) / 2);bottom:-15%;transition:all 0.15s ease-in;width:98%;height:2px;transform:translate(0, 0);background-color:#fff;opacity:0}.post-intro-tags .post-tag:hover::after{transform:translate(0, -2px);opacity:1}.post-intro-tags .post-tag::before{content:'#'}.post-intro-meta{margin-top:0.2rem;font:1.1rem "Oswald-Regular";color:#fff;display:flex;align-items:center}.post-intro-read{margin-top:0.2rem;font:0.9rem "Oswald-Regular";color:#fff;display:flex;align-items:center}.word-count{margin-right:1rem}.post-fade-in{opacity:1;transform:translate3d(0, 0, 0)}.post-intro-calander{font-size:0.9rem;margin-right:0.3rem}.post-intro-time{font-size:0.9rem;margin-right:0.5rem}.busuanzi-pv,.busuanzi-uv{font-size:0.9rem;margin-right:0.4rem}.shareWrapper{position:relative;font-size:0.9rem;padding:0 0.5rem 0 0}.shareWrapper:hover .shareList{visibility:visible;opacity:1}.shareIcon{font-size:0.9rem;cursor:pointer}.shareText{font-family:"Oswald-Regular";cursor:pointer}.shareList{position:absolute;visibility:hidden;margin:0;padding:0;left:100%;bottom:0;display:flex;opacity:0;transition:all 0.1s ease-in 0s}.shareList .iconfont-archer{display:inline-block;margin-right:3px;cursor:pointer}.shareList .iconfont-archer:hover{color:#aaa}.shareList [data-type='weibo']{position:relative;top:-2px}.shareList [data-type='facebook']{position:relative;top:1px}.share-qr{position:relative}.share-qrcode{position:absolute;left:0;bottom:1.5rem;visibility:hidden;opacity:0;transition:all 0.1s ease-in 0s}.share-qr:hover .share-qrcode{visibility:visible;opacity:1}.post-paginator{overflow:hidden;margin:0;list-style:none;padding:2.5rem 0 1rem 0;display:flex;justify-content:space-between}.post-paginator li{position:relative;max-width:13rem}.post-paginator .nextTitle,.post-paginator .prevTitle{font-size:1.2rem;color:#ccc}.post-paginator .nextTitle:hover,.post-paginator .prevTitle:hover{color:#f75357}.post-paginator .nextSlogan,.post-paginator .prevSlogan{font:bold 1.4rem "Oswald-Regular";color:#252525}.post-paginator .nextSlogan::before{content:'< ';font-size:1.7rem}.post-paginator .prevSlogan::after{content:' >';font-size:1.7rem}.abstract-content,.article-entry{position:relative;padding:1px 0;font-weight:lighter;font-weight:400;color:#23394d}.abstract-content ul,.abstract-content ul li,.article-entry ul,.article-entry ul li{list-style-type:initial}.abstract-content ol,.abstract-content ol li,.article-entry ol,.article-entry ol li{list-style-type:decimal-leading-zero}.abstract-content h1:first-child,.article-entry h1:first-child{margin-top:0}.abstract-content h2:first-child,.article-entry h2:first-child{margin-top:0}.abstract-content h3:first-child,.article-entry h3:first-child{margin-top:0}.abstract-content h4:first-child,.article-entry h4:first-child{margin-top:0}.abstract-content h5:first-child,.article-entry h5:first-child{margin-top:0}.abstract-content h6:first-child,.article-entry h6:first-child{margin-top:0}.abstract-content h5,.article-entry h5{font-size:1rem;margin:1rem 0}.abstract-content h6,.article-entry h6{font-size:0.8rem;margin:1rem 0}.abstract-content p,.article-entry p{line-height:1.625}.abstract-content em,.article-entry em{font-style:italic}.abstract-content img,.article-entry img{display:block;max-width:100%;margin:1rem auto 1rem;box-shadow:0 0 4px 2px rgba(0,0,0,0.2)}.abstract-content blockquote,.article-entry blockquote{margin:1.5em 0 1.5rem 0;padding:10px 20px;position:relative;background-color:#f6f6f6;border-left:3px solid #f75357}.abstract-content blockquote p,.article-entry blockquote p{margin:0}.abstract-content .table-container table,.abstract-content>table,.article-entry .table-container table,.article-entry>table{width:100%;border:1px solid #ddd;margin:1rem 0;border-collapse:collapse;box-shadow:2px 2px 2px rgba(0,0,0,0.125)}.abstract-content .table-container table tr,.abstract-content .table-container table td,.abstract-content>table tr,.abstract-content>table td,.article-entry .table-container table tr,.article-entry .table-container table td,.article-entry>table tr,.article-entry>table td{height:2rem}.abstract-content .table-container table thead tr,.abstract-content>table thead tr,.article-entry .table-container table thead tr,.article-entry>table thead tr{background:#f8f8f8}.abstract-content .table-container table tbody tr:hover,.abstract-content>table tbody tr:hover,.article-entry .table-container table tbody tr:hover,.article-entry>table tbody tr:hover{background:#efefef}.abstract-content .table-container table td,.abstract-content .table-container table th,.abstract-content>table td,.abstract-content>table th,.article-entry .table-container table td,.article-entry .table-container table th,.article-entry>table td,.article-entry>table th{border:1px solid #dedede;padding:0.2rem 1rem 0 1rem}.abstract-content a,.article-entry a{color:#f75357;padding:0 0 0 2px;word-break:break-all}.abstract-content a:hover,.article-entry a:hover{border-bottom:1px solid #f75357}.abstract-content a.fancybox,.article-entry a.fancybox{border:0}.license-wrapper{font-weight:300;line-height:1.5rem;border-top:1px dashed #ccc;border-bottom:1px dashed #ccc;color:#23394d}.license-wrapper p{margin:0.2rem 0}.license-wrapper a{color:#f75357}.toc-wrapper{display:block;position:absolute;top:50vh;width:22%;right:1%;overflow:hidden;max-width:calc((100% - 42.8125rem - 4rem) / 2);z-index:9999;margin:calc(3.5rem + 1rem) 0 0 0;transform:translate3d(0, 0, 0);transition:transform 0.3s ease-out 0s}.toc-wrapper .toc-active{color:#f75357}.toc-catalog{color:#bbb;cursor:pointer;user-select:none;font:bolder 1.2rem "Oswald-Regular"}.toc-catalog:hover{color:#f75357}.catalog-icon{position:relative;top:-0.1rem;margin-right:0.3rem}.toc,.toc-child{padding-left:0;margin:0 0 0 0}.toc-wrapper>*{transform:translate(0, 0);transition:transform 0.3s ease-out, opacity 0.3s ease-out;opacity:1}.toc-wrapper ol{padding-left:1rem}.toc-wrapper .toc-number{font-weight:bold}.toc-wrapper a{color:#ddd}.toc-wrapper a:hover{color:#f75357 !important}.toc-hide-children>*{transform:translate(-100%, 0);opacity:0}.toc-hide-children .toc-catalog{display:block;transform:none;opacity:1}.toc-fixed{position:fixed;top:0rem !important}.toc-slide{transform:translate3d(400px, 0, 0)}.toc-hide{display:none}.four-zero-four-body .loading{display:none !important}.four-zero-four-body .site-intro{height:100%}.four-zero-four-body .site-intro-meta{height:80%}.four-zero-four-body .wrapper{height:100vh;padding-bottom:0}.four-zero-four-body .container{padding:0}.four-zero-four-body .footer{width:100%;z-index:30;background-color:transparent;position:absolute;bottom:0}.four-zero-four-body .iconfont-archer::before{color:rgba(255,255,255,0.5)}.four-zero-four-body .copyright{color:#fff} diff --git a/font/Oswald-Regular.ttf b/font/Oswald-Regular.ttf new file mode 100644 index 0000000..c749cfa Binary files /dev/null and b/font/Oswald-Regular.ttf differ diff --git a/font/Source Sans Pro.woff b/font/Source Sans Pro.woff new file mode 100644 index 0000000..5ac4200 Binary files /dev/null and b/font/Source Sans Pro.woff differ diff --git a/font/Source Sans Pro.woff2 b/font/Source Sans Pro.woff2 new file mode 100644 index 0000000..db0937f Binary files /dev/null and b/font/Source Sans Pro.woff2 differ diff --git a/font/SourceCodePro-Regular.ttf.woff b/font/SourceCodePro-Regular.ttf.woff new file mode 100644 index 0000000..117c7e5 Binary files /dev/null and b/font/SourceCodePro-Regular.ttf.woff differ diff --git a/font/SourceCodePro-Regular.ttf.woff2 b/font/SourceCodePro-Regular.ttf.woff2 new file mode 100644 index 0000000..d97cd54 Binary files /dev/null and b/font/SourceCodePro-Regular.ttf.woff2 differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..69ebf2e --- /dev/null +++ b/index.html @@ -0,0 +1,1392 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DayDay's Studio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + DayDay's Studio. + + +

+ +

+ + + + If you don't STRUGGLE, you don't improve. + + + +

+ + +
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + +
+ + + CSS3 变量 + +
+ 工作需要了解了一下CSS3变量内容,简单记录一下。 +
+ +
+ + + + + + + + + + + + + + + + + + + + +
+ + + 媒体自动播放 + +
+ 前几天工作上遇到需要自动播放视频的需求,在自己搜索和亲友团的帮助下,整理处以下内容。 +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ avatar +
DayDay 卡比兽
+ +
+ 鲤鱼王型前端程序员成长历程 +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ ABOUT ME +
+ +
+ +
+
+ + + + + + + + +
+ + + PV: :) + +
+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/intro/404-bg.jpg b/intro/404-bg.jpg new file mode 100644 index 0000000..bbe49db Binary files /dev/null and b/intro/404-bg.jpg differ diff --git a/intro/about-bg.jpg b/intro/about-bg.jpg new file mode 100644 index 0000000..54835c8 Binary files /dev/null and b/intro/about-bg.jpg differ diff --git a/intro/index-bg.jpg b/intro/index-bg.jpg new file mode 100644 index 0000000..61a067f Binary files /dev/null and b/intro/index-bg.jpg differ diff --git a/intro/post-bg.jpg b/intro/post-bg.jpg new file mode 100644 index 0000000..357bf2f Binary files /dev/null and b/intro/post-bg.jpg differ diff --git a/lib/jquery.min.js b/lib/jquery.min.js new file mode 100644 index 0000000..4d9b3a2 --- /dev/null +++ b/lib/jquery.min.js @@ -0,0 +1,2 @@ +/*! jQuery v3.3.1 | (c) JS Foundation and other contributors | jquery.org/license */ +!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){"use strict";var n=[],r=e.document,i=Object.getPrototypeOf,o=n.slice,a=n.concat,s=n.push,u=n.indexOf,l={},c=l.toString,f=l.hasOwnProperty,p=f.toString,d=p.call(Object),h={},g=function e(t){return"function"==typeof t&&"number"!=typeof t.nodeType},y=function e(t){return null!=t&&t===t.window},v={type:!0,src:!0,noModule:!0};function m(e,t,n){var i,o=(t=t||r).createElement("script");if(o.text=e,n)for(i in v)n[i]&&(o[i]=n[i]);t.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[c.call(e)]||"object":typeof e}var b="3.3.1",w=function(e,t){return new w.fn.init(e,t)},T=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;w.fn=w.prototype={jquery:"3.3.1",constructor:w,length:0,toArray:function(){return o.call(this)},get:function(e){return null==e?o.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=w.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return w.each(this,e)},map:function(e){return this.pushStack(w.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(o.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(n>=0&&n0&&t-1 in e)}var E=function(e){var t,n,r,i,o,a,s,u,l,c,f,p,d,h,g,y,v,m,x,b="sizzle"+1*new Date,w=e.document,T=0,C=0,E=ae(),k=ae(),S=ae(),D=function(e,t){return e===t&&(f=!0),0},N={}.hasOwnProperty,A=[],j=A.pop,q=A.push,L=A.push,H=A.slice,O=function(e,t){for(var n=0,r=e.length;n+~]|"+M+")"+M+"*"),z=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),X=new RegExp(W),U=new RegExp("^"+R+"$"),V={ID:new RegExp("^#("+R+")"),CLASS:new RegExp("^\\.("+R+")"),TAG:new RegExp("^("+R+"|[*])"),ATTR:new RegExp("^"+I),PSEUDO:new RegExp("^"+W),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+P+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},G=/^(?:input|select|textarea|button)$/i,Y=/^h\d$/i,Q=/^[^{]+\{\s*\[native \w/,J=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,K=/[+~]/,Z=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),ee=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},te=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ne=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},re=function(){p()},ie=me(function(e){return!0===e.disabled&&("form"in e||"label"in e)},{dir:"parentNode",next:"legend"});try{L.apply(A=H.call(w.childNodes),w.childNodes),A[w.childNodes.length].nodeType}catch(e){L={apply:A.length?function(e,t){q.apply(e,H.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function oe(e,t,r,i){var o,s,l,c,f,h,v,m=t&&t.ownerDocument,T=t?t.nodeType:9;if(r=r||[],"string"!=typeof e||!e||1!==T&&9!==T&&11!==T)return r;if(!i&&((t?t.ownerDocument||t:w)!==d&&p(t),t=t||d,g)){if(11!==T&&(f=J.exec(e)))if(o=f[1]){if(9===T){if(!(l=t.getElementById(o)))return r;if(l.id===o)return r.push(l),r}else if(m&&(l=m.getElementById(o))&&x(t,l)&&l.id===o)return r.push(l),r}else{if(f[2])return L.apply(r,t.getElementsByTagName(e)),r;if((o=f[3])&&n.getElementsByClassName&&t.getElementsByClassName)return L.apply(r,t.getElementsByClassName(o)),r}if(n.qsa&&!S[e+" "]&&(!y||!y.test(e))){if(1!==T)m=t,v=e;else if("object"!==t.nodeName.toLowerCase()){(c=t.getAttribute("id"))?c=c.replace(te,ne):t.setAttribute("id",c=b),s=(h=a(e)).length;while(s--)h[s]="#"+c+" "+ve(h[s]);v=h.join(","),m=K.test(e)&&ge(t.parentNode)||t}if(v)try{return L.apply(r,m.querySelectorAll(v)),r}catch(e){}finally{c===b&&t.removeAttribute("id")}}}return u(e.replace(B,"$1"),t,r,i)}function ae(){var e=[];function t(n,i){return e.push(n+" ")>r.cacheLength&&delete t[e.shift()],t[n+" "]=i}return t}function se(e){return e[b]=!0,e}function ue(e){var t=d.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function le(e,t){var n=e.split("|"),i=n.length;while(i--)r.attrHandle[n[i]]=t}function ce(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function fe(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}function pe(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function de(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&ie(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function he(e){return se(function(t){return t=+t,se(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function ge(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}n=oe.support={},o=oe.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},p=oe.setDocument=function(e){var t,i,a=e?e.ownerDocument||e:w;return a!==d&&9===a.nodeType&&a.documentElement?(d=a,h=d.documentElement,g=!o(d),w!==d&&(i=d.defaultView)&&i.top!==i&&(i.addEventListener?i.addEventListener("unload",re,!1):i.attachEvent&&i.attachEvent("onunload",re)),n.attributes=ue(function(e){return e.className="i",!e.getAttribute("className")}),n.getElementsByTagName=ue(function(e){return e.appendChild(d.createComment("")),!e.getElementsByTagName("*").length}),n.getElementsByClassName=Q.test(d.getElementsByClassName),n.getById=ue(function(e){return h.appendChild(e).id=b,!d.getElementsByName||!d.getElementsByName(b).length}),n.getById?(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){return e.getAttribute("id")===t}},r.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&g){var n=t.getElementById(e);return n?[n]:[]}}):(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){var n="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}},r.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&g){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),r.find.TAG=n.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):n.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},r.find.CLASS=n.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&g)return t.getElementsByClassName(e)},v=[],y=[],(n.qsa=Q.test(d.querySelectorAll))&&(ue(function(e){h.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&y.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||y.push("\\["+M+"*(?:value|"+P+")"),e.querySelectorAll("[id~="+b+"-]").length||y.push("~="),e.querySelectorAll(":checked").length||y.push(":checked"),e.querySelectorAll("a#"+b+"+*").length||y.push(".#.+[+~]")}),ue(function(e){e.innerHTML="";var t=d.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&y.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&y.push(":enabled",":disabled"),h.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&y.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),y.push(",.*:")})),(n.matchesSelector=Q.test(m=h.matches||h.webkitMatchesSelector||h.mozMatchesSelector||h.oMatchesSelector||h.msMatchesSelector))&&ue(function(e){n.disconnectedMatch=m.call(e,"*"),m.call(e,"[s!='']:x"),v.push("!=",W)}),y=y.length&&new RegExp(y.join("|")),v=v.length&&new RegExp(v.join("|")),t=Q.test(h.compareDocumentPosition),x=t||Q.test(h.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return f=!0,0;var r=!e.compareDocumentPosition-!t.compareDocumentPosition;return r||(1&(r=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!n.sortDetached&&t.compareDocumentPosition(e)===r?e===d||e.ownerDocument===w&&x(w,e)?-1:t===d||t.ownerDocument===w&&x(w,t)?1:c?O(c,e)-O(c,t):0:4&r?-1:1)}:function(e,t){if(e===t)return f=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e===d?-1:t===d?1:i?-1:o?1:c?O(c,e)-O(c,t):0;if(i===o)return ce(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?ce(a[r],s[r]):a[r]===w?-1:s[r]===w?1:0},d):d},oe.matches=function(e,t){return oe(e,null,null,t)},oe.matchesSelector=function(e,t){if((e.ownerDocument||e)!==d&&p(e),t=t.replace(z,"='$1']"),n.matchesSelector&&g&&!S[t+" "]&&(!v||!v.test(t))&&(!y||!y.test(t)))try{var r=m.call(e,t);if(r||n.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(e){}return oe(t,d,null,[e]).length>0},oe.contains=function(e,t){return(e.ownerDocument||e)!==d&&p(e),x(e,t)},oe.attr=function(e,t){(e.ownerDocument||e)!==d&&p(e);var i=r.attrHandle[t.toLowerCase()],o=i&&N.call(r.attrHandle,t.toLowerCase())?i(e,t,!g):void 0;return void 0!==o?o:n.attributes||!g?e.getAttribute(t):(o=e.getAttributeNode(t))&&o.specified?o.value:null},oe.escape=function(e){return(e+"").replace(te,ne)},oe.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},oe.uniqueSort=function(e){var t,r=[],i=0,o=0;if(f=!n.detectDuplicates,c=!n.sortStable&&e.slice(0),e.sort(D),f){while(t=e[o++])t===e[o]&&(i=r.push(o));while(i--)e.splice(r[i],1)}return c=null,e},i=oe.getText=function(e){var t,n="",r=0,o=e.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=i(e)}else if(3===o||4===o)return e.nodeValue}else while(t=e[r++])n+=i(t);return n},(r=oe.selectors={cacheLength:50,createPseudo:se,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(Z,ee),e[3]=(e[3]||e[4]||e[5]||"").replace(Z,ee),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||oe.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&oe.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return V.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=a(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(Z,ee).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=E[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&E(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=oe.attr(r,e);return null==i?"!="===t:!t||(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i.replace($," ")+" ").indexOf(n)>-1:"|="===t&&(i===n||i.slice(0,n.length+1)===n+"-"))}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,p,d,h,g=o!==a?"nextSibling":"previousSibling",y=t.parentNode,v=s&&t.nodeName.toLowerCase(),m=!u&&!s,x=!1;if(y){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===v:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?y.firstChild:y.lastChild],a&&m){x=(d=(l=(c=(f=(p=y)[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]||[])[0]===T&&l[1])&&l[2],p=d&&y.childNodes[d];while(p=++d&&p&&p[g]||(x=d=0)||h.pop())if(1===p.nodeType&&++x&&p===t){c[e]=[T,d,x];break}}else if(m&&(x=d=(l=(c=(f=(p=t)[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]||[])[0]===T&&l[1]),!1===x)while(p=++d&&p&&p[g]||(x=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===v:1===p.nodeType)&&++x&&(m&&((c=(f=p[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]=[T,x]),p===t))break;return(x-=i)===r||x%r==0&&x/r>=0}}},PSEUDO:function(e,t){var n,i=r.pseudos[e]||r.setFilters[e.toLowerCase()]||oe.error("unsupported pseudo: "+e);return i[b]?i(t):i.length>1?(n=[e,e,"",t],r.setFilters.hasOwnProperty(e.toLowerCase())?se(function(e,n){var r,o=i(e,t),a=o.length;while(a--)e[r=O(e,o[a])]=!(n[r]=o[a])}):function(e){return i(e,0,n)}):i}},pseudos:{not:se(function(e){var t=[],n=[],r=s(e.replace(B,"$1"));return r[b]?se(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),t[0]=null,!n.pop()}}),has:se(function(e){return function(t){return oe(e,t).length>0}}),contains:se(function(e){return e=e.replace(Z,ee),function(t){return(t.textContent||t.innerText||i(t)).indexOf(e)>-1}}),lang:se(function(e){return U.test(e||"")||oe.error("unsupported lang: "+e),e=e.replace(Z,ee).toLowerCase(),function(t){var n;do{if(n=g?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(n=n.toLowerCase())===e||0===n.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===h},focus:function(e){return e===d.activeElement&&(!d.hasFocus||d.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:de(!1),disabled:de(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!r.pseudos.empty(e)},header:function(e){return Y.test(e.nodeName)},input:function(e){return G.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:he(function(){return[0]}),last:he(function(e,t){return[t-1]}),eq:he(function(e,t,n){return[n<0?n+t:n]}),even:he(function(e,t){for(var n=0;n=0;)e.push(r);return e}),gt:he(function(e,t,n){for(var r=n<0?n+t:n;++r1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function be(e,t,n){for(var r=0,i=t.length;r-1&&(o[l]=!(a[l]=f))}}else v=we(v===a?v.splice(h,v.length):v),i?i(null,a,v,u):L.apply(a,v)})}function Ce(e){for(var t,n,i,o=e.length,a=r.relative[e[0].type],s=a||r.relative[" "],u=a?1:0,c=me(function(e){return e===t},s,!0),f=me(function(e){return O(t,e)>-1},s,!0),p=[function(e,n,r){var i=!a&&(r||n!==l)||((t=n).nodeType?c(e,n,r):f(e,n,r));return t=null,i}];u1&&xe(p),u>1&&ve(e.slice(0,u-1).concat({value:" "===e[u-2].type?"*":""})).replace(B,"$1"),n,u0,i=e.length>0,o=function(o,a,s,u,c){var f,h,y,v=0,m="0",x=o&&[],b=[],w=l,C=o||i&&r.find.TAG("*",c),E=T+=null==w?1:Math.random()||.1,k=C.length;for(c&&(l=a===d||a||c);m!==k&&null!=(f=C[m]);m++){if(i&&f){h=0,a||f.ownerDocument===d||(p(f),s=!g);while(y=e[h++])if(y(f,a||d,s)){u.push(f);break}c&&(T=E)}n&&((f=!y&&f)&&v--,o&&x.push(f))}if(v+=m,n&&m!==v){h=0;while(y=t[h++])y(x,b,a,s);if(o){if(v>0)while(m--)x[m]||b[m]||(b[m]=j.call(u));b=we(b)}L.apply(u,b),c&&!o&&b.length>0&&v+t.length>1&&oe.uniqueSort(u)}return c&&(T=E,l=w),x};return n?se(o):o}return s=oe.compile=function(e,t){var n,r=[],i=[],o=S[e+" "];if(!o){t||(t=a(e)),n=t.length;while(n--)(o=Ce(t[n]))[b]?r.push(o):i.push(o);(o=S(e,Ee(i,r))).selector=e}return o},u=oe.select=function(e,t,n,i){var o,u,l,c,f,p="function"==typeof e&&e,d=!i&&a(e=p.selector||e);if(n=n||[],1===d.length){if((u=d[0]=d[0].slice(0)).length>2&&"ID"===(l=u[0]).type&&9===t.nodeType&&g&&r.relative[u[1].type]){if(!(t=(r.find.ID(l.matches[0].replace(Z,ee),t)||[])[0]))return n;p&&(t=t.parentNode),e=e.slice(u.shift().value.length)}o=V.needsContext.test(e)?0:u.length;while(o--){if(l=u[o],r.relative[c=l.type])break;if((f=r.find[c])&&(i=f(l.matches[0].replace(Z,ee),K.test(u[0].type)&&ge(t.parentNode)||t))){if(u.splice(o,1),!(e=i.length&&ve(u)))return L.apply(n,i),n;break}}}return(p||s(e,d))(i,t,!g,n,!t||K.test(e)&&ge(t.parentNode)||t),n},n.sortStable=b.split("").sort(D).join("")===b,n.detectDuplicates=!!f,p(),n.sortDetached=ue(function(e){return 1&e.compareDocumentPosition(d.createElement("fieldset"))}),ue(function(e){return e.innerHTML="","#"===e.firstChild.getAttribute("href")})||le("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),n.attributes&&ue(function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||le("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),ue(function(e){return null==e.getAttribute("disabled")})||le(P,function(e,t,n){var r;if(!n)return!0===e[t]?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),oe}(e);w.find=E,w.expr=E.selectors,w.expr[":"]=w.expr.pseudos,w.uniqueSort=w.unique=E.uniqueSort,w.text=E.getText,w.isXMLDoc=E.isXML,w.contains=E.contains,w.escapeSelector=E.escape;var k=function(e,t,n){var r=[],i=void 0!==n;while((e=e[t])&&9!==e.nodeType)if(1===e.nodeType){if(i&&w(e).is(n))break;r.push(e)}return r},S=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},D=w.expr.match.needsContext;function N(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var A=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,t,n){return g(t)?w.grep(e,function(e,r){return!!t.call(e,r,e)!==n}):t.nodeType?w.grep(e,function(e){return e===t!==n}):"string"!=typeof t?w.grep(e,function(e){return u.call(t,e)>-1!==n}):w.filter(t,e,n)}w.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?w.find.matchesSelector(r,e)?[r]:[]:w.find.matches(e,w.grep(t,function(e){return 1===e.nodeType}))},w.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(w(e).filter(function(){for(t=0;t1?w.uniqueSort(n):n},filter:function(e){return this.pushStack(j(this,e||[],!1))},not:function(e){return this.pushStack(j(this,e||[],!0))},is:function(e){return!!j(this,"string"==typeof e&&D.test(e)?w(e):e||[],!1).length}});var q,L=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(w.fn.init=function(e,t,n){var i,o;if(!e)return this;if(n=n||q,"string"==typeof e){if(!(i="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:L.exec(e))||!i[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(i[1]){if(t=t instanceof w?t[0]:t,w.merge(this,w.parseHTML(i[1],t&&t.nodeType?t.ownerDocument||t:r,!0)),A.test(i[1])&&w.isPlainObject(t))for(i in t)g(this[i])?this[i](t[i]):this.attr(i,t[i]);return this}return(o=r.getElementById(i[2]))&&(this[0]=o,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):g(e)?void 0!==n.ready?n.ready(e):e(w):w.makeArray(e,this)}).prototype=w.fn,q=w(r);var H=/^(?:parents|prev(?:Until|All))/,O={children:!0,contents:!0,next:!0,prev:!0};w.fn.extend({has:function(e){var t=w(e,this),n=t.length;return this.filter(function(){for(var e=0;e-1:1===n.nodeType&&w.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(o.length>1?w.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?u.call(w(e),this[0]):u.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(w.uniqueSort(w.merge(this.get(),w(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function P(e,t){while((e=e[t])&&1!==e.nodeType);return e}w.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return k(e,"parentNode")},parentsUntil:function(e,t,n){return k(e,"parentNode",n)},next:function(e){return P(e,"nextSibling")},prev:function(e){return P(e,"previousSibling")},nextAll:function(e){return k(e,"nextSibling")},prevAll:function(e){return k(e,"previousSibling")},nextUntil:function(e,t,n){return k(e,"nextSibling",n)},prevUntil:function(e,t,n){return k(e,"previousSibling",n)},siblings:function(e){return S((e.parentNode||{}).firstChild,e)},children:function(e){return S(e.firstChild)},contents:function(e){return N(e,"iframe")?e.contentDocument:(N(e,"template")&&(e=e.content||e),w.merge([],e.childNodes))}},function(e,t){w.fn[e]=function(n,r){var i=w.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=w.filter(r,i)),this.length>1&&(O[e]||w.uniqueSort(i),H.test(e)&&i.reverse()),this.pushStack(i)}});var M=/[^\x20\t\r\n\f]+/g;function R(e){var t={};return w.each(e.match(M)||[],function(e,n){t[n]=!0}),t}w.Callbacks=function(e){e="string"==typeof e?R(e):w.extend({},e);var t,n,r,i,o=[],a=[],s=-1,u=function(){for(i=i||e.once,r=t=!0;a.length;s=-1){n=a.shift();while(++s-1)o.splice(n,1),n<=s&&s--}),this},has:function(e){return e?w.inArray(e,o)>-1:o.length>0},empty:function(){return o&&(o=[]),this},disable:function(){return i=a=[],o=n="",this},disabled:function(){return!o},lock:function(){return i=a=[],n||t||(o=n=""),this},locked:function(){return!!i},fireWith:function(e,n){return i||(n=[e,(n=n||[]).slice?n.slice():n],a.push(n),t||u()),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!r}};return l};function I(e){return e}function W(e){throw e}function $(e,t,n,r){var i;try{e&&g(i=e.promise)?i.call(e).done(t).fail(n):e&&g(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}w.extend({Deferred:function(t){var n=[["notify","progress",w.Callbacks("memory"),w.Callbacks("memory"),2],["resolve","done",w.Callbacks("once memory"),w.Callbacks("once memory"),0,"resolved"],["reject","fail",w.Callbacks("once memory"),w.Callbacks("once memory"),1,"rejected"]],r="pending",i={state:function(){return r},always:function(){return o.done(arguments).fail(arguments),this},"catch":function(e){return i.then(null,e)},pipe:function(){var e=arguments;return w.Deferred(function(t){w.each(n,function(n,r){var i=g(e[r[4]])&&e[r[4]];o[r[1]](function(){var e=i&&i.apply(this,arguments);e&&g(e.promise)?e.promise().progress(t.notify).done(t.resolve).fail(t.reject):t[r[0]+"With"](this,i?[e]:arguments)})}),e=null}).promise()},then:function(t,r,i){var o=0;function a(t,n,r,i){return function(){var s=this,u=arguments,l=function(){var e,l;if(!(t=o&&(r!==W&&(s=void 0,u=[e]),n.rejectWith(s,u))}};t?c():(w.Deferred.getStackHook&&(c.stackTrace=w.Deferred.getStackHook()),e.setTimeout(c))}}return w.Deferred(function(e){n[0][3].add(a(0,e,g(i)?i:I,e.notifyWith)),n[1][3].add(a(0,e,g(t)?t:I)),n[2][3].add(a(0,e,g(r)?r:W))}).promise()},promise:function(e){return null!=e?w.extend(e,i):i}},o={};return w.each(n,function(e,t){var a=t[2],s=t[5];i[t[1]]=a.add,s&&a.add(function(){r=s},n[3-e][2].disable,n[3-e][3].disable,n[0][2].lock,n[0][3].lock),a.add(t[3].fire),o[t[0]]=function(){return o[t[0]+"With"](this===o?void 0:this,arguments),this},o[t[0]+"With"]=a.fireWith}),i.promise(o),t&&t.call(o,o),o},when:function(e){var t=arguments.length,n=t,r=Array(n),i=o.call(arguments),a=w.Deferred(),s=function(e){return function(n){r[e]=this,i[e]=arguments.length>1?o.call(arguments):n,--t||a.resolveWith(r,i)}};if(t<=1&&($(e,a.done(s(n)).resolve,a.reject,!t),"pending"===a.state()||g(i[n]&&i[n].then)))return a.then();while(n--)$(i[n],s(n),a.reject);return a.promise()}});var B=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;w.Deferred.exceptionHook=function(t,n){e.console&&e.console.warn&&t&&B.test(t.name)&&e.console.warn("jQuery.Deferred exception: "+t.message,t.stack,n)},w.readyException=function(t){e.setTimeout(function(){throw t})};var F=w.Deferred();w.fn.ready=function(e){return F.then(e)["catch"](function(e){w.readyException(e)}),this},w.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--w.readyWait:w.isReady)||(w.isReady=!0,!0!==e&&--w.readyWait>0||F.resolveWith(r,[w]))}}),w.ready.then=F.then;function _(){r.removeEventListener("DOMContentLoaded",_),e.removeEventListener("load",_),w.ready()}"complete"===r.readyState||"loading"!==r.readyState&&!r.documentElement.doScroll?e.setTimeout(w.ready):(r.addEventListener("DOMContentLoaded",_),e.addEventListener("load",_));var z=function(e,t,n,r,i,o,a){var s=0,u=e.length,l=null==n;if("object"===x(n)){i=!0;for(s in n)z(e,t,s,n[s],!0,o,a)}else if(void 0!==r&&(i=!0,g(r)||(a=!0),l&&(a?(t.call(e,r),t=null):(l=t,t=function(e,t,n){return l.call(w(e),n)})),t))for(;s1,null,!0)},removeData:function(e){return this.each(function(){K.remove(this,e)})}}),w.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=J.get(e,t),n&&(!r||Array.isArray(n)?r=J.access(e,t,w.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=w.queue(e,t),r=n.length,i=n.shift(),o=w._queueHooks(e,t),a=function(){w.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return J.get(e,n)||J.access(e,n,{empty:w.Callbacks("once memory").add(function(){J.remove(e,[t+"queue",n])})})}}),w.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),arguments.length\x20\t\r\n\f]+)/i,he=/^$|^module$|\/(?:java|ecma)script/i,ge={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};ge.optgroup=ge.option,ge.tbody=ge.tfoot=ge.colgroup=ge.caption=ge.thead,ge.th=ge.td;function ye(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&N(e,t)?w.merge([e],n):n}function ve(e,t){for(var n=0,r=e.length;n-1)i&&i.push(o);else if(l=w.contains(o.ownerDocument,o),a=ye(f.appendChild(o),"script"),l&&ve(a),n){c=0;while(o=a[c++])he.test(o.type||"")&&n.push(o)}return f}!function(){var e=r.createDocumentFragment().appendChild(r.createElement("div")),t=r.createElement("input");t.setAttribute("type","radio"),t.setAttribute("checked","checked"),t.setAttribute("name","t"),e.appendChild(t),h.checkClone=e.cloneNode(!0).cloneNode(!0).lastChild.checked,e.innerHTML="",h.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue}();var be=r.documentElement,we=/^key/,Te=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Ce=/^([^.]*)(?:\.(.+)|)/;function Ee(){return!0}function ke(){return!1}function Se(){try{return r.activeElement}catch(e){}}function De(e,t,n,r,i,o){var a,s;if("object"==typeof t){"string"!=typeof n&&(r=r||n,n=void 0);for(s in t)De(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=ke;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return w().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=w.guid++)),e.each(function(){w.event.add(this,t,i,r,n)})}w.event={global:{},add:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.get(e);if(y){n.handler&&(n=(o=n).handler,i=o.selector),i&&w.find.matchesSelector(be,i),n.guid||(n.guid=w.guid++),(u=y.events)||(u=y.events={}),(a=y.handle)||(a=y.handle=function(t){return"undefined"!=typeof w&&w.event.triggered!==t.type?w.event.dispatch.apply(e,arguments):void 0}),l=(t=(t||"").match(M)||[""]).length;while(l--)d=g=(s=Ce.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=w.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=w.event.special[d]||{},c=w.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&w.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(e,r,h,a)||e.addEventListener&&e.addEventListener(d,a)),f.add&&(f.add.call(e,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),w.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.hasData(e)&&J.get(e);if(y&&(u=y.events)){l=(t=(t||"").match(M)||[""]).length;while(l--)if(s=Ce.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){f=w.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,y.handle)||w.removeEvent(e,d,y.handle),delete u[d])}else for(d in u)w.event.remove(e,d+t[l],n,r,!0);w.isEmptyObject(u)&&J.remove(e,"handle events")}},dispatch:function(e){var t=w.event.fix(e),n,r,i,o,a,s,u=new Array(arguments.length),l=(J.get(this,"events")||{})[t.type]||[],c=w.event.special[t.type]||{};for(u[0]=t,n=1;n=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n-1:w.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u\x20\t\r\n\f]*)[^>]*)\/>/gi,Ae=/\s*$/g;function Le(e,t){return N(e,"table")&&N(11!==t.nodeType?t:t.firstChild,"tr")?w(e).children("tbody")[0]||e:e}function He(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Oe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Pe(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(J.hasData(e)&&(o=J.access(e),a=J.set(t,o),l=o.events)){delete a.handle,a.events={};for(i in l)for(n=0,r=l[i].length;n1&&"string"==typeof y&&!h.checkClone&&je.test(y))return e.each(function(i){var o=e.eq(i);v&&(t[0]=y.call(this,i,o.html())),Re(o,t,n,r)});if(p&&(i=xe(t,e[0].ownerDocument,!1,e,r),o=i.firstChild,1===i.childNodes.length&&(i=o),o||r)){for(u=(s=w.map(ye(i,"script"),He)).length;f")},clone:function(e,t,n){var r,i,o,a,s=e.cloneNode(!0),u=w.contains(e.ownerDocument,e);if(!(h.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||w.isXMLDoc(e)))for(a=ye(s),r=0,i=(o=ye(e)).length;r0&&ve(a,!u&&ye(e,"script")),s},cleanData:function(e){for(var t,n,r,i=w.event.special,o=0;void 0!==(n=e[o]);o++)if(Y(n)){if(t=n[J.expando]){if(t.events)for(r in t.events)i[r]?w.event.remove(n,r):w.removeEvent(n,r,t.handle);n[J.expando]=void 0}n[K.expando]&&(n[K.expando]=void 0)}}}),w.fn.extend({detach:function(e){return Ie(this,e,!0)},remove:function(e){return Ie(this,e)},text:function(e){return z(this,function(e){return void 0===e?w.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return Re(this,arguments,function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Le(this,e).appendChild(e)})},prepend:function(){return Re(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Le(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(w.cleanData(ye(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return w.clone(this,e,t)})},html:function(e){return z(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!Ae.test(e)&&!ge[(de.exec(e)||["",""])[1].toLowerCase()]){e=w.htmlPrefilter(e);try{for(;n=0&&(u+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-u-s-.5))),u}function et(e,t,n){var r=$e(e),i=Fe(e,t,r),o="border-box"===w.css(e,"boxSizing",!1,r),a=o;if(We.test(i)){if(!n)return i;i="auto"}return a=a&&(h.boxSizingReliable()||i===e.style[t]),("auto"===i||!parseFloat(i)&&"inline"===w.css(e,"display",!1,r))&&(i=e["offset"+t[0].toUpperCase()+t.slice(1)],a=!0),(i=parseFloat(i)||0)+Ze(e,t,n||(o?"border":"content"),a,r,i)+"px"}w.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Fe(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=G(t),u=Xe.test(t),l=e.style;if(u||(t=Je(s)),a=w.cssHooks[t]||w.cssHooks[s],void 0===n)return a&&"get"in a&&void 0!==(i=a.get(e,!1,r))?i:l[t];"string"==(o=typeof n)&&(i=ie.exec(n))&&i[1]&&(n=ue(e,t,i),o="number"),null!=n&&n===n&&("number"===o&&(n+=i&&i[3]||(w.cssNumber[s]?"":"px")),h.clearCloneStyle||""!==n||0!==t.indexOf("background")||(l[t]="inherit"),a&&"set"in a&&void 0===(n=a.set(e,n,r))||(u?l.setProperty(t,n):l[t]=n))}},css:function(e,t,n,r){var i,o,a,s=G(t);return Xe.test(t)||(t=Je(s)),(a=w.cssHooks[t]||w.cssHooks[s])&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=Fe(e,t,r)),"normal"===i&&t in Ve&&(i=Ve[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),w.each(["height","width"],function(e,t){w.cssHooks[t]={get:function(e,n,r){if(n)return!ze.test(w.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?et(e,t,r):se(e,Ue,function(){return et(e,t,r)})},set:function(e,n,r){var i,o=$e(e),a="border-box"===w.css(e,"boxSizing",!1,o),s=r&&Ze(e,t,r,a,o);return a&&h.scrollboxSize()===o.position&&(s-=Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-parseFloat(o[t])-Ze(e,t,"border",!1,o)-.5)),s&&(i=ie.exec(n))&&"px"!==(i[3]||"px")&&(e.style[t]=n,n=w.css(e,t)),Ke(e,n,s)}}}),w.cssHooks.marginLeft=_e(h.reliableMarginLeft,function(e,t){if(t)return(parseFloat(Fe(e,"marginLeft"))||e.getBoundingClientRect().left-se(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),w.each({margin:"",padding:"",border:"Width"},function(e,t){w.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[e+oe[r]+t]=o[r]||o[r-2]||o[0];return i}},"margin"!==e&&(w.cssHooks[e+t].set=Ke)}),w.fn.extend({css:function(e,t){return z(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=$e(e),i=t.length;a1)}});function tt(e,t,n,r,i){return new tt.prototype.init(e,t,n,r,i)}w.Tween=tt,tt.prototype={constructor:tt,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||w.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(w.cssNumber[n]?"":"px")},cur:function(){var e=tt.propHooks[this.prop];return e&&e.get?e.get(this):tt.propHooks._default.get(this)},run:function(e){var t,n=tt.propHooks[this.prop];return this.options.duration?this.pos=t=w.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):tt.propHooks._default.set(this),this}},tt.prototype.init.prototype=tt.prototype,tt.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=w.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){w.fx.step[e.prop]?w.fx.step[e.prop](e):1!==e.elem.nodeType||null==e.elem.style[w.cssProps[e.prop]]&&!w.cssHooks[e.prop]?e.elem[e.prop]=e.now:w.style(e.elem,e.prop,e.now+e.unit)}}},tt.propHooks.scrollTop=tt.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},w.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},w.fx=tt.prototype.init,w.fx.step={};var nt,rt,it=/^(?:toggle|show|hide)$/,ot=/queueHooks$/;function at(){rt&&(!1===r.hidden&&e.requestAnimationFrame?e.requestAnimationFrame(at):e.setTimeout(at,w.fx.interval),w.fx.tick())}function st(){return e.setTimeout(function(){nt=void 0}),nt=Date.now()}function ut(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)i["margin"+(n=oe[r])]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function lt(e,t,n){for(var r,i=(pt.tweeners[t]||[]).concat(pt.tweeners["*"]),o=0,a=i.length;o1)},removeAttr:function(e){return this.each(function(){w.removeAttr(this,e)})}}),w.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return"undefined"==typeof e.getAttribute?w.prop(e,t,n):(1===o&&w.isXMLDoc(e)||(i=w.attrHooks[t.toLowerCase()]||(w.expr.match.bool.test(t)?dt:void 0)),void 0!==n?null===n?void w.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:null==(r=w.find.attr(e,t))?void 0:r)},attrHooks:{type:{set:function(e,t){if(!h.radioValue&&"radio"===t&&N(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(M);if(i&&1===e.nodeType)while(n=i[r++])e.removeAttribute(n)}}),dt={set:function(e,t,n){return!1===t?w.removeAttr(e,n):e.setAttribute(n,n),n}},w.each(w.expr.match.bool.source.match(/\w+/g),function(e,t){var n=ht[t]||w.find.attr;ht[t]=function(e,t,r){var i,o,a=t.toLowerCase();return r||(o=ht[a],ht[a]=i,i=null!=n(e,t,r)?a:null,ht[a]=o),i}});var gt=/^(?:input|select|textarea|button)$/i,yt=/^(?:a|area)$/i;w.fn.extend({prop:function(e,t){return z(this,w.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[w.propFix[e]||e]})}}),w.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&w.isXMLDoc(e)||(t=w.propFix[t]||t,i=w.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=w.find.attr(e,"tabindex");return t?parseInt(t,10):gt.test(e.nodeName)||yt.test(e.nodeName)&&e.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),h.optSelected||(w.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),w.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){w.propFix[this.toLowerCase()]=this});function vt(e){return(e.match(M)||[]).join(" ")}function mt(e){return e.getAttribute&&e.getAttribute("class")||""}function xt(e){return Array.isArray(e)?e:"string"==typeof e?e.match(M)||[]:[]}w.fn.extend({addClass:function(e){var t,n,r,i,o,a,s,u=0;if(g(e))return this.each(function(t){w(this).addClass(e.call(this,t,mt(this)))});if((t=xt(e)).length)while(n=this[u++])if(i=mt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=t[a++])r.indexOf(" "+o+" ")<0&&(r+=o+" ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},removeClass:function(e){var t,n,r,i,o,a,s,u=0;if(g(e))return this.each(function(t){w(this).removeClass(e.call(this,t,mt(this)))});if(!arguments.length)return this.attr("class","");if((t=xt(e)).length)while(n=this[u++])if(i=mt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=t[a++])while(r.indexOf(" "+o+" ")>-1)r=r.replace(" "+o+" "," ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},toggleClass:function(e,t){var n=typeof e,r="string"===n||Array.isArray(e);return"boolean"==typeof t&&r?t?this.addClass(e):this.removeClass(e):g(e)?this.each(function(n){w(this).toggleClass(e.call(this,n,mt(this),t),t)}):this.each(function(){var t,i,o,a;if(r){i=0,o=w(this),a=xt(e);while(t=a[i++])o.hasClass(t)?o.removeClass(t):o.addClass(t)}else void 0!==e&&"boolean"!==n||((t=mt(this))&&J.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":J.get(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;t=" "+e+" ";while(n=this[r++])if(1===n.nodeType&&(" "+vt(mt(n))+" ").indexOf(t)>-1)return!0;return!1}});var bt=/\r/g;w.fn.extend({val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=g(e),this.each(function(n){var i;1===this.nodeType&&(null==(i=r?e.call(this,n,w(this).val()):e)?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=w.map(i,function(e){return null==e?"":e+""})),(t=w.valHooks[this.type]||w.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))});if(i)return(t=w.valHooks[i.type]||w.valHooks[i.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:"string"==typeof(n=i.value)?n.replace(bt,""):null==n?"":n}}}),w.extend({valHooks:{option:{get:function(e){var t=w.find.attr(e,"value");return null!=t?t:vt(w.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r-1)&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),w.each(["radio","checkbox"],function(){w.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=w.inArray(w(e).val(),t)>-1}},h.checkOn||(w.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})}),h.focusin="onfocusin"in e;var wt=/^(?:focusinfocus|focusoutblur)$/,Tt=function(e){e.stopPropagation()};w.extend(w.event,{trigger:function(t,n,i,o){var a,s,u,l,c,p,d,h,v=[i||r],m=f.call(t,"type")?t.type:t,x=f.call(t,"namespace")?t.namespace.split("."):[];if(s=h=u=i=i||r,3!==i.nodeType&&8!==i.nodeType&&!wt.test(m+w.event.triggered)&&(m.indexOf(".")>-1&&(m=(x=m.split(".")).shift(),x.sort()),c=m.indexOf(":")<0&&"on"+m,t=t[w.expando]?t:new w.Event(m,"object"==typeof t&&t),t.isTrigger=o?2:3,t.namespace=x.join("."),t.rnamespace=t.namespace?new RegExp("(^|\\.)"+x.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=i),n=null==n?[t]:w.makeArray(n,[t]),d=w.event.special[m]||{},o||!d.trigger||!1!==d.trigger.apply(i,n))){if(!o&&!d.noBubble&&!y(i)){for(l=d.delegateType||m,wt.test(l+m)||(s=s.parentNode);s;s=s.parentNode)v.push(s),u=s;u===(i.ownerDocument||r)&&v.push(u.defaultView||u.parentWindow||e)}a=0;while((s=v[a++])&&!t.isPropagationStopped())h=s,t.type=a>1?l:d.bindType||m,(p=(J.get(s,"events")||{})[t.type]&&J.get(s,"handle"))&&p.apply(s,n),(p=c&&s[c])&&p.apply&&Y(s)&&(t.result=p.apply(s,n),!1===t.result&&t.preventDefault());return t.type=m,o||t.isDefaultPrevented()||d._default&&!1!==d._default.apply(v.pop(),n)||!Y(i)||c&&g(i[m])&&!y(i)&&((u=i[c])&&(i[c]=null),w.event.triggered=m,t.isPropagationStopped()&&h.addEventListener(m,Tt),i[m](),t.isPropagationStopped()&&h.removeEventListener(m,Tt),w.event.triggered=void 0,u&&(i[c]=u)),t.result}},simulate:function(e,t,n){var r=w.extend(new w.Event,n,{type:e,isSimulated:!0});w.event.trigger(r,null,t)}}),w.fn.extend({trigger:function(e,t){return this.each(function(){w.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return w.event.trigger(e,t,n,!0)}}),h.focusin||w.each({focus:"focusin",blur:"focusout"},function(e,t){var n=function(e){w.event.simulate(t,e.target,w.event.fix(e))};w.event.special[t]={setup:function(){var r=this.ownerDocument||this,i=J.access(r,t);i||r.addEventListener(e,n,!0),J.access(r,t,(i||0)+1)},teardown:function(){var r=this.ownerDocument||this,i=J.access(r,t)-1;i?J.access(r,t,i):(r.removeEventListener(e,n,!0),J.remove(r,t))}}});var Ct=e.location,Et=Date.now(),kt=/\?/;w.parseXML=function(t){var n;if(!t||"string"!=typeof t)return null;try{n=(new e.DOMParser).parseFromString(t,"text/xml")}catch(e){n=void 0}return n&&!n.getElementsByTagName("parsererror").length||w.error("Invalid XML: "+t),n};var St=/\[\]$/,Dt=/\r?\n/g,Nt=/^(?:submit|button|image|reset|file)$/i,At=/^(?:input|select|textarea|keygen)/i;function jt(e,t,n,r){var i;if(Array.isArray(t))w.each(t,function(t,i){n||St.test(e)?r(e,i):jt(e+"["+("object"==typeof i&&null!=i?t:"")+"]",i,n,r)});else if(n||"object"!==x(t))r(e,t);else for(i in t)jt(e+"["+i+"]",t[i],n,r)}w.param=function(e,t){var n,r=[],i=function(e,t){var n=g(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(Array.isArray(e)||e.jquery&&!w.isPlainObject(e))w.each(e,function(){i(this.name,this.value)});else for(n in e)jt(n,e[n],t,i);return r.join("&")},w.fn.extend({serialize:function(){return w.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=w.prop(this,"elements");return e?w.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!w(this).is(":disabled")&&At.test(this.nodeName)&&!Nt.test(e)&&(this.checked||!pe.test(e))}).map(function(e,t){var n=w(this).val();return null==n?null:Array.isArray(n)?w.map(n,function(e){return{name:t.name,value:e.replace(Dt,"\r\n")}}):{name:t.name,value:n.replace(Dt,"\r\n")}}).get()}});var qt=/%20/g,Lt=/#.*$/,Ht=/([?&])_=[^&]*/,Ot=/^(.*?):[ \t]*([^\r\n]*)$/gm,Pt=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Mt=/^(?:GET|HEAD)$/,Rt=/^\/\//,It={},Wt={},$t="*/".concat("*"),Bt=r.createElement("a");Bt.href=Ct.href;function Ft(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(M)||[];if(g(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function _t(e,t,n,r){var i={},o=e===Wt;function a(s){var u;return i[s]=!0,w.each(e[s]||[],function(e,s){var l=s(t,n,r);return"string"!=typeof l||o||i[l]?o?!(u=l):void 0:(t.dataTypes.unshift(l),a(l),!1)}),u}return a(t.dataTypes[0])||!i["*"]&&a("*")}function zt(e,t){var n,r,i=w.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&w.extend(!0,e,r),e}function Xt(e,t,n){var r,i,o,a,s=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}function Ut(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o]))for(i in l)if((s=i.split(" "))[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}w.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Ct.href,type:"GET",isLocal:Pt.test(Ct.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":$t,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":w.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?zt(zt(e,w.ajaxSettings),t):zt(w.ajaxSettings,e)},ajaxPrefilter:Ft(It),ajaxTransport:Ft(Wt),ajax:function(t,n){"object"==typeof t&&(n=t,t=void 0),n=n||{};var i,o,a,s,u,l,c,f,p,d,h=w.ajaxSetup({},n),g=h.context||h,y=h.context&&(g.nodeType||g.jquery)?w(g):w.event,v=w.Deferred(),m=w.Callbacks("once memory"),x=h.statusCode||{},b={},T={},C="canceled",E={readyState:0,getResponseHeader:function(e){var t;if(c){if(!s){s={};while(t=Ot.exec(a))s[t[1].toLowerCase()]=t[2]}t=s[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return c?a:null},setRequestHeader:function(e,t){return null==c&&(e=T[e.toLowerCase()]=T[e.toLowerCase()]||e,b[e]=t),this},overrideMimeType:function(e){return null==c&&(h.mimeType=e),this},statusCode:function(e){var t;if(e)if(c)E.always(e[E.status]);else for(t in e)x[t]=[x[t],e[t]];return this},abort:function(e){var t=e||C;return i&&i.abort(t),k(0,t),this}};if(v.promise(E),h.url=((t||h.url||Ct.href)+"").replace(Rt,Ct.protocol+"//"),h.type=n.method||n.type||h.method||h.type,h.dataTypes=(h.dataType||"*").toLowerCase().match(M)||[""],null==h.crossDomain){l=r.createElement("a");try{l.href=h.url,l.href=l.href,h.crossDomain=Bt.protocol+"//"+Bt.host!=l.protocol+"//"+l.host}catch(e){h.crossDomain=!0}}if(h.data&&h.processData&&"string"!=typeof h.data&&(h.data=w.param(h.data,h.traditional)),_t(It,h,n,E),c)return E;(f=w.event&&h.global)&&0==w.active++&&w.event.trigger("ajaxStart"),h.type=h.type.toUpperCase(),h.hasContent=!Mt.test(h.type),o=h.url.replace(Lt,""),h.hasContent?h.data&&h.processData&&0===(h.contentType||"").indexOf("application/x-www-form-urlencoded")&&(h.data=h.data.replace(qt,"+")):(d=h.url.slice(o.length),h.data&&(h.processData||"string"==typeof h.data)&&(o+=(kt.test(o)?"&":"?")+h.data,delete h.data),!1===h.cache&&(o=o.replace(Ht,"$1"),d=(kt.test(o)?"&":"?")+"_="+Et+++d),h.url=o+d),h.ifModified&&(w.lastModified[o]&&E.setRequestHeader("If-Modified-Since",w.lastModified[o]),w.etag[o]&&E.setRequestHeader("If-None-Match",w.etag[o])),(h.data&&h.hasContent&&!1!==h.contentType||n.contentType)&&E.setRequestHeader("Content-Type",h.contentType),E.setRequestHeader("Accept",h.dataTypes[0]&&h.accepts[h.dataTypes[0]]?h.accepts[h.dataTypes[0]]+("*"!==h.dataTypes[0]?", "+$t+"; q=0.01":""):h.accepts["*"]);for(p in h.headers)E.setRequestHeader(p,h.headers[p]);if(h.beforeSend&&(!1===h.beforeSend.call(g,E,h)||c))return E.abort();if(C="abort",m.add(h.complete),E.done(h.success),E.fail(h.error),i=_t(Wt,h,n,E)){if(E.readyState=1,f&&y.trigger("ajaxSend",[E,h]),c)return E;h.async&&h.timeout>0&&(u=e.setTimeout(function(){E.abort("timeout")},h.timeout));try{c=!1,i.send(b,k)}catch(e){if(c)throw e;k(-1,e)}}else k(-1,"No Transport");function k(t,n,r,s){var l,p,d,b,T,C=n;c||(c=!0,u&&e.clearTimeout(u),i=void 0,a=s||"",E.readyState=t>0?4:0,l=t>=200&&t<300||304===t,r&&(b=Xt(h,E,r)),b=Ut(h,b,E,l),l?(h.ifModified&&((T=E.getResponseHeader("Last-Modified"))&&(w.lastModified[o]=T),(T=E.getResponseHeader("etag"))&&(w.etag[o]=T)),204===t||"HEAD"===h.type?C="nocontent":304===t?C="notmodified":(C=b.state,p=b.data,l=!(d=b.error))):(d=C,!t&&C||(C="error",t<0&&(t=0))),E.status=t,E.statusText=(n||C)+"",l?v.resolveWith(g,[p,C,E]):v.rejectWith(g,[E,C,d]),E.statusCode(x),x=void 0,f&&y.trigger(l?"ajaxSuccess":"ajaxError",[E,h,l?p:d]),m.fireWith(g,[E,C]),f&&(y.trigger("ajaxComplete",[E,h]),--w.active||w.event.trigger("ajaxStop")))}return E},getJSON:function(e,t,n){return w.get(e,t,n,"json")},getScript:function(e,t){return w.get(e,void 0,t,"script")}}),w.each(["get","post"],function(e,t){w[t]=function(e,n,r,i){return g(n)&&(i=i||r,r=n,n=void 0),w.ajax(w.extend({url:e,type:t,dataType:i,data:n,success:r},w.isPlainObject(e)&&e))}}),w._evalUrl=function(e){return w.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},w.fn.extend({wrapAll:function(e){var t;return this[0]&&(g(e)&&(e=e.call(this[0])),t=w(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstElementChild)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return g(e)?this.each(function(t){w(this).wrapInner(e.call(this,t))}):this.each(function(){var t=w(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=g(e);return this.each(function(n){w(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){w(this).replaceWith(this.childNodes)}),this}}),w.expr.pseudos.hidden=function(e){return!w.expr.pseudos.visible(e)},w.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},w.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch(e){}};var Vt={0:200,1223:204},Gt=w.ajaxSettings.xhr();h.cors=!!Gt&&"withCredentials"in Gt,h.ajax=Gt=!!Gt,w.ajaxTransport(function(t){var n,r;if(h.cors||Gt&&!t.crossDomain)return{send:function(i,o){var a,s=t.xhr();if(s.open(t.type,t.url,t.async,t.username,t.password),t.xhrFields)for(a in t.xhrFields)s[a]=t.xhrFields[a];t.mimeType&&s.overrideMimeType&&s.overrideMimeType(t.mimeType),t.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");for(a in i)s.setRequestHeader(a,i[a]);n=function(e){return function(){n&&(n=r=s.onload=s.onerror=s.onabort=s.ontimeout=s.onreadystatechange=null,"abort"===e?s.abort():"error"===e?"number"!=typeof s.status?o(0,"error"):o(s.status,s.statusText):o(Vt[s.status]||s.status,s.statusText,"text"!==(s.responseType||"text")||"string"!=typeof s.responseText?{binary:s.response}:{text:s.responseText},s.getAllResponseHeaders()))}},s.onload=n(),r=s.onerror=s.ontimeout=n("error"),void 0!==s.onabort?s.onabort=r:s.onreadystatechange=function(){4===s.readyState&&e.setTimeout(function(){n&&r()})},n=n("abort");try{s.send(t.hasContent&&t.data||null)}catch(e){if(n)throw e}},abort:function(){n&&n()}}}),w.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),w.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return w.globalEval(e),e}}}),w.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),w.ajaxTransport("script",function(e){if(e.crossDomain){var t,n;return{send:function(i,o){t=w(" + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + DayDay's Studio. +
+
+
+ + + + + + +
+
+
+ +

+ + + DayDay's Studio. + + +

+ +

+ + + + If you don't STRUGGLE, you don't improve. + + + +

+ + +
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ avatar +
DayDay 卡比兽
+ +
+ 鲤鱼王型前端程序员成长历程 +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ ABOUT ME +
+ +
+ +
+
+ + + + + + + + +
+ + + PV: :) + +
+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/placeholder b/placeholder deleted file mode 100644 index e69de29..0000000 diff --git a/scripts/main.js b/scripts/main.js new file mode 100644 index 0000000..1de621d --- /dev/null +++ b/scripts/main.js @@ -0,0 +1,4003 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 2); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var archerUtil = { + // 回到顶部 + backTop: function backTop(event) { + event.preventDefault(); + var topTimer = setInterval(function () { + var currTop = $(document).scrollTop(); + window.scrollTo(0, Math.max(Math.floor(currTop * 0.8))); + + if (currTop === 0) { + clearInterval(topTimer); + } + }, 20); + }, + // 获取元素在页面上相对左上角的位置 + getAbsPosition: function getAbsPosition(e) { + var x = e.offsetLeft, + y = e.offsetTop; + + while (e = e.offsetParent) { + x += e.offsetLeft; + y += e.offsetTop; + } + + return { + x: x, + y: y + }; + }, + // 格式化日期 + dateFormater: function dateFormater(date, fmt) { + var o = { + 'M+': date.getMonth() + 1, + // 月份 + 'd+': date.getDate(), + // 日 + 'h+': date.getHours(), + // 小时 + 'm+': date.getMinutes(), + // 分 + 's+': date.getSeconds(), + // 秒 + 'q+': Math.floor((date.getMonth() + 3) / 3), + // 季度 + S: date.getMilliseconds() // 毫秒 + + }; + + if (/(y+)/.test(fmt)) { + fmt = fmt.replace(RegExp.$1, String(date.getFullYear()).substr(4 - RegExp.$1.length)); + } + + for (var k in o) { + if (new RegExp('(' + k + ')').test(fmt)) { + fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(String(o[k]).length)); + } + } + + return fmt; + }, + // rAF的ticking + rafTick: function rafTick(ticking, updateFunc) { + if (!ticking) { + requestAnimationFrame(updateFunc); + } + + ticking = true; + } +}; +var _default = archerUtil; +exports.default = _default; + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _sidebar = _interopRequireDefault(__webpack_require__(6)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var mySidebar = new _sidebar.default({ + sidebar: '.sidebar', + nav: '.sidebar-tabs', + tabs: '.sidebar-tabs li', + content: '.sidebar-content', + panels: '.sideabar-contents > div', + menuButton: '.header-sidebar-menu' +}); +var _default = mySidebar; +exports.default = _default; + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _init = _interopRequireDefault(__webpack_require__(3)); + +var _scroll = __webpack_require__(5); + +__webpack_require__(1); + +var _mobile = __webpack_require__(8); + +var _tag = _interopRequireDefault(__webpack_require__(9)); + +var _toc = _interopRequireDefault(__webpack_require__(16)); + +var _fancybox = _interopRequireDefault(__webpack_require__(17)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var logStyle = 'color: #fff; background: #f75357; padding: 1px; border-radius: 5px;'; +console.info('%c 🎯 hexo-theme-archer ⬇️ ', logStyle); +console.info('%c 🏷 Version: 1.6.1 ', logStyle); +console.info('%c 📅 Version date: 20180830 ', logStyle); +console.info('%c 📦 https://github.com/fi3ework/hexo-theme-archer ', logStyle); // remove background placeholder + +(0, _init.default)(); // scroll event + +(0, _scroll.scroll)(); // init sidebar link + +var metas = new _tag.default(); +metas.addTab({ + metaName: 'tags', + labelsContainer: '.sidebar-tags-name', + postsContainer: '.sidebar-tags-list' +}); +metas.addTab({ + metaName: 'categories', + labelsContainer: '.sidebar-categories-name', + postsContainer: '.sidebar-categories-list' +}); // init toc + +window.addEventListener('load', function (event) { + console.log('All resources finished loading!'); + (0, _toc.default)(); +}); +(0, _mobile.initMobile)(); // initSearch() +// fancybox + +(0, _fancybox.default)(); + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _anchorJs = _interopRequireDefault(__webpack_require__(4)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var init = function init() { + var $introImg = $('.site-intro-img:first'), + introPlaceholder = $('.site-intro-placeholder:first'), + bgCSS = $introImg.css('background-image'), + bgRegResult = bgCSS.match(/url\("*([^"]*)"*\)/); + + if (bgRegResult.length < 2) { + console.log('...'); + console.log(bgRegResult); + return; + } + + var bgURL = bgRegResult[1], + img = new Image(); + + img.onload = function () { + // window.alert() + // setTimeout(function () { + introPlaceholder.remove(); // }, 100) + + console.info('PLACEHOLDER REMOVED'); + }; + + img.src = bgURL; + document.addEventListener('DOMContentLoaded', function () { + $('.container').removeClass('container-unloaded'); + $('.footer').removeClass('footer-unloaded'); + $('.loading').remove(); + }, false); // https://www.bryanbraun.com/anchorjs/ + + var anchors = new _anchorJs.default(); + anchors.options = { + placement: 'right', + class: 'anchorjs-archer' + }; + anchors.add(); +}; + +var _default = init; +exports.default = _default; + +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + +var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* eslint-env amd, node */ + +// https://github.com/umdjs/umd/blob/master/templates/returnExports.js +(function (root, factory) { + 'use strict'; + + if (true) { + // AMD. Register as an anonymous module. + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), + __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? + (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else if (typeof module === 'object' && module.exports) { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like environments that support module.exports, + // like Node. + module.exports = factory(); + } else { + // Browser globals (root is window) + root.AnchorJS = factory(); + root.anchors = new root.AnchorJS(); + } +}(this, function () { + 'use strict'; + + function AnchorJS(options) { + this.options = options || {}; + this.elements = []; + + /** + * Assigns options to the internal options object, and provides defaults. + * @param {Object} opts - Options object + */ + function _applyRemainingDefaultOptions(opts) { + opts.icon = opts.hasOwnProperty('icon') ? opts.icon : '\ue9cb'; // Accepts characters (and also URLs?), like '#', '¶', '❡', or '§'. + opts.visible = opts.hasOwnProperty('visible') ? opts.visible : 'hover'; // Also accepts 'always' & 'touch' + opts.placement = opts.hasOwnProperty('placement') ? opts.placement : 'right'; // Also accepts 'left' + opts.ariaLabel = opts.hasOwnProperty('ariaLabel') ? opts.ariaLabel : 'Anchor'; // Accepts any text. + opts.class = opts.hasOwnProperty('class') ? opts.class : ''; // Accepts any class name. + // Using Math.floor here will ensure the value is Number-cast and an integer. + opts.truncate = opts.hasOwnProperty('truncate') ? Math.floor(opts.truncate) : 64; // Accepts any value that can be typecast to a number. + } + + _applyRemainingDefaultOptions(this.options); + + /** + * Checks to see if this device supports touch. Uses criteria pulled from Modernizr: + * https://github.com/Modernizr/Modernizr/blob/da22eb27631fc4957f67607fe6042e85c0a84656/feature-detects/touchevents.js#L40 + * @return {Boolean} - true if the current device supports touch. + */ + this.isTouchDevice = function() { + return !!(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch); + }; + + /** + * Add anchor links to page elements. + * @param {String|Array|Nodelist} selector - A CSS selector for targeting the elements you wish to add anchor links + * to. Also accepts an array or nodeList containing the relavant elements. + * @return {this} - The AnchorJS object + */ + this.add = function(selector) { + var elements, + elsWithIds, + idList, + elementID, + i, + index, + count, + tidyText, + newTidyText, + readableID, + anchor, + visibleOptionToUse, + indexesToDrop = []; + + // We reapply options here because somebody may have overwritten the default options object when setting options. + // For example, this overwrites all options but visible: + // + // anchors.options = { visible: 'always'; } + _applyRemainingDefaultOptions(this.options); + + visibleOptionToUse = this.options.visible; + if (visibleOptionToUse === 'touch') { + visibleOptionToUse = this.isTouchDevice() ? 'always' : 'hover'; + } + + // Provide a sensible default selector, if none is given. + if (!selector) { + selector = 'h2, h3, h4, h5, h6'; + } + + elements = _getElements(selector); + + if (elements.length === 0) { + return this; + } + + _addBaselineStyles(); + + // We produce a list of existing IDs so we don't generate a duplicate. + elsWithIds = document.querySelectorAll('[id]'); + idList = [].map.call(elsWithIds, function assign(el) { + return el.id; + }); + + for (i = 0; i < elements.length; i++) { + if (this.hasAnchorJSLink(elements[i])) { + indexesToDrop.push(i); + continue; + } + + if (elements[i].hasAttribute('id')) { + elementID = elements[i].getAttribute('id'); + } else if (elements[i].hasAttribute('data-anchor-id')) { + elementID = elements[i].getAttribute('data-anchor-id'); + } else { + tidyText = this.urlify(elements[i].textContent); + + // Compare our generated ID to existing IDs (and increment it if needed) + // before we add it to the page. + newTidyText = tidyText; + count = 0; + do { + if (index !== undefined) { + newTidyText = tidyText + '-' + count; + } + + index = idList.indexOf(newTidyText); + count += 1; + } while (index !== -1); + index = undefined; + idList.push(newTidyText); + + elements[i].setAttribute('id', newTidyText); + elementID = newTidyText; + } + + readableID = elementID.replace(/-/g, ' '); + + // The following code builds the following DOM structure in a more effiecient (albeit opaque) way. + // ''; + anchor = document.createElement('a'); + anchor.className = 'anchorjs-link ' + this.options.class; + anchor.href = '#' + elementID; + anchor.setAttribute('aria-label', this.options.ariaLabel); + anchor.setAttribute('data-anchorjs-icon', this.options.icon); + + if (visibleOptionToUse === 'always') { + anchor.style.opacity = '1'; + } + + if (this.options.icon === '\ue9cb') { + anchor.style.font = '1em/1 anchorjs-icons'; + + // We set lineHeight = 1 here because the `anchorjs-icons` font family could otherwise affect the + // height of the heading. This isn't the case for icons with `placement: left`, so we restore + // line-height: inherit in that case, ensuring they remain positioned correctly. For more info, + // see https://github.com/bryanbraun/anchorjs/issues/39. + if (this.options.placement === 'left') { + anchor.style.lineHeight = 'inherit'; + } + } + + if (this.options.placement === 'left') { + anchor.style.position = 'absolute'; + anchor.style.marginLeft = '-1em'; + anchor.style.paddingRight = '0.5em'; + elements[i].insertBefore(anchor, elements[i].firstChild); + } else { // if the option provided is `right` (or anything else). + anchor.style.paddingLeft = '0.375em'; + elements[i].appendChild(anchor); + } + } + + for (i = 0; i < indexesToDrop.length; i++) { + elements.splice(indexesToDrop[i] - i, 1); + } + this.elements = this.elements.concat(elements); + + return this; + }; + + /** + * Removes all anchorjs-links from elements targed by the selector. + * @param {String|Array|Nodelist} selector - A CSS selector string targeting elements with anchor links, + * OR a nodeList / array containing the DOM elements. + * @return {this} - The AnchorJS object + */ + this.remove = function(selector) { + var index, + domAnchor, + elements = _getElements(selector); + + for (var i = 0; i < elements.length; i++) { + domAnchor = elements[i].querySelector('.anchorjs-link'); + if (domAnchor) { + // Drop the element from our main list, if it's in there. + index = this.elements.indexOf(elements[i]); + if (index !== -1) { + this.elements.splice(index, 1); + } + // Remove the anchor from the DOM. + elements[i].removeChild(domAnchor); + } + } + return this; + }; + + /** + * Removes all anchorjs links. Mostly used for tests. + */ + this.removeAll = function() { + this.remove(this.elements); + }; + + /** + * Urlify - Refine text so it makes a good ID. + * + * To do this, we remove apostrophes, replace nonsafe characters with hyphens, + * remove extra hyphens, truncate, trim hyphens, and make lowercase. + * + * @param {String} text - Any text. Usually pulled from the webpage element we are linking to. + * @return {String} - hyphen-delimited text for use in IDs and URLs. + */ + this.urlify = function(text) { + // Regex for finding the nonsafe URL characters (many need escaping): & +$,:;=?@"#{}|^~[`%!'<>]./()*\ + var nonsafeChars = /[& +$,:;=?@"#{}|^~[`%!'<>\]\.\/\(\)\*\\]/g, + urlText; + + // The reason we include this _applyRemainingDefaultOptions is so urlify can be called independently, + // even after setting options. This can be useful for tests or other applications. + if (!this.options.truncate) { + _applyRemainingDefaultOptions(this.options); + } + + // Note: we trim hyphens after truncating because truncating can cause dangling hyphens. + // Example string: // " ⚡⚡ Don't forget: URL fragments should be i18n-friendly, hyphenated, short, and clean." + urlText = text.trim() // "⚡⚡ Don't forget: URL fragments should be i18n-friendly, hyphenated, short, and clean." + .replace(/\'/gi, '') // "⚡⚡ Dont forget: URL fragments should be i18n-friendly, hyphenated, short, and clean." + .replace(nonsafeChars, '-') // "⚡⚡-Dont-forget--URL-fragments-should-be-i18n-friendly--hyphenated--short--and-clean-" + .replace(/-{2,}/g, '-') // "⚡⚡-Dont-forget-URL-fragments-should-be-i18n-friendly-hyphenated-short-and-clean-" + .substring(0, this.options.truncate) // "⚡⚡-Dont-forget-URL-fragments-should-be-i18n-friendly-hyphenated-" + .replace(/^-+|-+$/gm, '') // "⚡⚡-Dont-forget-URL-fragments-should-be-i18n-friendly-hyphenated" + .toLowerCase(); // "⚡⚡-dont-forget-url-fragments-should-be-i18n-friendly-hyphenated" + + return urlText; + }; + + /** + * Determines if this element already has an AnchorJS link on it. + * Uses this technique: http://stackoverflow.com/a/5898748/1154642 + * @param {HTMLElemnt} el - a DOM node + * @return {Boolean} true/false + */ + this.hasAnchorJSLink = function(el) { + var hasLeftAnchor = el.firstChild && ((' ' + el.firstChild.className + ' ').indexOf(' anchorjs-link ') > -1), + hasRightAnchor = el.lastChild && ((' ' + el.lastChild.className + ' ').indexOf(' anchorjs-link ') > -1); + + return hasLeftAnchor || hasRightAnchor || false; + }; + + /** + * Turns a selector, nodeList, or array of elements into an array of elements (so we can use array methods). + * It also throws errors on any other inputs. Used to handle inputs to .add and .remove. + * @param {String|Array|Nodelist} input - A CSS selector string targeting elements with anchor links, + * OR a nodeList / array containing the DOM elements. + * @return {Array} - An array containing the elements we want. + */ + function _getElements(input) { + var elements; + if (typeof input === 'string' || input instanceof String) { + // See https://davidwalsh.name/nodelist-array for the technique transforming nodeList -> Array. + elements = [].slice.call(document.querySelectorAll(input)); + // I checked the 'input instanceof NodeList' test in IE9 and modern browsers and it worked for me. + } else if (Array.isArray(input) || input instanceof NodeList) { + elements = [].slice.call(input); + } else { + throw new Error('The selector provided to AnchorJS was invalid.'); + } + return elements; + } + + /** + * _addBaselineStyles + * Adds baseline styles to the page, used by all AnchorJS links irregardless of configuration. + */ + function _addBaselineStyles() { + // We don't want to add global baseline styles if they've been added before. + if (document.head.querySelector('style.anchorjs') !== null) { + return; + } + + var style = document.createElement('style'), + linkRule = + ' .anchorjs-link {' + + ' opacity: 0;' + + ' text-decoration: none;' + + ' -webkit-font-smoothing: antialiased;' + + ' -moz-osx-font-smoothing: grayscale;' + + ' }', + hoverRule = + ' *:hover > .anchorjs-link,' + + ' .anchorjs-link:focus {' + + ' opacity: 1;' + + ' }', + anchorjsLinkFontFace = + ' @font-face {' + + ' font-family: "anchorjs-icons";' + // Icon from icomoon; 10px wide & 10px tall; 2 empty below & 4 above + ' src: url(data:n/a;base64,AAEAAAALAIAAAwAwT1MvMg8yG2cAAAE4AAAAYGNtYXDp3gC3AAABpAAAAExnYXNwAAAAEAAAA9wAAAAIZ2x5ZlQCcfwAAAH4AAABCGhlYWQHFvHyAAAAvAAAADZoaGVhBnACFwAAAPQAAAAkaG10eASAADEAAAGYAAAADGxvY2EACACEAAAB8AAAAAhtYXhwAAYAVwAAARgAAAAgbmFtZQGOH9cAAAMAAAAAunBvc3QAAwAAAAADvAAAACAAAQAAAAEAAHzE2p9fDzz1AAkEAAAAAADRecUWAAAAANQA6R8AAAAAAoACwAAAAAgAAgAAAAAAAAABAAADwP/AAAACgAAA/9MCrQABAAAAAAAAAAAAAAAAAAAAAwABAAAAAwBVAAIAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAMCQAGQAAUAAAKZAswAAACPApkCzAAAAesAMwEJAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAQAAg//0DwP/AAEADwABAAAAAAQAAAAAAAAAAAAAAIAAAAAAAAAIAAAACgAAxAAAAAwAAAAMAAAAcAAEAAwAAABwAAwABAAAAHAAEADAAAAAIAAgAAgAAACDpy//9//8AAAAg6cv//f///+EWNwADAAEAAAAAAAAAAAAAAAAACACEAAEAAAAAAAAAAAAAAAAxAAACAAQARAKAAsAAKwBUAAABIiYnJjQ3NzY2MzIWFxYUBwcGIicmNDc3NjQnJiYjIgYHBwYUFxYUBwYGIwciJicmNDc3NjIXFhQHBwYUFxYWMzI2Nzc2NCcmNDc2MhcWFAcHBgYjARQGDAUtLXoWOR8fORYtLTgKGwoKCjgaGg0gEhIgDXoaGgkJBQwHdR85Fi0tOAobCgoKOBoaDSASEiANehoaCQkKGwotLXoWOR8BMwUFLYEuehYXFxYugC44CQkKGwo4GkoaDQ0NDXoaShoKGwoFBe8XFi6ALjgJCQobCjgaShoNDQ0NehpKGgobCgoKLYEuehYXAAAADACWAAEAAAAAAAEACAAAAAEAAAAAAAIAAwAIAAEAAAAAAAMACAAAAAEAAAAAAAQACAAAAAEAAAAAAAUAAQALAAEAAAAAAAYACAAAAAMAAQQJAAEAEAAMAAMAAQQJAAIABgAcAAMAAQQJAAMAEAAMAAMAAQQJAAQAEAAMAAMAAQQJAAUAAgAiAAMAAQQJAAYAEAAMYW5jaG9yanM0MDBAAGEAbgBjAGgAbwByAGoAcwA0ADAAMABAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAH//wAP) format("truetype");' + + ' }', + pseudoElContent = + ' [data-anchorjs-icon]::after {' + + ' content: attr(data-anchorjs-icon);' + + ' }', + firstStyleEl; + + style.className = 'anchorjs'; + style.appendChild(document.createTextNode('')); // Necessary for Webkit. + + // We place it in the head with the other style tags, if possible, so as to + // not look out of place. We insert before the others so these styles can be + // overridden if necessary. + firstStyleEl = document.head.querySelector('[rel="stylesheet"], style'); + if (firstStyleEl === undefined) { + document.head.appendChild(style); + } else { + document.head.insertBefore(style, firstStyleEl); + } + + style.sheet.insertRule(linkRule, style.sheet.cssRules.length); + style.sheet.insertRule(hoverRule, style.sheet.cssRules.length); + style.sheet.insertRule(pseudoElContent, style.sheet.cssRules.length); + style.sheet.insertRule(anchorjsLinkFontFace, style.sheet.cssRules.length); + } + } + + return AnchorJS; +})); + + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.scroll = void 0; + +var _util = _interopRequireDefault(__webpack_require__(0)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var scroll = function scroll() { + var $banner = $('.banner:first'), + $postBanner = $banner.find('.post-title a'), + $bgEle = $('.site-intro:first'), + $homeLink = $('.home-link:first'), + $backTop = $('.back-top:first'), + $sidebarMenu = $('.header-sidebar-menu:first'), + bgTitleHeight = $bgEle.offset().top + $bgEle.outerHeight(), + $tocWrapper = $('.toc-wrapper:first'), + $tocCatalog = $tocWrapper.find('.toc-catalog'), + $progressBar = $('.read-progress'); // toc的收缩 + + $tocCatalog.on('click', function () { + $tocWrapper.toggleClass('toc-hide-children'); + }); // 滚动式切换文章标题和站点标题 + + var previousHeight = 0, + continueScroll = 0; + + function isScrollingUpOrDown(currTop) { + continueScroll += currTop - previousHeight; + + if (continueScroll > 30) { + // 向下滑动 + continueScroll = 0; + return 1; + } else if (continueScroll < -800) { + // 向上滑动 + continueScroll = 0; + return -1; + } else { + return 0; + } + } // 是否在向上或向下滚动 + + + var crossingState = -1; + var isHigherThanIntro = true; + + function isCrossingIntro(currTop) { + // 向下滑动超过intro + if (currTop > bgTitleHeight) { + if (crossingState !== 1) { + crossingState = 1; + isHigherThanIntro = false; + return 1; + } + } else { + // 向上滑动超过intro + if (crossingState !== -1) { + crossingState = -1; + isHigherThanIntro = true; + return -1; + } + } + + return 0; + } // 判断是否为post-page + + + var isPostPage = false; + var articleHeight, articleTop; + + if ($('.post-body').length) { + isPostPage = true; + articleTop = bgTitleHeight; // 如果执行时动画已执行完毕 + + articleHeight = $('.article-entry').outerHeight(); // 如果执行时动画未执行完毕 + + articleHeight = $('.container')[0].addEventListener('transitionend', function () { + articleHeight = $('.article-entry').outerHeight(); + }); + } + + function updateProgress(scrollTop, beginY, contentHeight) { + var windowHeight = $(window).height(); + var readPercent; + + if (scrollTop < bgTitleHeight) { + readPercent = 0; + } else { + readPercent = (scrollTop - beginY) / (contentHeight - windowHeight) * 100; + } // 防止文章过短,产生负百分比 + + + readPercent = readPercent >= 0 ? readPercent : 100; + var restPercent = readPercent - 100 <= 0 ? readPercent - 100 : 0; + $progressBar[0].style.transform = "translate3d(".concat(restPercent, "%, 0, 0)"); + } // rAF操作 + + + var tickingScroll = false; + + function updateScroll(scrollTop) { + var crossingState = isCrossingIntro(scrollTop); // intro边界切换 + + if (crossingState === 1) { + $tocWrapper.addClass('toc-fixed'); + $homeLink.addClass('home-link-hide'); + $backTop.addClass('back-top-show'); + $sidebarMenu.addClass('header-sidebar-menu-black'); + } else if (crossingState === -1) { + $tocWrapper.removeClass('toc-fixed'); + $homeLink.removeClass('home-link-hide'); + $banner.removeClass('banner-show'); + $backTop.removeClass('back-top-show'); + $sidebarMenu.removeClass('header-sidebar-menu-black'); + } // 如果不是post - page 以下忽略 + + + if (isPostPage) { + // 上下滑动一定距离显示/隐藏header + var upDownState = isScrollingUpOrDown(scrollTop); + + if (upDownState === 1) { + $banner.removeClass('banner-show'); + } else if (upDownState === -1 && !isHigherThanIntro) { + $banner.addClass('banner-show'); + } // 进度条君的长度 + + + updateProgress(scrollTop, articleTop, articleHeight); + } + + previousHeight = scrollTop; + tickingScroll = false; + } // scroll回调 + + + function onScroll() { + var scrollTop = $(document).scrollTop(); + var bindedUpdate = updateScroll.bind(null, scrollTop); + + _util.default.rafTick(tickingScroll, bindedUpdate); + } + + $(document).on('scroll', onScroll) // 返回顶部 + ; + [$postBanner, $backTop].forEach(function (ele) { + ele.on('click', _util.default.backTop); + }); +}; + +exports.scroll = scroll; + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _perfectScrollbar = _interopRequireDefault(__webpack_require__(7)); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +var Selector = function Selector(classPrefix) { + return { + ACTIVE: "".concat(classPrefix, "-active") + }; +}; + +var Sidebar = /*#__PURE__*/function () { + function Sidebar(options) { + _classCallCheck(this, Sidebar); + + this.options = _extends({}, Sidebar.defaultOptions, options); + this.activeIndex = this.options.activeIndex; + + this._initElements(); + + this._initTabs(); + + this._bindTabsClick(); + + this._bindButtonClick(); + + this._bindWrapperClick(); + + this._bindWrapperTransitionEnd(); + + this.perfectScrollbar(); + } + + _createClass(Sidebar, [{ + key: "_initElements", + value: function _initElements() { + this.$sidebar = $(this.options.sidebar); + this.$tabs = $(this.options.tabs); + this.$panels = $(this.options.panels); + this.$menuButton = $(this.options.menuButton); + this.$nav = $(this.options.nav); + this.$content = $(this.options.content); + } + }, { + key: "_initTabs", + value: function _initTabs() { + this.$tabs.each(function (index, tab) { + $(tab).data('tabIndex', index); + }); + } + }, { + key: "activateSidebar", + value: function activateSidebar() { + $('.wrapper').addClass('wrapper-sidebar-active'); + $('.header').addClass('header-sidebar-active'); + $('.toc-wrapper').addClass('toc-slide'); + this.$menuButton.addClass('header-sidebar-menu-active'); + this.$sidebar.removeClass('sidebar-hide'); + this.$sidebar.addClass('sidebar-active'); + } + }, { + key: "_inactivateSidebar", + value: function _inactivateSidebar() { + $('.wrapper').removeClass('wrapper-sidebar-active'); + $('.header').removeClass('header-sidebar-active'); + $('.toc-wrapper').removeClass('toc-slide'); + this.$menuButton.removeClass('header-sidebar-menu-active'); + this.$sidebar.removeClass("sidebar-active"); + } + }, { + key: "switchTo", + value: function switchTo(toIndex) { + this._switchTo(toIndex); + } + }, { + key: "_switchTab", + value: function _switchTab(toIndex) { + for (var i = 0; i < 3; i++) { + if (i !== toIndex) { + this.$nav.removeClass("sidebar-tabs-active-".concat(i)); + } else { + this.$nav.addClass("sidebar-tabs-active-".concat(i)); + } + } + } + }, { + key: "_bindWrapperTransitionEnd", + value: function _bindWrapperTransitionEnd() { + var _this = this; + + $('.wrapper').on('transitionend', function (e) { + if (!_this.$sidebar.hasClass('sidebar-active')) { + _this.$sidebar.addClass('sidebar-hide'); + } + }); + } + }, { + key: "_switchPanel", + value: function _switchPanel(toIndex) { + for (var i = 0; i < 3; i++) { + if (i !== toIndex) { + this.$content.removeClass("sidebar-content-active-".concat(i)); + } else { + this.$content.addClass("sidebar-content-active-".concat(i)); + } + } + } + }, { + key: "_switchTo", + value: function _switchTo(toIndex) { + this._switchTab(toIndex); + + this._switchPanel(toIndex); + } + }, { + key: "_bindTabsClick", + value: function _bindTabsClick() { + var _this2 = this; + + this.$tabs.click(function (e) { + var $target = $(e.target); + + _this2.switchTo($target.data('tabIndex')); + }); + } + }, { + key: "_bindButtonClick", + value: function _bindButtonClick() { + var _this3 = this; + + this.$menuButton.click(function (e) { + if (_this3.$sidebar.hasClass('sidebar-hide')) { + _this3.activateSidebar(); + } else { + _this3._inactivateSidebar(); + } + }); + } + }, { + key: "_bindWrapperClick", + value: function _bindWrapperClick() { + var _this4 = this; + + $('.wrapper').click(function (e) { + _this4._inactivateSidebar(); + }); + } // 阻止sidebarContent在滚动到顶部或底部时继续滚动 + + }, { + key: "perfectScrollbar", + value: function perfectScrollbar() { + var ps = new _perfectScrollbar.default('.sidebar', { + suppressScrollX: true + }); + } + }]); + + return Sidebar; +}(); + +Object.defineProperty(Sidebar, "defaultOptions", { + configurable: true, + enumerable: true, + writable: true, + value: { + activeIndex: 0 + } +}); +var _default = Sidebar; +exports.default = _default; + +/***/ }), +/* 7 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +/*! + * perfect-scrollbar v1.3.0 + * (c) 2017 Hyunje Jun + * @license MIT + */ +function get(element) { + return getComputedStyle(element); +} + +function set(element, obj) { + for (var key in obj) { + var val = obj[key]; + if (typeof val === 'number') { + val = val + "px"; + } + element.style[key] = val; + } + return element; +} + +function div(className) { + var div = document.createElement('div'); + div.className = className; + return div; +} + +var elMatches = + typeof Element !== 'undefined' && + (Element.prototype.matches || + Element.prototype.webkitMatchesSelector || + Element.prototype.msMatchesSelector); + +function matches(element, query) { + if (!elMatches) { + throw new Error('No element matching method supported'); + } + + return elMatches.call(element, query); +} + +function remove(element) { + if (element.remove) { + element.remove(); + } else { + if (element.parentNode) { + element.parentNode.removeChild(element); + } + } +} + +function queryChildren(element, selector) { + return Array.prototype.filter.call(element.children, function (child) { return matches(child, selector); } + ); +} + +var cls = { + main: 'ps', + element: { + thumb: function (x) { return ("ps__thumb-" + x); }, + rail: function (x) { return ("ps__rail-" + x); }, + consuming: 'ps__child--consume', + }, + state: { + focus: 'ps--focus', + active: function (x) { return ("ps--active-" + x); }, + scrolling: function (x) { return ("ps--scrolling-" + x); }, + }, +}; + +/* + * Helper methods + */ +var scrollingClassTimeout = { x: null, y: null }; + +function addScrollingClass(i, x) { + var classList = i.element.classList; + var className = cls.state.scrolling(x); + + if (classList.contains(className)) { + clearTimeout(scrollingClassTimeout[x]); + } else { + classList.add(className); + } +} + +function removeScrollingClass(i, x) { + scrollingClassTimeout[x] = setTimeout( + function () { return i.isAlive && i.element.classList.remove(cls.state.scrolling(x)); }, + i.settings.scrollingThreshold + ); +} + +function setScrollingClassInstantly(i, x) { + addScrollingClass(i, x); + removeScrollingClass(i, x); +} + +var EventElement = function EventElement(element) { + this.element = element; + this.handlers = {}; +}; + +var prototypeAccessors = { isEmpty: { configurable: true } }; + +EventElement.prototype.bind = function bind (eventName, handler) { + if (typeof this.handlers[eventName] === 'undefined') { + this.handlers[eventName] = []; + } + this.handlers[eventName].push(handler); + this.element.addEventListener(eventName, handler, false); +}; + +EventElement.prototype.unbind = function unbind (eventName, target) { + var this$1 = this; + + this.handlers[eventName] = this.handlers[eventName].filter(function (handler) { + if (target && handler !== target) { + return true; + } + this$1.element.removeEventListener(eventName, handler, false); + return false; + }); +}; + +EventElement.prototype.unbindAll = function unbindAll () { + var this$1 = this; + + for (var name in this$1.handlers) { + this$1.unbind(name); + } +}; + +prototypeAccessors.isEmpty.get = function () { + var this$1 = this; + + return Object.keys(this.handlers).every( + function (key) { return this$1.handlers[key].length === 0; } + ); +}; + +Object.defineProperties( EventElement.prototype, prototypeAccessors ); + +var EventManager = function EventManager() { + this.eventElements = []; +}; + +EventManager.prototype.eventElement = function eventElement (element) { + var ee = this.eventElements.filter(function (ee) { return ee.element === element; })[0]; + if (!ee) { + ee = new EventElement(element); + this.eventElements.push(ee); + } + return ee; +}; + +EventManager.prototype.bind = function bind (element, eventName, handler) { + this.eventElement(element).bind(eventName, handler); +}; + +EventManager.prototype.unbind = function unbind (element, eventName, handler) { + var ee = this.eventElement(element); + ee.unbind(eventName, handler); + + if (ee.isEmpty) { + // remove + this.eventElements.splice(this.eventElements.indexOf(ee), 1); + } +}; + +EventManager.prototype.unbindAll = function unbindAll () { + this.eventElements.forEach(function (e) { return e.unbindAll(); }); + this.eventElements = []; +}; + +EventManager.prototype.once = function once (element, eventName, handler) { + var ee = this.eventElement(element); + var onceHandler = function (evt) { + ee.unbind(eventName, onceHandler); + handler(evt); + }; + ee.bind(eventName, onceHandler); +}; + +function createEvent(name) { + if (typeof window.CustomEvent === 'function') { + return new CustomEvent(name); + } else { + var evt = document.createEvent('CustomEvent'); + evt.initCustomEvent(name, false, false, undefined); + return evt; + } +} + +var processScrollDiff = function( + i, + axis, + diff, + useScrollingClass, + forceFireReachEvent +) { + if ( useScrollingClass === void 0 ) useScrollingClass = true; + if ( forceFireReachEvent === void 0 ) forceFireReachEvent = false; + + var fields; + if (axis === 'top') { + fields = [ + 'contentHeight', + 'containerHeight', + 'scrollTop', + 'y', + 'up', + 'down' ]; + } else if (axis === 'left') { + fields = [ + 'contentWidth', + 'containerWidth', + 'scrollLeft', + 'x', + 'left', + 'right' ]; + } else { + throw new Error('A proper axis should be provided'); + } + + processScrollDiff$1(i, diff, fields, useScrollingClass, forceFireReachEvent); +}; + +function processScrollDiff$1( + i, + diff, + ref, + useScrollingClass, + forceFireReachEvent +) { + var contentHeight = ref[0]; + var containerHeight = ref[1]; + var scrollTop = ref[2]; + var y = ref[3]; + var up = ref[4]; + var down = ref[5]; + if ( useScrollingClass === void 0 ) useScrollingClass = true; + if ( forceFireReachEvent === void 0 ) forceFireReachEvent = false; + + var element = i.element; + + // reset reach + i.reach[y] = null; + + // 1 for subpixel rounding + if (element[scrollTop] < 1) { + i.reach[y] = 'start'; + } + + // 1 for subpixel rounding + if (element[scrollTop] > i[contentHeight] - i[containerHeight] - 1) { + i.reach[y] = 'end'; + } + + if (diff) { + element.dispatchEvent(createEvent(("ps-scroll-" + y))); + + if (diff < 0) { + element.dispatchEvent(createEvent(("ps-scroll-" + up))); + } else if (diff > 0) { + element.dispatchEvent(createEvent(("ps-scroll-" + down))); + } + + if (useScrollingClass) { + setScrollingClassInstantly(i, y); + } + } + + if (i.reach[y] && (diff || forceFireReachEvent)) { + element.dispatchEvent(createEvent(("ps-" + y + "-reach-" + (i.reach[y])))); + } +} + +function toInt(x) { + return parseInt(x, 10) || 0; +} + +function isEditable(el) { + return ( + matches(el, 'input,[contenteditable]') || + matches(el, 'select,[contenteditable]') || + matches(el, 'textarea,[contenteditable]') || + matches(el, 'button,[contenteditable]') + ); +} + +function outerWidth(element) { + var styles = get(element); + return ( + toInt(styles.width) + + toInt(styles.paddingLeft) + + toInt(styles.paddingRight) + + toInt(styles.borderLeftWidth) + + toInt(styles.borderRightWidth) + ); +} + +var env = { + isWebKit: + typeof document !== 'undefined' && + 'WebkitAppearance' in document.documentElement.style, + supportsTouch: + typeof window !== 'undefined' && + ('ontouchstart' in window || + (window.DocumentTouch && document instanceof window.DocumentTouch)), + supportsIePointer: + typeof navigator !== 'undefined' && navigator.msMaxTouchPoints, + isChrome: + typeof navigator !== 'undefined' && + /Chrome/i.test(navigator && navigator.userAgent), +}; + +var updateGeometry = function(i) { + var element = i.element; + + i.containerWidth = element.clientWidth; + i.containerHeight = element.clientHeight; + i.contentWidth = element.scrollWidth; + i.contentHeight = element.scrollHeight; + + if (!element.contains(i.scrollbarXRail)) { + // clean up and append + queryChildren(element, cls.element.rail('x')).forEach(function (el) { return remove(el); } + ); + element.appendChild(i.scrollbarXRail); + } + if (!element.contains(i.scrollbarYRail)) { + // clean up and append + queryChildren(element, cls.element.rail('y')).forEach(function (el) { return remove(el); } + ); + element.appendChild(i.scrollbarYRail); + } + + if ( + !i.settings.suppressScrollX && + i.containerWidth + i.settings.scrollXMarginOffset < i.contentWidth + ) { + i.scrollbarXActive = true; + i.railXWidth = i.containerWidth - i.railXMarginWidth; + i.railXRatio = i.containerWidth / i.railXWidth; + i.scrollbarXWidth = getThumbSize( + i, + toInt(i.railXWidth * i.containerWidth / i.contentWidth) + ); + i.scrollbarXLeft = toInt( + (i.negativeScrollAdjustment + element.scrollLeft) * + (i.railXWidth - i.scrollbarXWidth) / + (i.contentWidth - i.containerWidth) + ); + } else { + i.scrollbarXActive = false; + } + + if ( + !i.settings.suppressScrollY && + i.containerHeight + i.settings.scrollYMarginOffset < i.contentHeight + ) { + i.scrollbarYActive = true; + i.railYHeight = i.containerHeight - i.railYMarginHeight; + i.railYRatio = i.containerHeight / i.railYHeight; + i.scrollbarYHeight = getThumbSize( + i, + toInt(i.railYHeight * i.containerHeight / i.contentHeight) + ); + i.scrollbarYTop = toInt( + element.scrollTop * + (i.railYHeight - i.scrollbarYHeight) / + (i.contentHeight - i.containerHeight) + ); + } else { + i.scrollbarYActive = false; + } + + if (i.scrollbarXLeft >= i.railXWidth - i.scrollbarXWidth) { + i.scrollbarXLeft = i.railXWidth - i.scrollbarXWidth; + } + if (i.scrollbarYTop >= i.railYHeight - i.scrollbarYHeight) { + i.scrollbarYTop = i.railYHeight - i.scrollbarYHeight; + } + + updateCss(element, i); + + if (i.scrollbarXActive) { + element.classList.add(cls.state.active('x')); + } else { + element.classList.remove(cls.state.active('x')); + i.scrollbarXWidth = 0; + i.scrollbarXLeft = 0; + element.scrollLeft = 0; + } + if (i.scrollbarYActive) { + element.classList.add(cls.state.active('y')); + } else { + element.classList.remove(cls.state.active('y')); + i.scrollbarYHeight = 0; + i.scrollbarYTop = 0; + element.scrollTop = 0; + } +}; + +function getThumbSize(i, thumbSize) { + if (i.settings.minScrollbarLength) { + thumbSize = Math.max(thumbSize, i.settings.minScrollbarLength); + } + if (i.settings.maxScrollbarLength) { + thumbSize = Math.min(thumbSize, i.settings.maxScrollbarLength); + } + return thumbSize; +} + +function updateCss(element, i) { + var xRailOffset = { width: i.railXWidth }; + if (i.isRtl) { + xRailOffset.left = + i.negativeScrollAdjustment + + element.scrollLeft + + i.containerWidth - + i.contentWidth; + } else { + xRailOffset.left = element.scrollLeft; + } + if (i.isScrollbarXUsingBottom) { + xRailOffset.bottom = i.scrollbarXBottom - element.scrollTop; + } else { + xRailOffset.top = i.scrollbarXTop + element.scrollTop; + } + set(i.scrollbarXRail, xRailOffset); + + var yRailOffset = { top: element.scrollTop, height: i.railYHeight }; + if (i.isScrollbarYUsingRight) { + if (i.isRtl) { + yRailOffset.right = + i.contentWidth - + (i.negativeScrollAdjustment + element.scrollLeft) - + i.scrollbarYRight - + i.scrollbarYOuterWidth; + } else { + yRailOffset.right = i.scrollbarYRight - element.scrollLeft; + } + } else { + if (i.isRtl) { + yRailOffset.left = + i.negativeScrollAdjustment + + element.scrollLeft + + i.containerWidth * 2 - + i.contentWidth - + i.scrollbarYLeft - + i.scrollbarYOuterWidth; + } else { + yRailOffset.left = i.scrollbarYLeft + element.scrollLeft; + } + } + set(i.scrollbarYRail, yRailOffset); + + set(i.scrollbarX, { + left: i.scrollbarXLeft, + width: i.scrollbarXWidth - i.railBorderXWidth, + }); + set(i.scrollbarY, { + top: i.scrollbarYTop, + height: i.scrollbarYHeight - i.railBorderYWidth, + }); +} + +var clickRail = function(i) { + i.event.bind(i.scrollbarY, 'mousedown', function (e) { return e.stopPropagation(); }); + i.event.bind(i.scrollbarYRail, 'mousedown', function (e) { + var positionTop = + e.pageY - + window.pageYOffset - + i.scrollbarYRail.getBoundingClientRect().top; + var direction = positionTop > i.scrollbarYTop ? 1 : -1; + + i.element.scrollTop += direction * i.containerHeight; + updateGeometry(i); + + e.stopPropagation(); + }); + + i.event.bind(i.scrollbarX, 'mousedown', function (e) { return e.stopPropagation(); }); + i.event.bind(i.scrollbarXRail, 'mousedown', function (e) { + var positionLeft = + e.pageX - + window.pageXOffset - + i.scrollbarXRail.getBoundingClientRect().left; + var direction = positionLeft > i.scrollbarXLeft ? 1 : -1; + + i.element.scrollLeft += direction * i.containerWidth; + updateGeometry(i); + + e.stopPropagation(); + }); +}; + +var dragThumb = function(i) { + bindMouseScrollHandler(i, [ + 'containerWidth', + 'contentWidth', + 'pageX', + 'railXWidth', + 'scrollbarX', + 'scrollbarXWidth', + 'scrollLeft', + 'x' ]); + bindMouseScrollHandler(i, [ + 'containerHeight', + 'contentHeight', + 'pageY', + 'railYHeight', + 'scrollbarY', + 'scrollbarYHeight', + 'scrollTop', + 'y' ]); +}; + +function bindMouseScrollHandler( + i, + ref +) { + var containerHeight = ref[0]; + var contentHeight = ref[1]; + var pageY = ref[2]; + var railYHeight = ref[3]; + var scrollbarY = ref[4]; + var scrollbarYHeight = ref[5]; + var scrollTop = ref[6]; + var y = ref[7]; + + var element = i.element; + + var startingScrollTop = null; + var startingMousePageY = null; + var scrollBy = null; + + function mouseMoveHandler(e) { + element[scrollTop] = + startingScrollTop + scrollBy * (e[pageY] - startingMousePageY); + addScrollingClass(i, y); + updateGeometry(i); + + e.stopPropagation(); + e.preventDefault(); + } + + function mouseUpHandler() { + removeScrollingClass(i, y); + i.event.unbind(i.ownerDocument, 'mousemove', mouseMoveHandler); + } + + i.event.bind(i[scrollbarY], 'mousedown', function (e) { + startingScrollTop = element[scrollTop]; + startingMousePageY = e[pageY]; + scrollBy = + (i[contentHeight] - i[containerHeight]) / + (i[railYHeight] - i[scrollbarYHeight]); + + i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler); + i.event.once(i.ownerDocument, 'mouseup', mouseUpHandler); + + e.stopPropagation(); + e.preventDefault(); + }); +} + +var keyboard = function(i) { + var element = i.element; + + var elementHovered = function () { return matches(element, ':hover'); }; + var scrollbarFocused = function () { return matches(i.scrollbarX, ':focus') || matches(i.scrollbarY, ':focus'); }; + + function shouldPreventDefault(deltaX, deltaY) { + var scrollTop = element.scrollTop; + if (deltaX === 0) { + if (!i.scrollbarYActive) { + return false; + } + if ( + (scrollTop === 0 && deltaY > 0) || + (scrollTop >= i.contentHeight - i.containerHeight && deltaY < 0) + ) { + return !i.settings.wheelPropagation; + } + } + + var scrollLeft = element.scrollLeft; + if (deltaY === 0) { + if (!i.scrollbarXActive) { + return false; + } + if ( + (scrollLeft === 0 && deltaX < 0) || + (scrollLeft >= i.contentWidth - i.containerWidth && deltaX > 0) + ) { + return !i.settings.wheelPropagation; + } + } + return true; + } + + i.event.bind(i.ownerDocument, 'keydown', function (e) { + if ( + (e.isDefaultPrevented && e.isDefaultPrevented()) || + e.defaultPrevented + ) { + return; + } + + if (!elementHovered() && !scrollbarFocused()) { + return; + } + + var activeElement = document.activeElement + ? document.activeElement + : i.ownerDocument.activeElement; + if (activeElement) { + if (activeElement.tagName === 'IFRAME') { + activeElement = activeElement.contentDocument.activeElement; + } else { + // go deeper if element is a webcomponent + while (activeElement.shadowRoot) { + activeElement = activeElement.shadowRoot.activeElement; + } + } + if (isEditable(activeElement)) { + return; + } + } + + var deltaX = 0; + var deltaY = 0; + + switch (e.which) { + case 37: // left + if (e.metaKey) { + deltaX = -i.contentWidth; + } else if (e.altKey) { + deltaX = -i.containerWidth; + } else { + deltaX = -30; + } + break; + case 38: // up + if (e.metaKey) { + deltaY = i.contentHeight; + } else if (e.altKey) { + deltaY = i.containerHeight; + } else { + deltaY = 30; + } + break; + case 39: // right + if (e.metaKey) { + deltaX = i.contentWidth; + } else if (e.altKey) { + deltaX = i.containerWidth; + } else { + deltaX = 30; + } + break; + case 40: // down + if (e.metaKey) { + deltaY = -i.contentHeight; + } else if (e.altKey) { + deltaY = -i.containerHeight; + } else { + deltaY = -30; + } + break; + case 32: // space bar + if (e.shiftKey) { + deltaY = i.containerHeight; + } else { + deltaY = -i.containerHeight; + } + break; + case 33: // page up + deltaY = i.containerHeight; + break; + case 34: // page down + deltaY = -i.containerHeight; + break; + case 36: // home + deltaY = i.contentHeight; + break; + case 35: // end + deltaY = -i.contentHeight; + break; + default: + return; + } + + if (i.settings.suppressScrollX && deltaX !== 0) { + return; + } + if (i.settings.suppressScrollY && deltaY !== 0) { + return; + } + + element.scrollTop -= deltaY; + element.scrollLeft += deltaX; + updateGeometry(i); + + if (shouldPreventDefault(deltaX, deltaY)) { + e.preventDefault(); + } + }); +}; + +var wheel = function(i) { + var element = i.element; + + function shouldPreventDefault(deltaX, deltaY) { + var isTop = element.scrollTop === 0; + var isBottom = + element.scrollTop + element.offsetHeight === element.scrollHeight; + var isLeft = element.scrollLeft === 0; + var isRight = + element.scrollLeft + element.offsetWidth === element.offsetWidth; + + var hitsBound; + + // pick axis with primary direction + if (Math.abs(deltaY) > Math.abs(deltaX)) { + hitsBound = isTop || isBottom; + } else { + hitsBound = isLeft || isRight; + } + + return hitsBound ? !i.settings.wheelPropagation : true; + } + + function getDeltaFromEvent(e) { + var deltaX = e.deltaX; + var deltaY = -1 * e.deltaY; + + if (typeof deltaX === 'undefined' || typeof deltaY === 'undefined') { + // OS X Safari + deltaX = -1 * e.wheelDeltaX / 6; + deltaY = e.wheelDeltaY / 6; + } + + if (e.deltaMode && e.deltaMode === 1) { + // Firefox in deltaMode 1: Line scrolling + deltaX *= 10; + deltaY *= 10; + } + + if (deltaX !== deltaX && deltaY !== deltaY /* NaN checks */) { + // IE in some mouse drivers + deltaX = 0; + deltaY = e.wheelDelta; + } + + if (e.shiftKey) { + // reverse axis with shift key + return [-deltaY, -deltaX]; + } + return [deltaX, deltaY]; + } + + function shouldBeConsumedByChild(target, deltaX, deltaY) { + // FIXME: this is a workaround for