1,在调用ueditor的时候,删除Object.prototype.toJSONString 即delete(Object.prototype.toJSONString);
当使用transport.js里的文件后再重新加载transport或者删除之前赋值,使用后重新赋值回来,当然这里存在加载顺序关系
2,修改掉Obj.prototype.toJSONString,把使用prototype的obj换成function ,因为使用prototype更改了js的基础,所以在使用ueditor的时候,使js的基础发生错误,下面为一个转换成json的代码,从jquery复制出来的:
- function changeToJsonString(object) {
-
var type = typeof object; -
if ('object' == type) { -
if (Array == object.constructor) type = 'array'; -
else if (RegExp == object.constructor) type = 'regexp'; -
else type = 'object'; -
} -
switch (type) { -
case 'undefined': -
case 'unknown': -
return; -
break; -
case 'function': -
case 'boolean': -
case 'regexp': -
return object.toString(); -
break; -
case 'number': -
return isFinite(object) ? object.toString() : 'null'; -
break; -
case 'string': -
return '"' + object.replace(/(\\|\")/g, "\\$1").replace(/\n|\r|\t/g, function() { -
var a = arguments[0]; -
return (a == '\n') ? '\\n': (a == '\r') ? '\\r': (a == '\t') ? '\\t': "" -
}) + '"'; -
break; -
case 'object': -
if (object === null) return 'null'; -
var results = []; -
for (var property in object) { -
var value = changeToJsonString(object[property]); -
if (value !== undefined) results.push(changeToJsonString(property) + ':' + value); -
} -
return '{' + results.join(',') + '}'; -
break; -
case 'array': -
var results = []; -
for (var i = 0; i < object.length; i++) { -
var value = changeToJsonString(object[i]); -
if (value !== undefined) results.push(value); -
} -
return '[' + results.join(',') + ']'; -
break; -
} - }
接着把String.prototype.parseJSON也换成function,直接拿出来即可:
- function parseJson(value){
-
// Parsing happens in three stages. In the first stage, we run the text against -
// a regular expression which looks for non-JSON characters. We are especially -
// concerned with '()' and 'new' because they can cause invocation, and '=' -
// because it can cause mutation. But just to be safe, we will reject all -
// unexpected characters. -
try { -
if (/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/. -
test(value)) { -
// In the second stage we use the eval function to compile the text into a -
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity -
// in JavaScript: it can begin a block or an object literal. We wrap the text -
// in parens to eliminate the ambiguity. -
var j = eval_r('(' + value + ')'); -
// In the optional third stage, we recursively walk the new structure, passing -
// each name/value pair to a filter function for possible transformation. -
if (typeof filter === 'function') { -
function walk(k, v) { -
if (v && typeof v === 'object') { -
for (var i in v) { -
if (v.hasOwnProperty(i)) { -
v[i] = walk(i, v[i]); -
} -
} -
} -
return filter(k, v); -
} -
j = walk('', j); -
} -
return j; -
} -
} catch (e) { -
// Fall through if the regexp test fails. -
} -
throw new SyntaxError("parseJSON"); - }
解决ecshop和jquery冲突,测试
增加一个时间函数
- function dateToJsonString() {
-
// Ultimately, this method will be equivalent to the date.toISOString method. -
function f(n) { -
// Format integers to have at least two digits. -
return n < 10 ? '0' + n : n; -
} -
return '"' + this.getFullYear() + '-' + -
f(this.getMonth() + 1) + '-' + -
f(this.getDate()) + 'T' + -
f(this.getHours()) + ':' + -
f(this.getMinutes()) + ':' + -
f(this.getSeconds()) + '"'; -
};
解决ecshop跟jquery冲突问题
1,在jquery.js文件中第一步将已存在的$赋值出来然后释放掉,再在最后重新赋值给$
2,修改transport.js的toJSONString方法
修改文件在同压缩目录下, 修改了toJSONString和parseJSON和一个时间函数
以upload作为根目录
文件名 |
文件路径 |
修改量 |
具体修改操作 |
备注 |
前台文件 | ||||
common.js |
Js/ |
3 |
goods.toJSONString() => changeToJsonString(goods) package_info.toJSONString() => changeToJsonString(package_info) |
|
compare.js |
Js/ |
1 |
this.data.toJSONString() |
这里是记录当前时间,没有参数 |
compare.dwt |
Themes/default |
1 |
obj.toJSONString() => changeToJsonString(obj) |
|
compare.dwt |
Themes/default_old |
1 |
obj.toJSONString() => changeToJsonString(obj) |
|
flow.dwt |
Themes/default_old |
2 |
goods.toJSONString() => changeToJsonString(goods) |
|
flow.dwt |
Themes/default |
2 |
goods.toJSONString() => changeToJsonString(goods) |
|
comments_list.lbi |
Themes/default |
1 |
cmt.toJSONString() => changeToJsonString(cmt) |
|
comments_list.lbi |
Themes/default_old |
1 |
cmt.toJSONString() => changeToJsonString(cmt) |
|
brand.dwt |
Themes/default_old |
|
obj.toJSONString() =>changeToJsonString(obj) |
|
后台文件 | ||||
menu.htm |
Admin/templates |
1 |
this.SourceObject.toJSONString() => changeToJsonString(this.SourceObject) |
|
topic_edit.htm |
Admin/templates |
1 |
myTopic.toJSONString() => changeToJsonString(myTopic) |
|
template_setup.htm |
Admin/templates |
|
|
这里有几处存在toJSONString 暂时未知函数用处 |
wholesale_info.htm |
Admin/templates |
|
|
这里有几处存在toJSONString 暂时未知函数用处 |
selectzone.js |
Admin/js |
2 |
selOpt.toJSONString() => changeToJsonString(selOpt) arr.toJSONString() => changeToJsonString(arr) |
|
增加1.4.2jquery前后增加两项
前 $___ecshop_ = $ == null || $ == ‘undefined’ ? $ : null;
后 $ = $___ecshop_ ;
使用jquery时将$换成jQuery
,修改transport.js 测试结果
1,全功能使用uEditor不会出现 增加JS代码的问题
2,用户评论区可以正常判别验证码对错,可正常ajax提交评论内容
3,产品规格正常修改,ajax正常传输
4,后台商品分类,商品品牌,标签管理的移除,虚拟商品添加修改及编辑操作正常,缺货登记移除处理正常
5,调用ajax正常,script和json方式接受正常.
6,使用jquery插件zoominfo使用正常
2012/3/16