diff --git a/a.rb b/a.rb new file mode 100755 index 0000000..2249653 --- /dev/null +++ b/a.rb @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +# -*- coding: utf-8 -*- + +asobu = gets.chomp.to_i +kinyuu = gets.chomp + +puts"遊ぶなら1、遊ばないなら2を入力して下さい" +puts"数字を入力:" +while true + if asobu == 1 + puts"名前を決めてね!" + puts"記入:" + sleep(1) + puts"..." + sleep(2) + printf("%dさんよろしくね!\n",kinyuu) + puts"ー対戦ー" + puts"" + + + break + elsif asobu == 2 + puts"了解です" + break + else + puts"もう一回入力してね" + redo + end +end + + diff --git a/after1.jpg b/after1.jpg new file mode 100644 index 0000000..869bd59 --- /dev/null +++ b/after1.jpg Binary files differ diff --git a/after2.jpg b/after2.jpg new file mode 100644 index 0000000..cf38a52 --- /dev/null +++ b/after2.jpg Binary files differ diff --git a/after3.jpg b/after3.jpg new file mode 100644 index 0000000..96b41d6 --- /dev/null +++ b/after3.jpg Binary files differ diff --git a/before.jpg b/before.jpg new file mode 100644 index 0000000..660e13f --- /dev/null +++ b/before.jpg Binary files differ diff --git a/game.rb b/game.rb index 0287991..ecb365f 100755 --- a/game.rb +++ b/game.rb @@ -1,15 +1,12 @@ #!/usr/bin/env ruby # -*- coding: utf-8 -*- - +while true print "Roading.......\n" -nokori = 10 - -while nokori > 0 sleep(5) - nokori = nokori - 1 + puts"START" + puts"タイピングをしよう!" + end -puts"MUSIC GAME" - diff --git a/jaken...rb b/jaken...rb new file mode 100755 index 0000000..3ca8096 --- /dev/null +++ b/jaken...rb @@ -0,0 +1,3 @@ +#!/usr/bin/env/ruby +# -*- coding: utf-8 -*- + diff --git a/program.rb b/program.rb new file mode 100755 index 0000000..675d86f --- /dev/null +++ b/program.rb @@ -0,0 +1,60 @@ +#!/usr/koeki/bin/ruby +# -*- coding: utf-8 -*- + +#初期設定 + +require 'curses' +include Curses + +init_screen +cbreak +noecho + +rt = [] + +begin + sleep(0) + + 10.times do + system("display -geometry +30+20 before.jpg&") + sleep(2) + system('pkill magick -U `whoami`') + srand + i = rand(3)+1 + if i == 1 + system("display -geometry +30+20 after1.jpg&") + elsif i == 2 + system("display -geometry +30+20 after2.jpg&") + elsif i == 3 + system("display -geometry +30+20 after3.jpg&") + end + setpos(0,0) + addstr("\n 1:安全 2:危険") + refresh + start = Time.now + answer = getch + stop = Time.now + rt << [i,answer,stop.to_f - start.to_f] + refresh + + system('pkill magick -U `whoami`') + setpos(0,0) + addstr("\n ") + refresh + sleep(2) + end + + correct = 0 + total = 0 + for j in rt + total += j[2] + if (j[0] == 1 && j[1] == "1") || (j[0] != 1 && j[1] == "2") + correct += 1 + end + end + +ensure + close_screen +end + +printf("正答%d回  反応時間%5.3f秒\n", correct, total/10) diff --git a/program_advanced.rb b/program_advanced.rb new file mode 100644 index 0000000..d740d94 --- /dev/null +++ b/program_advanced.rb @@ -0,0 +1,66 @@ +#!/usr/koeki/bin/ruby +# -*- coding: utf-8 -*- + +#初期設定 + +require 'curses' +include Curses + +init_screen +cbreak +noecho + +rt = [] + +begin + sleep(0) + + 10.times do + system("display -geometry +0+0 before.jpg&") + sleep(2) + system('pkill magick -U `whoami`') + srand + i = rand(3)+1 + if i == 1 + system("display -geometry +400+0 quiz1.jpg&") + sleep(0.5) + system("display -geometry +0+0 after1.jpg&") + elsif i == 2 + system("display -geometry +400+0 quiz1.jpg") + sleep(0.5) + system("display -geometry +0+0 after2.jpg&") + elsif i == 3 + system("display -geometry +400+0 quiz1.jpg&") + sleep(0.5) + system("display -geometry +0+0 after3.jpg&") + end + setpos(0,0) + addstr("\n 1:安全 2:危険") + refresh + start = Time.now + answer = getch + stop = Time.now + rt << [i,answer,stop.to_f - start.to_f] + refresh + + system('pkill magick -U `whoami`') + setpos(0,0) + addstr("\n ") + refresh + sleep(2) + end + + correct = 0 + total = 0 + for j in rt + total += j[2] + if (j[0] == 1 && j[1] == "1") || (j[0] != 1 && j[1] == "2") + correct += 1 + end + end + +ensure + close_screen +end + +printf("正答%d回  反応時間%5.3f秒\n", correct, total/10) diff --git a/quiz.csv b/quiz.csv new file mode 100644 index 0000000..4c25671 --- /dev/null +++ b/quiz.csv @@ -0,0 +1,5 @@ +問題,選択肢1,選択肢2,選択肢3,正解番号,正解コメント,不正解コメント +パンはパンでも食べられないパンは,腐ったパン,フライパン,シャンパン,3,"シャンパンは飲み物 +他のは腹を壊していいなら行ける(行くなよ)",ぶぶー +アルミ缶の上にあるものは,未完,ある蜜柑,蜜柑がみっかんない,2,「或る」蜜柑なのだ,ぶぶー +Rubyで文字列を読み取るときは,gets,def,yomu,1,kotae=gets.chompなんてするといいね,ぶぶー diff --git a/quiz1.jpg b/quiz1.jpg new file mode 100644 index 0000000..a9e568d --- /dev/null +++ b/quiz1.jpg Binary files differ diff --git a/quiz2.jpg b/quiz2.jpg new file mode 100644 index 0000000..f8cced8 --- /dev/null +++ b/quiz2.jpg Binary files differ diff --git a/roket.rb b/roket.rb new file mode 100755 index 0000000..e8b4930 --- /dev/null +++ b/roket.rb @@ -0,0 +1,182 @@ +#!/usr/koeki/bin/ruby +# -*- coding: utf-8 -*- +# Curses でロケットの運動を描画する +# 作者:山本裕樹 + +require "curses" + +# 万有引力定数 G = 6.67430×10^-11 [m^3/kg/s^2] +# 地球の質量 ME = 5.9724×10^24 [kg] +# 地球の半径 RE = 6.3781x10^6 [m] +$G = 6.67430e-11 +$ME = 5.9724e24 +$RE = 6.3781e6 + +# 現実の座標から端末上の座標に変換するための x, y 方向のスケール +$xscale = 10.0 +$yscale = 5.0 + +# 初期値 +# ($x0, $y0):ロケットの発射位置(単位 [m]) +# ($u0, $v0):ロケットの発射速度(単位 [m/s]) +# $dt:時間の刻み(単位 [s]) +$x0 = $RE + 10 +$y0 = 0 +$u0 = 6000 +$v0 = 6000 +$dt = 60 + +# 原点から (x, y) までの距離 +def r(x, y) + return Math.sqrt(x ** 2 + y ** 2) +end + +# 運動方程式の右辺1 +def f(x, y) + return - $G * $ME * x / r(x, y) ** 3 +end + +# 運動方程式の右辺2 +def g(x, y) + return - $G * $ME * y / r(x, y) ** 3 +end + +# ku, kv, kx, ky の計算 +def calc_k(u, v, x, y, du, dv, dx, dy) + return f(x + dx, y + dy) * $dt, + g(x + dx, y + dy) * $dt, + (u + du) * $dt, + (v + dv) * $dt +end + +# ルンゲ=クッタ法で $dt 後の (x,y) と (u,v) を求める +def next_step(u, v, x, y) + ku1, kv1, kx1, ky1 = calc_k(u, v, x, y, 0, 0, 0, 0) + ku2, kv2, kx2, ky2 = calc_k(u, v, x, y, + ku1 * 0.5, kv1 * 0.5, kx1 * 0.5, ky1 * 0.5) + ku3, kv3, kx3, ky3 = calc_k(u, v, x, y, + ku2 * 0.5, kv2 * 0.5, kx2 * 0.5, ky2 * 0.5) + ku4, kv4, kx4, ky4 = calc_k(u, v, x, y, ku3, kv3, kx3, ky3) + return u + (ku1 + 2 * ku2 + 2 * ku3 + ku4) / 6.0, + v + (kv1 + 2 * kv2 + 2 * kv3 + kv4) / 6.0, + x + (kx1 + 2 * kx2 + 2 * kx3 + kx4) / 6.0, + y + (ky1 + 2 * ky2 + 2 * ky3 + ky4) / 6.0 +end + +# 現実の座標 (x,y) から端末上の座標 (cx,cy) へ変換 +def x2cx(x) ($cox + x / $RE * $xscale).round end +def y2cy(y) ($coy - y / $RE * $yscale).round end + +# 端末上の座標 (cx,cy) から現実の座標 (x,y) へ変換 +def cx2x(cx) (cx - $cox) * $RE / $xscale end +def cy2y(cy) -(cy - $coy) * $RE / $yscale end + +# (0, 0) を中心に地球を描く +def draw_earth + # 地球の色の設定 + Curses.attrset(Curses.color_pair(2)) + + # 端末上の全ての座標をスキャンして地球の半径内なら地球を出力 + 0.upto(Curses.cols - 1) do |cx| + 0.upto(Curses.lines - 1) do |cy| + if r(cx2x(cx), cy2y(cy)) < $RE + Curses.setpos(cy, cx) + Curses.addch(' ') + end + end + end +end + +# 現実の座標 (x,y) から端末上の座標へ変換して文字 ch を出力 +def puts_char(x, y, ch) + cx = x2cx(x) + cy = y2cy(y) + if (cx >= 0 && cx <= Curses.cols - 1) && + (cy >= 0 && cy <= Curses.lines - 1) + Curses.setpos(cy, cx) + Curses.addch(ch) + end +end + +# Cursesの初期化 +Curses.init_screen + +begin + # 色の設定 + Curses.start_color + Curses.init_pair(1, Curses::COLOR_WHITE, Curses::COLOR_BLACK) + Curses.init_pair(2, Curses::COLOR_BLACK, Curses::COLOR_BLUE) + Curses.init_pair(3, Curses::COLOR_CYAN, Curses::COLOR_BLACK) + Curses.init_pair(4, Curses::COLOR_BLACK, Curses::COLOR_RED) + + # 端末の中央の座標 + $cox = ((Curses.cols - 1) * 0.5).round + 0.5 + $coy = ((Curses.lines - 1) * 0.5).round + 0.5 + + # カーソルを非表示 + Curses.curs_set(0) + + # キー入力で待つ時間(ミリ秒) + Curses.stdscr.timeout = 60 + + # 初期値を代入 + x = $x0 + y = $y0 + u = $u0 + v = $v0 + + # 時間 + i = 0 + + # ロケットの軌道を描くループ + while 1 + # 地球を出力 + draw_earth + + # デフォルトの色 + Curses.attrset(Curses.color_pair(1)) + + # 時刻の出力 + Curses.setpos(Curses.lines - 1, 0) + Curses.addstr(sprintf("t=%d[s]\n", i * $dt)) + + if (r(x, y) > $RE) + # ロケットを出力 + puts_char(x, y, 'R') + else + # 爆発を出力 + Curses.attrset(Curses.color_pair(4)) + puts_char(x, y, 'X') + Curses.refresh + # ループを抜ける + break + end + + # キー入力があるか + if Curses.getch != nil + # ループを抜ける + break + end + + # (x, y) にロケットの跡を出力 + Curses.attrset(Curses.color_pair(3)) + puts_char(x, y, '.') + + # 画面表示の更新 + Curses.refresh + + # $dt 後の (x,y) を求める + u, v, x, y = next_step(u, v, x, y) + i += 1 + end + + # キー入力があるまでずっと待つ + Curses.stdscr.timeout = -1 + Curses.getch + +ensure + # Cursesの終了処理 + Curses.close_screen +end + + diff --git a/tiping..rb b/tiping..rb new file mode 100755 index 0000000..abbe1b0 --- /dev/null +++ b/tiping..rb @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# -*- coding: utf-8 -*- + +asobu = gets.chomp.to_i + +def hiragana() + betto = ["あ","い","う","え","お","か","き","く","け","こ","さ","し","す","せ","そ","た","ち","つ","て","と","な","に","ぬ","ね","の","は","ひ","ふ","へ","ほ","ま","み","む","め","も","や","ゆ","よ","ら","り","る","れ","ろ","わ","を","ん","!","?","。","、"] + betto[rand(betto.length)] +end + + puts"遊ぶなら1、遊ばないなら2を入力して下さい" + puts"数字を入力:" +while true + if asobu == 1 + puts"指定されたどうりに文字を打ち、おばけを倒して下さい" + puts"始めます" + printf("%sと入力:\n",hiragana) + + break + elsif asobu == 2 + puts"了解です" + break + else + puts"もう一回入力してね" + redo + end +end + + diff --git a/tiping.rb b/tiping.rb index 64eab23..d71d643 100755 --- a/tiping.rb +++ b/tiping.rb @@ -1,15 +1,19 @@ #!/usr/bin/env ruby # -*- coding: utf-8 -*- - puts"遊びますか?" puts"始めると入力:" asobu = gets.chomp +def moji() + spell = ["あ","い","う","え","お","か","き","く","け","こ","さ","し","す","せ","そ","た","ち","つ","て","と","な","に","ぬ","ね","の","は","ひ","ふ","へ","ほ","ま","み","む","め","も","や","ゆ","よ","ら","り","る","れ","ろ","わ","を","ん"] + spell[rand(spell.length)] +end while true if asobu == "始める" srand() rizumu = rand(10) +1 -puts"できるだけ早くタイピングして下さい(%sくらいで、タイピングできればすごいです)" +puts"できるだけ早くタイピングして下さい(?くらいで、タイピングできればすごいです)" + puts"すたーと" hajime = Time.now.to_f stop = gets.chomp diff --git a/tukiryokou.rb b/tukiryokou.rb new file mode 100755 index 0000000..f74d81a --- /dev/null +++ b/tukiryokou.rb @@ -0,0 +1,45 @@ +#!/usr/bin/env/ruby +# -*- coding: utf-8 -*- + +puts"宇宙旅行行くよ!!" +puts"今日の天気は?" +puts"晴れ、雨、曇り:" + +kyori = 38000 +hiniti = 0 +while true + tenki = gets.chomp + if tenki == "晴れ" || tenki == "曇り" + puts"今日は出発可能です" + puts"早速出発をしよう!" + puts"10日超高速旅行だよ" + puts"とても早く進むけど、安心してね。機内は安全でとても早く動いていても中は快適だから" + puts"準備はできた?(OK!って書いたら5秒後に発射するよ)" + jyunbi = gets.chomp + while true + if jyunbi == "OK!" + puts"わかった!いいんだね" + sleep(5) + puts"GO!!" + puts"____________________________________________" + puts"現在、地球から月までの距離は約38000000m(38000km)です" + puts"とても遠いですね" + kyori = kyori-3800 + hiniti += 1 + printf("現在、%d日目で地球からの距離は%dm離れています\n",hiniti,kyori) + + break + elsif jyuubi == "だめ" + puts"10秒待つね" + sleep(10) + redo + elsif tenki == "雨" + puts"また、明日にしよう" + break + else + puts"...?" + redo + end +end + end +end diff --git a/utyuryokou.rb b/utyuryokou.rb new file mode 100755 index 0000000..8e485b0 --- /dev/null +++ b/utyuryokou.rb @@ -0,0 +1,43 @@ +#!/usr/bin/env/ruby +# -*- coding: utf-8 -*- + +puts"宇宙旅行行くよ!!" +puts"今日の天気は?" +puts"晴れ、雨、曇り:" + +kyori = 38000 +hiniti = 10 +while true + tenki = gets.chomp + if tenki == "晴れ" || tenki == "曇り" + puts"今日は出発可能です" + puts"早速出発をしよう!" + puts"10日超高速旅行だよ" + puts"とても早く進むけど、安心してね。機内は安全でとても早く動いていても中は快適だから" + puts"準備はできた?(OK!って書いたら5秒後に発射するよ)" + jyunbi = gets.chomp + while true + if jyunbi == "OK!" + puts"わかった!いいんだね" + sleep(5) + puts"GO!!" + puts"____________________________________________" + puts"現在、地球から月までの距離は約38000000m(38000km)です" + puts"とても遠いですね" + kyori = kyori-3800 || hiniti-9 *= 1..10 + printf("現在、%d日目で地球からの距離は%dm離れています\n",hiniti,kyori) + brea + elsif jyuubi == "だめ" + puts"10秒待つね" + sleep(10) + redo + elsif tenki == "雨" + puts"また、明日にしよう" + break + else + puts"...?" + redo + end +end + end +end diff --git "a/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai.html" "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai.html" new file mode 100644 index 0000000..5680c2e --- /dev/null +++ "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai.html" @@ -0,0 +1,159 @@ + + + + + +【10-28】本講義 +|JDs4 - JD-Chokai + + + + + + +
+ +
+

【10-28】本講義 +

+

グループ + JD鳥海塾3期生 での話題 + +

+ +

+
+ + + + +
2023-10-25 13:30:21 末尾へ
+

+

+ + + + +
#2137 +齋藤優奈(メンター) +令和5年10月25日13:36:21 +本日の講義で使用するファイルです。講義が始まる前にRubyディレクトリに保存しておきましょう。 +[Direct]の部分を右クリックして「名前を付けてリンク先を保存」を選択し、Rubyディレクトリに保存してください。 +after1.jpg(28KB) + +after2.jpg(31KB) + +after3.jpg(26KB) + +before.jpg(30KB) +program.rb(1038B)[Direct] +program_advanced.rb(1244B)[Direct] + +quiz1.jpg(8887B) + +quiz2.jpg(8905B) + +quiz3.jpg(9009B) +
+ +
+ + + +
+
+ + + +
添付ファイル(11MB以下): +  + + +
+ + + +
+
+
+ + \ No newline at end of file diff --git "a/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/157-after1.jpeg" "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/157-after1.jpeg" new file mode 100644 index 0000000..e986449 --- /dev/null +++ "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/157-after1.jpeg" Binary files differ diff --git "a/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/158-after2.jpeg" "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/158-after2.jpeg" new file mode 100644 index 0000000..a8a996d --- /dev/null +++ "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/158-after2.jpeg" Binary files differ diff --git "a/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/159-after3.jpeg" "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/159-after3.jpeg" new file mode 100644 index 0000000..4c9bb43 --- /dev/null +++ "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/159-after3.jpeg" Binary files differ diff --git "a/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/160-before.jpeg" "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/160-before.jpeg" new file mode 100644 index 0000000..ae2cbbb --- /dev/null +++ "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/160-before.jpeg" Binary files differ diff --git "a/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/163-quiz1.jpeg" "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/163-quiz1.jpeg" new file mode 100644 index 0000000..ecdba14 --- /dev/null +++ "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/163-quiz1.jpeg" Binary files differ diff --git "a/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/164-quiz2.jpeg" "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/164-quiz2.jpeg" new file mode 100644 index 0000000..d0788fe --- /dev/null +++ "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/164-quiz2.jpeg" Binary files differ diff --git "a/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/165-quiz3.jpeg" "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/165-quiz3.jpeg" new file mode 100644 index 0000000..36ac682 --- /dev/null +++ "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/165-quiz3.jpeg" Binary files differ diff --git "a/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/default.css" "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/default.css" new file mode 100644 index 0000000..2bf82ff --- /dev/null +++ "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/default.css" @@ -0,0 +1,481 @@ +/* + * Default CSS definitions + */ +@media print { + div.blogcomment, div.blogcomment *, div.topmenu, + table.bloghead button { + display: none + } + a {text-decoration: none;} +} +body {background: #eff; margin: 2px; padding: 6px;} +h2, h3, hr {clear: both;} +*.warn {color: red;} +*.warnbg {background: red;} +*.hidden {visibility: hidden;} +*.border {border: 1px solid #113;} +div.topmenu { + margin: 0; padding: 0; width: 100%; height: 2em; +} +div.topmenu ul {width: 100%; position: fixed; z-index: 5; margin: 0; + margin: 0 auto;} +div.topmenu ul li { + float: left; width: 18%; + background: rgba(68,255,102,0.8); border: #3e5 2px groove; margin: 0; + text-align: center; font-size: 80%; list-style: none; + box-shadow: #242 2px 3px 5px; + text-shadow: #fff 0px 0px 10px; +} +div.topmenu ul li.worldname {background: #eeeeff;} +div.topmenu ul li:hover {background: #8fa;} +div.topmenu ul a {text-decoration: none;} + +ldiv.topmenu + h1 {clear: both; margin-top: 3em;} +pre.list { + overflow: auto; width: 96%; height: 40%; background: white; + border: 2px inset; +} +p.copyright { + border-top: 2px inset #555; text-align: right; clear: both; + font-size: 50%; +} +p.copyright a, a#reload {text-decoration: none;} + +td {padding-left: 0.5ex; padding-right: 0.5ex;} +table.td2r td:nth-child(2) {text-align: right;} +table.td3r td:nth-child(3) {text-align: right;} +table.td3rr td:nth-child(n+3) {text-align: right;} +table.td3evw th:nth-child(2n+4), span.textdigest { + background: white; +} +table.td4r td:nth-child(4) {text-align: right;} +table.thl th {text-align: left;} +span#reverse {background: white; padding: 0 0 0 0.4ex; border: outset;} + +table.form, table.b, table.b tr, table.b td, table.b th { + border: 1px solid black; border-collapse: collapse; +} +table.b, table.bloghead { + border-radius: 1ex; box-shadow: rgb(250,222,222) 1px 2px 3px; +} +td.warn {background: #fcc;} +input[type="checkbox"][name="rm"]:checked ~ table {background: red;} +input[type="checkbox"][name="rm"] ~ span {display: none;} +input[type="checkbox"][name="rm"]:checked ~ span {display: inline;} + +input[type="radio"][value="replace"] + input.replace[type="file"] { + visibility: hidden;} +input[type="radio"][value="replace"]:checked + input.replace[type="file"] { + visibility: visible; +} +button#morefile {visibility: hidden; background: #fe9;} +label.admin span {border-bottom: 1px solid blue;} +label.admin:after {content: "(ADMIN)"; color: red; text-decoration: none;} +span.fileinput { + display: inline-block; height: 3.2ex; + border: 1px solid #4444; border-radius: 1ex; + position: relative; width: 16em; background: #e7e7ea; text-align: center; +} +span.fileinput input[type="file"] { + position: absolute; width: 100%; height: 100%; left: 0; top: 0; + padding: 0; +} +span.fileinput:hover {background: #efc;} +/* keep/edit/rm action selector */ +input.action ~ input:not(.action), input.action ~ textarea { + display: none; +} +input.action[value="edit"]:checked ~ input[class="edit"], +input.action[value="mv"]:checked ~ input[type="text"] {display: inline;} +input.action[value="edit"]:checked ~ textarea {display: block;} +input.action[value="edit"]:checked ~ span:not(.fileinput), +input.action[value="mv"]:checked ~ span {display: none;} +input.action[value="rm"]:checked ~ span {background: red;} +label.confirm {display: none;} +*.inline, +input.action[value="rm"]:checked ~ label.confirm { + display: inline; +} + +input.hidesub ~ input[type="submit"] {visibility: hidden;} +input.hidesub:focus ~ input[type="submit"], +p:active input[type="submit"] +{visibility: visible;} +input[type=text]:focus {background: #ffa;} + +form.replyblog {xxx-margin-bottom: 40%;} +div.blogcomment { + position: fixed; bottom: 0; left: 0; + z-index: 2; background-color: rgba(250,222,222,0.6); +} +/* div.blogcomment textarea:focus {background: yellow; + position: fixed; top: 0; bottom: auto; } Need to consider narrow display */ +div.blogcomment * {opacity: 1.0;} +table.bloghead, .bloghead tr, .bloghead td { + border: 1px solid black; border-collapse: collapse; + min-width: 30em; +} +table.bloghead tr.preface { + font-size: 150%; background: yellow; /* text-align: center; */ + white-space: pre-wrap; +} +tr.preface em {color: navy; text-decoration: underline; padding-right: 0.3ex;} +tr.preface strong {color: navy; background: #eea;} +table.bloghead tr.frozen { + background: #ccf; border: blue thick solid; color: navy; +} + +table.bloghead {margin-bottom: 1em;} + +table.blog_replies, .blog_replies tr, .blog_replies td { + border: 1px solid #999; border-collapse: collapse; + white-space: pre-wrap; +} +table.bloghead tr.preface td ul, +table.bloghead tr.preface td ol, +table.bloghead tr.preface h2, +table.bloghead tr.preface h3, +table.bloghead tr.preface h4, +table.bloghead tr.preface h5, +table.bloghead tr.preface h5, +table.blog_replies video, +table.blog_replies iframe, +table.blog_replies ul, .blog_replies tr ul, .blog_replies td ul, +table.blog_replies ol, .blog_replies tr ol, .blog_replies td ol { + text-align: left; white-space: normal; margin: 1ex 0; +} +table.bloghead tr.preface h2, +table.bloghead tr.preface h3, +table.bloghead tr.preface h4, +table.bloghead tr.preface h5, +table.bloghead tr.preface h5 +{ + display: inline-block; +} +table.blog_replies p.proficon { + float: right; margin: 0 1ex 0 0; +} +table.blog_replies+p.update_link {margin-top: 0; margin-bottom: 14em;} +.blog_replies td.repl { + vertical-align: top; min-width: 30em; height: 3em; + max-width: 50em; +} +.blog_replies td.repl img {max-width: 30%;} +td.repl h2, td.repl h3, td.repl h4 { + display: inline; /* Because td.repl's white space is pre-wrap */ + /* text-shadow: blue 0px 1px; */ +} +td.repl hr {display: inline-block; width: 95%; color: #cde} +td.repl em {color: #a00; text-decoration: underline; padding-right: 0.3ex;} +td.repl strong {color: white; background: #00a; padding: 0 0.5ex;} +:root {--repl-heading-color: #a22;} +td.repl h2:before {content: "■"; color: var(--repl-heading-color);} +td.repl h3:before {content: "◆"; color: var(--repl-heading-color);} +td.repl h4:before {content: "◎"; color: var(--repl-heading-color);} +td.repl div.atall { + color: white; background: #66f; padding: 0 0.8ex; + display: inline-block; border-radius: 0.8ex; +} +td.repl.atall:first-line {font-size: 125%;} + +.blog_replies td.repatt {min-width: 12em;} +.blog_replies td.hideauthor {display: none;} +table.blog_replies iframe { + width: 80%; min-height: 300px; max-width: 50em; max-height: 80vw; + padding: 0; border: 0; +} +table.blog_replies td.new { /* New Article from last visit */ + background: white +} +table.mini, table.mini tr, table.mini th, table.mini td { + margin: 0; border-width: 0; + border-collapse: collapse; + vertical-align: top; width: auto; height: 1em; +} +table.mini th {background: #cee;} +table.mini tr {border-bottom: solid 1px #bcc;} +table.mini th, table.mini td {text-align: justify;} +table.mini td, table.mini th {padding: 1px 0.5ex; min-width: 1em;} +table.mini {margin-left: 1em; border-left: 2px solid #686;} +form.replyblog table s { + text-decoration: line-through #ff111180 0.3ex solid; +} + +div.pjaxview, div.pjaxview2 { + position: fixed; top: 1ex; left: 0; width: 9vw; height: 9vh; + background: #ffffee; border: 1px double navy; border-radius: 2em; + z-index: 7; +} +div.pjaxview2 { + width: 100vw; height: 98vh; transition: 0.5s; +} +div.pjaxview iframe { + width: 98%; height: 90%; object-fit: scale-down; +} +div.pjaxview p { + padding: 0.5ex; text-align: left; margin: 0 2em; + white-space: nowrap; overflow: hidden; +} +div.pjaxview p button { font-size: large; padding: 0 1em;} +div.pjaxview p button { background: #eeeee0; } +div.pjaxview p button:focus { background: #fffff8; } + +/* "visibility: collapse" not working on chromium browser */ +div.noprofimg tr.profimg {visibility: collapse; display: none;} +div.noprofimg tr:hover + tr.profimg, div.noprofimg tr:active + tr.profimg, +div.noprofimg tr.profimg:hover, div.noprofimg tr.profimg:active { + visibility: visible; display: table-row;} + +/* Used for overlapping image */ +img.overlap {position: absolute; top: 40px; left: 50px; z-index: 2;} + +/* Used in user's home page */ +p.profimg {float: left; max-width: 50%; max-height: 400px; + overflow: hidden; margin: 0 1em 1ex; + padding: 0; border: white 1px solid; box-shadow: 2px 3px 4px + } +p.profimg img {max-width: 400px;} +div.home+* {clear: both;} +body.grouphome p.groupimg { + float: right; margin: 0 1em 1ex; + overflow: hidden;} +body.grouphome p.groupimg img { + max-width: 380px; max-height: 380px;} + +@media screen { + div.fold {margin-top: 1em; border-top: 1px solid black; padding-top: 1em;} + div.noborder {border: 0px; margin: 0;} + div.fold > div { + xxdisplay: none; max-height: 80%; overflow: auto; + height: 0px; opacity: 0; padding: 0 1ex; + } + div.fold input[type="checkbox"]:checked ~ div, + div.fold input[type="radio"]:checked ~ div { + display: block; background: #fadede; + height: auto; opacity: 1.0; transition: 1s; + } + input.fold + label + *.folded {opacity: 0; display: none; hight: 0;} + input[type="checkbox"].fold:checked + label + *.folded { + opacity: 1.0; transition: 2s; + } + input[type="checkbox"].fold:checked + label + div.folded { + display: block; hight: auto; transition: 2s; + } + + /* fold2!! */ + div.foldtabs { + position: relative; height: 5em; margin-top: 1em; + border-top: 1px solid black; padding-top: 1em; + } + div.foldtabs > div { + position: absolute; top: 2.5em; opacity: 0.0; background: pink; + margin: 2px; overflow: auto; + } + div.foldtabs input[type="radio"] {display: none;} + div.foldtabs input[type="radio"]:checked + label + div { + display: block; opacity: 1.0; transition: 0.2s; width: 100%; + margin: 0; z-index: 2; + } + div.foldtabs > label { + border: 1px outset #ddd; background: #ddd; xbackground: pink; + border-top-left-radius: 0.8em; border-top-right-radius: 0.8em; + margin: 0; + padding: 0.2ex 0.5em; height: 3em; + } + div.foldtabs > input:active + label {background: white;} + div.foldtabs input:checked + label { + background: pink; border: pink 1px solid; border-bottom-width: 6px; + } + div.foldtabs input:checked + label:last-of-type {border-width: 1px;} + input[type="checkbox"] + label + input[type="submit"] {display: none;} + input[type="checkbox"]:checked + label + input[type="submit"] { + display: inline;} + div.foldtabs p {margin: 0;} +} + +/* ToDo List CheckBox inspired by https://cultureacademia.jp/webcreate/303/ */ +input.s4-checkbox {display: none;} /* Do not show real checkbox */ +input.s4-checkbox + label { + position: relative; padding-left: 0.8em; margin-right: 1em; +} +input.s4-checkbox + label:before, +input.s4-checkbox + label:after { + content: ""; display: block; /* Mimic Checkbox by absolute box */ + position: absolute; top: 0; left: 0; margin: 0; +} +input.s4-checkbox + label:before { /* checkbox frame */ + width: 0.8em; height: 0.8em; border: 1px solid #aaa; border-radius: 20%; + background: #ddd; +} +input.s4-checkbox:checked + label:before { /* checked frame bg */ + background: pink; +} +input.s4-checkbox:checked + label { /* checked text */ + /* text-shadow: red 1px 1px; */ +} +input.s4-checkbox:checked + label:after { /* checked mark */ + width: 0.6em; height: 0.4em; top: 0.05em; left: 0.1em; + border-bottom: 3px solid navy; + border-left: 3px solid navy; + transform: rotate(-40deg); +} +/* ---------------------------------------------------- */ + +div.dumptable {max-height: 70vw; overflow: auto;} +div.dumptable tr:hover {background-color: #fee;} +table.dumpblogs td, +div.lcto td { /* LINK + CTIME + TITLE + OWNER + something... */ + white-space: nowrap; overflow: hidden;} +table.dumpblogs td:nth-child(4), +div.lcto td:nth-child(2) {max-width: 8em;} +table.dumpblogs td:nth-child(5), /* team */ +table.dumpblogs td:nth-child(6), /* title */ +table.dumpblogs td:nth-child(7), /* heading */ +div.lcto td:nth-child(3), /* title */ +div.lcto td:nth-child(4) /* owner */ + {max-width: 14em;} +/* https://curecode.jp/tech/css-table-position-sticky-with-background-border-vanished/ */ +div.dumptable table.dumpblogs th { + position: sticky; top: 0; z-index: 1; background: #fcf0f0; + border: 1px solid black; border-collapse: collapse; + background-clip: padding-box; +} + +table.dumpblogs tr.凍結 td:nth-child(n+2) {opacity: 0.5;} +table.dumpblogs tr.凍結 td:last-child {opacity: 1.0; color: blue;} +*.frozen, *.凍結 {color: blue;} + +/* +table.dumpblogs td:nth-child(4) { + max-width: 7.6em; overflow: hidden;} +table.dumpblogs td:nth-child(5), +table.dumpblogs td:nth-child(6) { + max-width: 12em; overflow: hidden;} +table.dumpblogs td:nth-child(7) { + min-width: 5em; overflow: hidden;} +*/ + +/********************* icon list *********************/ +div.iconlist { + text-align: center; float: left; margin: 1ex 1em; + border: dotted #dfd 2px; padding: 1ex; +} +div.iconlist p {margin: 0; padding: 0;} +div.iconlist p.tag {background: #ffa; border-radius: 4em;} +div.iconlist p._temp {background: cyan;} +div.iconlist p._lecture {background: pink;} +div.iconlist p._admin {background: yellow;} +div.iconlist p._friend {background: fuchsia;} +div.iconlist p._fellows {background: #9f9;} /* light green */ +div.iconlist p._club {background: #4bb;} /* light teal */ +div.iconlist p._event {background: maroon; color: white;} +div.iconlist p._misc {background: purple; color: white;} +div.iconlist p._record {background: red; color: white;} +div.iconlist p._info {background: #eff;} /* light cyan */ +div.iconlist p._support {background: #ffe;} /* light yellow */ +div.iconlist p._test {background: #ffb6c1;} /* light pink */ +input#ismembtn:checked ~ div.iconlist, +input#isadmbtn:checked ~ div.iconlist {display: none;} +input#ismembtn:checked ~ div.iconlist.Member, +input#isadmbtn:checked ~ div.iconlist.ADMIN, +input#ismembtn:checked ~ div.iconlist.ADMIN {display: block;} +div.xy120x120 {min-width: 120px; min-height: 140px;} +div.xy96x96 {min-width: 96px; min-height: 116px;} +div.xy96x96 img {max-width: 96px;} +div.xy50x50 {min-width: 50px; min-height: 70px;} +div.xy50x50 img {max-width: 50px;} +div.moderated {background: rgba(255, 215, 0, 0.3);} /* gold */ +body.moderated {background: #fffec4;} /* #faed8a */ +body.ismember, div.ismember {border-top: 4px red solid; margin-top: 0;} +div.right, div.search {clear: both; float: right;} +*.clear {clear: both;} +div.search input[type="text"] { + border: solid 1px #bbb; border-radius: 0.5ex; min-height: 20px; + margin: 1em; padding: 0 0.5ex; padding-left: 18px; + background: url("../../img/loupe.png") left center no-repeat + rgba(242,240,240,0.7); + position: relative; +} +div.search div.fr, *.relative {position: relative;} +div.search p.help, textarea + p.help {display: none;} +div.search input:focus + p.help, +textarea:focus + p.help { + display: block; background: white; + position: absolute; right: 15em; white-space: pre; + border: 1px solid #888; border-radius: 1em; padding: 1ex; + box-shadow: #555 2px 2px; +} +textarea:focus + p.help { + position: fixed; + top: 0em; left: 0; +} +form.summary input[type=submit], +input[type="submit"].all, button.all { + background: #cfc; padding: 0.4ex 2ex; +} +button#c { + padding: 0.2ex 4em; border-radius: 0.5ex; +} +input#cmt input[type="submit"] {height: 4em;} + +input[type="reset"] {margin-left: 4em;} + +/* + * World List + */ +li.casmenu div {display: none; position: relative; width: 200%; + min-width: 80%; margin-right: 0;} +li.casmenu div table { + background: white; position: absolute; top: 0em; border: 3px solid navy; + max-width: 100%; +} +li.casmenu div table td {text-align: left; padding: 0.5ex 1em;} +li.casmenu:hover div, li.casmenu:active div, +li.casmenu div:hover, li.casmenu div:active +{display: block;} +span.pre {white-space: pre;} + +/* + * Frozen toggle button + */ +td.稼動状態 {text-align: center;} +button.toggle-frozen { + padding: 0 1emex; + background: #fdb585; + border-radius: 1ex; + border-bottom: solid 2px #d27d88; + box-shadow: inset 0 2px 0 rgba(255,255,255,0.2), 0 2px 2px rgba(0,0,0, 0.19); + background: linear-gradient(#fdeaea, #fdb2b2); // ffc8a8 +} +.凍結 button.toggle-frozen, .凍結 button.toggle-frozen::before { + background: linear-gradient(#d8e2ea, #83bbea); +} +.凍結 button.toggle-frozen::before { + content: attr(frozen-marker); color: blue; +} +.toggle-frozen::before { + content: attr(running-marker); +} +.info-tooltip { + position: absolute; padding: 1ex; + background: ivory; + border-radius: 1em; border: double 5px blue; + min-width: 10em; right: 0; bottom: 0; +} +.dissolving {opacity: 0; transition: 3.0s;} +.emerging {opacity: 1; transition: 3s;} +button#c, button#reload {display: inline-block;} +span.loading, button#c:disabled, button#reload:disabled { + visibility: visible; transform: rotateX(3600deg); transition: 30s; +} +span.loading {padding: 0 1em;} +input.aux, input[type="reset"] {margin-left: 10em; transform: scale(0.7);} + +/* + * PR Web + */ +body.pr {font-size: 200%;} +body.pr h1 { + text-align: center; width: 80%; padding: 3ex 0; margin: 0 auto; + background: #ffefef; border: double 5px navy; +} diff --git "a/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/file-icon.png" "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/file-icon.png" new file mode 100644 index 0000000..d82f259 --- /dev/null +++ "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/file-icon.png" Binary files differ diff --git "a/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/j2023.css" "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/j2023.css" new file mode 100644 index 0000000..5287ca2 --- /dev/null +++ "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/j2023.css" @@ -0,0 +1,9 @@ +@import url("default.css"); +body {background: url("img/jds4_bg_2023.png") #ffffbf no-repeat center fixed; + background-size: cover; margin: 2px; padding: 6px; +} +body.moderated {background: #e4ecc5; border: 3px gold solid;} +div.topmenu ul li { + background: #ffd531; border: #ed8 2px groove; margin: 0 +} +div.topmenu ul li:hover {background: #da6;} diff --git "a/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/s4-main.js" "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/s4-main.js" new file mode 100644 index 0000000..0bc713e --- /dev/null +++ "b/\343\200\22010-28\343\200\221\346\234\254\350\254\233\347\276\251 JDs4 - JD-Chokai_files/s4-main.js" @@ -0,0 +1,1223 @@ +// 愛 +(function (){ + var isOlderJS; // Set in init(); + var hoverTextLines = 10; + var hasTouchPad = + (navigator.maxTouchPoints && navigator.maxTouchPoints >0); + var myurl = document.URL, + mypath = myurl.substring(myurl.lastIndexOf("/")); + var art_m_list = []; + var mathjax = false; + let input_pdfsw = 'input[name="comppdf"]'; + if (mypath.match(/(.*)\/(.*)/)) { + mypath = RegExp.$2; + mypath = mypath.substring(0, mypath.lastIndexOf("?")); + //alert("mypath="+mypath); + } + function escapeChars(old) { + return old.replaceAll('&', '&') + .replaceAll('"', '"') + .replaceAll("<", '<') + .replaceAll(">", '>'); + } + function collectElementsByAttr(elm, attr, val) { + var e = document.getElementsByTagName(elm); + if (!e) return null; + var list = []; + for (var i of e) { + if (i.getAttribute(attr) == val) + list.push(i) + } + return list; + } + function nthChildOf(parent, n, elem) { // Return Nth child of type ELEM + // N begins with 1 + var i=0; + var le = elem.toLowerCase(); + for (var c of parent.childNodes) { + if (!c.tagName) continue; + if (c.tagName.toLowerCase() == le) { + if (++i >= n) return c; + } + } + return null; + } + function insertRedirect(e) { + var articleId, textarea = document.getElementById("text"); + var p = e.target, checked = p.checked; + while (p = p.parentNode) + if (p.nodeName.match(/^td$/i)) break; + if (!p) return; + while (p = p.nextSibling) + if (p.nodeName.match(/^td$/i)) break; + if (!p) return; + articleId = p.getAttribute("id"); + if (textarea && articleId) { + var tv = textarea.value, lines; + if (tv) + lines = tv.split("\n"); + else + lines = [""]; + var re = new RegExp("[, ]*#"+articleId+"(?![0-9])"); + checked = (p.nodeName.match(/^input$/) + ? p.checked // checkbox obeys its status + : !lines[0].match(re)) // a-elment toggles redirection + if (checked) { + if (!lines[0].match(re)) { + var re2 = new RegExp(/>#[#0-9, ]+[0-9]/); + if (lines[0].match(re2)) + lines[0] = lines[0].replace( + re2, '$&, '+'#'+articleId); + else { + if (lines[0] > "") lines[0] = " "+lines[0]; + lines[0] = ">#"+articleId+lines[0]; + } + } + } else { // Remove #xxxxx + if (lines[0].match(/^>#[0-9 ,]+#/)) // 2 or more #id's + lines[0] = lines[0].replace( + new RegExp("^>#"+articleId+"[ ,]*"), ">").replace( + new RegExp("[ ,]*#"+articleId), ""); + else { + lines[0] = lines[0].replace( + new RegExp(">#"+articleId+"[ ,]*"), ""); + } + } + lines[0] = lines[0].replace(/^> *$/, ''); + textarea.value = lines.join("\n"); + } + } + function registPjaxViewers(aHrefList) { + let apos=art_m_list.length; + for (let a of aHrefList) { + let href = a.getAttribute("href"); + let localvar = apos; + let td = a.parentNode, + tr = td.parentNode, + id = td.id, + text = td.textContent, + author = tr.getElementsByTagName("a"); + if (author) author = author[0].getAttribute("title"); + if (href.match(/\?showattc\+article_m\+([0-9]+)$/)) { + if (td.innerHTML.match(/読み取り不可/)) { + a.removeAttribute("href"); + continue; + } + let url = RegExp.lastMatch; + // console.log("pjaxView(e, "+href+", "+apos+")"); + a.addEventListener("click", function(e) { + // Shoud use closure local variable: localvar + pjaxView(e, href, localvar); + }, false); + apos++; + art_m_list.push({ + url: href, id: id, author: author, text: text + }); + } + } + } + function registInsertDirect(aHrefList) { + for (i of aHrefList) + if (i.getAttribute("href").match(/^#[0-9]+$/)) + if (RegExp.lastMatch == i.innerHTML) + i.addEventListener("click", insertRedirect, false) + } + function mathjaxUpdate(arg) { + try { + if (MathJax && MathJax.typesetPromise) { + MathJax.texReset(); // Reset Math counters + MathJax.typesetPromise(arg); // MathJax v3 + } + } catch (err) {console.log(err);} + } + var ajaxSubmit; + function replAddNews(newtable) { + let newids = [], idlist=[]; + let getArticleID = function (td) { + return parseInt(td.parentNode.getElementsByTagName("td")[1].id); + } + for (let i of newtable.querySelectorAll("td.repl")) + newids.push(i); + newids = newids.sort((a,b)=> { + return (getArticleID(a) - getArticleID(b)); + }); + for (i of newids) + idlist.push(getArticleID(i)); + console.log("IDList="+idlist.join()); + let cnt=0, ntr; + let current = collectElementsByAttr("td", "class", "repl"), + ncur=0, n, icur=0, o, oid, nid, otr; + current = document.querySelectorAll('td[class="repl"]'); + let last=current[current.length-1], + tbody = last.parentNode.parentNode; + let addEventsToNewTr = function(tr) { + let td = tr.getElementsByTagName("td"), + td0 = td[0], td1 = td[1]; + td0.classList.add("new"); + registInsertDirect(td0.querySelectorAll("a[href]")); + registPjaxViewers(td1.querySelectorAll("a[href]")); + } + // Erase all "new article" flags before merging + for (let i of document.querySelectorAll("td.new")) + i.classList.remove("new"); + // Now reconstruct articles with merge-sort like method + outer: for (; ncur= nid) { + addEventsToNewTr(ntr); + tbody.insertBefore(ntr, otr); + if (oid==nid) otr.remove(); + cnt++; + continue outer; + } + } + // Append absolutely new articles. + ntr = n.parentNode; + addEventsToNewTr(ntr) + tbody.appendChild(atMarkView(ntr)); + ntr.classList.add("dissolving"); + let localntr = ntr; + setTimeout(() => { + localntr.classList.remove("dissolving"); + localntr.classList.add("emerging"); + }, 100); + rewriteReplyHover(ntr); + cnt++; + } + mathjaxUpdate(newids); + console.log("Update "+cnt+"rows"); + if (cnt>0 && ntr.scrollIntoView) { + let option = {behavior: "smooth"}; + if (!isOlderJS) option.block = "center"; + try { // Scroll to last updated row + ntr.scrollIntoView(option); + } catch (e1) {} + } + return cnt; + } + + function warnFileSize(form) { + let szmax = form.querySelector('input[name="filesize_max"]').value; + if (!szmax || szmax=="") return; + szmax = parseInt(szmax); + if (szmax <= 0) return; + // szmax = 10000 + let ng = "", rcval=false, fileexists=false, + pdfsw = form.querySelector(input_pdfsw), + pdfmsg = "Try compressing PDF?\nPDFを圧縮してみますか?\n" + + "(それでも収まらない場合もあります)"; + for (let f of form.querySelectorAll('input[type="file"]')) { + let thiserr = false; + for (let i of f.files) { + fileexists = true; + let fn = i.name, sz = i.size; + console.log("max="+szmax+", fn="+fn+", sz="+sz); + if (sz > szmax) { + if (fn.match(/\.pdf/i) + && sz < szmax*3 // XXX : x3 reasonable? + && (pdfsw || confirm(pdfmsg))) { + if (!pdfsw) { + pdfsw = document.createElement("input"); + pdfsw.name = "comppdf"; + pdfsw.type = "hidden"; + f.parentNode.insertBefore(pdfsw, f); + pdfsw.value = "yes"; + } + } else { + thiserr = true; + ng += ((ng>"" ? ", " : "")+fn) + } + } + } + thiserr ? f.classList.add("warnbg") : f.classList.remove("warnbg"); + } + if (ng>"") { + rcval = "File-size Limit Error: "+ng+"\n"+ + "Should be less than "+szmax+"bytes.\n"+ + szmax+"バイト未満にしてください" + alert(rcval); + } + if (form.text.value == "") { + let w; + if (fileexists) + w = "Fill the text area\n" + + "添付したファイルに関する説明を入れてください。"; + else + w = "Enter your comment!\n何か書き込んでね!"; + alert(w); + rcval = (rcval || w); + form.text.classList.add("warnbg"); + setTimeout(() => {form.text.classList.remove("warnbg");}, 2000) + } + return rcval; + } + function ajaxPost(e) { + e.preventDefault(); + let rowid; + if (!myurl.match(/replyblog\+([0-9]+)/)) return; + rowid = RegExp.$1 + let myform = document.querySelector("form.replyblog"); + let data = new FormData(myform), + fetchtime = data.get("fetchtime"); + if (!fetchtime || fetchtime=="") return; + ///*XX*/fetchtime = "2020-06-14T00:00:00";data.set("fetchtime", fetchtime) + + ajaxSubmit = e.target; + ajaxSubmit.back = ajaxSubmit.textContent; + if (ajaxSubmit.id == "reload") { + ajaxSubmit.textContent = "更新中" + data.set("text", "") + } else { + if (warnFileSize(myform)) return; + ajaxSubmit.textContent = "送信中"; + } + ajaxSubmit.blur(); + ajaxSubmit.disabled = true; + let act = mypath+"?blog_fetch+"+rowid+"+f:"+fetchtime; + + function respUpdate(tbody) { + ajaxSubmit.textContent = ajaxSubmit.back; + ajaxSubmit.disabled = false; + let div = document.createElement("div"), form, newform; + try { + div.innerHTML = tbody; + form = div.querySelector("form"); + } catch (er) { + alert("Cannot parse fetch data"); + return; + } + let update = replAddNews(form); + let dispelem = myform.querySelector("textarea").parentNode; + if (div.querySelector('input[name="user"]')) { // is login form + dispInfoMomentary("Login Again Please", dispelem) + return; + } + newform = new FormData(form); + if (data.get("text") > "") { // Called by submit button + myform.reset(); + let pdfsw = myform.querySelector(input_pdfsw); + if (pdfsw) pdfsw.remove(); + // myform.text.value = ''; + } + myform.fetchtime.value = newform.get("fetchtime"); + myform.id.value = newform.get("id"); + if (update && update > 0) { + let s = update + " new article" + + (update>1 ? "s" : "") + " posted"; + dispInfoMomentary(s, dispelem); + } + } + fetch(act, { + method: "POST", body: data, + credentials: "include" // For older firefox + }).then((resp) => { + return resp.text(); + }).then((tbody) => { + respUpdate(tbody); + }) + } + function pjaxView(ev, url, mynum) { + if (ev.ctrlKey||ev.shiftKey) return; + ev.preventDefault(); + let box = document.createElement("div") + box.setAttribute("class", "pjaxview"); + let p1 = document.createElement("p"), + bt = document.createElement("button"), + sl = document.createElement("button"), + sr = document.createElement("button"), + loading = document.createElement("span"), + info = document.createElement("p"); + info1 = document.createElement("span"); + info2 = document.createElement("span"); + iframe = document.createElement("iframe"); + var curpos = mynum; + var historyBase = history.length; + + function _setPjaxCurposInfo() { + let len = art_m_list.length; + let cur = art_m_list[curpos] + info1.textContent = (1+curpos)+" of "+len+" article #"+cur.id+ + (cur.author ? " by "+cur.author : "") + ":"; + info2.textContent = cur.text.trim(); + info2.setAttribute("class", "border textdigest"); + } + function _resetPjax() { + // All we can do surely is to back 1 page, + // because we cannot move to desirable entry of history list. + history.back(); + } + function setSwipeAct(iframe) { + // We cannot use DOMContentLoaded nor iframe.contentWindow here. + // PDF.js does not construct contentWindow...? + iframe.addEventListener("load", () => { + loading.classList.remove("loading"); + if (!hasTouchPad) return; + let ifm = iframe.contentDocument; + let startX, moveX, thresh = 100; + ifm.addEventListener("touchstart", (e) => { + e.preventDefault(); + startX = e.touches[0].pageX; + }, false); + ifm.addEventListener("touchmove", (e) => { + e.preventDefault(); + moveX = e.touches[0].pageX; + }, false); + ifm.addEventListener("touchend", (e) => { + if (startX < moveX && startX + thresh < moveX) { + switchTo(e, -1); + } else if (startX > moveX && startX - thresh > moveX) { + switchTo(e, +1); + } + }, false); + }, false); + + } + function switchTo(e, direction) { + e.preventDefault(); + let len = art_m_list.length, cur, newpos, url; + newpos = (curpos+len+direction)%len; + if (curpos == newpos) return; // No need to switch to same one + curpos = newpos; + cur = art_m_list[curpos]; + url = cur.url; + // We should remove iframe once to preserve history Object + // https://inthetechpit.com/2019/04/20/update-iframe-without-affecting-browser-history/ + let parent = iframe.parentNode; + // alert("D = "+direction); + iframe.remove(); + parent.appendChild(iframe); + try { + loading.classList.add("loading"); + iframe.src = url; + // iframe.contentDocument.location.replace(url); + // location.replace cannot be used because PDF viewer.js + // does not have iframe.contentDocument + } catch (err) { + alert("Cannot load "+src+" : "+err.name); + } + _setPjaxCurposInfo(); + setSwipeAct(iframe); + } + function switchToByKey(e) { + // alert("KEY="+e.key); + switch (e.key) { + case "ArrowLeft": + switchTo(e, -1); break; + case "ArrowRight": + switchTo(e, +1); break; + case "Escape": + history.back(); + } + } + //

+ // + //

info1 info2

+ // + //
+ // ==> [ << ][Dissmiss][ >> ] + // ==> ## of ## article #xxx by AUTHOR + sl.textContent = " << "; + sr.textContent = " >> "; + sl.addEventListener("click", (e) => {switchTo(e, -1);}); + sr.addEventListener("click", (e) => {switchTo(e, +1);}); + sl.setAttribute("title", "to="+(mynum-1)); + sr.setAttribute("title", "to="+(mynum+1)); + document.body.appendChild(box); + bt.textContent = "Click to dismiss / もどる"+mynum; + + box.appendChild(p1); + p1.appendChild(sl); p1.appendChild(bt); p1.appendChild(sr); + { // TEST: Normal mode + let only = document.createElement("button"), + h = location.href; + only.textContent = ".oO□"; + only.setAttribute("title", "Open in Normal Window"); + only.addEventListener("click", function() { + location.replace(iframe.src); + }); + p1.appendChild(only); + } + p1.appendChild(loading); + info.appendChild(info1); info.appendChild(info2); + loading.textContent=" Loading..."; + loading.classList.add("hidden"); + loading.classList.add("loading"); + box.appendChild(info); + iframe.src = url; + + box.addEventListener("keydown", switchToByKey); + //box.addEventListener("click", (e) => {_resetPjax();}); + bt.addEventListener("click", (e) => {_resetPjax();}); + // dp.addEventListener("click", (e) => {_resetPjax();}); + info.addEventListener("click", (e) => {_resetPjax();}); + box.appendChild(iframe); + + setSwipeAct(iframe); + + _setPjaxCurposInfo(); + bt.focus(); + setTimeout(() => {box.classList.add("pjaxview2");}, 10); + // Finally update history stack + pjaxHistoryPush(box); + } + function pjaxHistoryPush(box) { + if (history.pushState) { + let h = location.href.replace(/#.*/, '')+"#pjaxview"; + history.pushState({url: h}, null, h); + window.addEventListener("popstate", (e) => { + if (box) { + box.remove(); box = null; + } + }, false); + } + } + function reverseChecks() { + var names = collectElementsByAttr("input", "name", "usel"); + for (let u of names) { + u.checked = !u.checked; + } + } + function renumberOL(str, start) { + var stra = str.split("\n"); + for (var i=1; i1 && area.value.charCodeAt(pos)==10) + b = area.value.lastIndexOf("\n", pos-1);; + return b>=0 ? b : 0; + } + function isInBeginEnd(area, pos){ + pos = pos||area.selectionStart; + let bol = beginningOfLine(area, pos); + let thisline = area.value.substr(bol); + console.log("curchar="+area.value.charCodeAt(pos)); + console.log("prechar="+area.value.charCodeAt(pos-1)); + console.log("bol="+bol+", thisline="+thisline); + let match = thisline.search(/\\(begin|end){([A-Za-z]*)/), lm, be; + if (match >= 0) { + lm = RegExp.lastMatch; + be = RegExp.$1; + return RegExp.$2 + } + return null; + } + function helpMarkdownBrace(e) { + if (!mathjax) return; + var area = e.target, pos = area.selectionStart, text = area.value, + begin = "\\begin", end = "\\end"; + if (pos < end.length) return; + if (text.substr(pos-end.length).startsWith(end)) { + let beg = text.lastIndexOf(begin, pos); + if (beg >= 0) { + let env = text.substr(beg).search(/\\begin{(.*?)}/); + if (env >= 0) { + textInsert(area, "{"+RegExp.$1+"}", pos); + e.preventDefault(); + } + } + } + } + function helpMarkdownBraceClose(e) { + if (!mathjax) return; + let area = e.target, pos = area.selectionStart, text = area.value, + begin = "\\begin", end = "\\end"; + if (text.substr(pos).startsWith("}")) { + area.setRangeText("", pos, pos+1); + // e.preventDefault(); + } + let inbegend = isInBeginEnd(area, pos); + if (!inbegend) return; + let nextendpos = text.substr(pos).indexOf("\\end{"); + let nextcurend = text.substr(pos).indexOf("\\end{"+inbegend+"}"); + if (nextcurend<0 || nextendpos!=nextcurend) { + area.setRangeText("}\n\n\\end{"+inbegend+"}", pos, pos); + area.selectionStart = pos+2; + e.preventDefault(); + } + console.log(inbegend); + + } + function helpMarkdownPreview(area) { + if (!mathjax) { + alert("no"+e.target) + dispInfoMomentary("This board has no MathJax mode.\n"+ + "この掲示板は数式モードOFFです。", + e.target.parentNode); + return; + } + let text = area.value; + let preview = document.createElement("div"); + let bp = document.createElement("p"); + let btn = document.createElement("button"); + btn.innerText = "Click or ESC to Dissmiss / クリックかESCで戻る"; + bp.classList.add("c"); + preview.classList.add("pjaxview"); + preview.classList.add("pjaxview2"); + let pre = document.createElement("p"); + bp.appendChild(btn); + preview.appendChild(bp); + preview.appendChild(pre); + pre.innerText = text; + document.body.appendChild(preview); + function dismiss(t) { + history.back(); + preview.remove(); + area.focus(); + } + preview.addEventListener("click", dismiss, false); + preview.addEventListener("keydown", dismiss, false); + MathJax.typesetPromise([pre]); + pjaxHistoryPush(preview); + btn.focus(); + } + function helpMarkdownAt(e) { + var area = e.target, pos = area.selectionStart; + if (pos == 0) { + area.value = "@all" + area.value; + area.selectionStart = area.selectionEnd = 4; + dispInfoMomentary("@all で全員に通知します", area.parentNode); + e.preventDefault(); + } + } + function helpMarkdown(e) { + switch (e.key) { + case "Backspace": helpMarkdownBS(e); break; + case "Enter": helpMarkdownEnter(e); break; + case "(": helpMarkdownParen(e); break; + case "p": if (e.metaKey) helpMarkdownPreview(e.target); break; + case "{": helpMarkdownBrace(e); break; + case "}": helpMarkdownBraceClose(e); break; + case "@": helpMarkdownAt(e); break; + } + } + /* Init event listeners */ + function addFileInput() { + var inpfile = collectElementsByAttr("input", "name", "image"); + if (!inpfile) return; + var filled = true; + var i, ih; + for (i of inpfile) { + if (! i.value) filled=false; + } + if (filled) { + ih = i.parentNode.innerHTML; + let ipph = i.parentNode.parentNode.innerHTML; //Entire td inside + if (ipph) { + let ip = i.parentNode; + var inpf = ipph.substring(ipph.indexOf('"+inpf.substring(0, inpf.indexOf("/span>")+6); + ip.insertAdjacentHTML("afterend", newi) + ip.nextSibling.nextSibling.addEventListener('change', () => { + warnFileSize(document.forms[0]); + }); + } + } + } + function initFileInput() { // Multiplies "input type=file" + var el, morefile = document.getElementById("morefile"); + if (morefile) { + for (el of collectElementsByAttr("input", "name", "image")) { + el.addEventListener("change", function(ev) { + if (ev.target.value > "" && ev.target.files.length == 1) + morefile.style.visibility = "visible"; + // No need to hide again, sure? + }); + } + morefile.addEventListener("click", addFileInput, null); + } + // When renaming, select basename part + for (el of collectElementsByAttr("input", "class", "mv")) { + el.addEventListener("focus", function(ev) { + var i = ev.target; + if (i) { + i.setSelectionRange(0, i.value.lastIndexOf(".")); + } + }); + } + } + function initTextarea() { + var te = collectElementsByAttr("textarea", "name", "text"); + if (!te || !te[0]) return; + te[0].addEventListener("keydown", helpMarkdown, false); + } + function atMarkView(elem) { + // Enclose "@all" with span + for (i of elem.querySelectorAll("td.repl")) { + if (i.textContent.startsWith("@all")) { + i.firstChild.nodeValue = i.firstChild.nodeValue.substring(4); + i.insertAdjacentHTML( + 'afterbegin', '
@all
' + ); + i.classList.add("atall"); + } + } + return elem; + } + var authVisible = false; + function toggleAuthorVisibility(e) { + // Click to hideauth button toggles visibility of author columns + e.stopPropagation(); + let b = document.getElementById("hideauth"); + if (authVisible) { + for (let i of document.querySelectorAll("td.repatt")) { + i.classList.remove("hideauthor"); + } + authVisible = false; + } else { + for (let i of document.querySelectorAll("td.repatt")) { + i.classList.add("hideauthor"); + } + authVisible = true; + } + b.textContent = b.textContent.replace(/OFF|ON/, authVisible ? "ON" : "OFF"); + } + function downloadFile(filename, content, BOM) { + let bom = new Uint8Array([0xEF, 0xBB, 0xBF]); + let str = new Blob(BOM ? [bom, content] : [content], + {type: "text/csv"}); + var uri = URL.createObjectURL(str); + let a = document.createElement("a"); + a.download = (BOM ? "BOM-" : "")+filename; + a.href = uri; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + } + function getTextContentCSV_1(e) { + let blogtbl = document.querySelector("table.blog_replies"); + let needBOM = e.ctrlKey; + if (!blogtbl) return; + let trw = blogtbl.querySelector("tr.warn"), a; + if (trw && (a=trw.querySelector("th>a"))) { + if (a.title == "Show All") { + if (window.confirm(`50件以下に表示制限されています。 +取得し直しますか? +Cancelを押すとこのまま取得します。 +Seen articles limited to 50 items. +Push OK to get all articles, Cancel to get only seen articles.`)) { + a.click(); + return; + } + } + } + if (navigator.userAgent.match(/Windows/)) { + if (!e.ctrlKey && !e.shiftKey && !window.confirm(`Excelで読ませるCSVの場合はBOMが必要です。 +その場合は一度キャンセルして Ctrl キーを押しながらボタンクリックして下さい。 +逆にExcel以外(GoogleスプレッドシートやLibreOfficeや他のツール)で読む場合はBOMをつけるとファイルの1行目の先頭にゴミのようなものが見える場合あるのでそのときは除去する必要があります。 +今後もBOM不要の場合はShiftキーを押しながらクリックして下さい。 +If you feed this CSV into Microsoft Excel, consider adding BOM sequence that can be prepended by pressing Control key with click. +In this case, click CSVget with ctrl key after Cancel this dialog. +If you never need BOM, press Shift key with click.`)) + return; + } + outcsv = [] + for (let row of blogtbl.querySelectorAll("tr[id]")) { + let tds = row.querySelectorAll("td"), + a = tds[0].querySelector("a.author"), + author = a.title, + name = a.innerText, + time = tds[0].querySelector("span").title, + id = tds[1].id, + body = tds[1].textContent; + //console.log(`${author},${name},${time},#${id},${body}`); + outcsv.push({ + "author": author, "name": name, "time": time, + "id": "#"+id, "body": body}); + } + let line = new CSV(outcsv, {header:true}).encode(), + fn = myurl.replace(/.*\?/, "").replaceAll("+", "-") + .replace(/#.*/, "").replace("-n:all", ""); + downloadFile(fn+".csv", line, needBOM); + } + function getTextContentCSV(e) { + if (!document.getElementById("csvminjs")) { + let csvmin = document.createElement("script"); + csvmin.src="https://www.yatex.org/libcache/csv.min.js"; + csvmin.id = "csvminjs"; + // https://stackoverflow.com/questions/14521108/dynamically-load-js-inside-js + csvmin.addEventListener("load", ()=>{ + getTextContentCSV_1(e)}, 10); + document.querySelector("head").appendChild(csvmin); + } else { + getTextContentCSV_1(e); + } + } + function initBlogs() { + // Auto-complete #xxxx + let i, check = collectElementsByAttr("input", "name", "notifyto"); + if (check) + for (i of check) { + i.addEventListener("click", insertRedirect, false); + } + registInsertDirect(document.querySelectorAll("a[href]")); + if (myurl.match(/replyblog\+[0-9]/) + && document.querySelector("td.repl")) { + // There's no need to provide ajax posting when + // no replies written to the blog. Therefore we + // assign ajax post when td.repl exists. + for (i of document.querySelectorAll('input#c[value="送信"]')) { + let b = document.createElement("button"); + b.textContent = "送信!"; + console.log("b="+b+", tc="+b.textContent); + b.addEventListener("click", ajaxPost, false); + // i.insertAdjacentElement('afterend', b); + b.setAttribute("class", i.getAttribute("class")) + b.setAttribute("title", i.getAttribute("title")) + i.parentNode.replaceChild(b, i); + b.id = i.id; + // i.remove(); + i.classList.add("aux"); + i.value = "送信(予備)" + b.parentNode.appendChild(i); + } + i = document.getElementById("reload"); + if (i) i.addEventListener("click", ajaxPost, false); + // Add CSV download button + let td = document.querySelector("table.bloghead tr td"); + if (td) { + let btn = document.createElement("button"); + btn.innerText = "CSVget"; + btn.type = "button"; + btn.accessKey = "g"; + btn.title = `Shortcut: G +見えている書き込みをCSVで取得します +全件表示されていることを確認してから利用して下さい。 +Excelで利用する場合は Ctrl を押しながらクリックして下さい。 +Get seen TEXT content as CSV.`; + btn.addEventListener("click", getTextContentCSV, false); + let artlink = td.querySelector('a[accesskey="f"]'); + let spacer = document.createElement("span"); + if (artlink) { + spacer.innerText = "|"; + artlink.insertAdjacentElement('beforebegin', btn); + artlink.insertAdjacentElement('beforebegin', spacer); + } else { + spacer.innerText = " "; + td.appendChild(spacer); + td.appendChild(btn); + } + } + } + for (i of document.querySelectorAll('input[type="file"]')) { + i.addEventListener('change', (e) => { + warnFileSize(document.forms[0]); + }, false) + } + if (i=document.getElementById("hideauth")) { + i.addEventListener('click', toggleAuthorVisibility, false); + } + // Hack article_m links + registPjaxViewers(document.querySelectorAll("a[href]")); + atMarkView(document); + } + function initGrpAction() { + var rev = document.getElementById("reverse"); + if (!rev) return; // Is not grpAction page + if (rev.tagName.match(/span/i)) { + rev.textContent = " 反転 "; + rev.addEventListener("click", reverseChecks, null); + } + var emailbtn = document.getElementById("email"); + emailbtn.addEventListener("click", function(ev){ + // Enlarge box and Select user's checkbox + if (!ev.target.checked) return; + var x = collectElementsByAttr("div", "class", "foldtabs"); + if (x && x[0] && x[0].style) { + x[0].style.height = "10em"; + } + let myuid = document.getElementById("myuid"); + if (myuid) { + let usel = collectElementsByAttr("input", "name", "usel"); + if (usel) { + for (u of usel) { + if (u.value == myuid.value) + u.checked = true; + } + } + } + }, null); + var teamsel = document.getElementById("selteam"); + if (teamsel) { + var usel, p, team; + // Select all members of the team + teamsel.addEventListener("change", function(ev) { + var teamname = teamsel.value, + selected = new RegExp('(^| )'+teamname+"($|,)"); + usel = collectElementsByAttr("input", "name", "usel"); + if (!usel) return; + for (u of usel) { + p = u.parentNode; // should be label + if (!p) continue; + if (teamname == "TEAM") { // Reset all checks + u.checked = false; // when "TEAM" is selected + } else { + p = p.parentNode.parentNode;// should be tr + team = nthChildOf(p, 5, "td") + if (team && team.textContent + && team.textContent.match(selected)) { + u.checked = true; + } + } + } + }, null); + } + } + function dispInfoMomentary(msg, elem) { + // Momentarily display MSG in tooltip-baloon relative to ELEM element. + let help = document.createElement("p"); + elem.style.position = 'relative'; + elem.style.overflow = 'visible'; + help.setAttribute("class", "info-tooltip"); + help.innerHTML = msg; + elem.appendChild(help); + setTimeout(() => { + help.classList.add("dissolving"); + setTimeout(() => help.remove(), 3000); + }, 1000); + } + function initGrphome() { + console.log("initGrphome"); + // (1)Setup Frozen State Changing Button + var ja = navigator.language.match(/ja/i); + + function toggleFrozen(e, rowid) { + let tgt = mypath+"?blog_setfrozen+"+rowid; + let td = e.target.parentNode; + let tr = td.parentNode; + fetch(tgt, { + method: "POST", + headers: {'Content-Type': 'text/html; charset=utf-8'}, + credentials: "include" + }).then(function(resp) { + return resp.text(); + }).then(function(tbody) { + try { + var json = JSON.parse(tbody); + } catch (e) { + return; + } + let state = json.state, newstate, info; + if (json.alert) { + alert(json.alert) + } + if (state.match(/frozen/i)) { + newstate = "凍結"; + info = ja ? newstate+"に設定しました" : 'Set Frozen'; + } else { + newstate = null; + info = ja ? '稼動に設定しました' : 'Set Running'; + } + tr.setAttribute("class", newstate); + dispInfoMomentary(info, td); + }); + } + let btn = document.querySelectorAll("button.toggle-frozen"); + for (let b of btn) { + let rowid = null; + let td=b.parentNode, tr = td.parentNode, fr, ru; + ru = ja ? "動" : "Running"; + fr = ja ? "凍" : "Frozen"; + b.setAttribute('frozen-marker', fr); + b.setAttribute('running-marker', ru); + for (let a of tr.querySelectorAll("a[href]")) { + if (a.getAttribute("href").match(/\?replyblog\+([0-9]+)/)) { + rowid = parseInt(RegExp.$1); + break; + } + } + if (rowid && rowid>0) { + b.addEventListener("click", function(e) { + if (!btn) return; + toggleFrozen(e, rowid); + }, false); + b.setAttribute("title", "稼動/凍結をその場で切り替えます\n\ +Toggle Running/Frozen ("+rowid+")"); + } + } + // (2)Setup Column Collapse Button + // INCOMPLETE: Cannot restore original state, but it's enough... + function toggleColmnWidth(th) { + let tbl = document.querySelector("table.dumpblogs"); + let colname = th.textContent, newwidth; + if (th.style.width) { + newwidth = null + // https://developer.mozilla.org/ja/docs/Web/CSS/table-layout + tbl.style.tableLayout = 'auto'; + tbl.style.width = null; + } else { + newwidth = "2em"; + tbl.style.tableLayout = 'fixed'; + tbl.style.width = '100%'; + } + th.style.width = newwidth; + th.style.overflow = "hidden"; + for (let td of document.querySelectorAll("td."+colname)) { + console.log(td.tagName); + td.style.width = newwidth; + console.log(td.style.width); + } + } + let row1 = document.querySelector("table.dumpblogs tr:first-child"); + if (row1) { + let heads = row1.querySelectorAll("th"); + for (let h of heads) { + h.addEventListener("click", function(e) { + toggleColmnWidth(h); + }, false); + h.setAttribute("title", "Click to shrink these columns"); + } + } + } + function initMath() { + mathjax = window.MathJax||document.getElementById("mathjax"); + if (!mathjax) return; + let ta = document.querySelector("textarea"); + if (!ta) return; + let btn = document.createElement("button"); + btn.setAttribute("title", "\\( と \\) で数式利用\n"+ + "\\[ と \\] で段組み数式モード\n"+ + "便利なマクロ:\n"+ + " \\boxed{aaa}, \\fcolorbox{framecolor}{bgcolor}{text}\n"+ + " \\underline{aaa}, \\fcolorbox{framecolor}{bgcolor}{text}\n"+ + "独自定義マクロ:\n"+ + " \\warn{xxx} 注意喚起用色付き枠\n"+ + " \\Warn{xxx} 大きな文字で注意喚起") + btn.innerHTML = "MathJax
Preview"; + btn.addEventListener('click', (e) => { + e.preventDefault(); + ta.focus(); + helpMarkdownPreview(ta); + }); + ta.parentNode.appendChild(btn); + } + function rewriteReplyHover(unit) { + function getTextById(id) { + let repltd = document.getElementById(id); + if (repltd) { + let txt = repltd.innerText, + authtd = repltd.parentNode.getElementsByTagName("td")[0], + author = authtd.querySelector("a.author").innerText, + digest = txt.split("\n").splice(0, hoverTextLines).join("\n"); + return escapeChars("[[ "+author+" ]]\n"+digest); + } else + return ""; + } + unit = unit||document; + for (let td of unit.querySelectorAll("td.repl")) { + let firstC = td.firstChild; + // Direct replacing innerHTML breaks embedded DOM event handlers. + // So, we split td.repl into elements and replace the first + // textNode(nodeType==3) with hover-text embeded content. + if (firstC.nodeType==3 && firstC.nodeValue.startsWith(">#")) { + let newline = firstC.nodeValue.indexOf("\n"); + let firstline; + if (newline > 0) { + firstline = firstC.nodeValue.substring(0, 1+newline); + firstC.nodeValue = firstC.nodeValue.substring(1+newline); + } else { + // Cannot be reached here, but leave this for robustness + firstline = firstC.nodeValue; + firstC.nodeValue = ""; + } + td.insertAdjacentHTML( + 'afterbegin', + escapeChars(firstline).replace( + /#([0-9]+)/g, + (match, start, whole) => { + let id = RegExp.$1 + return '' + match + ''; + })); + } + } + } + function initReplyHover(unit) { + // https://stackoverflow.com/questions/60154233/event-when-typesetting-is-done-mathjax-3 + if (mathjax && MathJax.startup) + MathJax.startup.promise.then(()=>rewriteReplyHover()); + else + rewriteReplyHover(); + } + var getHandoutCSV; + function initGetHandoutCSV() { + getHandoutCSV = document.getElementById("gethandoutcsv"); + if (!getHandoutCSV) return; + document.getElementById("bommsg").innerText = + `Excelで開く場合は上記CSVリンクをCtrlを押しながら。 +You need to click CSV link above with Ctrl-key when you handle CSV with Excel`; + getHandoutCSV.addEventListener("click", (e) => { + e.preventDefault(); // Stop visiting link + let bom = e.ctrlKey; + let csv = document.getElementById("totalcsv"); + if (!csv || !csv.textContent) return; + let fn = "report-count", plus=myurl.lastIndexOf("+"); + if (plus) fn += ("-"+myurl.substring(1+plus)); + fn = fn.replace(/#.*/, ""); + downloadFile(fn+".csv", csv.textContent, bom); + }); + } + function init() { + isOlderJS = !("insertAdjacentElement" in document.body); + initGrpAction(); + initBlogs(); + initFileInput(); + initTextarea(); + initGrphome(); + initMath(); + initReplyHover(); + initGetHandoutCSV(); + } + document.addEventListener('DOMContentLoaded', init, null); +})(); diff --git "a/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai.html" "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai.html" new file mode 100644 index 0000000..3ab9d43 --- /dev/null +++ "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai.html" @@ -0,0 +1,507 @@ + + + + + +プログラム募集! +|JDs4 - JD-Chokai + + + + + + +
+ +
+

プログラム募集! +

+

グループ + JD鳥海塾3期生 での話題 + +

+ +

+
+ + + + +
2023-10-13 09:34:30 末尾へ
+

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

#1780 +榊原一心(SAKAKIBARA Isshin) +令和5年10月13日09:46:24 +
@all
+

プログラムを募集します(11/3まで)

+11月4日(土)の「鶴岡サイエンスパークまつり2023」にJD鳥海塾で出展するのですが、そこで来場した小中学生にみなさんの作ってくれたプログラムを展示しようと思っています。 +「入塾して約3ヶ月でこういうのが作れるようになります!」と宣伝したいので、自信作お願いします。 + +テーマは、楽しい系、ミニゲーム、計算処理などでお願いします。

#1839 +OKAMOTO SHIN +令和5年10月20日18:51:20 +
誕生石のプログラムです。tanzixyouseki2.rb(986B)[Direct] +

#1844 +HIROSE Yuuji +令和5年10月20日19:11:08 +
>#1842 編集リンクから削除もできますよ。

#2073 +OKAMOTO SHIN +令和5年10月22日14:58:20 +
ありがとうございます。

#2103 +(3期生)村田佳史/MURATA Yoshifumi +令和5年10月23日07:29:19 +
単語長を作りました。今日のvlで改善しますmemomo.rb(705B)[Direct] +tanngotyou.rb(497B)[Direct] +

#2130 +(3期生)村田佳史/MURATA Yoshifumi +令和5年10月24日18:40:40 +
2つめ +シンプル?じゃんけんです。 +janken.rb(1792B)[Direct] +

#2263 +(3期生)佐藤大和/SATO Yamato +令和5年11月2日20:12:37 +
iidesuka +akiramedoki.rb(1263B)[Direct] +

#2264 +(3期生)佐藤大和/SATO Yamato +令和5年11月2日20:15:43 +
迷路みたいな感じですぐ出てしまうこともある +

#2265 +(3期生)佐藤大和/SATO Yamato +令和5年11月2日20:15:58 +
凄い終わるのが早い +

#2266 +榊原一心(SAKAKIBARA Isshin) +令和5年11月2日20:28:05 +
>#2263 +このプログラムを小学3、4年生くらいの子達にどう説明して遊んで貰えば良いですか。 +プログラムに名前をつけるとしたらなんですか?

#2267 +(3期生)佐藤大和/SATO Yamato +令和5年11月2日21:25:34 +
迷路です +

#2268 +(3期生)佐藤大和/SATO Yamato +令和5年11月2日21:26:16 +
簡単に数字でかんたん +

#2275 +(3期生)後藤 成那/GOTO Sena +令和5年11月3日19:28:23 +
じゃんけんのゲームです +自分がだした手とパソコンの手が表示されるのでとてもおもしろいゲームです + +janken_gu.jpg(6201B) + +janken_pa.jpg(8580B) + +janken_tyoki.jpg(7355B) +jyan.rb(1334B)[Direct] +

#2287 +HIROSE Yuuji +令和5年11月6日10:44:24 +
@all
ドコモ・プログラミングコンテストの案内 +プログラムを提出してくれた皆さんありがとうございました。 +サイエンスパークで見てもらった次のステップとして +こんなコンテストに応募してみませんか。 +ドコモ未来プロジェクトプログラミングコンテスト +言語は自由なので、Rubyでいけます。 +出してみたい人は相談に乗りますので教えてください。

#2289 +(3期生)村田佳史/MURATA Yoshifumi +令和5年11月6日15:22:58 +
>#2287 +やってみたいです!

#2290 +(3期生)今田陽太/KONTA Hinata +令和5年11月6日15:25:18 +
>#2287 僕もやってみたいです

#2294 +HIROSE Yuuji +令和5年11月6日21:36:21 +
>#2289, #2290 満足できるけどあまり長くないものを完成させましょう。 +動画で紹介する時間制限が3分なので30秒から40秒程度で実行完了するくらいのつもりで作ってみてください。 +他の皆さんはどうですか、 +

#2295 +(3期生)村田佳史/MURATA Yoshifumi +令和5年11月6日21:54:14 +
>#2294 +時間考えたことなかったから、難しそう

#2298 +(3期生)今田陽太/KONTA Hinata +令和5年11月7日15:47:37 +
連絡遅れました。 +わかりました。

編集 #2300 +(3期生)菅原美優/SUGAWARA Miyuu +令和5年11月7日23:34:16 +
>#2287 +私もやってみたいです +

#2301 +HIROSE Yuuji +令和5年11月8日07:09:34 +
>#2298, #2300 今田さん、美優さん、 +わかりました、やってみましょう。 +最近作ったものをアレンジするなどして、すぐできる形のものがよいと思います。 +その際気をつけるのは、以下のような点です。 +
  • プログラムにストーリーを持たせて使う人の想像をかき立てる
  • +
  • 将来的にはどう改良していきたいかのビジョンを持つ
  • +
  • でも現時点ではできるだけコンパクトにまとめる(極限まで短くする)
  • +
  • 実行時の見た目をわかりやすくする
  • +
短くするために、ifの羅列でなく配列や頑張ってCSVを活用するとよいでしょう。 +どんなものを作ってみたいですか。

#2302 +(3期生)今田陽太/KONTA Hinata +令和5年11月8日16:09:00 +
ゴミ分別のプログラムを改善したいです

#2303 +(3期生)村田佳史/MURATA Yoshifumi +令和5年11月8日17:07:55 +
>#2301 +戦わない、RPGなんてどうでしょうか

#2304 +HIROSE Yuuji +令和5年11月8日18:40:32 +
>#2302 今田さん、 +有用ですね、分別を教えてくれるのですか? +

#2305 +HIROSE Yuuji +令和5年11月8日18:41:22 +
>#2303 それはおもしろい、 +細かいストーリーはかけますか。

#2306 +(3期生)村田佳史/MURATA Yoshifumi +令和5年11月8日19:04:17 +
>#2305 +魔王を倒したあとのストーリーとか +勇者が魔王を倒しに行こうとするけど、魔王と勇者が和解する的な感じ +です +

#2307 +HIROSE Yuuji +令和5年11月8日19:57:35 +
>#2306 ふむふむ +台本はどんな感じにしますか +

編集 #2308 +(3期生)菅原美優/SUGAWARA Miyuu +令和5年11月9日18:53:06 +
>#2301 +月旅行プログラムを作りたいです。

#2309 +HIROSE Yuuji +令和5年11月9日20:15:46 +
>#2308 月旅行! +これは面白い、どんなストーリですか?

#2310 +(3期生)今田陽太/KONTA Hinata +令和5年11月9日20:27:55 +
>#2304 この前分別はできるようになったのでいいんですけど月曜日からしか選択できなかったので火曜日とか水曜日とかから始められるようにしたいです

#2311 +(3期生)村田佳史/MURATA Yoshifumi +令和5年11月9日20:31:06 +
>#2307 +台本は、和解するんのがいいので、 +勇「よしみんな魔王をたおしに行くぞ!(オー) +勇「ついに来たぞ、今日はお前を倒しに来た!」 +魔「え・・・もうきたの」 +勇「なんかあった?」 +魔「昨日戦ってもう疲れて、もう戦いは、したくないんだよ」 +魔「だからもう和解しない」 +勇「おお・・・じゃあこれから仲良くしようか」 +村「やばいぞ 魔王が来た魔王が」 +村「しかも勇者もいる!? どういうことだ」 +勇「これには事情があって・・・」 +魔「というわけだ」 +村「魔王しっかりまちづくりに協力しろよ」 +このあとはまた考えます +

編集 #2312 +(3期生)菅原美優/SUGAWARA Miyuu +令和5年11月9日21:56:54 +
>#2309 +ストーリーかはわからないですが、 +宇宙船(ロケット?)で月に行き月の石を持って帰るという感じにしたいです。

#2314 +HIROSE Yuuji +令和5年11月10日08:00:22 +
>#2310 参考としてCSVファイルにある問題を出題するプログラムを載せます。 +いくつか問題点があるので改善してみましょう。 +
  1. 配列が0から始まるので問題番号の指定が0からになっていてわかりにくい
  2. +
  3. 大きすぎる問題番号を入れるとエラーでコケる
  4. +
  5. 1問だけで終わってしまう
他の人も参考にして拡張してみてください。 +quiz.csv(529B)[Direct] +quiz.rb(631B)[Direct] +

#2315 +HIROSE Yuuji +令和5年11月10日08:04:55 +
>#2312 天文のときの地球脱出プログラムのように地球を出発する感じですかね。
+ +
+ + + +
+
+ + + +
添付ファイル(11MB以下): +  + + +
+ + + +
+
+
+ + \ No newline at end of file diff --git "a/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/175-janken_gu.jpeg" "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/175-janken_gu.jpeg" new file mode 100644 index 0000000..7fe27ba --- /dev/null +++ "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/175-janken_gu.jpeg" Binary files differ diff --git "a/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/176-janken_pa.jpeg" "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/176-janken_pa.jpeg" new file mode 100644 index 0000000..0663c35 --- /dev/null +++ "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/176-janken_pa.jpeg" Binary files differ diff --git "a/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/177-janken_tyoki.jpeg" "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/177-janken_tyoki.jpeg" new file mode 100644 index 0000000..baf7f57 --- /dev/null +++ "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/177-janken_tyoki.jpeg" Binary files differ diff --git "a/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_1380.png" "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_1380.png" new file mode 100644 index 0000000..d9c40ee --- /dev/null +++ "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_1380.png" Binary files differ diff --git "a/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_M_houtin2.png" "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_M_houtin2.png" new file mode 100644 index 0000000..3ef8b8a --- /dev/null +++ "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_M_houtin2.png" Binary files differ diff --git "a/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_blueimpulse.jpg" "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_blueimpulse.jpg" new file mode 100644 index 0000000..fef8ef4 --- /dev/null +++ "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_blueimpulse.jpg" Binary files differ diff --git "a/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_kqQX6PD7.png" "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_kqQX6PD7.png" new file mode 100644 index 0000000..4782de1 --- /dev/null +++ "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_kqQX6PD7.png" Binary files differ diff --git "a/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_saa45.JPG" "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_saa45.JPG" new file mode 100644 index 0000000..0b6d828 --- /dev/null +++ "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_saa45.JPG" Binary files differ diff --git "a/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_sp3.png" "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_sp3.png" new file mode 100644 index 0000000..43fbf52 --- /dev/null +++ "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_sp3.png" Binary files differ diff --git "a/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_\347\204\241\351\241\214.png" "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_\347\204\241\351\241\214.png" new file mode 100644 index 0000000..895888f --- /dev/null +++ "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_\347\204\241\351\241\214.png" Binary files differ diff --git "a/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_\347\204\241\351\241\214172.png" "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_\347\204\241\351\241\214172.png" new file mode 100644 index 0000000..14ac74a --- /dev/null +++ "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/S_\347\204\241\351\241\214172.png" Binary files differ diff --git "a/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/default.css" "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/default.css" new file mode 100644 index 0000000..2bf82ff --- /dev/null +++ "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/default.css" @@ -0,0 +1,481 @@ +/* + * Default CSS definitions + */ +@media print { + div.blogcomment, div.blogcomment *, div.topmenu, + table.bloghead button { + display: none + } + a {text-decoration: none;} +} +body {background: #eff; margin: 2px; padding: 6px;} +h2, h3, hr {clear: both;} +*.warn {color: red;} +*.warnbg {background: red;} +*.hidden {visibility: hidden;} +*.border {border: 1px solid #113;} +div.topmenu { + margin: 0; padding: 0; width: 100%; height: 2em; +} +div.topmenu ul {width: 100%; position: fixed; z-index: 5; margin: 0; + margin: 0 auto;} +div.topmenu ul li { + float: left; width: 18%; + background: rgba(68,255,102,0.8); border: #3e5 2px groove; margin: 0; + text-align: center; font-size: 80%; list-style: none; + box-shadow: #242 2px 3px 5px; + text-shadow: #fff 0px 0px 10px; +} +div.topmenu ul li.worldname {background: #eeeeff;} +div.topmenu ul li:hover {background: #8fa;} +div.topmenu ul a {text-decoration: none;} + +ldiv.topmenu + h1 {clear: both; margin-top: 3em;} +pre.list { + overflow: auto; width: 96%; height: 40%; background: white; + border: 2px inset; +} +p.copyright { + border-top: 2px inset #555; text-align: right; clear: both; + font-size: 50%; +} +p.copyright a, a#reload {text-decoration: none;} + +td {padding-left: 0.5ex; padding-right: 0.5ex;} +table.td2r td:nth-child(2) {text-align: right;} +table.td3r td:nth-child(3) {text-align: right;} +table.td3rr td:nth-child(n+3) {text-align: right;} +table.td3evw th:nth-child(2n+4), span.textdigest { + background: white; +} +table.td4r td:nth-child(4) {text-align: right;} +table.thl th {text-align: left;} +span#reverse {background: white; padding: 0 0 0 0.4ex; border: outset;} + +table.form, table.b, table.b tr, table.b td, table.b th { + border: 1px solid black; border-collapse: collapse; +} +table.b, table.bloghead { + border-radius: 1ex; box-shadow: rgb(250,222,222) 1px 2px 3px; +} +td.warn {background: #fcc;} +input[type="checkbox"][name="rm"]:checked ~ table {background: red;} +input[type="checkbox"][name="rm"] ~ span {display: none;} +input[type="checkbox"][name="rm"]:checked ~ span {display: inline;} + +input[type="radio"][value="replace"] + input.replace[type="file"] { + visibility: hidden;} +input[type="radio"][value="replace"]:checked + input.replace[type="file"] { + visibility: visible; +} +button#morefile {visibility: hidden; background: #fe9;} +label.admin span {border-bottom: 1px solid blue;} +label.admin:after {content: "(ADMIN)"; color: red; text-decoration: none;} +span.fileinput { + display: inline-block; height: 3.2ex; + border: 1px solid #4444; border-radius: 1ex; + position: relative; width: 16em; background: #e7e7ea; text-align: center; +} +span.fileinput input[type="file"] { + position: absolute; width: 100%; height: 100%; left: 0; top: 0; + padding: 0; +} +span.fileinput:hover {background: #efc;} +/* keep/edit/rm action selector */ +input.action ~ input:not(.action), input.action ~ textarea { + display: none; +} +input.action[value="edit"]:checked ~ input[class="edit"], +input.action[value="mv"]:checked ~ input[type="text"] {display: inline;} +input.action[value="edit"]:checked ~ textarea {display: block;} +input.action[value="edit"]:checked ~ span:not(.fileinput), +input.action[value="mv"]:checked ~ span {display: none;} +input.action[value="rm"]:checked ~ span {background: red;} +label.confirm {display: none;} +*.inline, +input.action[value="rm"]:checked ~ label.confirm { + display: inline; +} + +input.hidesub ~ input[type="submit"] {visibility: hidden;} +input.hidesub:focus ~ input[type="submit"], +p:active input[type="submit"] +{visibility: visible;} +input[type=text]:focus {background: #ffa;} + +form.replyblog {xxx-margin-bottom: 40%;} +div.blogcomment { + position: fixed; bottom: 0; left: 0; + z-index: 2; background-color: rgba(250,222,222,0.6); +} +/* div.blogcomment textarea:focus {background: yellow; + position: fixed; top: 0; bottom: auto; } Need to consider narrow display */ +div.blogcomment * {opacity: 1.0;} +table.bloghead, .bloghead tr, .bloghead td { + border: 1px solid black; border-collapse: collapse; + min-width: 30em; +} +table.bloghead tr.preface { + font-size: 150%; background: yellow; /* text-align: center; */ + white-space: pre-wrap; +} +tr.preface em {color: navy; text-decoration: underline; padding-right: 0.3ex;} +tr.preface strong {color: navy; background: #eea;} +table.bloghead tr.frozen { + background: #ccf; border: blue thick solid; color: navy; +} + +table.bloghead {margin-bottom: 1em;} + +table.blog_replies, .blog_replies tr, .blog_replies td { + border: 1px solid #999; border-collapse: collapse; + white-space: pre-wrap; +} +table.bloghead tr.preface td ul, +table.bloghead tr.preface td ol, +table.bloghead tr.preface h2, +table.bloghead tr.preface h3, +table.bloghead tr.preface h4, +table.bloghead tr.preface h5, +table.bloghead tr.preface h5, +table.blog_replies video, +table.blog_replies iframe, +table.blog_replies ul, .blog_replies tr ul, .blog_replies td ul, +table.blog_replies ol, .blog_replies tr ol, .blog_replies td ol { + text-align: left; white-space: normal; margin: 1ex 0; +} +table.bloghead tr.preface h2, +table.bloghead tr.preface h3, +table.bloghead tr.preface h4, +table.bloghead tr.preface h5, +table.bloghead tr.preface h5 +{ + display: inline-block; +} +table.blog_replies p.proficon { + float: right; margin: 0 1ex 0 0; +} +table.blog_replies+p.update_link {margin-top: 0; margin-bottom: 14em;} +.blog_replies td.repl { + vertical-align: top; min-width: 30em; height: 3em; + max-width: 50em; +} +.blog_replies td.repl img {max-width: 30%;} +td.repl h2, td.repl h3, td.repl h4 { + display: inline; /* Because td.repl's white space is pre-wrap */ + /* text-shadow: blue 0px 1px; */ +} +td.repl hr {display: inline-block; width: 95%; color: #cde} +td.repl em {color: #a00; text-decoration: underline; padding-right: 0.3ex;} +td.repl strong {color: white; background: #00a; padding: 0 0.5ex;} +:root {--repl-heading-color: #a22;} +td.repl h2:before {content: "■"; color: var(--repl-heading-color);} +td.repl h3:before {content: "◆"; color: var(--repl-heading-color);} +td.repl h4:before {content: "◎"; color: var(--repl-heading-color);} +td.repl div.atall { + color: white; background: #66f; padding: 0 0.8ex; + display: inline-block; border-radius: 0.8ex; +} +td.repl.atall:first-line {font-size: 125%;} + +.blog_replies td.repatt {min-width: 12em;} +.blog_replies td.hideauthor {display: none;} +table.blog_replies iframe { + width: 80%; min-height: 300px; max-width: 50em; max-height: 80vw; + padding: 0; border: 0; +} +table.blog_replies td.new { /* New Article from last visit */ + background: white +} +table.mini, table.mini tr, table.mini th, table.mini td { + margin: 0; border-width: 0; + border-collapse: collapse; + vertical-align: top; width: auto; height: 1em; +} +table.mini th {background: #cee;} +table.mini tr {border-bottom: solid 1px #bcc;} +table.mini th, table.mini td {text-align: justify;} +table.mini td, table.mini th {padding: 1px 0.5ex; min-width: 1em;} +table.mini {margin-left: 1em; border-left: 2px solid #686;} +form.replyblog table s { + text-decoration: line-through #ff111180 0.3ex solid; +} + +div.pjaxview, div.pjaxview2 { + position: fixed; top: 1ex; left: 0; width: 9vw; height: 9vh; + background: #ffffee; border: 1px double navy; border-radius: 2em; + z-index: 7; +} +div.pjaxview2 { + width: 100vw; height: 98vh; transition: 0.5s; +} +div.pjaxview iframe { + width: 98%; height: 90%; object-fit: scale-down; +} +div.pjaxview p { + padding: 0.5ex; text-align: left; margin: 0 2em; + white-space: nowrap; overflow: hidden; +} +div.pjaxview p button { font-size: large; padding: 0 1em;} +div.pjaxview p button { background: #eeeee0; } +div.pjaxview p button:focus { background: #fffff8; } + +/* "visibility: collapse" not working on chromium browser */ +div.noprofimg tr.profimg {visibility: collapse; display: none;} +div.noprofimg tr:hover + tr.profimg, div.noprofimg tr:active + tr.profimg, +div.noprofimg tr.profimg:hover, div.noprofimg tr.profimg:active { + visibility: visible; display: table-row;} + +/* Used for overlapping image */ +img.overlap {position: absolute; top: 40px; left: 50px; z-index: 2;} + +/* Used in user's home page */ +p.profimg {float: left; max-width: 50%; max-height: 400px; + overflow: hidden; margin: 0 1em 1ex; + padding: 0; border: white 1px solid; box-shadow: 2px 3px 4px + } +p.profimg img {max-width: 400px;} +div.home+* {clear: both;} +body.grouphome p.groupimg { + float: right; margin: 0 1em 1ex; + overflow: hidden;} +body.grouphome p.groupimg img { + max-width: 380px; max-height: 380px;} + +@media screen { + div.fold {margin-top: 1em; border-top: 1px solid black; padding-top: 1em;} + div.noborder {border: 0px; margin: 0;} + div.fold > div { + xxdisplay: none; max-height: 80%; overflow: auto; + height: 0px; opacity: 0; padding: 0 1ex; + } + div.fold input[type="checkbox"]:checked ~ div, + div.fold input[type="radio"]:checked ~ div { + display: block; background: #fadede; + height: auto; opacity: 1.0; transition: 1s; + } + input.fold + label + *.folded {opacity: 0; display: none; hight: 0;} + input[type="checkbox"].fold:checked + label + *.folded { + opacity: 1.0; transition: 2s; + } + input[type="checkbox"].fold:checked + label + div.folded { + display: block; hight: auto; transition: 2s; + } + + /* fold2!! */ + div.foldtabs { + position: relative; height: 5em; margin-top: 1em; + border-top: 1px solid black; padding-top: 1em; + } + div.foldtabs > div { + position: absolute; top: 2.5em; opacity: 0.0; background: pink; + margin: 2px; overflow: auto; + } + div.foldtabs input[type="radio"] {display: none;} + div.foldtabs input[type="radio"]:checked + label + div { + display: block; opacity: 1.0; transition: 0.2s; width: 100%; + margin: 0; z-index: 2; + } + div.foldtabs > label { + border: 1px outset #ddd; background: #ddd; xbackground: pink; + border-top-left-radius: 0.8em; border-top-right-radius: 0.8em; + margin: 0; + padding: 0.2ex 0.5em; height: 3em; + } + div.foldtabs > input:active + label {background: white;} + div.foldtabs input:checked + label { + background: pink; border: pink 1px solid; border-bottom-width: 6px; + } + div.foldtabs input:checked + label:last-of-type {border-width: 1px;} + input[type="checkbox"] + label + input[type="submit"] {display: none;} + input[type="checkbox"]:checked + label + input[type="submit"] { + display: inline;} + div.foldtabs p {margin: 0;} +} + +/* ToDo List CheckBox inspired by https://cultureacademia.jp/webcreate/303/ */ +input.s4-checkbox {display: none;} /* Do not show real checkbox */ +input.s4-checkbox + label { + position: relative; padding-left: 0.8em; margin-right: 1em; +} +input.s4-checkbox + label:before, +input.s4-checkbox + label:after { + content: ""; display: block; /* Mimic Checkbox by absolute box */ + position: absolute; top: 0; left: 0; margin: 0; +} +input.s4-checkbox + label:before { /* checkbox frame */ + width: 0.8em; height: 0.8em; border: 1px solid #aaa; border-radius: 20%; + background: #ddd; +} +input.s4-checkbox:checked + label:before { /* checked frame bg */ + background: pink; +} +input.s4-checkbox:checked + label { /* checked text */ + /* text-shadow: red 1px 1px; */ +} +input.s4-checkbox:checked + label:after { /* checked mark */ + width: 0.6em; height: 0.4em; top: 0.05em; left: 0.1em; + border-bottom: 3px solid navy; + border-left: 3px solid navy; + transform: rotate(-40deg); +} +/* ---------------------------------------------------- */ + +div.dumptable {max-height: 70vw; overflow: auto;} +div.dumptable tr:hover {background-color: #fee;} +table.dumpblogs td, +div.lcto td { /* LINK + CTIME + TITLE + OWNER + something... */ + white-space: nowrap; overflow: hidden;} +table.dumpblogs td:nth-child(4), +div.lcto td:nth-child(2) {max-width: 8em;} +table.dumpblogs td:nth-child(5), /* team */ +table.dumpblogs td:nth-child(6), /* title */ +table.dumpblogs td:nth-child(7), /* heading */ +div.lcto td:nth-child(3), /* title */ +div.lcto td:nth-child(4) /* owner */ + {max-width: 14em;} +/* https://curecode.jp/tech/css-table-position-sticky-with-background-border-vanished/ */ +div.dumptable table.dumpblogs th { + position: sticky; top: 0; z-index: 1; background: #fcf0f0; + border: 1px solid black; border-collapse: collapse; + background-clip: padding-box; +} + +table.dumpblogs tr.凍結 td:nth-child(n+2) {opacity: 0.5;} +table.dumpblogs tr.凍結 td:last-child {opacity: 1.0; color: blue;} +*.frozen, *.凍結 {color: blue;} + +/* +table.dumpblogs td:nth-child(4) { + max-width: 7.6em; overflow: hidden;} +table.dumpblogs td:nth-child(5), +table.dumpblogs td:nth-child(6) { + max-width: 12em; overflow: hidden;} +table.dumpblogs td:nth-child(7) { + min-width: 5em; overflow: hidden;} +*/ + +/********************* icon list *********************/ +div.iconlist { + text-align: center; float: left; margin: 1ex 1em; + border: dotted #dfd 2px; padding: 1ex; +} +div.iconlist p {margin: 0; padding: 0;} +div.iconlist p.tag {background: #ffa; border-radius: 4em;} +div.iconlist p._temp {background: cyan;} +div.iconlist p._lecture {background: pink;} +div.iconlist p._admin {background: yellow;} +div.iconlist p._friend {background: fuchsia;} +div.iconlist p._fellows {background: #9f9;} /* light green */ +div.iconlist p._club {background: #4bb;} /* light teal */ +div.iconlist p._event {background: maroon; color: white;} +div.iconlist p._misc {background: purple; color: white;} +div.iconlist p._record {background: red; color: white;} +div.iconlist p._info {background: #eff;} /* light cyan */ +div.iconlist p._support {background: #ffe;} /* light yellow */ +div.iconlist p._test {background: #ffb6c1;} /* light pink */ +input#ismembtn:checked ~ div.iconlist, +input#isadmbtn:checked ~ div.iconlist {display: none;} +input#ismembtn:checked ~ div.iconlist.Member, +input#isadmbtn:checked ~ div.iconlist.ADMIN, +input#ismembtn:checked ~ div.iconlist.ADMIN {display: block;} +div.xy120x120 {min-width: 120px; min-height: 140px;} +div.xy96x96 {min-width: 96px; min-height: 116px;} +div.xy96x96 img {max-width: 96px;} +div.xy50x50 {min-width: 50px; min-height: 70px;} +div.xy50x50 img {max-width: 50px;} +div.moderated {background: rgba(255, 215, 0, 0.3);} /* gold */ +body.moderated {background: #fffec4;} /* #faed8a */ +body.ismember, div.ismember {border-top: 4px red solid; margin-top: 0;} +div.right, div.search {clear: both; float: right;} +*.clear {clear: both;} +div.search input[type="text"] { + border: solid 1px #bbb; border-radius: 0.5ex; min-height: 20px; + margin: 1em; padding: 0 0.5ex; padding-left: 18px; + background: url("../../img/loupe.png") left center no-repeat + rgba(242,240,240,0.7); + position: relative; +} +div.search div.fr, *.relative {position: relative;} +div.search p.help, textarea + p.help {display: none;} +div.search input:focus + p.help, +textarea:focus + p.help { + display: block; background: white; + position: absolute; right: 15em; white-space: pre; + border: 1px solid #888; border-radius: 1em; padding: 1ex; + box-shadow: #555 2px 2px; +} +textarea:focus + p.help { + position: fixed; + top: 0em; left: 0; +} +form.summary input[type=submit], +input[type="submit"].all, button.all { + background: #cfc; padding: 0.4ex 2ex; +} +button#c { + padding: 0.2ex 4em; border-radius: 0.5ex; +} +input#cmt input[type="submit"] {height: 4em;} + +input[type="reset"] {margin-left: 4em;} + +/* + * World List + */ +li.casmenu div {display: none; position: relative; width: 200%; + min-width: 80%; margin-right: 0;} +li.casmenu div table { + background: white; position: absolute; top: 0em; border: 3px solid navy; + max-width: 100%; +} +li.casmenu div table td {text-align: left; padding: 0.5ex 1em;} +li.casmenu:hover div, li.casmenu:active div, +li.casmenu div:hover, li.casmenu div:active +{display: block;} +span.pre {white-space: pre;} + +/* + * Frozen toggle button + */ +td.稼動状態 {text-align: center;} +button.toggle-frozen { + padding: 0 1emex; + background: #fdb585; + border-radius: 1ex; + border-bottom: solid 2px #d27d88; + box-shadow: inset 0 2px 0 rgba(255,255,255,0.2), 0 2px 2px rgba(0,0,0, 0.19); + background: linear-gradient(#fdeaea, #fdb2b2); // ffc8a8 +} +.凍結 button.toggle-frozen, .凍結 button.toggle-frozen::before { + background: linear-gradient(#d8e2ea, #83bbea); +} +.凍結 button.toggle-frozen::before { + content: attr(frozen-marker); color: blue; +} +.toggle-frozen::before { + content: attr(running-marker); +} +.info-tooltip { + position: absolute; padding: 1ex; + background: ivory; + border-radius: 1em; border: double 5px blue; + min-width: 10em; right: 0; bottom: 0; +} +.dissolving {opacity: 0; transition: 3.0s;} +.emerging {opacity: 1; transition: 3s;} +button#c, button#reload {display: inline-block;} +span.loading, button#c:disabled, button#reload:disabled { + visibility: visible; transform: rotateX(3600deg); transition: 30s; +} +span.loading {padding: 0 1em;} +input.aux, input[type="reset"] {margin-left: 10em; transform: scale(0.7);} + +/* + * PR Web + */ +body.pr {font-size: 200%;} +body.pr h1 { + text-align: center; width: 80%; padding: 3ex 0; margin: 0 auto; + background: #ffefef; border: double 5px navy; +} diff --git "a/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/file-icon.png" "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/file-icon.png" new file mode 100644 index 0000000..d82f259 --- /dev/null +++ "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/file-icon.png" Binary files differ diff --git "a/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/j2023.css" "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/j2023.css" new file mode 100644 index 0000000..5287ca2 --- /dev/null +++ "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/j2023.css" @@ -0,0 +1,9 @@ +@import url("default.css"); +body {background: url("img/jds4_bg_2023.png") #ffffbf no-repeat center fixed; + background-size: cover; margin: 2px; padding: 6px; +} +body.moderated {background: #e4ecc5; border: 3px gold solid;} +div.topmenu ul li { + background: #ffd531; border: #ed8 2px groove; margin: 0 +} +div.topmenu ul li:hover {background: #da6;} diff --git "a/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/s4-main.js" "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/s4-main.js" new file mode 100644 index 0000000..0bc713e --- /dev/null +++ "b/\343\203\227\343\203\255\343\202\260\343\203\251\343\203\240\345\213\237\351\233\206\357\274\201 JDs4 - JD-Chokai_files/s4-main.js" @@ -0,0 +1,1223 @@ +// 愛 +(function (){ + var isOlderJS; // Set in init(); + var hoverTextLines = 10; + var hasTouchPad = + (navigator.maxTouchPoints && navigator.maxTouchPoints >0); + var myurl = document.URL, + mypath = myurl.substring(myurl.lastIndexOf("/")); + var art_m_list = []; + var mathjax = false; + let input_pdfsw = 'input[name="comppdf"]'; + if (mypath.match(/(.*)\/(.*)/)) { + mypath = RegExp.$2; + mypath = mypath.substring(0, mypath.lastIndexOf("?")); + //alert("mypath="+mypath); + } + function escapeChars(old) { + return old.replaceAll('&', '&') + .replaceAll('"', '"') + .replaceAll("<", '<') + .replaceAll(">", '>'); + } + function collectElementsByAttr(elm, attr, val) { + var e = document.getElementsByTagName(elm); + if (!e) return null; + var list = []; + for (var i of e) { + if (i.getAttribute(attr) == val) + list.push(i) + } + return list; + } + function nthChildOf(parent, n, elem) { // Return Nth child of type ELEM + // N begins with 1 + var i=0; + var le = elem.toLowerCase(); + for (var c of parent.childNodes) { + if (!c.tagName) continue; + if (c.tagName.toLowerCase() == le) { + if (++i >= n) return c; + } + } + return null; + } + function insertRedirect(e) { + var articleId, textarea = document.getElementById("text"); + var p = e.target, checked = p.checked; + while (p = p.parentNode) + if (p.nodeName.match(/^td$/i)) break; + if (!p) return; + while (p = p.nextSibling) + if (p.nodeName.match(/^td$/i)) break; + if (!p) return; + articleId = p.getAttribute("id"); + if (textarea && articleId) { + var tv = textarea.value, lines; + if (tv) + lines = tv.split("\n"); + else + lines = [""]; + var re = new RegExp("[, ]*#"+articleId+"(?![0-9])"); + checked = (p.nodeName.match(/^input$/) + ? p.checked // checkbox obeys its status + : !lines[0].match(re)) // a-elment toggles redirection + if (checked) { + if (!lines[0].match(re)) { + var re2 = new RegExp(/>#[#0-9, ]+[0-9]/); + if (lines[0].match(re2)) + lines[0] = lines[0].replace( + re2, '$&, '+'#'+articleId); + else { + if (lines[0] > "") lines[0] = " "+lines[0]; + lines[0] = ">#"+articleId+lines[0]; + } + } + } else { // Remove #xxxxx + if (lines[0].match(/^>#[0-9 ,]+#/)) // 2 or more #id's + lines[0] = lines[0].replace( + new RegExp("^>#"+articleId+"[ ,]*"), ">").replace( + new RegExp("[ ,]*#"+articleId), ""); + else { + lines[0] = lines[0].replace( + new RegExp(">#"+articleId+"[ ,]*"), ""); + } + } + lines[0] = lines[0].replace(/^> *$/, ''); + textarea.value = lines.join("\n"); + } + } + function registPjaxViewers(aHrefList) { + let apos=art_m_list.length; + for (let a of aHrefList) { + let href = a.getAttribute("href"); + let localvar = apos; + let td = a.parentNode, + tr = td.parentNode, + id = td.id, + text = td.textContent, + author = tr.getElementsByTagName("a"); + if (author) author = author[0].getAttribute("title"); + if (href.match(/\?showattc\+article_m\+([0-9]+)$/)) { + if (td.innerHTML.match(/読み取り不可/)) { + a.removeAttribute("href"); + continue; + } + let url = RegExp.lastMatch; + // console.log("pjaxView(e, "+href+", "+apos+")"); + a.addEventListener("click", function(e) { + // Shoud use closure local variable: localvar + pjaxView(e, href, localvar); + }, false); + apos++; + art_m_list.push({ + url: href, id: id, author: author, text: text + }); + } + } + } + function registInsertDirect(aHrefList) { + for (i of aHrefList) + if (i.getAttribute("href").match(/^#[0-9]+$/)) + if (RegExp.lastMatch == i.innerHTML) + i.addEventListener("click", insertRedirect, false) + } + function mathjaxUpdate(arg) { + try { + if (MathJax && MathJax.typesetPromise) { + MathJax.texReset(); // Reset Math counters + MathJax.typesetPromise(arg); // MathJax v3 + } + } catch (err) {console.log(err);} + } + var ajaxSubmit; + function replAddNews(newtable) { + let newids = [], idlist=[]; + let getArticleID = function (td) { + return parseInt(td.parentNode.getElementsByTagName("td")[1].id); + } + for (let i of newtable.querySelectorAll("td.repl")) + newids.push(i); + newids = newids.sort((a,b)=> { + return (getArticleID(a) - getArticleID(b)); + }); + for (i of newids) + idlist.push(getArticleID(i)); + console.log("IDList="+idlist.join()); + let cnt=0, ntr; + let current = collectElementsByAttr("td", "class", "repl"), + ncur=0, n, icur=0, o, oid, nid, otr; + current = document.querySelectorAll('td[class="repl"]'); + let last=current[current.length-1], + tbody = last.parentNode.parentNode; + let addEventsToNewTr = function(tr) { + let td = tr.getElementsByTagName("td"), + td0 = td[0], td1 = td[1]; + td0.classList.add("new"); + registInsertDirect(td0.querySelectorAll("a[href]")); + registPjaxViewers(td1.querySelectorAll("a[href]")); + } + // Erase all "new article" flags before merging + for (let i of document.querySelectorAll("td.new")) + i.classList.remove("new"); + // Now reconstruct articles with merge-sort like method + outer: for (; ncur= nid) { + addEventsToNewTr(ntr); + tbody.insertBefore(ntr, otr); + if (oid==nid) otr.remove(); + cnt++; + continue outer; + } + } + // Append absolutely new articles. + ntr = n.parentNode; + addEventsToNewTr(ntr) + tbody.appendChild(atMarkView(ntr)); + ntr.classList.add("dissolving"); + let localntr = ntr; + setTimeout(() => { + localntr.classList.remove("dissolving"); + localntr.classList.add("emerging"); + }, 100); + rewriteReplyHover(ntr); + cnt++; + } + mathjaxUpdate(newids); + console.log("Update "+cnt+"rows"); + if (cnt>0 && ntr.scrollIntoView) { + let option = {behavior: "smooth"}; + if (!isOlderJS) option.block = "center"; + try { // Scroll to last updated row + ntr.scrollIntoView(option); + } catch (e1) {} + } + return cnt; + } + + function warnFileSize(form) { + let szmax = form.querySelector('input[name="filesize_max"]').value; + if (!szmax || szmax=="") return; + szmax = parseInt(szmax); + if (szmax <= 0) return; + // szmax = 10000 + let ng = "", rcval=false, fileexists=false, + pdfsw = form.querySelector(input_pdfsw), + pdfmsg = "Try compressing PDF?\nPDFを圧縮してみますか?\n" + + "(それでも収まらない場合もあります)"; + for (let f of form.querySelectorAll('input[type="file"]')) { + let thiserr = false; + for (let i of f.files) { + fileexists = true; + let fn = i.name, sz = i.size; + console.log("max="+szmax+", fn="+fn+", sz="+sz); + if (sz > szmax) { + if (fn.match(/\.pdf/i) + && sz < szmax*3 // XXX : x3 reasonable? + && (pdfsw || confirm(pdfmsg))) { + if (!pdfsw) { + pdfsw = document.createElement("input"); + pdfsw.name = "comppdf"; + pdfsw.type = "hidden"; + f.parentNode.insertBefore(pdfsw, f); + pdfsw.value = "yes"; + } + } else { + thiserr = true; + ng += ((ng>"" ? ", " : "")+fn) + } + } + } + thiserr ? f.classList.add("warnbg") : f.classList.remove("warnbg"); + } + if (ng>"") { + rcval = "File-size Limit Error: "+ng+"\n"+ + "Should be less than "+szmax+"bytes.\n"+ + szmax+"バイト未満にしてください" + alert(rcval); + } + if (form.text.value == "") { + let w; + if (fileexists) + w = "Fill the text area\n" + + "添付したファイルに関する説明を入れてください。"; + else + w = "Enter your comment!\n何か書き込んでね!"; + alert(w); + rcval = (rcval || w); + form.text.classList.add("warnbg"); + setTimeout(() => {form.text.classList.remove("warnbg");}, 2000) + } + return rcval; + } + function ajaxPost(e) { + e.preventDefault(); + let rowid; + if (!myurl.match(/replyblog\+([0-9]+)/)) return; + rowid = RegExp.$1 + let myform = document.querySelector("form.replyblog"); + let data = new FormData(myform), + fetchtime = data.get("fetchtime"); + if (!fetchtime || fetchtime=="") return; + ///*XX*/fetchtime = "2020-06-14T00:00:00";data.set("fetchtime", fetchtime) + + ajaxSubmit = e.target; + ajaxSubmit.back = ajaxSubmit.textContent; + if (ajaxSubmit.id == "reload") { + ajaxSubmit.textContent = "更新中" + data.set("text", "") + } else { + if (warnFileSize(myform)) return; + ajaxSubmit.textContent = "送信中"; + } + ajaxSubmit.blur(); + ajaxSubmit.disabled = true; + let act = mypath+"?blog_fetch+"+rowid+"+f:"+fetchtime; + + function respUpdate(tbody) { + ajaxSubmit.textContent = ajaxSubmit.back; + ajaxSubmit.disabled = false; + let div = document.createElement("div"), form, newform; + try { + div.innerHTML = tbody; + form = div.querySelector("form"); + } catch (er) { + alert("Cannot parse fetch data"); + return; + } + let update = replAddNews(form); + let dispelem = myform.querySelector("textarea").parentNode; + if (div.querySelector('input[name="user"]')) { // is login form + dispInfoMomentary("Login Again Please", dispelem) + return; + } + newform = new FormData(form); + if (data.get("text") > "") { // Called by submit button + myform.reset(); + let pdfsw = myform.querySelector(input_pdfsw); + if (pdfsw) pdfsw.remove(); + // myform.text.value = ''; + } + myform.fetchtime.value = newform.get("fetchtime"); + myform.id.value = newform.get("id"); + if (update && update > 0) { + let s = update + " new article" + + (update>1 ? "s" : "") + " posted"; + dispInfoMomentary(s, dispelem); + } + } + fetch(act, { + method: "POST", body: data, + credentials: "include" // For older firefox + }).then((resp) => { + return resp.text(); + }).then((tbody) => { + respUpdate(tbody); + }) + } + function pjaxView(ev, url, mynum) { + if (ev.ctrlKey||ev.shiftKey) return; + ev.preventDefault(); + let box = document.createElement("div") + box.setAttribute("class", "pjaxview"); + let p1 = document.createElement("p"), + bt = document.createElement("button"), + sl = document.createElement("button"), + sr = document.createElement("button"), + loading = document.createElement("span"), + info = document.createElement("p"); + info1 = document.createElement("span"); + info2 = document.createElement("span"); + iframe = document.createElement("iframe"); + var curpos = mynum; + var historyBase = history.length; + + function _setPjaxCurposInfo() { + let len = art_m_list.length; + let cur = art_m_list[curpos] + info1.textContent = (1+curpos)+" of "+len+" article #"+cur.id+ + (cur.author ? " by "+cur.author : "") + ":"; + info2.textContent = cur.text.trim(); + info2.setAttribute("class", "border textdigest"); + } + function _resetPjax() { + // All we can do surely is to back 1 page, + // because we cannot move to desirable entry of history list. + history.back(); + } + function setSwipeAct(iframe) { + // We cannot use DOMContentLoaded nor iframe.contentWindow here. + // PDF.js does not construct contentWindow...? + iframe.addEventListener("load", () => { + loading.classList.remove("loading"); + if (!hasTouchPad) return; + let ifm = iframe.contentDocument; + let startX, moveX, thresh = 100; + ifm.addEventListener("touchstart", (e) => { + e.preventDefault(); + startX = e.touches[0].pageX; + }, false); + ifm.addEventListener("touchmove", (e) => { + e.preventDefault(); + moveX = e.touches[0].pageX; + }, false); + ifm.addEventListener("touchend", (e) => { + if (startX < moveX && startX + thresh < moveX) { + switchTo(e, -1); + } else if (startX > moveX && startX - thresh > moveX) { + switchTo(e, +1); + } + }, false); + }, false); + + } + function switchTo(e, direction) { + e.preventDefault(); + let len = art_m_list.length, cur, newpos, url; + newpos = (curpos+len+direction)%len; + if (curpos == newpos) return; // No need to switch to same one + curpos = newpos; + cur = art_m_list[curpos]; + url = cur.url; + // We should remove iframe once to preserve history Object + // https://inthetechpit.com/2019/04/20/update-iframe-without-affecting-browser-history/ + let parent = iframe.parentNode; + // alert("D = "+direction); + iframe.remove(); + parent.appendChild(iframe); + try { + loading.classList.add("loading"); + iframe.src = url; + // iframe.contentDocument.location.replace(url); + // location.replace cannot be used because PDF viewer.js + // does not have iframe.contentDocument + } catch (err) { + alert("Cannot load "+src+" : "+err.name); + } + _setPjaxCurposInfo(); + setSwipeAct(iframe); + } + function switchToByKey(e) { + // alert("KEY="+e.key); + switch (e.key) { + case "ArrowLeft": + switchTo(e, -1); break; + case "ArrowRight": + switchTo(e, +1); break; + case "Escape": + history.back(); + } + } + //

+ // + //

info1 info2

+ // + //
+ // ==> [ << ][Dissmiss][ >> ] + // ==> ## of ## article #xxx by AUTHOR + sl.textContent = " << "; + sr.textContent = " >> "; + sl.addEventListener("click", (e) => {switchTo(e, -1);}); + sr.addEventListener("click", (e) => {switchTo(e, +1);}); + sl.setAttribute("title", "to="+(mynum-1)); + sr.setAttribute("title", "to="+(mynum+1)); + document.body.appendChild(box); + bt.textContent = "Click to dismiss / もどる"+mynum; + + box.appendChild(p1); + p1.appendChild(sl); p1.appendChild(bt); p1.appendChild(sr); + { // TEST: Normal mode + let only = document.createElement("button"), + h = location.href; + only.textContent = ".oO□"; + only.setAttribute("title", "Open in Normal Window"); + only.addEventListener("click", function() { + location.replace(iframe.src); + }); + p1.appendChild(only); + } + p1.appendChild(loading); + info.appendChild(info1); info.appendChild(info2); + loading.textContent=" Loading..."; + loading.classList.add("hidden"); + loading.classList.add("loading"); + box.appendChild(info); + iframe.src = url; + + box.addEventListener("keydown", switchToByKey); + //box.addEventListener("click", (e) => {_resetPjax();}); + bt.addEventListener("click", (e) => {_resetPjax();}); + // dp.addEventListener("click", (e) => {_resetPjax();}); + info.addEventListener("click", (e) => {_resetPjax();}); + box.appendChild(iframe); + + setSwipeAct(iframe); + + _setPjaxCurposInfo(); + bt.focus(); + setTimeout(() => {box.classList.add("pjaxview2");}, 10); + // Finally update history stack + pjaxHistoryPush(box); + } + function pjaxHistoryPush(box) { + if (history.pushState) { + let h = location.href.replace(/#.*/, '')+"#pjaxview"; + history.pushState({url: h}, null, h); + window.addEventListener("popstate", (e) => { + if (box) { + box.remove(); box = null; + } + }, false); + } + } + function reverseChecks() { + var names = collectElementsByAttr("input", "name", "usel"); + for (let u of names) { + u.checked = !u.checked; + } + } + function renumberOL(str, start) { + var stra = str.split("\n"); + for (var i=1; i1 && area.value.charCodeAt(pos)==10) + b = area.value.lastIndexOf("\n", pos-1);; + return b>=0 ? b : 0; + } + function isInBeginEnd(area, pos){ + pos = pos||area.selectionStart; + let bol = beginningOfLine(area, pos); + let thisline = area.value.substr(bol); + console.log("curchar="+area.value.charCodeAt(pos)); + console.log("prechar="+area.value.charCodeAt(pos-1)); + console.log("bol="+bol+", thisline="+thisline); + let match = thisline.search(/\\(begin|end){([A-Za-z]*)/), lm, be; + if (match >= 0) { + lm = RegExp.lastMatch; + be = RegExp.$1; + return RegExp.$2 + } + return null; + } + function helpMarkdownBrace(e) { + if (!mathjax) return; + var area = e.target, pos = area.selectionStart, text = area.value, + begin = "\\begin", end = "\\end"; + if (pos < end.length) return; + if (text.substr(pos-end.length).startsWith(end)) { + let beg = text.lastIndexOf(begin, pos); + if (beg >= 0) { + let env = text.substr(beg).search(/\\begin{(.*?)}/); + if (env >= 0) { + textInsert(area, "{"+RegExp.$1+"}", pos); + e.preventDefault(); + } + } + } + } + function helpMarkdownBraceClose(e) { + if (!mathjax) return; + let area = e.target, pos = area.selectionStart, text = area.value, + begin = "\\begin", end = "\\end"; + if (text.substr(pos).startsWith("}")) { + area.setRangeText("", pos, pos+1); + // e.preventDefault(); + } + let inbegend = isInBeginEnd(area, pos); + if (!inbegend) return; + let nextendpos = text.substr(pos).indexOf("\\end{"); + let nextcurend = text.substr(pos).indexOf("\\end{"+inbegend+"}"); + if (nextcurend<0 || nextendpos!=nextcurend) { + area.setRangeText("}\n\n\\end{"+inbegend+"}", pos, pos); + area.selectionStart = pos+2; + e.preventDefault(); + } + console.log(inbegend); + + } + function helpMarkdownPreview(area) { + if (!mathjax) { + alert("no"+e.target) + dispInfoMomentary("This board has no MathJax mode.\n"+ + "この掲示板は数式モードOFFです。", + e.target.parentNode); + return; + } + let text = area.value; + let preview = document.createElement("div"); + let bp = document.createElement("p"); + let btn = document.createElement("button"); + btn.innerText = "Click or ESC to Dissmiss / クリックかESCで戻る"; + bp.classList.add("c"); + preview.classList.add("pjaxview"); + preview.classList.add("pjaxview2"); + let pre = document.createElement("p"); + bp.appendChild(btn); + preview.appendChild(bp); + preview.appendChild(pre); + pre.innerText = text; + document.body.appendChild(preview); + function dismiss(t) { + history.back(); + preview.remove(); + area.focus(); + } + preview.addEventListener("click", dismiss, false); + preview.addEventListener("keydown", dismiss, false); + MathJax.typesetPromise([pre]); + pjaxHistoryPush(preview); + btn.focus(); + } + function helpMarkdownAt(e) { + var area = e.target, pos = area.selectionStart; + if (pos == 0) { + area.value = "@all" + area.value; + area.selectionStart = area.selectionEnd = 4; + dispInfoMomentary("@all で全員に通知します", area.parentNode); + e.preventDefault(); + } + } + function helpMarkdown(e) { + switch (e.key) { + case "Backspace": helpMarkdownBS(e); break; + case "Enter": helpMarkdownEnter(e); break; + case "(": helpMarkdownParen(e); break; + case "p": if (e.metaKey) helpMarkdownPreview(e.target); break; + case "{": helpMarkdownBrace(e); break; + case "}": helpMarkdownBraceClose(e); break; + case "@": helpMarkdownAt(e); break; + } + } + /* Init event listeners */ + function addFileInput() { + var inpfile = collectElementsByAttr("input", "name", "image"); + if (!inpfile) return; + var filled = true; + var i, ih; + for (i of inpfile) { + if (! i.value) filled=false; + } + if (filled) { + ih = i.parentNode.innerHTML; + let ipph = i.parentNode.parentNode.innerHTML; //Entire td inside + if (ipph) { + let ip = i.parentNode; + var inpf = ipph.substring(ipph.indexOf('"+inpf.substring(0, inpf.indexOf("/span>")+6); + ip.insertAdjacentHTML("afterend", newi) + ip.nextSibling.nextSibling.addEventListener('change', () => { + warnFileSize(document.forms[0]); + }); + } + } + } + function initFileInput() { // Multiplies "input type=file" + var el, morefile = document.getElementById("morefile"); + if (morefile) { + for (el of collectElementsByAttr("input", "name", "image")) { + el.addEventListener("change", function(ev) { + if (ev.target.value > "" && ev.target.files.length == 1) + morefile.style.visibility = "visible"; + // No need to hide again, sure? + }); + } + morefile.addEventListener("click", addFileInput, null); + } + // When renaming, select basename part + for (el of collectElementsByAttr("input", "class", "mv")) { + el.addEventListener("focus", function(ev) { + var i = ev.target; + if (i) { + i.setSelectionRange(0, i.value.lastIndexOf(".")); + } + }); + } + } + function initTextarea() { + var te = collectElementsByAttr("textarea", "name", "text"); + if (!te || !te[0]) return; + te[0].addEventListener("keydown", helpMarkdown, false); + } + function atMarkView(elem) { + // Enclose "@all" with span + for (i of elem.querySelectorAll("td.repl")) { + if (i.textContent.startsWith("@all")) { + i.firstChild.nodeValue = i.firstChild.nodeValue.substring(4); + i.insertAdjacentHTML( + 'afterbegin', '
@all
' + ); + i.classList.add("atall"); + } + } + return elem; + } + var authVisible = false; + function toggleAuthorVisibility(e) { + // Click to hideauth button toggles visibility of author columns + e.stopPropagation(); + let b = document.getElementById("hideauth"); + if (authVisible) { + for (let i of document.querySelectorAll("td.repatt")) { + i.classList.remove("hideauthor"); + } + authVisible = false; + } else { + for (let i of document.querySelectorAll("td.repatt")) { + i.classList.add("hideauthor"); + } + authVisible = true; + } + b.textContent = b.textContent.replace(/OFF|ON/, authVisible ? "ON" : "OFF"); + } + function downloadFile(filename, content, BOM) { + let bom = new Uint8Array([0xEF, 0xBB, 0xBF]); + let str = new Blob(BOM ? [bom, content] : [content], + {type: "text/csv"}); + var uri = URL.createObjectURL(str); + let a = document.createElement("a"); + a.download = (BOM ? "BOM-" : "")+filename; + a.href = uri; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + } + function getTextContentCSV_1(e) { + let blogtbl = document.querySelector("table.blog_replies"); + let needBOM = e.ctrlKey; + if (!blogtbl) return; + let trw = blogtbl.querySelector("tr.warn"), a; + if (trw && (a=trw.querySelector("th>a"))) { + if (a.title == "Show All") { + if (window.confirm(`50件以下に表示制限されています。 +取得し直しますか? +Cancelを押すとこのまま取得します。 +Seen articles limited to 50 items. +Push OK to get all articles, Cancel to get only seen articles.`)) { + a.click(); + return; + } + } + } + if (navigator.userAgent.match(/Windows/)) { + if (!e.ctrlKey && !e.shiftKey && !window.confirm(`Excelで読ませるCSVの場合はBOMが必要です。 +その場合は一度キャンセルして Ctrl キーを押しながらボタンクリックして下さい。 +逆にExcel以外(GoogleスプレッドシートやLibreOfficeや他のツール)で読む場合はBOMをつけるとファイルの1行目の先頭にゴミのようなものが見える場合あるのでそのときは除去する必要があります。 +今後もBOM不要の場合はShiftキーを押しながらクリックして下さい。 +If you feed this CSV into Microsoft Excel, consider adding BOM sequence that can be prepended by pressing Control key with click. +In this case, click CSVget with ctrl key after Cancel this dialog. +If you never need BOM, press Shift key with click.`)) + return; + } + outcsv = [] + for (let row of blogtbl.querySelectorAll("tr[id]")) { + let tds = row.querySelectorAll("td"), + a = tds[0].querySelector("a.author"), + author = a.title, + name = a.innerText, + time = tds[0].querySelector("span").title, + id = tds[1].id, + body = tds[1].textContent; + //console.log(`${author},${name},${time},#${id},${body}`); + outcsv.push({ + "author": author, "name": name, "time": time, + "id": "#"+id, "body": body}); + } + let line = new CSV(outcsv, {header:true}).encode(), + fn = myurl.replace(/.*\?/, "").replaceAll("+", "-") + .replace(/#.*/, "").replace("-n:all", ""); + downloadFile(fn+".csv", line, needBOM); + } + function getTextContentCSV(e) { + if (!document.getElementById("csvminjs")) { + let csvmin = document.createElement("script"); + csvmin.src="https://www.yatex.org/libcache/csv.min.js"; + csvmin.id = "csvminjs"; + // https://stackoverflow.com/questions/14521108/dynamically-load-js-inside-js + csvmin.addEventListener("load", ()=>{ + getTextContentCSV_1(e)}, 10); + document.querySelector("head").appendChild(csvmin); + } else { + getTextContentCSV_1(e); + } + } + function initBlogs() { + // Auto-complete #xxxx + let i, check = collectElementsByAttr("input", "name", "notifyto"); + if (check) + for (i of check) { + i.addEventListener("click", insertRedirect, false); + } + registInsertDirect(document.querySelectorAll("a[href]")); + if (myurl.match(/replyblog\+[0-9]/) + && document.querySelector("td.repl")) { + // There's no need to provide ajax posting when + // no replies written to the blog. Therefore we + // assign ajax post when td.repl exists. + for (i of document.querySelectorAll('input#c[value="送信"]')) { + let b = document.createElement("button"); + b.textContent = "送信!"; + console.log("b="+b+", tc="+b.textContent); + b.addEventListener("click", ajaxPost, false); + // i.insertAdjacentElement('afterend', b); + b.setAttribute("class", i.getAttribute("class")) + b.setAttribute("title", i.getAttribute("title")) + i.parentNode.replaceChild(b, i); + b.id = i.id; + // i.remove(); + i.classList.add("aux"); + i.value = "送信(予備)" + b.parentNode.appendChild(i); + } + i = document.getElementById("reload"); + if (i) i.addEventListener("click", ajaxPost, false); + // Add CSV download button + let td = document.querySelector("table.bloghead tr td"); + if (td) { + let btn = document.createElement("button"); + btn.innerText = "CSVget"; + btn.type = "button"; + btn.accessKey = "g"; + btn.title = `Shortcut: G +見えている書き込みをCSVで取得します +全件表示されていることを確認してから利用して下さい。 +Excelで利用する場合は Ctrl を押しながらクリックして下さい。 +Get seen TEXT content as CSV.`; + btn.addEventListener("click", getTextContentCSV, false); + let artlink = td.querySelector('a[accesskey="f"]'); + let spacer = document.createElement("span"); + if (artlink) { + spacer.innerText = "|"; + artlink.insertAdjacentElement('beforebegin', btn); + artlink.insertAdjacentElement('beforebegin', spacer); + } else { + spacer.innerText = " "; + td.appendChild(spacer); + td.appendChild(btn); + } + } + } + for (i of document.querySelectorAll('input[type="file"]')) { + i.addEventListener('change', (e) => { + warnFileSize(document.forms[0]); + }, false) + } + if (i=document.getElementById("hideauth")) { + i.addEventListener('click', toggleAuthorVisibility, false); + } + // Hack article_m links + registPjaxViewers(document.querySelectorAll("a[href]")); + atMarkView(document); + } + function initGrpAction() { + var rev = document.getElementById("reverse"); + if (!rev) return; // Is not grpAction page + if (rev.tagName.match(/span/i)) { + rev.textContent = " 反転 "; + rev.addEventListener("click", reverseChecks, null); + } + var emailbtn = document.getElementById("email"); + emailbtn.addEventListener("click", function(ev){ + // Enlarge box and Select user's checkbox + if (!ev.target.checked) return; + var x = collectElementsByAttr("div", "class", "foldtabs"); + if (x && x[0] && x[0].style) { + x[0].style.height = "10em"; + } + let myuid = document.getElementById("myuid"); + if (myuid) { + let usel = collectElementsByAttr("input", "name", "usel"); + if (usel) { + for (u of usel) { + if (u.value == myuid.value) + u.checked = true; + } + } + } + }, null); + var teamsel = document.getElementById("selteam"); + if (teamsel) { + var usel, p, team; + // Select all members of the team + teamsel.addEventListener("change", function(ev) { + var teamname = teamsel.value, + selected = new RegExp('(^| )'+teamname+"($|,)"); + usel = collectElementsByAttr("input", "name", "usel"); + if (!usel) return; + for (u of usel) { + p = u.parentNode; // should be label + if (!p) continue; + if (teamname == "TEAM") { // Reset all checks + u.checked = false; // when "TEAM" is selected + } else { + p = p.parentNode.parentNode;// should be tr + team = nthChildOf(p, 5, "td") + if (team && team.textContent + && team.textContent.match(selected)) { + u.checked = true; + } + } + } + }, null); + } + } + function dispInfoMomentary(msg, elem) { + // Momentarily display MSG in tooltip-baloon relative to ELEM element. + let help = document.createElement("p"); + elem.style.position = 'relative'; + elem.style.overflow = 'visible'; + help.setAttribute("class", "info-tooltip"); + help.innerHTML = msg; + elem.appendChild(help); + setTimeout(() => { + help.classList.add("dissolving"); + setTimeout(() => help.remove(), 3000); + }, 1000); + } + function initGrphome() { + console.log("initGrphome"); + // (1)Setup Frozen State Changing Button + var ja = navigator.language.match(/ja/i); + + function toggleFrozen(e, rowid) { + let tgt = mypath+"?blog_setfrozen+"+rowid; + let td = e.target.parentNode; + let tr = td.parentNode; + fetch(tgt, { + method: "POST", + headers: {'Content-Type': 'text/html; charset=utf-8'}, + credentials: "include" + }).then(function(resp) { + return resp.text(); + }).then(function(tbody) { + try { + var json = JSON.parse(tbody); + } catch (e) { + return; + } + let state = json.state, newstate, info; + if (json.alert) { + alert(json.alert) + } + if (state.match(/frozen/i)) { + newstate = "凍結"; + info = ja ? newstate+"に設定しました" : 'Set Frozen'; + } else { + newstate = null; + info = ja ? '稼動に設定しました' : 'Set Running'; + } + tr.setAttribute("class", newstate); + dispInfoMomentary(info, td); + }); + } + let btn = document.querySelectorAll("button.toggle-frozen"); + for (let b of btn) { + let rowid = null; + let td=b.parentNode, tr = td.parentNode, fr, ru; + ru = ja ? "動" : "Running"; + fr = ja ? "凍" : "Frozen"; + b.setAttribute('frozen-marker', fr); + b.setAttribute('running-marker', ru); + for (let a of tr.querySelectorAll("a[href]")) { + if (a.getAttribute("href").match(/\?replyblog\+([0-9]+)/)) { + rowid = parseInt(RegExp.$1); + break; + } + } + if (rowid && rowid>0) { + b.addEventListener("click", function(e) { + if (!btn) return; + toggleFrozen(e, rowid); + }, false); + b.setAttribute("title", "稼動/凍結をその場で切り替えます\n\ +Toggle Running/Frozen ("+rowid+")"); + } + } + // (2)Setup Column Collapse Button + // INCOMPLETE: Cannot restore original state, but it's enough... + function toggleColmnWidth(th) { + let tbl = document.querySelector("table.dumpblogs"); + let colname = th.textContent, newwidth; + if (th.style.width) { + newwidth = null + // https://developer.mozilla.org/ja/docs/Web/CSS/table-layout + tbl.style.tableLayout = 'auto'; + tbl.style.width = null; + } else { + newwidth = "2em"; + tbl.style.tableLayout = 'fixed'; + tbl.style.width = '100%'; + } + th.style.width = newwidth; + th.style.overflow = "hidden"; + for (let td of document.querySelectorAll("td."+colname)) { + console.log(td.tagName); + td.style.width = newwidth; + console.log(td.style.width); + } + } + let row1 = document.querySelector("table.dumpblogs tr:first-child"); + if (row1) { + let heads = row1.querySelectorAll("th"); + for (let h of heads) { + h.addEventListener("click", function(e) { + toggleColmnWidth(h); + }, false); + h.setAttribute("title", "Click to shrink these columns"); + } + } + } + function initMath() { + mathjax = window.MathJax||document.getElementById("mathjax"); + if (!mathjax) return; + let ta = document.querySelector("textarea"); + if (!ta) return; + let btn = document.createElement("button"); + btn.setAttribute("title", "\\( と \\) で数式利用\n"+ + "\\[ と \\] で段組み数式モード\n"+ + "便利なマクロ:\n"+ + " \\boxed{aaa}, \\fcolorbox{framecolor}{bgcolor}{text}\n"+ + " \\underline{aaa}, \\fcolorbox{framecolor}{bgcolor}{text}\n"+ + "独自定義マクロ:\n"+ + " \\warn{xxx} 注意喚起用色付き枠\n"+ + " \\Warn{xxx} 大きな文字で注意喚起") + btn.innerHTML = "MathJax
Preview"; + btn.addEventListener('click', (e) => { + e.preventDefault(); + ta.focus(); + helpMarkdownPreview(ta); + }); + ta.parentNode.appendChild(btn); + } + function rewriteReplyHover(unit) { + function getTextById(id) { + let repltd = document.getElementById(id); + if (repltd) { + let txt = repltd.innerText, + authtd = repltd.parentNode.getElementsByTagName("td")[0], + author = authtd.querySelector("a.author").innerText, + digest = txt.split("\n").splice(0, hoverTextLines).join("\n"); + return escapeChars("[[ "+author+" ]]\n"+digest); + } else + return ""; + } + unit = unit||document; + for (let td of unit.querySelectorAll("td.repl")) { + let firstC = td.firstChild; + // Direct replacing innerHTML breaks embedded DOM event handlers. + // So, we split td.repl into elements and replace the first + // textNode(nodeType==3) with hover-text embeded content. + if (firstC.nodeType==3 && firstC.nodeValue.startsWith(">#")) { + let newline = firstC.nodeValue.indexOf("\n"); + let firstline; + if (newline > 0) { + firstline = firstC.nodeValue.substring(0, 1+newline); + firstC.nodeValue = firstC.nodeValue.substring(1+newline); + } else { + // Cannot be reached here, but leave this for robustness + firstline = firstC.nodeValue; + firstC.nodeValue = ""; + } + td.insertAdjacentHTML( + 'afterbegin', + escapeChars(firstline).replace( + /#([0-9]+)/g, + (match, start, whole) => { + let id = RegExp.$1 + return '' + match + ''; + })); + } + } + } + function initReplyHover(unit) { + // https://stackoverflow.com/questions/60154233/event-when-typesetting-is-done-mathjax-3 + if (mathjax && MathJax.startup) + MathJax.startup.promise.then(()=>rewriteReplyHover()); + else + rewriteReplyHover(); + } + var getHandoutCSV; + function initGetHandoutCSV() { + getHandoutCSV = document.getElementById("gethandoutcsv"); + if (!getHandoutCSV) return; + document.getElementById("bommsg").innerText = + `Excelで開く場合は上記CSVリンクをCtrlを押しながら。 +You need to click CSV link above with Ctrl-key when you handle CSV with Excel`; + getHandoutCSV.addEventListener("click", (e) => { + e.preventDefault(); // Stop visiting link + let bom = e.ctrlKey; + let csv = document.getElementById("totalcsv"); + if (!csv || !csv.textContent) return; + let fn = "report-count", plus=myurl.lastIndexOf("+"); + if (plus) fn += ("-"+myurl.substring(1+plus)); + fn = fn.replace(/#.*/, ""); + downloadFile(fn+".csv", csv.textContent, bom); + }); + } + function init() { + isOlderJS = !("insertAdjacentElement" in document.body); + initGrpAction(); + initBlogs(); + initFileInput(); + initTextarea(); + initGrphome(); + initMath(); + initReplyHover(); + initGetHandoutCSV(); + } + document.addEventListener('DOMContentLoaded', init, null); +})();