SSブログ

フォーム内容をサブウィンドウに表示する


文字数:





<style type="text/css">
<!--
body { background-color: #C0C0C0;}
a { text-decoration: none;}
textarea {font-size:16px;padding:10px;line-height:1.2em;width:500px;height:300px;}
form {margin:42px;}
-->
</style>
<script type="text/javascript">
<!--
function outData0()
{
    fOBJ  = document.myFORM;
    myTEXT = fOBJ.mess.value;
    myTEXT0 = myTEXT.replace(/\r\n|\n|\r/g,"<br />"+"\r\n");
    subWin = window.open("about:blank","form_data");
    subWin.document.open();
    subWin.document.write(myTEXT0);
    subWin.document.close();
}
function outData()
{
    fOBJ  = document.myFORM;
    myTEXT = fOBJ.mess.value;
    subWin = window.open("about:blank","form_data");
    subWin.document.open();
    subWin.document.write(myTEXT);
    subWin.document.close();
}

function ShowLength0(str) {
  str0=str.split(/(http:\/\/\S+)/);
  urlcount=(str0.length-1)/2;
  len0 = 0;
  for (i=0;i<str0.length;i++) {
    if (str0[i].match(/(http:\/\/\S+)/)) {
      len0=len0+str0[i].length;
    }
  }

  len = 0;
  str = escape(str);
  for (i=0;i<str.length;i++,len++) {
    if (str.charAt(i) == "%") {
      if (str.charAt(++i) == "u") {
        i += 3;
        len++;
      }
      i++;
    }
  }
  len=len-len0+urlcount*23;
  document.getElementById("inputlength").innerHTML = len;
}

function ShowLength(str) {
  str0=str.split(/(https?:\/\/\S+)/);
  urlcount=(str0.length-1)/2;
  len0 = 0;
  for (i=0;i<str0.length;i++) {
    if (str0[i].match(/(https?:\/\/\S+)/)) {
      len0=len0+str0[i].length;
    }
  }

var cntInput = str.length;
var list = str.match(/[\u0000-\u10ff\u2010-\u201f\u2032-\u2037]/g);
var cnt1byte = 0;
if (list != null) {cnt1byte = list.length;}
  len = cntInput*2 - cnt1byte;

  len=len-len0+urlcount*23;
  document.getElementById("inputlength").innerHTML = len/2+"("+len+")";
}

function tweet()
{
    fOBJ  = document.myFORM;
    myTEXT = fOBJ.mess.value;
    if (fOBJ.twitter.checked){
        window.open('https://twitter.com/intent/tweet?text='+encodeURIComponent(myTEXT));
    }
    if (fOBJ.Pawoo.checked){
        window.open('https://pawoo.net/share?text='+encodeURIComponent(myTEXT));
    }
    if (fOBJ.mstdn.checked){
        window.open('https://mstdn.jp/share?text='+encodeURIComponent(myTEXT));
    }
    if (fOBJ.fedibird.checked){
        window.open('https://fedibird.com/share?text='+encodeURIComponent(myTEXT));
    }
    if (fOBJ.mjn.checked){
        window.open('https://mastodon-japan.net/share?text='+encodeURIComponent(myTEXT));
    }
}

 -->
</script>

<form id="myFORM" name="myFORM">
<textarea rows="25" cols="64" wrap="soft" id="mess" name="mess" onkeyup="ShowLength(value);"></textarea><br />
<input type="button" value="表示" onClick="outData();">
<input type="button" value="表示(改行追加)" onClick="outData0();">
<input type="button" value="投稿" onClick="tweet();">
<span>文字数:</span><span id="inputlength"></span><br>
<input type="checkbox" id="twitter" name="twitter" checked><label for="twitter">Twitter</label><br>
<input type="checkbox" id="Pawoo" name="Pawoo"><label for="Pawoo">Pawoo</label><br>
<input type="checkbox" id="mstdn" name="mstdn"><label for="mstdn">mstdn.jp</label><br>
<input type="checkbox" id="fedibird" name="fedibird"><label for="fedibird">fedibird.com</label><br>
<input type="checkbox" id="mjn" name="mjn"><label for="mjn">mastodon-japan.net</label><br>
</form>
<script type="text/javascript">
<!--
document.getElementById("mess").value = decodeURIComponent(location.search.substring(1));
// document.myFORM.mess.focus();
document.myFORM.mess.setSelectionRange(0,0);
ShowLength(document.myFORM.mess.value);
 -->
</script>

マルチ投稿用ブックマークレット
マルチ投稿



共通テーマ:パソコン・インターネット

この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。