MagicAjax - 糟糕的文档不如不写文档
2006-01-13 10:35
204 查看
昨天下了MagicAjax0.2.2-release看了看Example觉得还算不错,打开MA跟随的Docs看了看,然后打开VS2005准备操刀一下。
因为使用MA的无刷新效果总是在浏览器的可见客户区的右上角出现一个Loading ...的提示条,但自己觉得颜色不是很好看,想改一下,发现MA是把scripts都搞到dll里去了,然后通过实现httpModules把scripts再Export出来,具体是在编译时生成一个WebResource.axd(在运行时才动态生成)。可是自己想改script,看看文档的Configuration一节
ScriptPath
Type: string
Default: null (omitted)
Description: MagicAjax's script files are embedded in the dll and are put on page using script tags like this:
<script type="text/javascript" src="AjaxCallObject.js.aspx"></script>
If you set ScriptPath to a value, the src attribute of the script tag will contain the path of ScriptPath. That way you can use your own modified versions of MagicAjax's script files. Example:
<magicAjax ScriptPath="~/script" />
在Core里找到script文件夹,添加到工程目录里,然后按照文档设置web.config文件,再把AjaxCallObject.js中的
function CreateWaitElement() {
var elem = document.getElementById('__AjaxCall_Wait');
if (!elem) {
elem = document.createElement("div");
elem.id = '__AjaxCall_Wait';
elem.style.position = 'absolute';
elem.style.height = 17;
elem.border = "1px";
elem.style.paddingLeft = "3px";
elem.style.paddingRight = "3px";
elem.style.fontSize = "11px";
elem.style.borderColor = "#ffffff";
elem.style.borderSize = "1px";
elem.style.backgroundColor = "DimGray";
elem.style.color = "#ffffff";
elem.innerHTML = 'Loading ';
elem.style.visibility = 'hidden';
document.body.insertBefore(elem, document.body.firstChild);
}
waitElement = elem;
}
一段代码做一些修改,比如elem.style.color="#000000";这样再出现Loading ...时字体应该是黑的了吧?
嘿,这一运行,还真没成功!!!
肯定不是script的错!玩了N的js,再把这搞错也太说不过去了!
判断问题出现在config里。
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="magicAjax" type="MagicAjax.Configuration.MagicAjaxSectionHandler, MagicAjax"/>
</configSections>
<magicAjax ScriptPath="~/script">
<pageStore/>
</magicAjax>
<system.web>
<authentication mode="Forms" />
..
<httpModules>
<add name="MagicAjaxModule" type="MagicAjax.MagicAjaxModule, MagicAjax"/>
</httpModules>
</system.web>
</configuration>
路径没问题,XML大小写敏感,拼写都是按文档写的,没问题,靠,Where?
最后,幸好MA开源的,找到MA的代码工程,打开一看:靠,靠,靠!
看到MagicAjaxConfiguration.cs
public MagicAjaxConfiguration(XmlNode xml)
{
// Default values
_scriptPath = null; // Null implicates that the embedded javascripts will be used (default)
_compareMode = OutputCompareMode.HashCode;
_tracing = false;
PageStoreMode mode = PageStoreMode.NoStore;
bool unloadStoredPage = false;
int cacheTimeout = 5;
int maxPages = 5;
bool maxPagesLimitAlert = false;
if (xml != null)
{
XmlAttribute attrib = (XmlAttribute)xml.Attributes.GetNamedItem("scriptPath");
倒,是scriptPath呀!!!
又看看文档,它真的是写的<magicAjax ScriptPath="~/script" />不是我的错!!!
该死的文档,不如不写!!!
准备,好好研究下MA的代码,因为昨晚发现把Loading改称中文出来的是乱码,是编码格式的问题。
如果,在浏览时把编码改为“简体中文”这样Loading条就正常显示了,可是页面其他中文都乱码了,应该把MA的Encoding改了。太晚了……就睡了,今天下午看看有时间的话来搞它!
我以后要么不写文档,写就负责任的写!
因为使用MA的无刷新效果总是在浏览器的可见客户区的右上角出现一个Loading ...的提示条,但自己觉得颜色不是很好看,想改一下,发现MA是把scripts都搞到dll里去了,然后通过实现httpModules把scripts再Export出来,具体是在编译时生成一个WebResource.axd(在运行时才动态生成)。可是自己想改script,看看文档的Configuration一节
ScriptPath
Type: string
Default: null (omitted)
Description: MagicAjax's script files are embedded in the dll and are put on page using script tags like this:
<script type="text/javascript" src="AjaxCallObject.js.aspx"></script>
If you set ScriptPath to a value, the src attribute of the script tag will contain the path of ScriptPath. That way you can use your own modified versions of MagicAjax's script files. Example:
<magicAjax ScriptPath="~/script" />
在Core里找到script文件夹,添加到工程目录里,然后按照文档设置web.config文件,再把AjaxCallObject.js中的
function CreateWaitElement() {
var elem = document.getElementById('__AjaxCall_Wait');
if (!elem) {
elem = document.createElement("div");
elem.id = '__AjaxCall_Wait';
elem.style.position = 'absolute';
elem.style.height = 17;
elem.border = "1px";
elem.style.paddingLeft = "3px";
elem.style.paddingRight = "3px";
elem.style.fontSize = "11px";
elem.style.borderColor = "#ffffff";
elem.style.borderSize = "1px";
elem.style.backgroundColor = "DimGray";
elem.style.color = "#ffffff";
elem.innerHTML = 'Loading ';
elem.style.visibility = 'hidden';
document.body.insertBefore(elem, document.body.firstChild);
}
waitElement = elem;
}
一段代码做一些修改,比如elem.style.color="#000000";这样再出现Loading ...时字体应该是黑的了吧?
嘿,这一运行,还真没成功!!!
肯定不是script的错!玩了N的js,再把这搞错也太说不过去了!
判断问题出现在config里。
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="magicAjax" type="MagicAjax.Configuration.MagicAjaxSectionHandler, MagicAjax"/>
</configSections>
<magicAjax ScriptPath="~/script">
<pageStore/>
</magicAjax>
<system.web>
<authentication mode="Forms" />
..
<httpModules>
<add name="MagicAjaxModule" type="MagicAjax.MagicAjaxModule, MagicAjax"/>
</httpModules>
</system.web>
</configuration>
路径没问题,XML大小写敏感,拼写都是按文档写的,没问题,靠,Where?
最后,幸好MA开源的,找到MA的代码工程,打开一看:靠,靠,靠!
看到MagicAjaxConfiguration.cs
public MagicAjaxConfiguration(XmlNode xml)
{
// Default values
_scriptPath = null; // Null implicates that the embedded javascripts will be used (default)
_compareMode = OutputCompareMode.HashCode;
_tracing = false;
PageStoreMode mode = PageStoreMode.NoStore;
bool unloadStoredPage = false;
int cacheTimeout = 5;
int maxPages = 5;
bool maxPagesLimitAlert = false;
if (xml != null)
{
XmlAttribute attrib = (XmlAttribute)xml.Attributes.GetNamedItem("scriptPath");
倒,是scriptPath呀!!!
又看看文档,它真的是写的<magicAjax ScriptPath="~/script" />不是我的错!!!
该死的文档,不如不写!!!
准备,好好研究下MA的代码,因为昨晚发现把Loading改称中文出来的是乱码,是编码格式的问题。
如果,在浏览时把编码改为“简体中文”这样Loading条就正常显示了,可是页面其他中文都乱码了,应该把MA的Encoding改了。太晚了……就睡了,今天下午看看有时间的话来搞它!
我以后要么不写文档,写就负责任的写!
相关文章推荐
- collection下list用法 很常用 (个人建议下载纯英文文档,翻译可能不如原版能让你明白)
- 套模板也写不好PRD、竞品分析?不如用8天学习高阶产品经理的文档撰写法!
- log.c -- 看文档,还不如看代码来的简单。
- 好记性不如烂笔头61-XML文档结构和属性说明
- document.write()、onclick="alert(xxx)、innerHTML、image.src.match("xxx")、id2.style.color="blue";、isNaN(id2)、document.write("糟糕!文档消失了。")、alert(id2.outerHTML)、id2.className="id06";、onclick="return registe"
- 经典面试问题:12小球问题算法(文档)
- 公司引擎宣传文档
- linux kernel 和内存方面的文档链接
- Master Note for Diagnosing ORA-7445 and Related Core Dumps (文档 ID 1092855.1)
- hadoop2.7文档翻译第一天
- sharding-jdbc报错--schema_reference.4: 无法读取方案文档 'http://www.dangdang.com/schema/ddframe/rdb/rdb.xsd',
- 《Spark Python API 官方文档中文版》 之 pyspark.sql (一)
- 分层架构文档
- 去掉WORD文档中向下的小箭头(换行符)
- StarUML文档转载说明
- 游览器---文档流
- 解决SharePoint 文档库itemadded eventhandler导致的上传完成后,编辑页面保持报错的问题,错误信息为“该文档已经被编辑过 the file has been modified by...”
- 利用beego自动生成带数据库基本CRUD的API和自动化文档
- 使用apache POI 进行word文档的操作,信息填值。
- 产品规划和设计文档示范