默认提交
Showing
34 changed files
with
2212 additions
and
1918 deletions
.env.development
0 → 100644
.env.fev
deleted
100644 → 0
.env.production
0 → 100644
.env.sandbox
0 → 100644
| ... | @@ -6,7 +6,7 @@ | ... | @@ -6,7 +6,7 @@ |
| 6 | "serve": "vue-cli-service serve", | 6 | "serve": "vue-cli-service serve", |
| 7 | "dev": "vue-cli-service serve", | 7 | "dev": "vue-cli-service serve", |
| 8 | "build": "vue-cli-service build", | 8 | "build": "vue-cli-service build", |
| 9 | "fev": "vue-cli-service build --mode fev", | 9 | "sandbox": "vue-cli-service build --mode sandbox", |
| 10 | "lint": "vue-cli-service lint", | 10 | "lint": "vue-cli-service lint", |
| 11 | "oss": "node build/oss-released.js" | 11 | "oss": "node build/oss-released.js" |
| 12 | }, | 12 | }, |
| ... | @@ -17,11 +17,16 @@ | ... | @@ -17,11 +17,16 @@ |
| 17 | "axios-mock-adapter": "^1.16.0", | 17 | "axios-mock-adapter": "^1.16.0", |
| 18 | "co": "^4.6.0", | 18 | "co": "^4.6.0", |
| 19 | "core-js": "^2.6.5", | 19 | "core-js": "^2.6.5", |
| 20 | "crypto-js": "^4.0.0", | ||
| 21 | "jsencrypt": "^3.0.0-rc.1", | ||
| 22 | "moment": "^2.29.1", | ||
| 20 | "glob": "^7.1.4", | 23 | "glob": "^7.1.4", |
| 24 | "js-cookie": "^2.2.1", | ||
| 21 | "mockjs": "^1.0.1-beta3", | 25 | "mockjs": "^1.0.1-beta3", |
| 22 | "postcss-px2rem": "^0.3.0", | 26 | "postcss-px2rem": "^0.3.0", |
| 23 | "postcss-pxtorem": "^4.0.1", | 27 | "postcss-pxtorem": "^4.0.1", |
| 24 | "vant": "^1.6.21", | 28 | "sass-resources-loader": "^2.0.3", |
| 29 | "vant": "^2.2.11", | ||
| 25 | "vue": "^2.6.10", | 30 | "vue": "^2.6.10", |
| 26 | "vue-router": "^3.0.3", | 31 | "vue-router": "^3.0.3", |
| 27 | "vuex": "^3.0.1" | 32 | "vuex": "^3.0.1" |
| ... | @@ -34,8 +39,8 @@ | ... | @@ -34,8 +39,8 @@ |
| 34 | "babel-plugin-import": "^1.12.0", | 39 | "babel-plugin-import": "^1.12.0", |
| 35 | "eslint": "^5.16.0", | 40 | "eslint": "^5.16.0", |
| 36 | "eslint-plugin-vue": "^5.0.0", | 41 | "eslint-plugin-vue": "^5.0.0", |
| 37 | "node-sass": "^4.12.0", | 42 | "node-sass": "^5.0.0", |
| 38 | "sass-loader": "^7.1.0", | 43 | "sass-loader": "^10.1.0", |
| 39 | "vue-template-compiler": "^2.6.10" | 44 | "vue-template-compiler": "^2.6.10" |
| 40 | } | 45 | } |
| 41 | } | 46 | } | ... | ... |
| ... | @@ -4,13 +4,11 @@ | ... | @@ -4,13 +4,11 @@ |
| 4 | <router-link to="/">Home</router-link> | | 4 | <router-link to="/">Home</router-link> | |
| 5 | <router-link to="/about">About</router-link> | 5 | <router-link to="/about">About</router-link> |
| 6 | </div>--> | 6 | </div>--> |
| 7 | <router-view/> | 7 | <router-view /> |
| 8 | </div> | 8 | </div> |
| 9 | </template> | 9 | </template> |
| 10 | 10 | ||
| 11 | <style lang="scss"> | 11 | <style lang="scss"> |
| 12 | @import './styles/support.scss'; | ||
| 13 | |||
| 14 | #app { | 12 | #app { |
| 15 | /* font-family: 'Avenir', Helvetica, Arial, sans-serif; | 13 | /* font-family: 'Avenir', Helvetica, Arial, sans-serif; |
| 16 | -webkit-font-smoothing: antialiased; | 14 | -webkit-font-smoothing: antialiased; |
| ... | @@ -82,6 +80,4 @@ div { | ... | @@ -82,6 +80,4 @@ div { |
| 82 | .app__content { | 80 | .app__content { |
| 83 | position: relative; | 81 | position: relative; |
| 84 | } | 82 | } |
| 85 | |||
| 86 | |||
| 87 | </style> | 83 | </style> | ... | ... |
| 1 | import axios from 'axios'; | 1 | import axios from 'axios'; |
| 2 | // import { | ||
| 3 | // Toast | ||
| 4 | // } from 'vant'; | ||
| 5 | 2 | ||
| 6 | function Toast(msg) { | 3 | import { |
| 7 | console.log("msg:", msg); | 4 | Toast |
| 8 | } | 5 | } from 'vant'; |
| 6 | |||
| 7 | import router from '@/router' | ||
| 8 | import { | ||
| 9 | getToken, | ||
| 10 | setToken, | ||
| 11 | removeToken | ||
| 12 | } from '@/utils/auth' | ||
| 13 | |||
| 14 | import { | ||
| 15 | makeEncrypt | ||
| 16 | } from '@/utils/encrypt-util' | ||
| 17 | |||
| 18 | import api from '@/api/api'; | ||
| 9 | 19 | ||
| 10 | // axios的默认url | 20 | // axios的默认url |
| 11 | // axios.defaults.baseURL = "" | 21 | // axios.defaults.baseURL = "" |
| 12 | 22 | ||
| 13 | // 服务器地址 | 23 | // 服务器地址 |
| 24 | // let base = process.env.VUE_APP_API_HOST + "/jxMallApi"; | ||
| 14 | let base = "https://ow.go.qudone.com"; | 25 | let base = "https://ow.go.qudone.com"; |
| 15 | if (location.href.indexOf("//k.wxpai.cn") > 0) { | 26 | if (location.href.indexOf("//k.wxpai.cn") > 0) { |
| 16 | base = "https://api.k.wxpai.cn/bizproxy" | 27 | base = "https://api.k.wxpai.cn/bizproxy" |
| 17 | } | 28 | } |
| 18 | // let base = COM.baseUrl; | ||
| 19 | 29 | ||
| 20 | // 请求拦截器 | 30 | // 请求拦截器 |
| 21 | // axios.interceptors.request.use( | 31 | // axios.interceptors.request.use( |
| ... | @@ -33,11 +43,37 @@ if (location.href.indexOf("//k.wxpai.cn") > 0) { | ... | @@ -33,11 +43,37 @@ if (location.href.indexOf("//k.wxpai.cn") > 0) { |
| 33 | // 响应拦截器 | 43 | // 响应拦截器 |
| 34 | axios.interceptors.response.use( | 44 | axios.interceptors.response.use( |
| 35 | response => { | 45 | response => { |
| 46 | let { | ||
| 47 | config | ||
| 48 | } = response; | ||
| 49 | let { | ||
| 50 | opt | ||
| 51 | } = config; | ||
| 52 | // 服务器状态码 | ||
| 36 | if (response.status === 200) { | 53 | if (response.status === 200) { |
| 54 | |||
| 55 | // 业务状态码 | ||
| 37 | if (response.data.code === 200) { | 56 | if (response.data.code === 200) { |
| 38 | return Promise.resolve(response); | 57 | return Promise.resolve(response); |
| 39 | } else { | 58 | } else { |
| 40 | Toast(response.data.bizMsg); | 59 | if (typeof (opt) == "undefined" || typeof (opt.toast) == "undefined" || opt.toast) { |
| 60 | Toast(response.data.errMsg); | ||
| 61 | } | ||
| 62 | switch (response.data.code) { | ||
| 63 | |||
| 64 | /** | ||
| 65 | * 登陆失败 | ||
| 66 | * 清除cookies | ||
| 67 | * 根据业务可能要引导回登陆页 | ||
| 68 | */ | ||
| 69 | case 403: | ||
| 70 | removeToken(); | ||
| 71 | break; | ||
| 72 | |||
| 73 | default: | ||
| 74 | break; | ||
| 75 | } | ||
| 76 | |||
| 41 | return Promise.reject(response); | 77 | return Promise.reject(response); |
| 42 | } | 78 | } |
| 43 | } else { | 79 | } else { |
| ... | @@ -48,49 +84,7 @@ axios.interceptors.response.use( | ... | @@ -48,49 +84,7 @@ axios.interceptors.response.use( |
| 48 | error => { | 84 | error => { |
| 49 | if (error.response.status) { | 85 | if (error.response.status) { |
| 50 | switch (error.response.status) { | 86 | switch (error.response.status) { |
| 51 | // 401: 未登录 | 87 | // 其他错误,直接抛出错误提示 |
| 52 | // 未登录则跳转登录页面,并携带当前页面的路径 | ||
| 53 | // 在登录成功后返回当前页面,这一步需要在登录页操作。 | ||
| 54 | case 401: | ||
| 55 | router.replace({ | ||
| 56 | path: '/login', | ||
| 57 | query: { | ||
| 58 | redirect: router.currentRoute.fullPath | ||
| 59 | } | ||
| 60 | }); | ||
| 61 | break; | ||
| 62 | // 403 token过期 | ||
| 63 | // 登录过期对用户进行提示 | ||
| 64 | // 清除本地token和清空vuex中token对象 | ||
| 65 | // 跳转登录页面 | ||
| 66 | case 403: | ||
| 67 | Toast({ | ||
| 68 | message: '登录过期,请重新登录', | ||
| 69 | duration: 1000, | ||
| 70 | forbidClick: true | ||
| 71 | }); | ||
| 72 | // 清除token | ||
| 73 | localStorage.removeItem('token'); | ||
| 74 | store.commit('loginSuccess', null); | ||
| 75 | // 跳转登录页面,并将要浏览的页面fullPath传过去,登录成功后跳转需要访问的页面 | ||
| 76 | setTimeout(() => { | ||
| 77 | router.replace({ | ||
| 78 | path: '/login', | ||
| 79 | query: { | ||
| 80 | redirect: router.currentRoute.fullPath | ||
| 81 | } | ||
| 82 | }); | ||
| 83 | }, 1000); | ||
| 84 | break; | ||
| 85 | // 404请求不存在 | ||
| 86 | case 404: | ||
| 87 | Toast({ | ||
| 88 | message: '网络请求不存在', | ||
| 89 | duration: 1500, | ||
| 90 | forbidClick: true | ||
| 91 | }); | ||
| 92 | break; | ||
| 93 | // 其他错误,直接抛出错误提示 | ||
| 94 | default: | 88 | default: |
| 95 | Toast({ | 89 | Toast({ |
| 96 | message: error.response.data.message, | 90 | message: error.response.data.message, |
| ... | @@ -103,6 +97,7 @@ axios.interceptors.response.use( | ... | @@ -103,6 +97,7 @@ axios.interceptors.response.use( |
| 103 | } | 97 | } |
| 104 | ); | 98 | ); |
| 105 | 99 | ||
| 100 | |||
| 106 | //formDataHeaders设置 | 101 | //formDataHeaders设置 |
| 107 | let formDataHeaders = { | 102 | let formDataHeaders = { |
| 108 | headers: { | 103 | headers: { |
| ... | @@ -113,14 +108,31 @@ let formDataHeaders = { | ... | @@ -113,14 +108,31 @@ let formDataHeaders = { |
| 113 | /** | 108 | /** |
| 114 | * 封装get方法 | 109 | * 封装get方法 |
| 115 | * @param {*} params | 110 | * @param {*} params |
| 111 | * | ||
| 116 | */ | 112 | */ |
| 117 | export const httpGet = params => { | 113 | export const httpGet = params => { |
| 118 | let { | 114 | let { |
| 119 | url, | 115 | url, |
| 120 | data | 116 | data, |
| 117 | mode, | ||
| 118 | opt = Object.assign({}, params.opt), | ||
| 119 | sid = true | ||
| 121 | } = params; | 120 | } = params; |
| 122 | return axios.get(`${base}${url}`, { | 121 | if (opt.enc) { |
| 123 | params: data | 122 | data = makeEncrypt(data); |
| 123 | } | ||
| 124 | let reqUrl = `${base}${url}`; | ||
| 125 | if (mode == "custom") { | ||
| 126 | reqUrl = `${url}` | ||
| 127 | } | ||
| 128 | let headers = {} | ||
| 129 | if (sid) { | ||
| 130 | headers.sessionId = getToken(); | ||
| 131 | } | ||
| 132 | return axios.get(reqUrl, { | ||
| 133 | params: data, | ||
| 134 | headers, | ||
| 135 | opt | ||
| 124 | }).then(res => res.data.content); | 136 | }).then(res => res.data.content); |
| 125 | } | 137 | } |
| 126 | 138 | ||
| ... | @@ -131,9 +143,26 @@ export const httpGet = params => { | ... | @@ -131,9 +143,26 @@ export const httpGet = params => { |
| 131 | export const httpPost = params => { | 143 | export const httpPost = params => { |
| 132 | let { | 144 | let { |
| 133 | url, | 145 | url, |
| 134 | data | 146 | data, |
| 147 | mode, | ||
| 148 | opt = Object.assign({}, params.opt), | ||
| 149 | sid = true | ||
| 135 | } = params; | 150 | } = params; |
| 136 | return axios.post(`${base}${url}`, data).then(res => res.data.content); | 151 | if (opt.enc) { |
| 152 | data = makeEncrypt(data); | ||
| 153 | } | ||
| 154 | let reqUrl = `${base}${url}`; | ||
| 155 | if (mode == "custom") { | ||
| 156 | reqUrl = `${url}` | ||
| 157 | } | ||
| 158 | let headers = {} | ||
| 159 | if (sid) { | ||
| 160 | headers.sessionId = getToken(); | ||
| 161 | } | ||
| 162 | return axios.post(reqUrl, data, { | ||
| 163 | headers, | ||
| 164 | opt | ||
| 165 | }).then(res => res.data.content); | ||
| 137 | } | 166 | } |
| 138 | 167 | ||
| 139 | 168 | ||
| ... | @@ -143,14 +172,40 @@ export const httpPost = params => { | ... | @@ -143,14 +172,40 @@ export const httpPost = params => { |
| 143 | * data数据是 formdata格式 | 172 | * data数据是 formdata格式 |
| 144 | * 例如: | 173 | * 例如: |
| 145 | * this.file = file | 174 | * this.file = file |
| 146 | let data = new FormData() //使用formData对象 | 175 | let data = new FormData() //使用formData对象 |
| 147 | data.append('path', '/pro/mzczcradmin/') | 176 | data.append('path', '/pro/mzczcradmin/') |
| 148 | data.append('file', file.file) | 177 | data.append('file', file.file) |
| 149 | */ | 178 | */ |
| 150 | export const formdata = params => { | 179 | export const formdata = params => { |
| 151 | let { | 180 | let { |
| 152 | url, | 181 | url, |
| 153 | data | 182 | data, |
| 154 | } = params; | 183 | } = params; |
| 155 | return axios.post(`${base}${url}`, data, formDataHeaders).then(res => res.data); | 184 | |
| 185 | let formData = new FormData(); //使用formData对象 | ||
| 186 | for (let key in data) { | ||
| 187 | formData.append(key, data[key]); | ||
| 188 | } | ||
| 189 | return axios.post(`${base}${url}`, formData, formDataHeaders).then(res => res.data.content); | ||
| 190 | } | ||
| 191 | |||
| 192 | |||
| 193 | |||
| 194 | /** | ||
| 195 | * 打点 | ||
| 196 | * @param {*} params | ||
| 197 | */ | ||
| 198 | export const stat = data => { | ||
| 199 | data.s = encodeURIComponent(getToken()); | ||
| 200 | let reqUrl = `${base}${api.stat}`; | ||
| 201 | let opt = { | ||
| 202 | toast: false | ||
| 203 | } | ||
| 204 | let headers = {} | ||
| 205 | // headers.sessionId = getToken(); | ||
| 206 | return axios.get(reqUrl, { | ||
| 207 | params: data, | ||
| 208 | headers, | ||
| 209 | opt | ||
| 210 | }).then(res => res.data.content);; | ||
| 156 | } | 211 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | // 字体放在同目录下 | ||
| 1 | // @font-face { | 2 | // @font-face { |
| 2 | // font-family: 'vivo-BoldExtended'; | 3 | // font-family: 'BentonSans'; |
| 3 | // src: url('./vivo-BoldExtended.ttf'); | 4 | // src: url('BentonSans-Regular_sOT.otf'); |
| 4 | // font-weight: normal; | ||
| 5 | // font-style: normal; | ||
| 6 | // } | 5 | // } |
| 7 | // @font-face { | ||
| 8 | // font-family: 'vivo-Regular'; | ||
| 9 | // src: url('./vivo-Regular.ttf'); | ||
| 10 | // font-weight: normal; | ||
| 11 | // font-style: normal; | ||
| 12 | // } | ||
| 13 | // @font-face { | ||
| 14 | // font-family: 'regular2'; | ||
| 15 | // src: url('./regular2.otf'); | ||
| 16 | // font-weight: normal; | ||
| 17 | // font-style: normal; | ||
| 18 | // } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 6 | |||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -3,13 +3,45 @@ import App from './App.vue' | ... | @@ -3,13 +3,45 @@ import App from './App.vue' |
| 3 | import router from './router' | 3 | import router from './router' |
| 4 | import store from './store' | 4 | import store from './store' |
| 5 | 5 | ||
| 6 | import Mock from './mock' | 6 | // import Mock from './mock' |
| 7 | Mock.bootstrap(); | 7 | // Mock.bootstrap(); |
| 8 | 8 | ||
| 9 | import 'amfe-flexible/index.js' | 9 | import 'amfe-flexible/index.js' |
| 10 | 10 | ||
| 11 | import '@/styles/index.scss' // global css | ||
| 12 | |||
| 13 | import '@/styles/index.scss' // global css | ||
| 14 | import '@/styles/fonticon.scss' // 图标字体 | ||
| 15 | import '@/assets/fonts/font.scss' // 字体引入 | ||
| 16 | |||
| 17 | // import '@styles/utils.scss' /*引入公共样式*/ | ||
| 18 | |||
| 11 | Vue.config.productionTip = false | 19 | Vue.config.productionTip = false |
| 12 | 20 | ||
| 21 | |||
| 22 | import { | ||
| 23 | Swipe, | ||
| 24 | SwipeItem, | ||
| 25 | Lazyload, | ||
| 26 | Tab, | ||
| 27 | Tabs, | ||
| 28 | Sticky, | ||
| 29 | Popup, | ||
| 30 | Tabbar, | ||
| 31 | TabbarItem, | ||
| 32 | Icon, | ||
| 33 | Toast | ||
| 34 | } from 'vant'; | ||
| 35 | |||
| 36 | Vue.use(Swipe).use(SwipeItem) | ||
| 37 | .use(Lazyload) | ||
| 38 | .use(Tab).use(Tabs) | ||
| 39 | .use(Sticky) | ||
| 40 | .use(Popup) | ||
| 41 | .use(Tabbar).use(TabbarItem) | ||
| 42 | .use(Icon) | ||
| 43 | .use(Toast); | ||
| 44 | |||
| 13 | new Vue({ | 45 | new Vue({ |
| 14 | router, | 46 | router, |
| 15 | store, | 47 | store, |
| ... | @@ -17,4 +49,4 @@ new Vue({ | ... | @@ -17,4 +49,4 @@ new Vue({ |
| 17 | isInit: false, | 49 | isInit: false, |
| 18 | }, | 50 | }, |
| 19 | render: h => h(App) | 51 | render: h => h(App) |
| 20 | }).$mount('#app') | 52 | }).$mount('#app') |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | <template> | 1 | <template> |
| 2 | <div class="home">home</div> | 2 | <div class="home"> |
| 3 | |||
| 4 | <div >旅游必备清单</div> | ||
| 5 | </div> | ||
| 3 | </template> | 6 | </template> |
| 4 | 7 | ||
| 5 | <script> | 8 | <script> |
| ... | @@ -11,5 +14,6 @@ export default { | ... | @@ -11,5 +14,6 @@ export default { |
| 11 | <style lang="scss" scoped> | 14 | <style lang="scss" scoped> |
| 12 | .home { | 15 | .home { |
| 13 | text-align: center; | 16 | text-align: center; |
| 17 | font-size: 14PX; | ||
| 14 | } | 18 | } |
| 15 | </style> | 19 | </style> | ... | ... |
| ... | @@ -15,7 +15,5 @@ export default { | ... | @@ -15,7 +15,5 @@ export default { |
| 15 | initData() {} | 15 | initData() {} |
| 16 | }, | 16 | }, |
| 17 | mounted() {}, | 17 | mounted() {}, |
| 18 | created() { | 18 | created() {} |
| 19 | console.log("demo created"); | ||
| 20 | } | ||
| 21 | } | 19 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
src/pages/demo/demo.scss
0 → 100644
File mode changed
src/pages/demo/demo.vue
0 → 100644
| 1 | |||
| 2 | <template> | ||
| 3 | <div class="page"> | ||
| 4 | <div class="app__bgc bgc"></div> | ||
| 5 | <div class="app__bg bg"></div> | ||
| 6 | <div class="app__content main"> | ||
| 7 | <div class="top-space"></div> | ||
| 8 | <div class="content"> | ||
| 9 | <!-- <span class="iconfont iconclose">demo</span> --> | ||
| 10 | demo | ||
| 11 | </div> | ||
| 12 | </div> | ||
| 13 | </div> | ||
| 14 | </template> | ||
| 15 | |||
| 16 | <script src="./demo.js"></script> | ||
| 17 | <style lang="scss" scoped> | ||
| 18 | @import './demo.scss'; | ||
| 19 | </style> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
src/pages/demo/index.scss
deleted
100644 → 0
| 1 | @import './../../styles/support'; |
src/pages/index/index.js
0 → 100644
| 1 | import api from '../../api/api' | ||
| 2 | import { | ||
| 3 | httpGet, | ||
| 4 | httpPost | ||
| 5 | } from '../../api/fetch-api.js' | ||
| 6 | |||
| 7 | export default { | ||
| 8 | data() { | ||
| 9 | return { | ||
| 10 | key: 'value' | ||
| 11 | } | ||
| 12 | }, | ||
| 13 | components: {}, | ||
| 14 | methods: { | ||
| 15 | initData() {}, | ||
| 16 | toLottery() { | ||
| 17 | this.$router.push({ | ||
| 18 | path: "/lottery" | ||
| 19 | }) | ||
| 20 | } | ||
| 21 | }, | ||
| 22 | mounted() {}, | ||
| 23 | created() { | ||
| 24 | } | ||
| 25 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
src/pages/index/index.scss
0 → 100644
| 1 | .content {} |
| ... | @@ -6,13 +6,13 @@ | ... | @@ -6,13 +6,13 @@ |
| 6 | <div class="app__content main"> | 6 | <div class="app__content main"> |
| 7 | <div class="top-space"></div> | 7 | <div class="top-space"></div> |
| 8 | <div class="content"> | 8 | <div class="content"> |
| 9 | <span class="iconfont iconclose">demo</span> | 9 | <div @click="toLottery">Index</div> |
| 10 | </div> | 10 | </div> |
| 11 | </div> | 11 | </div> |
| 12 | </div> | 12 | </div> |
| 13 | </template> | 13 | </template> |
| 14 | 14 | ||
| 15 | <script src="./index.js"></script> | 15 | <script src="./index.js"></script> |
| 16 | <style lang="scss" scoped> | 16 | <style lang="scss" scoped> |
| 17 | // @import './index.scss'; | 17 | @import "./index.scss"; |
| 18 | </style> | 18 | </style> |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
src/pages/lottery/lottery.js
0 → 100644
| 1 | import api from '../../api/api' | ||
| 2 | import { | ||
| 3 | httpGet, | ||
| 4 | httpPost | ||
| 5 | } from '../../api/fetch-api.js' | ||
| 6 | |||
| 7 | export default { | ||
| 8 | data() { | ||
| 9 | return { | ||
| 10 | key: 'value' | ||
| 11 | } | ||
| 12 | }, | ||
| 13 | components: {}, | ||
| 14 | methods: { | ||
| 15 | initData() {}, | ||
| 16 | toIndex() { | ||
| 17 | this.$router.push({ | ||
| 18 | path: "/" | ||
| 19 | }) | ||
| 20 | }, | ||
| 21 | }, | ||
| 22 | mounted() {}, | ||
| 23 | created() {} | ||
| 24 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
src/pages/lottery/lottery.scss
0 → 100644
src/pages/lottery/lottery.vue
0 → 100644
| 1 | |||
| 2 | <template> | ||
| 3 | <div class="page"> | ||
| 4 | <div class="app__bgc bgc"></div> | ||
| 5 | <div class="app__bg bg"></div> | ||
| 6 | <div class="app__content main"> | ||
| 7 | <div class="top-space"></div> | ||
| 8 | <div class="content"> | ||
| 9 | <div @click="toIndex">lottery</div> | ||
| 10 | </div> | ||
| 11 | </div> | ||
| 12 | </div> | ||
| 13 | </template> | ||
| 14 | |||
| 15 | <script src="./lottery.js"></script> | ||
| 16 | <style lang="scss" scoped> | ||
| 17 | @import "./lottery.scss"; | ||
| 18 | </style> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | import Vue from 'vue' | 1 | import Vue from 'vue' |
| 2 | import Router from 'vue-router' | 2 | import Router from 'vue-router' |
| 3 | import Home from './pages/Home.vue' | 3 | import Index from './pages/index/index.vue' |
| 4 | 4 | ||
| 5 | Vue.use(Router) | 5 | Vue.use(Router) |
| 6 | 6 | ||
| 7 | const routes = [{ | 7 | const routes = [{ |
| 8 | path: '/', | 8 | path: '/', |
| 9 | name: 'home', | 9 | name: 'index', |
| 10 | component: Home, | 10 | component: Index, |
| 11 | meta: { | 11 | meta: { |
| 12 | title: '首页' | 12 | title: '' |
| 13 | } | ||
| 14 | }, | ||
| 15 | { | ||
| 16 | path: '/lottery', | ||
| 17 | name: 'lottery', | ||
| 18 | component: () => import('./pages/lottery/lottery.vue'), | ||
| 19 | meta: { | ||
| 20 | title: 'lottery' | ||
| 13 | } | 21 | } |
| 14 | }, | 22 | }, |
| 15 | { | 23 | { |
| 16 | path: '/demo', | 24 | path: '/demo', |
| 17 | name: 'demo', | 25 | name: 'demo', |
| 18 | component: () => import('./pages/demo/index.vue'), | 26 | component: () => import('./pages/demo/demo.vue'), |
| 19 | meta: { | 27 | meta: { |
| 20 | title: '模板' | 28 | title: '模板' |
| 21 | } | 29 | } | ... | ... |
src/styles/_support.scss
deleted
100755 → 0
| 1 | /** | ||
| 2 | * ------------------------------------------------------------------ | ||
| 3 | * 支持文件 | ||
| 4 | * 需要引用的地方均需要加上这个支持文件 | ||
| 5 | * | ||
| 6 | * ------------------------------------------------------------------ | ||
| 7 | * | ||
| 8 | */ | ||
| 9 | |||
| 10 | @import "mixins"; | ||
| 11 | |||
| 12 | @import "var"; | ||
| 13 | |||
| 14 | // 图标字体 | ||
| 15 | @import "fonticon"; | ||
| 16 | |||
| 17 | // 字体引入 | ||
| 18 | @import './../assets/fonts/font.scss' | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
src/styles/_utils.scss
deleted
100755 → 0
| 1 | /** | ||
| 2 | * ------------------------------------------------------------------ | ||
| 3 | * 原子类 | ||
| 4 | * | ||
| 5 | * ------------------------------------------------------------------ | ||
| 6 | * | ||
| 7 | */ | ||
| 8 | @import "support"; | ||
| 9 | |||
| 10 | // Margin | ||
| 11 | .u-mt-smaller { | ||
| 12 | margin-top: $marginTopSmaller; | ||
| 13 | } | ||
| 14 | |||
| 15 | .u-mt-small { | ||
| 16 | margin-top: $marginTopSmall; | ||
| 17 | } | ||
| 18 | |||
| 19 | .u-mt-medium { | ||
| 20 | margin-top: $marginTopMedium; | ||
| 21 | } | ||
| 22 | |||
| 23 | .u-mt-large { | ||
| 24 | margin-top: $marginTopLarge; | ||
| 25 | } | ||
| 26 | |||
| 27 | .u-mt-larger { | ||
| 28 | margin-top: $marginTopLarger; | ||
| 29 | } | ||
| 30 | |||
| 31 | .u-mb-smaller { | ||
| 32 | margin-bottom: $marginTopSmaller; | ||
| 33 | } | ||
| 34 | |||
| 35 | .u-mb-small { | ||
| 36 | margin-bottom: $marginTopSmall; | ||
| 37 | } | ||
| 38 | |||
| 39 | .u-mb-medium { | ||
| 40 | margin-bottom: $marginTopMedium; | ||
| 41 | } | ||
| 42 | |||
| 43 | .u-mb-large { | ||
| 44 | margin-bottom: $marginTopLarge; | ||
| 45 | } | ||
| 46 | |||
| 47 | .u-mb-larger { | ||
| 48 | margin-bottom: $marginTopLarger; | ||
| 49 | } | ||
| 50 | |||
| 51 | // Padding | ||
| 52 | .u-pt-smaller { | ||
| 53 | padding-top: $paddingTopSmaller; | ||
| 54 | } | ||
| 55 | |||
| 56 | .u-pt-small { | ||
| 57 | padding-top: $paddingTopSmall; | ||
| 58 | } | ||
| 59 | |||
| 60 | .u-pt-medium { | ||
| 61 | padding-top: $paddingTopMedium; | ||
| 62 | } | ||
| 63 | |||
| 64 | .u-pt-large { | ||
| 65 | padding-top: $paddingTopLarge; | ||
| 66 | } | ||
| 67 | |||
| 68 | .u-pt-larger { | ||
| 69 | padding-top: $paddingTopLarger; | ||
| 70 | } | ||
| 71 | |||
| 72 | .u-pb-smaller { | ||
| 73 | padding-bottom: $paddingTopSmaller; | ||
| 74 | } | ||
| 75 | |||
| 76 | .u-pb-small { | ||
| 77 | padding-bottom: $paddingTopSmall; | ||
| 78 | } | ||
| 79 | |||
| 80 | .u-pb-medium { | ||
| 81 | padding-bottom: $paddingTopMedium; | ||
| 82 | } | ||
| 83 | |||
| 84 | .u-pb-large { | ||
| 85 | padding-bottom: $paddingTopLarge; | ||
| 86 | } | ||
| 87 | |||
| 88 | .u-pb-larger { | ||
| 89 | padding-bottom: $paddingTopLarger; | ||
| 90 | } | ||
| 91 | |||
| 92 | // 布局方位 | ||
| 93 | .u-ta-c { | ||
| 94 | text-align: center !important; | ||
| 95 | } | ||
| 96 | |||
| 97 | .u-ta-l { | ||
| 98 | text-align: left !important; | ||
| 99 | } | ||
| 100 | |||
| 101 | .u-ta-r { | ||
| 102 | text-align: right !important; | ||
| 103 | } | ||
| 104 | |||
| 105 | .u-fl-l { | ||
| 106 | float: left; | ||
| 107 | } | ||
| 108 | |||
| 109 | .u-fl-n { | ||
| 110 | float: none; | ||
| 111 | } | ||
| 112 | |||
| 113 | .u-fl-r { | ||
| 114 | float: right; | ||
| 115 | } | ||
| 116 | |||
| 117 | .u-d-b { | ||
| 118 | display: block; | ||
| 119 | } | ||
| 120 | |||
| 121 | .u-d-i { | ||
| 122 | display: inline !important; | ||
| 123 | } | ||
| 124 | |||
| 125 | .u-d-ib { | ||
| 126 | display: inline-block !important; | ||
| 127 | } | ||
| 128 | |||
| 129 | .u-d-n { | ||
| 130 | display: none !important; | ||
| 131 | } | ||
| 132 | |||
| 133 | .u-d-t { | ||
| 134 | display: table; | ||
| 135 | table-layout: fixed; | ||
| 136 | } | ||
| 137 | |||
| 138 | .u-d-tc { | ||
| 139 | display: table-cell; | ||
| 140 | } | ||
| 141 | |||
| 142 | .u-va-b { | ||
| 143 | vertical-align: bottom; | ||
| 144 | } | ||
| 145 | |||
| 146 | .u-va-m { | ||
| 147 | vertical-align: middle; | ||
| 148 | } | ||
| 149 | |||
| 150 | .u-va-t { | ||
| 151 | vertical-align: top; | ||
| 152 | } | ||
| 153 | |||
| 154 | // clearfix | ||
| 155 | .u-clearfix { | ||
| 156 | @include clearfix; | ||
| 157 | } | ||
| 158 | |||
| 159 | // 虚拟格式 | ||
| 160 | .u-cur-d { | ||
| 161 | cursor: default; | ||
| 162 | } | ||
| 163 | |||
| 164 | .u-cur-p { | ||
| 165 | cursor: pointer; | ||
| 166 | } | ||
| 167 | |||
| 168 | // flex | ||
| 169 | .u-flex { | ||
| 170 | display: -webkit-box; | ||
| 171 | display: -webkit-flex; | ||
| 172 | display: flex; | ||
| 173 | } | ||
| 174 | |||
| 175 | .u-flex-item { | ||
| 176 | -webkit-box-flex: 1; | ||
| 177 | -webkit-flex: 1; | ||
| 178 | flex: 1; | ||
| 179 | } | ||
| 180 | |||
| 181 | // 小程序中模拟ul、li | ||
| 182 | .u-ul { | ||
| 183 | padding-left: 30px; | ||
| 184 | text-align: left; | ||
| 185 | display: block; | ||
| 186 | } | ||
| 187 | |||
| 188 | .u-li { | ||
| 189 | position: relative; | ||
| 190 | font-size: $fontSizeSmall; | ||
| 191 | line-height: $fontSizeSmall + 4px; | ||
| 192 | margin-bottom: $marginTopSmall; | ||
| 193 | |||
| 194 | &:before { | ||
| 195 | position: absolute; | ||
| 196 | content: " "; | ||
| 197 | top: 14px; | ||
| 198 | left: -20px; | ||
| 199 | width: 8px; | ||
| 200 | height: 8px; | ||
| 201 | border-radius: 8px; | ||
| 202 | background-color: $colorBlack; | ||
| 203 | } | ||
| 204 | } |
src/styles/index.scss
0 → 100644
| 1 | #app { | ||
| 2 | border: 0; | ||
| 3 | margin: 0; | ||
| 4 | padding: 0; | ||
| 5 | } | ||
| 6 | |||
| 7 | body, | ||
| 8 | div { | ||
| 9 | border: 0; | ||
| 10 | margin: 0; | ||
| 11 | padding: 0; | ||
| 12 | } | ||
| 13 | |||
| 14 | .app__width { | ||
| 15 | width: 750px; | ||
| 16 | } | ||
| 17 | |||
| 18 | .app__width { | ||
| 19 | width: 750px; | ||
| 20 | } | ||
| 21 | |||
| 22 | .app__inner { | ||
| 23 | margin: 20px; | ||
| 24 | } | ||
| 25 | |||
| 26 | .app__title { | ||
| 27 | font-size: $fontSize; | ||
| 28 | line-height: $fontSize + 4px; | ||
| 29 | font-weight: bold; | ||
| 30 | padding-bottom: 10px; | ||
| 31 | margin-bottom: 20px; | ||
| 32 | border-bottom: 0.5px solid #eeeeee; | ||
| 33 | } | ||
| 34 | |||
| 35 | .app__desc { | ||
| 36 | font-size: $fontSizeSmaller; | ||
| 37 | line-height: $fontSizeSmaller + 2px; | ||
| 38 | margin-bottom: 20px; | ||
| 39 | color: $colorGray; | ||
| 40 | } | ||
| 41 | |||
| 42 | .app__bgc { | ||
| 43 | position: fixed; | ||
| 44 | background-color: #ffffff; | ||
| 45 | width: 100%; | ||
| 46 | height: 100%; | ||
| 47 | } | ||
| 48 | |||
| 49 | .app__bg { | ||
| 50 | position: absolute; | ||
| 51 | width: 100%; | ||
| 52 | height: 100%; | ||
| 53 | } | ||
| 54 | |||
| 55 | .app__top-shadow { | ||
| 56 | position: fixed; | ||
| 57 | width: 750px; | ||
| 58 | height: 1px; | ||
| 59 | box-shadow: 0px 4px 0.9px 0.1px rgba(6, 0, 1, 0.07); | ||
| 60 | background-color: #ffffff; | ||
| 61 | } | ||
| 62 | |||
| 63 | .app__content { | ||
| 64 | position: relative; | ||
| 65 | } |
| 1 | /** | 1 | // 居中按钮样式 |
| 2 | * ------------------------------------------------------------------ | 2 | @mixin btn-center($width, $height) { |
| 3 | * Sass Minxins | 3 | width: $width; |
| 4 | * | 4 | height: $height; |
| 5 | * 参考收集: | 5 | line-height: $height; |
| 6 | * https://github.com/twbs/bootstrap-sass/tree/master/assets/stylesheets/bootstrap/mixins | 6 | text-align: center; |
| 7 | * ------------------------------------------------------------------ | 7 | } |
| 8 | * | 8 | |
| 9 | */ | 9 | // 超过多少行自动省略 默认一行 |
| 10 | @mixin ellipsis($line: 1) { | ||
| 11 | display: -webkit-box; | ||
| 12 | word-break: break-all; | ||
| 13 | -webkit-box-orient: vertical; | ||
| 14 | -webkit-line-clamp: $line; | ||
| 15 | overflow: hidden; | ||
| 16 | text-overflow: ellipsis; | ||
| 17 | |||
| 18 | -ms-text-overflow: ellipsis; | ||
| 19 | } | ||
| 20 | @mixin ellipsis1() { | ||
| 21 | display: -webkit-box; | ||
| 22 | word-break: break-all; | ||
| 23 | -webkit-box-orient: vertical; | ||
| 24 | -webkit-line-clamp: 1; | ||
| 25 | overflow: hidden; | ||
| 26 | text-overflow: ellipsis; | ||
| 27 | white-space: nowrap; | ||
| 28 | } | ||
| 10 | 29 | ||
| 11 | // 文字截取 | 30 | // 文字截取 |
| 12 | @mixin text-overflow() { | 31 | @mixin text-overflow() { |
| 13 | overflow: hidden; | 32 | overflow: hidden; |
| 14 | white-space: normal; | 33 | white-space: normal; |
| 15 | text-overflow: ellipsis; | 34 | text-overflow: ellipsis; |
| 16 | word-break: break-all; | 35 | word-break: break-all; |
| 17 | word-wrap: normal; | 36 | word-wrap: normal; |
| 18 | } | 37 | } |
| 19 | 38 | ||
| 20 | @mixin word-break() { | 39 | @mixin word-break() { |
| 21 | word-break: break-all; | 40 | word-break: break-all; |
| 22 | word-wrap: break-word; | 41 | word-wrap: break-word; |
| 23 | white-space: normal; | 42 | white-space: normal; |
| 24 | } | 43 | } |
| 25 | 44 | ||
| 26 | // No wrap | 45 | // No wrap |
| 27 | @mixin no-wrap() { | 46 | @mixin no-wrap() { |
| 28 | word-break: normal; | 47 | word-break: normal; |
| 29 | word-wrap: normal; | 48 | word-wrap: normal; |
| 30 | white-space: nowrap; | 49 | white-space: nowrap; |
| 31 | } | 50 | } |
| 32 | 51 | ||
| 33 | // 清除浮动 | 52 | // 清除浮动 |
| 34 | @mixin clearfix() { | 53 | @mixin clearfix() { |
| 35 | &:before, | 54 | &:before, |
| 36 | &:after { | 55 | &:after { |
| 37 | content: " "; // 1 | 56 | content: " "; // 1 |
| 38 | display: table; // 2 | 57 | display: table; // 2 |
| 39 | } | 58 | } |
| 40 | &:after { | 59 | |
| 41 | clear: both; | 60 | &:after { |
| 42 | } | 61 | clear: both; |
| 62 | } | ||
| 43 | } | 63 | } |
| 44 | 64 | ||
| 45 | // Single side border-radius | 65 | // Single side border-radius |
| 46 | @mixin border-top-radius($radius) { | 66 | @mixin border-top-radius($radius) { |
| 47 | border-top-right-radius: $radius; | 67 | border-top-right-radius: $radius; |
| 48 | border-top-left-radius: $radius; | 68 | border-top-left-radius: $radius; |
| 49 | } | 69 | } |
| 50 | 70 | ||
| 51 | @mixin border-right-radius($radius) { | 71 | @mixin border-right-radius($radius) { |
| 52 | border-bottom-right-radius: $radius; | 72 | border-bottom-right-radius: $radius; |
| 53 | border-top-right-radius: $radius; | 73 | border-top-right-radius: $radius; |
| 54 | } | 74 | } |
| 55 | 75 | ||
| 56 | @mixin border-bottom-radius($radius) { | 76 | @mixin border-bottom-radius($radius) { |
| 57 | border-bottom-right-radius: $radius; | 77 | border-bottom-right-radius: $radius; |
| 58 | border-bottom-left-radius: $radius; | 78 | border-bottom-left-radius: $radius; |
| 59 | } | 79 | } |
| 60 | 80 | ||
| 61 | @mixin border-left-radius($radius) { | 81 | @mixin border-left-radius($radius) { |
| 62 | border-bottom-left-radius: $radius; | 82 | border-bottom-left-radius: $radius; |
| 63 | border-top-left-radius: $radius; | 83 | border-top-left-radius: $radius; |
| 64 | } | 84 | } |
| 65 | 85 | ||
| 66 | // Center-align a block level element | 86 | // Center-align a block level element |
| 67 | @mixin center-block() { | 87 | @mixin center-block() { |
| 68 | display: block; | 88 | display: block; |
| 69 | margin-left: auto; | 89 | margin-left: auto; |
| 70 | margin-right: auto; | 90 | margin-right: auto; |
| 71 | } | 91 | } |
| 72 | 92 | ||
| 73 | // CSS image replacement | 93 | // CSS image replacement |
| 74 | // Source: https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757 | 94 | // Source: https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757 |
| 75 | @mixin hide-text() { | 95 | @mixin hide-text() { |
| 76 | font-size: 0; | 96 | font-size: 0; |
| 77 | line-height: 0; | 97 | line-height: 0; |
| 78 | color: transparent; | 98 | color: transparent; |
| 79 | text-shadow: none; | 99 | text-shadow: none; |
| 80 | background-color: transparent; | 100 | background-color: transparent; |
| 81 | border: 0; | 101 | border: 0; |
| 102 | } | ||
| 103 | |||
| 104 | // 橙色底实心 自定义圆角按钮 | ||
| 105 | @mixin btc($hei: 22px, $borderRadius: 4px, $padding: 12px, $fontSize: 14px) { | ||
| 106 | @extend .fcc; | ||
| 107 | padding: 0 $padding; | ||
| 108 | height: $hei; | ||
| 109 | line-height: normal; | ||
| 110 | text-align: center; | ||
| 111 | border-radius: $borderRadius; | ||
| 112 | background-color: $cOrange; | ||
| 113 | font-size: $fontSize; | ||
| 114 | color: #ffffff; | ||
| 115 | letter-spacing: 1.4px; | ||
| 116 | cursor: pointer; | ||
| 117 | user-select: none; | ||
| 118 | } | ||
| 119 | |||
| 120 | // 白底空心 自定义圆角按钮 | ||
| 121 | @mixin btc-o($hei: 22px, $borderRadius: 4px, $padding: 12px, $fontSize: 14px) { | ||
| 122 | @extend .fcc; | ||
| 123 | @extend .bb; | ||
| 124 | padding: 0 $padding; | ||
| 125 | height: $hei; | ||
| 126 | line-height: normal; | ||
| 127 | text-align: center; | ||
| 128 | border-radius: $borderRadius; | ||
| 129 | font-size: $fontSize; | ||
| 130 | color: $cOrange; | ||
| 131 | letter-spacing: 1.4px; | ||
| 132 | background-color: #ffffff; | ||
| 133 | cursor: pointer; | ||
| 134 | border: solid 1px $cOrange; | ||
| 135 | user-select: none; | ||
| 136 | } | ||
| 137 | |||
| 138 | // 定宽 橙色底实心圆角按钮 | ||
| 139 | @mixin btc2($wid: 118px, $hei: 22px, $fontSize: 14px) { | ||
| 140 | width: $wid; | ||
| 141 | height: $hei; | ||
| 142 | line-height: $hei + 2px; | ||
| 143 | text-align: center; | ||
| 144 | border-radius: $hei * 0.5; | ||
| 145 | background-color: $cOrange; | ||
| 146 | font-size: $fontSize; | ||
| 147 | color: #ffffff; | ||
| 148 | letter-spacing: 1.4px; | ||
| 149 | cursor: pointer; | ||
| 150 | user-select: none; | ||
| 151 | } | ||
| 152 | |||
| 153 | // 橙框橙字 | ||
| 154 | @mixin btc3($hei: 22px, $fontSize: 14px) { | ||
| 155 | height: $hei; | ||
| 156 | line-height: $hei; | ||
| 157 | padding: 0 12px; | ||
| 158 | text-align: center; | ||
| 159 | border-radius: 2px; | ||
| 160 | font-size: $fontSize; | ||
| 161 | letter-spacing: 1.4px; | ||
| 162 | cursor: pointer; | ||
| 163 | user-select: none; | ||
| 164 | color: $cOrange; | ||
| 165 | border: solid 1px $cOrange; | ||
| 166 | } | ||
| 167 | |||
| 168 | // 定宽 黑色底实心圆角按钮 | ||
| 169 | @mixin btc4($wid: 118px, $hei: 22px, $fontSize: 14px) { | ||
| 170 | width: $wid; | ||
| 171 | height: $hei; | ||
| 172 | line-height: $hei + 2px; | ||
| 173 | text-align: center; | ||
| 174 | border-radius: $hei * 0.5; | ||
| 175 | background-color: $cLightDard; | ||
| 176 | font-size: $fontSize; | ||
| 177 | color: #ffffff; | ||
| 178 | letter-spacing: 1.4px; | ||
| 179 | cursor: pointer; | ||
| 180 | user-select: none; | ||
| 82 | } | 181 | } | ... | ... |
src/styles/utils.scss
0 → 100755
| 1 | .bis { | ||
| 2 | background-repeat: no-repeat; | ||
| 3 | background-size: 100% 100%; | ||
| 4 | } | ||
| 5 | |||
| 6 | //flex 布局和 子元素 对其方式 | ||
| 7 | .fl { | ||
| 8 | display: flex; | ||
| 9 | } | ||
| 10 | |||
| 11 | .flc { | ||
| 12 | display: flex; | ||
| 13 | justify-content: center; | ||
| 14 | } | ||
| 15 | |||
| 16 | .flb { | ||
| 17 | display: flex; | ||
| 18 | justify-content: space-between; | ||
| 19 | } | ||
| 20 | |||
| 21 | .fla { | ||
| 22 | display: flex; | ||
| 23 | align-items: center; | ||
| 24 | } | ||
| 25 | |||
| 26 | //水平和垂直居中 | ||
| 27 | .fcc { | ||
| 28 | display: flex; | ||
| 29 | justify-content: center; | ||
| 30 | align-items: center; | ||
| 31 | } | ||
| 32 | |||
| 33 | // 为元素设定的宽度和高度决定了元素的边框盒。 | ||
| 34 | .bb { | ||
| 35 | box-sizing: border-box; | ||
| 36 | } | ||
| 37 | |||
| 38 | // 满屏 | ||
| 39 | .fullp { | ||
| 40 | width: 100%; | ||
| 41 | height: 100%; | ||
| 42 | } | ||
| 43 | |||
| 44 | .pointer { | ||
| 45 | cursor: pointer; | ||
| 46 | } | ||
| 47 | |||
| 48 | .text-l { | ||
| 49 | text-align: left; | ||
| 50 | } | ||
| 51 | |||
| 52 | .text-r { | ||
| 53 | text-align: right; | ||
| 54 | } | ||
| 55 | |||
| 56 | .text-c { | ||
| 57 | text-align: center; | ||
| 58 | } | ||
| 59 | |||
| 60 | .underline { | ||
| 61 | text-decoration: underline; | ||
| 62 | } | ||
| 63 | |||
| 64 | .pointer { | ||
| 65 | cursor: pointer; | ||
| 66 | } |
File moved
src/utils/auth.js
0 → 100644
| ... | @@ -3,1530 +3,1530 @@ | ... | @@ -3,1530 +3,1530 @@ |
| 3 | * @author: Coolite Inc. http://www.coolite.com/ | 3 | * @author: Coolite Inc. http://www.coolite.com/ |
| 4 | * @date: 2008-05-13 | 4 | * @date: 2008-05-13 |
| 5 | * @copyright: Copyright (c) 2006-2008, Coolite Inc. (http://www.coolite.com/). All rights reserved. | 5 | * @copyright: Copyright (c) 2006-2008, Coolite Inc. (http://www.coolite.com/). All rights reserved. |
| 6 | * @license: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/. | 6 | * @license: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/. |
| 7 | * @website: http://www.datejs.com/ | 7 | * @website: http://www.datejs.com/ |
| 8 | */ | 8 | */ |
| 9 | 9 | ||
| 10 | Date.CultureInfo = { | 10 | Date.CultureInfo = { |
| 11 | name: "en-US", | 11 | name: "en-US", |
| 12 | englishName: "English (United States)", | 12 | englishName: "English (United States)", |
| 13 | nativeName: "English (United States)", | 13 | nativeName: "English (United States)", |
| 14 | dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], | 14 | dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], |
| 15 | abbreviatedDayNames: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], | 15 | abbreviatedDayNames: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], |
| 16 | shortestDayNames: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], | 16 | shortestDayNames: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], |
| 17 | firstLetterDayNames: ["S", "M", "T", "W", "T", "F", "S"], | 17 | firstLetterDayNames: ["S", "M", "T", "W", "T", "F", "S"], |
| 18 | monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], | 18 | monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], |
| 19 | abbreviatedMonthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], | 19 | abbreviatedMonthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], |
| 20 | amDesignator: "AM", | 20 | amDesignator: "AM", |
| 21 | pmDesignator: "PM", | 21 | pmDesignator: "PM", |
| 22 | firstDayOfWeek: 0, | 22 | firstDayOfWeek: 0, |
| 23 | twoDigitYearMax: 2029, | 23 | twoDigitYearMax: 2029, |
| 24 | dateElementOrder: "mdy", | 24 | dateElementOrder: "mdy", |
| 25 | formatPatterns: { | 25 | formatPatterns: { |
| 26 | shortDate: "M/d/yyyy", | 26 | shortDate: "M/d/yyyy", |
| 27 | longDate: "dddd, MMMM dd, yyyy", | 27 | longDate: "dddd, MMMM dd, yyyy", |
| 28 | shortTime: "h:mm tt", | 28 | shortTime: "h:mm tt", |
| 29 | longTime: "h:mm:ss tt", | 29 | longTime: "h:mm:ss tt", |
| 30 | fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", | 30 | fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", |
| 31 | sortableDateTime: "yyyy-MM-ddTHH:mm:ss", | 31 | sortableDateTime: "yyyy-MM-ddTHH:mm:ss", |
| 32 | universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", | 32 | universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", |
| 33 | rfc1123: "ddd, dd MMM yyyy HH:mm:ss GMT", | 33 | rfc1123: "ddd, dd MMM yyyy HH:mm:ss GMT", |
| 34 | monthDay: "MMMM dd", | 34 | monthDay: "MMMM dd", |
| 35 | yearMonth: "MMMM, yyyy" | 35 | yearMonth: "MMMM, yyyy" |
| 36 | }, | 36 | }, |
| 37 | regexPatterns: { | 37 | regexPatterns: { |
| 38 | jan: /^jan(uary)?/i, | 38 | jan: /^jan(uary)?/i, |
| 39 | feb: /^feb(ruary)?/i, | 39 | feb: /^feb(ruary)?/i, |
| 40 | mar: /^mar(ch)?/i, | 40 | mar: /^mar(ch)?/i, |
| 41 | apr: /^apr(il)?/i, | 41 | apr: /^apr(il)?/i, |
| 42 | may: /^may/i, | 42 | may: /^may/i, |
| 43 | jun: /^jun(e)?/i, | 43 | jun: /^jun(e)?/i, |
| 44 | jul: /^jul(y)?/i, | 44 | jul: /^jul(y)?/i, |
| 45 | aug: /^aug(ust)?/i, | 45 | aug: /^aug(ust)?/i, |
| 46 | sep: /^sep(t(ember)?)?/i, | 46 | sep: /^sep(t(ember)?)?/i, |
| 47 | oct: /^oct(ober)?/i, | 47 | oct: /^oct(ober)?/i, |
| 48 | nov: /^nov(ember)?/i, | 48 | nov: /^nov(ember)?/i, |
| 49 | dec: /^dec(ember)?/i, | 49 | dec: /^dec(ember)?/i, |
| 50 | sun: /^su(n(day)?)?/i, | 50 | sun: /^su(n(day)?)?/i, |
| 51 | mon: /^mo(n(day)?)?/i, | 51 | mon: /^mo(n(day)?)?/i, |
| 52 | tue: /^tu(e(s(day)?)?)?/i, | 52 | tue: /^tu(e(s(day)?)?)?/i, |
| 53 | wed: /^we(d(nesday)?)?/i, | 53 | wed: /^we(d(nesday)?)?/i, |
| 54 | thu: /^th(u(r(s(day)?)?)?)?/i, | 54 | thu: /^th(u(r(s(day)?)?)?)?/i, |
| 55 | fri: /^fr(i(day)?)?/i, | 55 | fri: /^fr(i(day)?)?/i, |
| 56 | sat: /^sa(t(urday)?)?/i, | 56 | sat: /^sa(t(urday)?)?/i, |
| 57 | future: /^next/i, | 57 | future: /^next/i, |
| 58 | past: /^last|past|prev(ious)?/i, | 58 | past: /^last|past|prev(ious)?/i, |
| 59 | add: /^(\+|aft(er)?|from|hence)/i, | 59 | add: /^(\+|aft(er)?|from|hence)/i, |
| 60 | subtract: /^(\-|bef(ore)?|ago)/i, | 60 | subtract: /^(\-|bef(ore)?|ago)/i, |
| 61 | yesterday: /^yes(terday)?/i, | 61 | yesterday: /^yes(terday)?/i, |
| 62 | today: /^t(od(ay)?)?/i, | 62 | today: /^t(od(ay)?)?/i, |
| 63 | tomorrow: /^tom(orrow)?/i, | 63 | tomorrow: /^tom(orrow)?/i, |
| 64 | now: /^n(ow)?/i, | 64 | now: /^n(ow)?/i, |
| 65 | millisecond: /^ms|milli(second)?s?/i, | 65 | millisecond: /^ms|milli(second)?s?/i, |
| 66 | second: /^sec(ond)?s?/i, | 66 | second: /^sec(ond)?s?/i, |
| 67 | minute: /^mn|min(ute)?s?/i, | 67 | minute: /^mn|min(ute)?s?/i, |
| 68 | hour: /^h(our)?s?/i, | 68 | hour: /^h(our)?s?/i, |
| 69 | week: /^w(eek)?s?/i, | 69 | week: /^w(eek)?s?/i, |
| 70 | month: /^m(onth)?s?/i, | 70 | month: /^m(onth)?s?/i, |
| 71 | day: /^d(ay)?s?/i, | 71 | day: /^d(ay)?s?/i, |
| 72 | year: /^y(ear)?s?/i, | 72 | year: /^y(ear)?s?/i, |
| 73 | shortMeridian: /^(a|p)/i, | 73 | shortMeridian: /^(a|p)/i, |
| 74 | longMeridian: /^(a\.?m?\.?|p\.?m?\.?)/i, | 74 | longMeridian: /^(a\.?m?\.?|p\.?m?\.?)/i, |
| 75 | timezone: /^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\s*(\+|\-)\s*\d\d\d\d?)|gmt|utc)/i, | 75 | timezone: /^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\s*(\+|\-)\s*\d\d\d\d?)|gmt|utc)/i, |
| 76 | ordinalSuffix: /^\s*(st|nd|rd|th)/i, | 76 | ordinalSuffix: /^\s*(st|nd|rd|th)/i, |
| 77 | timeContext: /^\s*(\:|a(?!u|p)|p)/i | 77 | timeContext: /^\s*(\:|a(?!u|p)|p)/i |
| 78 | }, | 78 | }, |
| 79 | timezones: [{ | 79 | timezones: [{ |
| 80 | name: "UTC", | 80 | name: "UTC", |
| 81 | offset: "-000" | 81 | offset: "-000" |
| 82 | }, { | 82 | }, { |
| 83 | name: "GMT", | 83 | name: "GMT", |
| 84 | offset: "-000" | 84 | offset: "-000" |
| 85 | }, { | 85 | }, { |
| 86 | name: "EST", | 86 | name: "EST", |
| 87 | offset: "-0500" | 87 | offset: "-0500" |
| 88 | }, { | 88 | }, { |
| 89 | name: "EDT", | 89 | name: "EDT", |
| 90 | offset: "-0400" | 90 | offset: "-0400" |
| 91 | }, { | 91 | }, { |
| 92 | name: "CST", | 92 | name: "CST", |
| 93 | offset: "-0600" | 93 | offset: "-0600" |
| 94 | }, { | 94 | }, { |
| 95 | name: "CDT", | 95 | name: "CDT", |
| 96 | offset: "-0500" | 96 | offset: "-0500" |
| 97 | }, { | 97 | }, { |
| 98 | name: "MST", | 98 | name: "MST", |
| 99 | offset: "-0700" | 99 | offset: "-0700" |
| 100 | }, { | 100 | }, { |
| 101 | name: "MDT", | 101 | name: "MDT", |
| 102 | offset: "-0600" | 102 | offset: "-0600" |
| 103 | }, { | 103 | }, { |
| 104 | name: "PST", | 104 | name: "PST", |
| 105 | offset: "-0800" | 105 | offset: "-0800" |
| 106 | }, { | 106 | }, { |
| 107 | name: "PDT", | 107 | name: "PDT", |
| 108 | offset: "-0700" | 108 | offset: "-0700" |
| 109 | }] | 109 | }] |
| 110 | }; | 110 | }; |
| 111 | (function () { | 111 | (function () { |
| 112 | var $D = Date, | 112 | var $D = Date, |
| 113 | $P = $D.prototype, | 113 | $P = $D.prototype, |
| 114 | $C = $D.CultureInfo, | 114 | $C = $D.CultureInfo, |
| 115 | p = function (s, l) { | 115 | p = function (s, l) { |
| 116 | if (!l) { | 116 | if (!l) { |
| 117 | l = 2; | 117 | l = 2; |
| 118 | } | 118 | } |
| 119 | return ("000" + s).slice(l * -1); | 119 | return ("000" + s).slice(l * -1); |
| 120 | }; | 120 | }; |
| 121 | $P.clearTime = function () { | 121 | $P.clearTime = function () { |
| 122 | this.setHours(0); | 122 | this.setHours(0); |
| 123 | this.setMinutes(0); | 123 | this.setMinutes(0); |
| 124 | this.setSeconds(0); | 124 | this.setSeconds(0); |
| 125 | this.setMilliseconds(0); | 125 | this.setMilliseconds(0); |
| 126 | return this; | 126 | return this; |
| 127 | }; | 127 | }; |
| 128 | $P.setTimeToNow = function () { | 128 | $P.setTimeToNow = function () { |
| 129 | var n = new Date(); | 129 | var n = new Date(); |
| 130 | this.setHours(n.getHours()); | 130 | this.setHours(n.getHours()); |
| 131 | this.setMinutes(n.getMinutes()); | 131 | this.setMinutes(n.getMinutes()); |
| 132 | this.setSeconds(n.getSeconds()); | 132 | this.setSeconds(n.getSeconds()); |
| 133 | this.setMilliseconds(n.getMilliseconds()); | 133 | this.setMilliseconds(n.getMilliseconds()); |
| 134 | return this; | 134 | return this; |
| 135 | }; | 135 | }; |
| 136 | $D.today = function () { | 136 | $D.today = function () { |
| 137 | return new Date().clearTime(); | 137 | return new Date().clearTime(); |
| 138 | }; | 138 | }; |
| 139 | $D.compare = function (date1, date2) { | 139 | $D.compare = function (date1, date2) { |
| 140 | if (isNaN(date1) || isNaN(date2)) { | 140 | if (isNaN(date1) || isNaN(date2)) { |
| 141 | throw new Error(date1 + " - " + date2); | 141 | throw new Error(date1 + " - " + date2); |
| 142 | } else if (date1 instanceof Date && date2 instanceof Date) { | 142 | } else if (date1 instanceof Date && date2 instanceof Date) { |
| 143 | return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; | 143 | return (date1 < date2) ? -1 : (date1 > date2) ? 1 : 0; |
| 144 | } else { | 144 | } else { |
| 145 | throw new TypeError(date1 + " - " + date2); | 145 | throw new TypeError(date1 + " - " + date2); |
| 146 | } | 146 | } |
| 147 | }; | 147 | }; |
| 148 | $D.equals = function (date1, date2) { | 148 | $D.equals = function (date1, date2) { |
| 149 | return (date1.compareTo(date2) === 0); | 149 | return (date1.compareTo(date2) === 0); |
| 150 | }; | 150 | }; |
| 151 | $D.getDayNumberFromName = function (name) { | 151 | $D.getDayNumberFromName = function (name) { |
| 152 | var n = $C.dayNames, | 152 | var n = $C.dayNames, |
| 153 | m = $C.abbreviatedDayNames, | 153 | m = $C.abbreviatedDayNames, |
| 154 | o = $C.shortestDayNames, | 154 | o = $C.shortestDayNames, |
| 155 | s = name.toLowerCase(); | 155 | s = name.toLowerCase(); |
| 156 | for (var i = 0; i < n.length; i++) { | 156 | for (var i = 0; i < n.length; i++) { |
| 157 | if (n[i].toLowerCase() == s || m[i].toLowerCase() == s || o[i].toLowerCase() == s) { | 157 | if (n[i].toLowerCase() == s || m[i].toLowerCase() == s || o[i].toLowerCase() == s) { |
| 158 | return i; | 158 | return i; |
| 159 | } | 159 | } |
| 160 | } | 160 | } |
| 161 | return -1; | 161 | return -1; |
| 162 | }; | 162 | }; |
| 163 | $D.getMonthNumberFromName = function (name) { | 163 | $D.getMonthNumberFromName = function (name) { |
| 164 | var n = $C.monthNames, | 164 | var n = $C.monthNames, |
| 165 | m = $C.abbreviatedMonthNames, | 165 | m = $C.abbreviatedMonthNames, |
| 166 | s = name.toLowerCase(); | 166 | s = name.toLowerCase(); |
| 167 | for (var i = 0; i < n.length; i++) { | 167 | for (var i = 0; i < n.length; i++) { |
| 168 | if (n[i].toLowerCase() == s || m[i].toLowerCase() == s) { | 168 | if (n[i].toLowerCase() == s || m[i].toLowerCase() == s) { |
| 169 | return i; | 169 | return i; |
| 170 | } | 170 | } |
| 171 | } | 171 | } |
| 172 | return -1; | 172 | return -1; |
| 173 | }; | 173 | }; |
| 174 | $D.isLeapYear = function (year) { | 174 | $D.isLeapYear = function (year) { |
| 175 | return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); | 175 | return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); |
| 176 | }; | 176 | }; |
| 177 | $D.getDaysInMonth = function (year, month) { | 177 | $D.getDaysInMonth = function (year, month) { |
| 178 | return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; | 178 | return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; |
| 179 | }; | 179 | }; |
| 180 | $D.getTimezoneAbbreviation = function (offset) { | 180 | $D.getTimezoneAbbreviation = function (offset) { |
| 181 | var z = $C.timezones, | 181 | var z = $C.timezones, |
| 182 | p; | 182 | p; |
| 183 | for (var i = 0; i < z.length; i++) { | 183 | for (var i = 0; i < z.length; i++) { |
| 184 | if (z[i].offset === offset) { | 184 | if (z[i].offset === offset) { |
| 185 | return z[i].name; | 185 | return z[i].name; |
| 186 | } | 186 | } |
| 187 | } | 187 | } |
| 188 | return null; | 188 | return null; |
| 189 | }; | 189 | }; |
| 190 | $D.getTimezoneOffset = function (name) { | 190 | $D.getTimezoneOffset = function (name) { |
| 191 | var z = $C.timezones, | 191 | var z = $C.timezones, |
| 192 | p; | 192 | p; |
| 193 | for (var i = 0; i < z.length; i++) { | 193 | for (var i = 0; i < z.length; i++) { |
| 194 | if (z[i].name === name.toUpperCase()) { | 194 | if (z[i].name === name.toUpperCase()) { |
| 195 | return z[i].offset; | 195 | return z[i].offset; |
| 196 | } | 196 | } |
| 197 | } | 197 | } |
| 198 | return null; | 198 | return null; |
| 199 | }; | 199 | }; |
| 200 | $P.clone = function () { | 200 | $P.clone = function () { |
| 201 | return new Date(this.getTime()); | 201 | return new Date(this.getTime()); |
| 202 | }; | 202 | }; |
| 203 | $P.compareTo = function (date) { | 203 | $P.compareTo = function (date) { |
| 204 | return Date.compare(this, date); | 204 | return Date.compare(this, date); |
| 205 | }; | 205 | }; |
| 206 | $P.equals = function (date) { | 206 | $P.equals = function (date) { |
| 207 | return Date.equals(this, date || new Date()); | 207 | return Date.equals(this, date || new Date()); |
| 208 | }; | 208 | }; |
| 209 | $P.between = function (start, end) { | 209 | $P.between = function (start, end) { |
| 210 | return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); | 210 | return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); |
| 211 | }; | 211 | }; |
| 212 | $P.isAfter = function (date) { | 212 | $P.isAfter = function (date) { |
| 213 | return this.compareTo(date || new Date()) === 1; | 213 | return this.compareTo(date || new Date()) === 1; |
| 214 | }; | 214 | }; |
| 215 | $P.isBefore = function (date) { | 215 | $P.isBefore = function (date) { |
| 216 | return (this.compareTo(date || new Date()) === -1); | 216 | return (this.compareTo(date || new Date()) === -1); |
| 217 | }; | 217 | }; |
| 218 | $P.isToday = function () { | 218 | $P.isToday = function () { |
| 219 | return this.isSameDay(new Date()); | 219 | return this.isSameDay(new Date()); |
| 220 | }; | 220 | }; |
| 221 | $P.isSameDay = function (date) { | 221 | $P.isSameDay = function (date) { |
| 222 | return this.clone().clearTime().equals(date.clone().clearTime()); | 222 | return this.clone().clearTime().equals(date.clone().clearTime()); |
| 223 | }; | 223 | }; |
| 224 | $P.addMilliseconds = function (value) { | 224 | $P.addMilliseconds = function (value) { |
| 225 | this.setMilliseconds(this.getMilliseconds() + value); | 225 | this.setMilliseconds(this.getMilliseconds() + value); |
| 226 | return this; | 226 | return this; |
| 227 | }; | 227 | }; |
| 228 | $P.addSeconds = function (value) { | 228 | $P.addSeconds = function (value) { |
| 229 | return this.addMilliseconds(value * 1000); | 229 | return this.addMilliseconds(value * 1000); |
| 230 | }; | 230 | }; |
| 231 | $P.addMinutes = function (value) { | 231 | $P.addMinutes = function (value) { |
| 232 | return this.addMilliseconds(value * 60000); | 232 | return this.addMilliseconds(value * 60000); |
| 233 | }; | 233 | }; |
| 234 | $P.addHours = function (value) { | 234 | $P.addHours = function (value) { |
| 235 | return this.addMilliseconds(value * 3600000); | 235 | return this.addMilliseconds(value * 3600000); |
| 236 | }; | 236 | }; |
| 237 | $P.addDays = function (value) { | 237 | $P.addDays = function (value) { |
| 238 | this.setDate(this.getDate() + value); | 238 | this.setDate(this.getDate() + value); |
| 239 | return this; | 239 | return this; |
| 240 | }; | 240 | }; |
| 241 | $P.addWeeks = function (value) { | 241 | $P.addWeeks = function (value) { |
| 242 | return this.addDays(value * 7); | 242 | return this.addDays(value * 7); |
| 243 | }; | 243 | }; |
| 244 | $P.addMonths = function (value) { | 244 | $P.addMonths = function (value) { |
| 245 | var n = this.getDate(); | 245 | var n = this.getDate(); |
| 246 | this.setDate(1); | 246 | this.setDate(1); |
| 247 | this.setMonth(this.getMonth() + value); | 247 | this.setMonth(this.getMonth() + value); |
| 248 | this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); | 248 | this.setDate(Math.min(n, $D.getDaysInMonth(this.getFullYear(), this.getMonth()))); |
| 249 | return this; | 249 | return this; |
| 250 | }; | 250 | }; |
| 251 | $P.addYears = function (value) { | 251 | $P.addYears = function (value) { |
| 252 | return this.addMonths(value * 12); | 252 | return this.addMonths(value * 12); |
| 253 | }; | 253 | }; |
| 254 | $P.add = function (config) { | 254 | $P.add = function (config) { |
| 255 | if (typeof config == "number") { | 255 | if (typeof config == "number") { |
| 256 | this._orient = config; | 256 | this._orient = config; |
| 257 | return this; | 257 | return this; |
| 258 | } | 258 | } |
| 259 | var x = config; | 259 | var x = config; |
| 260 | if (x.milliseconds) { | 260 | if (x.milliseconds) { |
| 261 | this.addMilliseconds(x.milliseconds); | 261 | this.addMilliseconds(x.milliseconds); |
| 262 | } | 262 | } |
| 263 | if (x.seconds) { | 263 | if (x.seconds) { |
| 264 | this.addSeconds(x.seconds); | 264 | this.addSeconds(x.seconds); |
| 265 | } | 265 | } |
| 266 | if (x.minutes) { | 266 | if (x.minutes) { |
| 267 | this.addMinutes(x.minutes); | 267 | this.addMinutes(x.minutes); |
| 268 | } | 268 | } |
| 269 | if (x.hours) { | 269 | if (x.hours) { |
| 270 | this.addHours(x.hours); | 270 | this.addHours(x.hours); |
| 271 | } | 271 | } |
| 272 | if (x.weeks) { | 272 | if (x.weeks) { |
| 273 | this.addWeeks(x.weeks); | 273 | this.addWeeks(x.weeks); |
| 274 | } | 274 | } |
| 275 | if (x.months) { | 275 | if (x.months) { |
| 276 | this.addMonths(x.months); | 276 | this.addMonths(x.months); |
| 277 | } | 277 | } |
| 278 | if (x.years) { | 278 | if (x.years) { |
| 279 | this.addYears(x.years); | 279 | this.addYears(x.years); |
| 280 | } | 280 | } |
| 281 | if (x.days) { | 281 | if (x.days) { |
| 282 | this.addDays(x.days); | 282 | this.addDays(x.days); |
| 283 | } | 283 | } |
| 284 | return this; | 284 | return this; |
| 285 | }; | 285 | }; |
| 286 | var $y, $m, $d; | 286 | var $y, $m, $d; |
| 287 | $P.getWeek = function () { | 287 | $P.getWeek = function () { |
| 288 | var a, b, c, d, e, f, g, n, s, w; | 288 | var a, b, c, d, e, f, g, n, s, w; |
| 289 | $y = (!$y) ? this.getFullYear() : $y; | 289 | $y = (!$y) ? this.getFullYear() : $y; |
| 290 | $m = (!$m) ? this.getMonth() + 1 : $m; | 290 | $m = (!$m) ? this.getMonth() + 1 : $m; |
| 291 | $d = (!$d) ? this.getDate() : $d; | 291 | $d = (!$d) ? this.getDate() : $d; |
| 292 | if ($m <= 2) { | 292 | if ($m <= 2) { |
| 293 | a = $y - 1; | 293 | a = $y - 1; |
| 294 | b = (a / 4 | 0) - (a / 100 | 0) + (a / 400 | 0); | 294 | b = (a / 4 | 0) - (a / 100 | 0) + (a / 400 | 0); |
| 295 | c = ((a - 1) / 4 | 0) - ((a - 1) / 100 | 0) + ((a - 1) / 400 | 0); | 295 | c = ((a - 1) / 4 | 0) - ((a - 1) / 100 | 0) + ((a - 1) / 400 | 0); |
| 296 | s = b - c; | 296 | s = b - c; |
| 297 | e = 0; | 297 | e = 0; |
| 298 | f = $d - 1 + (31 * ($m - 1)); | 298 | f = $d - 1 + (31 * ($m - 1)); |
| 299 | } else { | 299 | } else { |
| 300 | a = $y; | 300 | a = $y; |
| 301 | b = (a / 4 | 0) - (a / 100 | 0) + (a / 400 | 0); | 301 | b = (a / 4 | 0) - (a / 100 | 0) + (a / 400 | 0); |
| 302 | c = ((a - 1) / 4 | 0) - ((a - 1) / 100 | 0) + ((a - 1) / 400 | 0); | 302 | c = ((a - 1) / 4 | 0) - ((a - 1) / 100 | 0) + ((a - 1) / 400 | 0); |
| 303 | s = b - c; | 303 | s = b - c; |
| 304 | e = s + 1; | 304 | e = s + 1; |
| 305 | f = $d + ((153 * ($m - 3) + 2) / 5) + 58 + s; | 305 | f = $d + ((153 * ($m - 3) + 2) / 5) + 58 + s; |
| 306 | } | 306 | } |
| 307 | g = (a + b) % 7; | 307 | g = (a + b) % 7; |
| 308 | d = (f + g - e) % 7; | 308 | d = (f + g - e) % 7; |
| 309 | n = (f + 3 - d) | 0; | 309 | n = (f + 3 - d) | 0; |
| 310 | if (n < 0) { | 310 | if (n < 0) { |
| 311 | w = 53 - ((g - s) / 5 | 0); | 311 | w = 53 - ((g - s) / 5 | 0); |
| 312 | } else if (n > 364 + s) { | 312 | } else if (n > 364 + s) { |
| 313 | w = 1; | 313 | w = 1; |
| 314 | } else { | 314 | } else { |
| 315 | w = (n / 7 | 0) + 1; | 315 | w = (n / 7 | 0) + 1; |
| 316 | } | 316 | } |
| 317 | $y = $m = $d = null; | 317 | $y = $m = $d = null; |
| 318 | return w; | 318 | return w; |
| 319 | }; | 319 | }; |
| 320 | $P.getISOWeek = function () { | 320 | $P.getISOWeek = function () { |
| 321 | $y = this.getUTCFullYear(); | 321 | $y = this.getUTCFullYear(); |
| 322 | $m = this.getUTCMonth() + 1; | 322 | $m = this.getUTCMonth() + 1; |
| 323 | $d = this.getUTCDate(); | 323 | $d = this.getUTCDate(); |
| 324 | return p(this.getWeek()); | 324 | return p(this.getWeek()); |
| 325 | }; | 325 | }; |
| 326 | $P.setWeek = function (n) { | 326 | $P.setWeek = function (n) { |
| 327 | return this.moveToDayOfWeek(1).addWeeks(n - this.getWeek()); | 327 | return this.moveToDayOfWeek(1).addWeeks(n - this.getWeek()); |
| 328 | }; | 328 | }; |
| 329 | $D._validate = function (n, min, max, name) { | 329 | $D._validate = function (n, min, max, name) { |
| 330 | if (typeof n == "undefined") { | 330 | if (typeof n == "undefined") { |
| 331 | return false; | 331 | return false; |
| 332 | } else if (typeof n != "number") { | 332 | } else if (typeof n != "number") { |
| 333 | throw new TypeError(n + " is not a Number."); | 333 | throw new TypeError(n + " is not a Number."); |
| 334 | } else if (n < min || n > max) { | 334 | } else if (n < min || n > max) { |
| 335 | throw new RangeError(n + " is not a valid value for " + name + "."); | 335 | throw new RangeError(n + " is not a valid value for " + name + "."); |
| 336 | } | 336 | } |
| 337 | return true; | 337 | return true; |
| 338 | }; | 338 | }; |
| 339 | $D.validateMillisecond = function (value) { | 339 | $D.validateMillisecond = function (value) { |
| 340 | return $D._validate(value, 0, 999, "millisecond"); | 340 | return $D._validate(value, 0, 999, "millisecond"); |
| 341 | }; | 341 | }; |
| 342 | $D.validateSecond = function (value) { | 342 | $D.validateSecond = function (value) { |
| 343 | return $D._validate(value, 0, 59, "second"); | 343 | return $D._validate(value, 0, 59, "second"); |
| 344 | }; | 344 | }; |
| 345 | $D.validateMinute = function (value) { | 345 | $D.validateMinute = function (value) { |
| 346 | return $D._validate(value, 0, 59, "minute"); | 346 | return $D._validate(value, 0, 59, "minute"); |
| 347 | }; | 347 | }; |
| 348 | $D.validateHour = function (value) { | 348 | $D.validateHour = function (value) { |
| 349 | return $D._validate(value, 0, 23, "hour"); | 349 | return $D._validate(value, 0, 23, "hour"); |
| 350 | }; | 350 | }; |
| 351 | $D.validateDay = function (value, year, month) { | 351 | $D.validateDay = function (value, year, month) { |
| 352 | return $D._validate(value, 1, $D.getDaysInMonth(year, month), "day"); | 352 | return $D._validate(value, 1, $D.getDaysInMonth(year, month), "day"); |
| 353 | }; | 353 | }; |
| 354 | $D.validateMonth = function (value) { | 354 | $D.validateMonth = function (value) { |
| 355 | return $D._validate(value, 0, 11, "month"); | 355 | return $D._validate(value, 0, 11, "month"); |
| 356 | }; | 356 | }; |
| 357 | $D.validateYear = function (value) { | 357 | $D.validateYear = function (value) { |
| 358 | return $D._validate(value, 0, 9999, "year"); | 358 | return $D._validate(value, 0, 9999, "year"); |
| 359 | }; | 359 | }; |
| 360 | $P.set = function (config) { | 360 | $P.set = function (config) { |
| 361 | if ($D.validateMillisecond(config.millisecond)) { | 361 | if ($D.validateMillisecond(config.millisecond)) { |
| 362 | this.addMilliseconds(config.millisecond - this.getMilliseconds()); | 362 | this.addMilliseconds(config.millisecond - this.getMilliseconds()); |
| 363 | } | 363 | } |
| 364 | if ($D.validateSecond(config.second)) { | 364 | if ($D.validateSecond(config.second)) { |
| 365 | this.addSeconds(config.second - this.getSeconds()); | 365 | this.addSeconds(config.second - this.getSeconds()); |
| 366 | } | 366 | } |
| 367 | if ($D.validateMinute(config.minute)) { | 367 | if ($D.validateMinute(config.minute)) { |
| 368 | this.addMinutes(config.minute - this.getMinutes()); | 368 | this.addMinutes(config.minute - this.getMinutes()); |
| 369 | } | 369 | } |
| 370 | if ($D.validateHour(config.hour)) { | 370 | if ($D.validateHour(config.hour)) { |
| 371 | this.addHours(config.hour - this.getHours()); | 371 | this.addHours(config.hour - this.getHours()); |
| 372 | } | 372 | } |
| 373 | if ($D.validateMonth(config.month)) { | 373 | if ($D.validateMonth(config.month)) { |
| 374 | this.addMonths(config.month - this.getMonth()); | 374 | this.addMonths(config.month - this.getMonth()); |
| 375 | } | 375 | } |
| 376 | if ($D.validateYear(config.year)) { | 376 | if ($D.validateYear(config.year)) { |
| 377 | this.addYears(config.year - this.getFullYear()); | 377 | this.addYears(config.year - this.getFullYear()); |
| 378 | } | 378 | } |
| 379 | if ($D.validateDay(config.day, this.getFullYear(), this.getMonth())) { | 379 | if ($D.validateDay(config.day, this.getFullYear(), this.getMonth())) { |
| 380 | this.addDays(config.day - this.getDate()); | 380 | this.addDays(config.day - this.getDate()); |
| 381 | } | 381 | } |
| 382 | if (config.timezone) { | 382 | if (config.timezone) { |
| 383 | this.setTimezone(config.timezone); | 383 | this.setTimezone(config.timezone); |
| 384 | } | 384 | } |
| 385 | if (config.timezoneOffset) { | 385 | if (config.timezoneOffset) { |
| 386 | this.setTimezoneOffset(config.timezoneOffset); | 386 | this.setTimezoneOffset(config.timezoneOffset); |
| 387 | } | 387 | } |
| 388 | if (config.week && $D._validate(config.week, 0, 53, "week")) { | 388 | if (config.week && $D._validate(config.week, 0, 53, "week")) { |
| 389 | this.setWeek(config.week); | 389 | this.setWeek(config.week); |
| 390 | } | 390 | } |
| 391 | return this; | 391 | return this; |
| 392 | }; | 392 | }; |
| 393 | $P.moveToFirstDayOfMonth = function () { | 393 | $P.moveToFirstDayOfMonth = function () { |
| 394 | return this.set({ | 394 | return this.set({ |
| 395 | day: 1 | 395 | day: 1 |
| 396 | }); | 396 | }); |
| 397 | }; | 397 | }; |
| 398 | $P.moveToLastDayOfMonth = function () { | 398 | $P.moveToLastDayOfMonth = function () { |
| 399 | return this.set({ | 399 | return this.set({ |
| 400 | day: $D.getDaysInMonth(this.getFullYear(), this.getMonth()) | 400 | day: $D.getDaysInMonth(this.getFullYear(), this.getMonth()) |
| 401 | }); | 401 | }); |
| 402 | }; | 402 | }; |
| 403 | $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { | 403 | $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { |
| 404 | var shift = 0; | 404 | var shift = 0; |
| 405 | if (occurrence > 0) { | 405 | if (occurrence > 0) { |
| 406 | shift = occurrence - 1; | 406 | shift = occurrence - 1; |
| 407 | } else if (occurrence === -1) { | 407 | } else if (occurrence === -1) { |
| 408 | this.moveToLastDayOfMonth(); | 408 | this.moveToLastDayOfMonth(); |
| 409 | if (this.getDay() !== dayOfWeek) { | 409 | if (this.getDay() !== dayOfWeek) { |
| 410 | this.moveToDayOfWeek(dayOfWeek, -1); | 410 | this.moveToDayOfWeek(dayOfWeek, -1); |
| 411 | } | 411 | } |
| 412 | return this; | 412 | return this; |
| 413 | } | 413 | } |
| 414 | return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); | 414 | return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(dayOfWeek, +1).addWeeks(shift); |
| 415 | }; | 415 | }; |
| 416 | $P.moveToDayOfWeek = function (dayOfWeek, orient) { | 416 | $P.moveToDayOfWeek = function (dayOfWeek, orient) { |
| 417 | var diff = (dayOfWeek - this.getDay() + 7 * (orient || +1)) % 7; | 417 | var diff = (dayOfWeek - this.getDay() + 7 * (orient || +1)) % 7; |
| 418 | return this.addDays((diff === 0) ? diff += 7 * (orient || +1) : diff); | 418 | return this.addDays((diff === 0) ? diff += 7 * (orient || +1) : diff); |
| 419 | }; | 419 | }; |
| 420 | $P.moveToMonth = function (month, orient) { | 420 | $P.moveToMonth = function (month, orient) { |
| 421 | var diff = (month - this.getMonth() + 12 * (orient || +1)) % 12; | 421 | var diff = (month - this.getMonth() + 12 * (orient || +1)) % 12; |
| 422 | return this.addMonths((diff === 0) ? diff += 12 * (orient || +1) : diff); | 422 | return this.addMonths((diff === 0) ? diff += 12 * (orient || +1) : diff); |
| 423 | }; | 423 | }; |
| 424 | $P.getOrdinalNumber = function () { | 424 | $P.getOrdinalNumber = function () { |
| 425 | return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; | 425 | return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; |
| 426 | }; | 426 | }; |
| 427 | $P.getTimezone = function () { | 427 | $P.getTimezone = function () { |
| 428 | return $D.getTimezoneAbbreviation(this.getUTCOffset()); | 428 | return $D.getTimezoneAbbreviation(this.getUTCOffset()); |
| 429 | }; | 429 | }; |
| 430 | $P.setTimezoneOffset = function (offset) { | 430 | $P.setTimezoneOffset = function (offset) { |
| 431 | var here = this.getTimezoneOffset(), | 431 | var here = this.getTimezoneOffset(), |
| 432 | there = Number(offset) * -6 / 10; | 432 | there = Number(offset) * -6 / 10; |
| 433 | return this.addMinutes(there - here); | 433 | return this.addMinutes(there - here); |
| 434 | }; | 434 | }; |
| 435 | $P.setTimezone = function (offset) { | 435 | $P.setTimezone = function (offset) { |
| 436 | return this.setTimezoneOffset($D.getTimezoneOffset(offset)); | 436 | return this.setTimezoneOffset($D.getTimezoneOffset(offset)); |
| 437 | }; | 437 | }; |
| 438 | $P.hasDaylightSavingTime = function () { | 438 | $P.hasDaylightSavingTime = function () { |
| 439 | return (Date.today().set({ | 439 | return (Date.today().set({ |
| 440 | month: 0, | 440 | month: 0, |
| 441 | day: 1 | 441 | day: 1 |
| 442 | }).getTimezoneOffset() !== Date.today().set({ | 442 | }).getTimezoneOffset() !== Date.today().set({ |
| 443 | month: 6, | 443 | month: 6, |
| 444 | day: 1 | 444 | day: 1 |
| 445 | }).getTimezoneOffset()); | 445 | }).getTimezoneOffset()); |
| 446 | }; | 446 | }; |
| 447 | $P.isDaylightSavingTime = function () { | 447 | $P.isDaylightSavingTime = function () { |
| 448 | return (this.hasDaylightSavingTime() && new Date().getTimezoneOffset() === Date.today().set({ | 448 | return (this.hasDaylightSavingTime() && new Date().getTimezoneOffset() === Date.today().set({ |
| 449 | month: 6, | 449 | month: 6, |
| 450 | day: 1 | 450 | day: 1 |
| 451 | }).getTimezoneOffset()); | 451 | }).getTimezoneOffset()); |
| 452 | }; | 452 | }; |
| 453 | $P.getUTCOffset = function () { | 453 | $P.getUTCOffset = function () { |
| 454 | var n = this.getTimezoneOffset() * -10 / 6, | 454 | var n = this.getTimezoneOffset() * -10 / 6, |
| 455 | r; | 455 | r; |
| 456 | if (n < 0) { | 456 | if (n < 0) { |
| 457 | r = (n - 10000).toString(); | 457 | r = (n - 10000).toString(); |
| 458 | return r.charAt(0) + r.substr(2); | 458 | return r.charAt(0) + r.substr(2); |
| 459 | } else { | 459 | } else { |
| 460 | r = (n + 10000).toString(); | 460 | r = (n + 10000).toString(); |
| 461 | return "+" + r.substr(1); | 461 | return "+" + r.substr(1); |
| 462 | } | 462 | } |
| 463 | }; | 463 | }; |
| 464 | $P.getElapsed = function (date) { | 464 | $P.getElapsed = function (date) { |
| 465 | return (date || new Date()) - this; | 465 | return (date || new Date()) - this; |
| 466 | }; | 466 | }; |
| 467 | if (!$P.toISOString) { | 467 | if (!$P.toISOString) { |
| 468 | $P.toISOString = function () { | 468 | $P.toISOString = function () { |
| 469 | function f(n) { | 469 | function f(n) { |
| 470 | return n < 10 ? '0' + n : n; | 470 | return n < 10 ? '0' + n : n; |
| 471 | } | 471 | } |
| 472 | return '"' + this.getUTCFullYear() + '-' + | 472 | return '"' + this.getUTCFullYear() + '-' + |
| 473 | f(this.getUTCMonth() + 1) + '-' + | 473 | f(this.getUTCMonth() + 1) + '-' + |
| 474 | f(this.getUTCDate()) + 'T' + | 474 | f(this.getUTCDate()) + 'T' + |
| 475 | f(this.getUTCHours()) + ':' + | 475 | f(this.getUTCHours()) + ':' + |
| 476 | f(this.getUTCMinutes()) + ':' + | 476 | f(this.getUTCMinutes()) + ':' + |
| 477 | f(this.getUTCSeconds()) + 'Z"'; | 477 | f(this.getUTCSeconds()) + 'Z"'; |
| 478 | }; | 478 | }; |
| 479 | } | 479 | } |
| 480 | $P._toString = $P.toString; | 480 | $P._toString = $P.toString; |
| 481 | $P.toString = function (format) { | 481 | $P.toString = function (format) { |
| 482 | var x = this; | 482 | var x = this; |
| 483 | if (format && format.length == 1) { | 483 | if (format && format.length == 1) { |
| 484 | var c = $C.formatPatterns; | 484 | var c = $C.formatPatterns; |
| 485 | x.t = x.toString; | 485 | x.t = x.toString; |
| 486 | switch (format) { | 486 | switch (format) { |
| 487 | case "d": | 487 | case "d": |
| 488 | return x.t(c.shortDate); | 488 | return x.t(c.shortDate); |
| 489 | case "D": | 489 | case "D": |
| 490 | return x.t(c.longDate); | 490 | return x.t(c.longDate); |
| 491 | case "F": | 491 | case "F": |
| 492 | return x.t(c.fullDateTime); | 492 | return x.t(c.fullDateTime); |
| 493 | case "m": | 493 | case "m": |
| 494 | return x.t(c.monthDay); | 494 | return x.t(c.monthDay); |
| 495 | case "r": | 495 | case "r": |
| 496 | return x.t(c.rfc1123); | 496 | return x.t(c.rfc1123); |
| 497 | case "s": | 497 | case "s": |
| 498 | return x.t(c.sortableDateTime); | 498 | return x.t(c.sortableDateTime); |
| 499 | case "t": | 499 | case "t": |
| 500 | return x.t(c.shortTime); | 500 | return x.t(c.shortTime); |
| 501 | case "T": | 501 | case "T": |
| 502 | return x.t(c.longTime); | 502 | return x.t(c.longTime); |
| 503 | case "u": | 503 | case "u": |
| 504 | return x.t(c.universalSortableDateTime); | 504 | return x.t(c.universalSortableDateTime); |
| 505 | case "y": | 505 | case "y": |
| 506 | return x.t(c.yearMonth); | 506 | return x.t(c.yearMonth); |
| 507 | } | 507 | } |
| 508 | } | 508 | } |
| 509 | var ord = function (n) { | 509 | var ord = function (n) { |
| 510 | switch (n * 1) { | 510 | switch (n * 1) { |
| 511 | case 1: | 511 | case 1: |
| 512 | case 21: | 512 | case 21: |
| 513 | case 31: | 513 | case 31: |
| 514 | return "st"; | 514 | return "st"; |
| 515 | case 2: | 515 | case 2: |
| 516 | case 22: | 516 | case 22: |
| 517 | return "nd"; | 517 | return "nd"; |
| 518 | case 3: | 518 | case 3: |
| 519 | case 23: | 519 | case 23: |
| 520 | return "rd"; | 520 | return "rd"; |
| 521 | default: | 521 | default: |
| 522 | return "th"; | 522 | return "th"; |
| 523 | } | 523 | } |
| 524 | }; | 524 | }; |
| 525 | return format ? format.replace(/(\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S)/g, function (m) { | 525 | return format ? format.replace(/(\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S)/g, function (m) { |
| 526 | if (m.charAt(0) === "\\") { | 526 | if (m.charAt(0) === "\\") { |
| 527 | return m.replace("\\", ""); | 527 | return m.replace("\\", ""); |
| 528 | } | 528 | } |
| 529 | x.h = x.getHours; | 529 | x.h = x.getHours; |
| 530 | switch (m) { | 530 | switch (m) { |
| 531 | case "hh": | 531 | case "hh": |
| 532 | return p(x.h() < 13 ? (x.h() === 0 ? 12 : x.h()) : (x.h() - 12)); | 532 | return p(x.h() < 13 ? (x.h() === 0 ? 12 : x.h()) : (x.h() - 12)); |
| 533 | case "h": | 533 | case "h": |
| 534 | return x.h() < 13 ? (x.h() === 0 ? 12 : x.h()) : (x.h() - 12); | 534 | return x.h() < 13 ? (x.h() === 0 ? 12 : x.h()) : (x.h() - 12); |
| 535 | case "HH": | 535 | case "HH": |
| 536 | return p(x.h()); | 536 | return p(x.h()); |
| 537 | case "H": | 537 | case "H": |
| 538 | return x.h(); | 538 | return x.h(); |
| 539 | case "mm": | 539 | case "mm": |
| 540 | return p(x.getMinutes()); | 540 | return p(x.getMinutes()); |
| 541 | case "m": | 541 | case "m": |
| 542 | return x.getMinutes(); | 542 | return x.getMinutes(); |
| 543 | case "ss": | 543 | case "ss": |
| 544 | return p(x.getSeconds()); | 544 | return p(x.getSeconds()); |
| 545 | case "s": | 545 | case "s": |
| 546 | return x.getSeconds(); | 546 | return x.getSeconds(); |
| 547 | case "yyyy": | 547 | case "yyyy": |
| 548 | return p(x.getFullYear(), 4); | 548 | return p(x.getFullYear(), 4); |
| 549 | case "yy": | 549 | case "yy": |
| 550 | return p(x.getFullYear()); | 550 | return p(x.getFullYear()); |
| 551 | case "dddd": | 551 | case "dddd": |
| 552 | return $C.dayNames[x.getDay()]; | 552 | return $C.dayNames[x.getDay()]; |
| 553 | case "ddd": | 553 | case "ddd": |
| 554 | return $C.abbreviatedDayNames[x.getDay()]; | 554 | return $C.abbreviatedDayNames[x.getDay()]; |
| 555 | case "dd": | 555 | case "dd": |
| 556 | return p(x.getDate()); | 556 | return p(x.getDate()); |
| 557 | case "d": | 557 | case "d": |
| 558 | return x.getDate(); | 558 | return x.getDate(); |
| 559 | case "MMMM": | 559 | case "MMMM": |
| 560 | return $C.monthNames[x.getMonth()]; | 560 | return $C.monthNames[x.getMonth()]; |
| 561 | case "MMM": | 561 | case "MMM": |
| 562 | return $C.abbreviatedMonthNames[x.getMonth()]; | 562 | return $C.abbreviatedMonthNames[x.getMonth()]; |
| 563 | case "MM": | 563 | case "MM": |
| 564 | return p((x.getMonth() + 1)); | 564 | return p((x.getMonth() + 1)); |
| 565 | case "M": | 565 | case "M": |
| 566 | return x.getMonth() + 1; | 566 | return x.getMonth() + 1; |
| 567 | case "t": | 567 | case "t": |
| 568 | return x.h() < 12 ? $C.amDesignator.substring(0, 1) : $C.pmDesignator.substring(0, 1); | 568 | return x.h() < 12 ? $C.amDesignator.substring(0, 1) : $C.pmDesignator.substring(0, 1); |
| 569 | case "tt": | 569 | case "tt": |
| 570 | return x.h() < 12 ? $C.amDesignator : $C.pmDesignator; | 570 | return x.h() < 12 ? $C.amDesignator : $C.pmDesignator; |
| 571 | case "S": | 571 | case "S": |
| 572 | return ord(x.getDate()); | 572 | return ord(x.getDate()); |
| 573 | default: | 573 | default: |
| 574 | return m; | 574 | return m; |
| 575 | } | 575 | } |
| 576 | }) : this._toString(); | 576 | }) : this._toString(); |
| 577 | }; | 577 | }; |
| 578 | }()); | 578 | }()); |
| 579 | (function () { | 579 | (function () { |
| 580 | var $D = Date, | 580 | var $D = Date, |
| 581 | $P = $D.prototype, | 581 | $P = $D.prototype, |
| 582 | $C = $D.CultureInfo, | 582 | $C = $D.CultureInfo, |
| 583 | $N = Number.prototype; | 583 | $N = Number.prototype; |
| 584 | $P._orient = +1; | 584 | $P._orient = +1; |
| 585 | $P._nth = null; | 585 | $P._nth = null; |
| 586 | $P._is = false; | 586 | $P._is = false; |
| 587 | $P._same = false; | 587 | $P._same = false; |
| 588 | $P._isSecond = false; | 588 | $P._isSecond = false; |
| 589 | $N._dateElement = "day"; | 589 | $N._dateElement = "day"; |
| 590 | $P.next = function () { | 590 | $P.next = function () { |
| 591 | this._orient = +1; | 591 | this._orient = +1; |
| 592 | return this; | 592 | return this; |
| 593 | }; | 593 | }; |
| 594 | $D.next = function () { | 594 | $D.next = function () { |
| 595 | return $D.today().next(); | 595 | return $D.today().next(); |
| 596 | }; | 596 | }; |
| 597 | $P.last = $P.prev = $P.previous = function () { | 597 | $P.last = $P.prev = $P.previous = function () { |
| 598 | this._orient = -1; | 598 | this._orient = -1; |
| 599 | return this; | 599 | return this; |
| 600 | }; | 600 | }; |
| 601 | $D.last = $D.prev = $D.previous = function () { | 601 | $D.last = $D.prev = $D.previous = function () { |
| 602 | return $D.today().last(); | 602 | return $D.today().last(); |
| 603 | }; | 603 | }; |
| 604 | $P.is = function () { | 604 | $P.is = function () { |
| 605 | this._is = true; | 605 | this._is = true; |
| 606 | return this; | 606 | return this; |
| 607 | }; | 607 | }; |
| 608 | $P.same = function () { | 608 | $P.same = function () { |
| 609 | this._same = true; | 609 | this._same = true; |
| 610 | this._isSecond = false; | 610 | this._isSecond = false; |
| 611 | return this; | 611 | return this; |
| 612 | }; | 612 | }; |
| 613 | $P.today = function () { | 613 | $P.today = function () { |
| 614 | return this.same().day(); | 614 | return this.same().day(); |
| 615 | }; | 615 | }; |
| 616 | $P.weekday = function () { | 616 | $P.weekday = function () { |
| 617 | if (this._is) { | 617 | if (this._is) { |
| 618 | this._is = false; | 618 | this._is = false; |
| 619 | return (!this.is().sat() && !this.is().sun()); | 619 | return (!this.is().sat() && !this.is().sun()); |
| 620 | } | 620 | } |
| 621 | return false; | 621 | return false; |
| 622 | }; | 622 | }; |
| 623 | $P.at = function (time) { | 623 | $P.at = function (time) { |
| 624 | return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); | 624 | return (typeof time === "string") ? $D.parse(this.toString("d") + " " + time) : this.set(time); |
| 625 | }; | 625 | }; |
| 626 | $N.fromNow = $N.after = function (date) { | 626 | $N.fromNow = $N.after = function (date) { |
| 627 | var c = {}; | 627 | var c = {}; |
| 628 | c[this._dateElement] = this; | 628 | c[this._dateElement] = this; |
| 629 | return ((!date) ? new Date() : date.clone()).add(c); | 629 | return ((!date) ? new Date() : date.clone()).add(c); |
| 630 | }; | 630 | }; |
| 631 | $N.ago = $N.before = function (date) { | 631 | $N.ago = $N.before = function (date) { |
| 632 | var c = {}; | 632 | var c = {}; |
| 633 | c[this._dateElement] = this * -1; | 633 | c[this._dateElement] = this * -1; |
| 634 | return ((!date) ? new Date() : date.clone()).add(c); | 634 | return ((!date) ? new Date() : date.clone()).add(c); |
| 635 | }; | 635 | }; |
| 636 | var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), | 636 | var dx = ("sunday monday tuesday wednesday thursday friday saturday").split(/\s/), |
| 637 | mx = ("january february march april may june july august september october november december").split(/\s/), | 637 | mx = ("january february march april may june july august september october november december").split(/\s/), |
| 638 | px = ("Millisecond Second Minute Hour Day Week Month Year").split(/\s/), | 638 | px = ("Millisecond Second Minute Hour Day Week Month Year").split(/\s/), |
| 639 | pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear").split(/\s/), | 639 | pxf = ("Milliseconds Seconds Minutes Hours Date Week Month FullYear").split(/\s/), |
| 640 | nth = ("final first second third fourth fifth").split(/\s/), | 640 | nth = ("final first second third fourth fifth").split(/\s/), |
| 641 | de; | 641 | de; |
| 642 | $P.toObject = function () { | 642 | $P.toObject = function () { |
| 643 | var o = {}; | 643 | var o = {}; |
| 644 | for (var i = 0; i < px.length; i++) { | 644 | for (var i = 0; i < px.length; i++) { |
| 645 | o[px[i].toLowerCase()] = this["get" + pxf[i]](); | 645 | o[px[i].toLowerCase()] = this["get" + pxf[i]](); |
| 646 | } | 646 | } |
| 647 | return o; | 647 | return o; |
| 648 | }; | 648 | }; |
| 649 | $D.fromObject = function (config) { | 649 | $D.fromObject = function (config) { |
| 650 | config.week = null; | 650 | config.week = null; |
| 651 | return Date.today().set(config); | 651 | return Date.today().set(config); |
| 652 | }; | 652 | }; |
| 653 | var df = function (n) { | 653 | var df = function (n) { |
| 654 | return function () { | 654 | return function () { |
| 655 | if (this._is) { | 655 | if (this._is) { |
| 656 | this._is = false; | 656 | this._is = false; |
| 657 | return this.getDay() == n; | 657 | return this.getDay() == n; |
| 658 | } | 658 | } |
| 659 | if (this._nth !== null) { | 659 | if (this._nth !== null) { |
| 660 | if (this._isSecond) { | 660 | if (this._isSecond) { |
| 661 | this.addSeconds(this._orient * -1); | 661 | this.addSeconds(this._orient * -1); |
| 662 | } | 662 | } |
| 663 | this._isSecond = false; | 663 | this._isSecond = false; |
| 664 | var ntemp = this._nth; | 664 | var ntemp = this._nth; |
| 665 | this._nth = null; | 665 | this._nth = null; |
| 666 | var temp = this.clone().moveToLastDayOfMonth(); | 666 | var temp = this.clone().moveToLastDayOfMonth(); |
| 667 | this.moveToNthOccurrence(n, ntemp); | 667 | this.moveToNthOccurrence(n, ntemp); |
| 668 | if (this > temp) { | 668 | if (this > temp) { |
| 669 | throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); | 669 | throw new RangeError($D.getDayName(n) + " does not occur " + ntemp + " times in the month of " + $D.getMonthName(temp.getMonth()) + " " + temp.getFullYear() + "."); |
| 670 | } | 670 | } |
| 671 | return this; | 671 | return this; |
| 672 | } | 672 | } |
| 673 | return this.moveToDayOfWeek(n, this._orient); | 673 | return this.moveToDayOfWeek(n, this._orient); |
| 674 | }; | 674 | }; |
| 675 | }; | 675 | }; |
| 676 | var sdf = function (n) { | 676 | var sdf = function (n) { |
| 677 | return function () { | 677 | return function () { |
| 678 | var t = $D.today(), | 678 | var t = $D.today(), |
| 679 | shift = n - t.getDay(); | 679 | shift = n - t.getDay(); |
| 680 | if (n === 0 && $C.firstDayOfWeek === 1 && t.getDay() !== 0) { | 680 | if (n === 0 && $C.firstDayOfWeek === 1 && t.getDay() !== 0) { |
| 681 | shift = shift + 7; | 681 | shift = shift + 7; |
| 682 | } | 682 | } |
| 683 | return t.addDays(shift); | 683 | return t.addDays(shift); |
| 684 | }; | 684 | }; |
| 685 | }; | 685 | }; |
| 686 | for (var i = 0; i < dx.length; i++) { | 686 | for (var i = 0; i < dx.length; i++) { |
| 687 | $D[dx[i].toUpperCase()] = $D[dx[i].toUpperCase().substring(0, 3)] = i; | 687 | $D[dx[i].toUpperCase()] = $D[dx[i].toUpperCase().substring(0, 3)] = i; |
| 688 | $D[dx[i]] = $D[dx[i].substring(0, 3)] = sdf(i); | 688 | $D[dx[i]] = $D[dx[i].substring(0, 3)] = sdf(i); |
| 689 | $P[dx[i]] = $P[dx[i].substring(0, 3)] = df(i); | 689 | $P[dx[i]] = $P[dx[i].substring(0, 3)] = df(i); |
| 690 | } | 690 | } |
| 691 | var mf = function (n) { | 691 | var mf = function (n) { |
| 692 | return function () { | 692 | return function () { |
| 693 | if (this._is) { | 693 | if (this._is) { |
| 694 | this._is = false; | 694 | this._is = false; |
| 695 | return this.getMonth() === n; | 695 | return this.getMonth() === n; |
| 696 | } | 696 | } |
| 697 | return this.moveToMonth(n, this._orient); | 697 | return this.moveToMonth(n, this._orient); |
| 698 | }; | 698 | }; |
| 699 | }; | 699 | }; |
| 700 | var smf = function (n) { | 700 | var smf = function (n) { |
| 701 | return function () { | 701 | return function () { |
| 702 | return $D.today().set({ | 702 | return $D.today().set({ |
| 703 | month: n, | 703 | month: n, |
| 704 | day: 1 | 704 | day: 1 |
| 705 | }); | 705 | }); |
| 706 | }; | 706 | }; |
| 707 | }; | 707 | }; |
| 708 | for (var j = 0; j < mx.length; j++) { | 708 | for (var j = 0; j < mx.length; j++) { |
| 709 | $D[mx[j].toUpperCase()] = $D[mx[j].toUpperCase().substring(0, 3)] = j; | 709 | $D[mx[j].toUpperCase()] = $D[mx[j].toUpperCase().substring(0, 3)] = j; |
| 710 | $D[mx[j]] = $D[mx[j].substring(0, 3)] = smf(j); | 710 | $D[mx[j]] = $D[mx[j].substring(0, 3)] = smf(j); |
| 711 | $P[mx[j]] = $P[mx[j].substring(0, 3)] = mf(j); | 711 | $P[mx[j]] = $P[mx[j].substring(0, 3)] = mf(j); |
| 712 | } | 712 | } |
| 713 | var ef = function (j) { | 713 | var ef = function (j) { |
| 714 | return function () { | 714 | return function () { |
| 715 | if (this._isSecond) { | 715 | if (this._isSecond) { |
| 716 | this._isSecond = false; | 716 | this._isSecond = false; |
| 717 | return this; | 717 | return this; |
| 718 | } | 718 | } |
| 719 | if (this._same) { | 719 | if (this._same) { |
| 720 | this._same = this._is = false; | 720 | this._same = this._is = false; |
| 721 | var o1 = this.toObject(), | 721 | var o1 = this.toObject(), |
| 722 | o2 = (arguments[0] || new Date()).toObject(), | 722 | o2 = (arguments[0] || new Date()).toObject(), |
| 723 | v = "", | 723 | v = "", |
| 724 | k = j.toLowerCase(); | 724 | k = j.toLowerCase(); |
| 725 | for (var m = (px.length - 1); m > -1; m--) { | 725 | for (var m = (px.length - 1); m > -1; m--) { |
| 726 | v = px[m].toLowerCase(); | 726 | v = px[m].toLowerCase(); |
| 727 | if (o1[v] != o2[v]) { | 727 | if (o1[v] != o2[v]) { |
| 728 | return false; | 728 | return false; |
| 729 | } | 729 | } |
| 730 | if (k == v) { | 730 | if (k == v) { |
| 731 | break; | 731 | break; |
| 732 | } | 732 | } |
| 733 | } | 733 | } |
| 734 | return true; | 734 | return true; |
| 735 | } | 735 | } |
| 736 | if (j.substring(j.length - 1) != "s") { | 736 | if (j.substring(j.length - 1) != "s") { |
| 737 | j += "s"; | 737 | j += "s"; |
| 738 | } | 738 | } |
| 739 | return this["add" + j](this._orient); | 739 | return this["add" + j](this._orient); |
| 740 | }; | 740 | }; |
| 741 | }; | 741 | }; |
| 742 | var nf = function (n) { | 742 | var nf = function (n) { |
| 743 | return function () { | 743 | return function () { |
| 744 | this._dateElement = n; | 744 | this._dateElement = n; |
| 745 | return this; | 745 | return this; |
| 746 | }; | 746 | }; |
| 747 | }; | 747 | }; |
| 748 | for (var k = 0; k < px.length; k++) { | 748 | for (var k = 0; k < px.length; k++) { |
| 749 | de = px[k].toLowerCase(); | 749 | de = px[k].toLowerCase(); |
| 750 | $P[de] = $P[de + "s"] = ef(px[k]); | 750 | $P[de] = $P[de + "s"] = ef(px[k]); |
| 751 | $N[de] = $N[de + "s"] = nf(de); | 751 | $N[de] = $N[de + "s"] = nf(de); |
| 752 | } | 752 | } |
| 753 | $P._ss = ef("Second"); | 753 | $P._ss = ef("Second"); |
| 754 | var nthfn = function (n) { | 754 | var nthfn = function (n) { |
| 755 | return function (dayOfWeek) { | 755 | return function (dayOfWeek) { |
| 756 | if (this._same) { | 756 | if (this._same) { |
| 757 | return this._ss(arguments[0]); | 757 | return this._ss(arguments[0]); |
| 758 | } | 758 | } |
| 759 | if (dayOfWeek || dayOfWeek === 0) { | 759 | if (dayOfWeek || dayOfWeek === 0) { |
| 760 | return this.moveToNthOccurrence(dayOfWeek, n); | 760 | return this.moveToNthOccurrence(dayOfWeek, n); |
| 761 | } | 761 | } |
| 762 | this._nth = n; | 762 | this._nth = n; |
| 763 | if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { | 763 | if (n === 2 && (dayOfWeek === undefined || dayOfWeek === null)) { |
| 764 | this._isSecond = true; | 764 | this._isSecond = true; |
| 765 | return this.addSeconds(this._orient); | 765 | return this.addSeconds(this._orient); |
| 766 | } | 766 | } |
| 767 | return this; | 767 | return this; |
| 768 | }; | 768 | }; |
| 769 | }; | 769 | }; |
| 770 | for (var l = 0; l < nth.length; l++) { | 770 | for (var l = 0; l < nth.length; l++) { |
| 771 | $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); | 771 | $P[nth[l]] = (l === 0) ? nthfn(-1) : nthfn(l); |
| 772 | } | 772 | } |
| 773 | }()); | 773 | }()); |
| 774 | (function () { | 774 | (function () { |
| 775 | Date.Parsing = { | 775 | Date.Parsing = { |
| 776 | Exception: function (s) { | 776 | Exception: function (s) { |
| 777 | this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; | 777 | this.message = "Parse error at '" + s.substring(0, 10) + " ...'"; |
| 778 | } | 778 | } |
| 779 | }; | 779 | }; |
| 780 | var $P = Date.Parsing; | 780 | var $P = Date.Parsing; |
| 781 | var _ = $P.Operators = { | 781 | var _ = $P.Operators = { |
| 782 | rtoken: function (r) { | 782 | rtoken: function (r) { |
| 783 | return function (s) { | 783 | return function (s) { |
| 784 | var mx = s.match(r); | 784 | var mx = s.match(r); |
| 785 | if (mx) { | 785 | if (mx) { |
| 786 | return ([mx[0], s.substring(mx[0].length)]); | 786 | return ([mx[0], s.substring(mx[0].length)]); |
| 787 | } else { | 787 | } else { |
| 788 | throw new $P.Exception(s); | 788 | throw new $P.Exception(s); |
| 789 | } | 789 | } |
| 790 | }; | 790 | }; |
| 791 | }, | 791 | }, |
| 792 | token: function (s) { | 792 | token: function (s) { |
| 793 | return function (s) { | 793 | return function (s) { |
| 794 | return _.rtoken(new RegExp("^\s*" + s + "\s*"))(s); | 794 | return _.rtoken(new RegExp("^\s*" + s + "\s*"))(s); |
| 795 | }; | 795 | }; |
| 796 | }, | 796 | }, |
| 797 | stoken: function (s) { | 797 | stoken: function (s) { |
| 798 | return _.rtoken(new RegExp("^" + s)); | 798 | return _.rtoken(new RegExp("^" + s)); |
| 799 | }, | 799 | }, |
| 800 | until: function (p) { | 800 | until: function (p) { |
| 801 | return function (s) { | 801 | return function (s) { |
| 802 | var qx = [], | 802 | var qx = [], |
| 803 | rx = null; | 803 | rx = null; |
| 804 | while (s.length) { | 804 | while (s.length) { |
| 805 | try { | 805 | try { |
| 806 | rx = p.call(this, s); | 806 | rx = p.call(this, s); |
| 807 | } catch (e) { | 807 | } catch (e) { |
| 808 | qx.push(rx[0]); | 808 | qx.push(rx[0]); |
| 809 | s = rx[1]; | 809 | s = rx[1]; |
| 810 | continue; | 810 | continue; |
| 811 | } | 811 | } |
| 812 | break; | 812 | break; |
| 813 | } | 813 | } |
| 814 | return [qx, s]; | 814 | return [qx, s]; |
| 815 | }; | 815 | }; |
| 816 | }, | 816 | }, |
| 817 | many: function (p) { | 817 | many: function (p) { |
| 818 | return function (s) { | 818 | return function (s) { |
| 819 | var rx = [], | 819 | var rx = [], |
| 820 | r = null; | 820 | r = null; |
| 821 | while (s.length) { | 821 | while (s.length) { |
| 822 | try { | 822 | try { |
| 823 | r = p.call(this, s); | 823 | r = p.call(this, s); |
| 824 | } catch (e) { | 824 | } catch (e) { |
| 825 | return [rx, s]; | 825 | return [rx, s]; |
| 826 | } | 826 | } |
| 827 | rx.push(r[0]); | 827 | rx.push(r[0]); |
| 828 | s = r[1]; | 828 | s = r[1]; |
| 829 | } | 829 | } |
| 830 | return [rx, s]; | 830 | return [rx, s]; |
| 831 | }; | 831 | }; |
| 832 | }, | 832 | }, |
| 833 | optional: function (p) { | 833 | optional: function (p) { |
| 834 | return function (s) { | 834 | return function (s) { |
| 835 | var r = null; | 835 | var r = null; |
| 836 | try { | 836 | try { |
| 837 | r = p.call(this, s); | 837 | r = p.call(this, s); |
| 838 | } catch (e) { | 838 | } catch (e) { |
| 839 | return [null, s]; | 839 | return [null, s]; |
| 840 | } | 840 | } |
| 841 | return [r[0], r[1]]; | 841 | return [r[0], r[1]]; |
| 842 | }; | 842 | }; |
| 843 | }, | 843 | }, |
| 844 | not: function (p) { | 844 | not: function (p) { |
| 845 | return function (s) { | 845 | return function (s) { |
| 846 | try { | 846 | try { |
| 847 | p.call(this, s); | 847 | p.call(this, s); |
| 848 | } catch (e) { | 848 | } catch (e) { |
| 849 | return [null, s]; | 849 | return [null, s]; |
| 850 | } | 850 | } |
| 851 | throw new $P.Exception(s); | 851 | throw new $P.Exception(s); |
| 852 | }; | 852 | }; |
| 853 | }, | 853 | }, |
| 854 | ignore: function (p) { | 854 | ignore: function (p) { |
| 855 | return p ? function (s) { | 855 | return p ? function (s) { |
| 856 | var r = null; | 856 | var r = null; |
| 857 | r = p.call(this, s); | 857 | r = p.call(this, s); |
| 858 | return [null, r[1]]; | 858 | return [null, r[1]]; |
| 859 | } : null; | 859 | } : null; |
| 860 | }, | 860 | }, |
| 861 | product: function () { | 861 | product: function () { |
| 862 | var px = arguments[0], | 862 | var px = arguments[0], |
| 863 | qx = Array.prototype.slice.call(arguments, 1), | 863 | qx = Array.prototype.slice.call(arguments, 1), |
| 864 | rx = []; | 864 | rx = []; |
| 865 | for (var i = 0; i < px.length; i++) { | 865 | for (var i = 0; i < px.length; i++) { |
| 866 | rx.push(_.each(px[i], qx)); | 866 | rx.push(_.each(px[i], qx)); |
| 867 | } | 867 | } |
| 868 | return rx; | 868 | return rx; |
| 869 | }, | 869 | }, |
| 870 | cache: function (rule) { | 870 | cache: function (rule) { |
| 871 | var cache = {}, | 871 | var cache = {}, |
| 872 | r = null; | 872 | r = null; |
| 873 | return function (s) { | 873 | return function (s) { |
| 874 | try { | 874 | try { |
| 875 | r = cache[s] = (cache[s] || rule.call(this, s)); | 875 | r = cache[s] = (cache[s] || rule.call(this, s)); |
| 876 | } catch (e) { | 876 | } catch (e) { |
| 877 | r = cache[s] = e; | 877 | r = cache[s] = e; |
| 878 | } | 878 | } |
| 879 | if (r instanceof $P.Exception) { | 879 | if (r instanceof $P.Exception) { |
| 880 | throw r; | 880 | throw r; |
| 881 | } else { | 881 | } else { |
| 882 | return r; | 882 | return r; |
| 883 | } | 883 | } |
| 884 | }; | 884 | }; |
| 885 | }, | 885 | }, |
| 886 | any: function () { | 886 | any: function () { |
| 887 | var px = arguments; | 887 | var px = arguments; |
| 888 | return function (s) { | 888 | return function (s) { |
| 889 | var r = null; | 889 | var r = null; |
| 890 | for (var i = 0; i < px.length; i++) { | 890 | for (var i = 0; i < px.length; i++) { |
| 891 | if (px[i] == null) { | 891 | if (px[i] == null) { |
| 892 | continue; | 892 | continue; |
| 893 | } | 893 | } |
| 894 | try { | 894 | try { |
| 895 | r = (px[i].call(this, s)); | 895 | r = (px[i].call(this, s)); |
| 896 | } catch (e) { | 896 | } catch (e) { |
| 897 | r = null; | 897 | r = null; |
| 898 | } | 898 | } |
| 899 | if (r) { | 899 | if (r) { |
| 900 | return r; | 900 | return r; |
| 901 | } | 901 | } |
| 902 | } | 902 | } |
| 903 | throw new $P.Exception(s); | 903 | throw new $P.Exception(s); |
| 904 | }; | 904 | }; |
| 905 | }, | 905 | }, |
| 906 | each: function () { | 906 | each: function () { |
| 907 | var px = arguments; | 907 | var px = arguments; |
| 908 | return function (s) { | 908 | return function (s) { |
| 909 | var rx = [], | 909 | var rx = [], |
| 910 | r = null; | 910 | r = null; |
| 911 | for (var i = 0; i < px.length; i++) { | 911 | for (var i = 0; i < px.length; i++) { |
| 912 | if (px[i] == null) { | 912 | if (px[i] == null) { |
| 913 | continue; | 913 | continue; |
| 914 | } | 914 | } |
| 915 | try { | 915 | try { |
| 916 | r = (px[i].call(this, s)); | 916 | r = (px[i].call(this, s)); |
| 917 | } catch (e) { | 917 | } catch (e) { |
| 918 | throw new $P.Exception(s); | 918 | throw new $P.Exception(s); |
| 919 | } | 919 | } |
| 920 | rx.push(r[0]); | 920 | rx.push(r[0]); |
| 921 | s = r[1]; | 921 | s = r[1]; |
| 922 | } | 922 | } |
| 923 | return [rx, s]; | 923 | return [rx, s]; |
| 924 | }; | 924 | }; |
| 925 | }, | 925 | }, |
| 926 | all: function () { | 926 | all: function () { |
| 927 | var px = arguments, | 927 | var px = arguments, |
| 928 | _ = _; | 928 | _ = _; |
| 929 | return _.each(_.optional(px)); | 929 | return _.each(_.optional(px)); |
| 930 | }, | 930 | }, |
| 931 | sequence: function (px, d, c) { | 931 | sequence: function (px, d, c) { |
| 932 | d = d || _.rtoken(/^\s*/); | 932 | d = d || _.rtoken(/^\s*/); |
| 933 | c = c || null; | 933 | c = c || null; |
| 934 | if (px.length == 1) { | 934 | if (px.length == 1) { |
| 935 | return px[0]; | 935 | return px[0]; |
| 936 | } | 936 | } |
| 937 | return function (s) { | 937 | return function (s) { |
| 938 | var r = null, | 938 | var r = null, |
| 939 | q = null; | 939 | q = null; |
| 940 | var rx = []; | 940 | var rx = []; |
| 941 | for (var i = 0; i < px.length; i++) { | 941 | for (var i = 0; i < px.length; i++) { |
| 942 | try { | 942 | try { |
| 943 | r = px[i].call(this, s); | 943 | r = px[i].call(this, s); |
| 944 | } catch (e) { | 944 | } catch (e) { |
| 945 | break; | 945 | break; |
| 946 | } | 946 | } |
| 947 | rx.push(r[0]); | 947 | rx.push(r[0]); |
| 948 | try { | 948 | try { |
| 949 | q = d.call(this, r[1]); | 949 | q = d.call(this, r[1]); |
| 950 | } catch (ex) { | 950 | } catch (ex) { |
| 951 | q = null; | 951 | q = null; |
| 952 | break; | 952 | break; |
| 953 | } | 953 | } |
| 954 | s = q[1]; | 954 | s = q[1]; |
| 955 | } | 955 | } |
| 956 | if (!r) { | 956 | if (!r) { |
| 957 | throw new $P.Exception(s); | 957 | throw new $P.Exception(s); |
| 958 | } | 958 | } |
| 959 | if (q) { | 959 | if (q) { |
| 960 | throw new $P.Exception(q[1]); | 960 | throw new $P.Exception(q[1]); |
| 961 | } | 961 | } |
| 962 | if (c) { | 962 | if (c) { |
| 963 | try { | 963 | try { |
| 964 | r = c.call(this, r[1]); | 964 | r = c.call(this, r[1]); |
| 965 | } catch (ey) { | 965 | } catch (ey) { |
| 966 | throw new $P.Exception(r[1]); | 966 | throw new $P.Exception(r[1]); |
| 967 | } | 967 | } |
| 968 | } | 968 | } |
| 969 | return [rx, (r ? r[1] : s)]; | 969 | return [rx, (r ? r[1] : s)]; |
| 970 | }; | 970 | }; |
| 971 | }, | 971 | }, |
| 972 | between: function (d1, p, d2) { | 972 | between: function (d1, p, d2) { |
| 973 | d2 = d2 || d1; | 973 | d2 = d2 || d1; |
| 974 | var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); | 974 | var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); |
| 975 | return function (s) { | 975 | return function (s) { |
| 976 | var rx = _fn.call(this, s); | 976 | var rx = _fn.call(this, s); |
| 977 | return [ | 977 | return [ |
| 978 | [rx[0][0], r[0][2]], rx[1] | 978 | [rx[0][0], r[0][2]], rx[1] |
| 979 | ]; | 979 | ]; |
| 980 | }; | 980 | }; |
| 981 | }, | 981 | }, |
| 982 | list: function (p, d, c) { | 982 | list: function (p, d, c) { |
| 983 | d = d || _.rtoken(/^\s*/); | 983 | d = d || _.rtoken(/^\s*/); |
| 984 | c = c || null; | 984 | c = c || null; |
| 985 | return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); | 985 | return (p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c))); |
| 986 | }, | 986 | }, |
| 987 | set: function (px, d, c) { | 987 | set: function (px, d, c) { |
| 988 | d = d || _.rtoken(/^\s*/); | 988 | d = d || _.rtoken(/^\s*/); |
| 989 | c = c || null; | 989 | c = c || null; |
| 990 | return function (s) { | 990 | return function (s) { |
| 991 | var r = null, | 991 | var r = null, |
| 992 | p = null, | 992 | p = null, |
| 993 | q = null, | 993 | q = null, |
| 994 | rx = null, | 994 | rx = null, |
| 995 | best = [ | 995 | best = [ |
| 996 | [], s | 996 | [], s |
| 997 | ], | 997 | ], |
| 998 | last = false; | 998 | last = false; |
| 999 | for (var i = 0; i < px.length; i++) { | 999 | for (var i = 0; i < px.length; i++) { |
| 1000 | q = null; | 1000 | q = null; |
| 1001 | p = null; | 1001 | p = null; |
| 1002 | r = null; | 1002 | r = null; |
| 1003 | last = (px.length == 1); | 1003 | last = (px.length == 1); |
| 1004 | try { | 1004 | try { |
| 1005 | r = px[i].call(this, s); | 1005 | r = px[i].call(this, s); |
| 1006 | } catch (e) { | 1006 | } catch (e) { |
| 1007 | continue; | 1007 | continue; |
| 1008 | } | 1008 | } |
| 1009 | rx = [ | 1009 | rx = [ |
| 1010 | [r[0]], r[1] | 1010 | [r[0]], r[1] |
| 1011 | ]; | 1011 | ]; |
| 1012 | if (r[1].length > 0 && !last) { | 1012 | if (r[1].length > 0 && !last) { |
| 1013 | try { | 1013 | try { |
| 1014 | q = d.call(this, r[1]); | 1014 | q = d.call(this, r[1]); |
| 1015 | } catch (ex) { | 1015 | } catch (ex) { |
| 1016 | last = true; | 1016 | last = true; |
| 1017 | } | 1017 | } |
| 1018 | } else { | 1018 | } else { |
| 1019 | last = true; | 1019 | last = true; |
| 1020 | } | 1020 | } |
| 1021 | if (!last && q[1].length === 0) { | 1021 | if (!last && q[1].length === 0) { |
| 1022 | last = true; | 1022 | last = true; |
| 1023 | } | 1023 | } |
| 1024 | if (!last) { | 1024 | if (!last) { |
| 1025 | var qx = []; | 1025 | var qx = []; |
| 1026 | for (var j = 0; j < px.length; j++) { | 1026 | for (var j = 0; j < px.length; j++) { |
| 1027 | if (i != j) { | 1027 | if (i != j) { |
| 1028 | qx.push(px[j]); | 1028 | qx.push(px[j]); |
| 1029 | } | 1029 | } |
| 1030 | } | 1030 | } |
| 1031 | p = _.set(qx, d).call(this, q[1]); | 1031 | p = _.set(qx, d).call(this, q[1]); |
| 1032 | if (p[0].length > 0) { | 1032 | if (p[0].length > 0) { |
| 1033 | rx[0] = rx[0].concat(p[0]); | 1033 | rx[0] = rx[0].concat(p[0]); |
| 1034 | rx[1] = p[1]; | 1034 | rx[1] = p[1]; |
| 1035 | } | 1035 | } |
| 1036 | } | 1036 | } |
| 1037 | if (rx[1].length < best[1].length) { | 1037 | if (rx[1].length < best[1].length) { |
| 1038 | best = rx; | 1038 | best = rx; |
| 1039 | } | 1039 | } |
| 1040 | if (best[1].length === 0) { | 1040 | if (best[1].length === 0) { |
| 1041 | break; | 1041 | break; |
| 1042 | } | 1042 | } |
| 1043 | } | 1043 | } |
| 1044 | if (best[0].length === 0) { | 1044 | if (best[0].length === 0) { |
| 1045 | return best; | 1045 | return best; |
| 1046 | } | 1046 | } |
| 1047 | if (c) { | 1047 | if (c) { |
| 1048 | try { | 1048 | try { |
| 1049 | q = c.call(this, best[1]); | 1049 | q = c.call(this, best[1]); |
| 1050 | } catch (ey) { | 1050 | } catch (ey) { |
| 1051 | throw new $P.Exception(best[1]); | 1051 | throw new $P.Exception(best[1]); |
| 1052 | } | 1052 | } |
| 1053 | best[1] = q[1]; | 1053 | best[1] = q[1]; |
| 1054 | } | 1054 | } |
| 1055 | return best; | 1055 | return best; |
| 1056 | }; | 1056 | }; |
| 1057 | }, | 1057 | }, |
| 1058 | forward: function (gr, fname) { | 1058 | forward: function (gr, fname) { |
| 1059 | return function (s) { | 1059 | return function (s) { |
| 1060 | return gr[fname].call(this, s); | 1060 | return gr[fname].call(this, s); |
| 1061 | }; | 1061 | }; |
| 1062 | }, | 1062 | }, |
| 1063 | replace: function (rule, repl) { | 1063 | replace: function (rule, repl) { |
| 1064 | return function (s) { | 1064 | return function (s) { |
| 1065 | var r = rule.call(this, s); | 1065 | var r = rule.call(this, s); |
| 1066 | return [repl, r[1]]; | 1066 | return [repl, r[1]]; |
| 1067 | }; | 1067 | }; |
| 1068 | }, | 1068 | }, |
| 1069 | process: function (rule, fn) { | 1069 | process: function (rule, fn) { |
| 1070 | return function (s) { | 1070 | return function (s) { |
| 1071 | var r = rule.call(this, s); | 1071 | var r = rule.call(this, s); |
| 1072 | return [fn.call(this, r[0]), r[1]]; | 1072 | return [fn.call(this, r[0]), r[1]]; |
| 1073 | }; | 1073 | }; |
| 1074 | }, | 1074 | }, |
| 1075 | min: function (min, rule) { | 1075 | min: function (min, rule) { |
| 1076 | return function (s) { | 1076 | return function (s) { |
| 1077 | var rx = rule.call(this, s); | 1077 | var rx = rule.call(this, s); |
| 1078 | if (rx[0].length < min) { | 1078 | if (rx[0].length < min) { |
| 1079 | throw new $P.Exception(s); | 1079 | throw new $P.Exception(s); |
| 1080 | } | 1080 | } |
| 1081 | return rx; | 1081 | return rx; |
| 1082 | }; | 1082 | }; |
| 1083 | } | 1083 | } |
| 1084 | }; | 1084 | }; |
| 1085 | var _generator = function (op) { | 1085 | var _generator = function (op) { |
| 1086 | return function () { | 1086 | return function () { |
| 1087 | var args = null, | 1087 | var args = null, |
| 1088 | rx = []; | 1088 | rx = []; |
| 1089 | if (arguments.length > 1) { | 1089 | if (arguments.length > 1) { |
| 1090 | args = Array.prototype.slice.call(arguments); | 1090 | args = Array.prototype.slice.call(arguments); |
| 1091 | } else if (arguments[0] instanceof Array) { | 1091 | } else if (arguments[0] instanceof Array) { |
| 1092 | args = arguments[0]; | 1092 | args = arguments[0]; |
| 1093 | } | 1093 | } |
| 1094 | if (args) { | 1094 | if (args) { |
| 1095 | for (var i = 0, px = args.shift(); i < px.length; i++) { | 1095 | for (var i = 0, px = args.shift(); i < px.length; i++) { |
| 1096 | args.unshift(px[i]); | 1096 | args.unshift(px[i]); |
| 1097 | rx.push(op.apply(null, args)); | 1097 | rx.push(op.apply(null, args)); |
| 1098 | args.shift(); | 1098 | args.shift(); |
| 1099 | return rx; | 1099 | return rx; |
| 1100 | } | 1100 | } |
| 1101 | } else { | 1101 | } else { |
| 1102 | return op.apply(null, arguments); | 1102 | return op.apply(null, arguments); |
| 1103 | } | 1103 | } |
| 1104 | }; | 1104 | }; |
| 1105 | }; | 1105 | }; |
| 1106 | var gx = "optional not ignore cache".split(/\s/); | 1106 | var gx = "optional not ignore cache".split(/\s/); |
| 1107 | for (var i = 0; i < gx.length; i++) { | 1107 | for (var i = 0; i < gx.length; i++) { |
| 1108 | _[gx[i]] = _generator(_[gx[i]]); | 1108 | _[gx[i]] = _generator(_[gx[i]]); |
| 1109 | } | 1109 | } |
| 1110 | var _vector = function (op) { | 1110 | var _vector = function (op) { |
| 1111 | return function () { | 1111 | return function () { |
| 1112 | if (arguments[0] instanceof Array) { | 1112 | if (arguments[0] instanceof Array) { |
| 1113 | return op.apply(null, arguments[0]); | 1113 | return op.apply(null, arguments[0]); |
| 1114 | } else { | 1114 | } else { |
| 1115 | return op.apply(null, arguments); | 1115 | return op.apply(null, arguments); |
| 1116 | } | 1116 | } |
| 1117 | }; | 1117 | }; |
| 1118 | }; | 1118 | }; |
| 1119 | var vx = "each any all".split(/\s/); | 1119 | var vx = "each any all".split(/\s/); |
| 1120 | for (var j = 0; j < vx.length; j++) { | 1120 | for (var j = 0; j < vx.length; j++) { |
| 1121 | _[vx[j]] = _vector(_[vx[j]]); | 1121 | _[vx[j]] = _vector(_[vx[j]]); |
| 1122 | } | 1122 | } |
| 1123 | }()); | 1123 | }()); |
| 1124 | (function () { | 1124 | (function () { |
| 1125 | var $D = Date, | 1125 | var $D = Date, |
| 1126 | $P = $D.prototype, | 1126 | $P = $D.prototype, |
| 1127 | $C = $D.CultureInfo; | 1127 | $C = $D.CultureInfo; |
| 1128 | var flattenAndCompact = function (ax) { | 1128 | var flattenAndCompact = function (ax) { |
| 1129 | var rx = []; | 1129 | var rx = []; |
| 1130 | for (var i = 0; i < ax.length; i++) { | 1130 | for (var i = 0; i < ax.length; i++) { |
| 1131 | if (ax[i] instanceof Array) { | 1131 | if (ax[i] instanceof Array) { |
| 1132 | rx = rx.concat(flattenAndCompact(ax[i])); | 1132 | rx = rx.concat(flattenAndCompact(ax[i])); |
| 1133 | } else { | 1133 | } else { |
| 1134 | if (ax[i]) { | 1134 | if (ax[i]) { |
| 1135 | rx.push(ax[i]); | 1135 | rx.push(ax[i]); |
| 1136 | } | 1136 | } |
| 1137 | } | 1137 | } |
| 1138 | } | 1138 | } |
| 1139 | return rx; | 1139 | return rx; |
| 1140 | }; | 1140 | }; |
| 1141 | $D.Grammar = {}; | 1141 | $D.Grammar = {}; |
| 1142 | $D.Translator = { | 1142 | $D.Translator = { |
| 1143 | hour: function (s) { | 1143 | hour: function (s) { |
| 1144 | return function () { | 1144 | return function () { |
| 1145 | this.hour = Number(s); | 1145 | this.hour = Number(s); |
| 1146 | }; | 1146 | }; |
| 1147 | }, | 1147 | }, |
| 1148 | minute: function (s) { | 1148 | minute: function (s) { |
| 1149 | return function () { | 1149 | return function () { |
| 1150 | this.minute = Number(s); | 1150 | this.minute = Number(s); |
| 1151 | }; | 1151 | }; |
| 1152 | }, | 1152 | }, |
| 1153 | second: function (s) { | 1153 | second: function (s) { |
| 1154 | return function () { | 1154 | return function () { |
| 1155 | this.second = Number(s); | 1155 | this.second = Number(s); |
| 1156 | }; | 1156 | }; |
| 1157 | }, | 1157 | }, |
| 1158 | meridian: function (s) { | 1158 | meridian: function (s) { |
| 1159 | return function () { | 1159 | return function () { |
| 1160 | this.meridian = s.slice(0, 1).toLowerCase(); | 1160 | this.meridian = s.slice(0, 1).toLowerCase(); |
| 1161 | }; | 1161 | }; |
| 1162 | }, | 1162 | }, |
| 1163 | timezone: function (s) { | 1163 | timezone: function (s) { |
| 1164 | return function () { | 1164 | return function () { |
| 1165 | var n = s.replace(/[^\d\+\-]/g, ""); | 1165 | var n = s.replace(/[^\d\+\-]/g, ""); |
| 1166 | if (n.length) { | 1166 | if (n.length) { |
| 1167 | this.timezoneOffset = Number(n); | 1167 | this.timezoneOffset = Number(n); |
| 1168 | } else { | 1168 | } else { |
| 1169 | this.timezone = s.toLowerCase(); | 1169 | this.timezone = s.toLowerCase(); |
| 1170 | } | 1170 | } |
| 1171 | }; | 1171 | }; |
| 1172 | }, | 1172 | }, |
| 1173 | day: function (x) { | 1173 | day: function (x) { |
| 1174 | var s = x[0]; | 1174 | var s = x[0]; |
| 1175 | return function () { | 1175 | return function () { |
| 1176 | this.day = Number(s.match(/\d+/)[0]); | 1176 | this.day = Number(s.match(/\d+/)[0]); |
| 1177 | }; | 1177 | }; |
| 1178 | }, | 1178 | }, |
| 1179 | month: function (s) { | 1179 | month: function (s) { |
| 1180 | return function () { | 1180 | return function () { |
| 1181 | this.month = (s.length == 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s) / 4 : Number(s) - 1; | 1181 | this.month = (s.length == 3) ? "jan feb mar apr may jun jul aug sep oct nov dec".indexOf(s) / 4 : Number(s) - 1; |
| 1182 | }; | 1182 | }; |
| 1183 | }, | 1183 | }, |
| 1184 | year: function (s) { | 1184 | year: function (s) { |
| 1185 | return function () { | 1185 | return function () { |
| 1186 | var n = Number(s); | 1186 | var n = Number(s); |
| 1187 | this.year = ((s.length > 2) ? n : (n + (((n + 2000) < $C.twoDigitYearMax) ? 2000 : 1900))); | 1187 | this.year = ((s.length > 2) ? n : (n + (((n + 2000) < $C.twoDigitYearMax) ? 2000 : 1900))); |
| 1188 | }; | 1188 | }; |
| 1189 | }, | 1189 | }, |
| 1190 | rday: function (s) { | 1190 | rday: function (s) { |
| 1191 | return function () { | 1191 | return function () { |
| 1192 | switch (s) { | 1192 | switch (s) { |
| 1193 | case "yesterday": | 1193 | case "yesterday": |
| 1194 | this.days = -1; | 1194 | this.days = -1; |
| 1195 | break; | 1195 | break; |
| 1196 | case "tomorrow": | 1196 | case "tomorrow": |
| 1197 | this.days = 1; | 1197 | this.days = 1; |
| 1198 | break; | 1198 | break; |
| 1199 | case "today": | 1199 | case "today": |
| 1200 | this.days = 0; | 1200 | this.days = 0; |
| 1201 | break; | 1201 | break; |
| 1202 | case "now": | 1202 | case "now": |
| 1203 | this.days = 0; | 1203 | this.days = 0; |
| 1204 | this.now = true; | 1204 | this.now = true; |
| 1205 | break; | 1205 | break; |
| 1206 | } | 1206 | } |
| 1207 | }; | 1207 | }; |
| 1208 | }, | 1208 | }, |
| 1209 | finishExact: function (x) { | 1209 | finishExact: function (x) { |
| 1210 | x = (x instanceof Array) ? x : [x]; | 1210 | x = (x instanceof Array) ? x : [x]; |
| 1211 | for (var i = 0; i < x.length; i++) { | 1211 | for (var i = 0; i < x.length; i++) { |
| 1212 | if (x[i]) { | 1212 | if (x[i]) { |
| 1213 | x[i].call(this); | 1213 | x[i].call(this); |
| 1214 | } | 1214 | } |
| 1215 | } | 1215 | } |
| 1216 | var now = new Date(); | 1216 | var now = new Date(); |
| 1217 | if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { | 1217 | if ((this.hour || this.minute) && (!this.month && !this.year && !this.day)) { |
| 1218 | this.day = now.getDate(); | 1218 | this.day = now.getDate(); |
| 1219 | } | 1219 | } |
| 1220 | if (!this.year) { | 1220 | if (!this.year) { |
| 1221 | this.year = now.getFullYear(); | 1221 | this.year = now.getFullYear(); |
| 1222 | } | 1222 | } |
| 1223 | if (!this.month && this.month !== 0) { | 1223 | if (!this.month && this.month !== 0) { |
| 1224 | this.month = now.getMonth(); | 1224 | this.month = now.getMonth(); |
| 1225 | } | 1225 | } |
| 1226 | if (!this.day) { | 1226 | if (!this.day) { |
| 1227 | this.day = 1; | 1227 | this.day = 1; |
| 1228 | } | 1228 | } |
| 1229 | if (!this.hour) { | 1229 | if (!this.hour) { |
| 1230 | this.hour = 0; | 1230 | this.hour = 0; |
| 1231 | } | 1231 | } |
| 1232 | if (!this.minute) { | 1232 | if (!this.minute) { |
| 1233 | this.minute = 0; | 1233 | this.minute = 0; |
| 1234 | } | 1234 | } |
| 1235 | if (!this.second) { | 1235 | if (!this.second) { |
| 1236 | this.second = 0; | 1236 | this.second = 0; |
| 1237 | } | 1237 | } |
| 1238 | if (this.meridian && this.hour) { | 1238 | if (this.meridian && this.hour) { |
| 1239 | if (this.meridian == "p" && this.hour < 12) { | 1239 | if (this.meridian == "p" && this.hour < 12) { |
| 1240 | this.hour = this.hour + 12; | 1240 | this.hour = this.hour + 12; |
| 1241 | } else if (this.meridian == "a" && this.hour == 12) { | 1241 | } else if (this.meridian == "a" && this.hour == 12) { |
| 1242 | this.hour = 0; | 1242 | this.hour = 0; |
| 1243 | } | 1243 | } |
| 1244 | } | 1244 | } |
| 1245 | if (this.day > $D.getDaysInMonth(this.year, this.month)) { | 1245 | if (this.day > $D.getDaysInMonth(this.year, this.month)) { |
| 1246 | throw new RangeError(this.day + " is not a valid value for days."); | 1246 | throw new RangeError(this.day + " is not a valid value for days."); |
| 1247 | } | 1247 | } |
| 1248 | var r = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second); | 1248 | var r = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second); |
| 1249 | if (this.timezone) { | 1249 | if (this.timezone) { |
| 1250 | r.set({ | 1250 | r.set({ |
| 1251 | timezone: this.timezone | 1251 | timezone: this.timezone |
| 1252 | }); | 1252 | }); |
| 1253 | } else if (this.timezoneOffset) { | 1253 | } else if (this.timezoneOffset) { |
| 1254 | r.set({ | 1254 | r.set({ |
| 1255 | timezoneOffset: this.timezoneOffset | 1255 | timezoneOffset: this.timezoneOffset |
| 1256 | }); | 1256 | }); |
| 1257 | } | 1257 | } |
| 1258 | return r; | 1258 | return r; |
| 1259 | }, | 1259 | }, |
| 1260 | finish: function (x) { | 1260 | finish: function (x) { |
| 1261 | x = (x instanceof Array) ? flattenAndCompact(x) : [x]; | 1261 | x = (x instanceof Array) ? flattenAndCompact(x) : [x]; |
| 1262 | if (x.length === 0) { | 1262 | if (x.length === 0) { |
| 1263 | return null; | 1263 | return null; |
| 1264 | } | 1264 | } |
| 1265 | for (var i = 0; i < x.length; i++) { | 1265 | for (var i = 0; i < x.length; i++) { |
| 1266 | if (typeof x[i] == "function") { | 1266 | if (typeof x[i] == "function") { |
| 1267 | x[i].call(this); | 1267 | x[i].call(this); |
| 1268 | } | 1268 | } |
| 1269 | } | 1269 | } |
| 1270 | var today = $D.today(); | 1270 | var today = $D.today(); |
| 1271 | if (this.now && !this.unit && !this.operator) { | 1271 | if (this.now && !this.unit && !this.operator) { |
| 1272 | return new Date(); | 1272 | return new Date(); |
| 1273 | } else if (this.now) { | 1273 | } else if (this.now) { |
| 1274 | today = new Date(); | 1274 | today = new Date(); |
| 1275 | } | 1275 | } |
| 1276 | var expression = !!(this.days && this.days !== null || this.orient || this.operator); | 1276 | var expression = !!(this.days && this.days !== null || this.orient || this.operator); |
| 1277 | var gap, mod, orient; | 1277 | var gap, mod, orient; |
| 1278 | orient = ((this.orient == "past" || this.operator == "subtract") ? -1 : 1); | 1278 | orient = ((this.orient == "past" || this.operator == "subtract") ? -1 : 1); |
| 1279 | if (!this.now && "hour minute second".indexOf(this.unit) != -1) { | 1279 | if (!this.now && "hour minute second".indexOf(this.unit) != -1) { |
| 1280 | today.setTimeToNow(); | 1280 | today.setTimeToNow(); |
| 1281 | } | 1281 | } |
| 1282 | if (this.month || this.month === 0) { | 1282 | if (this.month || this.month === 0) { |
| 1283 | if ("year day hour minute second".indexOf(this.unit) != -1) { | 1283 | if ("year day hour minute second".indexOf(this.unit) != -1) { |
| 1284 | this.value = this.month + 1; | 1284 | this.value = this.month + 1; |
| 1285 | this.month = null; | 1285 | this.month = null; |
| 1286 | expression = true; | 1286 | expression = true; |
| 1287 | } | 1287 | } |
| 1288 | } | 1288 | } |
| 1289 | if (!expression && this.weekday && !this.day && !this.days) { | 1289 | if (!expression && this.weekday && !this.day && !this.days) { |
| 1290 | var temp = Date[this.weekday](); | 1290 | var temp = Date[this.weekday](); |
| 1291 | this.day = temp.getDate(); | 1291 | this.day = temp.getDate(); |
| 1292 | if (!this.month) { | 1292 | if (!this.month) { |
| 1293 | this.month = temp.getMonth(); | 1293 | this.month = temp.getMonth(); |
| 1294 | } | 1294 | } |
| 1295 | this.year = temp.getFullYear(); | 1295 | this.year = temp.getFullYear(); |
| 1296 | } | 1296 | } |
| 1297 | if (expression && this.weekday && this.unit != "month") { | 1297 | if (expression && this.weekday && this.unit != "month") { |
| 1298 | this.unit = "day"; | 1298 | this.unit = "day"; |
| 1299 | gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); | 1299 | gap = ($D.getDayNumberFromName(this.weekday) - today.getDay()); |
| 1300 | mod = 7; | 1300 | mod = 7; |
| 1301 | this.days = gap ? ((gap + (orient * mod)) % mod) : (orient * mod); | 1301 | this.days = gap ? ((gap + (orient * mod)) % mod) : (orient * mod); |
| 1302 | } | 1302 | } |
| 1303 | if (this.month && this.unit == "day" && this.operator) { | 1303 | if (this.month && this.unit == "day" && this.operator) { |
| 1304 | this.value = (this.month + 1); | 1304 | this.value = (this.month + 1); |
| 1305 | this.month = null; | 1305 | this.month = null; |
| 1306 | } | 1306 | } |
| 1307 | if (this.value != null && this.month != null && this.year != null) { | 1307 | if (this.value != null && this.month != null && this.year != null) { |
| 1308 | this.day = this.value * 1; | 1308 | this.day = this.value * 1; |
| 1309 | } | 1309 | } |
| 1310 | if (this.month && !this.day && this.value) { | 1310 | if (this.month && !this.day && this.value) { |
| 1311 | today.set({ | 1311 | today.set({ |
| 1312 | day: this.value * 1 | 1312 | day: this.value * 1 |
| 1313 | }); | 1313 | }); |
| 1314 | if (!expression) { | 1314 | if (!expression) { |
| 1315 | this.day = this.value * 1; | 1315 | this.day = this.value * 1; |
| 1316 | } | 1316 | } |
| 1317 | } | 1317 | } |
| 1318 | if (!this.month && this.value && this.unit == "month" && !this.now) { | 1318 | if (!this.month && this.value && this.unit == "month" && !this.now) { |
| 1319 | this.month = this.value; | 1319 | this.month = this.value; |
| 1320 | expression = true; | 1320 | expression = true; |
| 1321 | } | 1321 | } |
| 1322 | if (expression && (this.month || this.month === 0) && this.unit != "year") { | 1322 | if (expression && (this.month || this.month === 0) && this.unit != "year") { |
| 1323 | this.unit = "month"; | 1323 | this.unit = "month"; |
| 1324 | gap = (this.month - today.getMonth()); | 1324 | gap = (this.month - today.getMonth()); |
| 1325 | mod = 12; | 1325 | mod = 12; |
| 1326 | this.months = gap ? ((gap + (orient * mod)) % mod) : (orient * mod); | 1326 | this.months = gap ? ((gap + (orient * mod)) % mod) : (orient * mod); |
| 1327 | this.month = null; | 1327 | this.month = null; |
| 1328 | } | 1328 | } |
| 1329 | if (!this.unit) { | 1329 | if (!this.unit) { |
| 1330 | this.unit = "day"; | 1330 | this.unit = "day"; |
| 1331 | } | 1331 | } |
| 1332 | if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { | 1332 | if (!this.value && this.operator && this.operator !== null && this[this.unit + "s"] && this[this.unit + "s"] !== null) { |
| 1333 | this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator == "add") ? 1 : -1) + (this.value || 0) * orient; | 1333 | this[this.unit + "s"] = this[this.unit + "s"] + ((this.operator == "add") ? 1 : -1) + (this.value || 0) * orient; |
| 1334 | } else if (this[this.unit + "s"] == null || this.operator != null) { | 1334 | } else if (this[this.unit + "s"] == null || this.operator != null) { |
| 1335 | if (!this.value) { | 1335 | if (!this.value) { |
| 1336 | this.value = 1; | 1336 | this.value = 1; |
| 1337 | } | 1337 | } |
| 1338 | this[this.unit + "s"] = this.value * orient; | 1338 | this[this.unit + "s"] = this.value * orient; |
| 1339 | } | 1339 | } |
| 1340 | if (this.meridian && this.hour) { | 1340 | if (this.meridian && this.hour) { |
| 1341 | if (this.meridian == "p" && this.hour < 12) { | 1341 | if (this.meridian == "p" && this.hour < 12) { |
| 1342 | this.hour = this.hour + 12; | 1342 | this.hour = this.hour + 12; |
| 1343 | } else if (this.meridian == "a" && this.hour == 12) { | 1343 | } else if (this.meridian == "a" && this.hour == 12) { |
| 1344 | this.hour = 0; | 1344 | this.hour = 0; |
| 1345 | } | 1345 | } |
| 1346 | } | 1346 | } |
| 1347 | if (this.weekday && !this.day && !this.days) { | 1347 | if (this.weekday && !this.day && !this.days) { |
| 1348 | var temp = Date[this.weekday](); | 1348 | var temp = Date[this.weekday](); |
| 1349 | this.day = temp.getDate(); | 1349 | this.day = temp.getDate(); |
| 1350 | if (temp.getMonth() !== today.getMonth()) { | 1350 | if (temp.getMonth() !== today.getMonth()) { |
| 1351 | this.month = temp.getMonth(); | 1351 | this.month = temp.getMonth(); |
| 1352 | } | 1352 | } |
| 1353 | } | 1353 | } |
| 1354 | if ((this.month || this.month === 0) && !this.day) { | 1354 | if ((this.month || this.month === 0) && !this.day) { |
| 1355 | this.day = 1; | 1355 | this.day = 1; |
| 1356 | } | 1356 | } |
| 1357 | if (!this.orient && !this.operator && this.unit == "week" && this.value && !this.day && !this.month) { | 1357 | if (!this.orient && !this.operator && this.unit == "week" && this.value && !this.day && !this.month) { |
| 1358 | return Date.today().setWeek(this.value); | 1358 | return Date.today().setWeek(this.value); |
| 1359 | } | 1359 | } |
| 1360 | if (expression && this.timezone && this.day && this.days) { | 1360 | if (expression && this.timezone && this.day && this.days) { |
| 1361 | this.day = this.days; | 1361 | this.day = this.days; |
| 1362 | } | 1362 | } |
| 1363 | return (expression) ? today.add(this) : today.set(this); | 1363 | return (expression) ? today.add(this) : today.set(this); |
| 1364 | } | 1364 | } |
| 1365 | }; | 1365 | }; |
| 1366 | var _ = $D.Parsing.Operators, | 1366 | var _ = $D.Parsing.Operators, |
| 1367 | g = $D.Grammar, | 1367 | g = $D.Grammar, |
| 1368 | t = $D.Translator, | 1368 | t = $D.Translator, |
| 1369 | _fn; | 1369 | _fn; |
| 1370 | g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); | 1370 | g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/); |
| 1371 | g.timePartDelimiter = _.stoken(":"); | 1371 | g.timePartDelimiter = _.stoken(":"); |
| 1372 | g.whiteSpace = _.rtoken(/^\s*/); | 1372 | g.whiteSpace = _.rtoken(/^\s*/); |
| 1373 | g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); | 1373 | g.generalDelimiter = _.rtoken(/^(([\s\,]|at|@|on)+)/); |
| 1374 | var _C = {}; | 1374 | var _C = {}; |
| 1375 | g.ctoken = function (keys) { | 1375 | g.ctoken = function (keys) { |
| 1376 | var fn = _C[keys]; | 1376 | var fn = _C[keys]; |
| 1377 | if (!fn) { | 1377 | if (!fn) { |
| 1378 | var c = $C.regexPatterns; | 1378 | var c = $C.regexPatterns; |
| 1379 | var kx = keys.split(/\s+/), | 1379 | var kx = keys.split(/\s+/), |
| 1380 | px = []; | 1380 | px = []; |
| 1381 | for (var i = 0; i < kx.length; i++) { | 1381 | for (var i = 0; i < kx.length; i++) { |
| 1382 | px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); | 1382 | px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); |
| 1383 | } | 1383 | } |
| 1384 | fn = _C[keys] = _.any.apply(null, px); | 1384 | fn = _C[keys] = _.any.apply(null, px); |
| 1385 | } | 1385 | } |
| 1386 | return fn; | 1386 | return fn; |
| 1387 | }; | 1387 | }; |
| 1388 | g.ctoken2 = function (key) { | 1388 | g.ctoken2 = function (key) { |
| 1389 | return _.rtoken($C.regexPatterns[key]); | 1389 | return _.rtoken($C.regexPatterns[key]); |
| 1390 | }; | 1390 | }; |
| 1391 | g.h = _.cache(_.process(_.rtoken(/^(0[0-9]|1[0-2]|[1-9])/), t.hour)); | 1391 | g.h = _.cache(_.process(_.rtoken(/^(0[0-9]|1[0-2]|[1-9])/), t.hour)); |
| 1392 | g.hh = _.cache(_.process(_.rtoken(/^(0[0-9]|1[0-2])/), t.hour)); | 1392 | g.hh = _.cache(_.process(_.rtoken(/^(0[0-9]|1[0-2])/), t.hour)); |
| 1393 | g.H = _.cache(_.process(_.rtoken(/^([0-1][0-9]|2[0-3]|[0-9])/), t.hour)); | 1393 | g.H = _.cache(_.process(_.rtoken(/^([0-1][0-9]|2[0-3]|[0-9])/), t.hour)); |
| 1394 | g.HH = _.cache(_.process(_.rtoken(/^([0-1][0-9]|2[0-3])/), t.hour)); | 1394 | g.HH = _.cache(_.process(_.rtoken(/^([0-1][0-9]|2[0-3])/), t.hour)); |
| 1395 | g.m = _.cache(_.process(_.rtoken(/^([0-5][0-9]|[0-9])/), t.minute)); | 1395 | g.m = _.cache(_.process(_.rtoken(/^([0-5][0-9]|[0-9])/), t.minute)); |
| 1396 | g.mm = _.cache(_.process(_.rtoken(/^[0-5][0-9]/), t.minute)); | 1396 | g.mm = _.cache(_.process(_.rtoken(/^[0-5][0-9]/), t.minute)); |
| 1397 | g.s = _.cache(_.process(_.rtoken(/^([0-5][0-9]|[0-9])/), t.second)); | 1397 | g.s = _.cache(_.process(_.rtoken(/^([0-5][0-9]|[0-9])/), t.second)); |
| 1398 | g.ss = _.cache(_.process(_.rtoken(/^[0-5][0-9]/), t.second)); | 1398 | g.ss = _.cache(_.process(_.rtoken(/^[0-5][0-9]/), t.second)); |
| 1399 | g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); | 1399 | g.hms = _.cache(_.sequence([g.H, g.m, g.s], g.timePartDelimiter)); |
| 1400 | g.t = _.cache(_.process(g.ctoken2("shortMeridian"), t.meridian)); | 1400 | g.t = _.cache(_.process(g.ctoken2("shortMeridian"), t.meridian)); |
| 1401 | g.tt = _.cache(_.process(g.ctoken2("longMeridian"), t.meridian)); | 1401 | g.tt = _.cache(_.process(g.ctoken2("longMeridian"), t.meridian)); |
| 1402 | g.z = _.cache(_.process(_.rtoken(/^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/), t.timezone)); | 1402 | g.z = _.cache(_.process(_.rtoken(/^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/), t.timezone)); |
| 1403 | g.zz = _.cache(_.process(_.rtoken(/^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/), t.timezone)); | 1403 | g.zz = _.cache(_.process(_.rtoken(/^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/), t.timezone)); |
| 1404 | g.zzz = _.cache(_.process(g.ctoken2("timezone"), t.timezone)); | 1404 | g.zzz = _.cache(_.process(g.ctoken2("timezone"), t.timezone)); |
| 1405 | g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([g.tt, g.zzz])); | 1405 | g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([g.tt, g.zzz])); |
| 1406 | g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); | 1406 | g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix); |
| 1407 | g.d = _.cache(_.process(_.each(_.rtoken(/^([0-2]\d|3[0-1]|\d)/), _.optional(g.ctoken2("ordinalSuffix"))), t.day)); | 1407 | g.d = _.cache(_.process(_.each(_.rtoken(/^([0-2]\d|3[0-1]|\d)/), _.optional(g.ctoken2("ordinalSuffix"))), t.day)); |
| 1408 | g.dd = _.cache(_.process(_.each(_.rtoken(/^([0-2]\d|3[0-1])/), _.optional(g.ctoken2("ordinalSuffix"))), t.day)); | 1408 | g.dd = _.cache(_.process(_.each(_.rtoken(/^([0-2]\d|3[0-1])/), _.optional(g.ctoken2("ordinalSuffix"))), t.day)); |
| 1409 | g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { | 1409 | g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { |
| 1410 | return function () { | 1410 | return function () { |
| 1411 | this.weekday = s; | 1411 | this.weekday = s; |
| 1412 | }; | 1412 | }; |
| 1413 | })); | 1413 | })); |
| 1414 | g.M = _.cache(_.process(_.rtoken(/^(1[0-2]|0\d|\d)/), t.month)); | 1414 | g.M = _.cache(_.process(_.rtoken(/^(1[0-2]|0\d|\d)/), t.month)); |
| 1415 | g.MM = _.cache(_.process(_.rtoken(/^(1[0-2]|0\d)/), t.month)); | 1415 | g.MM = _.cache(_.process(_.rtoken(/^(1[0-2]|0\d)/), t.month)); |
| 1416 | g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); | 1416 | g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)); |
| 1417 | g.y = _.cache(_.process(_.rtoken(/^(\d\d?)/), t.year)); | 1417 | g.y = _.cache(_.process(_.rtoken(/^(\d\d?)/), t.year)); |
| 1418 | g.yy = _.cache(_.process(_.rtoken(/^(\d\d)/), t.year)); | 1418 | g.yy = _.cache(_.process(_.rtoken(/^(\d\d)/), t.year)); |
| 1419 | g.yyy = _.cache(_.process(_.rtoken(/^(\d\d?\d?\d?)/), t.year)); | 1419 | g.yyy = _.cache(_.process(_.rtoken(/^(\d\d?\d?\d?)/), t.year)); |
| 1420 | g.yyyy = _.cache(_.process(_.rtoken(/^(\d\d\d\d)/), t.year)); | 1420 | g.yyyy = _.cache(_.process(_.rtoken(/^(\d\d\d\d)/), t.year)); |
| 1421 | _fn = function () { | 1421 | _fn = function () { |
| 1422 | return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); | 1422 | return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))); |
| 1423 | }; | 1423 | }; |
| 1424 | g.day = _fn(g.d, g.dd); | 1424 | g.day = _fn(g.d, g.dd); |
| 1425 | g.month = _fn(g.M, g.MMM); | 1425 | g.month = _fn(g.M, g.MMM); |
| 1426 | g.year = _fn(g.yyyy, g.yy); | 1426 | g.year = _fn(g.yyyy, g.yy); |
| 1427 | g.orientation = _.process(g.ctoken("past future"), function (s) { | 1427 | g.orientation = _.process(g.ctoken("past future"), function (s) { |
| 1428 | return function () { | 1428 | return function () { |
| 1429 | this.orient = s; | 1429 | this.orient = s; |
| 1430 | }; | 1430 | }; |
| 1431 | }); | 1431 | }); |
| 1432 | g.operator = _.process(g.ctoken("add subtract"), function (s) { | 1432 | g.operator = _.process(g.ctoken("add subtract"), function (s) { |
| 1433 | return function () { | 1433 | return function () { |
| 1434 | this.operator = s; | 1434 | this.operator = s; |
| 1435 | }; | 1435 | }; |
| 1436 | }); | 1436 | }); |
| 1437 | g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); | 1437 | g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday); |
| 1438 | g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { | 1438 | g.unit = _.process(g.ctoken("second minute hour day week month year"), function (s) { |
| 1439 | return function () { | 1439 | return function () { |
| 1440 | this.unit = s; | 1440 | this.unit = s; |
| 1441 | }; | 1441 | }; |
| 1442 | }); | 1442 | }); |
| 1443 | g.value = _.process(_.rtoken(/^\d\d?(st|nd|rd|th)?/), function (s) { | 1443 | g.value = _.process(_.rtoken(/^\d\d?(st|nd|rd|th)?/), function (s) { |
| 1444 | return function () { | 1444 | return function () { |
| 1445 | this.value = s.replace(/\D/g, ""); | 1445 | this.value = s.replace(/\D/g, ""); |
| 1446 | }; | 1446 | }; |
| 1447 | }); | 1447 | }); |
| 1448 | g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM]); | 1448 | g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM]); |
| 1449 | _fn = function () { | 1449 | _fn = function () { |
| 1450 | return _.set(arguments, g.datePartDelimiter); | 1450 | return _.set(arguments, g.datePartDelimiter); |
| 1451 | }; | 1451 | }; |
| 1452 | g.mdy = _fn(g.ddd, g.month, g.day, g.year); | 1452 | g.mdy = _fn(g.ddd, g.month, g.day, g.year); |
| 1453 | g.ymd = _fn(g.ddd, g.year, g.month, g.day); | 1453 | g.ymd = _fn(g.ddd, g.year, g.month, g.day); |
| 1454 | g.dmy = _fn(g.ddd, g.day, g.month, g.year); | 1454 | g.dmy = _fn(g.ddd, g.day, g.month, g.year); |
| 1455 | g.date = function (s) { | 1455 | g.date = function (s) { |
| 1456 | return ((g[$C.dateElementOrder] || g.mdy).call(this, s)); | 1456 | return ((g[$C.dateElementOrder] || g.mdy).call(this, s)); |
| 1457 | }; | 1457 | }; |
| 1458 | g.format = _.process(_.many(_.any(_.process(_.rtoken(/^(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { | 1458 | g.format = _.process(_.many(_.any(_.process(_.rtoken(/^(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { |
| 1459 | if (g[fmt]) { | 1459 | if (g[fmt]) { |
| 1460 | return g[fmt]; | 1460 | return g[fmt]; |
| 1461 | } else { | 1461 | } else { |
| 1462 | throw $D.Parsing.Exception(fmt); | 1462 | throw $D.Parsing.Exception(fmt); |
| 1463 | } | 1463 | } |
| 1464 | }), _.process(_.rtoken(/^[^dMyhHmstz]+/), function (s) { | 1464 | }), _.process(_.rtoken(/^[^dMyhHmstz]+/), function (s) { |
| 1465 | return _.ignore(_.stoken(s)); | 1465 | return _.ignore(_.stoken(s)); |
| 1466 | }))), function (rules) { | 1466 | }))), function (rules) { |
| 1467 | return _.process(_.each.apply(null, rules), t.finishExact); | 1467 | return _.process(_.each.apply(null, rules), t.finishExact); |
| 1468 | }); | 1468 | }); |
| 1469 | var _F = {}; | 1469 | var _F = {}; |
| 1470 | var _get = function (f) { | 1470 | var _get = function (f) { |
| 1471 | return _F[f] = (_F[f] || g.format(f)[0]); | 1471 | return _F[f] = (_F[f] || g.format(f)[0]); |
| 1472 | }; | 1472 | }; |
| 1473 | g.formats = function (fx) { | 1473 | g.formats = function (fx) { |
| 1474 | if (fx instanceof Array) { | 1474 | if (fx instanceof Array) { |
| 1475 | var rx = []; | 1475 | var rx = []; |
| 1476 | for (var i = 0; i < fx.length; i++) { | 1476 | for (var i = 0; i < fx.length; i++) { |
| 1477 | rx.push(_get(fx[i])); | 1477 | rx.push(_get(fx[i])); |
| 1478 | } | 1478 | } |
| 1479 | return _.any.apply(null, rx); | 1479 | return _.any.apply(null, rx); |
| 1480 | } else { | 1480 | } else { |
| 1481 | return _get(fx); | 1481 | return _get(fx); |
| 1482 | } | 1482 | } |
| 1483 | }; | 1483 | }; |
| 1484 | g._formats = g.formats(["\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d"]); | 1484 | g._formats = g.formats(["\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "MMddyyyy", "ddMMyyyy", "Mddyyyy", "ddMyyyy", "Mdyyyy", "dMyyyy", "yyyy", "Mdyy", "dMyy", "d"]); |
| 1485 | g._start = _.process(_.set([g.date, g.time, g.expression], g.generalDelimiter, g.whiteSpace), t.finish); | 1485 | g._start = _.process(_.set([g.date, g.time, g.expression], g.generalDelimiter, g.whiteSpace), t.finish); |
| 1486 | g.start = function (s) { | 1486 | g.start = function (s) { |
| 1487 | try { | 1487 | try { |
| 1488 | var r = g._formats.call({}, s); | 1488 | var r = g._formats.call({}, s); |
| 1489 | if (r[1].length === 0) { | 1489 | if (r[1].length === 0) { |
| 1490 | return r; | 1490 | return r; |
| 1491 | } | 1491 | } |
| 1492 | } catch (e) {} | 1492 | } catch (e) {} |
| 1493 | return g._start.call({}, s); | 1493 | return g._start.call({}, s); |
| 1494 | }; | 1494 | }; |
| 1495 | $D._parse = $D.parse; | 1495 | $D._parse = $D.parse; |
| 1496 | $D.parse = function (s) { | 1496 | $D.parse = function (s) { |
| 1497 | var r = null; | 1497 | var r = null; |
| 1498 | if (!s) { | 1498 | if (!s) { |
| 1499 | return null; | 1499 | return null; |
| 1500 | } | 1500 | } |
| 1501 | if (s instanceof Date) { | 1501 | if (s instanceof Date) { |
| 1502 | return s; | 1502 | return s; |
| 1503 | } | 1503 | } |
| 1504 | try { | 1504 | try { |
| 1505 | r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); | 1505 | r = $D.Grammar.start.call({}, s.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); |
| 1506 | } catch (e) { | 1506 | } catch (e) { |
| 1507 | return null; | 1507 | return null; |
| 1508 | } | 1508 | } |
| 1509 | return ((r[1].length === 0) ? r[0] : null); | 1509 | return ((r[1].length === 0) ? r[0] : null); |
| 1510 | }; | 1510 | }; |
| 1511 | $D.getParseFunction = function (fx) { | 1511 | $D.getParseFunction = function (fx) { |
| 1512 | var fn = $D.Grammar.formats(fx); | 1512 | var fn = $D.Grammar.formats(fx); |
| 1513 | return function (s) { | 1513 | return function (s) { |
| 1514 | var r = null; | 1514 | var r = null; |
| 1515 | try { | 1515 | try { |
| 1516 | r = fn.call({}, s); | 1516 | r = fn.call({}, s); |
| 1517 | } catch (e) { | 1517 | } catch (e) { |
| 1518 | return null; | 1518 | return null; |
| 1519 | } | 1519 | } |
| 1520 | return ((r[1].length === 0) ? r[0] : null); | 1520 | return ((r[1].length === 0) ? r[0] : null); |
| 1521 | }; | 1521 | }; |
| 1522 | }; | 1522 | }; |
| 1523 | $D.parseExact = function (s, fx) { | 1523 | $D.parseExact = function (s, fx) { |
| 1524 | return $D.getParseFunction(fx)(s); | 1524 | return $D.getParseFunction(fx)(s); |
| 1525 | }; | 1525 | }; |
| 1526 | }()); | 1526 | }()); |
| 1527 | 1527 | ||
| 1528 | // module.exports = { | 1528 | // module.exports = { |
| 1529 | // Date:Date | 1529 | // Date:Date |
| 1530 | // } | 1530 | // } |
| 1531 | 1531 | ||
| 1532 | module.exports = Date; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1532 | export default Date; | ... | ... |
src/utils/encrypt-util.js
0 → 100644
| 1 | import CryptoJS from "crypto-js"; | ||
| 2 | import JsEncrypt from "jsencrypt"; | ||
| 3 | let rsa = new JsEncrypt(); | ||
| 4 | |||
| 5 | /* | ||
| 6 | * 创建加密 | ||
| 7 | * @param data | ||
| 8 | * | ||
| 9 | * 设置项 | ||
| 10 | * key 公钥 | ||
| 11 | * iv 偏移量 | ||
| 12 | */ | ||
| 13 | export function makeEncrypt(param) { | ||
| 14 | let key = ""; | ||
| 15 | let iv = "" | ||
| 16 | rsa.setPublicKey(key); | ||
| 17 | let chars = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(","); | ||
| 18 | |||
| 19 | function randomAesKey() { | ||
| 20 | let res = ""; | ||
| 21 | for (let i = 0; i < 16; i++) { | ||
| 22 | let id = Math.ceil(Math.random() * (chars.length - 1)); | ||
| 23 | res += chars[id]; | ||
| 24 | } | ||
| 25 | return res; | ||
| 26 | }; | ||
| 27 | |||
| 28 | function encryptContent(obj) { | ||
| 29 | let aesKey = randomAesKey(); | ||
| 30 | let key = CryptoJS.enc.Utf8.parse(aesKey); | ||
| 31 | let ivR = CryptoJS.enc.Utf8.parse(iv); | ||
| 32 | var encrypted = CryptoJS.AES.encrypt(JSON.stringify(obj), key, { | ||
| 33 | iv: ivR, | ||
| 34 | mode: CryptoJS.mode.CBC, | ||
| 35 | padding: CryptoJS.pad.Pkcs7 | ||
| 36 | }); | ||
| 37 | let content = encrypted.toString(); //返回的是base64格式的密文 | ||
| 38 | let securityKey = rsa.encrypt(aesKey); | ||
| 39 | |||
| 40 | let result = { | ||
| 41 | k: securityKey, | ||
| 42 | v: content | ||
| 43 | }; | ||
| 44 | return result; | ||
| 45 | }; | ||
| 46 | let data = encryptContent(param) | ||
| 47 | return data; | ||
| 48 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -8,6 +8,16 @@ export function checkMobile(str) { | ... | @@ -8,6 +8,16 @@ export function checkMobile(str) { |
| 8 | return REGEXPS.mobile.test(str); | 8 | return REGEXPS.mobile.test(str); |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | // 判断是否微信环境 | ||
| 12 | export function isWeiXin() { | ||
| 13 | var ua = window.navigator.userAgent.toLowerCase(); | ||
| 14 | if (ua.match(/MicroMessenger/i) == 'micromessenger') { | ||
| 15 | return true; | ||
| 16 | } else { | ||
| 17 | return false; | ||
| 18 | } | ||
| 19 | } | ||
| 20 | |||
| 11 | /** | 21 | /** |
| 12 | * 链接参数转换为obj | 22 | * 链接参数转换为obj |
| 13 | * 入参 完整链接 | 23 | * 入参 完整链接 |
| ... | @@ -29,33 +39,22 @@ export function param2Obj(url) { | ... | @@ -29,33 +39,22 @@ export function param2Obj(url) { |
| 29 | } | 39 | } |
| 30 | 40 | ||
| 31 | 41 | ||
| 32 | 42 | /** | |
| 33 | //获取cookie、 | 43 | * 从数组中获取 key未value的对象 |
| 34 | export function getCookie(name) { | 44 | * @param {*} value |
| 35 | var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); | 45 | * @param {*} key |
| 36 | if (arr = document.cookie.match(reg)) | 46 | * @param {*} list |
| 37 | return (arr[2]); | 47 | */ |
| 38 | else | 48 | export function getObjByListKeyValue(value, key, list) { |
| 39 | return null; | 49 | let result = null; |
| 50 | list.forEach(element => { | ||
| 51 | if (element[key + ""] == value) { | ||
| 52 | result = element; | ||
| 53 | } | ||
| 54 | }); | ||
| 55 | return result; | ||
| 40 | } | 56 | } |
| 41 | 57 | ||
| 42 | //设置cookie | ||
| 43 | export function setCookie(c_name, value, expiredays) { | ||
| 44 | var exdate = new Date(); | ||
| 45 | exdate.setDate(exdate.getDate() + expiredays); | ||
| 46 | document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString()); | ||
| 47 | }; | ||
| 48 | |||
| 49 | //删除cookie | ||
| 50 | export function delCookie(name) { | ||
| 51 | var exp = new Date(); | ||
| 52 | exp.setTime(exp.getTime() - 1); | ||
| 53 | var cval = getCookie(name); | ||
| 54 | if (cval != null) | ||
| 55 | document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString(); | ||
| 56 | }; | ||
| 57 | |||
| 58 | |||
| 59 | /** | 58 | /** |
| 60 | * 获取环境信息 | 59 | * 获取环境信息 |
| 61 | * @return {Object} 环境信息对象 | 60 | * @return {Object} 环境信息对象 | ... | ... |
| 1 | const Timestamp = new Date().getTime(); | 1 | const Timestamp = new Date().getTime(); |
| 2 | const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | 2 | const MiniCssExtractPlugin = require('mini-css-extract-plugin'); |
| 3 | // 打包目录 | 3 | const path = require('path') |
| 4 | let webpack_public_path = 'dist' | 4 | |
| 5 | if (process.env.NODE_ENV === 'production') { | 5 | // 配置资源包路径 |
| 6 | webpack_public_path = process.env.VUE_APP_TITLE | 6 | let webpack_public_path = process.env.VUE_APP_PUBLIC_PATH; |
| 7 | |||
| 8 | let webpack_output_dir = "dist"; | ||
| 9 | webpack_output_dir = process.env.VUE_APP_OUTPUT_DIR; | ||
| 10 | |||
| 11 | |||
| 12 | function resolve(dir) { | ||
| 13 | return path.join(__dirname, dir); | ||
| 7 | } | 14 | } |
| 15 | |||
| 8 | module.exports = { | 16 | module.exports = { |
| 17 | chainWebpack: (config) => { | ||
| 18 | config.resolve.alias | ||
| 19 | .set('@', resolve('src')) | ||
| 20 | .set('@public', resolve('public')) | ||
| 21 | .set('@assets', resolve('src/assets')) | ||
| 22 | .set('@components', resolve('src/components')) | ||
| 23 | .set('@pages', resolve('src/pages')) | ||
| 24 | .set('@api', resolve('src/api')) | ||
| 25 | .set('@styles', resolve('src/styles')) | ||
| 26 | .set('@store', resolve('src/store')) | ||
| 27 | .set('@utils', resolve('src/utils')) | ||
| 28 | .set('@common', resolve('src/common')); | ||
| 29 | |||
| 30 | const oneOfsMap = config.module.rule('scss').oneOfs.store | ||
| 31 | oneOfsMap.forEach(item => { | ||
| 32 | item | ||
| 33 | .use('sass-resources-loader') | ||
| 34 | .loader('sass-resources-loader') | ||
| 35 | .options({ | ||
| 36 | // Provide path to the file with resources | ||
| 37 | // 要公用的scss的路径 | ||
| 38 | resources: ['./src/styles/vars.scss', './src/styles/mixins.scss', './src/styles/utils.scss'] | ||
| 39 | }) | ||
| 40 | .end() | ||
| 41 | }) | ||
| 42 | |||
| 43 | }, | ||
| 9 | configureWebpack: { // webpack 配置 | 44 | configureWebpack: { // webpack 配置 |
| 10 | // 修改打包后js文件名 | 45 | // 修改打包后js文件名 |
| 11 | output: { // 输出重构 打包编译后的 文件名称 【模块名称.版本号.时间戳】 | 46 | output: { // 输出重构 打包编译后的 文件名称 【模块名称.版本号.时间戳】 |
| ... | @@ -42,10 +77,11 @@ module.exports = { | ... | @@ -42,10 +77,11 @@ module.exports = { |
| 42 | //例如 https://www.my-app.com/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.my-app.com/my-app/,则设置 baseUrl 为 /my-app/。 | 77 | //例如 https://www.my-app.com/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.my-app.com/my-app/,则设置 baseUrl 为 /my-app/。 |
| 43 | //baseUrl 从 Vue CLI 3.3 起已弃用,请使用publicPath | 78 | //baseUrl 从 Vue CLI 3.3 起已弃用,请使用publicPath |
| 44 | //baseUrl: process.env.NODE_ENV === "production" ? "./" : "/", | 79 | //baseUrl: process.env.NODE_ENV === "production" ? "./" : "/", |
| 45 | publicPath: process.env.NODE_ENV === "dev" ? "/" : "./", | 80 | // publicPath: process.env.NODE_ENV === "dev" ? "/" : "./", |
| 81 | publicPath: process.env.NODE_ENV === "dev" ? "/" : webpack_public_path, // history模式 用短码? | ||
| 46 | 82 | ||
| 47 | // outputDir: 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致) | 83 | // outputDir: 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致) |
| 48 | outputDir: webpack_public_path, | 84 | outputDir: webpack_output_dir, |
| 49 | //用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下) | 85 | //用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下) |
| 50 | assetsDir: "assets", | 86 | assetsDir: "assets", |
| 51 | //指定生成的 index.html 的输出路径 (打包之后,改变系统默认的index.html的文件名) | 87 | //指定生成的 index.html 的输出路径 (打包之后,改变系统默认的index.html的文件名) |
| ... | @@ -70,11 +106,11 @@ module.exports = { | ... | @@ -70,11 +106,11 @@ module.exports = { |
| 70 | productionSourceMap: false, | 106 | productionSourceMap: false, |
| 71 | 107 | ||
| 72 | // 它支持webPack-dev-server的所有选项 | 108 | // 它支持webPack-dev-server的所有选项 |
| 73 | devServer: { | 109 | // devServer: { |
| 74 | host: "localhost", | 110 | // host: "localhost", |
| 75 | port: 9001, // 端口号 | 111 | // port: 9001, // 端口号 |
| 76 | https: false, // https:{type:Boolean} | 112 | // https: false, // https:{type:Boolean} |
| 77 | open: true, //配置自动启动浏览器 | 113 | // open: true, //配置自动启动浏览器 |
| 78 | // proxy: 'http://localhost:4000' // 配置跨域处理,只有一个代理 | 114 | // // proxy: 'http://localhost:4000' // 配置跨域处理,只有一个代理 |
| 79 | } | 115 | // } |
| 80 | }; | 116 | }; |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment