Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
123
返回列表 发新帖

[插件] 代码缩放 for 4.0

[复制链接]
飞飞小剑 发表于 2006-1-15 21:10:26 | 显示全部楼层
问题已经解决
如下
codedisp函数替换成如下代码

function codedisp($code) {
        global $discuzcodes;
        $discuzcodes['pcodecount']++;
        $code = htmlspecialchars(str_replace('\\"', '"', preg_replace("/^[\n\r]*(.+?)[\n\r]*$/is", "\\1", $code)));
        $discuzcodes['codehtml'][$discuzcodes['pcodecount']] = "<br><textarea name='FF$discuzcodes[pcodecount]' rows=\"15\" cols=\"95\">$code</textarea><br><input type=\"button\" value=\"运行代码\" onclick=\"runCode(FF$discuzcodes[pcodecount])\">&nbsp;<input type=\"button\" value=\"复制代码\" onclick=\"copyCode(FF$discuzcodes[pcodecount])\">&nbsp;<input type=\"button\" value=\"另存代码\" onclick=\"saveCode(FF$discuzcodes[pcodecount])\">&nbsp;<script language=JavaScript>ffcod=delpost.FF$discuzcodes[pcodecount].value;ffcod=ffcod.replace(/<br \/>/g,'');delpost.FF$discuzcodes[pcodecount].value=ffcod;</script>提示:你可以先修改部分代码再运行<br>";
        return "[\tDISCUZ_CODE_$discuzcodes[pcodecount]\t]";
}



在common.js文件里增加如下函数


function runCode(obj) {
        var winname = window.open('', "_blank", '');
        winname.document.open('text/html', 'replace');
        winname.document.writeln(obj.value);
        winname.document.close();
}

function saveCode(obj) {
        var winname = window.open('', '_blank', 'top=10000');
        winname.document.open('text/html', 'replace');
        winname.document.writeln(obj.value);
        winname.document.execCommand('saveas','','code.htm');
        winname.close();
}

[ 本帖最后由 飞飞小剑 于 2006-1-15 22:51 编辑 ]
回复

使用道具 举报

uv123 发表于 2006-1-15 22:16:01 | 显示全部楼层
原帖由 飞飞小剑 于 2006-1-15 21:10 发表
问题已经解决
如下
codedisp函数替换成如下代码

function codedisp($code) {
        global $discuzcodes;
        $discuzcodes['pcodecount']++;
        $code = htmlspecialchars(str_replace('\\"', '"', pre ...


按照你的代码修改后,会有网页发生错误状况,及复制代码和另存代码都无法使用
回复

使用道具 举报

飞飞小剑 发表于 2006-1-15 22:49:14 | 显示全部楼层
回复

使用道具 举报

xzc0001 发表于 2006-1-27 19:44:22 | 显示全部楼层
帮你顶上去
回复

使用道具 举报

ruokuang 发表于 2006-2-6 11:25:55 | 显示全部楼层
还是不行!
回复

使用道具 举报

偏店浪人 发表于 2006-4-3 13:52:04 | 显示全部楼层
不错。收藏了再慢慢看。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-5-26 07:32 , Processed in 1.281069 second(s), 15 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表