結果在IE8測試下有個地方沒反應,
查了一下是建立元素的時候沒有結尾。
//會爆掉!!
// var $anchor = $("<a data-id='" + nodeData.id + "'>");
var $anchor = $("<a data-id='" + nodeData.id + "'></a>");
//會爆掉!!
// var $anchor = $("<a data-id='" + nodeData.id + "'>");
var $anchor = $("<a data-id='" + nodeData.id + "'></a>");
(function(a){a.console=function(a){"undefined"!=typeof window.console&&console.log(a)}})(jQuery);
@GET
@Path("/download/{store_type}/{store_id}/{uuid}/{obj_name}")
public Response downloadObject(@Context HttpServletRequest request,
@Context HttpServletResponse response,
@PathParam(value = "store_type") String store_type,
@PathParam(value = "store_id") String store_id,
@PathParam(value = "uuid") String uuid,
@PathParam(value = "obj_name") String obj_name,
@QueryParam(value = "alf_ticket") String alf_ticket){
//...省略很多
String downloadlink = "http://test.jpg";
URI reidrectURI = null;
try{
reidrectURI = URI.create(downloadlink );
return Response.seeOther(reidrectURI).build();
}catch(IllegalArgumentException illaEx){
illaEx.printStackTrace();
JSONObject resp = new JSONObject();
resp.put("statuscode", 500);
resp.put("link", originalAlfDownloadLink);
ResponseBuilder builder =
Response.status(Response.Status.INTERNAL_SERVER_ERROR).type(MediaType.APPLICATION_JSON);
builder.entity(resp.toString());
Response respBuilder = builder.build();
return respBuilder;
}
}
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace()
The last element of the array represents the bottom of the stack, which is the least recent method invocation in the sequence.
StackTraceElement has getClassName(), getFileName(), getLineNumber() andgetMethodName().stackTraceElements[1] or[2]).this object, which the prototype methods (along with everything else)will have access to.function Dog(_dogName){
var that = this;
var dogname = _dogName || "dog" ;//default setting
that._getName = function(){
return dogname;
};
that._setName = function(newName){
dogname = newName;
};
};
//use getName to access private member
Dog.prototype.getName = function(){
return this._getName();
};
Dog.prototype.setName = function(newName){
return this._setName(newName);
};
var myDog = new Dog();
console.log("mydog:" + myDog.getName());
var tomDog = new Dog("tom");
console.log("tomDog:" + tomDog.getName());
tomDog.setName("mary");
console.log("tomDog2:" + tomDog.getName());
//移除qtip2
$.validator.prototype.qtipDestory = function(element){
if( $(element).valid()){
$(element).filter(".valid").qtip("destroy");
}
};
//顯示qtip2
$.validator.prototype.qtip = function(error,element,my,at){
// Set positioning based on the elements position in the form
var elem = $(element),
corners = ["right center", "bottom left"],
flipIt = elem.parents("span.right").length > 0;
if(my == "undefined" && at != "undefined"){
corners = [my,at];
}
// Check we have a valid error message
if(!error.is(":empty")) {
// Apply the tooltip only if it isn"t valid
elem.filter(":not(.valid)").qtip({
overwrite: false,
content: error,
position: {
my: corners[ flipIt ? 0 : 1 ],
at: corners[ flipIt ? 1 : 0 ],
viewport: $(window)
},
show: {
event: false,
ready: true
},
hide: false,
style: {
classes: "qtip-red" // Make it red... the classic error colour!
}
})
// If we have a tooltip on this element already, just update its content
.qtip("option", "content.text", error);
}
// If the error is empty, remove the qTip
else { elem.qtip("destroy"); }
}
...省略
errorPlacement:function(error,element){
$your_validated.qtip(error,element);
},
//驗證成功會把qtip消除
success:$.noop,
//別忘了reset
$your_validated.resetForm();
$(".qtip").each(function(){
$(this).data("qtip").destroy();
})
$(form).ajaxSubmit({
url: apiEndpoint,
type: "post",
// data: postData,
dataType: "json",
beforeSubmit: function(arr, $form, options){
//The array of form data takes the following form:
//$.console(arr);
arr[arr.length] = { name:"draft", value:draft};
}
});
//清掉資料
$.data("your_key",null)
//判斷資料還存不存在,如果沒存過第一次是會找到undefined!!
var queryUserData = $.data("your_key",null)
if(typeof (queryUserData) == "undefined" || queryUserData == null){
//做你要幹的事
//.....
}
$parentNode.delegate("li","click",function(event){
var $currLI = $(this);
if($currLI.hasClass("select_this")){
//unselected
$.console("[UserList.render] delegate:unselected user");
if(event.shiftKey){
//just unselected
$currLI.removeClass("select_this");
}else{
//re-locate last selected/unselected
$currLI.removeClass("select_this");
$currLI.addClass("last_selected");
$lastSelected.removeClass("last_selected");
//change last selected
$lastSelected = $currLI;
}
}else{
//selected
$.console("[UserList.render] delegate:selected user");
//
// SHIFT + CLICK
//
var $shiftSelected = [];//record seleted items by shfit key
if(event.shiftKey){
//shift + click logic
if($lastSelected.length > 0){//first click
if($lastSelected == $currLI){
$.console("[UserList.render] same selection");
return false;
}else{
//detect foward or back
direction = $currLI.nextAll(".last_selected").length > 0 ? "forward" : "back";
$.console("[UserList.render] last_selected count:" + $currLI.nextAll(".last_selected").length);
$.console("[UserList.render] direction:" + direction);
if(direction == "forward"){
$shiftSelected = $currLI.nextUntil($lastSelected);
}else{
//back
$shiftSelected = $lastSelected.nextUntil($currLI);
}
// $.console("$shiftSelected:" + $shiftSelected.length);
$LICollection.removeClass("select_this");//reset pre selected
//final selected items
$shiftSelected.addClass("select_this");//highlight shift selected
$lastSelected.addClass("select_this");//highlight last selected
$currLI.addClass("select_this");//highlight current selected
}
}else{
$lastSelected = $currLI;
$currLI.addClass("select_this last_selected");
}
}else{
//record last selected
$lastSelected = $currLI;
$currLI.addClass("select_this last_selected");
}
}
//for debug
// $.console("lastselected username:" + $lastSelected.find(".usr_name").html());
if(userlist.selecteEventHandler && typeof(userlist.selecteEventHandler) === "function"){
userlist.selecteEventHandler($currLI,userlist.getSelectedItems());
}
});
//userElem為html tag $(userElem).hide().appendTo($parentNode).fadeIn(1000);
function main()
{
var filter = args["filter"];
}
function main()
{
// Get the user name of the person to get
var userName = url.extension;
}
function main(){
//invalid input
if(!json.has("users")){
status.setCode(status.STATUS_BAD_REQUEST, "The request body format is error.");
return;
}
var usersIndex ;
var users = json.get("users");//json array
for (usersIndex = 0; usersIndex < users.length(); usersIndex++){
//Get user val
var currentUser = users.get(usersIndex);
}
/user/{userid}
/alfresco/service/user/fred?profile=full&format=html
<filter-mapping>
<filter-name>theFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
web.xml to exclude a more specific pattern such as: /public/*.<filter>
<filter-name>theFilter</filter-name>
<filter-class>org.demo.CustomServletFilter</filter-class>
<init-param>
<param-name>excludePatterns</param-name>
<param-value>public/*</param-value>
</init-param>
</filter>
public void init(FilterConfig cfg) throws ServletException { this.excludePatterns = cfg.getInitParameter("excludePatterns"); . . . } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { String url = request.getRequestURL().toString(); if (matchExcludePatterns(url)) { chain.doFilter(request, response); return; } . . . }
//dom api
document.getElementById('dllink').click();
//jquery api
$("#dllink")[0].click();
$("#myform").validate();
$("a.check").click(function() {
alert("Valid: " + $("#myform").valid());
return false;
});
setTimeout method has a delay of 1ms. This is just to add the function into the UI queue. Since setTimeout runs asynchronously the Javascript interpreter will continue by directly calling thereturn statement, which in turn triggers the browsers modal dialog. This will block the UI queue and the code from the first setTimeout is not executed, until the modal is closed. If the user pressed cancel, it will trigger another setTimeout which fires in about one second. If the user confirmed with ok, the user will redirect and the second setTimeout is never fired.$(function(){
$(window).bind("beforeunload", function(e) {
setTimeout(function() {
setTimeout(function() {
$("body").css('background-color', 'red').html("User click cancel button");
}, 1000);
},1);
return 'are you sure';
});
//按ok處理
$(window).unload( function () {
console.log('bye bye :)');
} );
});
public static boolean isValidName(String text)
{
Pattern pattern = Pattern.compile(
"# Match a valid Windows filename (unspecified file system). \n" +
"^ # Anchor to start of string. \n" +
"(?! # Assert filename is not: CON, PRN, \n" +
" (?: # AUX, NUL, COM1, COM2, COM3, COM4, \n" +
" CON|PRN|AUX|NUL| # COM5, COM6, COM7, COM8, COM9, \n" +
" COM[1-9]|LPT[1-9] # LPT1, LPT2, LPT3, LPT4, LPT5, \n" +
" ) # LPT6, LPT7, LPT8, and LPT9... \n" +
" (?:\\.[^.]*)? # followed by optional extension \n" +
" $ # and end of string \n" +
") # End negative lookahead assertion. \n" +
"[^<>:\"/\\\\|?*\\x00-\\x1F]* # Zero or more valid filename chars.\n" +
"[^<>:\"/\\\\|?*\\x00-\\x1F\\ .] # Last char is not a space or dot. \n" +
"$ # Anchor to end of string. ",
Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.COMMENTS);
Matcher matcher = pattern.matcher(text);
boolean isMatch = matcher.matches();
return isMatch;
}
Date.parse method is implementation dependent, on ECMAScript 5, this method can parse ISO8601 formatted dates, but I would recommend you to make the parsing manually.function parseDate(input, format) {
format = format || 'yyyy-mm-dd'; // default format
var parts = input.match(/(\d+)/g),
i = 0, fmt = {};
// extract date-part indexes from the format
format.replace(/(yyyy|dd|mm)/g, function(part) { fmt[part] = i++; });
return new Date(parts[fmt['yyyy']], parts[fmt['mm']]-1, parts[fmt['dd']]);
}
parseDate('06.21.2010', 'mm.dd.yyyy');
parseDate('21.06.2010', 'dd.mm.yyyy');
parseDate('2010/06/21', 'yyyy/mm/dd');
parseDate('2010-06-21');
Date.prototype.toISOString is available, e.g.:if (typeof Date.prototype.toISOString == "function") {
// ES5 ISO date parsing available
}
public void execute(WebScriptRequest req, WebScriptResponse response) {
InputStream inputBody = req.getContent().getInputStream();
String requestBody = RequestBODY.get(inputBody,Charset.forName("utf-8"));
//requestBody:{"parentUUID":"23d97062-5310-4b80-864a-a2232238fd11","uuids":[]}
System.out.println("requestBody:" + requestBody);
}
function notWatermark(value, element){
return value != 'enter text...';
}
$.validator.addMethod("notWatermark", notWatermark, "Field cannot be empty.");
$('#SearchForm').validate({
rules: {
SomeField: {
required: true,
notWatermark: true
}
},
var browserVersionFullNumber = $.getBrowserVersion(); var myRegexp = /([\d]+)/g; var match = myRegexp.exec(browserVersionFullNumber); browserVersion = match[1]; // abc
var expiredDate = $(obj).text();
$.console("pre expiredDate:" + expiredDate);
expiredDate = expiredDate.replace(/-/g,"/");
$.console("expiredDate:" + expiredDate);
var bmExpiredDate = new Date(Date.parse(expiredDate));
$.console(bmExpiredDate);
輸出的結果:var dropzone = document.getElementById('dropzone');
dropzone.ondrop = function(e) {
var length = e.dataTransfer.files.length;
for (var i = 0; i < length; i++) {
var file = e.dataTransfer.files[i];
... // do whatever you want
}
};
dropzone.ondrop = function(e) {
var length = e.dataTransfer.items.length;
for (var i = 0; i < length; i++) {
var entry = e.dataTransfer.items[i].webkitGetAsEntry();
if (entry.isFile) {
... // do whatever you want
} else if (entry.isDirectory) {
... // do whatever you want
}
}
};
Entry (FileEntry or DirectoryEntry) by using new function called getAsEntry (webkitGetAsEntry).Entry object, you can use standard file handling methods that were introduced in the FileSystem API specification. For example, this example shows how you can detect if a dropped object is a file or a directory by examining the .isFile(or the .isDirectory) field.