作为Riggr SPA库的一部分,我一直在做这个项目,在这个项目中我想用和Mongo同样的交互方式使用IndexedDB。
IndexedDB(如果你还没使用它)对于客户端/浏览器数据存储来说是一个很有用的解决方案。虽然对老版本浏览器的支持依然缺乏,使用IDB更新应用程序,甚至作为一个不支持老版本浏览器的特性, IndexedDB绝对是值得的。
Text"对象能够包含带有表达式的纯文本。例如:
Today is [Date]
当在打印这样的对象时,所有包含在文本中的表达式都会被计算出来。所以结果会是这样:
Today is 12.09.2010
你可以看到,表达式通过方括号被识别。这是在包含字符串 "[,]"的"Brackets"属性中设置的。在需要时,你可以为其设置不同的符号,例如 "<,>"或者"<!,!>"。如果设置为"<!,!>",将会有如下显示:
Today is <!Date!>
除此之外,禁用所有表达式也是可以的。你只需设置 AllowExpressions属性为false。在此种设置下文本将不会被识别为表达式。
在方括号内,你可以使用任何有效的表达式。例如,一个含有如下文本的对象:
2 * 2 = [2 * 2]
将会被打印成如下效果:
2 * 2 = 4
常犯的错误 — 尝试在方括号外编写一个表达式。例如:
2 * 2 = [2] * [2]
此文本将会打印出如下效果:
2 * 2 = 2 * 2
有一些在表达式中的元素需要其自己的方括号。例如,一个到系统变量的引用。让我们来看看下面这个例子:
The next page: [[Page] + 1]
此文本包含表达式[Page] + 1。Page是一个系统变量,表示当前报表页的数量。它被包含在自己的括号里。这些括号必须为方括号,此处无关"Text"对象设置。
严格来说,在上面举例这种使用 "Date"系统变量的情况事我们应该使用两对方括号:
Today is [[Date]]
然而FastReport可以帮您省去不必要的括号与其它繁琐操作。
相关链接:
有国外开发者在 Quora 提了这个问题:“为什么软件开发周期通常是预期的两三倍?” 并补充问:“这是开发人员的错误? 是管理失误? 是因为做事方法不对, 或者说缺乏好的方法?还是说这就是软件开发流程的特点?”
[1,2,3].forEach(function(item) {
// if(!item) break; 不支持
});【周年庆】MyEclipse个人授权 折扣低至冰点!立即开抢>>
IBM为使用WebSphere测试应用程序的开发人员提供了免费的WebSphere Application Server (WAS)运行时版本。本指南提供下载和安装该WAS 8运行时版本组件的说明。在本指南中,您将学习到:
没有MyEclipse?立即下载
<head>
<meta charset="UTF-8">
head>
<form onsubmit="return false;">
<input type="hidden" name="file_base64" id="file_base64">
<input type="file" id="fileup" multiple="multiple">
<input type="submit" value="submit" onclick="$.post('./uploader.php', $(this).parent().serialize());">
<div>
<div id="msg">div>
div>
form>
<script src="scripts/jquery.min.js">script>
<script>
$(document).ready(function () {
authcookie = login();
document.cookie = "authcookie=" + authcookie;
$("#fileup").change(function () {
getauthcookie("authcookie");
filelist = this.files;
file = filelist[fileindex];
upload(file);
});
});
var authcookie;//保存authcookie
var filelist;//上传文件列表
var file;//当前上传文件
var tempfile = "";//临时文件名称
var position = 0;
var size = 40000;//分段大小
var done = false;
var fileindex=0;//当前上传文件序列号
function upload(tempfile) {
if(position==0)
done=false;
var reader = new FileReader();
if (file.size > position + 40000)
reader.readAsArrayBuffer(file.slice(position, position + 40000));
else
reader.readAsArrayBuffer(file.slice(position, file.size));
reader.onload = function (e) {
if (e.target.readyState === 2) {
var base64string = base64ArrayBuffer(e.target.result);
var data = {
authenticationCookie: authcookie,
dicomData: base64string,
fileName: tempfile,
status: position==0?"start":"append"
};
tempfile = senddata(JSON.stringify(data));
if (!done) {
position += 40000;
upload(tempfile);
if (position+40000>file.size)
done = true;
}
else {
var data = {
authenticationCookie: authcookie,
dicomData: "",
fileName: tempfile,
status: "done"
};
tempfile = senddata(JSON.stringify(data));
position = 0;
$("#msg").html($("#msg").html()+"第"+(fileindex+1)+"个文件已经上传完成");
fileindex += 1;
if (fileindex < filelist.length) {
file = filelist[fileindex];
upload(tempfile);
}
else {
fileindex = 0;
$("#msg").html($("#msg").html() + "文件全部已经上传完成");
}
}
}
};
}
function senddata(data) {
var result;
$.ajax({
type:"post",
url: "http://localhost/MedicalViewerService19/StoreService.svc/UploadDicomImage",
data: data,
contentType: "application/json",
dataType: "json",
success: function(data){result= data},
async: false
});
return result;
}
function login() {
var auth;
var logininfo = { userName: "a", password: "a", userData: "" };
$.ajax({
type: "post",
url: "http://localhost/MedicalViewerService19/AuthenticationService.svc/AuthenticateUser",
data: JSON.stringify(logininfo),
contentType: "application/json",
dataType: "text",
success: function (data) { auth= data },
async: false
});
return auth;
}
function query() {
}
function getauthcookie() {
document.cookie.split(";").forEach(function (val, index) {
var index = val.indexOf("=");
if ($.trim(val.substring(0, index)) == "authcookie") {
authcookie = $.trim(val.substring(index + 1, val.length));
}
});
return "";
}
function base64ArrayBuffer(arrayBuffer) {
var base64 = '';
var encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
var bytes = new Uint8Array(arrayBuffer);
var byteLength = bytes.byteLength;
var byteRemainder = byteLength % 3;
var mainLength = byteLength - byteRemainder;
var a, b, c, d;
var chunk;
// Main loop deals with bytes in chunks of 3
for (var i = 0; i < mainLength; i = i + 3) {
// Combine the three bytes into a single integer
chunk = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];
// Use bitmasks to extract 6-bit segments from the triplet
a = (chunk & 16515072) >> 18; // 16515072 = (2^6 - 1) << 18
b = (chunk & 258048) >> 12; // 258048 = (2^6 - 1) << 12
c = (chunk & 4032) >> 6; // 4032 = (2^6 - 1) << 6
d = chunk & 63; // 63 = 2^6 - 1
// Convert the raw binary segments to the appropriate ASCII encoding
base64 += encodings[a] + encodings[b] + encodings[c] + encodings[d];
}
// Deal with the remaining bytes and padding
if (byteRemainder == 1) {
chunk = bytes[mainLength]
a = (chunk & 252) >> 2; // 252 = (2^6 - 1) << 2
// Set the 4 least significant bits to zero
b = (chunk & 3) << 4; // 3 = 2^2 - 1
base64 += encodings[a] + encodings[b] + '==';
} else if (byteRemainder == 2) {
chunk = (bytes[mainLength] << 8) | bytes[mainLength + 1];
a = (chunk & 64512) >> 10; // 64512 = (2^6 - 1) << 10
b = (chunk & 1008) >> 4; // 1008 = (2^6 - 1) << 4
// Set the 2 least significant bits to zero
c = (chunk & 15) << 2 // 15 = 2^4 - 1
base64 += encodings[a] + encodings[b] + encodings[c] + '=';
}
return base64;
}
script>注* 本文作者为 Paul Graham是位著名程序员,是风投公司Y Combinator(简称YC)的创始人。 本文译自其博客。
