• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisão6e26fb8ee01157ba9a9880f50ffbf65004185b8e (tree)
Hora2015-01-11 16:06:14
Autorumorigu <umorigu@gmai...>
Commiterumorigu

Mensagem de Log

Mudança Sumário

Diff

--- a/skin/pukiwiki.skin.php
+++ b/skin/pukiwiki.skin.php
@@ -78,6 +78,7 @@ if (isset($pkwk_dtd)) {
7878
7979 <title><?php echo $title ?> - <?php echo $page_title ?></title>
8080
81+ <script type="text/javascript" src="skin/unclink.js"></script>
8182 <link rel="SHORTCUT ICON" href="<?php echo $image['favicon'] ?>" />
8283 <link rel="stylesheet" type="text/css" media="screen" href="<?php echo SKIN_DIR ?>pukiwiki.css.php?charset=<?php echo $css_charset ?>" charset="<?php echo $css_charset ?>" />
8384 <link rel="stylesheet" type="text/css" media="print" href="<?php echo SKIN_DIR ?>pukiwiki.css.php?charset=<?php echo $css_charset ?>&amp;media=print" charset="<?php echo $css_charset ?>" />
--- /dev/null
+++ b/skin/unclink.js
@@ -0,0 +1,56 @@
1+// unclink.js
2+
3+if (window.addEventListener && Array.prototype.indexOf
4+ && document.createDocumentFragment) {
5+ window.addEventListener('DOMContentLoaded', function() {
6+ function uncToUrl(unc) {
7+ var ua = navigator.userAgent;
8+ if (ua.indexOf('Macintosh') >= 0) {
9+ return unc.replace(/^\\\\/, 'smb://').replace(/\\/g, '/');
10+ } else if (ua.indexOf('Firefox') >= 0) {
11+ return unc.replace(/^\\\\/, 'file://///').replace(/\\/g, '/');
12+ } else {
13+ return unc.replace(/^\\\\/, 'file://').replace(/\\/g, '/');
14+ }
15+ }
16+ function makeUncLink(element) {
17+ var re = /([\s\<\>]|^)(\\\\([a-zA-Z0-9\-]+)(\.[a-zA-Z0-9\-]+)+\\[^\\\/\:\*\?\"\>\<\|\;\s][^\/\:\*\?\"\>\<\|\;\s]*)/;
18+ var f, m, text = element.nodeValue;
19+ while (m = text.match(re)) {
20+ // m[1]: head, m[2]: UNC path
21+ f || (f = document.createDocumentFragment());
22+ if (m.index > 0 || m[1].length > 0) {
23+ f.appendChild(document.createTextNode(text.substr(0, m.index) + m[1]));
24+ }
25+ var a = document.createElement('a');
26+ a.textContent = m[2];
27+ a.href = uncToUrl(a.textContent);
28+ f.appendChild(a);
29+ text = text.substr(m.index + m[0].length);
30+ }
31+ if (f) {
32+ text.length > 0 && f.appendChild(document.createTextNode(text));
33+ element.parentNode.replaceChild(f, element)
34+ }
35+ }
36+ var ignoreTags = ['A', 'INPUT', 'TEXTAREA', 'BUTTON',
37+ 'SCRIPT', 'FRAME', 'IFRAME'];
38+ function walkElement(element) {
39+ var e = element.firstChild;
40+ while (e) {
41+ if (e.nodeType == 3 && e.nodeValue.length > 5 && /\S/.test(e.nodeValue)) {
42+ var next = e.nextSibling;
43+ makeUncLink(e);
44+ e = next;
45+ } else {
46+ if (e.nodeType == 1 && ignoreTags.indexOf(e.tagName) == -1) {
47+ walkElement(e);
48+ }
49+ e = e.nextSibling;
50+ }
51+ }
52+ }
53+ var target = document.getElementById('body');
54+ walkElement(target);
55+ });
56+}