Author: humbedooh Date: Wed Jul 31 12:19:01 2019 New Revision: 1864046 URL: http://svn.apache.org/viewvc?rev=1864046&view=rev Log: Initial check-in of a wizard-style helper, work in progress! Added: comdev/reporter.apache.org/trunk/site/wizard/ comdev/reporter.apache.org/trunk/site/wizard/css/ comdev/reporter.apache.org/trunk/site/wizard/css/wizard.css comdev/reporter.apache.org/trunk/site/wizard/index.html comdev/reporter.apache.org/trunk/site/wizard/js/ comdev/reporter.apache.org/trunk/site/wizard/js/source/ comdev/reporter.apache.org/trunk/site/wizard/js/source/base-http-extensions.js comdev/reporter.apache.org/trunk/site/wizard/js/source/base-js-extensions.js comdev/reporter.apache.org/trunk/site/wizard/js/source/build.sh comdev/reporter.apache.org/trunk/site/wizard/js/source/datepicker.js comdev/reporter.apache.org/trunk/site/wizard/js/source/generators.js comdev/reporter.apache.org/trunk/site/wizard/js/source/init.js comdev/reporter.apache.org/trunk/site/wizard/js/source/primer.js comdev/reporter.apache.org/trunk/site/wizard/js/source/reportdate.js comdev/reporter.apache.org/trunk/site/wizard/js/source/scaffolding-html.js comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js comdev/reporter.apache.org/trunk/site/wizard/steps.json Added: comdev/reporter.apache.org/trunk/site/wizard/css/wizard.css URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/css/wizard.css?rev=1864046&view=auto ============================================================================== --- comdev/reporter.apache.org/trunk/site/wizard/css/wizard.css (added) +++ comdev/reporter.apache.org/trunk/site/wizard/css/wizard.css Wed Jul 31 12:19:01 2019 @@ -0,0 +1,159 @@ +.wizard-step { + width: 64px !important; + height: 64px; + font-size: 36px !important; + border-radius: 50%; + border: 3px solid #666; + display: inline-block; + color: #666; + text-align: center; + margin-left: 18px; + margin-top: 0px; + padding-top: 3px; + position: relative; + z-index: 3; + background: #FFF; +} + + +.wizard-step-wrapper { + display: inline-block; + color: #333; + width: 100px; + height: 120px; +} + +.wizard-step-wrapper:hover > * { + cursor: pointer; + color: #090; + border-color: #090 !important; + +} +.wizard-step-wrapper:hover .wizard-step { + background-color: #090; + color: #EEE !important; + position: relative; + z-index: 3; +} + +.wizard-step-text { + display: inline-block; + width: 100px; + height: 40px; + font-size: 12px; + line-height: 18px; + margin-left: 9px; + text-align: center; +} + +.wizard-step.active { + color: #EEE; + background: #369; + border-color: #369; +} + +.wizard-line { + border-top: 3px solid #666; + width: 48px; + display: inline-block; + height: 88px; + margin-bottom: -40px; + margin-left: -14px; + margin-right: -32px; + z-index: 0; + position: relative; +} + + +.done { + color: #9BE; + border-color: #9BE; +} + + +#steps { + width: 680px; + border: 1.5px solid #3339; + background: #EEE; + border-radius: 10px; + margin: 10px auto; + padding: 10px; + height: 110px; + text-align: center; +} + +#wizard-content { + width: 680px; + border: 1.5px solid #3339; + background: #FFE; + border-radius: 10px; + margin: 10px auto; + padding: 10px; + height: 480px; + font-size: 0.85rem; +} + +#step_text { + margin-bottom: 10px !important; +} + + +.loader, +.loader:before, +.loader:after { + background: #000d50; + -webkit-animation: load1 1s infinite ease-in-out; + animation: load1 1s infinite ease-in-out; + width: 1em; + height: 4em; +} +.loader { + color: #000d50; + text-indent: -9999em; + margin: 88px auto; + position: relative; + font-size: 11px; + -webkit-transform: translateZ(0); + -ms-transform: translateZ(0); + transform: translateZ(0); + -webkit-animation-delay: -0.16s; + animation-delay: -0.16s; +} +.loader:before, +.loader:after { + position: absolute; + top: 0; + content: ''; +} +.loader:before { + left: -1.5em; + -webkit-animation-delay: -0.32s; + animation-delay: -0.32s; +} +.loader:after { + left: 1.5em; +} +@-webkit-keyframes load1 { + 0%, + 80%, + 100% { + box-shadow: 0 0; + height: 4em; + } + 40% { + box-shadow: 0 -2em; + height: 5em; + } +} +@keyframes load1 { + 0%, + 80%, + 100% { + box-shadow: 0 0; + height: 4em; + } + 40% { + box-shadow: 0 -2em; + height: 5em; + } +} Added: comdev/reporter.apache.org/trunk/site/wizard/index.html URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/index.html?rev=1864046&view=auto ============================================================================== --- comdev/reporter.apache.org/trunk/site/wizard/index.html (added) +++ comdev/reporter.apache.org/trunk/site/wizard/index.html Wed Jul 31 12:19:01 2019 @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + +ASF Board Report Wizard + + + + +
+

Loading base data..

+
+ +
+ + + + + + + + + + + + + + Added: comdev/reporter.apache.org/trunk/site/wizard/js/source/base-http-extensions.js URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/source/base-http-extensions.js?rev=1864046&view=auto ============================================================================== --- comdev/reporter.apache.org/trunk/site/wizard/js/source/base-http-extensions.js (added) +++ comdev/reporter.apache.org/trunk/site/wizard/js/source/base-http-extensions.js Wed Jul 31 12:19:01 2019 @@ -0,0 +1,118 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + +// URL calls currently 'in escrow'. This controls the spinny wheel animation +var async_escrow = {} +var async_maxwait = 250; // ms to wait before displaying spinner +var async_status = 'clear'; +var async_cache = {} + +// Escrow spinner check +async function escrow_check() { + let now = new Date(); + let show_spinner = false; + for (var k in async_escrow) { + if ( (now - async_escrow[k]) > async_maxwait ) { + show_spinner = true; + break; + } + } + // Fetch or create the spinner + let spinner = document.getElementById('spinner'); + if (!spinner) { + spinner = new HTML('div', { id: 'spinner', class: 'spinner'}); + spinwheel = new HTML('div', {id: 'spinwheel', class: 'spinwheel'}); + spinner.inject(spinwheel); + spinner.inject(new HTML('h2', {}, "Loading, please wait..")); + document.body.appendChild(spinner); + } + // Show or don't show spinner? + if (show_spinner) { + spinner.style.display = 'block'; + if (async_status === 'clear') { + console.log("Waiting for JSON resource, deploying spinner"); + async_status = 'waiting'; + } + } else { + spinner.style.display = 'none'; + if (async_status === 'waiting') { + console.log("All URLs out of escrow, dropping spinner"); + async_status = 'clear'; + } + } +} + +async function async_snap(error) { + msg = await error.text(); + msg = msg.replace(/<.*?>/g, ""); // strip HTML tags + modal("An error occured", "An error code %u occured while trying to fetch %s:\n%s".format(error.status, error.url, msg), "error"); +} + + +// Asynchronous GET call +async function GET(url, callback, state) { + console.log("Fetching JSON resource at %s".format(url)) + let pkey = "GET-%s-%s".format(callback, url); + let res = undefined; + let res_json = undefined; + state = state || {}; + state.url = url; + if (state && state.cached === true && async_cache[url]) { + console.log("Fetching %s from cache".format(url)); + res_json = async_cache[url]; + } + else { + try { + console.log("putting %s in escrow...".format(url)); + async_escrow[pkey] = new Date(); // Log start of request in escrow dict + const rv = await fetch(url, {credentials: 'same-origin'}); // Wait for resource... + + // Since this is an async request, the request may have been canceled + // by the time we get a response. Only do callback if not. + if (async_escrow[pkey] !== undefined) { + delete async_escrow[pkey]; // move out of escrow when fetched + res = rv; + } + } + catch (e) { + delete async_escrow[pkey]; // move out of escrow if failed + console.log("The URL %s could not be fetched: %s".format(url, e)); + modal("An error occured", "An error occured while trying to fetch %s:\n%s".format(url, e), "error"); + } + } + if (res !== undefined || res_json !== undefined) { + // We expect a 2xx return code (usually 200 or 201), snap otherwise + if ((res_json) || (res.status >= 200 && res.status < 300)) { + console.log("Successfully fetched %s".format(url)) + if (res_json) { + js = res_json; + } else { + js = await res.json(); + async_cache[url] = js; + } + if (callback) { + callback(state, js); + } else { + console.log("No callback function was registered for %s, ignoring result.".format(url)); + } + } else { + console.log("URL %s returned HTTP code %u, snapping!".format(url, res.status)); + async_snap(res); + } + } +} Added: comdev/reporter.apache.org/trunk/site/wizard/js/source/base-js-extensions.js URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/source/base-js-extensions.js?rev=1864046&view=auto ============================================================================== --- comdev/reporter.apache.org/trunk/site/wizard/js/source/base-js-extensions.js (added) +++ comdev/reporter.apache.org/trunk/site/wizard/js/source/base-js-extensions.js Wed Jul 31 12:19:01 2019 @@ -0,0 +1,139 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +/** + * String formatting prototype + * A'la printf + */ + +String.prototype.format = function() { + let args = arguments; + let n = 0; + let t = this; + let rtn = this.replace(/(?!%)?%([-+]*)([0-9.]*)([a-zA-Z])/g, function(m, pm, len, fmt) { + len = parseInt(len || '1'); + // We need the correct number of args, balk otherwise, using ourselves to format the error! + if (args.length <= n) { + let err = "Error interpolating string '%s': Expected at least %u argments, only got %u!".format(t, n+1, args.length); + console.log(err); + throw err; + } + let varg = args[n]; + n++; + switch (fmt) { + case 's': + if (typeof(varg) == 'function') { + varg = '(function)'; + } + return varg; + // For now, let u, d and i do the same thing + case 'd': + case 'i': + case 'u': + varg = parseInt(varg).pad(len); // truncate to Integer, pad if needed + return varg; + } + }); + return rtn; +} + + +/** + * Number prettification prototype: + * Converts 1234567 into 1,234,567 etc + */ + +Number.prototype.pretty = function(fix) { + if (fix) { + return String(this.toFixed(fix)).replace(/(\d)(?=(\d{3})+\.)/g, '$1,'); + } + return String(this.toFixed(0)).replace(/(\d)(?=(\d{3})+$)/g, '$1,'); +}; + + +/** + * Number padding + * usage: 123.pad(6) -> 000123 + */ + +Number.prototype.pad = function(n) { + var str; + str = String(this); + + /* Do we need to pad? if so, do it using String.repeat */ + if (str.length < n) { + str = "0".repeat(n - str.length) + str; + } + return str; +}; + + +/* Func for converting a date to YYYY-MM-DD HH:MM */ + +Date.prototype.ISOBare = function() { + var M, d, h, m, y; + y = this.getFullYear(); + m = (this.getMonth() + 1).pad(2); + d = this.getDate().pad(2); + h = this.getHours().pad(2); + M = this.getMinutes().pad(2); + return y + "-" + m + "-" + d + " " + h + ":" + M; +}; + + +/* isArray: function to detect if an object is an array */ + +isArray = function(value) { + return value && typeof value === 'object' && value instanceof Array && typeof value.length === 'number' && typeof value.splice === 'function' && !(value.propertyIsEnumerable('length')); +}; + + +/* isHash: function to detect if an object is a hash */ + +isHash = function(value) { + return value && typeof value === 'object' && !isArray(value); +}; + + +/* Remove an array element by value */ + +Array.prototype.remove = function(val) { + var i, item, j, len; + for (i = j = 0, len = this.length; j < len; i = ++j) { + item = this[i]; + if (item === val) { + this.splice(i, 1); + return this; + } + } + return this; +}; + + +/* Check if array has value */ +Array.prototype.has = function(val) { + var i, item, j, len; + for (i = j = 0, len = this.length; j < len; i = ++j) { + item = this[i]; + if (item === val) { + return true; + } + } + return false; +}; + + Added: comdev/reporter.apache.org/trunk/site/wizard/js/source/build.sh URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/source/build.sh?rev=1864046&view=auto ============================================================================== --- comdev/reporter.apache.org/trunk/site/wizard/js/source/build.sh (added) +++ comdev/reporter.apache.org/trunk/site/wizard/js/source/build.sh Wed Jul 31 12:19:01 2019 @@ -0,0 +1,24 @@ +echo "Combining JS..." +echo '/* + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +// THIS IS AN AUTOMATICALLY COMBINED FILE. PLEASE EDIT source/*.js!! +' > ../wizard.js +for f in `ls *.js`; do + printf "\n\n/******************************************\n Fetched from source/${f}\n******************************************/\n\n" >> ../wizard.js + perl -0pe 's/\/\*.*?\*\/[\r\n]*//sm' ${f} >> ../wizard.js +done +echo "Done!" Added: comdev/reporter.apache.org/trunk/site/wizard/js/source/datepicker.js URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/source/datepicker.js?rev=1864046&view=auto ============================================================================== --- comdev/reporter.apache.org/trunk/site/wizard/js/source/datepicker.js (added) +++ comdev/reporter.apache.org/trunk/site/wizard/js/source/datepicker.js Wed Jul 31 12:19:01 2019 @@ -0,0 +1,739 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; +var datepicker_spawner = null +var calendarpicker_spawner = null +var units = { + w: 'week', + d: 'day', + M: 'month', + y: 'year' +} + +function fixupPicker(obj) { + obj.addEventListener("focus", function(event){ + $('html').on('hide.bs.dropdown', function (e) { + return false; + }); + }); + obj.addEventListener("blur", function(event){ + $('html').unbind('hide.bs.dropdown') + }); +} +// makeSelect: Creates a