<html>
<body>
<button style="background-color: #008CBA; color: white; border: 2px solid black; width: 100%; font-size: 24px;" id="generate">Generate ID</button>
<form id="req">
<div id="sections">
<divclasssection"><fieldset>
<option value="**MUST NOT**">MUST NOT</option>
| <legend>Requirement</legend>
<p><option value="**SHOULD**">SHOULD</option>
| <labelforid">Requirement ID:</label>**SHOULD NOT**">SHOULD NOT</option>
| <inputstyle="width: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" name="id" id="id" value="" type="text" readonly/>value="**MAY**">MAY</option>
</select>
</p>
<p>
<label for=" | keyword>Keyword>Introduced:</label>
<select style="width: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" name=" | keyword MUST>MUST< MUST NOT">MUST NOT<beijing">beijing</option>
| SHOULD>SHOULD< SHOULDNOT">SHOULD NOT<selected="selected">dublin</option>
| MAY">MAY<el alto">el alto</option>
</select>
</p>
<p>
<label for=" | target>Target>Impacts*:</label>
<select style="width: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" name=" | target">impacts" size="10" multiple>
| VNF>VNF< VNFC>VNFC< VNF PROVIDER">VNF PROVIDER< VNF HEAT ORCHESTRATION TEMPLATE">VNF HEAT ORCHESTRATION TEMPLATE< VNF PACKAGE">VNF PACKAGE< PNF>PNF< VNF or PNF">VNF or PNF<Documentation">Documentation</option>
| </select>
</p><option value="DCAE">DCAE</option>
| <p>
API">External API</option>
| <label for="introduced">Introduced:</label>
<option value="Holmes">Holmes</option>
| <selectstyle="width:100%;margin:8px0;box-sizing:border-box;padding:12px20px;"nameintroduced> amsterdam>amsterdam< beijing">beijing<Micro Bus">Micro Bus</option>
| casablanca>casablanca< dublin selected="selected">dublin< el alto">el alto< </select><option value="CLI">CLI</option>
| </p>
<option value="OOM">OOM</option>
| <p>
<label forimpacts">Impacts*:</label> <select style="width: 100%; margin: 8px 0;box-sizing:border-box;padding:12px20px;"nameimpacts"size=10" multiple> AAI>AAI< AAF>AAF< APPC>APPC< CLAMP>CLAMP< CCSDK>CCSDK< DCAE>DCAE< Documentation>Documentation< DCAE>DCAE< ExternalAPI>External API< Holmes>Holmes<<option value="Integration">Integration</option><option value="Logging">Logging</option>
<b>*Hold down the Ctrl (windows) / Command (Mac) | <option value="MicroBus">Micro Bus</option>
button to select multiple options for impacts.</b>
| <option value="Modeling">Modeling</option> <option value="MultiVIM">Multi VIM</option> <option valueMusic">Music</option>validation_mode">Validation Mode:</label>
<select | <option valueCLI">CLI</option>
<option value="OOM">OOM</option>width: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" name="validation_mode">
| OOF">OOF<" selected disabled hidden>Select Validation Mode</option>
| UsecaseUI>Usecase UI< Policy>Policy< <option value="Portal">Portal</option> <option value="SDNC">SDNC</option>
<option value="SDC">SDC</option> <option valueSO">SO</option>requirementText">Requirement Text:*</label>
<textarea | <option valueVFC">VFC</option>
<option value="VID">VID</option>width: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" id="requirementText" rows="10" cols="30" class="required" value="" type="text"></textarea>
</p>
| <optionvalue="VNFSDK">VNFSDK</option>
<optionvalue="VNFRQTS">VNFRQTS</option>
<b>*Make sure to add keyword entered in KEYWORD field in the requirement | <option value="VVP">VVP</option> select> p><p></div>
</form>
<button style="background-color: #008CBA; color: white; border: | *HolddowntheCtrl (windows) / Command (Mac) button to select multiple options for impacts.
</p>
<p>width: 100%; font-size: 24px;" onclick="formDataToObject(document.getElementById('req'))">Convert to RST</button>
<textarea style="width: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" rows="10" cols="30" id="formatted" readonly>
Formatted RST will Show here.
</textarea>
<script>
//define template
var template | <label for="validation_mode">Validation Mode:</label>= $('#sections .section:first').clone();
//define counter
var | <selectstyle"width:100%margin:8px0; box-sizing: border-box; padding: 12px 20px;" name="validation_mode">var url = "https://wiki.onap.org/download/attachments/60887371/needs.json?api=v2"
$('body').on('click', '#generate', function(e) {
| <option value="static">static</option> myFunction();
});
function | <option value="none">none</option>myFunction() {
get(url).then(JSON.parse).then(function(data) {
| </select>
console.log("It worked!", data);
| </p>
<p>
}).catch(function(err) {
// | <label for="requirementText">Requirement Text:*</label>
Instead, this happens:
console.log("It failed!", err);
| <textareastyle="width: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" name="requirementText" id="requirementText" rows="10" cols="30" value="" type="text">Enter Requirement text.</textarea>
}).then(function(data) {
var parsedData = parseIDs(data);
var finalIDs = | </p>
createIDs(1, parsedData);
console.log(finalIDs);
| <p>
*Make sure to surround your keyword with '**', for example, **MUST**.})
}
function get(url) {
// Return a new | </p>
</fieldset>
return new Promise(function(resolve, reject) | </div></div>
<form>
<button style="background-color: #008CBA; color: white; border: 2px solid black; width: 100%; font-size: 24px;" onclick="formDataToObject(document.getElementById('req'))">Convert to RST</button>XHR stuff
var req = new XMLHttpRequest();
| <textareastyle="width:100%;margin:8px0; box-sizing: border-box; padding: 12px 20px;" rows="10" cols="30" id="demo" readonly>
Formatted RST will Show here.
</textarea>
<script>
req.open('GET', url);
req.onload = function() {
// | define template
var template = $('#sections .section:first').clone();
This is called even on 404 etc
// | define counter
varsectionsCount=1;
varurl="https://wiki.onap.org/download/attachments/60887371/needs.json?api=v2"
$('body').on('click','#generate',function(e){
// Resolve the promise with the response | myFunction();});
$('body').on('click','#convert',functione) {convert();
});
functionmyFunction(){
get(url).then(JSON.parse).then(function(data) {
Otherwise reject with the status text
| console.log("It worked!", data);
// which will hopefully be a meaningful error
| returndata;
}).catch(function(err) {reject(Error(req.statusText));
| //Instead, this happens: console.log("It failed!", err) }).then(function(data) {varparsedData parseIDsdata;varfinalIDs = createIDs(1, parsedData reject(Error("Network Error"));
| console.log(finalIDs)alert(finalIDs);addSectionfinalIDsgeturl//Returnapromise.returnnew Promise(function(resolve, reject) {
version = jsonText.current_version;
result.add(Object.keys(jsonText["versions"][version]["needs"]));
| //DotheusualXHR stuff console.log(result);
return result;
| varreq=new XMLHttpRequest(); req.open('GET', url);function createIDs(numberOfIDs, parsedData) {
var addedIDs = [];
| req.onload=function(){
for (x = 0; x < numberOfIDs; x++) {
| //Thisiscalledevenon404etc
//socheckthestatusif (req.status == 200) {new_id = (Math.floor(Math.random() * 999999));
if | // Resolve the promise with the response text
(new_id < 100000) {
new_id = ('000000' | resolve(req.response else { // Otherwise reject with the status text // which will hopefully be a meaningful error reject(Error(req.statusText(parsedData.has(new_id));
addedIDs[x] | } ; // Handle network errorsreq.onerror= function addSection(finalIDs) {
document.getElementById('id').value = finalIDs;
| reject(Error("NetworkError"));
};formDataToObject(elForm) {
| Make the request(!elForm instanceof Element) return;
var fields = | reqsend();querySelectorAll('input, select, textarea'),
| });
}
functionparseIDsjsonText){
i = 0, imax = fields.length; i < | var result = new Set();
versionjsonText.current_version;result.add(Object.keys(jsonText["versions"][version]["needs"]));
console.log(result)returnresult;
if (field.type === 'button' | }
function createIDs(numberOfIDs, parsedData) {|| field.type === 'image' || field.type === 'submit' || !sKey) continue;
| varaddedIDs = [];for(x=0;x < numberOfIDs; x++) {
var new_id""do{
new_id=(Math.floor(Math.random() * 999999));new_id < 100000) {o[sKey] === undefined) o[sKey] = '';
| new_id = ('000000' + new_id).slice(-6);
if (field.checked) o[sKey] = field.value;
| }new_id = ("R-" + new_id);
}
while (parsedData.has(new_id))addedIDs[x]=new_id;
}
return addedIDs;
for (var j = 0, jmax = field.options.length; j < jmax; ++j) {
| }
functionaddSection(finalIDs){
document.getElementById('id').value = finalIDs;
(field.options[j].selected) a.push(field.options[j].value);
| }
function formDataToObject(elForm) {
//if(!elForm instanceof Element) returnvarfields=elForm.querySelectorAll('input,select, textarea'),o={};for(vari=0, imaxfieldslengthi<imax;++i){
varfield=fields[i],sKey=field.name|| field.id if (field.type === 'button' || field.type === 'image' || field.type === 'submit' || !sKey) continue;o;
}
function buildRST(o) {
var rst | switch(fieldtype) { req::\n";
var arrayOfLines | case 'checkbox':
= $('#requirementText').val().split('\n');
for (y in o) {
| o[sKey]=+field.checked;
if (y == "requirementText") {
| break;
for (z in arrayOfLines) {
| case'radio':
if(o[sKey] === undefined) o[sKey] = '' if (field.checked) o[sKey] = field.value; break;
case 'select-multiple':
+= " :" + y + ": " + o[y] + | var a = [];
for(varj=0,jmax=field.options.length; j < jmax; ++j) {
document.getElementById("formatted").innerHTML = rst;
}
function formcheck() {
var l | iffield.options[j].selected) a.push(field.options[j].value)".required").length;
var result | } o[sKey] = a;< l; i++) {
//Push each element to the | break; default:
($('.required').eq(i).val() == "") {
| o[sKey] = field.valueresult.push($('.required')[i].name);
}
}
if | buildRST(o);
returno;
}
function buildRST(o) {alert("Please enter a value in: " + result);
| varrst="..req::\n\n";
vararrayOfLines= $('#requirementText').val().split('\n')for(y in o) {addedTarget, addedKeword;
var text | if(y == "requirementText") {
$('#requirementText');
switch (fieldClicked.id) {
| for(zinarrayOfLines){
rst+"\n'The ' + fieldClicked.value | "+ arrayOfLines[z] } text.val(text.val() + addedTarget);
| }else{rst+=":"+y+": " + o[y] + "\n" text.val(text.val() + fieldClicked.value);
| }
}document.getElementById("demo").innerHTML = rst;}
}
</script>
</body>
</html>
|
|