-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_clicktogenerate.html
More file actions
203 lines (187 loc) · 7.82 KB
/
test_clicktogenerate.html
File metadata and controls
203 lines (187 loc) · 7.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Email Generator by M. Concepcion</title>
<style>
body {
font-family: Helvetica, Arial, sans-serif;
}
section {
display: block;
padding-bottom: 10px;
}
.body-container {
display: flex;
flex-direction: row;
width: 1024px;
background-color: #f0f0f0;
margin: 20px auto;
vertical-align: top;
}
.split-container {
border: 1px solid #26C;
width: 50%;
padding: 1vw;
display: inline-block;
}
.simple-text {
display: inline-block;
font-family:Arial,Helvetica,sans-serif;
font-size: 40px;
font-weight: bold;
}
</style>
</head>
<body>
<h2 class="editor-title">Universal Email Generator</h2>
<div class="body-container">
<!-- Left side of editor -->
<div class="split-container">
<form>
<!-- Dropdown for selecting what email template to use -->
<section id="sectTemplateSelect">
<label for="dropdownTemplateSelect">Template:</label>
<select id="dropdownTemplateSelect" onchange="changeTemplate()">
<option value="templateSFA" selected="selected">SFA</option>
<option value="templateSO5">SO5</option>
</select>
</section>
<section id="sectAddFileName">
<label for="txtinputFileName">File Name:</label>
<input id="txtinputFileName" type="text" size="50">
</section>
<section id="sectNumberOfImgsLinks">
<label for="txtinputLinkCount">Link Count:</label>
<input id="txtinputLinkCount" type="number" defaultValue="1" style="width:40px;">
<label for="txtinputImgCount">Image Count:</label>
<input id="txtinputImgCount" type="number" defaultValue="1" style="width:40px;">
</section>
<!-- Button for adding a new table row to the code -->
<section id="sectAddHTMLRow">
<button id="btnAddHTMLRow" type="button">Add Table Row</button>
<button id="btnAddRowSep" type="button">Add Row Separator</button>
</section>
<!-- Area where the link input fields are added -->
<section id="sectLinkRows">
<div id="divLinkRows">
</div>
</section>
<!-- Area where new table rows are added -->
<section id="sectHTMLRows">
<div id="divHTMLRows">
</div>
</section>
<!-- Button for generating code -->
<section id="sectGenerateCode">
<button id="btnGenerateCode" type="button">Generate Code</button>
</section>
</form>
</div>
<div class="split-container">
<section id="sectResultTextArea">
<label for="textareaResult">Result HTML:</label>
<textarea id="textareaResult" cols="80" rows="40"></textarea>
</section>
<section id="sectCopyCodeToClipboard">
<button id="btnCopyCodeToClipboard" type="button">Copy Code to Clipboard</button>
</section>
</div>
</div>
<script>
/* **************************************************
* HTML Format variables
*/
var tableCellRowOpenTags = " <tr>\n"
+ " <td align=\"center\">\n";
var tableCellRowCloseTags = " </td>\n"
+ " </tr>\n";
var tableCellRowSeparator = " <tr><td height=\"6\" bgcolor=\"#F5F5F5\"></td></tr>\n";
var imgURLStart = "https://image.s5a.com/is/image/saks/";
var imgURLFmtSettings = "?scl=1&qlt=100&fmt=png";
var imgURLUserFilename = "";
var imgURLFullURL = "";
var modeShift = "Saks Fifth Avenue";
function changeTemplate() {
if ( document.getElementById( "dropdownTemplateSelect" ).value == "templateSFA" ) {
modeShift = "Saks Fifth Avenue";
} else {
modeShift = "Saks Off 5th";
}
}
/* **************************************************
* EVENT LISTENERS
*/
/* Event Listener for "Link Count"
*
* Generates a series of input field sets, based on the number provided in
* the "Link Count" input box.
* Each set will have two input fields:
* "URL:" User will provide the relative URL that the image will click through to.
* "Alt:" The Alt tag that accompanies the URL
*/
document.getElementById( "txtinputLinkCount" ).addEventListener( "blur" , function() {
document.getElementById( "divLinkRows" ).innerHTML = "";
var maxCount = document.getElementById( "txtinputLinkCount" ).value;
for( var i = 0; i < maxCount; i++ ) {
var linkSetParentDiv = document.createElement( "div" );
var linkSetParentDivID = "linkSetDiv" + (i+1);
linkSetParentDiv.setAttribute( "id", linkSetParentDivID );
var linkSetURLBoxID = "URLBox" + (i+1);
var linkSetURLBoxLabel = document.createElement( "label" );
linkSetURLBoxLabel.setAttribute( "for", linkSetURLBoxID );
linkSetURLBoxLabel.innerHTML = "Link " + (i+1) + ":";
var linkSetURLBox = document.createElement( "input" );
linkSetURLBox.setAttribute( "id", linkSetURLBoxID );
linkSetURLBox.setAttribute( "type", "text" );
linkSetURLBox.setAttribute( "style" , "width:40%;" );
var linkSetAltBox = document.createElement( "input" );
var linkSetAltBoxID = "AltBox" + (i+1);
var linkSetAltBoxLabel = document.createElement( "label" );
linkSetAltBoxLabel.setAttribute( "for", linkSetAltBoxID );
linkSetAltBoxLabel.innerHTML = "Alt Tag:";
linkSetAltBox.setAttribute( "id" , linkSetAltBoxID );
linkSetAltBox.setAttribute( "type", "text" );
linkSetParentDiv.innerHTML = linkSetURLBoxLabel.outerHTML + linkSetURLBox.outerHTML + " " + linkSetAltBoxLabel.outerHTML + linkSetAltBox.outerHTML;
document.getElementById( "divLinkRows" ).appendChild( linkSetParentDiv );
}
});
/* Event Listener for "Image Count"
*
* Generates a series of table row sets, based on the number provided in
* the "Image Count" input box
*/
document.getElementById( "txtinputImgCount" ).addEventListener( "blur", function() {
document.getElementById( "divHTMLRows" ).innerHTML = "";
var maxCount = document.getElementById( "txtinputImgCount" ).value;
for( var i = 0; i < maxCount; i++ ) {
var elemRandom = document.createElement( "p" );
elemRandom.innerHTML = "Image Slot " + ( i + 1 );
document.getElementById( "divHTMLRows" ).appendChild( elemRandom );
}
});
/* Event Listener for "Add HTML Row" button
*
*/
document.getElementById( "btnAddHTMLRow" ).addEventListener( "click", function() {
var elemParagraph = document.createElement( "p" );
elemParagraph.innerHTML = "Clicked!";
document.getElementById( "divHTMLRows" ).appendChild( elemParagraph );
});
/* Event Listener for "Add Row Separator" button */
document.getElementById( "btnAddRowSep" ).addEventListener( "click", function() {
var elemHR = document.createElement( "hr" );
document.getElementById( "divHTMLRows" ).appendChild( elemHR );
});
/* Event listener for "Generate Code" button */
document.getElementById( "btnGenerateCode" ).addEventListener( "click", function() {
document.getElementById( "textareaResult" ).value = modeShift;
});
/* Event Listener for "Copy Code To Clipboard" button */
document.getElementById( "btnCopyCodeToClipboard" ).addEventListener( "click", function() {
document.getElementById( "textareaResult" ).select();
document.execCommand( 'copy' );
});
</script>
</body>
</html>