Customized Twitter button code with while loop

Twitter button with additional methods to allow evaluation of string length, then trimming to fit. Console log function used to check at each step.

by Shirley Hicks

HTML

<div id="console-log"></div>

<a class="btn btn-info btn-lg" id="tweettext" title="tweetquote!" href="#" onclick="dynamicURL()" method="POST" target="_blank"><i class="fa fa-twitter fa-lg"></i>Share it on Twitter!</a>

CSS

.console-line {
  font-family: monospace;
  margin: 2px;
}

JavaScript

var consoleLine = "<p class=\"console-line\"></p>";
//console log emulation
console = {
  log: function(text) {
    $("#console-log").append($(consoleLine).html(text));
  }
}

var testyTest = "My line goes here!";
console.log(testyTest);

var quoteStr = '\"A ship in port is safe, but that is not what ships are for. Sail out to sea and do new things. Extra, blah, blah, blah, blah.\"';
var nameStr = '<a href=\"http://www.biography.com/people/grace-hopper-21406809#early-life\">Rear Admiral Grace Hopper</a>';
console.log(quoteStr);
console.log(nameStr);

//strips HTML markup out of the string
var cleanedNameStr = nameStr.replace(/<[^>]*>?/gi, '');
console.log(cleanedNameStr);
//max tweet == 140 char. " - " and stripped nameStr needs 
//to be allowed for in length of tweet. So....
var maxLength = 140 - (3 + cleanedNameStr.length);
console.log("tweet room = " + maxLength);
var isLess140 = true;
//check quoteStr against maxLength. If longer, split into 
//pieces at periods

if (quoteStr.length > maxLength) {
  console.log("this string is too long.");
  //split quote strigs up at periods before checking length
  var strArray = quoteStr.split(".");
  var tweetStr = " ";
  var ct = 0;
  console.log(tweetStr);
  }

do{
	tweetStr += strArray[ct] + ". ";
  console.log(tweetStr);
  ct++;
  console.log(ct);
  var strALen = tweetStr.length;
  console.log(strALen);
  var strB = strArray[ct];
  console.log(strB);
  var strBLen = strB.length;
  console.log(strBLen);
  if ((strALen + strBLen) >= maxLength){
  	isLess140 = false;
  }
} while( isLess140 === true);

//push the quote to the twitter button
function dynamicURL(combinedStr) {
  //also assign the values to a string for twitter
  var twitterURL = "https://twitter.com/intent/tweet?text=" + combinedStr;
  document.getElementById("tweettext") = twitterURL;

}