forked from LaconicNetwork/kompose
#### What type of PR is this? <!-- Add one of the following kinds: /kind bug /kind documentation /kind feature --> /kind cleanup #### What this PR does / why we need it: Fixes the current broken examples by: * Removing all the old incompatible ones (we do not really support v3 anymore or v2... since switching libraries) * Uses quay.io/kompose/web as our front end example which is a fork of the guestbook-go kubernetes examples #### Which issue(s) this PR fixes: <!-- *Automatically closes linked issue when PR is merged. Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`. --> Closes https://github.com/kubernetes/kompose/issues/1757 #### Special notes for your reviewer: Test using docker-compose (you'll see it come up!), then try with kompose :) Signed-off-by: Charlie Drage <charlie@charliedrage.com>
48 lines
1.6 KiB
JavaScript
48 lines
1.6 KiB
JavaScript
$(document).ready(function() {
|
|
var headerTitleElement = $("#header h1");
|
|
var entriesElement = $("#guestbook-entries");
|
|
var formElement = $("#guestbook-form");
|
|
var submitElement = $("#guestbook-submit");
|
|
var entryContentElement = $("#guestbook-entry-content");
|
|
var hostAddressElement = $("#guestbook-host-address");
|
|
|
|
var appendGuestbookEntries = function(data) {
|
|
entriesElement.empty();
|
|
$.each(data, function(key, val) {
|
|
entriesElement.append("<p>" + val + "</p>");
|
|
});
|
|
}
|
|
// On submission, clear the input field and add the entry to the guestbook.
|
|
var handleSubmission = function(e) {
|
|
e.preventDefault();
|
|
var entryValue = entryContentElement.val()
|
|
if (entryValue.length > 0) {
|
|
entriesElement.append("<p>...</p>");
|
|
$.getJSON("rpush/guestbook/" + entryValue, appendGuestbookEntries);
|
|
}
|
|
// Clear entryContentElement input field on click.
|
|
entryContentElement.val("");
|
|
return false;
|
|
}
|
|
|
|
var colors = ["#1f77b4", "#2ca02c", "#d62728", "#9467bd", "#ff7f0e"];
|
|
var randomColor = colors[Math.floor(5 * Math.random())];
|
|
(function setElementsColor(color) {
|
|
headerTitleElement.css("color", color);
|
|
entryContentElement.css("box-shadow", "inset 0 0 0 2px " + color);
|
|
submitElement.css("background-color", color);
|
|
})(randomColor);
|
|
|
|
submitElement.click(handleSubmission);
|
|
formElement.submit(handleSubmission);
|
|
hostAddressElement.append(document.URL);
|
|
|
|
// Poll every second.
|
|
(function fetchGuestbook() {
|
|
$.getJSON("lrange/guestbook").done(appendGuestbookEntries).always(
|
|
function() {
|
|
setTimeout(fetchGuestbook, 1000);
|
|
});
|
|
})();
|
|
});
|