📄 tabs.js
字号:
* standard cookie syntax.
* @returns String
*/
org.ditchnet.util.Cookie.prototype.toCookieString = function () {
with (org.ditchnet.util) {
var buff = new StringBuffer();
// name=value;
buff.append(this.getName()).append(Cookie.EQUALS);
// if (this.getValue() instanceof Array) {
if (typeof this.getValue() == "object" &&
this.getValue().constructor == Array) {
var values = this.getValue();
for (var i = 0; i < values.length; i++) {
buff.append(values[i])
.append(i == values.length-1 ? "" : Cookie.SUB_VALUE_DELIM);
}
} else {
buff.append(this.getValue())
}
buff.append(Cookie.DELIM);
// path=pathvalue;
buff.append(Cookie.PATH).append(Cookie.EQUALS)
.append(this.getPath()).append(Cookie.DELIM);
// expires=expiresvalue
buff.append(Cookie.EXPIRES).append(Cookie.EQUALS)
.append(this.getExpires()).append(Cookie.DELIM);
if (this.getDomain()) {
// domain=domainvalue
buff.append(Cookie.DOMAIN).append(Cookie.EQUALS)
.append(this.getDomain()).append(Cookie.DELIM);
}
if (this.isSecure()) {
// secure;
buff.append(Cookie.SECURE).append(Cookie.DELIM);
}
}
return buff.toString();
};
/**
* Returns a String representation of this <code>Cookie</cookie> in the
* standard cookie syntax -- but only the name and value with no trailing
* semicolon.
* @returns String
*/
org.ditchnet.util.Cookie.prototype.toNameValueString = function () {
var buff = new org.ditchnet.util.StringBuffer();
// name=value -- no trailing semicolon
buff.append(this.getName()).append(Cookie.EQUALS)
.append(this.getValue());
return buff.toString();
};
/**
* Get the <code>name</code> attribute value for this <code>Cookie</code>
* object.
* @returns String
*/
org.ditchnet.util.Cookie.prototype.getName = function () {
return this._name;
};
/**
* Set the <code>name</code> attribute value for this <code>Cookie</code>
* object.
* @param String name
* @returns void
*/
org.ditchnet.util.Cookie.prototype.setName = function (name) {
this._name = name;
};
/**
* Get the <code>value</code> attribute value for this <code>Cookie</code>
* object.
* @returns String
*/
org.ditchnet.util.Cookie.prototype.getValue = function () {
return this._value;
};
/**
* Set the <code>value</code> attribute value for this <code>Cookie</code>
* object.
* @param String value
* @returns void
*/
org.ditchnet.util.Cookie.prototype.setValue = function (value) {
this._value = value;
};
/**
* Get the <code>path</code> attribute value for this <code>Cookie</code>
* object.
* @returns String
*/
org.ditchnet.util.Cookie.prototype.getPath = function () {
if (this._path === undefined) {
return "/";
} else {
return this._path;
}
};
/**
* Set the <code>path</code> attribute value for this <code>Cookie</code>
* object.
* @param String path
* @returns void
*/
org.ditchnet.util.Cookie.prototype.setPath = function (path) {
this._path = path;
};
/**
* Get the <code>secure</code> attribute value for this <code>Cookie</code>
* object.
* @returns boolean
*/
org.ditchnet.util.Cookie.prototype.isSecure = function () {
return this._secure;
};
/**
* Set the <code>secure</code> attribute value for this <code>Cookie</code>
* object.
* @param boolean secure
* @returns void
*/
org.ditchnet.util.Cookie.prototype.setSecure = function (secure) {
this._secure = secure;
};
/**
* Get the <code>domain</code> attribute value for this <code>Cookie</code>
* object.
* @returns String
*/
org.ditchnet.util.Cookie.prototype.getDomain = function () {
return this._domain;
};
/**
* Set the <code>domain</code> attribute value for this <code>Cookie</code>
* object.
* @param String domain
* @returns void
*/
org.ditchnet.util.Cookie.prototype.setDomain = function (domain) {
this._domain = domain;
};
/**
* Get the <code>expires</code> attribute value for this <code>Cookie</code>
* object.
* @returns String
*/
org.ditchnet.util.Cookie.prototype.getExpires = function () {
if (this._expires === undefined) {
return this._getDefaultExpires();
} else {
return this._expires;
}
};
/**
* Set the <code>expires</code> attribute value for this <code>Cookie</code>
* object.
* @param String expires
* @returns void
*/
org.ditchnet.util.Cookie.prototype.setExpires = function (expires) {
this._expires = expires;
};
/**
* Private method to get the devault value for the <code>domain</code>
* attribute value for this <code>Cookie</code>
* object.
* @returns String
*/
org.ditchnet.util.Cookie.prototype._getDefaultDomain = function () {
return window.location.hostname;
};
/**
* Private method to get the devault value for the <code>expires</code>
* attribute value for this <code>Cookie</code>
* object.
* @returns String
*/
org.ditchnet.util.Cookie.prototype._getDefaultExpires = function () {
var date = new Date();
date.setFullYear(date.getFullYear()+10);
return date.toGMTString();
};
/**
* A utility class that mirrors the <code>java.util.StringBuffer</code> class.
* Improves performance of string concatenation by storing strings in a
* private internal array.
* @author Todd Ditchendorf
* @constructor Accepts optional inital parameter to store in the
* buffer.
* @param String s Initial buffer value.
*/
org.ditchnet.util.StringBuffer = function (s) {
this._array = [];
if (s && typeof s != "string") {
throw new Error("IllegalArgumentException: StringBuffer's " +
"constructor accepts an optional String argument. Given:" +
(typeof s));
}
if (s) {
this.append(s);
}
};
/**
* Appends an additional String to the buffer and returns a reference to this
* object for method chaining.
* @param String s New String to be added to buffer.
* @returns StringBuffer
*/
org.ditchnet.util.StringBuffer.prototype.append = function (s) {
this._array.push(s);
return this;
};
/**
* Returns a String representation of this <code>StringBuffer</code>
* @returns String
*/
org.ditchnet.util.StringBuffer.prototype.toString = function () {
return this._array.join("");
};
/**
* An object that maps keys to values. A map cannot contain duplicate keys;
* each key can map to at most one value.
* @author Todd Ditchendorf
*/
org.ditchnet.util.Map = function (o) {
/* if (o && !(o instanceof Object)) {
throw new Error("IllegalArgumentException: Map's " +
"constructor's only argument must be an Object");
}*/
this._obj = (o) ? (o) : new Object();
};
/**
* Associates the specified value with the specified key in this map.
* @param Object key New key to enter,
* @param Object Value New value to enter.
* @returns Object
*/
org.ditchnet.util.Map.prototype.put = function (key,value) {
this._obj[key] = value;
};
/**
* Returns the value to which this map maps the specified key.
* @param Object key Get the value for this key in this Map.
* @returns Object
*/
org.ditchnet.util.Map.prototype.get = function (key) {
if (!this._obj[key]) return null;
return this._obj[key];
};
/**
* Returns the number of key-value mappings in this map.
* @returns number
*/
org.ditchnet.util.Map.prototype.size = function () {
var count = 0;
for (var key in this._obj)
count++;
return count;
};
/**
* Returns true if this map contains no key-value mappings.
* @returns boolean
*/
org.ditchnet.util.Map.prototype.isEmpty = function () {
return this.size() == 0;
};
/**
* Returns a string representation of this map.
* @returns String
*/
org.ditchnet.util.Map.prototype.toString = function () {
var buff = new org.ditchnet.util.StringBuffer();
count = 0;
for ( var key in this._obj ) {
buff.append(key).append(" = ").append(this._obj[key])
.append(count == this.size() - 1 ? "" : "\r\n");
count++;
}
return buff.toString();
};
/**
* Returns true if this map contains a mapping for the specified key.
* @param Object key Testing this Map for key with this value.
* @returns boolean
*/
org.ditchnet.util.Map.prototype.containsKey = function (key) {
if (this._obj[key] !== undefined) {
return true;
}
return false;
};
/**
* Returns true if this map maps one or more keys to the specified value.
* @param Object value Testing this Map for key with this value.
* @returns boolean
*/
org.ditchnet.util.Map.prototype.containsValue = function (value) {
for (var key in this._obj) {
if (this._obj[key] == value) {
return true;
}
}
return false;
};
/**
* Removes the mapping for this key from this map if it is present
* @param Object key Testing this Map for key with this value.
* @returns boolean
*/
org.ditchnet.util.Map.prototype.remove = function (key) {
if (this.containsKey(key)) {
delete this._obj[key];
}
};
/**
* Returns a set view of the values contained in this map.
* @returns Array
*/
org.ditchnet.util.Map.prototype.keySet = function () {
var keys = [];
for (var key in this._obj) {
keys.push(key);
}
return keys;
};
/**
* Returns a collection view of the values contained in this map.
* @returns Collection
*/
org.ditchnet.util.Map.prototype.values = function () {
var values = new Collection();
for (var key in this._obj) {
values.add(this._obj[key]);
}
return values;
};
/**
* Map implementation that makes working with URL params easy.
* @author Todd Ditchendorf
* @constructor should not be called directly
*/
org.ditchnet.util.ParameterMap = function (q) {
this._map = new org.ditchnet.util.Map();
this._q;
if (q) {
this._q = q.substring(1);
}
var pairs = this._q.split(/&+/g);
var a;
for (var i = 0; i < pairs.length; i++) {
a = pairs[i].split(/=+/g);
this._map.put(a[0],a[1]);
}
/*this._re = /(\w+)\=([^&]+)&?/g;
this._current = [];
if(!isIE5Mac && !isIEWin50) {
while (this._current = this._re.exec(this._q)) {
this._map.put(this._current[1],this._current[2]);
}
}*/
};
/**
* Static convenience method to get a parameter map containing the current
* pages URL params.
* @returns ParameterMap
*/
org.ditchnet.util.ParameterMap.getPageParameterMap = function () {
return new org.ditchnet.util.ParameterMap(
window.location.search.toString());
};
/**
* Returns string representation of this parameter map in the standard URL
* query string format (e.g. '?name=value&name2=value'
* @returns String
*/
org.ditchnet.util.ParameterMap.prototype.toQueryString = function () {
var buff = new org.ditchnet.util.StringBuffer("?");
var count = 0;
var key,value;
var keys = this._map.keySet();
for (var i = 0; i < keys.length; i++) {
key = keys[i];
value = this._map.get(key);
buff.append(key).append("=").append(value)
.append(count == this._map.size() - 1 ? "" : "&");
count++;
}
return buff.toString();
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -