<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>鬼の领地 &#187; Discuz!</title>
	<atom:link href="http://blog.upsuper.org/tag/discuz/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.upsuper.org</link>
	<description>the place where there are some ghost appearing...</description>
	<lastBuildDate>Thu, 17 Jun 2010 08:12:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>修改 ASCIIMathML.js 适应 Discuz! 6.0</title>
		<link>http://blog.upsuper.org/edit-asciimathml-js-for-discuz-6/</link>
		<comments>http://blog.upsuper.org/edit-asciimathml-js-for-discuz-6/#comments</comments>
		<pubDate>Sun, 31 Aug 2008 03:17:00 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[雕虫小技]]></category>
		<category><![CDATA[Discuz!]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MathML]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=590</guid>
		<description><![CDATA[前几天，一位大牛 (Mathself) 提议给论坛安装上一个数学插件，并且告诉我参看奥数之家论坛。我经过研究发现，就是一个叫做 ASCIIMathML.js 的文件在起作用，这个文件将类 LaTeX 的公式转换为 MathML。Firefox 提供原声的 MathML 支持，而 IE8 以下的版本需要 MathPlayer 插件支持，Opera 自 9.5 起提供原生的 MathML 支持。

经过研究，首先发现，ASCIIMathML.js 默认不提供 Opera 的支持，对 ASCIIMathML.js先做了点小修改：

75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
function AMisMathMLavailable&#40;&#41; &#123;
  if &#40;navigator.appName.slice&#40;0,8&#41;==&#34;Netscape&#34;&#41; 
    if &#40;navigator.appVersion.slice&#40;0,1&#41;&#62;=&#34;5&#34;&#41; return null;
    else return AMnoMathMLNote&#40;&#41;;
  else if &#40;window.opera&#41;
    return null;
  else if [...]]]></description>
			<content:encoded><![CDATA[<p>前几天，一位大牛 (Mathself) 提议给论坛安装上一个数学插件，并且告诉我参看<a href="http://www.aoshoo.com/bbs1/index.asp" target="_blank">奥数之家论坛</a>。我经过研究发现，就是一个叫做 ASCIIMathML.js 的文件在起作用，这个文件将类 LaTeX 的公式转换为 MathML。Firefox 提供原声的 MathML 支持，而 IE8 以下的版本需要 MathPlayer 插件支持，Opera 自 9.5 起提供原生的 MathML 支持。<br />
<span id="more-590"></span><br />
经过研究，首先发现，ASCIIMathML.js 默认不提供 Opera 的支持，对 ASCIIMathML.js先做了点小修改：</p>

<div class="wp_codebox"><table><tr id="p5904"><td class="line_numbers"><pre>75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
</pre></td><td class="code" id="p590code4"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> AMisMathMLavailable<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>navigator.<span style="color: #660066;">appName</span>.<span style="color: #660066;">slice</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">&quot;Netscape&quot;</span><span style="color: #009900;">&#41;</span> 
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>navigator.<span style="color: #660066;">appVersion</span>.<span style="color: #660066;">slice</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;=</span><span style="color: #3366CC;">&quot;5&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">return</span> AMnoMathMLNote<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">opera</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>navigator.<span style="color: #660066;">appName</span>.<span style="color: #660066;">slice</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">9</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">&quot;Microsoft&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> ActiveX <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;MathPlayer.Factory.1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">return</span> AMnoMathMLNote<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">return</span> AMnoMathMLNote<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>不过话说 Opera 对 MathML 的支持实在有限……感觉看起来很囧的说……</p>
<p>把这个弄到服务器以后，我就钻空子注册了一个带公式的用户名。结果 Doggy 瞬间出台规定禁止……我说还不如从代码上禁用……又经过一番研究，发觉只要改 ASCIIMathML.js 的代码就可以了，下面是研究成果：首先是修改 onLoad 直接调用的 generic：</p>

<div class="wp_codebox"><table><tr id="p5905"><td class="line_numbers"><pre>903
904
905
906
</pre></td><td class="code" id="p590code5"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> generic<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  translate<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>那个 true 表示仅转换需要的地方。</p>
<p>然后是修改处理的地方：</p>

<div class="wp_codebox"><table><tr id="p5906"><td class="line_numbers"><pre>861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
</pre></td><td class="code" id="p590code6"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> AMprocessNode<span style="color: #009900;">&#40;</span>n<span style="color: #339933;">,</span> linebreaks<span style="color: #339933;">,</span> spanclassAM<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> frag<span style="color: #339933;">,</span>st<span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>spanclassAM<span style="color: #339933;">!=</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    frag <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>frag.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>frag<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">className</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;t_msgfont&quot;</span><span style="color: #009900;">&#41;</span>
        AMprocessNodeR<span style="color: #009900;">&#40;</span>frag<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>linebreaks<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
      st <span style="color: #339933;">=</span> n.<span style="color: #660066;">innerHTML</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span>err<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>st<span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">||</span> 
        st.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span>AMdelimiter1<span style="color: #009900;">&#41;</span><span style="color: #339933;">!=-</span><span style="color: #CC0000;">1</span> <span style="color: #339933;">||</span> st.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span>AMdelimiter2<span style="color: #009900;">&#41;</span><span style="color: #339933;">!=-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> 
      AMprocessNodeR<span style="color: #009900;">&#40;</span>n<span style="color: #339933;">,</span>linebreaks<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>isIE<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">//needed to match size and font of formula to surrounding text</span>
    frag <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'math'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>frag.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> frag<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">update</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>为什么这样改呢……因为在 Discuz! 里面帖子内容都是在 div 标签里……而且这些标签有一个共同特征，那就是有 t_msgfont 这个 class！于是这样改完，就可以仅仅在帖子内容中使用 MathML 了！</p>
<p>我是根据很早以前的 1.4.7 版本改的……虽然据说有很新的版本……2.x 什么的……不想管了……<br />
如果不想自己改的话，直接从这里下载改好的文件：<a href="http://www.fzyz.cn/forum/include/javascript/ASCIIMathML.js">ASCIIMathML.js</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/edit-asciimathml-js-for-discuz-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>我的newwap</title>
		<link>http://blog.upsuper.org/my-newwap/</link>
		<comments>http://blog.upsuper.org/my-newwap/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 06:06:36 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[我的计划]]></category>
		<category><![CDATA[Discuz!]]></category>
		<category><![CDATA[WAP]]></category>
		<category><![CDATA[学校]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=77</guid>
		<description><![CDATA[学校的论坛一直以来人气都比不过贴吧，我个人分析原因有一定来自手机访问的方便性。说实话，DZ论坛原来那个WAP版我也觉得做的不怎么样，于是我就自己写！
已经写了一个有一点点功能的版本http://www.fzyz.cn/forum/newwap，但因为写得太乱了，于是重新大改，构成了这个正在做的版本http://www.fzyz.cn/forum/w。
DZ果然是一个逊霸，完全没有为后面开发做考虑…… Doggy 说WP在这点做的很好，不过我没写过WP的插件，不做评论。
]]></description>
			<content:encoded><![CDATA[<p>学校的论坛一直以来人气都比不过贴吧，我个人分析原因有一定来自手机访问的方便性。说实话，DZ论坛原来那个WAP版我也觉得做的不怎么样，于是我就自己写！</p>
<p>已经写了一个有一点点功能的版本<a href="http://www.fzyz.cn/forum/newwap">http://www.fzyz.cn/forum/newwap</a>，但因为写得太乱了，于是重新大改，构成了这个正在做的版本<a href="http://www.fzyz.cn/forum/w">http://www.fzyz.cn/forum/w</a>。</p>
<p>DZ果然是一个逊霸，完全没有为后面开发做考虑…… Doggy 说WP在这点做的很好，不过我没写过WP的插件，不做评论。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/my-newwap/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>终于把宠物中心装好了</title>
		<link>http://blog.upsuper.org/installed-pet-cente/</link>
		<comments>http://blog.upsuper.org/installed-pet-cente/#comments</comments>
		<pubDate>Thu, 31 Jan 2008 11:37:35 +0000</pubDate>
		<dc:creator>upsuper</dc:creator>
				<category><![CDATA[雕虫小技]]></category>
		<category><![CDATA[Discuz!]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[插件]]></category>

		<guid isPermaLink="false">http://blog.upsuper.org/?p=9</guid>
		<description><![CDATA[在大家的强烈支持下，我把DZ论坛的无心宠物中心插件装好了。
为了装这个宠物中心，我把include/db_mysql.class.php都改了，如果大家在安装后发现宠物中心不能启动，并且提示找不到query_first，那么查找

1
2
3
function affected_rows&#40;&#41; &#123;
	return mysql_affected_rows&#40;$this-&#62;link&#41;;
&#125;

前面加上：

1
2
3
function query_first&#40;$sql&#41; &#123;
	return $this-&#62;fetch_array&#40;$this-&#62;query&#40;$sql&#41;&#41;;
&#125;

我曾经试图修改插件的文件，结果发现，这个插件用这个文件用得太多了，干脆改论坛的核心文件了。
]]></description>
			<content:encoded><![CDATA[<p>在大家的强烈支持下，我把DZ论坛的无心宠物中心插件装好了。</p>
<p>为了装这个宠物中心，我把<em>include/db_mysql.class.php</em>都改了，如果大家在安装后发现宠物中心不能启动，并且提示找不到<em>query_first</em>，那么查找</p>

<div class="wp_codebox"><table><tr id="p99"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p9code9"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> affected_rows<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">mysql_affected_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">link</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>前面加上：</p>

<div class="wp_codebox"><table><tr id="p910"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p9code10"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> query_first<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>我曾经试图修改插件的文件，结果发现，这个插件用这个文件用得太多了，干脆改论坛的核心文件了。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.upsuper.org/installed-pet-cente/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
