This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hello Everyone:
This is my first time posting here and I really moneyed this up,
the background:
- I hired a 3rd party (contractor) to make a key generator for a couple of now discontinued pieces of software which was provided as HTML with some integrated JS in the head and a few external dependencies (moment and jQuery). (see the first batch of code)
- I've made cosmetic changes to the contractor-supplied HTML to improve upon it and add my own branding, but I thought I'd use what limited knowledge of HTML I had to parse through the code and add some features (namely show/hide elements based on product selected in dropdown, add a button that would open a popup window that displays some arbitrary text along with information from the form that the user entered thus allowing them to not only check their entries before coming to me going "help! my codes don't work" but also print a hard copy for their records.
- I went to ChatGPT to get the code to implement the requested changes
- I added in several columns to the various tables where the codes display (to add clickable help icons that would pop up a window which displayed a page in the /help folder relative to the main HTML) and that's when everything started going to heck in a handbasket.
- Didn't start noticing issues until after implementing various iterations of the generate JS function in the head and the output table in the body.
For the record, I rarely if even hand-code from scratch unless it's a simple page with text and links, I use various versions of FrontPage (97-2003 (RIP)) and/or DreamWeaver (MX-CS3) to do most of my heavy lifting. As such please forgive the spaghetti code that these tools have added.
Find below the original code from the 3rd-party contractor for the KeyTool along with my new code that is broken (e.g. codes won't generate)
All code will be provided upon request due to Reddit's character limits for the body of a post and I want to ensure that it is accessible to allow for the community to help
note: All Code including the below is provided in the following ZIP which can be downloaded from my Mega Drive: https://mega.nz/file/NV0wEDYI#3dkfYgchBGm5fVCTxqvNicofH1B15S2a3odf7C1Ebk8
<html><head><style type="text/css">h2 {padding: 0em 0em 0.5em 0em;}th, td {padding: 0.15em 1em 0.15em 1em;}tr.space td {padding: 0.12em 1em 1em 1em;}.style1 {color: #FF0000;font-weight: bold;}</style><title>AveraSell Improved Download Center - KeyTool</title><script src="jquery-3.1.1.slim.min.js"></script><script src="moment.min.js"></script><script type="text/javascript">function init() {var expires = 14;var now = moment();$('#regdate').val(now.format('MM/DD/YYYY'));$('#expdate').val(now.add(expires, 'days').format('MM/DD/YYYY'));togglepfw44();}function togglepfw44() {$('#pfw44input').prop('hidden', $('#product').val() === 'avs');}function toggledate() {$('#regdate, #expdate').prop('disabled', !$('#timed').prop('checked'));}function clear() {$('#serialnum, #versioncode').html('');$('#edition td:nth-child(2), #edition td:nth-child(3)').html('');$('#modules td:nth-child(2), #modules td:nth-child(3)').html('');}function generate() {var vc = 178890;var edition = [[223987, 543238],[998732, 215588],[776490, 366591]];var module = [[322547, 226789],[632788, 129874],[399872, 112256],[200876, 679032],[666634, 188897],[877334, 766952],[222990, 777778],[229347, 543832]];var i;var sum = 0;var name = $('#name').val();var addr = $('#address').val();for (i = 0; i < name.length; i ) {sum = name.charCodeAt(i);}for (i = 0; i < addr.length; i ) {sum = addr.charCodeAt(i);}var s = 12*(sum Math.floor(sum*67/12472));if ($('#product').val() === 'avs') {s = 886;} else {s = 288;if ($('#timed').prop('checked')) {reg = moment($('#regdate').val(), 'MM/DD/YYYY');exp = moment($('#expdate').val(), 'MM/DD/YYYY');var date_re = /^\d{1,2}\/\d{1,2}\/\d{4}$/;var valid = true;$('#invalidreg').html(reg.creationData().input.search(date_re) >= 0 && reg.isValid() ? '' : (valid = false, ' invalid date'));if (exp.creationData().input.search(date_re) >= 0 && exp.isValid()) {if (reg.isSameOrAfter(exp)) {$('#invalidexp').html('expiration date should be after registration date');valid = false;}else {$('#invalidexp').html('');}} else {$('#invalidexp').html('invalid date');valid = false;}if (!valid) {clear();return;}var epoch = moment('1800-12-28');s = 3*exp.diff(epoch, 'days') - 2*reg.diff(epoch, 'days') - 34;}}$('#serialnum').html(67*sum);$('#versioncode').html(vc s);var row = $('#edition tr:nth-child(1)');for (i = 0; i < 3; i ) {row.find('td:nth-child(2)').html(edition[i][0] s);row.find('td:nth-child(3)').html(edition[i][1] s);row = row.next();}row = $('#modules tr:nth-child(1)');for (i = 0; i < 8; i ) {row.find('td:nth-child(2)').html(module[i][0] s);row.find('td:nth-child(3)').html(module[i][1] s);row = row.next();}}</script></head><body onload="init();"><h2>POSitive For Windows / AveraSell Registration</h2><p>To register additional features in AveraSell or POSitive For Windows (PFW) fill out the information below and click the button to get your codes. </p><p><img border="0" src="images/info24.png" width="24" height="24" alt="Info Icon"> Please Note: <span class="style1">Spelling, Capitalization, Punctuation, and Spacing are absolutely critical!</span> Please enter the information exactly as it is displayed in company setup (<strong>File > System > Company</strong>) We Encourage you to copy/paste this <strong>Company Name</strong> and <strong>Address 1</strong>from the company setup screen (copy button in lower left of this screen). After choosing copy, open notepad and choose <strong>Edit > Paste then copy the information into the boxes</strong> below and click the "<strong>Get Unlocking Codes Now</strong>" button below.</p><p><img border="0" src="images/help.png" width="24" height="24" alt="Help Resource"> <font color="#0000FF"><b>Want to make a correction or alteration to your companyname and/or address 1 without starting over?</b></font> <a title="Tutorial Video Link | Working With TopScan" target="_blank" href="https://youtu.be/LRVRrnFRqKw?t=5m59s">Watch this Tutorial video to find out how</a>. (External Link Opens in newWindow / Tab). <font color="#0000FF"><b>Video starts at 5 Minutes and 59Seconds in. This is set to happen automatically so you don't have to scrubthrough it looking for the information.</b></font></p><table border="1" width="85%" bgcolor="#CC0000" id="table1"><tr><td><b><font color="#FFFFFF" size="5"><img border="0" src="images/infobig.png" width="48" height="48" alt="information icon" align="left"></font><font color="#FFFFFF" size="4">VERY IMPORTANT: </font></b><font size="4" color="#FFFFFF"><b>Please <u>take a backup</u> of your<a href="file:///C:/AVS/compny.tps">C:\AVS\compny.tps</a><font color="#FFFFFF">or your </font><a href="file:///C:/pfw/compny.tps">C:\pfw\compny.tps</a>depending on which POS product you use <u>BEFORE</u> you use the method listed in the videolinked above.</b></font></td></tr></table><table border="1" width="89%" bgcolor="#CC0000" id="table2"><tr><td><b><font color="#FFFFFF" size="5"><img border="0" src="images/infobig.png" width="48" height="48" alt="information icon" align="left"></font></b><font color="#FFFFFF"><b>PleaseNote: Using the method described will cause you to need to re-registerusing KeyTool to obtain new codes for your updated company name and/oraddress.</b></font></td></tr></table><p><strong>Just so you know: we do NOT retain any of the information you enter into this form. Once you <em>leave this page</em>, you'll need to re-enter your company name and address 1 to recover your codes.</strong></p><p>Having Trouble with your Codes? see the <a href="keytool-help.html#regts">section on Troubleshooting registration issues</a> in KeyTool Help</p><table width="477"><tbody><tr><td>Product:</td><td><select id="product" onchange="togglepfw44();"><option value="avs">AveraSell</option><option value="pfw44">POSitive For Windows (PFW) Version 4.3 / 4.4</option></select></td></tr><tr><td width="142">Company Name:</td><td width="358"><input type="text" id="name" size="40" maxlength="45"/></td></tr><tr><td>Address 1:</td><td><input type="text" id="address" size="40" maxlength="35"/></td></tr></tbody><tbody id="pfw44input" hidden><tr><td>Codes are for: <a href="#Timed" target="_blank"><img border="0" src="help.png" width="24" height="24" alt="Help (Opens In New Window / Tab)" align="left"></a></td><td><input type="radio" name="timed" checked onchange="toggledate();">Permanent Unlocks<input type="radio" name="timed" id="timed" onchange="toggledate();">Timed Unlocks</td><tr><td>Registration Date:</td><td><input type="text" id="regdate" disabled size="12" maxlength="10"/> (mm/dd/yyyy)<span class="style1" id="invalidreg"/></td></tr><tr><td>Expiration Date:</td><td><input type="text" id="expdate" disabled size="12" maxlength="10"/> (mm/dd/yyyy)<span class="style1" id="invalidexp"></td></tr></tbody><tr><td colspan="2"><button onClick="generate();">Get Unlocking Codes Now!</button> </td></tr></table><p />Please check that the serial number matches the number displayed on the registration screen. <span class="style1">This is absolutely critical else the codes won't work</span>!.<hr><h2 />Unlocking information: </h2><p /><b>based on the information you provided above, the following are the codesneeded to unlock your chosen POS product:</b><p /><table><tr> <td width="195">Serial Number</td><td width="116" id="serialnum" /></tr><tr class="space"> <td>Version Code</td><td id="versioncode" /> </tr><tr> <th>Edition (Registration Number)</th> <th>Single User</th> <th width="200">Multi User</th> </tr><tbody id="edition"><tr> <td>Basic</td><td /><td /> </tr><tr> <td>Professional</td><td /><td /> </tr><tr class="space"> <td>Premiere</td><td /><td /> </tr></tbody><tr> <th>Modules</th> </tr><tbody id="modules"><tr> <td>Consignments</td><td /><td /> </tr><tr> <td>Service</td><td /><td /> </tr><tr> <td>Quotes</td><td /><td /> </tr><tr> <td>Contract Pricing</td><td /><td /> </tr><tr> <td>Multi-Store</td><td /><td /> </tr><tr> <td>Commissions</td><td /><td /> </tr><tr> <td>Yahoo Store</td><td /><td /> </tr><tr> <td>SecureCart Import</td><td /><td /> </tr></tbody></table><h2><a name="Timed">What are "Timed Unlocks" in PFW and Why Do You Offer theAbility To Generate Them?</a></h2><p>In PFW Timed unlocks are there to enable you to test the full functionalityof the software either by removing the restrictions of the initial demo mode,activating or deactivating modules, or testing over the network. We offerTimed unlocks as an opportunity for you to do the exact same purposebut allow you to come back and generate permanent unlocks if you find you'resatisfied with how PFW performs in your environment.</p><p>If you choose to generate "timed unlocks" the expiration date is defaulted to14 days from the current date. You can however choose to use a differentexpiration date just enter it in the appropriate box.</p><p>The recommended registration progression is to generate timed unlocks firstto see if the software meets your needs and then come back to generate permanentunlocks, but if you know that the software will meet your needs and don't needto test, then you could just go directly for permanent unlocks, doing theregistration progression is not a requirement.</p><h3> </h3><h3> </h3><h3>Codes Not Working?</h3><p>Don't panic, there's probably a simple and quick answer for why they aren't working. To troubleshoot registration issues take the following actions:</p><ol><li>Check, Double Check, and Check again to ensure that the <strong>Company Name</strong> AND <strong>Address 1</strong> are entered <strong>EXACTLY</strong> the same as in <strong>File > System > Company</strong></li><li>Check, Double Check, and Check again that the <strong>serial number</strong> matches what is displayed here based on your <strong>Company Name</strong> AND <strong>Address 1</strong>.</li><li>Check, Double Check, and Check again that you didn't "flub" or "goof" the Version Code OR Registration Number. (e.g. put the Version Code in the Registration Number box, transpose a digit or several, or other simple mistakes)</li><li>Make sure that you're using the right edition and that you're only using one type of code (example only using multi-user codes) as single-user and multi-user codes are not interchangable.</li></ol></body></html>
the above is contractor-supplied code as original, the below is the modified code
basically my opjectives with the modified code (above) are as follows:
- Alert if the user has just clicked the button without entering anything in at all
- show avaious elements based on product selected while hiding others. Ensure that if the user picks one product then changes the selection (e.g. made a mistake because they were moving too quickly) that the right controls and visual elements show/hide
- figure out a better way to impliment the help icons so a) they're more obvious to user that clicking them will get help on the topic, and b) they can (if possoble) not clutter the table with needless cells (unless I want to attach a help page to everything which at that point why not just rip out needed information from the manuel)
- Simpify the registration process by allowing the user to select from radio buttons the desired edition and whether single or multi-user codes are needed. Add a set check boxes for the optional modules they want. This then should drive the output (and/or print window see below) to only show the codes based on user selection.
- ensure that company name and address 1 along with product and the optional timed/permanent unlocks and date fields are filled in
- make the date boxes for times unlocks of the one product as dropdown calendars thus it's (hopefully) easier to set the dates.
- Offer a "Print unlocking codes" feature that will pop up a window that would say something like the folloowing in the body:
Based on the information entered (shown below for reference), the following are the codes needed to unlock your program and this should be filed away for your records:
[table with form information]
Company Name: <name field>
Address Line 1: <address field>
Product: <product selection>
Code Type (optional based product selection):
Code Registration Date (optional based on product selection):
code Expiration date (optional based on product selection):...
[end table]
[Display message noting that spelling, capitalization, spacing, and punctuation are critical to making the codes work and to please check and if need be correct any errors before attempting to enter the displayed codes]
[table showing all of the unlocking codes as generated on the previous page]
and 2 buttons one to print and one to close without printing.
7) be able to modify just about anything without breaking it this badly.
8) add a close this window button on each help page in the upper right
Subreddit
Post Details
- Posted
- 1 year ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/HTML/commen...