DOT label maker 2

by frogggeee McFrogggeee

HTML

<p id = "labels" style = "font-size: 18px;  margin-top: 0px;"></p>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.5/jspdf.debug.js"></script>

CSS

After Recording Retum To:
CMG MORTGAGE INC., DA CMG FINANCIAL
3160 CROW CANYON ROAD STE 400
SAN RAMON, CA 94583-1382
Return To: U.S. Bank, 
Hopkins Excelsior Blvd
9380 Excelsior Blvd, Floor #3
Hopkins, MN 55343
After Recording Return To:
UNITED WHOLESALE MORTGAGE, LLC
585 SOUTH BOULEVARD E
PONTIAC. MI 48341
When recorded, return to:
OnPoint Community Credit Union
2701 NW Vaughn Street, #800
Portland, OR 97210
When recorded, return to:
Indecomm Global Services
1427 Energy Park Drive
St. Paul, MN 55108
After Recording Return To:
OPTIMUM FIRST INC
8900 WARNER AVE
FOUNTAIN VALLEY, CALIFORNIA 92708
When Recorded Mail To:
LOANDEPOT. COM, LLC 
6531 IRVINE CENTER DRIVE, SUITE 100
IRVINE, CA 92618
(888) 337-6888
After Recording Return To:
GUILD MORTGAGE C/O DOC PROBE
MAIL STOP CODE: DP1960
1133 OCEAN AVENUE
LAKEWOOD, NJ 08701 
Additional Information Required for Recording:
When recorded, return to:
1st Security Bank of Washington C/O DocProbe
1820 Swarthmore Avenue
P.O. Box 840
Lakewood, NJ 08701
When recorded, return to:
Umpqua Bank
6610 SW Cardinal Lane, 1st Floor
Tigard, OR 97224
When recorded, return to:
Nova Financial & Investment Corporation
6245 East Broadway, Suite 400
Tucson, AZ 85711
When Recorded Mail To:
Rocket Mortgage, LLC
1050 Woodward Ave
Detroit, MI 48226-1906
(313) 373-0000
Return Name and Address
Primary Residential Mortgage, Inc. c/o First American
1795 International Way
Idaho Falls, ID 83402
Return to:
CORNERSTONE HOME LENDING c/o DocProbe, LLC
1133 Ocean Avenue
Mail stop code: DP7243
Lakewood, NJ 08701
Return to:
NW Equity Lending, LLC
4660 NE 77th Avenue, Suite 200
Vancouver, WA 98662
After Recording Return To:.
Cardinal Financial Company, Limited Partnership
3701 Arco Corporate Drive, Suite 200
Charlotte, NC 28273
After Recording Return To:
Rebecca Waldrup/Symmetry Lending
6600 Peachtree Dunwoody Rd.
Building 400, Suite 290
Atlanta, Georgia 30328
Return Name and Address
1st Security Bank of Washington C/O DocProbe
1820 Swarthmore Avenue
P.O. Box...

JavaScript

//GIANT GREEN CLICK ME BUTTON TO SUMMON PROMPT
let keywords = ["return", "record", "Return", "Record", "recording", "Recording"];
let labels = [];
let data = prompt("Please paste the data");
labels = data.split("\n");
for (let i = 0; i < labels.length; i++) {
  for (let j = 0; j < keywords.length; j++) {
    if (labels[i].includes(keywords[j])) {
      if (labels[i].split(":").length > 1) {
        if (labels[i].split(":")[1].length < 2) {
          labels[i] = "@";
        } else {
          labels[i] = "@" + labels[i].split(":")[1];
        }
      } else {
        // exception: return to: river mark community credit union
        labels[i] = "@";
      }
    }

  }
}
labels = labels.join("").replace(/\n|\r/g, "<").split("@");
if (labels[0] == "") {
  labels.shift();
}
for (let i = 0; i < labels.length; i++) {
  labels[i] += "<";
}
labels = labels.join("").split("<");
//document.getElementById("labels").innerHTML = labels.join("").split("<").join("<br>");
let lines = [];
let rows = [];
let length = 34;
let lineCount = 0; // total lines for current row
let linesCreated = 0; // lines created for current label
for (let i = 0; i < labels.length; i++) {
  if (labels[i] == "") {
    lines.push(">");
    lineCount++;
    linesCreated = 0;
  } else {
    // insert > symbol at row breaks
    let words = labels[i].split(" ");
    let line = "";
    for (let j = 0; j < words.length; j++) {
      words[j] = words[j].substr(0, 1).toUpperCase() + words[j].substr(1, words[j].length).toLowerCase();
      if (words[j].toLowerCase() == "llc" || words[j].toLowerCase() == "lic") {
        words[j] = "LLC";
      }
      if (words[j].length == 2) {
        words[j] = words[j].toUpperCase();
      }
      if ((line + " " + words[j]).length > length) {
        lines.push(line);
        lineCount++;
        linesCreated++;
        line = words[j] + " ";
      } else {
        line += words[j] + " ";
      }

    }
    lines.push(line)
    linesCreated++;
    lineCount++;
    line =...