├── .babelrc ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── README.md ├── build ├── build.js ├── dev-client.js ├── dev-server.js ├── utils.js ├── webpack.base.conf.js ├── webpack.dev.conf.js └── webpack.prod.conf.js ├── config ├── dev.env.js ├── index.js ├── prod.env.js └── test.env.js ├── index.html ├── package.json └── src ├── assets ├── images │ ├── components │ │ ├── go_icon.png │ │ ├── go_next_icon.png │ │ ├── login_icon.png │ │ ├── nav_icon.png │ │ └── user.png │ ├── index.png │ ├── loading.gif │ └── logo.png ├── logo.png └── scss │ ├── common │ ├── common.scss │ └── reset.scss │ ├── iconfont │ └── iconfont.css │ └── main.scss ├── components ├── header.vue ├── load.vue ├── loading.vue ├── menu.vue ├── nvAlert.vue ├── nvfooter.vue ├── reply.vue └── userinfo.vue ├── filter.js ├── libs ├── qrcode.js └── utils.js ├── main.js ├── router.js └── views ├── about.vue ├── index.vue ├── list.vue ├── login.vue ├── message.vue ├── publish.vue ├── topic.vue └── user.vue /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015", "stage-2"], 3 | "plugins": ["transform-runtime"], 4 | "comments": false 5 | } 6 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | build/*.js 2 | config/*.js 3 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: 'babel-eslint', 4 | parserOptions: { 5 | sourceType: 'module' 6 | }, 7 | // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style 8 | extends: 'standard', 9 | // required to lint *.vue files 10 | plugins: [ 11 | 'html' 12 | ], 13 | // add your custom rules here 14 | 'rules': { 15 | // allow paren-less arrow functions 16 | 'arrow-parens': 0, 17 | // allow async-await 18 | 'generator-star-spacing': 0, 19 | // allow debugger during development 20 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | dist/ 4 | npm-debug.log 5 | selenium-debug.log 6 | test/unit/coverage 7 | test/e2e/reports 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A [cnode](https://cnodejs.org/) webapp Based on vue.js 2 | 3 | > A Vue.js project 4 | 5 | ##Install 6 | ```shell 7 | git clone https://github.com/Thstone37/vue-cnode.git 8 | ``` 9 | 10 | ## Build Setup 11 | 12 | ``` bash 13 | # install dependencies 14 | npm install 15 | 16 | # serve with hot reload at localhost:8080 17 | npm run dev 18 | 19 | # build for production with minification 20 | npm run build 21 | 22 | # run unit tests 23 | npm run unit 24 | 25 | # run e2e tests 26 | npm run e2e 27 | 28 | # run all tests 29 | npm test 30 | ``` 31 | 32 | For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /build/build.js: -------------------------------------------------------------------------------- 1 | // https://github.com/shelljs/shelljs 2 | require('shelljs/global') 3 | env.NODE_ENV = 'production' 4 | 5 | var path = require('path') 6 | var config = require('../config') 7 | var ora = require('ora') 8 | var webpack = require('webpack') 9 | var webpackConfig = require('./webpack.prod.conf') 10 | 11 | console.log( 12 | ' Tip:\n' + 13 | ' Built files are meant to be served over an HTTP server.\n' + 14 | ' Opening index.html over file:// won\'t work.\n' 15 | ) 16 | 17 | var spinner = ora('building for production...') 18 | spinner.start() 19 | 20 | var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory) 21 | rm('-rf', assetsPath) 22 | mkdir('-p', assetsPath) 23 | cp('-R', 'static/', assetsPath) 24 | 25 | webpack(webpackConfig, function (err, stats) { 26 | spinner.stop() 27 | if (err) throw err 28 | process.stdout.write(stats.toString({ 29 | colors: true, 30 | modules: false, 31 | children: false, 32 | chunks: false, 33 | chunkModules: false 34 | }) + '\n') 35 | }) 36 | -------------------------------------------------------------------------------- /build/dev-client.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | require('eventsource-polyfill') 3 | var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true') 4 | 5 | hotClient.subscribe(function (event) { 6 | if (event.action === 'reload') { 7 | window.location.reload() 8 | } 9 | }) 10 | -------------------------------------------------------------------------------- /build/dev-server.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var express = require('express') 3 | var webpack = require('webpack') 4 | var config = require('../config') 5 | var proxyMiddleware = require('http-proxy-middleware') 6 | var webpackConfig = process.env.NODE_ENV === 'testing' 7 | ? require('./webpack.prod.conf') 8 | : require('./webpack.dev.conf') 9 | 10 | // default port where dev server listens for incoming traffic 11 | var port = process.env.PORT || config.dev.port 12 | // Define HTTP proxies to your custom API backend 13 | // https://github.com/chimurai/http-proxy-middleware 14 | var proxyTable = config.dev.proxyTable 15 | 16 | var app = express() 17 | var compiler = webpack(webpackConfig) 18 | 19 | var devMiddleware = require('webpack-dev-middleware')(compiler, { 20 | publicPath: webpackConfig.output.publicPath, 21 | stats: { 22 | colors: true, 23 | chunks: false 24 | } 25 | }) 26 | 27 | var hotMiddleware = require('webpack-hot-middleware')(compiler) 28 | // force page reload when html-webpack-plugin template changes 29 | compiler.plugin('compilation', function (compilation) { 30 | compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) { 31 | hotMiddleware.publish({ action: 'reload' }) 32 | cb() 33 | }) 34 | }) 35 | 36 | // proxy api requests 37 | Object.keys(proxyTable).forEach(function (context) { 38 | var options = proxyTable[context] 39 | if (typeof options === 'string') { 40 | options = { target: options } 41 | } 42 | app.use(proxyMiddleware(context, options)) 43 | }) 44 | 45 | // handle fallback for HTML5 history API 46 | app.use(require('connect-history-api-fallback')()) 47 | 48 | // serve webpack bundle output 49 | app.use(devMiddleware) 50 | 51 | // enable hot-reload and state-preserving 52 | // compilation error display 53 | app.use(hotMiddleware) 54 | 55 | // serve pure static assets 56 | var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory) 57 | app.use(staticPath, express.static('./static')) 58 | 59 | module.exports = app.listen(port, function (err) { 60 | if (err) { 61 | console.log(err) 62 | return 63 | } 64 | console.log('Listening at http://localhost:' + port + '\n') 65 | }) 66 | -------------------------------------------------------------------------------- /build/utils.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var config = require('../config') 3 | var ExtractTextPlugin = require('extract-text-webpack-plugin') 4 | 5 | exports.assetsPath = function (_path) { 6 | return path.posix.join(config.build.assetsSubDirectory, _path) 7 | } 8 | 9 | exports.cssLoaders = function (options) { 10 | options = options || {} 11 | // generate loader string to be used with extract text plugin 12 | function generateLoaders (loaders) { 13 | var sourceLoader = loaders.map(function (loader) { 14 | var extraParamChar 15 | if (/\?/.test(loader)) { 16 | loader = loader.replace(/\?/, '-loader?') 17 | extraParamChar = '&' 18 | } else { 19 | loader = loader + '-loader' 20 | extraParamChar = '?' 21 | } 22 | return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '') 23 | }).join('!') 24 | 25 | if (options.extract) { 26 | return ExtractTextPlugin.extract('vue-style-loader', sourceLoader) 27 | } else { 28 | return ['vue-style-loader', sourceLoader].join('!') 29 | } 30 | } 31 | 32 | // http://vuejs.github.io/vue-loader/configurations/extract-css.html 33 | return { 34 | css: generateLoaders(['css']), 35 | postcss: generateLoaders(['css']), 36 | less: generateLoaders(['css', 'less']), 37 | sass: generateLoaders(['css', 'sass?indentedSyntax']), 38 | scss: generateLoaders(['css', 'sass']), 39 | stylus: generateLoaders(['css', 'stylus']), 40 | styl: generateLoaders(['css', 'stylus']) 41 | } 42 | } 43 | 44 | // Generate loaders for standalone style files (outside of .vue) 45 | exports.styleLoaders = function (options) { 46 | var output = [] 47 | var loaders = exports.cssLoaders(options) 48 | for (var extension in loaders) { 49 | var loader = loaders[extension] 50 | output.push({ 51 | test: new RegExp('\\.' + extension + '$'), 52 | loader: loader 53 | }) 54 | } 55 | return output 56 | } 57 | -------------------------------------------------------------------------------- /build/webpack.base.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var config = require('../config') 3 | var utils = require('./utils') 4 | var projectRoot = path.resolve(__dirname, '../') 5 | var ExtractTextPlugin = require("extract-text-webpack-plugin"); 6 | 7 | module.exports = { 8 | entry: { 9 | app: './src/main.js' 10 | }, 11 | output: { 12 | path: config.build.assetsRoot, 13 | publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath, 14 | filename: '[name].js' 15 | }, 16 | resolve: { 17 | extensions: ['', '.js', '.vue'], 18 | fallback: [path.join(__dirname, '../node_modules')], 19 | alias: { 20 | 'src': path.resolve(__dirname, '../src'), 21 | 'assets': path.resolve(__dirname, '../src/assets'), 22 | 'components': path.resolve(__dirname, '../src/components') 23 | } 24 | }, 25 | resolveLoader: { 26 | fallback: [path.join(__dirname, '../node_modules')] 27 | }, 28 | module: { 29 | loaders: [ 30 | { 31 | test: /\.vue$/, 32 | loader: 'vue' 33 | }, 34 | // { 35 | // test:/\.scss$/, 36 | // loader:ExtractTextPlugin.extract( 37 | // "style-loader", "css-loader!sass-loader") 38 | // }, 39 | { 40 | test: /\.js$/, 41 | loader: 'babel', 42 | include: projectRoot, 43 | exclude: /node_modules/ 44 | }, 45 | { 46 | test: /\.json$/, 47 | loader: 'json' 48 | }, 49 | { 50 | test: /\.html$/, 51 | loader: 'vue-html' 52 | }, 53 | { 54 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 55 | loader: 'url', 56 | query: { 57 | limit: 10000, 58 | name: utils.assetsPath('img/[name].[hash:7].[ext]') 59 | } 60 | }, 61 | { 62 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 63 | loader: 'url', 64 | query: { 65 | limit: 10000, 66 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]') 67 | } 68 | } 69 | ] 70 | }, 71 | vue: { 72 | loaders: utils.cssLoaders() 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /build/webpack.dev.conf.js: -------------------------------------------------------------------------------- 1 | var config = require('../config') 2 | var webpack = require('webpack') 3 | var merge = require('webpack-merge') 4 | var utils = require('./utils') 5 | var baseWebpackConfig = require('./webpack.base.conf') 6 | var HtmlWebpackPlugin = require('html-webpack-plugin') 7 | var ExtractTextPlugin = require("extract-text-webpack-plugin"); 8 | 9 | // add hot-reload related code to entry chunks 10 | Object.keys(baseWebpackConfig.entry).forEach(function (name) { 11 | baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name]) 12 | }) 13 | 14 | module.exports = merge(baseWebpackConfig, { 15 | module: { 16 | loaders: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap }) 17 | }, 18 | // eval-source-map is faster for development 19 | devtool: '#eval-source-map', 20 | plugins: [ 21 | new webpack.DefinePlugin({ 22 | 'process.env': config.dev.env 23 | }), 24 | // https://github.com/glenjamin/webpack-hot-middleware#installation--usage 25 | new webpack.optimize.OccurenceOrderPlugin(), 26 | new webpack.HotModuleReplacementPlugin(), 27 | new webpack.NoErrorsPlugin(), 28 | // https://github.com/ampedandwired/html-webpack-plugin 29 | new HtmlWebpackPlugin({ 30 | filename: 'index.html', 31 | template: 'index.html', 32 | inject: true 33 | }), 34 | new webpack.ProvidePlugin({ 35 | $: 'webpack-zepto' 36 | }), 37 | new ExtractTextPlugin("style.css", { 38 | allChunks: true, 39 | disable: false 40 | }) 41 | ] 42 | }) 43 | -------------------------------------------------------------------------------- /build/webpack.prod.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var config = require('../config') 3 | var utils = require('./utils') 4 | var webpack = require('webpack') 5 | var merge = require('webpack-merge') 6 | var baseWebpackConfig = require('./webpack.base.conf') 7 | var ExtractTextPlugin = require('extract-text-webpack-plugin') 8 | var HtmlWebpackPlugin = require('html-webpack-plugin') 9 | var env = process.env.NODE_ENV === 'testing' 10 | ? require('../config/test.env') 11 | : config.build.env 12 | 13 | var webpackConfig = merge(baseWebpackConfig, { 14 | module: { 15 | loaders: utils.styleLoaders({ sourceMap: config.build.productionSourceMap, extract: true }) 16 | }, 17 | devtool: config.build.productionSourceMap ? '#source-map' : false, 18 | output: { 19 | path: config.build.assetsRoot, 20 | filename: utils.assetsPath('js/[name].[chunkhash].js'), 21 | chunkFilename: utils.assetsPath('js/[id].[chunkhash].js') 22 | }, 23 | vue: { 24 | loaders: utils.cssLoaders({ 25 | sourceMap: config.build.productionSourceMap, 26 | extract: true 27 | }) 28 | }, 29 | plugins: [ 30 | // http://vuejs.github.io/vue-loader/workflow/production.html 31 | new webpack.DefinePlugin({ 32 | 'process.env': env 33 | }), 34 | new webpack.optimize.UglifyJsPlugin({ 35 | compress: { 36 | warnings: false 37 | } 38 | }), 39 | new webpack.optimize.OccurenceOrderPlugin(), 40 | // extract css into its own file 41 | // new ExtractTextPlugin(utils.assetsPath('css/[name].[contenthash].css')), 42 | new ExtractTextPlugin(utils.assetsPath('css/style.[contenthash].css'),{ 43 | allChunks:true 44 | }), 45 | // generate dist index.html with correct asset hash for caching. 46 | // you can customize output by editing /index.html 47 | // see https://github.com/ampedandwired/html-webpack-plugin 48 | new HtmlWebpackPlugin({ 49 | filename: process.env.NODE_ENV === 'testing' 50 | ? 'index.html' 51 | : config.build.index, 52 | template: 'index.html', 53 | inject: true, 54 | minify: { 55 | removeComments: true, 56 | collapseWhitespace: true, 57 | removeAttributeQuotes: true 58 | // more options: 59 | // https://github.com/kangax/html-minifier#options-quick-reference 60 | }, 61 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin 62 | chunksSortMode: 'dependency' 63 | }), 64 | // split vendor js into its own file 65 | new webpack.optimize.CommonsChunkPlugin({ 66 | name: 'vendor', 67 | minChunks: function (module, count) { 68 | // any required modules inside node_modules are extracted to vendor 69 | return ( 70 | module.resource && 71 | /\.js$/.test(module.resource) && 72 | module.resource.indexOf( 73 | path.join(__dirname, '../node_modules') 74 | ) === 0 75 | ) 76 | } 77 | }), 78 | // extract webpack runtime and module manifest to its own file in order to 79 | // prevent vendor hash from being updated whenever app bundle is updated 80 | new webpack.optimize.CommonsChunkPlugin({ 81 | name: 'manifest', 82 | chunks: ['vendor'] 83 | }), 84 | new webpack.ProvidePlugin({ 85 | $: 'webpack-zepto' 86 | }) 87 | ] 88 | }) 89 | 90 | if (config.build.productionGzip) { 91 | var CompressionWebpackPlugin = require('compression-webpack-plugin') 92 | 93 | webpackConfig.plugins.push( 94 | new CompressionWebpackPlugin({ 95 | asset: '[path].gz[query]', 96 | algorithm: 'gzip', 97 | test: new RegExp( 98 | '\\.(' + 99 | config.build.productionGzipExtensions.join('|') + 100 | ')$' 101 | ), 102 | threshold: 10240, 103 | minRatio: 0.8 104 | }) 105 | ) 106 | } 107 | 108 | module.exports = webpackConfig 109 | -------------------------------------------------------------------------------- /config/dev.env.js: -------------------------------------------------------------------------------- 1 | var merge = require('webpack-merge') 2 | var prodEnv = require('./prod.env') 3 | 4 | module.exports = merge(prodEnv, { 5 | NODE_ENV: '"development"' 6 | }) 7 | -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | // see http://vuejs-templates.github.io/webpack for documentation. 2 | var path = require('path') 3 | 4 | module.exports = { 5 | build: { 6 | env: require('./prod.env'), 7 | index: path.resolve(__dirname, '../dist/index.html'), 8 | assetsRoot: path.resolve(__dirname, '../dist'), 9 | assetsSubDirectory: 'static', 10 | assetsPublicPath: '/', 11 | productionSourceMap: true, 12 | // Gzip off by default as many popular static hosts such as 13 | // Surge or Netlify already gzip all static assets for you. 14 | // Before setting to `true`, make sure to: 15 | // npm install --save-dev compression-webpack-plugin 16 | productionGzip: false, 17 | productionGzipExtensions: ['js', 'css'] 18 | }, 19 | dev: { 20 | env: require('./dev.env'), 21 | port: 8080, 22 | assetsSubDirectory: 'static', 23 | assetsPublicPath: '/', 24 | proxyTable: {}, 25 | // CSS Sourcemaps off by default because relative paths are "buggy" 26 | // with this option, according to the CSS-Loader README 27 | // (https://github.com/webpack/css-loader#sourcemaps) 28 | // In our experience, they generally work as expected, 29 | // just be aware of this issue when enabling this option. 30 | cssSourceMap: false, 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /config/prod.env.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | NODE_ENV: '"production"' 3 | } 4 | -------------------------------------------------------------------------------- /config/test.env.js: -------------------------------------------------------------------------------- 1 | var merge = require('webpack-merge') 2 | var devEnv = require('./dev.env') 3 | 4 | module.exports = merge(devEnv, { 5 | NODE_ENV: '"testing"' 6 | }) 7 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Vue.js 6 | 7 | 8 | 9 |
10 | 11 |
12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "y", 3 | "version": "1.0.0", 4 | "description": "A Vue.js project", 5 | "author": "Thstone37 <82461760@qq.com>", 6 | "private": true, 7 | "scripts": { 8 | "dev": "node build/dev-server.js", 9 | "build": "node build/build.js", 10 | "unit": "karma start test/unit/karma.conf.js --single-run", 11 | "e2e": "node test/e2e/runner.js", 12 | "test": "npm run unit && npm run e2e" 13 | }, 14 | "dependencies": { 15 | "vue": "^1.0.21", 16 | "babel-runtime": "^6.0.0" 17 | }, 18 | "devDependencies": { 19 | "babel-core": "^6.0.0", 20 | "babel-loader": "^6.0.0", 21 | "babel-plugin-transform-runtime": "^6.0.0", 22 | "babel-preset-es2015": "^6.9.0", 23 | "babel-preset-stage-2": "^6.0.0", 24 | "babel-register": "^6.0.0", 25 | "chai": "^3.5.0", 26 | "chromedriver": "^2.21.2", 27 | "connect-history-api-fallback": "^1.1.0", 28 | "cross-spawn": "^2.1.5", 29 | "css-loader": "^0.23.0", 30 | "eventsource-polyfill": "^0.9.6", 31 | "express": "^4.13.3", 32 | "extract-text-webpack-plugin": "^1.0.1", 33 | "file-loader": "^0.8.4", 34 | "function-bind": "^1.0.2", 35 | "html-webpack-plugin": "^2.8.1", 36 | "http-proxy-middleware": "^0.12.0", 37 | "inject-loader": "^2.0.1", 38 | "isparta-loader": "^2.0.0", 39 | "json-loader": "^0.5.4", 40 | "karma": "^0.13.15", 41 | "karma-coverage": "^0.5.5", 42 | "karma-mocha": "^0.2.2", 43 | "karma-phantomjs-launcher": "^1.0.0", 44 | "karma-sinon-chai": "^1.2.0", 45 | "karma-sourcemap-loader": "^0.3.7", 46 | "karma-spec-reporter": "0.0.24", 47 | "karma-webpack": "^1.7.0", 48 | "lodash": "^4.15.0", 49 | "lolex": "^1.4.0", 50 | "markdown": "^0.5.0", 51 | "mocha": "^2.4.5", 52 | "nightwatch": "^0.8.18", 53 | "node-sass": "^3.8.0", 54 | "ora": "^0.2.0", 55 | "phantomjs-prebuilt": "^2.1.3", 56 | "sass-loader": "^4.0.0", 57 | "selenium-server": "2.53.0", 58 | "shelljs": "^0.6.0", 59 | "sinon": "^1.17.3", 60 | "sinon-chai": "^2.8.0", 61 | "style-loader": "^0.13.1", 62 | "url-loader": "^0.5.7", 63 | "vue-hot-reload-api": "^1.2.0", 64 | "vue-html-loader": "^1.0.0", 65 | "vue-loader": "^8.3.0", 66 | "vue-resource": "^0.9.3", 67 | "vue-router": "^0.7.13", 68 | "vue-style-loader": "^1.0.0", 69 | "webpack": "^1.12.2", 70 | "webpack-dev-middleware": "^1.4.0", 71 | "webpack-hot-middleware": "^2.6.0", 72 | "webpack-merge": "^0.8.3", 73 | "webpack-zepto": "0.0.1", 74 | "zepto": "^1.2.0" 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/assets/images/components/go_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thstone37/vue-cnode/40eeec6ba3b453cd7933aa02e68ffc04f119b7a3/src/assets/images/components/go_icon.png -------------------------------------------------------------------------------- /src/assets/images/components/go_next_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thstone37/vue-cnode/40eeec6ba3b453cd7933aa02e68ffc04f119b7a3/src/assets/images/components/go_next_icon.png -------------------------------------------------------------------------------- /src/assets/images/components/login_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thstone37/vue-cnode/40eeec6ba3b453cd7933aa02e68ffc04f119b7a3/src/assets/images/components/login_icon.png -------------------------------------------------------------------------------- /src/assets/images/components/nav_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thstone37/vue-cnode/40eeec6ba3b453cd7933aa02e68ffc04f119b7a3/src/assets/images/components/nav_icon.png -------------------------------------------------------------------------------- /src/assets/images/components/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thstone37/vue-cnode/40eeec6ba3b453cd7933aa02e68ffc04f119b7a3/src/assets/images/components/user.png -------------------------------------------------------------------------------- /src/assets/images/index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thstone37/vue-cnode/40eeec6ba3b453cd7933aa02e68ffc04f119b7a3/src/assets/images/index.png -------------------------------------------------------------------------------- /src/assets/images/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thstone37/vue-cnode/40eeec6ba3b453cd7933aa02e68ffc04f119b7a3/src/assets/images/loading.gif -------------------------------------------------------------------------------- /src/assets/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thstone37/vue-cnode/40eeec6ba3b453cd7933aa02e68ffc04f119b7a3/src/assets/images/logo.png -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thstone37/vue-cnode/40eeec6ba3b453cd7933aa02e68ffc04f119b7a3/src/assets/logo.png -------------------------------------------------------------------------------- /src/assets/scss/common/common.scss: -------------------------------------------------------------------------------- 1 | #app{ 2 | width:100%; 3 | height:100%; 4 | } -------------------------------------------------------------------------------- /src/assets/scss/common/reset.scss: -------------------------------------------------------------------------------- 1 | html,body{ 2 | width: 100%; 3 | height: 100%; 4 | line-height: 1.5; 5 | font-family: "Helvetica-Neue", "Helvetica", Arial, sans-serif; 6 | margin: 0; 7 | padding: 0; 8 | list-style: none; 9 | border: 0; 10 | } 11 | div, span, object, iframe, img, table, caption, thead, tbody, 12 | tfoot, tr, tr, td, article, aside, canvas, details, figure, hgroup, menu, 13 | nav, footer, header, section, summary, mark, audio, video { 14 | border: 0; 15 | margin: 0; 16 | padding: 0; 17 | } 18 | 19 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, address, cit, code, 20 | del, dfn, em, ins, q, samp, small, strong, sub, sup, b, i, hr, dl, dt, dd, 21 | ol, ul, li, fieldset, legend, label { 22 | border: 0; 23 | font-size: 100%; 24 | vertical-align: baseline; 25 | margin: 0; 26 | padding: 0; 27 | } 28 | 29 | article, aside, canvas, figure, figure img, figcaption, hgroup, 30 | footer, header, nav, section, audio, video { 31 | display: block; 32 | } 33 | 34 | table { 35 | border-collapse: separate; 36 | border-spacing: 0; 37 | caption, th, td { 38 | text-align: left; 39 | vertical-align: middle; 40 | } 41 | } 42 | li{ 43 | list-style: none; 44 | } 45 | a{ 46 | text-decoration: none; 47 | } 48 | a img { 49 | border: 0; 50 | } 51 | 52 | :focus { 53 | outline: 0; 54 | } 55 | *{ 56 | -webkit-box-sizing: border-box; 57 | } 58 | textarea{ 59 | resize: none; 60 | -webkit-appearance: none; 61 | } 62 | input{ 63 | -webkit-appearance: none; 64 | } 65 | select { 66 | -webkit-appearance: none; 67 | background-color: #fff; 68 | } -------------------------------------------------------------------------------- /src/assets/scss/iconfont/iconfont.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'iconfont'; 3 | src: url('//at.alicdn.com/t/font_1449145493_7316074.eot'); /* IE9*/ 4 | src: url('//at.alicdn.com/t/font_1449145493_7316074.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ 5 | url('//at.alicdn.com/t/font_1449145493_7316074.woff') format('woff'), /* chrome、firefox */ 6 | url('//at.alicdn.com/t/font_1449145493_7316074.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/ 7 | url('//at.alicdn.com/t/font_1449145493_7316074.svg#iconfont') format('svg'); /* iOS 4.1- */ 8 | } 9 | 10 | 11 | .iconfont { 12 | font-family:"iconfont" !important; 13 | font-size:16px; 14 | font-style:normal; 15 | -webkit-font-smoothing: antialiased; 16 | -webkit-text-stroke-width: 0.2px; 17 | -moz-osx-font-smoothing: grayscale; 18 | } 19 | .icon-tianjia:before { content: "\e60d"; margin-right: 30px; } 20 | .icon-fenxiang:before { content: "\e600"; margin-right: 30px; } 21 | .icon-shezhi:before { content: "\e601"; margin-right: 30px;} 22 | .icon-wenda:before { content: "\e602"; margin-right: 30px;} 23 | .icon-hao:before { content: "\e603"; margin-right: 30px;} 24 | .icon-quanbu:before { content: "\e604"; margin-right: 30px;} 25 | .icon-zhaopin:before { content: "\e605"; margin-right: 30px;} 26 | .icon-xiaoxi:before { content: "\e606"; margin-right: 30px;} 27 | .icon-about:before { content: "\e607"; margin-right: 30px;} -------------------------------------------------------------------------------- /src/assets/scss/main.scss: -------------------------------------------------------------------------------- 1 | @import "./common/reset.scss"; 2 | @import "./common/common.scss"; 3 | @import "./iconfont/iconfont.css"; 4 | -------------------------------------------------------------------------------- /src/components/header.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 30 | 31 | -------------------------------------------------------------------------------- /src/components/load.vue: -------------------------------------------------------------------------------- 1 | 4 | 11 | -------------------------------------------------------------------------------- /src/components/loading.vue: -------------------------------------------------------------------------------- 1 | 9 | 15 | -------------------------------------------------------------------------------- /src/components/menu.vue: -------------------------------------------------------------------------------- 1 | 15 | 23 | -------------------------------------------------------------------------------- /src/components/nvAlert.vue: -------------------------------------------------------------------------------- 1 | 8 | 13 | -------------------------------------------------------------------------------- /src/components/nvfooter.vue: -------------------------------------------------------------------------------- 1 | 11 | 32 | -------------------------------------------------------------------------------- /src/components/reply.vue: -------------------------------------------------------------------------------- 1 | 7 | 66 | -------------------------------------------------------------------------------- /src/components/userinfo.vue: -------------------------------------------------------------------------------- 1 | 16 | 35 | -------------------------------------------------------------------------------- /src/filter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @authors Your Name (you@example.org) 4 | * @date 2016-08-12 17:30:27 5 | * @version $Id$ 6 | */ 7 | import utils from "./libs/utils.js" 8 | 9 | exports.getLastTimeStr=function(time,is){ 10 | if(is){ 11 | return utils.Millisecondstodate(new Date()-new Date(time)); 12 | }else{ 13 | return utils.fmtDate(new Date(time)); 14 | } 15 | } 16 | exports.getTitleStr=function(tab){ 17 | var str="" 18 | switch(tab){ 19 | case "share": 20 | str="分享"; 21 | break; 22 | case "ask": 23 | str="问答"; 24 | break; 25 | case "good": 26 | str="精华"; 27 | break; 28 | case "job": 29 | str="招聘"; 30 | break; 31 | default: 32 | str="全部"; 33 | break; 34 | } 35 | return str; 36 | } 37 | 38 | exports.getTabClassName=function(tab,good,top){ 39 | var className=""; 40 | if(good){ 41 | className="good"; 42 | }else if(top){ 43 | className="top" 44 | }else{ 45 | switch(tab){ 46 | case "share": 47 | className="share"; 48 | break; 49 | case "ask": 50 | className="ask"; 51 | break; 52 | case "job": 53 | className="job"; 54 | break; 55 | default: 56 | className="default"; 57 | break; 58 | } 59 | } 60 | return className; 61 | } -------------------------------------------------------------------------------- /src/libs/qrcode.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | var _aa = {}; 4 | _aa._ab = function(f, e) { 5 | var d = qrcode.width; 6 | var b = qrcode.height; 7 | var c = true; 8 | for (var g = 0; g < e.length && c; g += 2) { 9 | var a = Math.floor(e[g]); 10 | var h = Math.floor(e[g + 1]); 11 | if (a < -1 || a > d || h < -1 || h > b) { 12 | throw "Error._ab " 13 | } 14 | c = false; 15 | if (a == -1) { 16 | e[g] = 0; 17 | c = true 18 | } else { 19 | if (a == d) { 20 | e[g] = d - 1; 21 | c = true 22 | } 23 | } 24 | if (h == -1) { 25 | e[g + 1] = 0; 26 | c = true 27 | } else { 28 | if (h == b) { 29 | e[g + 1] = b - 1; 30 | c = true 31 | } 32 | } 33 | } 34 | c = true; 35 | for (var g = e.length - 2; g >= 0 && c; g -= 2) { 36 | var a = Math.floor(e[g]); 37 | var h = Math.floor(e[g + 1]); 38 | if (a < -1 || a > d || h < -1 || h > b) { 39 | throw "Error._ab " 40 | } 41 | c = false; 42 | if (a == -1) { 43 | e[g] = 0; 44 | c = true 45 | } else { 46 | if (a == d) { 47 | e[g] = d - 1; 48 | c = true 49 | } 50 | } 51 | if (h == -1) { 52 | e[g + 1] = 0; 53 | c = true 54 | } else { 55 | if (h == b) { 56 | e[g + 1] = b - 1; 57 | c = true 58 | } 59 | } 60 | } 61 | }; 62 | _aa._af = function(b, d, a) { 63 | var l = new _ac(d); 64 | var k = new Array(d << 1); 65 | for (var g = 0; g < d; g++) { 66 | var h = k.length; 67 | var j = g + 0.5; 68 | for (var i = 0; i < h; i += 2) { 69 | k[i] = (i >> 1) + 0.5; 70 | k[i + 1] = j 71 | } 72 | a._ad(k); 73 | _aa._ab(b, k); 74 | try { 75 | for (var i = 0; i < h; i += 2) { 76 | var e = (Math.floor(k[i]) * 4) + (Math.floor(k[i + 1]) * qrcode.width * 4); 77 | var f = b[Math.floor(k[i]) + qrcode.width * Math.floor(k[i + 1])]; 78 | qrcode.imagedata.data[e] = f ? 255 : 0; 79 | qrcode.imagedata.data[e + 1] = f ? 255 : 0; 80 | qrcode.imagedata.data[e + 2] = 0; 81 | qrcode.imagedata.data[e + 3] = 255; 82 | if (f) { 83 | l._dq(i >> 1, g) 84 | } 85 | } 86 | } catch (c) { 87 | throw "Error._ab" 88 | } 89 | } 90 | return l 91 | }; 92 | _aa._ah = function(h, o, l, k, r, q, b, a, f, e, n, m, t, s, d, c, j, i) { 93 | var g = _ae._ag(l, k, r, q, b, a, f, e, n, m, t, s, d, c, j, i); 94 | return _aa._af(h, o, g) 95 | }; 96 | 97 | function _a1(b, a) { 98 | this.count = b; 99 | this._fc = a; 100 | this.__defineGetter__("Count", 101 | function() { 102 | return this.count 103 | }); 104 | this.__defineGetter__("_dm", 105 | function() { 106 | return this._fc 107 | }) 108 | } 109 | 110 | function _a2(a, c, b) { 111 | this._bm = a; 112 | if (b) { 113 | this._do = new Array(c, b) 114 | } else { 115 | this._do = new Array(c) 116 | } 117 | this.__defineGetter__("_bo", 118 | function() { 119 | return this._bm 120 | }); 121 | this.__defineGetter__("_dn", 122 | function() { 123 | return this._bm * this._fo 124 | }); 125 | this.__defineGetter__("_fo", 126 | function() { 127 | var e = 0; 128 | for (var d = 0; d < this._do.length; d++) { 129 | e += this._do[d].length 130 | } 131 | return e 132 | }); 133 | this._fb = function() { 134 | return this._do 135 | } 136 | } 137 | 138 | function _a3(k, l, h, g, f, e) { 139 | this._bs = k; 140 | this._ar = l; 141 | this._do = new Array(h, g, f, e); 142 | var j = 0; 143 | var b = h._bo; 144 | var a = h._fb(); 145 | for (var d = 0; d < a.length; d++) { 146 | var c = a[d]; 147 | j += c.Count * (c._dm + b) 148 | } 149 | this._br = j; 150 | this.__defineGetter__("_fd", 151 | function() { 152 | return this._bs 153 | }); 154 | this.__defineGetter__("_as", 155 | function() { 156 | return this._ar 157 | }); 158 | this.__defineGetter__("_dp", 159 | function() { 160 | return this._br 161 | }); 162 | this.__defineGetter__("_cr", 163 | function() { 164 | return 17 + 4 * this._bs 165 | }); 166 | this._aq = function() { 167 | var r = this._cr; 168 | var o = new _ac(r); 169 | o._bq(0, 0, 9, 9); 170 | o._bq(r - 8, 0, 8, 9); 171 | o._bq(0, r - 8, 9, 8); 172 | var n = this._ar.length; 173 | for (var m = 0; m < n; m++) { 174 | var q = this._ar[m] - 2; 175 | for (var s = 0; s < n; s++) { 176 | if ((m == 0 && (s == 0 || s == n - 1)) || (m == n - 1 && s == 0)) { 177 | continue 178 | } 179 | o._bq(this._ar[s] - 2, q, 5, 5) 180 | } 181 | } 182 | o._bq(6, 9, 1, r - 17); 183 | o._bq(9, 6, r - 17, 1); 184 | if (this._bs > 6) { 185 | o._bq(r - 11, 0, 3, 6); 186 | o._bq(0, r - 11, 6, 3) 187 | } 188 | return o 189 | }; 190 | this._bu = function(i) { 191 | return this._do[i.ordinal()] 192 | } 193 | } 194 | _a3._bv = new Array(31892, 34236, 39577, 42195, 48118, 51042, 55367, 58893, 63784, 68472, 70749, 76311, 79154, 84390, 87683, 92361, 96236, 102084, 102881, 110507, 110734, 117786, 119615, 126325, 127568, 133589, 136944, 141498, 145311, 150283, 152622, 158308, 161089, 167017); 195 | _a3.VERSIONS = _ay(); 196 | _a3._av = function(a) { 197 | if (a < 1 || a > 40) { 198 | throw "bad arguments" 199 | } 200 | return _a3.VERSIONS[a - 1] 201 | }; 202 | _a3._at = function(b) { 203 | if (b % 4 != 1) { 204 | throw "Error _at" 205 | } 206 | try { 207 | return _a3._av((b - 17) >> 2) 208 | } catch (a) { 209 | throw "Error _av" 210 | } 211 | }; 212 | _a3._aw = function(d) { 213 | var b = 4294967295; 214 | var f = 0; 215 | for (var c = 0; c < _a3._bv.length; c++) { 216 | var a = _a3._bv[c]; 217 | if (a == d) { 218 | return this._av(c + 7) 219 | } 220 | var e = _ax._gj(d, a); 221 | if (e < b) { 222 | f = c + 7; 223 | b = e 224 | } 225 | } 226 | if (b <= 3) { 227 | return this._av(f) 228 | } 229 | return null 230 | }; 231 | 232 | function _ay() { 233 | return new Array(new _a3(1, new Array(), new _a2(7, new _a1(1, 19)), new _a2(10, new _a1(1, 16)), new _a2(13, new _a1(1, 13)), new _a2(17, new _a1(1, 9))), new _a3(2, new Array(6, 18), new _a2(10, new _a1(1, 34)), new _a2(16, new _a1(1, 28)), new _a2(22, new _a1(1, 22)), new _a2(28, new _a1(1, 16))), new _a3(3, new Array(6, 22), new _a2(15, new _a1(1, 55)), new _a2(26, new _a1(1, 44)), new _a2(18, new _a1(2, 17)), new _a2(22, new _a1(2, 13))), new _a3(4, new Array(6, 26), new _a2(20, new _a1(1, 80)), new _a2(18, new _a1(2, 32)), new _a2(26, new _a1(2, 24)), new _a2(16, new _a1(4, 9))), new _a3(5, new Array(6, 30), new _a2(26, new _a1(1, 108)), new _a2(24, new _a1(2, 43)), new _a2(18, new _a1(2, 15), new _a1(2, 16)), new _a2(22, new _a1(2, 11), new _a1(2, 12))), new _a3(6, new Array(6, 34), new _a2(18, new _a1(2, 68)), new _a2(16, new _a1(4, 27)), new _a2(24, new _a1(4, 19)), new _a2(28, new _a1(4, 15))), new _a3(7, new Array(6, 22, 38), new _a2(20, new _a1(2, 78)), new _a2(18, new _a1(4, 31)), new _a2(18, new _a1(2, 14), new _a1(4, 15)), new _a2(26, new _a1(4, 13), new _a1(1, 14))), new _a3(8, new Array(6, 24, 42), new _a2(24, new _a1(2, 97)), new _a2(22, new _a1(2, 38), new _a1(2, 39)), new _a2(22, new _a1(4, 18), new _a1(2, 19)), new _a2(26, new _a1(4, 14), new _a1(2, 15))), new _a3(9, new Array(6, 26, 46), new _a2(30, new _a1(2, 116)), new _a2(22, new _a1(3, 36), new _a1(2, 37)), new _a2(20, new _a1(4, 16), new _a1(4, 17)), new _a2(24, new _a1(4, 12), new _a1(4, 13))), new _a3(10, new Array(6, 28, 50), new _a2(18, new _a1(2, 68), new _a1(2, 69)), new _a2(26, new _a1(4, 43), new _a1(1, 44)), new _a2(24, new _a1(6, 19), new _a1(2, 20)), new _a2(28, new _a1(6, 15), new _a1(2, 16))), new _a3(11, new Array(6, 30, 54), new _a2(20, new _a1(4, 81)), new _a2(30, new _a1(1, 50), new _a1(4, 51)), new _a2(28, new _a1(4, 22), new _a1(4, 23)), new _a2(24, new _a1(3, 12), new _a1(8, 13))), new _a3(12, new Array(6, 32, 58), new _a2(24, new _a1(2, 92), new _a1(2, 93)), new _a2(22, new _a1(6, 36), new _a1(2, 37)), new _a2(26, new _a1(4, 20), new _a1(6, 21)), new _a2(28, new _a1(7, 14), new _a1(4, 15))), new _a3(13, new Array(6, 34, 62), new _a2(26, new _a1(4, 107)), new _a2(22, new _a1(8, 37), new _a1(1, 38)), new _a2(24, new _a1(8, 20), new _a1(4, 21)), new _a2(22, new _a1(12, 11), new _a1(4, 12))), new _a3(14, new Array(6, 26, 46, 66), new _a2(30, new _a1(3, 115), new _a1(1, 116)), new _a2(24, new _a1(4, 40), new _a1(5, 41)), new _a2(20, new _a1(11, 16), new _a1(5, 17)), new _a2(24, new _a1(11, 12), new _a1(5, 13))), new _a3(15, new Array(6, 26, 48, 70), new _a2(22, new _a1(5, 87), new _a1(1, 88)), new _a2(24, new _a1(5, 41), new _a1(5, 42)), new _a2(30, new _a1(5, 24), new _a1(7, 25)), new _a2(24, new _a1(11, 12), new _a1(7, 13))), new _a3(16, new Array(6, 26, 50, 74), new _a2(24, new _a1(5, 98), new _a1(1, 99)), new _a2(28, new _a1(7, 45), new _a1(3, 46)), new _a2(24, new _a1(15, 19), new _a1(2, 20)), new _a2(30, new _a1(3, 15), new _a1(13, 16))), new _a3(17, new Array(6, 30, 54, 78), new _a2(28, new _a1(1, 107), new _a1(5, 108)), new _a2(28, new _a1(10, 46), new _a1(1, 47)), new _a2(28, new _a1(1, 22), new _a1(15, 23)), new _a2(28, new _a1(2, 14), new _a1(17, 15))), new _a3(18, new Array(6, 30, 56, 82), new _a2(30, new _a1(5, 120), new _a1(1, 121)), new _a2(26, new _a1(9, 43), new _a1(4, 44)), new _a2(28, new _a1(17, 22), new _a1(1, 23)), new _a2(28, new _a1(2, 14), new _a1(19, 15))), new _a3(19, new Array(6, 30, 58, 86), new _a2(28, new _a1(3, 113), new _a1(4, 114)), new _a2(26, new _a1(3, 44), new _a1(11, 45)), new _a2(26, new _a1(17, 21), new _a1(4, 22)), new _a2(26, new _a1(9, 13), new _a1(16, 14))), new _a3(20, new Array(6, 34, 62, 90), new _a2(28, new _a1(3, 107), new _a1(5, 108)), new _a2(26, new _a1(3, 41), new _a1(13, 42)), new _a2(30, new _a1(15, 24), new _a1(5, 25)), new _a2(28, new _a1(15, 15), new _a1(10, 16))), new _a3(21, new Array(6, 28, 50, 72, 94), new _a2(28, new _a1(4, 116), new _a1(4, 117)), new _a2(26, new _a1(17, 42)), new _a2(28, new _a1(17, 22), new _a1(6, 23)), new _a2(30, new _a1(19, 16), new _a1(6, 17))), new _a3(22, new Array(6, 26, 50, 74, 98), new _a2(28, new _a1(2, 111), new _a1(7, 112)), new _a2(28, new _a1(17, 46)), new _a2(30, new _a1(7, 24), new _a1(16, 25)), new _a2(24, new _a1(34, 13))), new _a3(23, new Array(6, 30, 54, 74, 102), new _a2(30, new _a1(4, 121), new _a1(5, 122)), new _a2(28, new _a1(4, 47), new _a1(14, 48)), new _a2(30, new _a1(11, 24), new _a1(14, 25)), new _a2(30, new _a1(16, 15), new _a1(14, 16))), new _a3(24, new Array(6, 28, 54, 80, 106), new _a2(30, new _a1(6, 117), new _a1(4, 118)), new _a2(28, new _a1(6, 45), new _a1(14, 46)), new _a2(30, new _a1(11, 24), new _a1(16, 25)), new _a2(30, new _a1(30, 16), new _a1(2, 17))), new _a3(25, new Array(6, 32, 58, 84, 110), new _a2(26, new _a1(8, 106), new _a1(4, 107)), new _a2(28, new _a1(8, 47), new _a1(13, 48)), new _a2(30, new _a1(7, 24), new _a1(22, 25)), new _a2(30, new _a1(22, 15), new _a1(13, 16))), new _a3(26, new Array(6, 30, 58, 86, 114), new _a2(28, new _a1(10, 114), new _a1(2, 115)), new _a2(28, new _a1(19, 46), new _a1(4, 47)), new _a2(28, new _a1(28, 22), new _a1(6, 23)), new _a2(30, new _a1(33, 16), new _a1(4, 17))), new _a3(27, new Array(6, 34, 62, 90, 118), new _a2(30, new _a1(8, 122), new _a1(4, 123)), new _a2(28, new _a1(22, 45), new _a1(3, 46)), new _a2(30, new _a1(8, 23), new _a1(26, 24)), new _a2(30, new _a1(12, 15), new _a1(28, 16))), new _a3(28, new Array(6, 26, 50, 74, 98, 122), new _a2(30, new _a1(3, 117), new _a1(10, 118)), new _a2(28, new _a1(3, 45), new _a1(23, 46)), new _a2(30, new _a1(4, 24), new _a1(31, 25)), new _a2(30, new _a1(11, 15), new _a1(31, 16))), new _a3(29, new Array(6, 30, 54, 78, 102, 126), new _a2(30, new _a1(7, 116), new _a1(7, 117)), new _a2(28, new _a1(21, 45), new _a1(7, 46)), new _a2(30, new _a1(1, 23), new _a1(37, 24)), new _a2(30, new _a1(19, 15), new _a1(26, 16))), new _a3(30, new Array(6, 26, 52, 78, 104, 130), new _a2(30, new _a1(5, 115), new _a1(10, 116)), new _a2(28, new _a1(19, 47), new _a1(10, 48)), new _a2(30, new _a1(15, 24), new _a1(25, 25)), new _a2(30, new _a1(23, 15), new _a1(25, 16))), new _a3(31, new Array(6, 30, 56, 82, 108, 134), new _a2(30, new _a1(13, 115), new _a1(3, 116)), new _a2(28, new _a1(2, 46), new _a1(29, 47)), new _a2(30, new _a1(42, 24), new _a1(1, 25)), new _a2(30, new _a1(23, 15), new _a1(28, 16))), new _a3(32, new Array(6, 34, 60, 86, 112, 138), new _a2(30, new _a1(17, 115)), new _a2(28, new _a1(10, 46), new _a1(23, 47)), new _a2(30, new _a1(10, 24), new _a1(35, 25)), new _a2(30, new _a1(19, 15), new _a1(35, 16))), new _a3(33, new Array(6, 30, 58, 86, 114, 142), new _a2(30, new _a1(17, 115), new _a1(1, 116)), new _a2(28, new _a1(14, 46), new _a1(21, 47)), new _a2(30, new _a1(29, 24), new _a1(19, 25)), new _a2(30, new _a1(11, 15), new _a1(46, 16))), new _a3(34, new Array(6, 34, 62, 90, 118, 146), new _a2(30, new _a1(13, 115), new _a1(6, 116)), new _a2(28, new _a1(14, 46), new _a1(23, 47)), new _a2(30, new _a1(44, 24), new _a1(7, 25)), new _a2(30, new _a1(59, 16), new _a1(1, 17))), new _a3(35, new Array(6, 30, 54, 78, 102, 126, 150), new _a2(30, new _a1(12, 121), new _a1(7, 122)), new _a2(28, new _a1(12, 47), new _a1(26, 48)), new _a2(30, new _a1(39, 24), new _a1(14, 25)), new _a2(30, new _a1(22, 15), new _a1(41, 16))), new _a3(36, new Array(6, 24, 50, 76, 102, 128, 154), new _a2(30, new _a1(6, 121), new _a1(14, 122)), new _a2(28, new _a1(6, 47), new _a1(34, 48)), new _a2(30, new _a1(46, 24), new _a1(10, 25)), new _a2(30, new _a1(2, 15), new _a1(64, 16))), new _a3(37, new Array(6, 28, 54, 80, 106, 132, 158), new _a2(30, new _a1(17, 122), new _a1(4, 123)), new _a2(28, new _a1(29, 46), new _a1(14, 47)), new _a2(30, new _a1(49, 24), new _a1(10, 25)), new _a2(30, new _a1(24, 15), new _a1(46, 16))), new _a3(38, new Array(6, 32, 58, 84, 110, 136, 162), new _a2(30, new _a1(4, 122), new _a1(18, 123)), new _a2(28, new _a1(13, 46), new _a1(32, 47)), new _a2(30, new _a1(48, 24), new _a1(14, 25)), new _a2(30, new _a1(42, 15), new _a1(32, 16))), new _a3(39, new Array(6, 26, 54, 82, 110, 138, 166), new _a2(30, new _a1(20, 117), new _a1(4, 118)), new _a2(28, new _a1(40, 47), new _a1(7, 48)), new _a2(30, new _a1(43, 24), new _a1(22, 25)), new _a2(30, new _a1(10, 15), new _a1(67, 16))), new _a3(40, new Array(6, 30, 58, 86, 114, 142, 170), new _a2(30, new _a1(19, 118), new _a1(6, 119)), new _a2(28, new _a1(18, 47), new _a1(31, 48)), new _a2(30, new _a1(34, 24), new _a1(34, 25)), new _a2(30, new _a1(20, 15), new _a1(61, 16)))) 234 | } 235 | 236 | function _ae(i, f, c, h, e, b, g, d, a) { 237 | this.a11 = i; 238 | this.a12 = h; 239 | this.a13 = g; 240 | this.a21 = f; 241 | this.a22 = e; 242 | this.a23 = d; 243 | this.a31 = c; 244 | this.a32 = b; 245 | this.a33 = a; 246 | this._ad = function(w) { 247 | var t = w.length; 248 | var A = this.a11; 249 | var z = this.a12; 250 | var v = this.a13; 251 | var r = this.a21; 252 | var q = this.a22; 253 | var o = this.a23; 254 | var m = this.a31; 255 | var k = this.a32; 256 | var j = this.a33; 257 | for (var n = 0; n < t; n += 2) { 258 | var u = w[n]; 259 | var s = w[n + 1]; 260 | var l = v * u + o * s + j; 261 | w[n] = (A * u + r * s + m) / l; 262 | w[n + 1] = (z * u + q * s + k) / l 263 | } 264 | }; 265 | this._fp = function(m, k) { 266 | var r = m.length; 267 | for (var l = 0; l < r; l++) { 268 | var j = m[l]; 269 | var q = k[l]; 270 | var o = this.a13 * j + this.a23 * q + this.a33; 271 | m[l] = (this.a11 * j + this.a21 * q + this.a31) / o; 272 | k[l] = (this.a12 * j + this.a22 * q + this.a32) / o 273 | } 274 | }; 275 | this._fr = function() { 276 | return new _ae(this.a22 * this.a33 - this.a23 * this.a32, this.a23 * this.a31 - this.a21 * this.a33, this.a21 * this.a32 - this.a22 * this.a31, this.a13 * this.a32 - this.a12 * this.a33, this.a11 * this.a33 - this.a13 * this.a31, this.a12 * this.a31 - this.a11 * this.a32, this.a12 * this.a23 - this.a13 * this.a22, this.a13 * this.a21 - this.a11 * this.a23, this.a11 * this.a22 - this.a12 * this.a21) 277 | }; 278 | this.times = function(j) { 279 | return new _ae(this.a11 * j.a11 + this.a21 * j.a12 + this.a31 * j.a13, this.a11 * j.a21 + this.a21 * j.a22 + this.a31 * j.a23, this.a11 * j.a31 + this.a21 * j.a32 + this.a31 * j.a33, this.a12 * j.a11 + this.a22 * j.a12 + this.a32 * j.a13, this.a12 * j.a21 + this.a22 * j.a22 + this.a32 * j.a23, this.a12 * j.a31 + this.a22 * j.a32 + this.a32 * j.a33, this.a13 * j.a11 + this.a23 * j.a12 + this.a33 * j.a13, this.a13 * j.a21 + this.a23 * j.a22 + this.a33 * j.a23, this.a13 * j.a31 + this.a23 * j.a32 + this.a33 * j.a33) 280 | } 281 | } 282 | _ae._ag = function(q, e, o, d, n, c, m, b, h, r, l, f, a, j, i, s) { 283 | var g = this._be(q, e, o, d, n, c, m, b); 284 | var k = this._bf(h, r, l, f, a, j, i, s); 285 | return k.times(g) 286 | }; 287 | _ae._bf = function(f, h, d, g, b, e, a, c) { 288 | var dy2 = c - e; 289 | var dy3 = h - g + e - c; 290 | if (dy2 == 0 && dy3 == 0) { 291 | return new _ae(d - f, b - d, f, g - h, e - g, h, 0, 0, 1) 292 | } else { 293 | var dx1 = d - b; 294 | var dx2 = a - b; 295 | var dx3 = f - d + b - a; 296 | var dy1 = g - e; 297 | var _dr = dx1 * dy2 - dx2 * dy1; 298 | var a13 = (dx3 * dy2 - dx2 * dy3) / _dr; 299 | var a23 = (dx1 * dy3 - dx3 * dy1) / _dr; 300 | return new _ae(d - f + a13 * d, a - f + a23 * a, f, g - h + a13 * g, c - h + a23 * c, h, a13, a23, 1) 301 | } 302 | }; 303 | _ae._be = function(f, h, d, g, b, e, a, c) { 304 | return this._bf(f, h, d, g, b, e, a, c)._fr() 305 | }; 306 | 307 | function _bg(b, a) { 308 | this.bits = b; 309 | this.points = a 310 | } 311 | var xDiff = 0; 312 | var yDiff = 0; 313 | function Detector(a) { 314 | this.image = a; 315 | this._am = null; 316 | this._bi = function(m, l, c, b) { 317 | var d = Math.abs(b - l) > Math.abs(c - m); 318 | if (d) { 319 | var s = m; 320 | m = l; 321 | l = s; 322 | s = c; 323 | c = b; 324 | b = s 325 | } 326 | var j = Math.abs(c - m); 327 | var i = Math.abs(b - l); 328 | var q = -j >> 1; 329 | var v = l < b ? 1 : -1; 330 | var f = m < c ? 1 : -1; 331 | var e = 0; 332 | for (var h = m, 333 | g = l; h != c; h += f) { 334 | var u = d ? g : h; 335 | var t = d ? h : g; 336 | if (e == 1) { 337 | if (this.image[u + t * qrcode.width]) { 338 | e++ 339 | } 340 | } else { 341 | if (!this.image[u + t * qrcode.width]) { 342 | e++ 343 | } 344 | } 345 | if (e == 3) { 346 | var o = h - m; 347 | var n = g - l; 348 | return Math.sqrt((o * o + n * n)) 349 | } 350 | q += i; 351 | if (q > 0) { 352 | if (g == b) { 353 | break 354 | } 355 | g += v; 356 | q -= j 357 | } 358 | } 359 | var k = c - m; 360 | var r = b - l; 361 | return Math.sqrt((k * k + r * r)) 362 | }; 363 | this._bh = function(i, g, h, f) { 364 | var b = this._bi(i, g, h, f); 365 | var e = 1; 366 | var d = i - (h - i); 367 | if (d < 0) { 368 | e = i / (i - d); 369 | d = 0 370 | } else { 371 | if (d >= qrcode.width) { 372 | e = (qrcode.width - 1 - i) / (d - i); 373 | d = qrcode.width - 1 374 | } 375 | } 376 | var c = Math.floor(g - (f - g) * e); 377 | e = 1; 378 | if (c < 0) { 379 | e = g / (g - c); 380 | c = 0 381 | } else { 382 | if (c >= qrcode.height) { 383 | e = (qrcode.height - 1 - g) / (c - g); 384 | c = qrcode.height - 1 385 | } 386 | } 387 | d = Math.floor(i + (d - i) * e); 388 | b += this._bi(i, g, d, c); 389 | return b - 1 390 | }; 391 | this._bj = function(c, d) { 392 | var b = this._bh(Math.floor(c.X), Math.floor(c.Y), Math.floor(d.X), Math.floor(d.Y)); 393 | var e = this._bh(Math.floor(d.X), Math.floor(d.Y), Math.floor(c.X), Math.floor(c.Y)); 394 | if (isNaN(b)) { 395 | return e / 7 396 | } 397 | if (isNaN(e)) { 398 | return b / 7 399 | } 400 | return (b + e) / 14 401 | }; 402 | this._bk = function(d, c, b) { 403 | return (this._bj(d, c) + this._bj(d, b)) / 2 404 | }; 405 | this.distance = function(c, b) { 406 | xDiff = c.X - b.X; 407 | yDiff = c.Y - b.Y; 408 | return Math.sqrt((xDiff * xDiff + yDiff * yDiff)) 409 | }; 410 | this._bx = function(g, f, d, e) { 411 | var b = Math.round(this.distance(g, f) / e); 412 | var c = Math.round(this.distance(g, d) / e); 413 | var h = ((b + c) >> 1) + 7; 414 | switch (h & 3) { 415 | case 0: 416 | h++; 417 | break; 418 | case 2: 419 | h--; 420 | break; 421 | case 3: 422 | throw "Error" 423 | } 424 | return h 425 | }; 426 | this._bl = function(g, f, d, j) { 427 | var k = Math.floor(j * g); 428 | var h = Math.max(0, f - k); 429 | var i = Math.min(qrcode.width - 1, f + k); 430 | if (i - h < g * 3) { 431 | throw "Error" 432 | } 433 | var b = Math.max(0, d - k); 434 | var c = Math.min(qrcode.height - 1, d + k); 435 | var e = new _ak(this.image, h, b, i - h, c - b, g, this._am); 436 | return e.find() 437 | }; 438 | this.createTransform = function(l, h, k, b, g) { 439 | var j = g - 3.5; 440 | var i; 441 | var f; 442 | var e; 443 | var c; 444 | if (b != null) { 445 | i = b.X; 446 | f = b.Y; 447 | e = c = j - 3 448 | } else { 449 | i = (h.X - l.X) + k.X; 450 | f = (h.Y - l.Y) + k.Y; 451 | e = c = j 452 | } 453 | var d = _ae._ag(3.5, 3.5, j, 3.5, e, c, 3.5, j, l.X, l.Y, h.X, h.Y, i, f, k.X, k.Y); 454 | return d 455 | }; 456 | this._bz = function(e, b, d) { 457 | var c = _aa; 458 | return c._af(e, d, b) 459 | }; 460 | this._cd = function(r) { 461 | var j = r._gq; 462 | var h = r._gs; 463 | var n = r._gp; 464 | var d = this._bk(j, h, n); 465 | if (d < 1) { 466 | throw "Error" 467 | } 468 | var s = this._bx(j, h, n, d); 469 | var b = _a3._at(s); 470 | var k = b._cr - 7; 471 | var l = null; 472 | if (b._as.length > 0) { 473 | var f = h.X - j.X + n.X; 474 | var e = h.Y - j.Y + n.Y; 475 | var c = 1 - 3 / k; 476 | var u = Math.floor(j.X + c * (f - j.X)); 477 | var t = Math.floor(j.Y + c * (e - j.Y)); 478 | for (var q = 4; q <= 16; q <<= 1) { 479 | l = this._bl(d, u, t, q); 480 | break 481 | } 482 | } 483 | var g = this.createTransform(j, h, n, l, s); 484 | var m = this._bz(this.image, g, s); 485 | var o; 486 | if (l == null) { 487 | o = new Array(n, j, h) 488 | } else { 489 | o = new Array(n, j, h, l) 490 | } 491 | return new _bg(m, o) 492 | }; 493 | this.detect = function() { 494 | var b = new _cc()._ce(this.image); 495 | return this._cd(b) 496 | } 497 | } 498 | var _ca = 21522; 499 | var _cb = new Array(new Array(21522, 0), new Array(20773, 1), new Array(24188, 2), new Array(23371, 3), new Array(17913, 4), new Array(16590, 5), new Array(20375, 6), new Array(19104, 7), new Array(30660, 8), new Array(29427, 9), new Array(32170, 10), new Array(30877, 11), new Array(26159, 12), new Array(25368, 13), new Array(27713, 14), new Array(26998, 15), new Array(5769, 16), new Array(5054, 17), new Array(7399, 18), new Array(6608, 19), new Array(1890, 20), new Array(597, 21), new Array(3340, 22), new Array(2107, 23), new Array(13663, 24), new Array(12392, 25), new Array(16177, 26), new Array(14854, 27), new Array(9396, 28), new Array(8579, 29), new Array(11994, 30), new Array(11245, 31)); 500 | var _ch = new Array(0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4); 501 | 502 | function _ax(a) { 503 | this._cf = _cg.forBits((a >> 3) & 3); 504 | this._fe = (a & 7); 505 | this.__defineGetter__("_cg", 506 | function() { 507 | return this._cf 508 | }); 509 | this.__defineGetter__("_dx", 510 | function() { 511 | return this._fe 512 | }); 513 | this.GetHashCode = function() { 514 | return (this._cf.ordinal() << 3) | _fe 515 | }; 516 | this.Equals = function(c) { 517 | var b = c; 518 | return this._cf == b._cf && this._fe == b._fe 519 | } 520 | } 521 | _ax._gj = function(d, c) { 522 | d ^= c; 523 | return _ch[d & 15] + _ch[(_ew(d, 4) & 15)] + _ch[(_ew(d, 8) & 15)] + _ch[(_ew(d, 12) & 15)] + _ch[(_ew(d, 16) & 15)] + _ch[(_ew(d, 20) & 15)] + _ch[(_ew(d, 24) & 15)] + _ch[(_ew(d, 28) & 15)] 524 | }; 525 | _ax._ci = function(a) { 526 | var b = _ax._cj(a); 527 | if (b != null) { 528 | return b 529 | } 530 | return _ax._cj(a ^ _ca) 531 | }; 532 | _ax._cj = function(d) { 533 | var b = 4294967295; 534 | var a = 0; 535 | for (var c = 0; c < _cb.length; c++) { 536 | var g = _cb[c]; 537 | var f = g[0]; 538 | if (f == d) { 539 | return new _ax(g[1]) 540 | } 541 | var e = this._gj(d, f); 542 | if (e < b) { 543 | a = g[1]; 544 | b = e 545 | } 546 | } 547 | if (b <= 3) { 548 | return new _ax(a) 549 | } 550 | return null 551 | }; 552 | 553 | function _cg(a, c, b) { 554 | this._ff = a; 555 | this.bits = c; 556 | this.name = b; 557 | this.__defineGetter__("Bits", 558 | function() { 559 | return this.bits 560 | }); 561 | this.__defineGetter__("Name", 562 | function() { 563 | return this.name 564 | }); 565 | this.ordinal = function() { 566 | return this._ff 567 | } 568 | } 569 | _cg.forBits = function(a) { 570 | if (a < 0 || a >= FOR_BITS.length) { 571 | throw "bad arguments" 572 | } 573 | return FOR_BITS[a] 574 | }; 575 | var L = new _cg(0, 1, "L"); 576 | var M = new _cg(1, 0, "M"); 577 | var Q = new _cg(2, 3, "Q"); 578 | var H = new _cg(3, 2, "H"); 579 | var FOR_BITS = new Array(M, L, H, Q); 580 | 581 | function _ac(d, a) { 582 | if (!a) { 583 | a = d 584 | } 585 | if (d < 1 || a < 1) { 586 | throw "Both dimensions must be greater than 0" 587 | } 588 | this.width = d; 589 | this.height = a; 590 | var c = d >> 5; 591 | if ((d & 31) != 0) { 592 | c++ 593 | } 594 | this.rowSize = c; 595 | this.bits = new Array(c * a); 596 | for (var b = 0; b < this.bits.length; b++) { 597 | this.bits[b] = 0 598 | } 599 | this.__defineGetter__("Width", 600 | function() { 601 | return this.width 602 | }); 603 | this.__defineGetter__("Height", 604 | function() { 605 | return this.height 606 | }); 607 | this.__defineGetter__("Dimension", 608 | function() { 609 | if (this.width != this.height) { 610 | throw "Can't call getDimension() on a non-square matrix" 611 | } 612 | return this.width 613 | }); 614 | this._ds = function(e, g) { 615 | var f = g * this.rowSize + (e >> 5); 616 | return ((_ew(this.bits[f], (e & 31))) & 1) != 0 617 | }; 618 | this._dq = function(e, g) { 619 | var f = g * this.rowSize + (e >> 5); 620 | this.bits[f] |= 1 << (e & 31) 621 | }; 622 | this.flip = function(e, g) { 623 | var f = g * this.rowSize + (e >> 5); 624 | this.bits[f] ^= 1 << (e & 31) 625 | }; 626 | this.clear = function() { 627 | var e = this.bits.length; 628 | for (var f = 0; f < e; f++) { 629 | this.bits[f] = 0 630 | } 631 | }; 632 | this._bq = function(g, j, f, m) { 633 | if (j < 0 || g < 0) { 634 | throw "Left and top must be nonnegative" 635 | } 636 | if (m < 1 || f < 1) { 637 | throw "Height and width must be at least 1" 638 | } 639 | var l = g + f; 640 | var e = j + m; 641 | if (e > this.height || l > this.width) { 642 | throw "The region must fit inside the matrix" 643 | } 644 | for (var i = j; i < e; i++) { 645 | var h = i * this.rowSize; 646 | for (var k = g; k < l; k++) { 647 | this.bits[h + (k >> 5)] |= 1 << (k & 31) 648 | } 649 | } 650 | } 651 | } 652 | 653 | function _dl(a, b) { 654 | this._dv = a; 655 | this._dw = b; 656 | this.__defineGetter__("_du", 657 | function() { 658 | return this._dv 659 | }); 660 | this.__defineGetter__("Codewords", 661 | function() { 662 | return this._dw 663 | }) 664 | } 665 | _dl._gn = function(c, h, s) { 666 | if (c.length != h._dp) { 667 | throw "bad arguments" 668 | } 669 | var k = h._bu(s); 670 | var e = 0; 671 | var d = k._fb(); 672 | for (var r = 0; r < d.length; r++) { 673 | e += d[r].Count 674 | } 675 | var l = new Array(e); 676 | var n = 0; 677 | for (var o = 0; o < d.length; o++) { 678 | var f = d[o]; 679 | for (var r = 0; r < f.Count; r++) { 680 | var m = f._dm; 681 | var t = k._bo + m; 682 | l[n++] = new _dl(m, new Array(t)) 683 | } 684 | } 685 | var u = l[0]._dw.length; 686 | var b = l.length - 1; 687 | while (b >= 0) { 688 | var w = l[b]._dw.length; 689 | if (w == u) { 690 | break 691 | } 692 | b-- 693 | } 694 | b++; 695 | var g = u - k._bo; 696 | var a = 0; 697 | for (var r = 0; r < g; r++) { 698 | for (var o = 0; o < n; o++) { 699 | l[o]._dw[r] = c[a++] 700 | } 701 | } 702 | for (var o = b; o < n; o++) { 703 | l[o]._dw[g] = c[a++] 704 | } 705 | var q = l[0]._dw.length; 706 | for (var r = g; r < q; r++) { 707 | for (var o = 0; o < n; o++) { 708 | var v = o < b ? r : r + 1; 709 | l[o]._dw[v] = c[a++] 710 | } 711 | } 712 | return l 713 | }; 714 | 715 | function _cl(a) { 716 | var b = a.Dimension; 717 | if (b < 21 || (b & 3) != 1) { 718 | throw "Error _cl" 719 | } 720 | this._au = a; 721 | this._cp = null; 722 | this._co = null; 723 | this._dk = function(d, c, e) { 724 | return this._au._ds(d, c) ? (e << 1) | 1 : e << 1 725 | }; 726 | this._cm = function() { 727 | if (this._co != null) { 728 | return this._co 729 | } 730 | var g = 0; 731 | for (var e = 0; e < 6; e++) { 732 | g = this._dk(e, 8, g) 733 | } 734 | g = this._dk(7, 8, g); 735 | g = this._dk(8, 8, g); 736 | g = this._dk(8, 7, g); 737 | for (var c = 5; c >= 0; c--) { 738 | g = this._dk(8, c, g) 739 | } 740 | this._co = _ax._ci(g); 741 | if (this._co != null) { 742 | return this._co 743 | } 744 | var f = this._au.Dimension; 745 | g = 0; 746 | var d = f - 8; 747 | for (var e = f - 1; e >= d; e--) { 748 | g = this._dk(e, 8, g) 749 | } 750 | for (var c = f - 7; c < f; c++) { 751 | g = this._dk(8, c, g) 752 | } 753 | this._co = _ax._ci(g); 754 | if (this._co != null) { 755 | return this._co 756 | } 757 | throw "Error _cm" 758 | }; 759 | this._cq = function() { 760 | if (this._cp != null) { 761 | return this._cp 762 | } 763 | var h = this._au.Dimension; 764 | var f = (h - 17) >> 2; 765 | if (f <= 6) { 766 | return _a3._av(f) 767 | } 768 | var g = 0; 769 | var e = h - 11; 770 | for (var c = 5; c >= 0; c--) { 771 | for (var d = h - 9; d >= e; d--) { 772 | g = this._dk(d, c, g) 773 | } 774 | } 775 | this._cp = _a3._aw(g); 776 | if (this._cp != null && this._cp._cr == h) { 777 | return this._cp 778 | } 779 | g = 0; 780 | for (var d = 5; d >= 0; d--) { 781 | for (var c = h - 9; c >= e; c--) { 782 | g = this._dk(d, c, g) 783 | } 784 | } 785 | this._cp = _a3._aw(g); 786 | if (this._cp != null && this._cp._cr == h) { 787 | return this._cp 788 | } 789 | throw "Error _cq" 790 | }; 791 | this._gk = function() { 792 | var r = this._cm(); 793 | var o = this._cq(); 794 | var c = _dx._gl(r._dx); 795 | var f = this._au.Dimension; 796 | c._dj(this._au, f); 797 | var k = o._aq(); 798 | var n = true; 799 | var s = new Array(o._dp); 800 | var m = 0; 801 | var q = 0; 802 | var h = 0; 803 | for (var e = f - 1; e > 0; e -= 2) { 804 | if (e == 6) { 805 | e-- 806 | } 807 | for (var l = 0; l < f; l++) { 808 | var g = n ? f - 1 - l : l; 809 | for (var d = 0; d < 2; d++) { 810 | if (!k._ds(e - d, g)) { 811 | h++; 812 | q <<= 1; 813 | if (this._au._ds(e - d, g)) { 814 | q |= 1 815 | } 816 | if (h == 8) { 817 | s[m++] = q; 818 | h = 0; 819 | q = 0 820 | } 821 | } 822 | } 823 | } 824 | n ^= true 825 | } 826 | if (m != o._dp) { 827 | throw "Error _gk" 828 | } 829 | return s 830 | } 831 | } 832 | var _dx = {}; 833 | _dx._gl = function(a) { 834 | if (a < 0 || a > 7) { 835 | throw "bad arguments" 836 | } 837 | return _dx._dy[a] 838 | }; 839 | 840 | function _fg() { 841 | this._dj = function(c, d) { 842 | for (var b = 0; b < d; b++) { 843 | for (var a = 0; a < d; a++) { 844 | if (this._fw(b, a)) { 845 | c.flip(a, b) 846 | } 847 | } 848 | } 849 | }; 850 | this._fw = function(b, a) { 851 | return ((b + a) & 1) == 0 852 | } 853 | } 854 | 855 | function _fh() { 856 | this._dj = function(c, d) { 857 | for (var b = 0; b < d; b++) { 858 | for (var a = 0; a < d; a++) { 859 | if (this._fw(b, a)) { 860 | c.flip(a, b) 861 | } 862 | } 863 | } 864 | }; 865 | this._fw = function(b, a) { 866 | return (b & 1) == 0 867 | } 868 | } 869 | 870 | function _fi() { 871 | this._dj = function(c, d) { 872 | for (var b = 0; b < d; b++) { 873 | for (var a = 0; a < d; a++) { 874 | if (this._fw(b, a)) { 875 | c.flip(a, b) 876 | } 877 | } 878 | } 879 | }; 880 | this._fw = function(b, a) { 881 | return a % 3 == 0 882 | } 883 | } 884 | 885 | function _fj() { 886 | this._dj = function(c, d) { 887 | for (var b = 0; b < d; b++) { 888 | for (var a = 0; a < d; a++) { 889 | if (this._fw(b, a)) { 890 | c.flip(a, b) 891 | } 892 | } 893 | } 894 | }; 895 | this._fw = function(b, a) { 896 | return (b + a) % 3 == 0 897 | } 898 | } 899 | 900 | function _fk() { 901 | this._dj = function(c, d) { 902 | for (var b = 0; b < d; b++) { 903 | for (var a = 0; a < d; a++) { 904 | if (this._fw(b, a)) { 905 | c.flip(a, b) 906 | } 907 | } 908 | } 909 | }; 910 | this._fw = function(b, a) { 911 | return (((_ew(b, 1)) + (a / 3)) & 1) == 0 912 | } 913 | } 914 | 915 | function _fl() { 916 | this._dj = function(c, d) { 917 | for (var b = 0; b < d; b++) { 918 | for (var a = 0; a < d; a++) { 919 | if (this._fw(b, a)) { 920 | c.flip(a, b) 921 | } 922 | } 923 | } 924 | }; 925 | this._fw = function(c, b) { 926 | var a = c * b; 927 | return (a & 1) + (a % 3) == 0 928 | } 929 | } 930 | 931 | function _fm() { 932 | this._dj = function(c, d) { 933 | for (var b = 0; b < d; b++) { 934 | for (var a = 0; a < d; a++) { 935 | if (this._fw(b, a)) { 936 | c.flip(a, b) 937 | } 938 | } 939 | } 940 | }; 941 | this._fw = function(c, b) { 942 | var a = c * b; 943 | return (((a & 1) + (a % 3)) & 1) == 0 944 | } 945 | } 946 | 947 | function _fn() { 948 | this._dj = function(c, d) { 949 | for (var b = 0; b < d; b++) { 950 | for (var a = 0; a < d; a++) { 951 | if (this._fw(b, a)) { 952 | c.flip(a, b) 953 | } 954 | } 955 | } 956 | }; 957 | this._fw = function(b, a) { 958 | return ((((b + a) & 1) + ((b * a) % 3)) & 1) == 0 959 | } 960 | } 961 | _dx._dy = new Array(new _fg(), new _fh(), new _fi(), new _fj(), new _fk(), new _fl(), new _fm(), new _fn()); 962 | 963 | function _db(_fa) { 964 | this._fa = _fa; 965 | this.decode = function(received, _fv) { 966 | var poly = new _bp(this._fa, received); 967 | var _dh = new Array(_fv); 968 | for (var i = 0; i < _dh.length; i++) { 969 | _dh[i] = 0 970 | } 971 | var _fq = false; 972 | var noError = true; 973 | for (var i = 0; i < _fv; i++) { 974 | var evs = poly.evaluateAt(this._fa.exp(_fq ? i + 1 : i)); 975 | _dh[_dh.length - 1 - i] = evs; 976 | if (evs != 0) { 977 | noError = false 978 | } 979 | } 980 | if (noError) { 981 | return 982 | } 983 | var _fu = new _bp(this._fa, _dh); 984 | var _dg = this._eb(this._fa._ba(_fv, 1), _fu, _fv); 985 | var sigma = _dg[0]; 986 | var omega = _dg[1]; 987 | var _dz = this._ey(sigma); 988 | var _ea = this._di(omega, _dz, _fq); 989 | for (var i = 0; i < _dz.length; i++) { 990 | var position = received.length - 1 - this._fa.log(_dz[i]); 991 | if (position < 0) { 992 | throw "ReedSolomonException Bad error location" 993 | } 994 | received[position] = _az._bd(received[position], _ea[i]) 995 | } 996 | }; 997 | this._eb = function(a, b, R) { 998 | if (a._ec < b._ec) { 999 | var temp = a; 1000 | a = b; 1001 | b = temp 1002 | } 1003 | var rLast = a; 1004 | var r = b; 1005 | var sLast = this._fa.One; 1006 | var s = this._fa.Zero; 1007 | var tLast = this._fa.Zero; 1008 | var t = this._fa.One; 1009 | while (r._ec >= Math.floor(R / 2)) { 1010 | var rLastLast = rLast; 1011 | var _ga = sLast; 1012 | var _gb = tLast; 1013 | rLast = r; 1014 | sLast = s; 1015 | tLast = t; 1016 | if (rLast.Zero) { 1017 | throw "r_{i-1} was zero" 1018 | } 1019 | r = rLastLast; 1020 | var q = this._fa.Zero; 1021 | var _df = rLast._ex(rLast._ec); 1022 | var _fy = this._fa.inverse(_df); 1023 | while (r._ec >= rLast._ec && !r.Zero) { 1024 | var _fx = r._ec - rLast._ec; 1025 | var scale = this._fa.multiply(r._ex(r._ec), _fy); 1026 | q = q._bd(this._fa._ba(_fx, scale)); 1027 | r = r._bd(rLast._dc(_fx, scale)) 1028 | } 1029 | s = q.multiply1(sLast)._bd(_ga); 1030 | t = q.multiply1(tLast)._bd(_gb) 1031 | } 1032 | var _de = t._ex(0); 1033 | if (_de == 0) { 1034 | throw "ReedSolomonException sigmaTilde(0) was zero" 1035 | } 1036 | var inverse = this._fa.inverse(_de); 1037 | var sigma = t.multiply2(inverse); 1038 | var omega = r.multiply2(inverse); 1039 | return new Array(sigma, omega) 1040 | }; 1041 | this._ey = function(_ez) { 1042 | var _fz = _ez._ec; 1043 | if (_fz == 1) { 1044 | return new Array(_ez._ex(1)) 1045 | } 1046 | var result = new Array(_fz); 1047 | var e = 0; 1048 | for (var i = 1; i < 256 && e < _fz; i++) { 1049 | if (_ez.evaluateAt(i) == 0) { 1050 | result[e] = this._fa.inverse(i); 1051 | e++ 1052 | } 1053 | } 1054 | if (e != _fz) { 1055 | throw "Error locator degree does not match number of roots" 1056 | } 1057 | return result 1058 | }; 1059 | this._di = function(_fs, _dz, _fq) { 1060 | var s = _dz.length; 1061 | var result = new Array(s); 1062 | for (var i = 0; i < s; i++) { 1063 | var _gc = this._fa.inverse(_dz[i]); 1064 | var _dr = 1; 1065 | for (var j = 0; j < s; j++) { 1066 | if (i != j) { 1067 | _dr = this._fa.multiply(_dr, _az._bd(1, this._fa.multiply(_dz[j], _gc))) 1068 | } 1069 | } 1070 | result[i] = this._fa.multiply(_fs.evaluateAt(_gc), this._fa.inverse(_dr)); 1071 | if (_fq) { 1072 | result[i] = this._fa.multiply(result[i], _gc) 1073 | } 1074 | } 1075 | return result 1076 | } 1077 | } 1078 | 1079 | function _bp(f, e) { 1080 | if (e == null || e.length == 0) { 1081 | throw "bad arguments" 1082 | } 1083 | this._fa = f; 1084 | var c = e.length; 1085 | if (c > 1 && e[0] == 0) { 1086 | var d = 1; 1087 | while (d < c && e[d] == 0) { 1088 | d++ 1089 | } 1090 | if (d == c) { 1091 | this._dd = f.Zero._dd 1092 | } else { 1093 | this._dd = new Array(c - d); 1094 | for (var b = 0; b < this._dd.length; b++) { 1095 | this._dd[b] = 0 1096 | } 1097 | for (var a = 0; a < this._dd.length; a++) { 1098 | this._dd[a] = e[d + a] 1099 | } 1100 | } 1101 | } else { 1102 | this._dd = e 1103 | } 1104 | this.__defineGetter__("Zero", 1105 | function() { 1106 | return this._dd[0] == 0 1107 | }); 1108 | this.__defineGetter__("_ec", 1109 | function() { 1110 | return this._dd.length - 1 1111 | }); 1112 | this.__defineGetter__("Coefficients", 1113 | function() { 1114 | return this._dd 1115 | }); 1116 | this._ex = function(g) { 1117 | return this._dd[this._dd.length - 1 - g] 1118 | }; 1119 | this.evaluateAt = function(h) { 1120 | if (h == 0) { 1121 | return this._ex(0) 1122 | } 1123 | var l = this._dd.length; 1124 | if (h == 1) { 1125 | var g = 0; 1126 | for (var k = 0; k < l; k++) { 1127 | g = _az._bd(g, this._dd[k]) 1128 | } 1129 | return g 1130 | } 1131 | var j = this._dd[0]; 1132 | for (var k = 1; k < l; k++) { 1133 | j = _az._bd(this._fa.multiply(h, j), this._dd[k]) 1134 | } 1135 | return j 1136 | }; 1137 | this._bd = function(g) { 1138 | if (this._fa != g._fa) { 1139 | throw "GF256Polys do not have same _az _fa" 1140 | } 1141 | if (this.Zero) { 1142 | return g 1143 | } 1144 | if (g.Zero) { 1145 | return this 1146 | } 1147 | var o = this._dd; 1148 | var n = g._dd; 1149 | if (o.length > n.length) { 1150 | var j = o; 1151 | o = n; 1152 | n = j 1153 | } 1154 | var h = new Array(n.length); 1155 | var k = n.length - o.length; 1156 | for (var m = 0; m < k; m++) { 1157 | h[m] = n[m] 1158 | } 1159 | for (var l = k; l < n.length; l++) { 1160 | h[l] = _az._bd(o[l - k], n[l]) 1161 | } 1162 | return new _bp(f, h) 1163 | }; 1164 | this.multiply1 = function(o) { 1165 | if (this._fa != o._fa) { 1166 | throw "GF256Polys do not have same _az _fa" 1167 | } 1168 | if (this.Zero || o.Zero) { 1169 | return this._fa.Zero 1170 | } 1171 | var r = this._dd; 1172 | var g = r.length; 1173 | var l = o._dd; 1174 | var n = l.length; 1175 | var q = new Array(g + n - 1); 1176 | for (var m = 0; m < g; m++) { 1177 | var h = r[m]; 1178 | for (var k = 0; k < n; k++) { 1179 | q[m + k] = _az._bd(q[m + k], this._fa.multiply(h, l[k])) 1180 | } 1181 | } 1182 | return new _bp(this._fa, q) 1183 | }; 1184 | this.multiply2 = function(g) { 1185 | if (g == 0) { 1186 | return this._fa.Zero 1187 | } 1188 | if (g == 1) { 1189 | return this 1190 | } 1191 | var j = this._dd.length; 1192 | var k = new Array(j); 1193 | for (var h = 0; h < j; h++) { 1194 | k[h] = this._fa.multiply(this._dd[h], g) 1195 | } 1196 | return new _bp(this._fa, k) 1197 | }; 1198 | this._dc = function(l, g) { 1199 | if (l < 0) { 1200 | throw "bad arguments" 1201 | } 1202 | if (g == 0) { 1203 | return this._fa.Zero 1204 | } 1205 | var j = this._dd.length; 1206 | var k = new Array(j + l); 1207 | for (var h = 0; h < k.length; h++) { 1208 | k[h] = 0 1209 | } 1210 | for (var h = 0; h < j; h++) { 1211 | k[h] = this._fa.multiply(this._dd[h], g) 1212 | } 1213 | return new _bp(this._fa, k) 1214 | }; 1215 | this.divide = function(l) { 1216 | if (this._fa != l._fa) { 1217 | throw "GF256Polys do not have same _az _fa" 1218 | } 1219 | if (l.Zero) { 1220 | throw "Divide by 0" 1221 | } 1222 | var j = this._fa.Zero; 1223 | var o = this; 1224 | var g = l._ex(l._ec); 1225 | var n = this._fa.inverse(g); 1226 | while (o._ec >= l._ec && !o.Zero) { 1227 | var m = o._ec - l._ec; 1228 | var h = this._fa.multiply(o._ex(o._ec), n); 1229 | var i = l._dc(m, h); 1230 | var k = this._fa._ba(m, h); 1231 | j = j._bd(k); 1232 | o = o._bd(i) 1233 | } 1234 | return new Array(j, o) 1235 | } 1236 | } 1237 | 1238 | function _az(b) { 1239 | this._gh = new Array(256); 1240 | this._gi = new Array(256); 1241 | var a = 1; 1242 | for (var e = 0; e < 256; e++) { 1243 | this._gh[e] = a; 1244 | a <<= 1; 1245 | if (a >= 256) { 1246 | a ^= b 1247 | } 1248 | } 1249 | for (var e = 0; e < 255; e++) { 1250 | this._gi[this._gh[e]] = e 1251 | } 1252 | var d = new Array(1); 1253 | d[0] = 0; 1254 | this.zero = new _bp(this, new Array(d)); 1255 | var c = new Array(1); 1256 | c[0] = 1; 1257 | this.one = new _bp(this, new Array(c)); 1258 | this.__defineGetter__("Zero", 1259 | function() { 1260 | return this.zero 1261 | }); 1262 | this.__defineGetter__("One", 1263 | function() { 1264 | return this.one 1265 | }); 1266 | this._ba = function(j, f) { 1267 | if (j < 0) { 1268 | throw "bad arguments" 1269 | } 1270 | if (f == 0) { 1271 | return zero 1272 | } 1273 | var h = new Array(j + 1); 1274 | for (var g = 0; g < h.length; g++) { 1275 | h[g] = 0 1276 | } 1277 | h[0] = f; 1278 | return new _bp(this, h) 1279 | }; 1280 | this.exp = function(f) { 1281 | return this._gh[f] 1282 | }; 1283 | this.log = function(f) { 1284 | if (f == 0) { 1285 | throw "bad arguments" 1286 | } 1287 | return this._gi[f] 1288 | }; 1289 | this.inverse = function(f) { 1290 | if (f == 0) { 1291 | throw "System.ArithmeticException" 1292 | } 1293 | return this._gh[255 - this._gi[f]] 1294 | }; 1295 | this.multiply = function(g, f) { 1296 | if (g == 0 || f == 0) { 1297 | return 0 1298 | } 1299 | if (g == 1) { 1300 | return f 1301 | } 1302 | if (f == 1) { 1303 | return g 1304 | } 1305 | return this._gh[(this._gi[g] + this._gi[f]) % 255] 1306 | } 1307 | } 1308 | _az._bb = new _az(285); 1309 | _az._bc = new _az(301); 1310 | _az._bd = function(d, c) { 1311 | return d ^ c 1312 | }; 1313 | var Decoder = {}; 1314 | Decoder.rsDecoder = new _db(_az._bb); 1315 | Decoder.correctErrors = function(g, b) { 1316 | var d = g.length; 1317 | var f = new Array(d); 1318 | for (var e = 0; e < d; e++) { 1319 | f[e] = g[e] & 255 1320 | } 1321 | var a = g.length - b; 1322 | try { 1323 | Decoder.rsDecoder.decode(f, a) 1324 | } catch (c) { 1325 | throw c 1326 | } 1327 | for (var e = 0; e < b; e++) { 1328 | g[e] = f[e] 1329 | } 1330 | }; 1331 | Decoder.decode = function(r) { 1332 | var b = new _cl(r); 1333 | var o = b._cq(); 1334 | var c = b._cm()._cg; 1335 | var q = b._gk(); 1336 | var a = _dl._gn(q, o, c); 1337 | var f = 0; 1338 | for (var k = 0; k < a.length; k++) { 1339 | f += a[k]._du 1340 | } 1341 | var e = new Array(f); 1342 | var n = 0; 1343 | for (var h = 0; h < a.length; h++) { 1344 | var m = a[h]; 1345 | var d = m.Codewords; 1346 | var g = m._du; 1347 | Decoder.correctErrors(d, g); 1348 | for (var k = 0; k < g; k++) { 1349 | e[n++] = d[k] 1350 | } 1351 | } 1352 | var l = new QRCodeDataBlockReader(e, o._fd, c.Bits); 1353 | return l 1354 | }; 1355 | var browser = { 1356 | versions: function() { 1357 | var u = navigator.userAgent, 1358 | app = navigator.appVersion; 1359 | return { //移动终端浏览器版本信息 1360 | ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端 1361 | android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或uc浏览器 1362 | iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器 1363 | iPad: u.indexOf('iPad') > -1, //是否iPad 1364 | }; 1365 | }(), 1366 | } 1367 | 1368 | var qrcode = {}; 1369 | qrcode.imagedata = null; 1370 | qrcode.width = 0; 1371 | qrcode.height = 0; 1372 | qrcode.qrCodeSymbol = null; 1373 | qrcode.debug = false; 1374 | qrcode.maxImgSize = 1024 * 1024; 1375 | qrcode._eo = [ 1376 | [10, 9, 8, 8], 1377 | [12, 11, 16, 10], 1378 | [14, 13, 16, 12] 1379 | ]; 1380 | qrcode.callback = null; 1381 | qrcode.decode = function(d) { 1382 | if (arguments.length == 0) { 1383 | var b = document.getElementById("qr-canvas"); 1384 | var a = b.getContext("2d"); 1385 | qrcode.width = b.width; 1386 | qrcode.height = b.height; 1387 | qrcode.imagedata = a.getImageData(0, 0, qrcode.width, qrcode.height); 1388 | qrcode.result = qrcode.process(a); 1389 | if (qrcode.callback != null) { 1390 | qrcode.callback(qrcode.result) 1391 | } 1392 | return qrcode.result 1393 | } else { 1394 | var c = new Image(); 1395 | c.onload = function() { 1396 | var g = document.getElementById("out-canvas"); 1397 | if (g != null) { 1398 | var j = g.getContext("2d"); 1399 | j.clearRect(0, 0, 320, 240); 1400 | if (browser.versions.iPhone || browser.versions.iPad || browser.versions.ios) { 1401 | drawImageIOSFix(j, c, 0, 0, 320, 240); 1402 | } 1403 | else{ 1404 | j.drawImage(c, 0, 0, 320, 240); 1405 | } 1406 | } 1407 | var i = document.createElement("canvas"); 1408 | var h = i.getContext("2d"); 1409 | var f = c.height; 1410 | var l = c.width; 1411 | if (c.width * c.height > qrcode.maxImgSize) { 1412 | var k = c.width / c.height; 1413 | f = Math.sqrt(qrcode.maxImgSize / k); 1414 | l = k * f 1415 | } 1416 | i.width = l; 1417 | i.height = f; 1418 | i.style.display ="none"; 1419 | var u = navigator.userAgent, 1420 | app = navigator.appVersion; 1421 | if (browser.versions.iPhone || browser.versions.iPad || browser.versions.ios) { 1422 | drawImageIOSFix(h, c, 0, 0, i.width, i.height); 1423 | } else { 1424 | h.drawImage(c, 0, 0, i.width, i.height); 1425 | } 1426 | qrcode.width = i.width; 1427 | qrcode.height = i.height; 1428 | try { 1429 | qrcode.imagedata = h.getImageData(0, 0, i.width, i.height) 1430 | } catch (m) { 1431 | qrcode.result = "Cross domain image reading not supported in your browser! Save it to your computer then drag and drop the file!"; 1432 | if (qrcode.callback != null) { 1433 | qrcode.callback(qrcode.result) 1434 | } 1435 | return 1436 | } 1437 | try { 1438 | qrcode.result = qrcode.process(h) 1439 | } catch (m) { 1440 | console.log(m); 1441 | qrcode.result = "error decoding QR Code" 1442 | } 1443 | if (qrcode.callback != null) { 1444 | qrcode.callback(qrcode.result) 1445 | } 1446 | }; 1447 | c.src = d 1448 | } 1449 | }; 1450 | qrcode.isUrl = function(a) { 1451 | var b = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/; 1452 | return b.test(a) 1453 | }; 1454 | qrcode.decode_url = function(b) { 1455 | var d = ""; 1456 | try { 1457 | d = escape(b) 1458 | } catch (c) { 1459 | console.log(c); 1460 | d = b 1461 | } 1462 | var a = ""; 1463 | try { 1464 | a = decodeURIComponent(d) 1465 | } catch (c) { 1466 | console.log(c); 1467 | a = d 1468 | } 1469 | return a 1470 | }; 1471 | qrcode.decode_utf8 = function(a) { 1472 | if (qrcode.isUrl(a)) { 1473 | return qrcode.decode_url(a) 1474 | } else { 1475 | return a 1476 | } 1477 | }; 1478 | qrcode.process = function(r) { 1479 | var a = new Date().getTime(); 1480 | var c = qrcode.grayScaleToBitmap(qrcode.grayscale()); 1481 | if (qrcode.debug) { 1482 | for (var m = 0; m < qrcode.height; m++) { 1483 | for (var n = 0; n < qrcode.width; n++) { 1484 | var o = (n * 4) + (m * qrcode.width * 4); 1485 | qrcode.imagedata.data[o] = c[n + m * qrcode.width] ? 0 : 0; 1486 | qrcode.imagedata.data[o + 1] = c[n + m * qrcode.width] ? 0 : 0; 1487 | qrcode.imagedata.data[o + 2] = c[n + m * qrcode.width] ? 255 : 0 1488 | } 1489 | } 1490 | r.putImageData(qrcode.imagedata, 0, 0) 1491 | } 1492 | var h = new Detector(c); 1493 | var q = h.detect(); 1494 | if (qrcode.debug) { 1495 | r.putImageData(qrcode.imagedata, 0, 0) 1496 | } 1497 | var k = Decoder.decode(q.bits); 1498 | var g = k.DataByte; 1499 | var l = ""; 1500 | for (var f = 0; f < g.length; f++) { 1501 | for (var e = 0; e < g[f].length; e++) { 1502 | l += String.fromCharCode(g[f][e]) 1503 | } 1504 | } 1505 | var d = new Date().getTime(); 1506 | var b = d - a; 1507 | console.log(b); 1508 | return qrcode.decode_utf8(l) 1509 | }; 1510 | qrcode.getPixel = function(a, b) { 1511 | if (qrcode.width < a) { 1512 | throw "point error" 1513 | } 1514 | if (qrcode.height < b) { 1515 | throw "point error" 1516 | } 1517 | var point = (a * 4) + (b * qrcode.width * 4); 1518 | var p = (qrcode.imagedata.data[point] * 33 + qrcode.imagedata.data[point + 1] * 34 + qrcode.imagedata.data[point + 2] * 33) / 100; 1519 | return p 1520 | }; 1521 | qrcode.binarize = function(d) { 1522 | var c = new Array(qrcode.width * qrcode.height); 1523 | for (var e = 0; e < qrcode.height; e++) { 1524 | for (var b = 0; b < qrcode.width; b++) { 1525 | var a = qrcode.getPixel(b, e); 1526 | c[b + e * qrcode.width] = a <= d ? true : false 1527 | } 1528 | } 1529 | return c 1530 | }; 1531 | qrcode._em = function(d) { 1532 | var c = 4; 1533 | var k = Math.floor(qrcode.width / c); 1534 | var j = Math.floor(qrcode.height / c); 1535 | var f = new Array(c); 1536 | for (var g = 0; g < c; g++) { 1537 | f[g] = new Array(c); 1538 | for (var e = 0; e < c; e++) { 1539 | f[g][e] = new Array(0, 0) 1540 | } 1541 | } 1542 | for (var o = 0; o < c; o++) { 1543 | for (var a = 0; a < c; a++) { 1544 | f[a][o][0] = 255; 1545 | for (var l = 0; l < j; l++) { 1546 | for (var n = 0; n < k; n++) { 1547 | var h = d[k * a + n + (j * o + l) * qrcode.width]; 1548 | if (h < f[a][o][0]) { 1549 | f[a][o][0] = h 1550 | } 1551 | if (h > f[a][o][1]) { 1552 | f[a][o][1] = h 1553 | } 1554 | } 1555 | } 1556 | } 1557 | } 1558 | var m = new Array(c); 1559 | for (var b = 0; b < c; b++) { 1560 | m[b] = new Array(c) 1561 | } 1562 | for (var o = 0; o < c; o++) { 1563 | for (var a = 0; a < c; a++) { 1564 | m[a][o] = Math.floor((f[a][o][0] + f[a][o][1]) / 2) 1565 | } 1566 | } 1567 | return m 1568 | }; 1569 | qrcode.grayScaleToBitmap = function(f) { 1570 | var j = qrcode._em(f); 1571 | var b = j.length; 1572 | var e = Math.floor(qrcode.width / b); 1573 | var d = Math.floor(qrcode.height / b); 1574 | var c = new Array(qrcode.height * qrcode.width); 1575 | for (var i = 0; i < b; i++) { 1576 | for (var a = 0; a < b; a++) { 1577 | for (var g = 0; g < d; g++) { 1578 | for (var h = 0; h < e; h++) { 1579 | c[e * a + h + (d * i + g) * qrcode.width] = (f[e * a + h + (d * i + g) * qrcode.width] < j[a][i]) ? true : false 1580 | } 1581 | } 1582 | } 1583 | } 1584 | return c 1585 | }; 1586 | qrcode.grayscale = function() { 1587 | var c = new Array(qrcode.width * qrcode.height); 1588 | for (var d = 0; d < qrcode.height; d++) { 1589 | for (var b = 0; b < qrcode.width; b++) { 1590 | var a = qrcode.getPixel(b, d); 1591 | c[b + d * qrcode.width] = a 1592 | } 1593 | } 1594 | return c 1595 | }; 1596 | 1597 | function _ew(a, b) { 1598 | if (a >= 0) { 1599 | return a >> b 1600 | } else { 1601 | return (a >> b) + (2 << ~b) 1602 | } 1603 | } 1604 | Array.prototype.remove = function(c, b) { 1605 | var a = this.slice((b || c) + 1 || this.length); 1606 | this.length = c < 0 ? this.length + c : c; 1607 | return this.push.apply(this, a) 1608 | }; 1609 | var _gf = 3; 1610 | var _eh = 57; 1611 | var _el = 8; 1612 | var _eg = 2; 1613 | exports.qrcode = qrcode; 1614 | qrcode._er = function(c) { 1615 | function b(l, k) { 1616 | xDiff = l.X - k.X; 1617 | yDiff = l.Y - k.Y; 1618 | return Math.sqrt((xDiff * xDiff + yDiff * yDiff)) 1619 | } 1620 | 1621 | function d(k, o, n) { 1622 | var m = o.x; 1623 | var l = o.y; 1624 | return ((n.x - m) * (k.y - l)) - ((n.y - l) * (k.x - m)) 1625 | } 1626 | var i = b(c[0], c[1]); 1627 | var f = b(c[1], c[2]); 1628 | var e = b(c[0], c[2]); 1629 | var a, j, h; 1630 | if (f >= i && f >= e) { 1631 | j = c[0]; 1632 | a = c[1]; 1633 | h = c[2] 1634 | } else { 1635 | if (e >= f && e >= i) { 1636 | j = c[1]; 1637 | a = c[0]; 1638 | h = c[2] 1639 | } else { 1640 | j = c[2]; 1641 | a = c[0]; 1642 | h = c[1] 1643 | } 1644 | } 1645 | if (d(a, j, h) < 0) { 1646 | var g = a; 1647 | a = h; 1648 | h = g 1649 | } 1650 | c[0] = a; 1651 | c[1] = j; 1652 | c[2] = h 1653 | }; 1654 | 1655 | function detectVerticalSquash(img) { 1656 | var iw = img.naturalWidth, 1657 | ih = img.naturalHeight; 1658 | var canvas = document.createElement('canvas'); 1659 | canvas.width = 1; 1660 | canvas.height = ih; 1661 | var ctx = canvas.getContext('2d'); 1662 | ctx.drawImage(img, 0, 0); 1663 | var data = ctx.getImageData(0, 0, 1, ih).data; 1664 | // search image edge pixel position in case it is squashed vertically. 1665 | var sy = 0; 1666 | var ey = ih; 1667 | var py = ih; 1668 | while (py > sy) { 1669 | var alpha = data[(py - 1) * 4 + 3]; 1670 | if (alpha === 0) { 1671 | ey = py; 1672 | } else { 1673 | sy = py; 1674 | } 1675 | py = (ey + sy) >> 1; 1676 | } 1677 | var ratio = (py / ih); 1678 | return (ratio === 0) ? 1 : ratio; 1679 | } 1680 | 1681 | /** 1682 | * A replacement for context.drawImage 1683 | * (args are for source and destination). 1684 | */ 1685 | function drawImageIOSFix(ctx, img, sx, sy, sw, sh, dx, dy, dw, dh) { 1686 | var vertSquashRatio = detectVerticalSquash(img); 1687 | // Works only if whole image is displayed: 1688 | // ctx.drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh / vertSquashRatio); 1689 | // The following works correct also when only a part of the image is displayed: 1690 | ctx.drawImage(img, sx * vertSquashRatio, sy * vertSquashRatio, 1691 | sw * vertSquashRatio, sh * vertSquashRatio, 1692 | dx, dy, dw, dh); 1693 | } 1694 | 1695 | function _cz(c, a, b) { 1696 | this.x = c; 1697 | this.y = a; 1698 | this.count = 1; 1699 | this._aj = b; 1700 | this.__defineGetter__("_ei", 1701 | function() { 1702 | return this._aj 1703 | }); 1704 | this.__defineGetter__("Count", 1705 | function() { 1706 | return this.count 1707 | }); 1708 | this.__defineGetter__("X", 1709 | function() { 1710 | return this.x 1711 | }); 1712 | this.__defineGetter__("Y", 1713 | function() { 1714 | return this.y 1715 | }); 1716 | this._ek = function() { 1717 | this.count++ 1718 | }; 1719 | this._ev = function(f, e, d) { 1720 | if (Math.abs(e - this.y) <= f && Math.abs(d - this.x) <= f) { 1721 | var g = Math.abs(f - this._aj); 1722 | return g <= 1 || g / this._aj <= 1 1723 | } 1724 | return false 1725 | } 1726 | } 1727 | 1728 | function _es(a) { 1729 | this._go = a[0]; 1730 | this._gu = a[1]; 1731 | this._gr = a[2]; 1732 | this.__defineGetter__("_gp", 1733 | function() { 1734 | return this._go 1735 | }); 1736 | this.__defineGetter__("_gq", 1737 | function() { 1738 | return this._gu 1739 | }); 1740 | this.__defineGetter__("_gs", 1741 | function() { 1742 | return this._gr 1743 | }) 1744 | } 1745 | 1746 | function _cc() { 1747 | this.image = null; 1748 | this._cv = []; 1749 | this._ge = false; 1750 | this._al = new Array(0, 0, 0, 0, 0); 1751 | this._am = null; 1752 | this.__defineGetter__("_da", 1753 | function() { 1754 | this._al[0] = 0; 1755 | this._al[1] = 0; 1756 | this._al[2] = 0; 1757 | this._al[3] = 0; 1758 | this._al[4] = 0; 1759 | return this._al 1760 | }); 1761 | this._ao = function(f) { 1762 | var b = 0; 1763 | for (var d = 0; d < 5; d++) { 1764 | var e = f[d]; 1765 | if (e == 0) { 1766 | return false 1767 | } 1768 | b += e 1769 | } 1770 | if (b < 7) { 1771 | return false 1772 | } 1773 | var c = Math.floor((b << _el) / 7); 1774 | var a = Math.floor(c / 2); 1775 | return Math.abs(c - (f[0] << _el)) < a && Math.abs(c - (f[1] << _el)) < a && Math.abs(3 * c - (f[2] << _el)) < 3 * a && Math.abs(c - (f[3] << _el)) < a && Math.abs(c - (f[4] << _el)) < a 1776 | }; 1777 | this._an = function(b, a) { 1778 | return (a - b[4] - b[3]) - b[2] / 2 1779 | }; 1780 | this._ap = function(a, j, d, g) { 1781 | var c = this.image; 1782 | var h = qrcode.height; 1783 | var b = this._da; 1784 | var f = a; 1785 | while (f >= 0 && c[j + f * qrcode.width]) { 1786 | b[2]++; 1787 | f-- 1788 | } 1789 | if (f < 0) { 1790 | return NaN 1791 | } 1792 | while (f >= 0 && !c[j + f * qrcode.width] && b[1] <= d) { 1793 | b[1]++; 1794 | f-- 1795 | } 1796 | if (f < 0 || b[1] > d) { 1797 | return NaN 1798 | } 1799 | while (f >= 0 && c[j + f * qrcode.width] && b[0] <= d) { 1800 | b[0]++; 1801 | f-- 1802 | } 1803 | if (b[0] > d) { 1804 | return NaN 1805 | } 1806 | f = a + 1; 1807 | while (f < h && c[j + f * qrcode.width]) { 1808 | b[2]++; 1809 | f++ 1810 | } 1811 | if (f == h) { 1812 | return NaN 1813 | } 1814 | while (f < h && !c[j + f * qrcode.width] && b[3] < d) { 1815 | b[3]++; 1816 | f++ 1817 | } 1818 | if (f == h || b[3] >= d) { 1819 | return NaN 1820 | } 1821 | while (f < h && c[j + f * qrcode.width] && b[4] < d) { 1822 | b[4]++; 1823 | f++ 1824 | } 1825 | if (b[4] >= d) { 1826 | return NaN 1827 | } 1828 | var e = b[0] + b[1] + b[2] + b[3] + b[4]; 1829 | if (5 * Math.abs(e - g) >= 2 * g) { 1830 | return NaN 1831 | } 1832 | return this._ao(b) ? this._an(b, f) : NaN 1833 | }; 1834 | this._ej = function(b, a, e, h) { 1835 | var d = this.image; 1836 | var i = qrcode.width; 1837 | var c = this._da; 1838 | var g = b; 1839 | while (g >= 0 && d[g + a * qrcode.width]) { 1840 | c[2]++; 1841 | g-- 1842 | } 1843 | if (g < 0) { 1844 | return NaN 1845 | } 1846 | while (g >= 0 && !d[g + a * qrcode.width] && c[1] <= e) { 1847 | c[1]++; 1848 | g-- 1849 | } 1850 | if (g < 0 || c[1] > e) { 1851 | return NaN 1852 | } 1853 | while (g >= 0 && d[g + a * qrcode.width] && c[0] <= e) { 1854 | c[0]++; 1855 | g-- 1856 | } 1857 | if (c[0] > e) { 1858 | return NaN 1859 | } 1860 | g = b + 1; 1861 | while (g < i && d[g + a * qrcode.width]) { 1862 | c[2]++; 1863 | g++ 1864 | } 1865 | if (g == i) { 1866 | return NaN 1867 | } 1868 | while (g < i && !d[g + a * qrcode.width] && c[3] < e) { 1869 | c[3]++; 1870 | g++ 1871 | } 1872 | if (g == i || c[3] >= e) { 1873 | return NaN 1874 | } 1875 | while (g < i && d[g + a * qrcode.width] && c[4] < e) { 1876 | c[4]++; 1877 | g++ 1878 | } 1879 | if (c[4] >= e) { 1880 | return NaN 1881 | } 1882 | var f = c[0] + c[1] + c[2] + c[3] + c[4]; 1883 | if (5 * Math.abs(f - h) >= h) { 1884 | return NaN 1885 | } 1886 | return this._ao(c) ? this._an(c, g) : NaN 1887 | }; 1888 | this._cu = function(c, f, e) { 1889 | var d = c[0] + c[1] + c[2] + c[3] + c[4]; 1890 | var n = this._an(c, e); 1891 | var b = this._ap(f, Math.floor(n), c[2], d); 1892 | if (!isNaN(b)) { 1893 | n = this._ej(Math.floor(n), Math.floor(b), c[2], d); 1894 | if (!isNaN(n)) { 1895 | var l = d / 7; 1896 | var m = false; 1897 | var h = this._cv.length; 1898 | for (var g = 0; g < h; g++) { 1899 | var a = this._cv[g]; 1900 | if (a._ev(l, b, n)) { 1901 | a._ek(); 1902 | m = true; 1903 | break 1904 | } 1905 | } 1906 | if (!m) { 1907 | var k = new _cz(n, b, l); 1908 | this._cv.push(k); 1909 | if (this._am != null) { 1910 | this._am._ep(k) 1911 | } 1912 | } 1913 | return true 1914 | } 1915 | } 1916 | return false 1917 | }; 1918 | this._ee = function() { 1919 | var h = this._cv.length; 1920 | if (h < 3) { 1921 | throw "Couldn't find enough finder patterns" 1922 | } 1923 | if (h > 3) { 1924 | var b = 0; 1925 | var j = 0; 1926 | for (var d = 0; d < h; d++) { 1927 | var g = this._cv[d]._ei; 1928 | b += g; 1929 | j += (g * g) 1930 | } 1931 | var a = b / h; 1932 | this._cv.sort(function(m, l) { 1933 | var k = Math.abs(l._ei - a); 1934 | var i = Math.abs(m._ei - a); 1935 | if (k < i) { 1936 | return (-1) 1937 | } else { 1938 | if (k == i) { 1939 | return 0 1940 | } else { 1941 | return 1 1942 | } 1943 | } 1944 | }); 1945 | var e = Math.sqrt(j / h - a * a); 1946 | var c = Math.max(0.2 * a, e); 1947 | for (var d = 0; d < this._cv.length && this._cv.length > 3; d++) { 1948 | var f = this._cv[d]; 1949 | if (Math.abs(f._ei - a) > c) { 1950 | this._cv.remove(d); 1951 | d-- 1952 | } 1953 | } 1954 | } 1955 | if (this._cv.length > 3) { 1956 | this._cv.sort(function(k, i) { 1957 | if (k.count > i.count) { 1958 | return -1 1959 | } 1960 | if (k.count < i.count) { 1961 | return 1 1962 | } 1963 | return 0 1964 | }) 1965 | } 1966 | return new Array(this._cv[0], this._cv[1], this._cv[2]) 1967 | }; 1968 | this._eq = function() { 1969 | var b = this._cv.length; 1970 | if (b <= 1) { 1971 | return 0 1972 | } 1973 | var c = null; 1974 | for (var d = 0; d < b; d++) { 1975 | var a = this._cv[d]; 1976 | if (a.Count >= _eg) { 1977 | if (c == null) { 1978 | c = a 1979 | } else { 1980 | this._ge = true; 1981 | return Math.floor((Math.abs(c.X - a.X) - Math.abs(c.Y - a.Y)) / 2) 1982 | } 1983 | } 1984 | } 1985 | return 0 1986 | }; 1987 | this._cx = function() { 1988 | var g = 0; 1989 | var c = 0; 1990 | var a = this._cv.length; 1991 | for (var d = 0; d < a; d++) { 1992 | var f = this._cv[d]; 1993 | if (f.Count >= _eg) { 1994 | g++; 1995 | c += f._ei 1996 | } 1997 | } 1998 | if (g < 3) { 1999 | return false 2000 | } 2001 | var e = c / a; 2002 | var b = 0; 2003 | for (var d = 0; d < a; d++) { 2004 | f = this._cv[d]; 2005 | b += Math.abs(f._ei - e) 2006 | } 2007 | return b <= 0.05 * c 2008 | }; 2009 | this._ce = function(e) { 2010 | var o = false; 2011 | this.image = e; 2012 | var n = qrcode.height; 2013 | var k = qrcode.width; 2014 | var a = Math.floor((3 * n) / (4 * _eh)); 2015 | if (a < _gf || o) { 2016 | a = _gf 2017 | } 2018 | var g = false; 2019 | var d = new Array(5); 2020 | for (var h = a - 1; h < n && !g; h += a) { 2021 | d[0] = 0; 2022 | d[1] = 0; 2023 | d[2] = 0; 2024 | d[3] = 0; 2025 | d[4] = 0; 2026 | var b = 0; 2027 | for (var f = 0; f < k; f++) { 2028 | if (e[f + h * qrcode.width]) { 2029 | if ((b & 1) == 1) { 2030 | b++ 2031 | } 2032 | d[b]++ 2033 | } else { 2034 | if ((b & 1) == 0) { 2035 | if (b == 4) { 2036 | if (this._ao(d)) { 2037 | var c = this._cu(d, h, f); 2038 | if (c) { 2039 | a = 2; 2040 | if (this._ge) { 2041 | g = this._cx() 2042 | } else { 2043 | var m = this._eq(); 2044 | if (m > d[2]) { 2045 | h += m - d[2] - a; 2046 | f = k - 1 2047 | } 2048 | } 2049 | } else { 2050 | do { 2051 | f++ 2052 | } while (f < k && !e[f + h * qrcode.width]); 2053 | f-- 2054 | } 2055 | b = 0; 2056 | d[0] = 0; 2057 | d[1] = 0; 2058 | d[2] = 0; 2059 | d[3] = 0; 2060 | d[4] = 0 2061 | } else { 2062 | d[0] = d[2]; 2063 | d[1] = d[3]; 2064 | d[2] = d[4]; 2065 | d[3] = 1; 2066 | d[4] = 0; 2067 | b = 3 2068 | } 2069 | } else { 2070 | d[++b]++ 2071 | } 2072 | } else { 2073 | d[b]++ 2074 | } 2075 | } 2076 | } 2077 | if (this._ao(d)) { 2078 | var c = this._cu(d, h, k); 2079 | if (c) { 2080 | a = d[0]; 2081 | if (this._ge) { 2082 | g = _cx() 2083 | } 2084 | } 2085 | } 2086 | } 2087 | var l = this._ee(); 2088 | qrcode._er(l); 2089 | return new _es(l) 2090 | } 2091 | } 2092 | 2093 | function _ai(c, a, b) { 2094 | this.x = c; 2095 | this.y = a; 2096 | this.count = 1; 2097 | this._aj = b; 2098 | this.__defineGetter__("_ei", 2099 | function() { 2100 | return this._aj 2101 | }); 2102 | this.__defineGetter__("Count", 2103 | function() { 2104 | return this.count 2105 | }); 2106 | this.__defineGetter__("X", 2107 | function() { 2108 | return Math.floor(this.x) 2109 | }); 2110 | this.__defineGetter__("Y", 2111 | function() { 2112 | return Math.floor(this.y) 2113 | }); 2114 | this._ek = function() { 2115 | this.count++ 2116 | }; 2117 | this._ev = function(f, e, d) { 2118 | if (Math.abs(e - this.y) <= f && Math.abs(d - this.x) <= f) { 2119 | var g = Math.abs(f - this._aj); 2120 | return g <= 1 || g / this._aj <= 1 2121 | } 2122 | return false 2123 | } 2124 | } 2125 | 2126 | function _ak(g, c, b, f, a, e, d) { 2127 | this.image = g; 2128 | this._cv = new Array(); 2129 | this.startX = c; 2130 | this.startY = b; 2131 | this.width = f; 2132 | this.height = a; 2133 | this._ef = e; 2134 | this._al = new Array(0, 0, 0); 2135 | this._am = d; 2136 | this._an = function(i, h) { 2137 | return (h - i[2]) - i[1] / 2 2138 | }; 2139 | this._ao = function(l) { 2140 | var k = this._ef; 2141 | var h = k / 2; 2142 | for (var j = 0; j < 3; j++) { 2143 | if (Math.abs(k - l[j]) >= h) { 2144 | return false 2145 | } 2146 | } 2147 | return true 2148 | }; 2149 | this._ap = function(h, r, l, o) { 2150 | var k = this.image; 2151 | var q = qrcode.height; 2152 | var j = this._al; 2153 | j[0] = 0; 2154 | j[1] = 0; 2155 | j[2] = 0; 2156 | var n = h; 2157 | while (n >= 0 && k[r + n * qrcode.width] && j[1] <= l) { 2158 | j[1]++; 2159 | n-- 2160 | } 2161 | if (n < 0 || j[1] > l) { 2162 | return NaN 2163 | } 2164 | while (n >= 0 && !k[r + n * qrcode.width] && j[0] <= l) { 2165 | j[0]++; 2166 | n-- 2167 | } 2168 | if (j[0] > l) { 2169 | return NaN 2170 | } 2171 | n = h + 1; 2172 | while (n < q && k[r + n * qrcode.width] && j[1] <= l) { 2173 | j[1]++; 2174 | n++ 2175 | } 2176 | if (n == q || j[1] > l) { 2177 | return NaN 2178 | } 2179 | while (n < q && !k[r + n * qrcode.width] && j[2] <= l) { 2180 | j[2]++; 2181 | n++ 2182 | } 2183 | if (j[2] > l) { 2184 | return NaN 2185 | } 2186 | var m = j[0] + j[1] + j[2]; 2187 | if (5 * Math.abs(m - o) >= 2 * o) { 2188 | return NaN 2189 | } 2190 | return this._ao(j) ? this._an(j, n) : NaN 2191 | }; 2192 | this._cu = function(l, o, n) { 2193 | var m = l[0] + l[1] + l[2]; 2194 | var u = this._an(l, n); 2195 | var k = this._ap(o, Math.floor(u), 2 * l[1], m); 2196 | if (!isNaN(k)) { 2197 | var t = (l[0] + l[1] + l[2]) / 3; 2198 | var r = this._cv.length; 2199 | for (var q = 0; q < r; q++) { 2200 | var h = this._cv[q]; 2201 | if (h._ev(t, k, u)) { 2202 | return new _ai(u, k, t) 2203 | } 2204 | } 2205 | var s = new _ai(u, k, t); 2206 | this._cv.push(s); 2207 | if (this._am != null) { 2208 | this._am._ep(s) 2209 | } 2210 | } 2211 | return null 2212 | }; 2213 | this.find = function() { 2214 | var q = this.startX; 2215 | var t = this.height; 2216 | var r = q + f; 2217 | var s = b + (t >> 1); 2218 | var m = new Array(0, 0, 0); 2219 | for (var k = 0; k < t; k++) { 2220 | var o = s + ((k & 1) == 0 ? ((k + 1) >> 1) : -((k + 1) >> 1)); 2221 | m[0] = 0; 2222 | m[1] = 0; 2223 | m[2] = 0; 2224 | var n = q; 2225 | while (n < r && !g[n + qrcode.width * o]) { 2226 | n++ 2227 | } 2228 | var h = 0; 2229 | while (n < r) { 2230 | if (g[n + o * qrcode.width]) { 2231 | if (h == 1) { 2232 | m[h]++ 2233 | } else { 2234 | if (h == 2) { 2235 | if (this._ao(m)) { 2236 | var l = this._cu(m, o, n); 2237 | if (l != null) { 2238 | return l 2239 | } 2240 | } 2241 | m[0] = m[2]; 2242 | m[1] = 1; 2243 | m[2] = 0; 2244 | h = 1 2245 | } else { 2246 | m[++h]++ 2247 | } 2248 | } 2249 | } else { 2250 | if (h == 1) { 2251 | h++ 2252 | } 2253 | m[h]++ 2254 | } 2255 | n++ 2256 | } 2257 | if (this._ao(m)) { 2258 | var l = this._cu(m, o, r); 2259 | if (l != null) { 2260 | return l 2261 | } 2262 | } 2263 | } 2264 | if (!(this._cv.length == 0)) { 2265 | return this._cv[0] 2266 | } 2267 | throw "Couldn't find enough alignment patterns" 2268 | } 2269 | } 2270 | 2271 | function QRCodeDataBlockReader(c, a, b) { 2272 | this._ed = 0; 2273 | this._cw = 7; 2274 | this.dataLength = 0; 2275 | this.blocks = c; 2276 | this._en = b; 2277 | if (a <= 9) { 2278 | this.dataLengthMode = 0 2279 | } else { 2280 | if (a >= 10 && a <= 26) { 2281 | this.dataLengthMode = 1 2282 | } else { 2283 | if (a >= 27 && a <= 40) { 2284 | this.dataLengthMode = 2 2285 | } 2286 | } 2287 | } 2288 | this._gd = function(f) { 2289 | var k = 0; 2290 | if (f < this._cw + 1) { 2291 | var m = 0; 2292 | for (var e = 0; e < f; e++) { 2293 | m += (1 << e) 2294 | } 2295 | m <<= (this._cw - f + 1); 2296 | k = (this.blocks[this._ed] & m) >> (this._cw - f + 1); 2297 | this._cw -= f; 2298 | return k 2299 | } else { 2300 | if (f < this._cw + 1 + 8) { 2301 | var j = 0; 2302 | for (var e = 0; e < this._cw + 1; e++) { 2303 | j += (1 << e) 2304 | } 2305 | k = (this.blocks[this._ed] & j) << (f - (this._cw + 1)); 2306 | this._ed++; 2307 | k += ((this.blocks[this._ed]) >> (8 - (f - (this._cw + 1)))); 2308 | this._cw = this._cw - f % 8; 2309 | if (this._cw < 0) { 2310 | this._cw = 8 + this._cw 2311 | } 2312 | return k 2313 | } else { 2314 | if (f < this._cw + 1 + 16) { 2315 | var j = 0; 2316 | var h = 0; 2317 | for (var e = 0; e < this._cw + 1; e++) { 2318 | j += (1 << e) 2319 | } 2320 | var g = (this.blocks[this._ed] & j) << (f - (this._cw + 1)); 2321 | this._ed++; 2322 | var d = this.blocks[this._ed] << (f - (this._cw + 1 + 8)); 2323 | this._ed++; 2324 | for (var e = 0; e < f - (this._cw + 1 + 8); e++) { 2325 | h += (1 << e) 2326 | } 2327 | h <<= 8 - (f - (this._cw + 1 + 8)); 2328 | var l = (this.blocks[this._ed] & h) >> (8 - (f - (this._cw + 1 + 8))); 2329 | k = g + d + l; 2330 | this._cw = this._cw - (f - 8) % 8; 2331 | if (this._cw < 0) { 2332 | this._cw = 8 + this._cw 2333 | } 2334 | return k 2335 | } else { 2336 | return 0 2337 | } 2338 | } 2339 | } 2340 | }; 2341 | this.NextMode = function() { 2342 | if ((this._ed > this.blocks.length - this._en - 2)) { 2343 | return 0 2344 | } else { 2345 | return this._gd(4) 2346 | } 2347 | }; 2348 | this.getDataLength = function(d) { 2349 | var e = 0; 2350 | while (true) { 2351 | if ((d >> e) == 1) { 2352 | break 2353 | } 2354 | e++ 2355 | } 2356 | return this._gd(qrcode._eo[this.dataLengthMode][e]) 2357 | }; 2358 | this.getRomanAndFigureString = function(h) { 2359 | var f = h; 2360 | var g = 0; 2361 | var j = ""; 2362 | var d = new Array("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", " ", "$", "%", "*", "+", "-", ".", "/", ":"); 2363 | do { 2364 | if (f > 1) { 2365 | g = this._gd(11); 2366 | var i = Math.floor(g / 45); 2367 | var e = g % 45; 2368 | j += d[i]; 2369 | j += d[e]; 2370 | f -= 2 2371 | } else { 2372 | if (f == 1) { 2373 | g = this._gd(6); 2374 | j += d[g]; 2375 | f -= 1 2376 | } 2377 | } 2378 | } while (f > 0); 2379 | return j 2380 | }; 2381 | this.getFigureString = function(f) { 2382 | var d = f; 2383 | var e = 0; 2384 | var g = ""; 2385 | do { 2386 | if (d >= 3) { 2387 | e = this._gd(10); 2388 | if (e < 100) { 2389 | g += "0" 2390 | } 2391 | if (e < 10) { 2392 | g += "0" 2393 | } 2394 | d -= 3 2395 | } else { 2396 | if (d == 2) { 2397 | e = this._gd(7); 2398 | if (e < 10) { 2399 | g += "0" 2400 | } 2401 | d -= 2 2402 | } else { 2403 | if (d == 1) { 2404 | e = this._gd(4); 2405 | d -= 1 2406 | } 2407 | } 2408 | } 2409 | g += e 2410 | } while (d > 0); 2411 | return g 2412 | }; 2413 | this.get8bitByteArray = function(g) { 2414 | var e = g; 2415 | var f = 0; 2416 | var d = new Array(); 2417 | do { 2418 | f = this._gd(8); 2419 | d.push(f); 2420 | e-- 2421 | } while (e > 0); 2422 | return d 2423 | }; 2424 | this.getKanjiString = function(j) { 2425 | var g = j; 2426 | var i = 0; 2427 | var h = ""; 2428 | do { 2429 | i = _gd(13); 2430 | var e = i % 192; 2431 | var f = i / 192; 2432 | var k = (f << 8) + e; 2433 | var d = 0; 2434 | if (k + 33088 <= 40956) { 2435 | d = k + 33088 2436 | } else { 2437 | d = k + 49472 2438 | } 2439 | h += String.fromCharCode(d); 2440 | g-- 2441 | } while (g > 0); 2442 | return h 2443 | }; 2444 | this.__defineGetter__("DataByte", 2445 | function() { 2446 | var g = new Array(); 2447 | var e = 1; 2448 | var f = 2; 2449 | var d = 4; 2450 | var n = 8; 2451 | do { 2452 | var k = this.NextMode(); 2453 | if (k == 0) { 2454 | if (g.length > 0) { 2455 | break 2456 | } else { 2457 | throw "Empty data block" 2458 | } 2459 | } 2460 | if (k != e && k != f && k != d && k != n) { 2461 | throw "Invalid mode: " + k + " in (block:" + this._ed + " bit:" + this._cw + ")" 2462 | } 2463 | var dataLength = this.getDataLength(k); 2464 | if (dataLength < 1) { 2465 | throw "Invalid data length: " + dataLength 2466 | } 2467 | switch (k) { 2468 | case e: 2469 | var l = this.getFigureString(dataLength); 2470 | var i = new Array(l.length); 2471 | for (var h = 0; h < l.length; h++) { 2472 | i[h] = l.charCodeAt(h) 2473 | } 2474 | g.push(i); 2475 | break; 2476 | case f: 2477 | var l = this.getRomanAndFigureString(dataLength); 2478 | var i = new Array(l.length); 2479 | for (var h = 0; h < l.length; h++) { 2480 | i[h] = l.charCodeAt(h) 2481 | } 2482 | g.push(i); 2483 | break; 2484 | case d: 2485 | var m = this.get8bitByteArray(dataLength); 2486 | g.push(m); 2487 | break; 2488 | case n: 2489 | var l = this.getKanjiString(dataLength); 2490 | g.push(l); 2491 | break 2492 | } 2493 | } while (true); 2494 | return g 2495 | }) 2496 | }; 2497 | -------------------------------------------------------------------------------- /src/libs/utils.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @authors Your Name (you@example.org) 4 | * @date 2016-08-12 16:23:52 5 | * @version $Id$ 6 | */ 7 | let _=require("lodash"); 8 | const fmtDate=function(date){ 9 | var str=""; 10 | var o={ 11 | y:date.getFullYear(), 12 | M:date.getMonth()+1, 13 | d:date.getDate(), 14 | h:date.getHours(), 15 | min:date.getMinutes() 16 | } 17 | if(o.M<10){ 18 | o.M="0"+o.M; 19 | } 20 | if(o.d<10){ 21 | o.d="0"+o.d; 22 | } 23 | if(o.h<10){ 24 | o.h="0"+o.h; 25 | } 26 | if(o.min<10){ 27 | o.min="0"+o.m; 28 | } 29 | str+=o.y+"-"+o.M+"-"+o.d+" "+o.h+":"+o.min; 30 | return str; 31 | } 32 | 33 | const Millisecondstodate=function(msd){ 34 | var time=parseInt(msd/1000); 35 | var str=""; 36 | if(time!=null&&time!=""){ 37 | if(time>60&&time<3600){ 38 | str=parseInt(time/60)+" 分钟前" 39 | }else if(time>=3600&&time<86400){ 40 | str=parseInt(time/3600)+" 小时前" 41 | }else if(time>=86400&&time<86400*30){ 42 | str=parseInt(time/86400)+" 天前" 43 | }else if(time>=86400*30&&time<86400*365){ 44 | str=parseInt(time/(86400*30))+" 月前" 45 | }else if(time>=86400*365){ 46 | str=parseInt(time/(86400*365))+" 年前" 47 | }else{ 48 | str=time+" 秒前"; 49 | } 50 | } 51 | return str; 52 | } 53 | 54 | const fetchUser=function(text){ 55 | if(text==""){ 56 | return []; 57 | }else{ 58 | var ignore_regexps=[ 59 | /```.+?```/g, //去除单行的``` 60 | /^```[\s\S]+?^```/gm, //```里面的是pre标签内容 61 | /`[\s\S]+?`/g, //同一行中`some code`内容也不能被解析 62 | /^ .*/gm, //4个空格也是pre标签,不匹配换行符 63 | /\b\S*?@[^\s]*?\..+?\b/g, //邮箱地址'name@gmail.com' 64 | /\[@.+?\]\(\/.+?\)/g //已经link的 'username',不能再次解析 65 | ]; 66 | } 67 | ignore_regexps.forEach(function(regexp){ 68 | text=text.replace(regexp,""); 69 | }); 70 | var results=text.match(/@[0-9a-zA-Z_-]+\b/igm); 71 | var names=[]; 72 | if(results){ 73 | for(var i=0,l=results.length;i Vue.filter(k,filter[k])); 7 | let router=new VueRouter({ 8 | saveSrollPosition:true, 9 | transitionOnLoad:true 10 | }) 11 | //当未登录时,点击页脚导航,跳转到登录页面,同时此时记录跳转之前的路径,用query记录下,当登录成功后重新跳回到消息,发表,我的页面 12 | router.beforeEach((transition) => { 13 | if(transition.to.auth){ 14 | if(localStorage.token){ 15 | transition.next(); 16 | }else{ 17 | let redirect=encodeURIComponent(transition.to.path); 18 | transition.redirect("/login?redirect="+redirect); 19 | } 20 | }else{ 21 | transition.next(); 22 | } 23 | }) 24 | let app=Vue.extend({}); 25 | routerMap(router); 26 | router.start(app,"#app"); 27 | 28 | -------------------------------------------------------------------------------- /src/router.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @authors Your Name (you@example.org) 4 | * @date 2016-08-12 13:17:23 5 | * @version $Id$ 6 | */ 7 | 8 | export default function(router){ 9 | router.map({ 10 | "*":{ 11 | name:"home", 12 | component:function(resolve){ 13 | require(['./views/index.vue'],resolve); 14 | } 15 | }, 16 | "/":{ 17 | name:"home", 18 | component:function(resolve){ 19 | require(['./views/index.vue'],resolve); 20 | } 21 | }, 22 | "/list":{ 23 | name:"list", 24 | component:function(resolve){ 25 | require(['./views/list.vue'],resolve); 26 | } 27 | }, 28 | "/login":{ 29 | name:"login", 30 | component:function(resolve){ 31 | require(['./views/login.vue'],resolve) 32 | } 33 | }, 34 | "/user/:loginname":{ 35 | name:"user", 36 | component:function(resolve){ 37 | require(['./views/user.vue'],resolve); 38 | }, 39 | auth:true 40 | }, 41 | "/topic/:id":{ 42 | name:"topic", 43 | component:function(resolve){ 44 | require(['./views/topic.vue'],resolve); 45 | } 46 | }, 47 | "/about":{ 48 | name:"about", 49 | component:function(resolve){ 50 | require(['./views/about.vue'],resolve); 51 | } 52 | }, 53 | "/message":{ 54 | name:"message", 55 | component:function(resolve){ 56 | require(['./views/message.vue'],resolve); 57 | }, 58 | auth:true 59 | }, 60 | "/publish":{ 61 | name:"publish", 62 | component:function(resolve){ 63 | require(['./views/publish.vue'],resolve); 64 | }, 65 | auth:true 66 | } 67 | }) 68 | } -------------------------------------------------------------------------------- /src/views/about.vue: -------------------------------------------------------------------------------- 1 | 15 | 23 | -------------------------------------------------------------------------------- /src/views/index.vue: -------------------------------------------------------------------------------- 1 | 6 | 16 | 23 | -------------------------------------------------------------------------------- /src/views/list.vue: -------------------------------------------------------------------------------- 1 | 30 | 119 | -------------------------------------------------------------------------------- /src/views/login.vue: -------------------------------------------------------------------------------- 1 | 16 | 140 | -------------------------------------------------------------------------------- /src/views/message.vue: -------------------------------------------------------------------------------- 1 | 11 | 30 | -------------------------------------------------------------------------------- /src/views/publish.vue: -------------------------------------------------------------------------------- 1 | 25 | 89 | -------------------------------------------------------------------------------- /src/views/topic.vue: -------------------------------------------------------------------------------- 1 | 44 | 132 | 253 | -------------------------------------------------------------------------------- /src/views/user.vue: -------------------------------------------------------------------------------- 1 | 35 | 86 | --------------------------------------------------------------------------------