{"id":56377,"date":"2022-07-12T03:01:49","date_gmt":"2022-07-11T17:01:49","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=56377"},"modified":"2022-07-12T08:46:14","modified_gmt":"2022-07-11T22:46:14","slug":"broadcast-channel-api-same-domain-crontab-curl-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/broadcast-channel-api-same-domain-crontab-curl-tutorial\/","title":{"rendered":"Broadcast Channel API Same Domain Crontab Curl Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test.php\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Broadcast Channel API Same Domain Crontab Curl Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test_tidy.jpg\" title=\"Broadcast Channel API Same Domain Crontab Curl Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Broadcast Channel API Same Domain Crontab Curl Tutorial<\/p><\/div>\n<p>The PHP of yesterday&#8217;s <a title='Broadcast Channel API Same Domain Sharing Tutorial' href='#bcapisdst'>Broadcast Channel API Same Domain Sharing Tutorial<\/a> might get busy, effectively being the source data of its own functionality.  In this context it can be better to not burden it, directly in the actions of the code, to take on any &#8220;data tidy&#8221; chores.  Because it is PHP we can, instead &#8230;<\/p>\n<ul>\n<li>for an operational piece of functionality &#8230;<\/li>\n<li>that being &#8220;data tidy&#8221; of irrelevant records of the form &#8230;<br \/>\n<blockquote><p>\n&lt;?php<br \/>\n<code><br \/>\n\/\/ AM 09:46:06 Saturday 9th of July 2022: bcn=yeswell msg=TGlzdGVuZXI6IFdlbGwsCm9r<br \/>\n<\/code><br \/>\n?&gt;\n<\/p><\/blockquote>\n<\/li>\n<li>schedule a once a day &#8220;data tidy&#8221; call up at the RJM Programming Linux CentOS web server via <font size=1>good ol&#8217;<\/font> <a target=_blank title='crontab information from computerhope ... thanks' href='http:\/\/www.computerhope.com\/jargon\/c\/cron.htm'><i>crontab<\/i><\/a>\/<a target=_blank title='Linux or unix curl information from computerhope' href='http:\/\/www.computerhope.com\/unix\/curl.htm'><i>curl<\/i><\/a> <font size=1><a target=_blank title='Fred and Ginger' href='http:\/\/www.youtube.com\/watch?v=MsS7B8nyw5Y'>&#8220;Fred\/Ginger&#8221;<\/a> feeling<\/font> call as per &#8230;<br \/>\n<code><br \/>\n58 23 * * * curl HTTP:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test.php?tidy=y<br \/>\n<\/code>\n<\/li>\n<li>arranging in that PHP code &#8220;independent&#8221; $_GET[&#8216;tidy&#8217;] (argument) new code &#8230;<br \/>\n&lt;?php<br \/>\n<code><br \/>\n  if (isset($_GET['tidy'])) {<br \/>\n    $pregm='#^\/\/[ ][AP]M[ ][0-9][0-9][:][0-9][0-9][:][0-9][0-9][ ]' . str_replace(' ','[ ]', '' . date('l jS \\of F Y')) . '[:][ ]bcn[=][^\\ ]+[ ]msg[=][A-Za-z0-9+\/= ]+$#m';<br \/>\n    $phpis=file_get_contents(dirname(__FILE__) . \"\/\" . \"broadcast_api_test.php\");<br \/>\n    $recs=file(dirname(__FILE__) . \"\/\" . \"broadcast_api_test.php\");<br \/>\n    $parts=explode('\/' . '\/ ' . 'bcdata', $phpis);<br \/>\n    $parte=explode('\/' . '\/ end of ' . 'bcdata', $phpis);<br \/>\n    if (sizeof($parts) == 2 && sizeof($parte) == 2) {<br \/>\n     $betw=\"\\n\";<br \/>\n     for ($jj=0; $jj&lt;sizeof($recs); $jj++) {<br \/>\n      $nw=preg_match($pregm, $recs[$jj], $matches);<br \/>\n      if ($nw) {<br \/>\n       for ($ii=0; $ii&lt;sizeof($matches); $ii++) {<br \/>\n        if (strpos($matches[$ii], \" bcn=\") !== false) {<br \/>\n         if (strpos($betw, $matches[$ii]) === false) {<br \/>\n          $betw.='' . $matches[$ii] . \"\\n\";<br \/>\n         }<br \/>\n        }<br \/>\n       }<br \/>\n      }<br \/>\n     }<br \/>\n     file_put_contents(dirname(__FILE__) . \"\/\" . \"broadcast_api_test.php\", $parts[0] . '\/' . '\/ ' . 'bcdata' . explode('\/' . '\/ end of ' . 'bcdata', $betw)[0] . '\/' . '\/ end of ' . 'bcdata' . $parte[1]);<br \/>\n     exit;<br \/>\n    }<br \/>\n  }<br \/>\n<\/code><br \/>\n?&gt;<br \/>\n &#8230; starring PHP&#8217;s <a target=_blank title='preg_match information from php.net' href='https:\/\/www.php.net\/manual\/en\/function.preg-match.php'>preg_match<\/a> and <a target=_blank title='file information from php.net' href='https:\/\/www.php.net\/manual\/en\/function.file.php'>file<\/a> and <a target=_blank title='file_get_contents information from php.net' href='https:\/\/www.php.net\/manual\/en\/function.file-get-contents.php'>file_get_contents<\/a> and <a target=_blank title='file_put_contents information from php.net' href='https:\/\/www.php.net\/manual\/en\/function.file-put-contents.php'>file_put_contents<\/a> and <a target=_blank title='explode information from php.net' href='https:\/\/www.php.net\/manual\/en\/function.explode.php'>explode<\/a>, combining, logic to remove records that are not of the same day (component of the whole datetime parts of the data records) as the web server is showing\n<\/li>\n<\/ul>\n<p> &#8230; to have <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test.php---GETME\" title=\"broadcast_api_test.php\">our changed<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test.php---GETME\" title=\"broadcast_api_test.php\">broadcast_api_test.php<\/a> Broadcasting <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test.php\" title=\"Click picture\">web application<\/a> be that &#8220;neat and tidy&#8221; webpage it&#8217;s always wanted to be <font size=1>(but do you think they&#8217;ll ask? &#8230;. noooooooo!)<\/font>.<\/p>\n<p>A &#8220;peer to peer&#8221; approach could be to call that <i>HTTP:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test.php?tidy=y<\/i> every time in an iframe each time a new Broadcast Channel is established, but that causes more stress to the PHP incarnations, and that is what we mean by &#8220;hiving off&#8221; operational tasks to &#8220;crontab\/curl&#8221; scheduled and independent arrangements, in preference.<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/broadcast-channel-api-same-domain-crontab-curl-tutorial\/'>Broadcast Channel API Same Domain Crontab Curl Tutorial<\/a>.<\/p-->\n<hr>\n<p id='bcapisdst'>Previous relevant <a target=_blank title='Broadcast Channel API Same Domain Sharing Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/broadcast-channel-api-same-domain-sharing-tutorial\/'>Broadcast Channel API Same Domain Sharing Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test.php\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Broadcast Channel API Same Domain Sharing Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test_invite.jpg\" title=\"Broadcast Channel API Same Domain Sharing Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Broadcast Channel API Same Domain Sharing Tutorial<\/p><\/div>\n<p>Yesterday&#8217;s <i>getting us onto a &#8220;same domain&#8221; footing<\/i> work with <a title='Broadcast Channel API Same Domain Tutorial' href='#bcapisdt'>Broadcast Channel API Same Domain Tutorial<\/a> has meant that it now makes sense for this PHP serverside web application to potentially spread its net wider to invite via &#8230;<\/p>\n<ul>\n<li>email<\/li>\n<li>SMS<\/li>\n<\/ul>\n<p> &#8230; other users and collaborators, whether they want to be &#8230;<\/p>\n<ul>\n<li>broadcasters<\/li>\n<li>listeners<\/li>\n<\/ul>\n<p> &#8230; into the mix of <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test.php--GETME\" title=\"broadcast_api_test.php\">our changed<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test.php--GETME\" title=\"broadcast_api_test.php\">broadcast_api_test.php<\/a> Broadcasting <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test.php\" title=\"Click picture\">web application<\/a> using the <a target=_blank title='Broadcast Channel API information' href='https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Broadcast_Channel_API'>Broadcast Channel API<\/a>.<\/p>\n<p>We use client based &#8220;a&#8221; link &#8230;<\/p>\n<ul>\n<li>mailto:<\/li>\n<li>sms:<\/li>\n<\/ul>\n<p> &#8230; prefixed URLs to achieve this, you may notice &#8230;<\/p>\n<p><iframe src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test.php?nowin=y\" style=\"width:100%;height:900px;\"><\/iframe><\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/broadcast-channel-api-same-domain-sharing-tutorial\/'>Broadcast Channel API Same Domain Sharing Tutorial<\/a>.<\/p-->\n<hr>\n<p id='bcapisdt'>Previous relevant <a target=_blank title='Broadcast Channel API Same Domain Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/broadcast-channel-api-same-domain-tutorial\/'>Broadcast Channel API Same Domain Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test.php\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Broadcast Channel API Same Domain Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test_diffwb.jpg\" title=\"Broadcast Channel API Same Domain Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Broadcast Channel API Same Domain Tutorial<\/p><\/div>\n<p>Yesterday&#8217;s <a title='Broadcast Channel API Primer Tutorial' href='#bcapipt'>Broadcast Channel API Primer Tutorial<\/a>&#8216;s premise would have disappointed many as we outlined the restriction &#8230;<\/p>\n<blockquote cite='\/\/www.rjmprogramming.com.au\/ITblog\/broadcast-channel-api-primer-tutorial\/'><p>\nsame device, same web browser\n<\/p><\/blockquote>\n<p> &#8230; with our HTML and Javascript client facing <a target=_blank title='Broadcast Channel API information' href='https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Broadcast_Channel_API'>Broadcast Channel API<\/a> web application.<\/p>\n<p>But supposing we introduce &#8220;database&#8221; or &#8220;other data repository&#8221; thoughts?  That can ease that restriction to then be, merely &#8230;<\/p>\n<blockquote cite='\/\/www.rjmprogramming.com.au\/ITblog\/broadcast-channel-api-same-domain-tutorial\/'><p>\nsame domain\n<\/p><\/blockquote>\n<p> &#8230; which just means broadcasters and listeners access the <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test.php-GETME\" title=\"broadcast_api_test.php\">&#8220;how we got there&#8221;<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test.php-GETME\" title=\"broadcast_api_test.php\">&#8220;now PHP server facing&#8221; broadcast_api_test.php<\/a> new Broadcasting <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test.php\" title=\"Click picture\">web application<\/a> incarnation.<\/p>\n<p>But no formal &#8220;database&#8221; connections here.  We make the PHP code itself be the &#8220;other data repository&#8221;, the new web application writing to itself, referencing the data of a particular Broadcast Channel in PHP records like &#8230;<\/p>\n<p>&lt;?php<br \/>\n<code><br \/>\n\/\/ AM 09:46:06 Saturday 9th of July 2022: bcn=yeswell msg=TGlzdGVuZXI6IFdlbGwsCm9r<br \/>\n<\/code><br \/>\n?&gt;<\/p>\n<p> &#8230; the message part <a target=_blank title='PHP base64_encode information' href='http:\/\/php.net\/manual\/en\/function.base64-encode.php'>base64_encode<\/a>d to avoid line feeds and carriage returns of the textarea inputting elements.<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/broadcast-channel-api-same-domain-tutorial\/'>Broadcast Channel API Same Domain Tutorial<\/a>.<\/p-->\n<hr>\n<p id='bcapipt'>Previous relevant <a target=_blank title='Broadcast Channel API Primer Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/broadcast-channel-api-primer-tutorial\/'>Broadcast Channel API Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Broadcast Channel API Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test.jpg\" title=\"Broadcast Channel API Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Broadcast Channel API Primer Tutorial<\/p><\/div>\n<p>Broadcasting is a tried and trusted model of &#8230;<\/p>\n<ul>\n<li>information distribution<\/li>\n<li>entertainment distribution<\/li>\n<\/ul>\n<p> &#8230; and if you add in &#8220;listeners who can respond&#8221; (perhaps named and the broadcaster can re-respond) you can add &#8230;<\/p>\n<ul>\n<li>feedback<\/li>\n<li>collaboration<\/li>\n<li>sharing<\/li>\n<\/ul>\n<p> &#8230; into the mix.  Well, today, we have a <a target=_blank title='Broadcast Channel API information' href='https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Broadcast_Channel_API'>Broadcast Channel API<\/a> idea where same device, same web browser users can subscribe to a Broadcast Channel and join into <a target=_blank title='window.postMessage() information' href='https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Window\/postMessage'>postMessage<\/a>() inspired functionality of this ilk.<\/p>\n<p><code><br \/>\n&lt;html&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;title&gt;Broadcast API Usage - RJM Programming - July, 2022 ... thanks to https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Broadcast_Channel_API&lt;\/title&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;<br \/>\n&lt;style&gt;<br \/>\n  td { vertical-align: top; }<br \/>\n  #ta { width: 98%; background-color: yellow; }<br \/>\n  #tab { width: 98%; background-color: lightblue; }<br \/>\n&lt;\/style&gt;<br \/>\n&lt;table border=20 style='width:100%;'&gt;<br \/>\n&lt;tr&gt;&lt;th contenteditable=true id=bname&gt;Broadcaster&lt;\/th&gt;&lt;th contenteditable=true id=lname&gt;Listener&lt;\/th&gt;&lt;\/tr&gt;<br \/>\n&lt;tr&gt;&lt;td id=blist&gt;<br \/>\n&lt;input style='width:100%;' id=itab type=text placeholder='RJM Programming Broadcast Channel Name of yours' value='' onblur='newone(this);'&gt;&lt;\/input&gt;<br \/>\n&lt;textarea id=tab placeholder='' value='' onblur='sthis(this);' rows=5 cols=80&gt;&lt;\/textarea&gt;<br \/>\n&lt;\/td&gt;<br \/>\n&lt;td id=btextarea&gt;<br \/>\n&lt;input id=ita style='width:100%;' type=text placeholder='RJM Programming Broadcast Channel Name of broadcaster to subscribe to' value='' onblur='onenew(this);'&gt;&lt;\/input&gt;<br \/>\n&lt;textarea id=ta onblur='sthis(this);' placeholder='' value='' rows=5 cols=80&gt;&lt;\/textarea&gt;<br \/>\n&lt;\/td&gt;&lt;\/tr&gt;<br \/>\n&lt;\/table&gt;<br \/>\n<br \/>\n&lt;script type='text\/javascript'&gt;<br \/>\n  var lastmsg='';<br \/>\n  let ourbc=null;<br \/>\n  let yourbc=null;<br \/>\n  let pbc=null;<br \/>\n  let bc=null;<br \/>\n  var wois=null;<br \/>\n<br \/> <br \/>\n  var ebc=location.search.split('bc=')[1] ? decodeURIComponent(location.search.split('bc=')[1].split('&')[0]).replace(\/\\+\/g,' ') : \"\";<br \/>\n  if (ebc.trim() != '') {<br \/>\n    \/\/const bc=null;<br \/>\n    document.getElementById('itab').placeholder=ebc;<br \/>\n    document.getElementById('ita').placeholder=ebc;<br \/>\n    document.getElementById('itab').value='';<br \/>\n    document.getElementById('ita').value='';<br \/>\n    document.getElementById('itab').onblur=function(event) { event.target.value=ebc; }<br \/>\n    document.getElementById('ita').onblur=function(event) { event.target.value=ebc; }<br \/>\n    document.getElementById('itab').setAttribute('readonly',true);<br \/>\n    document.getElementById('tab').setAttribute('readonly',true);<br \/>\n    document.getElementById('tab').style.display='none';<br \/>\n    yourbc = new BroadcastChannel(ebc);<br \/>\n    yourbc.onmessage = event =&gt; {<br \/>\n      if (minussc(event.data) != lastmsg) {<br \/>\n        \/\/alert('in with msg=' + event.data);<br \/>\n        \/\/document.getElementById('ta').value+=String.fromCharCode(10) + event.data.replace(lastmsg, '');<br \/>\n        document.getElementById('ta').value=String.fromCharCode(10) + event.data; \/\/.replace(lastmsg, '');<br \/>\n        document.getElementById('ta').title='' + new Date();<br \/>\n        document.getElementById('ta').rows='' + oureval(3 + eval('' + document.getElementById('ta').rows));<br \/>\n        document.getElementById('tab').rows='' + oureval(3 + eval('' + document.getElementById('tab').rows));<br \/>\n        if (yourbc) {<br \/>\n          \/\/yourbc.postMessage(document.getElementById('lname').innerHTML + ': ' + minussc(event.data)); \/\/.replace(lastmsg, ''));<br \/>\n          yourbc.postMessage(event.data); \/\/.replace(lastmsg, ''));<br \/>\n          window.opener.andback(); \/\/ wois.focus();<br \/>\n        }<br \/>\n        lastmsg=minussc(event.data);<br \/>\n      }<br \/>\n    };<br \/>\n    wois=window.opener;<br \/>\n  }<br \/>\n<br \/> <br \/>\n  function andback() {<br \/>\n    \/\/alert('Am back');<br \/>\n    window.focus();<br \/>\n  }<br \/>\n<br \/> <br \/>\n  function oureval(inv) {<br \/>\n    var tabi=document.getElementById('tab').value.split(String.fromCharCode(10));<br \/>\n    var tai=document.getElementById('ta').value.split(String.fromCharCode(10));<br \/>\n    return Math.max(eval(2 + eval('' + tabi.length)), eval(2 + eval('' + tai.length)));<br \/>\n  }<br \/>\n<br \/>\n  function newone(iv) {<br \/>\n   if (iv.value.trim() != '') {<br \/>\n    \/\/ Connection to a broadcast channel<br \/>\n    \/\/if (ourbc) {<br \/>\n    \/\/  ourbc.close();<br \/>\n    \/\/}<br \/>\n    \/\/const bc = new BroadcastChannel(iv.value);<br \/>\n    bc = new BroadcastChannel(iv.value);<br \/>\n    pbc=bc;<br \/>\n    ourbc=bc;<br \/>\n    document.getElementById('ita').setAttribute('readonly',true);<br \/>\n    document.getElementById('ta').setAttribute('readonly',true);<br \/>\n    document.getElementById('ta').style.display='none';<br \/>\n    ebc=iv.value;<br \/>\n    document.getElementById('itab').placeholder=ebc;<br \/>\n    document.getElementById('ita').placeholder=ebc;<br \/>\n    document.getElementById('itab').value='';<br \/>\n    document.getElementById('ita').value='';<br \/>\n    document.getElementById('itab').onblur=function(event) { event.target.value=ebc; }<br \/>\n    document.getElementById('ita').onblur=function(event) { event.target.value=ebc; }<br \/>\n    bc.onmessage = event =&gt; {<br \/>\n      if (minussc(event.data) != lastmsg) {<br \/>\n        \/\/document.getElementById('tab').value+=String.fromCharCode(10) + event.data.replace(lastmsg, '');<br \/>\n        document.getElementById('tab').value=String.fromCharCode(10) + event.data; \/\/.replace(lastmsg, '');<br \/>\n        document.getElementById('tab').title='' + new Date();<br \/>\n        document.getElementById('ta').rows='' + oureval(3 + eval('' + document.getElementById('ta').rows));<br \/>\n        document.getElementById('tab').rows='' + oureval(3 + eval('' + document.getElementById('tab').rows));<br \/>\n        if (bc) {<br \/>\n          \/\/bc.postMessage(document.getElementById('bname').innerHTML + ': ' + minussc(event.data)); \/\/.replace(lastmsg, ''));<br \/>\n          bc.postMessage(event.data); \/\/.replace(lastmsg, ''));<br \/>\n          wois.focus();<br \/>\n        }<br \/>\n        lastmsg=minussc(event.data);<br \/>\n      }<br \/>\n    };<br \/>\n    wois=window.open(document.URL.split('#')[0].split('?')[0] + '?bc=' + encodeURIComponent(iv.placeholder), '_blank');<br \/>\n   }<br \/>\n  }<br \/>\n<br \/> <br \/>\n  function onenew(iv) {<br \/>\n    yourbc = new BroadcastChannel(iv.value);<br \/>\n    yourbc.onmessage = event =&gt; {<br \/>\n      if (minussc(event.data) != lastmsg) {<br \/>\n        \/\/document.getElementById('tab').value+=String.fromCharCode(10) + event.data.replace(lastmsg, '');<br \/>\n        document.getElementById('tab').value=String.fromCharCode(10) + event.data; \/\/.replace(lastmsg, '');<br \/>\n        document.getElementById('tab').title='' + new Date();<br \/>\n        document.getElementById('ta').rows='' + oureval(3 + eval('' + document.getElementById('ta').rows));<br \/>\n        document.getElementById('tab').rows='' + oureval(3 + eval('' + document.getElementById('tab').rows));<br \/>\n        if (ourbc) {<br \/>\n          \/\/ourbc.postMessage(document.getElementById('bname').innerHTML + ': ' + minussc(event.data)); \/\/.replace(lastmsg, ''));<br \/>\n          ourbc.postMessage(event.data); \/\/.replace(lastmsg, ''));<br \/>\n          wois.focus();<br \/>\n        }<br \/>\n        lastmsg=minussc(event.data);<br \/>\n      }<br \/>\n    };<br \/>\n  }<br \/>\n<br \/> <br \/>\n  function minussc(insa) {<br \/>\n    if (insa.indexOf(': ') != -1) {<br \/>\n      return insa.replace(insa.split(': ')[0] + ': ','');<br \/>\n    }<br \/>\n    return insa;<br \/>\n  }<br \/>\n<br \/> <br \/>\n  function sthis(iv) {<br \/>\n    if (iv.value.trim() != '') {<br \/>\n    if (yourbc && !pbc) {<br \/>\n      yourbc.postMessage(document.getElementById('lname').innerHTML + ': ' + minussc(iv.value));<br \/>\n      document.getElementById('ta').rows='' + oureval(3 + eval('' + document.getElementById('ta').rows));<br \/>\n      document.getElementById('tab').rows='' + oureval(3 + eval('' + document.getElementById('tab').rows));<br \/>\n      iv.placeholder+=String.fromCharCode(10) + iv.value;<br \/>\n      iv.value='';<br \/>\n    } else if (bc) {<br \/>\n      \/\/alert('at broadcaster with msg=' + iv.value);<br \/>\n      \/\/bc=newone(document.getElementById('itab'));<br \/>\n      bc.postMessage(document.getElementById('bname').innerHTML + ': ' + minussc(iv.value));<br \/>\n      document.getElementById('ta').rows='' + oureval(3 + eval('' + document.getElementById('ta').rows));<br \/>\n      document.getElementById('tab').rows='' + oureval(3 + eval('' + document.getElementById('tab').rows));<br \/>\n      iv.placeholder+=String.fromCharCode(10) + iv.value;<br \/>\n      iv.value='';<br \/>\n    }<br \/>\n    }<br \/>\n  }<br \/>\n&lt;\/script&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<br \/>\n<\/code><\/p>\n<p> &#8230; as a first draft &#8220;proof of concept&#8221; <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test.html_GETME\">broadcast_api_test.html<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/broadcast_api_test.html\">Broadcast API web application<\/a> you can try for yourself.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d56362' onclick='var dv=document.getElementById(\"d56362\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/broadcast\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d56362' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d56367' onclick='var dv=document.getElementById(\"d56367\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/php\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d56367' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d56374' onclick='var dv=document.getElementById(\"d56374\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/email\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d56374' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d56377' onclick='var dv=document.getElementById(\"d56377\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/crontab\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d56377' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The PHP of yesterday&#8217;s Broadcast Channel API Same Domain Sharing Tutorial might get busy, effectively being the source data of its own functionality. In this context it can be better to not burden it, directly in the actions of the &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/broadcast-channel-api-same-domain-crontab-curl-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,29,37],"tags":[2914,88,1885,1653,2661,1710,4027,4026,198,212,1604,234,1985,1709,2442,274,284,290,380,2321,418,429,430,576,625,652,2114,886,932,2227,4028,997,2407,1055,1893,3310,1122,1133,1137,1159,1262,1319,1411],"class_list":["post-56377","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-operating-system","category-tutorials","tag-_get","tag-api","tag-argument","tag-base64","tag-base64_encode","tag-broadcast","tag-broadcast-channel-api","tag-broadcaster","tag-channel","tag-client","tag-collaboration","tag-command-line","tag-comment","tag-communication","tag-contenteditable","tag-crontab","tag-curl","tag-data","tag-email","tag-explode","tag-file","tag-file_get_contents","tag-file_put_contents","tag-html","tag-invitation","tag-javascript","tag-listener","tag-operations","tag-php","tag-postmessage","tag-preg_match","tag-programming","tag-record","tag-repository","tag-schedule","tag-scheduling","tag-server","tag-share","tag-sharing","tag-sms","tag-textarea","tag-tutorial","tag-web-server"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/56377"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=56377"}],"version-history":[{"count":10,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/56377\/revisions"}],"predecessor-version":[{"id":56387,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/56377\/revisions\/56387"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=56377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=56377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=56377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}