Propchange:
incubator/directmemory/trunk/server/directmemory-server-archetype/src/main/resources/archetype-resources/src/main/webapp/js/jquery-1.7.1.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/directmemory/trunk/server/directmemory-server-archetype/src/main/resources/archetype-resources/src/main/webapp/js/jquery-1.7.1.js
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
incubator/directmemory/trunk/server/directmemory-server-archetype/src/main/resources/archetype-resources/src/main/webapp/js/jquery-tmpl.js
URL:
http://svn.apache.org/viewvc/incubator/directmemory/trunk/server/directmemory-server-archetype/src/main/resources/archetype-resources/src/main/webapp/js/jquery-tmpl.js?rev=1294886&view=auto
==============================================================================
---
incubator/directmemory/trunk/server/directmemory-server-archetype/src/main/resources/archetype-resources/src/main/webapp/js/jquery-tmpl.js
(added)
+++
incubator/directmemory/trunk/server/directmemory-server-archetype/src/main/resources/archetype-resources/src/main/webapp/js/jquery-tmpl.js
Tue Feb 28 23:08:18 2012
@@ -0,0 +1,484 @@
+/*!
+ * jQuery Templates Plugin 1.0.0pre
+ * http://github.com/jquery/jquery-tmpl
+ * Requires jQuery 1.4.2
+ *
+ * Copyright Software Freedom Conservancy, Inc.
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ */
+(function( jQuery, undefined ){
+ var oldManip = jQuery.fn.domManip, tmplItmAtt = "_tmplitem", htmlExpr =
/^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,
+ newTmplItems = {}, wrappedItems = {}, appendToTmplItems,
topTmplItem = { key: 0, data: {} }, itemKey = 0, cloneIndex = 0, stack = [];
+
+ function newTmplItem( options, parentItem, fn, data ) {
+ // Returns a template item data structure for a new rendered
instance of a template (a 'template item').
+ // The content field is a hierarchical array of strings and
nested items (to be
+ // removed and replaced by nodes field of dom elements, once
inserted in DOM).
+ var newItem = {
+ data: data || (data === 0 || data === false) ? data :
(parentItem ? parentItem.data : {}),
+ _wrap: parentItem ? parentItem._wrap : null,
+ tmpl: null,
+ parent: parentItem || null,
+ nodes: [],
+ calls: tiCalls,
+ nest: tiNest,
+ wrap: tiWrap,
+ html: tiHtml,
+ update: tiUpdate
+ };
+ if ( options ) {
+ jQuery.extend( newItem, options, { nodes: [], parent:
parentItem });
+ }
+ if ( fn ) {
+ // Build the hierarchical content to be used during
insertion into DOM
+ newItem.tmpl = fn;
+ newItem._ctnt = newItem._ctnt || newItem.tmpl( jQuery,
newItem );
+ newItem.key = ++itemKey;
+ // Keep track of new template item, until it is stored
as jQuery Data on DOM element
+ (stack.length ? wrappedItems : newTmplItems)[itemKey] =
newItem;
+ }
+ return newItem;
+ }
+
+ // Override appendTo etc., in order to provide support for targeting
multiple elements. (This code would disappear if integrated in jquery core).
+ jQuery.each({
+ appendTo: "append",
+ prependTo: "prepend",
+ insertBefore: "before",
+ insertAfter: "after",
+ replaceAll: "replaceWith"
+ }, function( name, original ) {
+ jQuery.fn[ name ] = function( selector ) {
+ var ret = [], insert = jQuery( selector ), elems, i, l,
tmplItems,
+ parent = this.length === 1 &&
this[0].parentNode;
+
+ appendToTmplItems = newTmplItems || {};
+ if ( parent && parent.nodeType === 11 &&
parent.childNodes.length === 1 && insert.length === 1 ) {
+ insert[ original ]( this[0] );
+ ret = this;
+ } else {
+ for ( i = 0, l = insert.length; i < l; i++ ) {
+ cloneIndex = i;
+ elems = (i > 0 ? this.clone(true) :
this).get();
+ jQuery( insert[i] )[ original ]( elems
);
+ ret = ret.concat( elems );
+ }
+ cloneIndex = 0;
+ ret = this.pushStack( ret, name,
insert.selector );
+ }
+ tmplItems = appendToTmplItems;
+ appendToTmplItems = null;
+ jQuery.tmpl.complete( tmplItems );
+ return ret;
+ };
+ });
+
+ jQuery.fn.extend({
+ // Use first wrapped element as template markup.
+ // Return wrapped set of template items, obtained by rendering
template against data.
+ tmpl: function( data, options, parentItem ) {
+ return jQuery.tmpl( this[0], data, options, parentItem
);
+ },
+
+ // Find which rendered template item the first wrapped DOM
element belongs to
+ tmplItem: function() {
+ return jQuery.tmplItem( this[0] );
+ },
+
+ // Consider the first wrapped element as a template
declaration, and get the compiled template or store it as a named template.
+ template: function( name ) {
+ return jQuery.template( name, this[0] );
+ },
+
+ domManip: function( args, table, callback, options ) {
+ if ( args[0] && jQuery.isArray( args[0] )) {
+ var dmArgs = jQuery.makeArray( arguments ),
elems = args[0], elemsLength = elems.length, i = 0, tmplItem;
+ while ( i < elemsLength && !(tmplItem =
jQuery.data( elems[i++], "tmplItem" ))) {}
+ if ( tmplItem && cloneIndex ) {
+ dmArgs[2] = function( fragClone ) {
+ // Handler called by oldManip
when rendered template has been inserted into DOM.
+ jQuery.tmpl.afterManip( this,
fragClone, callback );
+ };
+ }
+ oldManip.apply( this, dmArgs );
+ } else {
+ oldManip.apply( this, arguments );
+ }
+ cloneIndex = 0;
+ if ( !appendToTmplItems ) {
+ jQuery.tmpl.complete( newTmplItems );
+ }
+ return this;
+ }
+ });
+
+ jQuery.extend({
+ // Return wrapped set of template items, obtained by rendering
template against data.
+ tmpl: function( tmpl, data, options, parentItem ) {
+ var ret, topLevel = !parentItem;
+ if ( topLevel ) {
+ // This is a top-level tmpl call (not from a
nested template using {{tmpl}})
+ parentItem = topTmplItem;
+ tmpl = jQuery.template[tmpl] ||
jQuery.template( null, tmpl );
+ wrappedItems = {}; // Any wrapped items will be
rebuilt, since this is top level
+ } else if ( !tmpl ) {
+ // The template item is already associated with
DOM - this is a refresh.
+ // Re-evaluate rendered template for the
parentItem
+ tmpl = parentItem.tmpl;
+ newTmplItems[parentItem.key] = parentItem;
+ parentItem.nodes = [];
+ if ( parentItem.wrapped ) {
+ updateWrapped( parentItem,
parentItem.wrapped );
+ }
+ // Rebuild, without creating a new template item
+ return jQuery( build( parentItem, null,
parentItem.tmpl( jQuery, parentItem ) ));
+ }
+ if ( !tmpl ) {
+ return []; // Could throw...
+ }
+ if ( typeof data === "function" ) {
+ data = data.call( parentItem || {} );
+ }
+ if ( options && options.wrapped ) {
+ updateWrapped( options, options.wrapped );
+ }
+ ret = jQuery.isArray( data ) ?
+ jQuery.map( data, function( dataItem ) {
+ return dataItem ? newTmplItem( options,
parentItem, tmpl, dataItem ) : null;
+ }) :
+ [ newTmplItem( options, parentItem, tmpl, data
) ];
+ return topLevel ? jQuery( build( parentItem, null, ret
) ) : ret;
+ },
+
+ // Return rendered template item for an element.
+ tmplItem: function( elem ) {
+ var tmplItem;
+ if ( elem instanceof jQuery ) {
+ elem = elem[0];
+ }
+ while ( elem && elem.nodeType === 1 && !(tmplItem =
jQuery.data( elem, "tmplItem" )) && (elem = elem.parentNode) ) {}
+ return tmplItem || topTmplItem;
+ },
+
+ // Set:
+ // Use $.template( name, tmpl ) to cache a named template,
+ // where tmpl is a template string, a script element or a
jQuery instance wrapping a script element, etc.
+ // Use $( "selector" ).template( name ) to provide access by
name to a script block template declaration.
+
+ // Get:
+ // Use $.template( name ) to access a cached template.
+ // Also $( selectorToScriptBlock ).template(), or $.template(
null, templateString )
+ // will return the compiled template, without adding a name
reference.
+ // If templateString includes at least one HTML tag,
$.template( templateString ) is equivalent
+ // to $.template( null, templateString )
+ template: function( name, tmpl ) {
+ if (tmpl) {
+ // Compile template and associate with name
+ if ( typeof tmpl === "string" ) {
+ // This is an HTML string being passed
directly in.
+ tmpl = buildTmplFn( tmpl );
+ } else if ( tmpl instanceof jQuery ) {
+ tmpl = tmpl[0] || {};
+ }
+ if ( tmpl.nodeType ) {
+ // If this is a template block, use
cached copy, or generate tmpl function and cache.
+ tmpl = jQuery.data( tmpl, "tmpl" ) ||
jQuery.data( tmpl, "tmpl", buildTmplFn( tmpl.innerHTML ));
+ // Issue: In IE, if the container
element is not a script block, the innerHTML will remove quotes from attribute
values whenever the value does not include white space.
+ // This means that foo="${x}" will not
work if the value of x includes white space: foo="${x}" -> foo=value of x.
+ // To correct this, include space in
tag: foo="${ x }" -> foo="value of x"
+ }
+ return typeof name === "string" ?
(jQuery.template[name] = tmpl) : tmpl;
+ }
+ // Return named compiled template
+ return name ? (typeof name !== "string" ?
jQuery.template( null, name ):
+ (jQuery.template[name] ||
+ // If not in map, and not containing at
least on HTML tag, treat as a selector.
+ // (If integrated with core, use
quickExpr.exec)
+ jQuery.template( null, htmlExpr.test(
name ) ? name : jQuery( name )))) : null;
+ },
+
+ encode: function( text ) {
+ // Do HTML encoding replacing < > & and ' and " by
corresponding entities.
+ return ("" +
text).split("<").join("<").split(">").join(">").split('"').join(""").split("'").join("'");
+ }
+ });
+
+ jQuery.extend( jQuery.tmpl, {
+ tag: {
+ "tmpl": {
+ _default: { $2: "null" },
+ open:
"if($notnull_1){__=__.concat($item.nest($1,$2));}"
+ // tmpl target parameter can be of type
function, so use $1, not $1a (so not auto detection of functions)
+ // This means that {{tmpl foo}} treats foo as a
template (which IS a function).
+ // Explicit parens can be used if foo is a
function that returns a template: {{tmpl foo()}}.
+ },
+ "wrap": {
+ _default: { $2: "null" },
+ open: "$item.calls(__,$1,$2);__=[];",
+ close:
"call=$item.calls();__=call._.concat($item.wrap(call,__));"
+ },
+ "each": {
+ _default: { $2: "$index, $value" },
+ open:
"if($notnull_1){$.each($1a,function($2){with(this){",
+ close: "}});}"
+ },
+ "if": {
+ open: "if(($notnull_1) && $1a){",
+ close: "}"
+ },
+ "else": {
+ _default: { $1: "true" },
+ open: "}else if(($notnull_1) && $1a){"
+ },
+ "html": {
+ // Unecoded expression evaluation.
+ open: "if($notnull_1){__.push($1a);}"
+ },
+ "=": {
+ // Encoded expression evaluation. Abbreviated
form is ${}.
+ _default: { $1: "$data" },
+ open: "if($notnull_1){__.push($.encode($1a));}"
+ },
+ "!": {
+ // Comment tag. Skipped by parser
+ open: ""
+ }
+ },
+
+ // This stub can be overridden, e.g. in jquery.tmplPlus for
providing rendered events
+ complete: function( items ) {
+ newTmplItems = {};
+ },
+
+ // Call this from code which overrides domManip, or equivalent
+ // Manage cloning/storing template items etc.
+ afterManip: function afterManip( elem, fragClone, callback ) {
+ // Provides cloned fragment ready for fixup prior to
and after insertion into DOM
+ var content = fragClone.nodeType === 11 ?
+ jQuery.makeArray(fragClone.childNodes) :
+ fragClone.nodeType === 1 ? [fragClone] : [];
+
+ // Return fragment to original caller (e.g. append) for
DOM insertion
+ callback.call( elem, fragClone );
+
+ // Fragment has been inserted:- Add inserted nodes to
tmplItem data structure. Replace inserted element annotations by jQuery.data.
+ storeTmplItems( content );
+ cloneIndex++;
+ }
+ });
+
+ //========================== Private helper functions, used by code
above ==========================
+
+ function build( tmplItem, nested, content ) {
+ // Convert hierarchical content into flat string array
+ // and finally return array of fragments ready for DOM insertion
+ var frag, ret = content ? jQuery.map( content, function( item )
{
+ return (typeof item === "string") ?
+ // Insert template item annotations, to be
converted to jQuery.data( "tmplItem" ) when elems are inserted into DOM.
+ (tmplItem.key ? item.replace(
/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g, "$1 " + tmplItmAtt + "=\"" +
tmplItem.key + "\" $2" ) : item) :
+ // This is a child template item. Build nested
template.
+ build( item, tmplItem, item._ctnt );
+ }) :
+ // If content is not defined, insert tmplItem directly. Not a
template item. May be a string, or a string array, e.g. from {{html
$item.html()}}.
+ tmplItem;
+ if ( nested ) {
+ return ret;
+ }
+
+ // top-level template
+ ret = ret.join("");
+
+ // Support templates which have initial or final text nodes, or
consist only of text
+ // Also support HTML entities within the HTML markup.
+ ret.replace( /^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/,
function( all, before, middle, after) {
+ frag = jQuery( middle ).get();
+
+ storeTmplItems( frag );
+ if ( before ) {
+ frag = unencode( before ).concat(frag);
+ }
+ if ( after ) {
+ frag = frag.concat(unencode( after ));
+ }
+ });
+ return frag ? frag : unencode( ret );
+ }
+
+ function unencode( text ) {
+ // Use createElement, since createTextNode will not render HTML
entities correctly
+ var el = document.createElement( "div" );
+ el.innerHTML = text;
+ return jQuery.makeArray(el.childNodes);
+ }
+
+ // Generate a reusable function that will serve to render a template
against data
+ function buildTmplFn( markup ) {
+ return new Function("jQuery","$item",
+ // Use the variable __ to hold a string array while
building the compiled template. (See
https://github.com/jquery/jquery-tmpl/issues#issue/10).
+ "var $=jQuery,call,__=[],$data=$item.data;" +
+
+ // Introduce the data as local variables using with(){}
+ "with($data){__.push('" +
+
+ // Convert the template into pure JavaScript
+ jQuery.trim(markup)
+ .replace( /([\\'])/g, "\\$1" )
+ .replace( /[\r\t\n]/g, " " )
+ .replace( /\$\{([^\}]*)\}/g, "{{= $1}}" )
+ .replace(
/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,
+ function( all, slash, type, fnargs, target,
parens, args ) {
+ var tag = jQuery.tmpl.tag[ type ], def,
expr, exprAutoFnDetect;
+ if ( !tag ) {
+ throw "Unknown template tag: "
+ type;
+ }
+ def = tag._default || [];
+ if ( parens && !/\w$/.test(target)) {
+ target += parens;
+ parens = "";
+ }
+ if ( target ) {
+ target = unescape( target );
+ args = args ? ("," + unescape(
args ) + ")") : (parens ? ")" : "");
+ // Support for target being
things like a.toLowerCase();
+ // In that case don't call with
template item as 'this' pointer. Just evaluate...
+ expr = parens ?
(target.indexOf(".") > -1 ? target + unescape( parens ) : ("(" + target +
").call($item" + args)) : target;
+ exprAutoFnDetect = parens ?
expr : "(typeof(" + target + ")==='function'?(" + target + ").call($item):(" +
target + "))";
+ } else {
+ exprAutoFnDetect = expr =
def.$1 || "null";
+ }
+ fnargs = unescape( fnargs );
+ return "');" +
+ tag[ slash ? "close" : "open" ]
+ .split( "$notnull_1"
).join( target ? "typeof(" + target + ")!=='undefined' && (" + target +
")!=null" : "true" )
+ .split( "$1a" ).join(
exprAutoFnDetect )
+ .split( "$1" ).join(
expr )
+ .split( "$2" ).join(
fnargs || def.$2 || "" ) +
+ "__.push('";
+ }) +
+ "');}return __;"
+ );
+ }
+ function updateWrapped( options, wrapped ) {
+ // Build the wrapped content.
+ options._wrap = build( options, true,
+ // Suport imperative scenario in which options.wrapped
can be set to a selector or an HTML string.
+ jQuery.isArray( wrapped ) ? wrapped : [htmlExpr.test(
wrapped ) ? wrapped : jQuery( wrapped ).html()]
+ ).join("");
+ }
+
+ function unescape( args ) {
+ return args ? args.replace( /\\'/g, "'").replace(/\\\\/g, "\\"
) : null;
+ }
+ function outerHtml( elem ) {
+ var div = document.createElement("div");
+ div.appendChild( elem.cloneNode(true) );
+ return div.innerHTML;
+ }
+
+ // Store template items in jQuery.data(), ensuring a unique tmplItem
data data structure for each rendered template instance.
+ function storeTmplItems( content ) {
+ var keySuffix = "_" + cloneIndex, elem, elems, newClonedItems =
{}, i, l, m;
+ for ( i = 0, l = content.length; i < l; i++ ) {
+ if ( (elem = content[i]).nodeType !== 1 ) {
+ continue;
+ }
+ elems = elem.getElementsByTagName("*");
+ for ( m = elems.length - 1; m >= 0; m-- ) {
+ processItemKey( elems[m] );
+ }
+ processItemKey( elem );
+ }
+ function processItemKey( el ) {
+ var pntKey, pntNode = el, pntItem, tmplItem, key;
+ // Ensure that each rendered template inserted into the
DOM has its own template item,
+ if ( (key = el.getAttribute( tmplItmAtt ))) {
+ while ( pntNode.parentNode && (pntNode =
pntNode.parentNode).nodeType === 1 && !(pntKey = pntNode.getAttribute(
tmplItmAtt ))) { }
+ if ( pntKey !== key ) {
+ // The next ancestor with a _tmplitem
expando is on a different key than this one.
+ // So this is a top-level element
within this template item
+ // Set pntNode to the key of the
parentNode, or to 0 if pntNode.parentNode is null, or pntNode is a fragment.
+ pntNode = pntNode.parentNode ?
(pntNode.nodeType === 11 ? 0 : (pntNode.getAttribute( tmplItmAtt ) || 0)) : 0;
+ if ( !(tmplItem = newTmplItems[key]) ) {
+ // The item is for wrapped
content, and was copied from the temporary parent wrappedItem.
+ tmplItem = wrappedItems[key];
+ tmplItem = newTmplItem(
tmplItem, newTmplItems[pntNode]||wrappedItems[pntNode] );
+ tmplItem.key = ++itemKey;
+ newTmplItems[itemKey] =
tmplItem;
+ }
+ if ( cloneIndex ) {
+ cloneTmplItem( key );
+ }
+ }
+ el.removeAttribute( tmplItmAtt );
+ } else if ( cloneIndex && (tmplItem = jQuery.data( el,
"tmplItem" )) ) {
+ // This was a rendered element, cloned during
append or appendTo etc.
+ // TmplItem stored in jQuery data has already
been cloned in cloneCopyEvent. We must replace it with a fresh cloned tmplItem.
+ cloneTmplItem( tmplItem.key );
+ newTmplItems[tmplItem.key] = tmplItem;
+ pntNode = jQuery.data( el.parentNode,
"tmplItem" );
+ pntNode = pntNode ? pntNode.key : 0;
+ }
+ if ( tmplItem ) {
+ pntItem = tmplItem;
+ // Find the template item of the parent element.
+ // (Using !=, not !==, since pntItem.key is
number, and pntNode may be a string)
+ while ( pntItem && pntItem.key != pntNode ) {
+ // Add this element as a top-level node
for this rendered template item, as well as for any
+ // ancestor items between this item and
the item of its parent element
+ pntItem.nodes.push( el );
+ pntItem = pntItem.parent;
+ }
+ // Delete content built during rendering -
reduce API surface area and memory use, and avoid exposing of stale data after
rendering...
+ delete tmplItem._ctnt;
+ delete tmplItem._wrap;
+ // Store template item as jQuery data on the
element
+ jQuery.data( el, "tmplItem", tmplItem );
+ }
+ function cloneTmplItem( key ) {
+ key = key + keySuffix;
+ tmplItem = newClonedItems[key] =
+ (newClonedItems[key] || newTmplItem(
tmplItem, newTmplItems[tmplItem.parent.key + keySuffix] || tmplItem.parent ));
+ }
+ }
+ }
+
+ //---- Helper functions for template item ----
+
+ function tiCalls( content, tmpl, data, options ) {
+ if ( !content ) {
+ return stack.pop();
+ }
+ stack.push({ _: content, tmpl: tmpl, item:this, data: data,
options: options });
+ }
+
+ function tiNest( tmpl, data, options ) {
+ // nested template, using {{tmpl}} tag
+ return jQuery.tmpl( jQuery.template( tmpl ), data, options,
this );
+ }
+
+ function tiWrap( call, wrapped ) {
+ // nested template, using {{wrap}} tag
+ var options = call.options || {};
+ options.wrapped = wrapped;
+ // Apply the template, which may incorporate wrapped content,
+ return jQuery.tmpl( jQuery.template( call.tmpl ), call.data,
options, call.item );
+ }
+
+ function tiHtml( filter, textOnly ) {
+ var wrapped = this._wrap;
+ return jQuery.map(
+ jQuery( jQuery.isArray( wrapped ) ? wrapped.join("") :
wrapped ).filter( filter || "*" ),
+ function(e) {
+ return textOnly ?
+ e.innerText || e.textContent :
+ e.outerHTML || outerHtml(e);
+ });
+ }
+
+ function tiUpdate() {
+ var coll = this.nodes;
+ jQuery.tmpl( null, null, null, this).insertBefore( coll[0] );
+ jQuery( coll ).remove();
+ }
+})( jQuery );
\ No newline at end of file
Propchange:
incubator/directmemory/trunk/server/directmemory-server-archetype/src/main/resources/archetype-resources/src/main/webapp/js/jquery-tmpl.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/directmemory/trunk/server/directmemory-server-archetype/src/main/resources/archetype-resources/src/main/webapp/js/jquery-tmpl.js
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
incubator/directmemory/trunk/server/directmemory-server-archetype/src/main/resources/archetype-resources/src/main/webapp/js/jquery.json-2.3.js
URL:
http://svn.apache.org/viewvc/incubator/directmemory/trunk/server/directmemory-server-archetype/src/main/resources/archetype-resources/src/main/webapp/js/jquery.json-2.3.js?rev=1294886&view=auto
==============================================================================
---
incubator/directmemory/trunk/server/directmemory-server-archetype/src/main/resources/archetype-resources/src/main/webapp/js/jquery.json-2.3.js
(added)
+++
incubator/directmemory/trunk/server/directmemory-server-archetype/src/main/resources/archetype-resources/src/main/webapp/js/jquery.json-2.3.js
Tue Feb 28 23:08:18 2012
@@ -0,0 +1,193 @@
+/**
+ * jQuery JSON Plugin
+ * version: 2.3 (2011-09-17)
+ *
+ * This document is licensed as free software under the terms of the
+ * MIT License: http://www.opensource.org/licenses/mit-license.php
+ *
+ * Brantley Harris wrote this plugin. It is based somewhat on the JSON.org
+ * website's http://www.json.org/json2.js, which proclaims:
+ * "NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.", a sentiment that
+ * I uphold.
+ *
+ * It is also influenced heavily by MochiKit's serializeJSON, which is
+ * copyrighted 2005 by Bob Ippolito.
+ */
+
+(function( $ ) {
+
+ var escapeable = /["\\\x00-\x1f\x7f-\x9f]/g,
+ meta = {
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '\\': '\\\\'
+ };
+
+ /**
+ * jQuery.toJSON
+ * Converts the given argument into a JSON respresentation.
+ *
+ * @param o {Mixed} The json-serializble *thing* to be converted
+ *
+ * If an object has a toJSON prototype, that will be used to get the
representation.
+ * Non-integer/string keys are skipped in the object, as are keys that
point to a
+ * function.
+ *
+ */
+ $.toJSON = typeof JSON === 'object' && JSON.stringify
+ ? JSON.stringify
+ : function( o ) {
+
+ if ( o === null ) {
+ return 'null';
+ }
+
+ var type = typeof o;
+
+ if ( type === 'undefined' ) {
+ return undefined;
+ }
+ if ( type === 'number' || type === 'boolean' ) {
+ return '' + o;
+ }
+ if ( type === 'string') {
+ return $.quoteString( o );
+ }
+ if ( type === 'object' ) {
+ if ( typeof o.toJSON === 'function' ) {
+ return $.toJSON( o.toJSON() );
+ }
+ if ( o.constructor === Date ) {
+ var month = o.getUTCMonth() + 1,
+ day = o.getUTCDate(),
+ year = o.getUTCFullYear(),
+ hours = o.getUTCHours(),
+ minutes = o.getUTCMinutes(),
+ seconds = o.getUTCSeconds(),
+ milli = o.getUTCMilliseconds();
+
+ if ( month < 10 ) {
+ month = '0' + month;
+ }
+ if ( day < 10 ) {
+ day = '0' + day;
+ }
+ if ( hours < 10 ) {
+ hours = '0' + hours;
+ }
+ if ( minutes < 10 ) {
+ minutes = '0' + minutes;
+ }
+ if ( seconds < 10 ) {
+ seconds = '0' + seconds;
+ }
+ if ( milli < 100 ) {
+ milli = '0' + milli;
+ }
+ if ( milli < 10 ) {
+ milli = '0' + milli;
+ }
+ return '"' + year + '-' + month + '-' + day +
'T' +
+ hours + ':' + minutes + ':' + seconds +
+ '.' + milli + 'Z"';
+ }
+ if ( o.constructor === Array ) {
+ var ret = [];
+ for ( var i = 0; i < o.length; i++ ) {
+ ret.push( $.toJSON( o[i] ) || 'null' );
+ }
+ return '[' + ret.join(',') + ']';
+ }
+ var name,
+ val,
+ pairs = [];
+ for ( var k in o ) {
+ type = typeof k;
+ if ( type === 'number' ) {
+ name = '"' + k + '"';
+ } else if (type === 'string') {
+ name = $.quoteString(k);
+ } else {
+ // Keys must be numerical or string.
Skip others
+ continue;
+ }
+ type = typeof o[k];
+
+ if ( type === 'function' || type ===
'undefined' ) {
+ // Invalid values like these return
undefined
+ // from toJSON, however those object
members
+ // shouldn't be included in the JSON
string at all.
+ continue;
+ }
+ val = $.toJSON( o[k] );
+ pairs.push( name + ':' + val );
+ }
+ return '{' + pairs.join( ',' ) + '}';
+ }
+ };
+
+ /**
+ * jQuery.evalJSON
+ * Evaluates a given piece of json source.
+ *
+ * @param src {String}
+ */
+ $.evalJSON = typeof JSON === 'object' && JSON.parse
+ ? JSON.parse
+ : function( src ) {
+ return eval('(' + src + ')');
+ };
+
+ /**
+ * jQuery.secureEvalJSON
+ * Evals JSON in a way that is *more* secure.
+ *
+ * @param src {String}
+ */
+ $.secureEvalJSON = typeof JSON === 'object' && JSON.parse
+ ? JSON.parse
+ : function( src ) {
+
+ var filtered =
+ src
+ .replace( /\\["\\\/bfnrtu]/g, '@' )
+ .replace(
/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
+ .replace( /(?:^|:|,)(?:\s*\[)+/g, '');
+
+ if ( /^[\],:{}\s]*$/.test( filtered ) ) {
+ return eval( '(' + src + ')' );
+ } else {
+ throw new SyntaxError( 'Error parsing JSON, source is
not valid.' );
+ }
+ };
+
+ /**
+ * jQuery.quoteString
+ * Returns a string-repr of a string, escaping quotes intelligently.
+ * Mostly a support function for toJSON.
+ * Examples:
+ * >>> jQuery.quoteString('apple')
+ * "apple"
+ *
+ * >>> jQuery.quoteString('"Where are we going?", she asked.')
+ * "\"Where are we going?\", she asked."
+ */
+ $.quoteString = function( string ) {
+ if ( string.match( escapeable ) ) {
+ return '"' + string.replace( escapeable, function( a ) {
+ var c = meta[a];
+ if ( typeof c === 'string' ) {
+ return c;
+ }
+ c = a.charCodeAt();
+ return '\\u00' + Math.floor(c /
16).toString(16) + (c % 16).toString(16);
+ }) + '"';
+ }
+ return '"' + string + '"';
+ };
+
+})( jQuery );
Propchange:
incubator/directmemory/trunk/server/directmemory-server-archetype/src/main/resources/archetype-resources/src/main/webapp/js/jquery.json-2.3.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/directmemory/trunk/server/directmemory-server-archetype/src/main/resources/archetype-resources/src/main/webapp/js/jquery.json-2.3.js
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
incubator/directmemory/trunk/server/directmemory-server-archetype/src/main/resources/archetype-resources/src/main/webapp/js/sample.js
URL:
http://svn.apache.org/viewvc/incubator/directmemory/trunk/server/directmemory-server-archetype/src/main/resources/archetype-resources/src/main/webapp/js/sample.js?rev=1294886&view=auto
==============================================================================
---
incubator/directmemory/trunk/server/directmemory-server-archetype/src/main/resources/archetype-resources/src/main/webapp/js/sample.js
(added)
+++
incubator/directmemory/trunk/server/directmemory-server-archetype/src/main/resources/archetype-resources/src/main/webapp/js/sample.js
Tue Feb 28 23:08:18 2012
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+$(function() {
+ Wine=function(name,description){
+ this.name=name;
+ this.description=description;
+ }
+ clearResultContent=function(){
+ $("#result-content" ).html("");
+ }
+ displayInfo=function(msg){
+ //alert(msg);
+ clearResultContent();
+ $("#result-content" ).html($("#alert-message-info").tmpl({message:msg}));
+ }
+
+ displayError=function(msg){
+ //alert(msg);
+ clearResultContent();
+ $("#result-content" ).html($("#alert-message-error").tmpl({message:msg}));
+ }
+
+ displayWarning=function(msg){
+ //alert(msg);
+ clearResultContent();
+ $("#result-content"
).html($("#alert-message-warning").tmpl({message:msg}));
+ }
+
+ // X-DirectMemory-ExpiresIn
+ putWineInCache=function(wine,expiresIn,serializer){
+ $.ajax({
+ url: 'cache/'+encodeURIComponent(wine.name),
+ data:$.toJSON( wine ),
+ cache: false,
+ type: 'PUT',
+
headers:{'X-DirectMemory-ExpiresIn':expiresIn,'X-DirectMemory-Serializer':serializer},
+ contentType: "text/plain",
+ statusCode: {
+ 204: function() {
+ displayWarning("not put in cache");
+ },
+ 200:function( data, textStatus, jqXHR ) {
+ var size = jqXHR.getResponseHeader('X-DirectMemory-SerializeSize');
+ displayInfo('put in cache with key:'+wine.name+ " bytes
stored:"+size);
+
+ },
+ 500:function(data){
+ displayError("error put in cache");
+ }
+ }
+ });
+ }
+
+ deleteFromCache=function(key){
+ $.ajax({
+ url: 'cache/'+encodeURIComponent(key),
+ cache: false,
+ type: 'DELETE',
+ dataType: 'text',
+ statusCode: {
+ 204: function() {
+ displayWarning("not found in cache");
+ },
+ 200:function( data ) {
+ displayInfo(' key '+key+ ' deleted from cache');
+ },
+ 500:function(data){
+ displayError("error delete from cache");
+ }
+ }
+ });
+ }
+
+ $(document).ready(function() {
+
+ $("#put-cache-btn").on('click',function(){
+ var wine = new Wine($("#wine_name" ).val(),$("#wine_description"
).val());
+ if ( $.trim(wine.name ).length<1){
+ displayError("name mandatory");
+ return;
+ }
+ var expiresIn=$("#expires-in").val()?$("#expires-in").val():0;
+ if( $.trim(expiresIn).length>0 && !$.isNumeric($.trim(expiresIn))){
+ displayError("expiresIn must be a number");
+ return;
+ }
+ putWineInCache(wine,expiresIn,$("#serializer" ).val());
+
+ });
+
+ $("#get_cache_btn").on('click',function(){
+ var key = $("#wine_name_cache" ).val();
+ if ( $.trim(key).length<1){
+ displayError("key mandatory");
+ return;
+ }
+
+ $.ajax({
+ url: 'cache/'+encodeURIComponent(key),
+ cache: false,
+ type: 'GET',
+ headers:{'X-DirectMemory-Serializer':$("#serializer" ).val()},
+ dataType: 'text',
+ statusCode: {
+ 204: function() {
+ displayWarning("not found in cache");
+ },
+ 200:function( data ) {
+ var wine = $.parseJSON(data);
+ displayInfo('get from cache with key:'+wine.description);
+ },
+ 500:function(data){
+ displayError("error get from cache");
+ }
+ }
+ });
+
+ });
+
+ $("#delete_cache_btn").on('click',function(){
+ var key = $("#wine_key_cache" ).val();
+ if ( $.trim(key).length<1){
+ displayError("key mandatory");
+ return;
+ }
+ deleteFromCache(key);
+ });
+
+
+ });
+
+
+});
\ No newline at end of file
Propchange:
incubator/directmemory/trunk/server/directmemory-server-archetype/src/main/resources/archetype-resources/src/main/webapp/js/sample.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/directmemory/trunk/server/directmemory-server-archetype/src/main/resources/archetype-resources/src/main/webapp/js/sample.js
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
incubator/directmemory/trunk/server/directmemory-server-archetype/src/test/resources/projects/basic/archetype.properties
URL:
http://svn.apache.org/viewvc/incubator/directmemory/trunk/server/directmemory-server-archetype/src/test/resources/projects/basic/archetype.properties?rev=1294886&view=auto
==============================================================================
---
incubator/directmemory/trunk/server/directmemory-server-archetype/src/test/resources/projects/basic/archetype.properties
(added)
+++
incubator/directmemory/trunk/server/directmemory-server-archetype/src/test/resources/projects/basic/archetype.properties
Tue Feb 28 23:08:18 2012
@@ -0,0 +1,5 @@
+#Tue Feb 28 23:40:10 CET 2012
+package=it.pkg
+version=0.1-SNAPSHOT
+groupId=archetype.it
+artifactId=basic
Propchange:
incubator/directmemory/trunk/server/directmemory-server-archetype/src/test/resources/projects/basic/archetype.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/directmemory/trunk/server/directmemory-server-archetype/src/test/resources/projects/basic/archetype.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
incubator/directmemory/trunk/server/directmemory-server-archetype/src/test/resources/projects/basic/goal.txt
URL:
http://svn.apache.org/viewvc/incubator/directmemory/trunk/server/directmemory-server-archetype/src/test/resources/projects/basic/goal.txt?rev=1294886&view=auto
==============================================================================
(empty)
Propchange:
incubator/directmemory/trunk/server/directmemory-server-archetype/src/test/resources/projects/basic/goal.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/directmemory/trunk/server/directmemory-server-archetype/src/test/resources/projects/basic/goal.txt
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: incubator/directmemory/trunk/server/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/directmemory/trunk/server/pom.xml?rev=1294886&r1=1294885&r2=1294886&view=diff
==============================================================================
--- incubator/directmemory/trunk/server/pom.xml (original)
+++ incubator/directmemory/trunk/server/pom.xml Tue Feb 28 23:08:18 2012
@@ -38,6 +38,7 @@
<module>directmemory-server-commons</module>
<module>directmemory-server</module>
<module>directmemory-server-client</module>
+ <module>directmemory-server-archetype</module>
</modules>
<dependencyManagement>