From 7ac93841d69f533c9ada9c19dc3ba9dc6af50bdc Mon Sep 17 00:00:00 2001 From: virusdefender <1670873886@qq.com> Date: Fri, 11 Sep 2015 18:21:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B5=8F=E8=A7=88=E5=99=A8?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E6=94=AF=E6=8C=81=20flash=20=E7=9A=84?= =?UTF-8?q?=E5=88=A4=E6=96=AD=EF=BC=8C=E5=A4=8D=E5=88=B6=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=20Flash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/src/js/app/oj/problem/problem.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/static/src/js/app/oj/problem/problem.js b/static/src/js/app/oj/problem/problem.js index 360569c..e34daea 100644 --- a/static/src/js/app/oj/problem/problem.js +++ b/static/src/js/app/oj/problem/problem.js @@ -6,9 +6,26 @@ require(["jquery", "codeMirror", "csrfToken", "bsAlert", "ZeroClipboard"], return; } - // 提供点击复制到剪切板的功能 - ZeroClipboard.config({swfPath: "/static/img/ZeroClipboard.swf"}); - new ZeroClipboard($(".copy-sample")); + // 复制样例需要 Flash 的支持 检测浏览器是否安装了 Flash + function detect_flash() { + var ie_flash; + try { + ie_flash = (window.ActiveXObject && (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) !== false) + } catch (err) { + ie_flash = false; + } + var _flash_installed = ((typeof navigator.plugins != "undefined" && typeof navigator.plugins["Shockwave Flash"] == "object") || ie_flash); + return _flash_installed; + } + + if(detect_flash()) { + // 提供点击复制到剪切板的功能 + ZeroClipboard.config({swfPath: "/static/img/ZeroClipboard.swf"}); + new ZeroClipboard($(".copy-sample")); + } + else{ + $(".copy-sample").hide(); + } var codeEditor = codeMirror(codeEditorSelector, "text/x-csrc"); var language = $("input[name='language'][checked]").val(); @@ -186,4 +203,4 @@ require(["jquery", "codeMirror", "csrfToken", "bsAlert", "ZeroClipboard"], } } }) - }); + }); \ No newline at end of file