<html>
<head>
<title>Linked Sentence Creator - RJM Programming - March, 2024</title>
<style>
a {
text-decoration: none;
cursor: pointer;
}

.red {
background-color: rgba(255,0,0,0.3);
}

.yellow {
background-color: rgba(255,255,0,0.3);
}

.green {
background-color: rgba(0,255,0,0.3);
}
</style>
<script type='text/javascript'>

var curlspan=0, currspan=0;

function lfidea(proposedihw) { // thanks to https://stackoverflow.com/questions/14217101/what-character-represents-a-new-line-in-a-text-area
var wasline='', isline='', brdelim='';
//alert(proposedihw);
if (proposedihw.indexOf(String.fromCharCode(10) + String.fromCharCode(13)) != -1) {
//alert('Here');
while (proposedihw.indexOf(String.fromCharCode(10) + String.fromCharCode(13)) != -1) {
proposedihw=proposedihw.replace(String.fromCharCode(10) + String.fromCharCode(13), '<br>');
}
}
if (proposedihw.indexOf(String.fromCharCode(13) + String.fromCharCode(10)) != -1) {
//alert('Here2');
while (proposedihw.indexOf(String.fromCharCode(13) + String.fromCharCode(10)) != -1) {
proposedihw=proposedihw.replace(String.fromCharCode(13) + String.fromCharCode(10), '<br>');
}
}
if (proposedihw.indexOf(String.fromCharCode(13)) != -1) {
//alert('Here3');
while (proposedihw.indexOf(String.fromCharCode(13)) != -1) {
proposedihw=proposedihw.replace(String.fromCharCode(13), '<br>');
}
}
if (proposedihw.indexOf(String.fromCharCode(10)) != -1) {
//alert('Here4');
while (proposedihw.indexOf(String.fromCharCode(10)) != -1) {
proposedihw=proposedihw.replace(String.fromCharCode(10), '<br>');
}
}
var multilines=proposedihw.split('<br>');
for (var im=0; im<multilines.length; im++) {
if (multilines[im].indexOf(' ') == 0) {
wasline=brdelim + multilines[im];
isline=brdelim + multilines[im];
while (multilines[im].indexOf(' ') == 0) {
multilines[im]=multilines[im].replace(' ','&nbsp;');
isline=isline.replace(' ','&nbsp;');
}
proposedihw=proposedihw.replace(wasline, isline);
}
brdelim='<br>';
}
return proposedihw; //.replace(/\~\~/g, '<br>');
}

function nuance(proposedlinkw) {
if (proposedlinkw.indexOf('//') == 0) { return document.URL.split(':')[0] + ':' + proposedlinkw; }
return proposedlinkw;
}

function fleshout(proposedl) {
var wasv=document.getElementById(proposedl).value;
if (document.getElementById(proposedl).value.trim() != '') {
if (document.getElementById(proposedl).value.substring(0,1) != '#') {
if (document.getElementById(proposedl).value.toLowerCase().indexOf('http:') != -1 || document.getElementById(proposedl).value.toLowerCase().indexOf('https:') != -1) {
return proposedl;
} else if (document.getElementById(proposedl).value.toLowerCase().indexOf('www.') == 0) {
document.getElementById(proposedl).value='//' + wasv;
return proposedl;
} else if (document.getElementById(proposedl).value.indexOf('//') == 0) {
return proposedl;
} else if (document.getElementById(proposedl).value.indexOf('/') == 0) {
document.getElementById(proposedl).value=document.URL.split('//')[0] + '//' + document.URL.split('//')[1].split('/')[0] + wasv;
return proposedl;
} else if (document.getElementById(proposedl).value.indexOf('..') == 0) {
document.getElementById(proposedl).value=document.URL.split('linked_sentence_creator.htm')[0] + '' + wasv;
return proposedl;
} else if (document.getElementById(proposedl).value.indexOf('./') == 0) {
document.getElementById(proposedl).value=document.URL.split('linked_sentence_creator.htm')[0] + '/' + wasv.substring(2);
return proposedl;
} else if (document.getElementById(proposedl).value.indexOf('.') == 0) {
document.getElementById(proposedl).value=document.URL.split('linked_sentence_creator.htm')[0] + '/' + wasv.substring(1);
return proposedl;
} else {
document.getElementById(proposedl).value='//' + wasv;
return proposedl;
}
}
}
return proposedl;
}

function modifydothis(forwhat) {
if (document.getElementById('ilmodify').value == '' && document.getElementById('iwmodify').value == '') {
return '';
}
if (document.getElementById(fleshout('ilmodify')).value != '') {
document.getElementById(forwhat.id).innerHTML=lfidea(document.getElementById('iwmodify').value);
document.getElementById(forwhat.id).href=document.getElementById('ilmodify').value;
} else {
document.getElementById(forwhat.id).innerHTML=lfidea(document.getElementById('iwmodify').value);
document.getElementById(forwhat.id).href='#';
}
if (document.getElementById(forwhat.id).href.substring(0,1) == '#') {
document.getElementById(forwhat.id).target='_self';
document.getElementById(forwhat.id).title='';
} else {
document.getElementById(forwhat.id).target='_blank';
document.getElementById(forwhat.id).title='Linking to ' + nuance(document.getElementById('ilmodify').value);
}
document.getElementById('ilmodify').value='';
document.getElementById('iwmodify').value='';
document.getElementById('ibmodify').disabled=true;
document.getElementById('instruction').innerHTML='';
return '';
}

function enabling(forwhat) {
if (forwhat.value != '') {
document.getElementById(('' + forwhat.id).replace('iw', 'ib')).disabled=false;
if (forwhat.id.indexOf('append') != -1) {
document.getElementById('ilmodify').value='';
document.getElementById('iwmodify').value='';
document.getElementById('ibmodify').disabled=true;
document.getElementById('ilprepend').value='';
document.getElementById('iwprepend').value='';
document.getElementById('ibprepend').disabled=true;
} else if (forwhat.id.indexOf('prepend') != -1) {
document.getElementById('ilmodify').value='';
document.getElementById('iwmodify').value='';
document.getElementById('ibmodify').disabled=true;
document.getElementById('ilappend').value='';
document.getElementById('iwappend').value='';
document.getElementById('ibappend').disabled=true;
} else if (forwhat.id.indexOf('modify') != -1) {
document.getElementById('ilprepend').value='';
document.getElementById('iwprepend').value='';
document.getElementById('ibprepend').disabled=true;
document.getElementById('ilappend').value='';
document.getElementById('iwappend').value='';
document.getElementById('ibappend').disabled=true;
}
} else {
document.getElementById(('' + forwhat.id).replace('iw', 'ib')).disabled=true;
}
}

function doit(forwhat) {
var curis=document.getElementById('a' + curlspan).innerHTML;
var ao=null;
var tb=' target=_blank ';
if (document.getElementById(('' + forwhat.id).replace('ib', 'iw')).value != '') {
if (('' + forwhat.id).indexOf('modify') != -1) {
var ahuhs=document.getElementsByTagName('a');
for (var ihuhs=0; ihuhs<ahuhs.length; ihuhs++) {
//alert('*' + document.getElementById(('' + forwhat.id).replace('ib', 'iw')).value + '*vs*' + ahuhs[ihuhs].innerHTML + '*');
if (document.getElementById(('' + forwhat.id).replace('ib', 'iw')).value == ahuhs[ihuhs].innerHTML) {
ao=ahuhs[ihuhs];
}
}
if (ao) {
modifydothis(ao);
} else {
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('instruction').innerHTML='Shape to spread sentence part to modify.';
} else {
document.getElementById('instruction').innerHTML='Right click sentence part to modify.';
}
}
} else if (('' + forwhat.id).indexOf('append') != -1) {
if (document.getElementById(fleshout(('' + forwhat.id).replace('ib', 'il'))).value != '') {
if (document.getElementById(('' + forwhat.id).replace('ib', 'il')).value.substring(0,1) == '#') { tb=''; }
document.getElementById('a' + currspan).innerHTML+='</a> <a id=a' + eval(1 + currspan) + tb + ' ontouchstart="event.stopPropagation(); event.preventDefault(); modifydothis(this); " oncontextmenu="event.stopPropagation(); modifydothis(this); " title="Linking to ' + nuance(document.getElementById(('' + forwhat.id).replace('ib', 'il')).value) + '" href="' + document.getElementById(('' + forwhat.id).replace('ib', 'il')).value + '">' + lfidea(document.getElementById(('' + forwhat.id).replace('ib', 'iw')).value);
} else {
document.getElementById('a' + currspan).innerHTML+='</a> <a id=a' + eval(1 + currspan) + ' ontouchstart="event.stopPropagation(); event.preventDefault(); modifydothis(this); " oncontextmenu="event.stopPropagation(); modifydothis(this); " title="" href=#>' + lfidea(document.getElementById(('' + forwhat.id).replace('ib', 'iw')).value);
}
currspan++;
document.getElementById(('' + forwhat.id).replace('ib', 'iw')).value='';
document.getElementById(('' + forwhat.id).replace('ib', 'il')).value='';
forwhat.disabled=true;
} else if (('' + forwhat.id).indexOf('prepend') != -1) {
if (document.getElementById(fleshout(('' + forwhat.id).replace('ib', 'il'))).value.substring(0,1) == '#') { tb=''; }
if (document.getElementById(('' + forwhat.id).replace('ib', 'il')).value != '') {
document.getElementById('a' + curlspan).innerHTML='<a id=a' + eval(-1 + curlspan) + tb + ' ontouchstart="event.stopPropagation(); event.preventDefault(); modifydothis(this); " oncontextmenu="event.stopPropagation(); modifydothis(this); " title="Linking to ' + nuance(document.getElementById(('' + forwhat.id).replace('ib', 'il')).value) + '" href="' + document.getElementById(('' + forwhat.id).replace('ib', 'il')).value + '">' + lfidea(document.getElementById(('' + forwhat.id).replace('ib', 'iw')).value) + ' ' + curis;
} else {
document.getElementById('a' + curlspan).innerHTML='<a id=a' + eval(-1 + curlspan) + ' ontouchstart="event.stopPropagation(); event.preventDefault(); modifydothis(this); " oncontextmenu="event.stopPropagation(); modifydothis(this); " title="" href=#>' + lfidea(document.getElementById(('' + forwhat.id).replace('ib', 'iw')).value) + ' ' + curis;
}
curlspan--;
document.getElementById(('' + forwhat.id).replace('ib', 'iw')).value='';
document.getElementById(('' + forwhat.id).replace('ib', 'il')).value='';
forwhat.disabled=true;
}
} else {
document.getElementById('instruction').innerHTML='';
}
}

</script>
</head>
<body onload="if (window.parent == window.self) { if (!navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) { document.getElementById('ilmodify').focus(); } }">
<h1>Linked Sentence Creator</h1>
<h3>RJM Programming - March, 2024</h3><br><br>


<span title='Each sentence part is linked, even if a boring (default) hashtagged arrangement, but you can Modify and add a link arrangement at any time, anywhere.' id='span0' style='margin:2 5 5 2;padding:1 1 1 1;line-height:38px;font-size:28px;border:3px dotted pink;background-color:rgb(240,240,240);'><a ontouchstart="event.stopPropagation(); event.preventDefault(); modifydothis(this); " oncontextmenu="event.stopPropagation(); modifydothis(this); " data-title="" id="a0" href='#'>Once upon a time</a> </span>

<br><br><br>
<table cellpadding=8 cellspacing=8 style='width:95%;' border=5>
<tr><th style="background-color:white;" colspan=3>Regarding Sentence above ... <span id=instruction></span></th></tr>
<colgroup>
<col class="red" />
<col class="yellow" />
<col class="green" />
</colgroup>
<tr><th style='text-align:left;'>Prepend ...</th><th style='text-align:center;'>Modify</th><th style='text-align:right;'>... Append</th></tr>
<tr><td id=tdprepend style='text-align:left;'>
<textarea rows=1 data-usedtobe='input type=text' style='width:80%;text-align:left;' placeholder='Sentence part goes here' value='' id=iwprepend onblur=enabling(this);></textarea><br>
<input style='width:80%;text-align:left;' type=url placeholder='Optional link goes here' value='' id=ilprepend></input><br><br>
<input style='width:80%;text-align:left;' type=button value='Prepend' id=ibprepend onclick=doit(this); disabled></input><br>
</td>
<td id=tdmodify style='text-align:center;'>
<textarea rows=1 data-usedtobe='input type=text' style='width:80%;text-align:center;' title='Sentence part replacement goes here' data-usedtobeblurb=' ... please note that anywhere ~~ can be used for a line feed' placeholder='Sentence part replacement goes here' value='Once upon a time' id=iwmodify onblur=enabling(this);>Once upon a time</textarea><br>
<input style='width:80%;text-align:center;' type=url title='Optional link goes here' placeholder='Optional link goes here' value='#' id=ilmodify></input><br><br>
<input style='width:80%;text-align:center;' type=button value='Modify' id=ibmodify onclick=doit(this);></input><br>
</td>
<td id=tdappend style='text-align:right;'>
<textarea rows=1 data-usedtobe='input type=text' style='width:80%;text-align:right;' placeholder='Sentence part goes here' value='' id=iwappend onblur=enabling(this);></textarea><br>
<input style='width:80%;text-align:right;' type=url placeholder='Optional link goes here' value='' id=ilappend></input><br><br>
<input style='width:80%;text-align:right;' type=button value='Append' id=ibappend onclick=doit(this); disabled></input><br>
</td></tr>
</table>

</body>
</html>