Google Geo Chart and Map Chart Hashtag SMS Tutorial

Google Geo Chart and Map Chart Hashtag SMS Tutorial

Google Geo Chart and Map Chart Hashtag SMS Tutorial

We’ve reached limits! Yes, researching for SMS sharing conduits within the macOS arrangement here, we believe for iMessage SMS messages there may be a length limit that kicks in around the 18k mark. Anyway, along the line, with SMS messaging (via hashtagging) in …

  • Google Charts Map Chart
  • Google Charts Geo Chart

… further to the hashtag emailing in yesterday’s Google Geo Chart and Map Chart Hashtag Emailing Tutorial we ask for a mobile number to send to, and forewarn the user if we suspect it may not work, which our testing showed happens, even though the iPhone Message app declares the SMS “Delivered”, sometimes it isn’t, when the SMS messages are very long.

For a few days now, there seemed to be “no limits”, and that can be an uneasy way to go about software development. It is advantageous to know what might be a problem down the track.

The changes feature …

Collect a method=POST (and now a method=GET) (perhaps large data set) into a potentially useful (later) PHP variable hashtag part to an “a” “mailto:” href …
<?php

$shto="";
$gshto="";

if (isset($_POST['title'])) {
foreach ($_POST as $name => $val) {
if (strpos($val, 'data:') !== false) {
$fval=urlencode($val); //str_replace(" ", "%20", str_replace("'", urlencode("'"), str_replace('"', urlencode('"'), str_replace('=', urlencode('='), str_replace('>', urlencode('>'), str_replace('<', urlencode('<'), str_replace('?', urlencode('?'), str_replace('&', urlencode('&'), $val)))))))); } else { $fval=str_replace('+','%20',urlencode(str_replace(' ',' + ',str_replace('+',' ',$val)))); //str_replace(" ", "%20", str_replace("'", urlencode("'"), str_replace('"', urlencode('"'), str_replace('=', urlencode('='), str_replace('>', urlencode('>'), str_replace('<', urlencode('<'), str_replace('?', urlencode('?'), str_replace('&', urlencode('&'), $val)))))))); } if ($shto == "") { $shto="#" . $name . "=" . $fval; //str_replace(" ", "%20", str_replace("'", urlencode("'"), str_replace('"', urlencode('"'), str_replace('=', urlencode('='), str_replace('>', urlencode('>'), str_replace('<', urlencode('<'), str_replace('?', urlencode('?'), str_replace('&', urlencode('&'), $val)))))))); } else { $shto.="&" . $name . "=" . $fval; //str_replace(" ", "%20", str_replace("'", urlencode("'"), str_replace('"', urlencode('"'), str_replace('=', urlencode('='), str_replace('>', urlencode('>'), str_replace('<', urlencode('<'), str_replace('?', urlencode('?'), str_replace('&', urlencode('&'), $val)))))))); } } } if (isset($_GET['data'])) {
foreach ($_GET as $name => $val) {
if (strpos($val, 'data:') !== false) {
$fval=urlencode($val); //str_replace(" ", "%20", str_replace("'", urlencode("'"), str_replace('"', urlencode('"'), str_replace('=', urlencode('='), str_replace('>', urlencode('>'), str_replace('<', urlencode('<'), str_replace('?', urlencode('?'), str_replace('&', urlencode('&'), $val))))))));
} else {
//$fval=str_replace('+','%20',urlencode($val)); //str_replace(" ", "%20", str_replace("'", urlencode("'"), str_replace('"', urlencode('"'), str_replace('=', urlencode('='), str_replace('>', urlencode('>'), str_replace('<', urlencode('<'), str_replace('?', urlencode('?'), str_replace('&', urlencode('&'), $val))))))));
$fval=str_replace('+','%20',urlencode(str_replace(' ',' + ',str_replace('+',' ',$val)))); //str_replace(" ", "%20", str_replace("'", urlencode("'"), str_replace('"', urlencode('"'), str_replace('=', urlencode('='), str_replace('>', urlencode('>'), str_replace('<', urlencode('<'), str_replace('?', urlencode('?'), str_replace('&', urlencode('&'), $val))))))));
}
if ($shto == "") {
$gshto="#" . $name . "=" . $fval; //str_replace(" ", "%20", str_replace("'", urlencode("'"), str_replace('"', urlencode('"'), str_replace('=', urlencode('='), str_replace('>', urlencode('>'), str_replace('<', urlencode('<'), str_replace('?', urlencode('?'), str_replace('&', urlencode('&'), $val))))))));
} else {
$gshto.="&" . $name . "=" . $fval; //str_replace(" ", "%20", str_replace("'", urlencode("'"), str_replace('"', urlencode('"'), str_replace('=', urlencode('='), str_replace('>', urlencode('>'), str_replace('<', urlencode('<'), str_replace('?', urlencode('?'), str_replace('&', urlencode('&'), $val))))))));
}
}
}


?>
Rework the existant “Email …” link wording into an Email 📧 and SMS 📟 emoji link combination arrangement …
<?php

if ($shto != "") {
echo " setTimeout(function(){
if (document.getElementById('remail')) {
if (document.getElementById('remail').innerHTML.indexOf('Email') == 0) {
//alert(document.getElementById('remail').href);
var inplace=document.getElementById('remail').outerHTML.replace(document.getElementById('remail').outerHTML.split(' href=\"')[1].split('body=')[0], 'sms:&').replace('To email ', 'To SMS (and if it fails for lengthy messages the email methodology may work better) ').replace('remail','rsms');
//alert('inplace=' + inplace);
if (document.getElementById('slineof')) {
document.getElementById('slineof').innerHTML=document.getElementById('slineof').innerHTML.replace(document.getElementById('remail').outerHTML, document.getElementById('remail').outerHTML.replace(document.getElementById('remail').innerHTML, '&#128231;') + ' ' + inplace.split('>')[0] + '>&#128223;</a>');
} else {
document.getElementById('remail').innerHTML='&#128231;</a> ' + inplace.split('>')[0] + '>&#128223;';
}
}
}
}, 5000); " . "\n";
} else if ($gshto != "") {
echo " if (typeof sethash == \"function\") { sethash(encodeURIComponent(\"" . $gshto . "\")); } " . "\n";
echo " setTimeout(function(){
if (document.getElementById('remail')) {
if (document.getElementById('remail').innerHTML.indexOf('Email') == 0) {
//alert(document.getElementById('remail').href);
var inplace=document.getElementById('remail').outerHTML.replace(document.getElementById('remail').outerHTML.split(' href=\"')[1].split('body=')[0], 'sms:&').replace('To email ', 'To SMS (and if it fails for lengthy messages the email methodology may work better) ').replace('remail','rsms');
//alert('inplace=' + inplace);
if (document.getElementById('slineof')) {
document.getElementById('slineof').innerHTML=document.getElementById('slineof').innerHTML.replace(document.getElementById('remail').outerHTML, document.getElementById('remail').outerHTML.replace(document.getElementById('remail').innerHTML, '&#128231;') + ' ' + inplace.split('>')[0] + '>&#128223;</a>');
} else {
document.getElementById('remail').innerHTML='&#128231;</a> ' + inplace.split('>')[0] + '>&#128223;';
}
}
}
}, 5000); " . "\n";
}

?>
Some email returns involve a double encoding
<?php echo ”

var lhpassed=('' + location.hash);
if (decodeURIComponent(lhpassed).indexOf('%20') != -1) {
lhpassed=decodeURIComponent(lhpassed);
}


“; ?>
Just about totally reworked Javascript function ahdepends function …
<?php echo ”

function smsprompt(inbv, indv) {
var lprval=null;
if (eval('' + decodeURIComponent(document.getElementById('remail').href.split('&body=')[1]).length) >= 18000) {
lprval=prompt(inbv + ' We suspect data is too long for an SMS and if you enter an email address instead, we shall try to email that recipient.', indv);
} else {
lprval=prompt(inbv, indv);
}
if (lprval != null) {
if (lprval.indexOf('@') != -1) {
glprval=document.getElementById('rsms').href;
setTimeout(function() { document.getElementById('rsms').href=glprval; }, 4000);
document.getElementById('remail').href=document.getElementById('remail').href.replace(document.getElementById('remail').href.split('?')[0], 'mailto:' + lprval);
document.getElementById('rsms').href=document.getElementById('remail').href; //'#'; // + glprval;
//document.getElementById('remail').click();
return '';
} else {
return lprval;
}
} else {
glprval=document.getElementById('rsms').href;
document.getElementById('rsms').href='#'; // + glprval;
setTimeout(function() { document.getElementById('rsms').href=glprval; }, 4000);
return lprval;
}
return '';
}

function ahdepends(ahoe) {
var aho=ahoe.target;
if (document.getElementById('remail')) {
var thistitle='';
if (document.getElementById('remail').href.indexOf('title=') != -1) {
thistitle=decodeURIComponent(document.getElementById('remail').href.split('title=')[1].split('&')[0]);
//alert('thistitle=' + thistitle);
} else if (document.getElementById('remail').href.indexOf(encodeURIComponent('title=')) != -1) {
thistitle=decodeURIComponent(decodeURIComponent(document.getElementById('remail').href.split(encodeURIComponent('title='))[1].split(encodeURIComponent('&'))[0]));
//alert('Thistitle=' + thistitle);
} //else {
//alert(document.getElementById('remail').href);
//}
if (thistitle.indexOf(';') == 2) {
thistitle=thistitle.substring(3);
}
if (document.getElementById('remail').href.indexOf('Google%20Chart%20Snapshot') != -1 && thistitle != '') {
if (document.getElementById('remail').href.indexOf(encodeURIComponent(thistitle)) == -1) {
document.getElementById('remail').href=document.getElementById('remail').href.replace('Google%20Chart%20Snapshot' + document.getElementById('remail').href.split('Google%20Chart%20Snapshot')[1].split('&')[0], encodeURIComponent('Google Chart Snapshot ... ' + thistitle));
}
}
if (aho.id == 'rsms') {
ahoe.stopPropagation();
if (aho.href.split('&body=')[1] != document.getElementById('remail').href.split('&body=')[1]) {
aho.href=aho.href.replace('&body=' + aho.href.split('&body=')[1], '&body=' + document.getElementById('remail').href.split('&body=')[1]);
}
}
}
if (aho.id == 'rsms' && aho.href.indexOf(':&') != -1) {
var smsp=('' + smsprompt('Please enter SMS number to send to.',''));
if (('' + smsp).indexOf('@') == -1) {
aho.href=aho.href.replace(':&', ':' + smsp + '&').replace(':null&', ':&');
//document.title=aho.href.substring(0,100);
}
if (aho.href.replace(/^\#/g,':&').indexOf(':&') != -1 || ('' + smsp) == 'null') {
//document.title='2:' + aho.href.substring(0,100);
ahoe.stopPropagation();
ahoe.preventDefault();
} else if (aho.href.indexOf('@') == -1) {
document.getElementById('remail').click();
}
}
if (dependssuffix != '') {
if (aho.href.indexOf(encodeURIComponent(dependssuffix)) == -1) {
//alert(dependssuffix);
aho.href+=encodeURIComponent(dependssuffix);
}
if (1 == 7 && aho.href.indexOf(encodeURIComponent('&data=')) != -1 && top.document.URL.indexOf('dams_usa.htm') != -1) {
if (aho.href.split(encodeURIComponent('&data='))[1].indexOf('%2520') != -1) {
//aho.href=aho.href.replace(aho.href.split('&body=')[1], decodeURIComponent(aho.href.split('&body=')[1]));
aho.href=aho.href.replace(aho.href.split(encodeURIComponent('&data='))[1], decodeURIComponent(aho.href.split(encodeURIComponent('&data='))[1]));
//aho.href=aho.href.replace(/\%2520/g, '%20');
}
}
}
//alert(aho.href);
}

“; ?>

And codewise …

… to make this happen.


Previous relevant Google Geo Chart and Map Chart Hashtag Emailing Tutorial is shown below.

Google Geo Chart and Map Chart Hashtag Emailing Tutorial

Google Geo Chart and Map Chart Hashtag Emailing Tutorial

Before we got sidetracked, but along the same “where of life” themes, before the latest recent web application predilections …

… we were delving into passing on work from the Google Chart‘s Map Chart to the Google Chart Geo Chart and Image Chart Map Chart more often, where we started that thread (at Google Chart Image Chart Map Chart Mainstream Primer Tutorial at the end of last year) with a three point plan (which became four point two days later)

  1. Help itself โ€ฆ map.php โ€ฆ phase 1
  2. Redirect to Image Chart Map Chart โ€ฆ map.php and/or geo_chart.php โ€ฆ just after first prompt โ€ฆ phase 2
  3. Caller form method=POST map.php action interventions at onsubmit event โ€ฆ non map.php โ€ฆ phase 3
  4. Transfer the onclick prompt window functionality over to geo_chart.php โ€ฆ phase 4

And then yesterday’s work in Earth Bearing Distance Missing Two Earth Scanner Integration Tutorial involving the Missing Two web application’s interfacing to the Google Chart Map Chart saw a more happy interfacing with this Map Chart, and reminding us with both …

  • Google Charts Map Chart
  • Google Charts Geo Chart

… how on occasions we could have large data set scenarios relying on PHP $_POST data (via form method=POST (or you can use Ajax FormData post) arrangements) that had not passed on their data parts when the user clicked the “Email” link down the bottom. But ever since that happy discovery from around about the time of Earth Scanner Sharing Itinerary Detail Tutorial that …

  • hashtagging … was the friend of …
  • “a” “mailto:” and/or “sms:” link hrefs … replacing the need for …
  • PHP mail via a local mail server methodologies … when the email body is a single link whose length was greater than about 850 (ie. no such stringent limitations with “just clientside” hashtagging (which we’re yet to know what the limit is, but it seems huge))

… and … spoiler alert … we could not break (where we do not count as broken the clicking of a “Message clipped” message link, which we always click to fully show the whole link, as a warning from your email client application (eg. Gmail)) it with any large amounts of data from our PHP Wikipedia Australian List Integration Tutorial “peer to peer” suite of linked PHP web applications passing large amounts of data to those Google Charts and emailing that on to an emailee recipient. Good news indeed!

The changes feature …

Collect a method=POST (perhaps large data set) into a potentially useful (later) PHP variable hashtag part to an “a” “mailto:” href …
<?php

$shto="";

if (isset($_POST['title'])) {
foreach ($_POST as $name => $val) {
if (strpos($val, 'data:') !== false) {
$fval=urlencode($val); //str_replace(" ", "%20", str_replace("'", urlencode("'"), str_replace('"', urlencode('"'), str_replace('=', urlencode('='), str_replace('>', urlencode('>'), str_replace('<', urlencode('<'), str_replace('?', urlencode('?'), str_replace('&', urlencode('&'), $val)))))))); } else { $fval=str_replace('+','%20',urlencode(str_replace(' ',' + ',str_replace('+',' ',$val)))); //str_replace(" ", "%20", str_replace("'", urlencode("'"), str_replace('"', urlencode('"'), str_replace('=', urlencode('='), str_replace('>', urlencode('>'), str_replace('<', urlencode('<'), str_replace('?', urlencode('?'), str_replace('&', urlencode('&'), $val)))))))); } if ($shto == "") { $shto="#" . $name . "=" . $fval; //str_replace(" ", "%20", str_replace("'", urlencode("'"), str_replace('"', urlencode('"'), str_replace('=', urlencode('='), str_replace('>', urlencode('>'), str_replace('<', urlencode('<'), str_replace('?', urlencode('?'), str_replace('&', urlencode('&'), $val)))))))); } else { $shto.="&" . $name . "=" . $fval; //str_replace(" ", "%20", str_replace("'", urlencode("'"), str_replace('"', urlencode('"'), str_replace('=', urlencode('='), str_replace('>', urlencode('>'), str_replace('<', urlencode('<'), str_replace('?', urlencode('?'), str_replace('&', urlencode('&'), $val)))))))); } } }

?>
Up the top of where PHP is writing out the Javascript, checking for an email derived URL with huge hashtag we turn into a form method=POST scenario for the user clicking the email body huge link ...

var dependssuffix='';
if (('' + location.hash).indexOf('&data=') != -1) {
dependssuffix=('' + location.hash);
}
<?php
if ($shto != "") {
echo " if (typeof sethash == \"function\") { sethash(encodeURIComponent(\"" . $shto . "\")); } " . "\n";
}

echo "
var lhpassed=('' + location.hash);
if ((1 == 1 || document.URL.split('#')[0].indexOf('?') == -1) && lhpassed.indexOf('&data=') != -1) {
if (3 == 3) { // good for new style of hashtagged email
var gformoh='<iframe name=lastgif id=lastgif style=\"position:absolute;width:100%;height:100%;z-index:897;top:0px;left:0px;\" src=></iframe><br><form style=display:none; target=_self method=POST action=\"' + document.URL.split('#')[0] + '\"><input id=gformsubis type=submit value=Submit style=display:none;></input></form>';
var fldsare=lhpassed.replace(/^\#/g,'').split('=');
for (var ifldsare=1; ifldsare<fldsare.length; ifldsare++) {
gformoh=gformoh.replace('</form>','<input type=hidden name=\"' + fldsare[eval(-1 + ifldsare)].split('&')[eval(-1 + fldsare[eval(-1 + ifldsare)].split('&').length)] + '\" value=\"' + (fldsare[ifldsare].split('&')[0]) + '\"></input></form>');
}
setTimeout(function() {
document.body.innerHTML+=gformoh;
document.getElementById('gformsubis').click(); }, 7000);
} else {
var gzhr = new XMLHttpRequest();
var gzform=new FormData();
var fldsare=lhpassed.replace(/^\#/g,'').split('=');
for (var ifldsare=1; ifldsare<fldsare.length; ifldsare++) {
gzform.append(fldsare[eval(-1 + ifldsare)].split('&')[eval(-1 + fldsare[eval(-1 + ifldsare)].split('&').length)], decodeURIComponent(fldsare[ifldsare].split('&')[0]));
}
gzhr.open('post', document.URL.split('#')[0], true);
gzhr.send(gzform);
}
}
";

?>
All location.search. strings become, for example ...
<?php echo "

var ansis=(location.search + '" . $shto . "').split('val' + pnum + '=')[1] ? decodeURIComponent(decodeURIComponent((location.search + '" . $shto . "').split('val' + pnum + '=')[1].split('&')[0]).replace(/\+/g,' ')) : '';

"; ?>
Javascript functions that are wrappers to Javascript prompt window scenarios need ...
<?php echo "

function ourprompt(ourp1, ourp2) {
if (('' + location.hash).replace('&data=') != ('' + location.hash)) { return ourp2; }
var iop=0;
tzpn='';
// more code here
thisris=prompt(ourp1, ourp2);
// more code here
return thisris;
}

"; ?>
New if for code involving no data passed in $_GET[] nor $_POST[] but huge hashtag (via email) ...
<?php

echo ' if (("" + location.hash).replace("&data=") == ("" + location.hash)) { ' . "\n";

echo ' datalineprefix = " "; ' . "\n";
echo ' datalinesuffix = ""; ' . "\n";
echo ' var prethisline = "", fti=false, extra = ""; ' . "\n";
echo ' var thisline = 1, gc_m="", gtitle="", glabel="", gvalue=""; ' . "\n";
// more code here going on to interactive Javascript prompt window asks
// more code here
echo "} \n";

echo "} \n";

?>
New Javascript function helpers ...
<?php echo "

var dependssuffix='';

function sethash(towhat) {
if (towhat.indexOf(encodeURIComponent('#')) == 0) {
dependssuffix=decodeURIComponent(towhat);
} else {
dependssuffix=towhat;
}
}

function depends(ins) {
if (ins.indexOf('?') == -1 && ins.indexOf('#') == -1 && dependssuffix != '') {
if (dependssuffix.indexOf('?') == 0) {
return (ins + '#' + dependssuffix.substring(1));
} else if (dependssuffix.indexOf('#') == 0) {
return (ins + dependssuffix);
} else {
return (ins + '#' + dependssuffix);
}
}
return ins;
}

"; ?>
Add hashtag suffix to "a" "mailto:" link href attribute as applicable ...
<?php

echo '<a id="amapid" title="Another Map" href="' . $https . 'www.rjmprogramming.com.au/PHP/Map/map.php">Another</a> <a id="amapidgeo" title="Another Geo Map" style="text-decoration:underline;cursor:pointer;" onclick=gogeo("' . $https . 'www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php");>Geo</a> <a id="amapidtwo" title="Another Map" href="' . $https . 'www.rjmprogramming.com.au/PHP/Map/map.php">Map?</a>' . '  <a onclick=ahdepends(this); href="MAILTO:fillin.email@address?subject=Google%' . '20Chart%' . '20Snapshot&body=' . urlencode("HTTP://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . $shto) . '" style="display:inline;" title="To email a snapshot of this Google Chart click me." id="remail">Email snapshot of Google Chart ...</a>' . " \n";

?>

Codewise ...

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Event-Driven Programming, Tutorials and tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>