# HG changeset patch # User HIROSE Yuuji # Date 1609568103 -32400 # Node ID 411ce55c0dae74313dd3f2793103c85e806e9ea6 # Parent 3d437261edca67cbc4a88501c0bb93346ccb3b02 AJAX posting and PJAX file-viewer initially introduced. diff -r 3d437261edca -r 411ce55c0dae examples/common/default/default.css --- a/examples/common/default/default.css Thu Dec 31 10:31:13 2020 +0900 +++ b/examples/common/default/default.css Sat Jan 02 15:15:03 2021 +0900 @@ -4,6 +4,9 @@ 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; } @@ -35,7 +38,9 @@ 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) {background: white;} +table.td3evw th:nth-child(2n+4), span.textdigest { + background: white; +} table.thl th {text-align: left;} span#reverse {background: white; padding: 0 0 0 0.4ex; border: outset;} @@ -165,6 +170,24 @@ 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;} +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: 95vw; 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;} @@ -393,9 +416,13 @@ border-radius: 1em; border: double 5px blue; min-width: 10em; right: 0; bottom: 0; } -.dissolving { - opacity: 0; transition: 3.0s; +.dissolving {opacity: 0; transition: 3.0s;} +.emerging {opacity: 1; transition: 3s;} +span.loading, input#c:disabled { + visibility: visible; transform: rotateX(3600deg); transition: 30s; + display: inline-block; } +span.loading {padding: 0 1em;} /* * PR Web diff -r 3d437261edca -r 411ce55c0dae s4-blog.sh --- a/s4-blog.sh Thu Dec 31 10:31:13 2020 +0900 +++ b/s4-blog.sh Sat Jan 02 15:15:03 2021 +0900 @@ -178,6 +178,7 @@ fi fi fi + err "blog_showentry Entered: `gdate +%S.%03N` blogrowid=$rowid" blog_notify=`getvalbyid blog notify "$rowid"` blog_team=`blog_getteam "$rowid"` blog_mode=`getvalbyid blog mode "$rowid"` @@ -201,6 +202,12 @@ THEN '' ELSE 'Unreadable' END" + elif [ x"$blog_mode" = x"report-closed" ]; then + F_UNREADABLE="CASE + WHEN author = '$user' + THEN '' + ELSE 'Unreadable' + END" else F_UNREADABLE="'Unreadable'" fi @@ -226,6 +233,21 @@ #err id=$id #err "select val from $ts where key='title' and id='$id';" + ## Parse control sequence + nlimit=$listartlimit + case "$control" in + n:[Aa][Ll][Ll]) + unset nlimit ;; + n:*) + nlimit=${control##*:} + nlimit=${nlimit%%[!A-Z0-9a-z_]*} + ;; + f:[Aa][Ll][Ll]) ;; + f:2???-??-??*) # f:2020-12-27T08:02:43 + fetch=${control#f:} + fetch_ajax=`echo "'$fetch'"|tr T ' '` + esac + err control=$control fetch_ajax=$fetch_ajax #(1)Display root article cat< @@ -271,18 +293,21 @@ EOF if test -s $midfile && IFS='|' read edit ctime hexhead blogtype < $midfile then - cat<<-EOF + if [ -z "$fetch_ajax" ]; then # UUUUU + + cat<<-EOF ${edit:+$href }$ctime $blogtype $href2${edit:+$href3} $href4 $href5 `echo "$hexhead"|unhexize|htmlescape|hreflink|minitbl` EOF - case "$blogtype" in - "クイズ"|"XXXX集計") - echo "${blogtype}モードは本人と管理者の書き込みのみが表示されます。" - ;; - esac | html p 'class="warn"' + case "$blogtype" in + "クイズ"|"XXXX集計") + echo "${blogtype}モードは本人と管理者の書き込みのみが表示されます。" + ;; + esac | html p 'class="warn"' + fi # UUUUU if [ x"$blogtype" = x"クイズ" -o x"$blogtype" = x"XXXX集計" ]; then if $isgroup; then # Failsafe to query timeout @@ -307,16 +332,7 @@ echo "時間をおいて繋いでください(Please visit later)." | html p return fi - ## Parse control sequence - nlimit=$listartlimit - case "$control" in - n:[Aa][Ll][Ll]) - unset nlimit ;; - n:*) - nlimit=${control##*:} - nlimit=${nlimit%%[!A-Z0-9a-z_]*} - ;; - esac + lkhome=" $fetch_ajax}; EOF if [ $? -ne 0 -a ! -s $midfile ]; then echo "時間をおいてください(Visit later please)." | html p @@ -426,6 +443,7 @@ else CAT=cat fi + err "blog_showentry Started: `gdate +%S.%03N` ${fetch_ajax:+ajax}" # Start blog_replies table $CAT $midfile | while IFS='|' read id edit notify uid author uname icon aid \ @@ -487,6 +505,7 @@ usecache='' tsfile=$td/$id.stamp for i in $imgids; do mrid=${i%%:*}; i=${i#*:}; sz=`size_h ${i%%:*}` + _href="href=\"$catlink+$mrid\"" fn=`echo "${i#*:}"|unhexize` fnb=$fn"(${sz})" case "$fn" in @@ -508,7 +527,7 @@ };}; then usecache=1 # Set usecache flag on cat<<-EOF - + <__UNCLICKABLE__> $fnb EOF # !!NOTE!! Create row stamp ONLY WHEN imgcache is active @@ -522,18 +541,18 @@ cat "$outfile" \ | hexize \ | sed -e 's/\(..\)/%\1/g' \ - -e "s|^|$fnb|" unset stampfile # img data stream is not suitable to cache echo $tm > $tsfile else # Failed to convert rm -f $outfile - echo "$fnb" + echo "<__UNCLICKABLE__>$fnb" fi fi ;; *) - echo "<__UNREADABLE__>$fnb" + echo "<__UNCLICKABLE__>$fnb" ;; esac done @@ -548,10 +567,18 @@ fi test -n "$stampfile" && date "+%F %T" > $stampfile fi + if [ -n "$fa" ]; then + replhref="s/a href=[^>]*>/a>/" + else + replhref="" + fi # Printing a cached row sed -e "/^/s,,${notify:+$nt}," \ + ${replhref:+-e "/^<__UNCLICKABLE__>/$replhref"} \ + ${replhref:+-e "/^<__UNREADABLE__>/$replhref"} \ + -e "/<__UNCLICKABLE__>/s///" \ -e "/<__UNREADABLE__>/s,,${fa:+$cannotread}," \ $cachefile done @@ -589,10 +616,12 @@ `cgi_file image "" "$file_accept title=\"$filehelp\" multiple"` - + + + EOF - ) + ) cat<<-EOF

+ // + //

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); + 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; + + document.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 + 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) { @@ -75,7 +405,6 @@ } function renumberOL(str, start) { var stra = str.split("\n"); - for (var i=1; i")+1); i.insertAdjacentHTML("afterend", newi) - // alert(newi); + i.nextSibling.nextSibling.addEventListener('change', () => { + // next==br next.next==input[type=file] + warnFileSize(document.forms[0]); + }); } } } @@ -248,12 +580,28 @@ var check = collectElementsByAttr("input", "name", "notifyto"); if (check) for (let i of check) { - i.addEventListener("click", insertRedirect, null); + i.addEventListener("click", insertRedirect, false); } - for (let i of document.getElementsByTagName("a")) + for (let i of document.querySelectorAll("a[href]")) if (i.getAttribute("href").match(/^#[0-9]+$/)) if (RegExp.lastMatch == i.innerHTML) - i.addEventListener("click", insertRedirect, null) + i.addEventListener("click", insertRedirect, false) + for (let i of document.querySelectorAll('input[value="送信"]')) { + // let b = document.createElement("button"); + let b = i; + b.value = "送信!"; + console.log("b="+b+", tc="+b.textContent); + b.addEventListener("click", ajaxPost, false); + // i.insertAdjacentElement('afterend', b); + } + for (let f of document.querySelectorAll('input[type="file"]')) { + let form = document.forms[0]; + f.addEventListener('change', (e) => { + warnFileSize(form); + }, false) + } + // Hack article_m links + registPjaxViewers(document.querySelectorAll("a[href]")); } function initGrpAction() { var rev = document.getElementById("reverse"); @@ -323,13 +671,6 @@ function initGrphome() { console.log("initGrphome"); // (1)Setup Frozen State Changing Button - let url = document.URL, - mypath = url.substring(url.lastIndexOf("/")); - if (mypath.match(/(.*)\/(.*)/)) { - mypath = RegExp.$2; - mypath = mypath.substring(0, mypath.lastIndexOf("?")); - //alert("mypath="+mypath); - } else return; var ja = navigator.language.match(/ja/i); function toggleFrozen(e, rowid) { @@ -339,6 +680,7 @@ fetch(tgt, { method: "POST", headers: {'Content-Type': 'text/html; charset=utf-8'}, + credentials: "include" }).then(function(resp) { return resp.text(); }).then(function(tbody) { @@ -420,6 +762,7 @@ } } function init() { + isOlderJS = !("insertAdjacentElement" in document.body); initGrpAction(); initBlogs(); initFileInput(); diff -r 3d437261edca -r 411ce55c0dae scripts/s4-sns.case --- a/scripts/s4-sns.case Thu Dec 31 10:31:13 2020 +0900 +++ b/scripts/s4-sns.case Sat Jan 02 15:15:03 2021 +0900 @@ -46,7 +46,7 @@ echo "Refresh: 0; $newurl"; echo exit 0 ;; - lshandout|lshandoutall|gethandout|gethandoutcsv|gethandoutcsv2|blogseen|getteamcsv|blog_setfrozen) + lshandout|lshandoutall|gethandout|gethandoutcsv|gethandoutcsv2|blogseen|getteamcsv|blog_setfrozen|blog_fetch) case "$stage" in lshandout*|blogseen*) contenttype; echo ;; esac