Commit 55a7312a by zhoubin

代码初始化

parent b3557475
.DS_Store
node_modules
bower_components
demo/config.js
deploy.sh
/.project
/dist/
/*************************************************************
* JSHint Docs:
* http://www.jshint.com/docs
*
* NOTICE: All of our javascript file should pass check of jsHint.
*
* by MaYiqing
*************************************************************/
{
// Global objects
"predef": [
"Q", // global namespace
"model", // UserViewModel
"ko", // knockout.js
"Highcharts", // highcharts.js
"phpjs", // php.js
"_bucketName" // defined in bucket_box_layout.html
],
// Enforcing options
//"quotmark": "single", // always use single quotes
"noarg": true, // forbiden arguments.calle and arguments.caller
"noempty": true, // don't let statements blocks empty
"eqeqeq": true, // always use === to compare
"undef": true, // don't use undefined object
"unused": "vars", // warning when there are some var never use in the file
"curly": true, // always put curly braces around blocks in loops and conditionals
"forin": true, // use hasOwnProperty when use "for(key in obj){}"
"newcap": true, // must capitalize names of constructor functions
// Relaxing options
"expr": true, // suppresses warnings about the use of expressions where function calls
"boss": true, // suppresses warnings about the use of assignments in cases where comparisons are expected
// Enviroments
"browser": true, // globals exposed by modern browsers, like document, window, etc.
"devel": true, // globals that are usually used for logging poor-man's debugging: console, alert, etc.
"jquery": true, // jquery library
"node": true,
"evil": true
}
language: node_js
node_js:
- '4'
cache:
directories:
- node_modules
- bower_components
install:
- npm install
- bower install
script:
- make build
deploy:
provider: npm
email: sdk@qiniu.com
api_key:
secure: d06l6wsuv/YFeY3E0TRGemGjtQ7LZdN9WxiFnseT2exTFkDgMw9EV2uOUWllXNrbxXUY+2ZpDswtYrgZ4exQGfKKQRGFy6/g8oxPgyylVwBz98vlie8NvXXmANoyt7mwQwjninf5/XUiY3cwn9YCaU1jyxcayFdQTex05T++qvc=
on:
tags: true
all : install build dev
install :
npm install
bower install
build :
npm run build
dev :
npm run watch
node demo/server.js
{
"name": "qiniu",
"description": "Javascript SDK for Qiniu Resource (Cloud) Storage API",
"version": "v1.0.24",
"main": "dist/qiniu.min.js",
"moduleType": [
"globals"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"keywords": [
"cloud",
"storage",
"s3",
"qiniu",
"upload"
],
"authors": "sdk@qiniu.com",
"contributors": [{
"name": "luoyeshu0507",
"email": "lizhiwei@qiniu.com"
}, {
"name": "codedogfish",
"email": "jackyu@qiniu.com"
}, {
"name": "jinxinxin",
"email": "jinxinxin@qiniu.com"
}],
"homepage": "https://github.com/qiniu/js-sdk",
"repository": {
"type": "git",
"url": "git://github.com/qiniu/js-sdk.git"
},
"devDependencies": {
"bootstrap": "~3.3.6",
"highlight": "~8.9.1",
"jquery": "~1.9.1",
"respond": "~1.4.2",
"vue": "^2.2.1"
},
"private": false
}
module.exports = {
'AccessKey': '<Your Access Key>', // https://portal.qiniu.com/user/key
'SecretKey': '<Your Secret Key>',
'Bucket': '<Your Bucket Name>',
'Port': 19110,
'UptokenUrl': 'uptoken',
'Domain': '<Your Bucket Name>' // bucket domain eg:http://qiniu-plupload.qiniudn.com/
};
// jQuery zepto vue angular 等库皆有 progress 的实现 以jQuery为例:
$(function(){
var $key = $('#key'); // file name eg: the file is image.jpg,but $key='a.jpg', you will upload the file named 'a.jpg'
var $userfile = $('#userfile'); // the file you selected
// upload info
var $selectedFile = $('.selected-file');
var $progress = $(".progress");
var $uploadedResult = $('.uploaded-result');
$("#userfile").change(function() { // you can ues 'onchange' here to uplpad automatically after select a file
$uploadedResult.html('');
var selectedFile = $userfile.val();
if (selectedFile) {
// randomly generate the final file name
var ramdomName = Math.random().toString(36).substr(2) + $userfile.val().match(/\.?[^.\/]+$/);
$key.val(ramdomName);
$selectedFile.html('文件:' + selectedFile);
} else {
return false;
}
var f = new FormData(document.getElementById("testform"));
$.ajax({
url: 'http://upload.qiniu.com/', // Different bucket zone has different upload url, you can get right url by the browser error massage when uploading a file with wrong upload url.
type: 'POST',
data: f,
processData: false,
contentType: false,
xhr: function(){
myXhr = $.ajaxSettings.xhr();
if(myXhr.upload){
myXhr.upload.addEventListener('progress',function(e) {
// console.log(e);
if (e.lengthComputable) {
var percent = e.loaded/e.total*100;
$progress.html('上传:' + e.loaded + "/" + e.total+" bytes. " + percent.toFixed(2) + "%");
}
}, false);
}
return myXhr;
},
success: function(res) {
console.log("成功:" + JSON.stringify(res));
var str = '<span>已上传:' + res.key + '</span>';
if (res.key && res.key.match(/\.(jpg|jpeg|png|gif)$/)) {
str += '<img src="' + domain + res.key + '"/>';
}
$uploadedResult.html(str);
},
error: function(res) {
console.log("失败:" + JSON.stringify(res));
$uploadedResult.html('上传失败:' + res.responseText);
}
});
return false;
});
});
\ No newline at end of file
/**
* @license httpPerformance v1.0.0
* License: MIT
* author: luoyeshu0507
*
* @description
*
* This object provides a utility for detailing the http request performance
*
*/
;(function(window, undefined){
'use strict';
var p = window.performance;
var httpPerformance = {
clear: function() {
p.clearMarks && p.clearMarks();
p.clearMeasures && p.clearMeasures();
p.clearResourceTimings && p.clearResourceTimings();
},
getAll: function() {
var performanceArr = [];
p.getEntries().forEach(function(item) {
performanceArr.push(httpPerformance.formatPerformance(item));
});
return performanceArr;
},
getByName: function(name) {
var performanceArr = [];
p.getEntriesByName(name).forEach(function(item) {
performanceArr.push(httpPerformance.formatPerformance(item));
});
return performanceArr;
},
formatPerformance: function(prt) { // PerformanceResourceTiming
return {
redirect: prt.redirectEnd - prt.redirectStart,
domainLookup: prt.domainLookupEnd - prt.domainLookupStart,
connect: prt.connectEnd - prt.connectStart,
request: prt.responseStart - prt.requestStart,
response: prt.responseEnd - prt.responseStart,
entryType: prt.entryType,
initiatorType: prt.initiatorType,
name: prt.name,
duration: prt.duration,
};
}
};
// support AMD and CMD
if (typeof module !== 'undefined' && module.exports) {
module.exports = httpPerformance;
} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
define('httpPerformance', [], function () {
return httpPerformance;
});
} else {
window.httpPerformance = httpPerformance;
}
})(window);
/*global Qiniu */
/*global plupload */
/*global FileProgress */
/*global hljs */
$(function() {
var uploader = Qiniu.uploader({
disable_statistics_report: false,
runtimes: 'html5,flash,html4',
browse_button: 'pickfiles',
container: 'container',
drop_element: 'container',
max_file_size: '1000mb',
flash_swf_url: 'bower_components/plupload/js/Moxie.swf',
dragdrop: true,
chunk_size: '4mb',
multi_selection: !(moxie.core.utils.Env.OS.toLowerCase() === "ios"),
uptoken_url: $('#uptoken_url').val(),
// uptoken_func: function(){
// var ajax = new XMLHttpRequest();
// ajax.open('GET', $('#uptoken_url').val(), false);
// ajax.setRequestHeader("If-Modified-Since", "0");
// ajax.send();
// if (ajax.status === 200) {
// var res = JSON.parse(ajax.responseText);
// console.log('custom uptoken_func:' + res.uptoken);
// return res.uptoken;
// } else {
// console.log('custom uptoken_func err');
// return '';
// }
// },
domain: $('#domain').val(),
get_new_uptoken: false,
//downtoken_url: '/downtoken',
// unique_names: true,
// save_key: true,
// x_vars: {
// 'id': '1234',
// 'time': function(up, file) {
// var time = (new Date()).getTime();
// // do something with 'time'
// return time;
// },
// },
auto_start: true,
log_level: 5,
init: {
'BeforeChunkUpload': function(up, file) {
console.log("before chunk upload:", file.name);
},
'FilesAdded': function(up, files) {
$('table').show();
$('#success').hide();
plupload.each(files, function(file) {
var progress = new FileProgress(file,
'fsUploadProgress');
progress.setStatus("等待...");
progress.bindUploadCancel(up);
});
},
'BeforeUpload': function(up, file) {
console.log("this is a beforeupload function from init");
var progress = new FileProgress(file, 'fsUploadProgress');
var chunk_size = plupload.parseSize(this.getOption(
'chunk_size'));
if (up.runtime === 'html5' && chunk_size) {
progress.setChunkProgess(chunk_size);
}
},
'UploadProgress': function(up, file) {
var progress = new FileProgress(file, 'fsUploadProgress');
var chunk_size = plupload.parseSize(this.getOption(
'chunk_size'));
progress.setProgress(file.percent + "%", file.speed,
chunk_size);
},
'UploadComplete': function() {
$('#success').show();
},
'FileUploaded': function(up, file, info) {
var progress = new FileProgress(file, 'fsUploadProgress');
console.log("response:", info.response);
progress.setComplete(up, info.response);
},
'Error': function(up, err, errTip) {
$('table').show();
var progress = new FileProgress(err.file, 'fsUploadProgress');
progress.setError();
progress.setStatus(errTip);
}
// ,
// 'Key': function(up, file) {
// var key = "";
// // do something with key
// return key
// }
}
});
//uploader.init();
uploader.bind('BeforeUpload', function() {
console.log("hello man, i am going to upload a file");
});
uploader.bind('FileUploaded', function() {
console.log('hello man,a file is uploaded');
});
$('#container').on(
'dragenter',
function(e) {
e.preventDefault();
$('#container').addClass('draging');
e.stopPropagation();
}
).on('drop', function(e) {
e.preventDefault();
$('#container').removeClass('draging');
e.stopPropagation();
}).on('dragleave', function(e) {
e.preventDefault();
$('#container').removeClass('draging');
e.stopPropagation();
}).on('dragover', function(e) {
e.preventDefault();
$('#container').addClass('draging');
e.stopPropagation();
});
$('#show_code').on('click', function() {
$('#myModal-code').modal();
$('pre code').each(function(i, e) {
hljs.highlightBlock(e);
});
});
$('body').on('click', 'table button.btn', function() {
$(this).parents('tr').next().toggle();
});
var getRotate = function(url) {
if (!url) {
return 0;
}
var arr = url.split('/');
for (var i = 0, len = arr.length; i < len; i++) {
if (arr[i] === 'rotate') {
return parseInt(arr[i + 1], 10);
}
}
return 0;
};
$('#myModal-img .modal-body-footer').find('a').on('click', function() {
var img = $('#myModal-img').find('.modal-body img');
var key = img.data('key');
var oldUrl = img.attr('src');
var originHeight = parseInt(img.data('h'), 10);
var fopArr = [];
var rotate = getRotate(oldUrl);
if (!$(this).hasClass('no-disable-click')) {
$(this).addClass('disabled').siblings().removeClass('disabled');
if ($(this).data('imagemogr') !== 'no-rotate') {
fopArr.push({
'fop': 'imageMogr2',
'auto-orient': true,
'strip': true,
'rotate': rotate,
'format': 'png'
});
}
} else {
$(this).siblings().removeClass('disabled');
var imageMogr = $(this).data('imagemogr');
if (imageMogr === 'left') {
rotate = rotate - 90 < 0 ? rotate + 270 : rotate - 90;
} else if (imageMogr === 'right') {
rotate = rotate + 90 > 360 ? rotate - 270 : rotate + 90;
}
fopArr.push({
'fop': 'imageMogr2',
'auto-orient': true,
'strip': true,
'rotate': rotate,
'format': 'png'
});
}
$('#myModal-img .modal-body-footer').find('a.disabled').each(
function() {
var watermark = $(this).data('watermark');
var imageView = $(this).data('imageview');
var imageMogr = $(this).data('imagemogr');
if (watermark) {
fopArr.push({
fop: 'watermark',
mode: 1,
image: 'http://www.b1.qiniudn.com/images/logo-2.png',
dissolve: 100,
gravity: watermark,
dx: 100,
dy: 100
});
}
if (imageView) {
var height;
switch (imageView) {
case 'large':
height = originHeight;
break;
case 'middle':
height = originHeight * 0.5;
break;
case 'small':
height = originHeight * 0.1;
break;
default:
height = originHeight;
break;
}
fopArr.push({
fop: 'imageView2',
mode: 3,
h: parseInt(height, 10),
q: 100,
format: 'png'
});
}
if (imageMogr === 'no-rotate') {
fopArr.push({
'fop': 'imageMogr2',
'auto-orient': true,
'strip': true,
'rotate': 0,
'format': 'png'
});
}
});
var newUrl = Qiniu.pipeline(fopArr, key);
var newImg = new Image();
img.attr('src', 'images/loading.gif');
newImg.onload = function() {
img.attr('src', newUrl);
img.parent('a').attr('href', newUrl);
};
newImg.src = newUrl;
return false;
});
});
/*global Qiniu */
/*global plupload */
/*global FileProgress */
/*global hljs */
$(function() {
var uploader = Qiniu.uploader({
runtimes: 'html5,flash,html4',
browse_button: 'pickfiles',
container: 'container',
drop_element: 'container',
max_file_size: '100mb',
flash_swf_url: 'js/plupload/Moxie.swf',
dragdrop: true,
chunk_size: '4mb',
uptoken_url: $('#uptoken_url').val(),
domain: $('#domain').val(),
auto_start: true,
init: {
'FilesAdded': function(up, files) {
$('table').show();
$('#success').hide();
plupload.each(files, function(file) {
var progress = new FileProgress(file, 'fsUploadProgress');
progress.setStatus("等待...");
});
},
'BeforeUpload': function(up, file) {
var progress = new FileProgress(file, 'fsUploadProgress');
var chunk_size = plupload.parseSize(this.getOption('chunk_size'));
if (up.runtime === 'html5' && chunk_size) {
progress.setChunkProgess(chunk_size);
}
},
'UploadProgress': function(up, file) {
var progress = new FileProgress(file, 'fsUploadProgress');
var chunk_size = plupload.parseSize(this.getOption('chunk_size'));
progress.setProgress(file.percent + "%", file.speed, chunk_size);
},
'UploadComplete': function() {
$('#success').show();
},
'FileUploaded': function(up, file, info) {
var progress = new FileProgress(file, 'fsUploadProgress');
progress.setComplete(up, info);
},
'Error': function(up, err, errTip) {
$('table').show();
var progress = new FileProgress(err.file, 'fsUploadProgress');
progress.setError();
progress.setStatus(errTip);
}
}
});
uploader.bind('FileUploaded', function() {
console.log('hello man,a file is uploaded');
});
var Q2 = new QiniuJsSDK();
var uploader2 = Q2.uploader({
runtimes: 'html5,flash,html4',
browse_button: 'pickfiles2',
container: 'container2',
drop_element: 'container2',
max_file_size: '100mb',
flash_swf_url: 'js/plupload/Moxie.swf',
dragdrop: true,
chunk_size: '4mb',
uptoken_url: $('#uptoken_url').val(),
domain: $('#domain').val(),
auto_start: true,
init: {
'FilesAdded': function(up, files) {
$('table').show();
$('#success').hide();
plupload.each(files, function(file) {
var progress = new FileProgress(file, 'fsUploadProgress');
progress.setStatus("等待...");
});
},
'BeforeUpload': function(up, file) {
var progress = new FileProgress(file, 'fsUploadProgress');
var chunk_size = plupload.parseSize(this.getOption('chunk_size'));
if (up.runtime === 'html5' && chunk_size) {
progress.setChunkProgess(chunk_size);
}
},
'UploadProgress': function(up, file) {
var progress = new FileProgress(file, 'fsUploadProgress');
var chunk_size = plupload.parseSize(this.getOption('chunk_size'));
progress.setProgress(file.percent + "%", file.speed, chunk_size);
},
'UploadComplete': function() {
$('#success').show();
},
'FileUploaded': function(up, file, info) {
var progress = new FileProgress(file, 'fsUploadProgress');
progress.setComplete(up, info);
},
'Error': function(up, err, errTip) {
$('table').show();
var progress = new FileProgress(err.file, 'fsUploadProgress');
progress.setError();
progress.setStatus(errTip);
}
}
});
uploader2.bind('FileUploaded', function() {
console.log('hello man 2,a file is uploaded');
});
$('#container').on(
'dragenter',
function(e) {
e.preventDefault();
$('#container').addClass('draging');
e.stopPropagation();
}
).on('drop', function(e) {
e.preventDefault();
$('#container').removeClass('draging');
e.stopPropagation();
}).on('dragleave', function(e) {
e.preventDefault();
$('#container').removeClass('draging');
e.stopPropagation();
}).on('dragover', function(e) {
e.preventDefault();
$('#container').addClass('draging');
e.stopPropagation();
});
$('#show_code').on('click', function() {
$('#myModal-code').modal();
$('pre code').each(function(i, e) {
hljs.highlightBlock(e);
});
});
$('body').on('click', 'table button.btn', function() {
$(this).parents('tr').next().toggle();
});
var getRotate = function(url) {
if (!url) {
return 0;
}
var arr = url.split('/');
for (var i = 0, len = arr.length; i < len; i++) {
if (arr[i] === 'rotate') {
return parseInt(arr[i + 1], 10);
}
}
return 0;
};
$('#myModal-img .modal-body-footer').find('a').on('click', function() {
var img = $('#myModal-img').find('.modal-body img');
var key = img.data('key');
var oldUrl = img.attr('src');
var originHeight = parseInt(img.data('h'), 10);
var fopArr = [];
var rotate = getRotate(oldUrl);
if (!$(this).hasClass('no-disable-click')) {
$(this).addClass('disabled').siblings().removeClass('disabled');
if ($(this).data('imagemogr') !== 'no-rotate') {
fopArr.push({
'fop': 'imageMogr2',
'auto-orient': true,
'strip': true,
'rotate': rotate,
'format': 'png'
});
}
} else {
$(this).siblings().removeClass('disabled');
var imageMogr = $(this).data('imagemogr');
if (imageMogr === 'left') {
rotate = rotate - 90 < 0 ? rotate + 270 : rotate - 90;
} else if (imageMogr === 'right') {
rotate = rotate + 90 > 360 ? rotate - 270 : rotate + 90;
}
fopArr.push({
'fop': 'imageMogr2',
'auto-orient': true,
'strip': true,
'rotate': rotate,
'format': 'png'
});
}
$('#myModal-img .modal-body-footer').find('a.disabled').each(function() {
var watermark = $(this).data('watermark');
var imageView = $(this).data('imageview');
var imageMogr = $(this).data('imagemogr');
if (watermark) {
fopArr.push({
fop: 'watermark',
mode: 1,
image: 'http://www.b1.qiniudn.com/images/logo-2.png',
dissolve: 100,
gravity: watermark,
dx: 100,
dy: 100
});
}
if (imageView) {
var height;
switch (imageView) {
case 'large':
height = originHeight;
break;
case 'middle':
height = originHeight * 0.5;
break;
case 'small':
height = originHeight * 0.1;
break;
default:
height = originHeight;
break;
}
fopArr.push({
fop: 'imageView2',
mode: 3,
h: parseInt(height, 10),
q: 100,
format: 'png'
});
}
if (imageMogr === 'no-rotate') {
fopArr.push({
'fop': 'imageMogr2',
'auto-orient': true,
'strip': true,
'rotate': 0,
'format': 'png'
});
}
});
var newUrl = Qiniu.pipeline(fopArr, key);
var newImg = new Image();
img.attr('src', 'images/loading.gif');
newImg.onload = function() {
img.attr('src', newUrl);
img.parent('a').attr('href', newUrl);
};
newImg.src = newUrl;
return false;
});
});
var qiniu = require('qiniu');
var express = require('express');
var config = require('./config.js');
var app = express();
app.configure(function() {
app.use(express.static(__dirname + '/'));
});
app.set('views', __dirname + '/views');
app.engine('html', require('ejs').renderFile);
app.use(express.urlencoded());
app.use('/bower_components', express.static(__dirname + '/../bower_components'));
app.use('/src', express.static(__dirname + '/../src'));
app.use('/dist', express.static(__dirname + '/../dist'));
var mac = new qiniu.auth.digest.Mac(config.AccessKey, config.SecretKey);
var options = {
scope: config.Bucket,
deleteAfterDays: 1,
};
var putPolicy = new qiniu.rs.PutPolicy(options);
var bucketManager = new qiniu.rs.BucketManager(mac, null);
app.get('/uptoken', function(req, res, next) {
var token = putPolicy.uploadToken(mac);
res.header("Cache-Control", "max-age=0, private, must-revalidate");
res.header("Pragma", "no-cache");
res.header("Expires", 0);
if (token) {
res.json({
uptoken: token
});
}
});
app.post('/downtoken', function(req, res) {
var key = req.body.key;
var domain = req.body.domain;
//trim '/' if the domain's last char is '/'
if (domain.lastIndexOf('/') === domain.length - 1) {
domain = domain.substr(0, domain.length - 1);
}
var deadline = 3600 + Math.floor(Date.now() / 1000);
var privateDownUrl = bucketManager.privateDownloadUrl(domain, key,
deadline);
res.json({
url: privateDownUrl,
});
});
app.get('/', function(req, res) {
res.render('index.html', {
domain: config.Domain,
uptoken_url: config.UptokenUrl
});
});
app.get('/multiple', function(req, res) {
res.render('multiple.html', {
domain: config.Domain,
uptoken_url: config.UptokenUrl
});
});
app.get('/formdata', function(req, res) {
var token = putPolicy.uploadToken(mac);
res.render('formdata.html', {
domain: config.Domain,
uptoken: token
});
});
app.get('/performance', function(req, res) {
var token = putPolicy.uploadToken(mac);
res.render('performance.html', {
uptoken: token
});
});
app.listen(config.Port, function() {
console.log('Listening on port %d\n', config.Port);
console.log(
'▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ Demos ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽ ▽');
console.log(
' ▹▹▹▹▹▹▹▹▹▹▹▹▹▹▹▹ Upload: http://127.0.0.1:%d ◁ ◁ ◁ ◁ ◁ ◁ ◁',
config.Port);
console.log(
' ▹▹▹▹▹▹▹ Multiple upload: http://127.0.0.1:%d/multiple ◁ ◁ ◁',
config.Port);
console.log(
' ▹▹▹▹▹▹▹ Formdata upload: http://127.0.0.1:%d/formdata ◁ ◁ ◁',
config.Port);
console.log(
' ▹▹▹▹▹▹▹ Up Performance: http://127.0.0.1:%d/performance ◁ ◁',
config.Port);
console.log(
'△ △ △ △ △ △ △ △ △ △ △ △ △ △ △ △ △ △ △ △ △ △ △ △ △ △ △ △ △ △ △ △ △\n'
);
});
#testform{
display: none;
}
body{
padding: 0;
margin:0;
font-family: Tahoma,Arial,Roboto,"Droid Sans","Helvetica Neue","Droid Sans Fallback","Heiti SC",sans-self;
color: #666;
}
.title{
background-color: #0983C7;
line-height: 40px;
text-align: center;
color:#fff;
font-family: '微软雅黑';
}
.container{
width: 100%;
margin:0 auto;
max-width:640px;
background-color: #fff;
border-radius: 10px;
min-height: 600px;
}
label{
display:block;
width: 300px;
height:150px;
margin: 30px auto;
border-radius: 10px;
border:2px dashed #ddd;
overflow: hidden;
cursor: pointer;
}
label span{
display:block;
width:50px;
height:50px;
border-radius: 100%;
border:3px solid #0983C7;
margin:30px auto 15px;
position:relative;
}
label em{
font-style: normal;
text-align: center;
display:block;
}
label span:before, label span:after{
display:block;
content:'';
background-color: #0983C7;
position: absolute;
}
label span:before{
width:3px;
height:30px;
top:10px;
left:24px;
}
label span:after{
width:30px;
height:3px;
top:24px;
left:10px;
}
.selected-file, .progress, .uploaded-result{
line-height: 30px;
margin: 0 20px;
}
.uploaded-result span{
display: block;
}
.uploaded-result img{
display:block;
margin: 20px auto;
width:100%;
max-width: 100%;
}
/*
github.com style (c) Vasily Polovnyov <vast@whiteants.net>
*/
pre code {
display:block;
padding:0.5em;
font:12px Arial;
line-height:2.0em
}
pre .comment,pre .template_comment,pre .diff .header,pre .javadoc {
color:#998;
font-style:italic
}
pre .keyword,pre .css .rule .keyword,pre .winutils,pre .javascript .title,pre .nginx .title,pre .subst,pre .request,pre .status {
//color:#333;
color: #787878;
font-weight:bold
}
pre .number,pre .hexcolor,pre .ruby .constant {
color:#099;
}
pre .string,pre .tag .value,pre .phpdoc,pre .tex .formula {
/*color:#d14*/
color: #409B1C;
}
pre .title,pre .id {
color:#900;
font-weight:bold
}
pre .javascript .title,pre .lisp .title,pre .clojure .title,pre .subst {
font-weight:normal
}
pre .class .title,pre .haskell .type,pre .vhdl .literal,pre .tex .command {
color:#458;
font-weight:bold
}
pre .tag,pre .tag .title,pre .rules .property,pre .django .tag .keyword {
color:#000080;
font-weight:normal
}
pre .attribute,pre .variable,pre .lisp .body {
/*color:#008080*/
color: #FF7800;
}
pre .regexp {
color:#009926
}
pre .class {
color:#458;
font-weight:bold
}
pre .symbol,pre .ruby .symbol .string,pre .lisp .keyword,pre .tex .special,pre .prompt {
color:#990073
}
pre .built_in,pre .lisp .title,pre .clojure .built_in {
color:#0086b3
}
pre .preprocessor,pre .pi,pre .doctype,pre .shebang,pre .cdata {
color:#999;
font-weight:bold
}
pre .deletion {
background:#fdd
}
pre .addition {
background:#dfd
}
pre .diff .change {
background:#0086b3
}
pre .chunk {
color:#aaa
}
body {
font-family: '微软雅黑';
overflow: scroll;
}
h1 {
border-bottom: 1px solid #d2d2d2;
padding-bottom: 15px;
position: relative;
font-weight: bold;
margin-bottom: 15px;
font-family: '微软雅黑';
}
h3,h4 {
color: #d2d2d2;
font-family: '微软雅黑',"Helvetica Neue", Helvetica, Arial, sans-serif;
}
h1 .view_github {
display: block;
font-size: 14px;
line-height: 30px;
position: absolute;
right: 0;
bottom: 0;
border: 1px solid #d2d2d2;
border-bottom: none;
border-radius:0;
}
h1 .view_github:hover,h1 .view_code:hover {
background-color: #f5f5f5;
}
h1 .view_code {
display: block;
font-size: 14px;
line-height: 30px;
position: absolute;
right: 225px;
bottom: 0;
border: 1px solid #d2d2d2;
border-bottom: none;
border-radius:0;
height: 45px;
}
.col-md-12.no-padding {
padding-left:0;
padding-right:0;
}
.info {
position: relative;
height: 100%;
}
tr .progress{
width: 96%;
display: inline-block;
}
tr .progress-bar {
min-height: 20px;
float: none;
}
tr .progress, tr .progress div {
height: 20px;
}
tr .progress .chunk-status {
position: absolute;
left: 24px;
top: 0;
}
tr .progressCancel{
display: inline-block;
float: right;
position: relative;
z-index: 100;
color: #333;
text-decoration: none;
}
.status {
position: absolute;
width: 100%;
top:0;
left: 24px;
}
.tip {
padding-left: 30px;
}
.tip p {
line-height: 1;
}
#container {
margin-bottom: 20px;
border-width: 2px;
border-radius: 3px;
border-color: #dcdcdc;
cursor: default;
}
#container:hover,#container:active {
background-color:#fff;
border-color: #dcdcdc;
-webkit-box-shadow:none;
box-shadow:none;
}
#container.draging {
background-color:#fff;
border-color:#999999;
}
#success {
line-height: 30px;
height: 30px;
margin:20px 0 0 0;
}
#success div {
padding-left: 24px;
}
#container a {
width: 15%;
min-width: 145px;
}
button {
border-radius: 3px;
-webkit-box-shadow: 0 1px 0 rgba(243, 243, 243, 0.75);
box-shadow: 0 1px 0 rgba(243, 243, 243, 0.75);
color: #646464;
border: 1px solid #d2d2d2;
text-align: center;
-webkit-transition: background-color 0.218s, border-color 0.218s, box-shadow 0.218s;
transition: background-color 0.218s, border-color 0.218s, box-shadow 0.218s;
-webkit-user-select: none;
outline: none;
}
td .Wrapper {
margin-top: 20px;
text-align: center;
overflow: hidden;
}
td .Wrapper .infoWrapper{
width:50%;
height:100px;
margin-left: 10px;
text-align: left;
line-height: 25px;
}
td .Wrapper .infoWrapper a:first-child{
margin-right: 10px;
}
td .Wrapper.default {
margin-top: 20px;
text-align: left;
}
td .Wrapper.default img{
width:100px;
height:100px;
}
td .imgWrapper {
position: relative;
width:100px;
height: 100px;
}
td .imgWrapper .linkWrapper {
position: absolute;
left: 15px;
top: 0;
width:100px;
height: 100px;
cursor: pointer;
}
td .imgWrapper .linkWrapper a{
line-height: 50px;
}
table td .hash {
margin-bottom: 20px;
}
pre {
margin-top: 20px;
}
.container .modal-dialog {
width: 45%;
}
.container .modal-dialog .modal-content {
max-height: 90%;
}
.container .modal-dialog .modal-body img{
max-width: 95%;
max-height: 70%;
}
.container .modal-body-footer , .container .modal-body-footer div{
margin-top: 10px;
margin-bottom: 10px;
}
.container .modal-dialog .modal-body-footer {
margin-top: 0px;
}
.container .modal-dialog .modal-body-footer span {
margin-right: 20px;
}
.container .modal-dialog .modal-body-footer .text-warning,.container .modal-dialog .modal-footer span ,.container .modal-dialog .modal-footer a{
font-size: 12px;
}
.body .btn-default {
border-radius: 3px;
-webkit-box-shadow: 0 1px 0 rgba(243, 243, 243, 0.75);
box-shadow: 0 1px 0 rgba(243, 243, 243, 0.75);
color: #646464;
border: 1px solid #d2d2d2;
text-align: center;
-webkit-transition: background-color 0.218s, border-color 0.218s, box-shadow 0.218s;
transition: background-color 0.218s, border-color 0.218s, box-shadow 0.218s;
-webkit-user-select: none;
outline: none;
}
.body .btn-default:hover,.body .btn-default:active,.body .btn-default:focus ,.no-padding button:hover,.no-padding button:active,.no-padding button:focus{
border-color: #bebebe;
text-decoration: none;
background-color: #fff;
color: #262626;
outline: none;
-webkit-box-shadow: 0 1px 0 rgba(230, 230, 230, 0.8);
box-shadow: 0 1px 0 rgba(230, 230, 230, 0.8);
}
a {
cursor: pointer;
}
#testform{
display: none;
}
body{
padding: 0;
margin:0;
font-family: core, "Avenir Next", "Helvetica Neue", Helvetica, Arial, "Source Han Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi MicroHei", sans-serif;
color: #666;
font-size: 14px;
background: url('http://assets.qiniu.com/v2/qiniu-blue-195x105.png') no-repeat #1DA4DE;
}
ul,li {
padding: 0;
margin: 0;
}
td, th{
border: 0 none;
border-bottom: 1px solid #f0f0f0;
}
.hidden{
display: none;
}
.show {
display: inherit;
}
.title{
background-color: #0983C7;
line-height: 40px;
text-align: center;
color:#fff;
}
.container{
width: 100%;
margin:0 auto;
max-width:640px;
background-color: #fff;
border-radius: 10px;
min-height: 530px;
overflow: hidden;
padding-bottom: 30px;
}
.uploaded-result{
line-height: 30px;
margin: 0 20px;
}
.uploaded-result th{
text-align: left;
}
.uploaded-result table {
width: 100%;
word-break: break-all;
}
#canvas{
display:none;
}
.progress{
padding: 20px 20px;
color: #108ee9;
line-height: 26px;
}
.warning{
color: #f0ad4e;
font-weight: normal;
font-size: 12px;
}
.run{
display: block;
width: 120px;
line-height: 26px;
background-color: #1992ea;
border-radius: 6px;
margin: 20px auto;
text-align: center;
color: #fff;
text-decoration: none;
cursor: pointer;
font-size: 14px;
}
.run:hover{
background-color: #1DA4DE;
}
.disabled, .disabled:hover{
background-color: #aaa;
}
.uphosts-list li{
list-style: none;
font-size: 14px;
}
.uphosts-list ul:first-of-type{
text-align: center;
height: 27px;
line-height: 26px;
margin: 20px;
border-bottom: 1px solid #d9d9d9;
}
.uphosts-list ul:first-of-type li{
float: left;
width: 50px;
margin: 0 10px;
cursor: pointer;
}
.uphosts-list ul:first-of-type li.on{
color: #108ee9;
border-bottom: 2px solid #108ee9;
}
.uphosts-list ul:last-child{
margin: 20px;
}
.uphosts-list ul:last-child li{
display: none;
}
.uphosts-list ul:last-child li.on{
display: block;
}
.uphosts-list ul:last-child li label{
display: inline-block;
width: 50%;
padding: 6px 0;
cursor: pointer;
}
.up-performance{
margin-bottom: 20px;
}
.per-title{
font-weight: bold;
color: #108ee9;
}
.up-headers{
}
.up-headers tr td:first-child{
width: 120px;
}
@media screen and (min-width: 640px){
.container{
margin-top:50px;
}
}
@media screen and (max-width: 640px){
body{
background-color:#fff;
}
.uphosts-list ul:last-child li label{
width: 100%;
}
.container{
border-radius: 0;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>七牛云 - formdata 上传 demo</title>
<link rel="stylesheet" href="../styles/formdata.css">
<script src="../../bower_components/jquery/jquery.min.js"></script>
<script src="../scripts/formdata.js"></script>
<script>
var domain = "<%= domain %>"; // you bucket domain eg: http://xxx.bkt.clouddn.com
</script>
</head>
<body>
<div class="container">
<div class="title">Formdata 上传 demo</div>
<!-- Document:https://developer.qiniu.com/kodo/manual/form-upload -->
<form id="testform" method="post" enctype="multipart/form-data">
<input name="key" id="key" type="hidden" value="">
<input name="token" type="hidden" value="<%= uptoken %>">
<input id="userfile" name="file" type="file" />
<!-- take photo with phone -->
<!-- <input id="userfile" name="file" accept="image/*" type="file" /> -->
<!-- take video with phone -->
<!-- <input id="userfile" name="file" type="file" accept="video/*"/> -->
<input name="accept" type="hidden" />
</form>
<!-- add file -->
<label for="userfile">
<span></span>
<em>添加文件</em>
</label>
<!-- upload info -->
<div class="selected-file"></div>
<div class="progress"></div>
<div class="uploaded-result"></div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<link rel="stylesheet" href="styles/performance.css">
<title>七牛云 - 上传速度检测</title>
</head>
<body>
<div id="app" class="container">
<div class="title">七牛云上传速度检测</div>
<form id="testform" method="post" enctype="multipart/form-data">
<input name="key" id="key" type="hidden" value="a.jpg">
<input name="accept" type="hidden" />
</form>
<zone-list :host-map="hostMap" :current-zone="currentZone" :switch-zone="switchZone" :selected-host="selectedHost"></zone-list>
<span class="run" :class="{'disabled': !selectedHost.host}" @click="uploadTest">开始检测</span>
<!-- upload info -->
<div class="progress">{{loadMessage}}</div>
<div class="uploaded-result">
<upload-performance :per='performance' v-if="performance" :warning="!isPerformanceSupported"></upload-performance>
<up-headers :headers="headers" v-if="headers"></up-headers>
</div>
</div>
<script src="scripts/http-performance.js"></script>
<script src="bower_components/vue/dist/vue.min.js"></script>
<script src="scripts/performance.js"></script>
</body>
</html>
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "qiniu-js",
"jsName": "qiniu",
"version": "1.0.24",
"private": false,
"scripts": {
"start": "node demo/server.js",
"watch": "webpack --watch",
"build": "webpack"
},
"description": "Javascript SDK for Qiniu Resource (Cloud) Storage API",
"main": "dist/qiniu.min.js",
"repository": {
"type": "git",
"url": "git://github.com/qiniu/js-sdk.git"
},
"bugs": {
"url": "https://github.com/qiniu/js-sdk/issues"
},
"keywords": [
"cloud",
"storage",
"s3",
"qiniu",
"web-service"
],
"author": "sdk@qiniu.com",
"contributors": [
{
"name": "luoyeshu0507",
"email": "lizhiwei@qiniu.com"
},
{
"name": "codedogfish",
"email": "jackyu@qiniu.com"
},
{
"name": "jinxinxin",
"email": "jinxinxin@qiniu.com"
}
],
"devDependencies": {
"bower": "^1.6.8",
"ejs": "~2.5.5",
"express": "^3.4.8",
"grunt": "~0.4.2",
"grunt-cli": "~0.1.13",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-jshint": "~0.7.2",
"grunt-contrib-uglify": "~0.2.2",
"grunt-contrib-watch": "~0.5.3",
"open-browser-webpack-plugin": "0.0.5",
"qiniu": "~7.0.5",
"webpack": "^3.8.1",
"webpack-dev-middleware": "^1.12.0"
},
"license": "MIT"
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: path.resolve(__dirname, 'src/qiniu.js'),
output: {
path: path.resolve(__dirname, 'dist/'),
filename: 'qiniu.min.js',
},
devtool: 'inline-source-map',
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
]
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment