| ... | ... |
@@ -20,18 +20,34 @@ |
| 20 | 20 |
} |
| 21 | 21 |
</style> |
| 22 | 22 |
<script> |
| 23 |
- function getQueryParam(variable, defaultValue) {
|
|
| 23 |
+ function getRawQueryParam(variable, defaultValue) {
|
|
| 24 | 24 |
var query = location.search.substring(1); |
| 25 | 25 |
var vars = query.split("&");
|
| 26 | 26 |
for (var i = 0; i < vars.length; i++) {
|
| 27 | 27 |
var pair = vars[i].split("=");
|
| 28 | 28 |
if (pair[0] === variable) {
|
| 29 |
- return decodeURIComponent(pair[1]); |
|
| 29 |
+ return pair[1]; |
|
| 30 | 30 |
} |
| 31 | 31 |
} |
| 32 | 32 |
return defaultValue; |
| 33 | 33 |
} |
| 34 | 34 |
|
| 35 |
+ function getQueryParam(variable, defaultValue) {
|
|
| 36 |
+ return decodeURIComponent(getRawQueryParam(variable, defaultValue)); |
|
| 37 |
+ } |
|
| 38 |
+ |
|
| 39 |
+ function readAndEncodeList(elementId) {
|
|
| 40 |
+ var cn = document.getElementById(elementId).childNodes; |
|
| 41 |
+ var result = []; |
|
| 42 |
+ var i; |
|
| 43 |
+ for (i = 0; i < cn.length; i++) {
|
|
| 44 |
+ if (cn[i].className === "item") {
|
|
| 45 |
+ result.push(encodeURIComponent(cn[i].childNodes[0].nodeValue)); |
|
| 46 |
+ } |
|
| 47 |
+ } |
|
| 48 |
+ return result; |
|
| 49 |
+ } |
|
| 50 |
+ |
|
| 35 | 51 |
function onSubmit() {
|
| 36 | 52 |
// Set the return URL depending on the runtime environment |
| 37 | 53 |
var return_to = getQueryParam("return_to", "pebblejs://close#");
|
| ... | ... |
@@ -49,6 +65,7 @@ |
| 49 | 65 |
"autoClose" : document.getElementById("autoClose").checked ? 1 : 0,
|
| 50 | 66 |
"wakeupTime" : document.getElementById("wakeupEnable").checked
|
| 51 | 67 |
? document.getElementById("wakeupTime").value : "-1",
|
| 68 |
+ "extraFields" : readAndEncodeList("extraFields").join(","),
|
|
| 52 | 69 |
} |
| 53 | 70 |
|
| 54 | 71 |
if (!document.getElementById("bundleEnable").checked) {
|
| ... | ... |
@@ -211,6 +228,22 @@ |
| 211 | 228 |
</div> |
| 212 | 229 |
</div> |
| 213 | 230 |
|
| 231 |
+ <div class="item-container"> |
|
| 232 |
+ <div class="item-container-header">Extra Form Fields</div> |
|
| 233 |
+ <div class="item-container-content"> |
|
| 234 |
+ <div class="item-dynamic-list" id="extraFields"> |
|
| 235 |
+ </div> |
|
| 236 |
+ </div> |
|
| 237 |
+ <div class="item-container-footer"> |
|
| 238 |
+ Extra fields are sent with constant values along with the sent data. |
|
| 239 |
+ It can be used to provide e.g. an authentication token, or an |
|
| 240 |
+ identification field. Items in the list above must be of the form |
|
| 241 |
+ "name=value" (without quotes), and then part before the equal sign is |
|
| 242 |
+ field name and the part after is its value. Entries without equal sign |
|
| 243 |
+ are considered as a whole field name with empty value. |
|
| 244 |
+ </div> |
|
| 245 |
+ </div> |
|
| 246 |
+ |
|
| 214 | 247 |
<div class="item-container"> |
| 215 | 248 |
<div class="button-container"> |
| 216 | 249 |
<input id="submitButton" type="button" class="item-button" value="SUBMIT" onClick="onSubmit()"> |
| ... | ... |
@@ -252,6 +285,15 @@ |
| 252 | 285 |
updateBundleVisibility(); |
| 253 | 286 |
updateSignVisibility(); |
| 254 | 287 |
updateWakeupVisibility(); |
| 288 |
+ |
|
| 289 |
+ var initExtraFields = ("," + getRawQueryParam("extra", "")).split(",");
|
|
| 290 |
+ initExtraFields.shift(); |
|
| 291 |
+ for (var i = 0; i < initExtraFields.length; i++) {
|
|
| 292 |
+ var newNode = document.createElement("label");
|
|
| 293 |
+ newNode.className = "item"; |
|
| 294 |
+ newNode.appendChild(document.createTextNode(decodeURIComponent(initExtraFields[i]))); |
|
| 295 |
+ document.getElementById("extraFields").appendChild(newNode);
|
|
| 296 |
+ } |
|
| 255 | 297 |
</script> |
| 256 | 298 |
</body> |
| 257 | 299 |
</html> |