<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"><divid="sections">
<divclasssection">
**MUST NOT**">MUST NOT</option>
| <fieldset>
<option value="**SHOULD**">SHOULD</option>
| <p>
<label forid">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>
<option value="VNF">VNF</option>
<option value="VNFC">VNFC</option> VNF PROVIDER">VNF PROVIDER< VNF HEAT ORCHESTRATION TEMPLATE">VNF HEAT ORCHESTRATION TEMPLATE< VNF PACKAGE">VNF PACKAGE< PNF>PNF< VNF or PNF">VNF or PNF<</select> <option value="DCAE">DCAE</option>
| </p>
<option value="Documentation">Documentation</option>
| <p>
<label forintroduced>Introduced:<label><selectstyle"width: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" name="introduced">"External API">External API</option>
<option value="Holmes">Holmes</option>
| amsterdam>amsterdam< beijing>beijing< casablanca">casablanca<Micro Bus">Micro Bus</option>
| ="dublin" selectedselected>dublin< elalto>elalto< </select><option value="Music">Music</option>
| </p>
<option value="CLI">CLI</option>
| <p>
<label forimpacts">Impacts*:</label><selectstylewidth: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" name="impacts" size="10" multiple>
OOF">OOF</option>
<option value="Usecase UI">Usecase UI</option>
<option value=" | 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><optionvalue="Logging">Logging</option>
<b>*Hold down the Ctrl (windows) / Command | <option value="MicroBus">Micro Bus</option>
(Mac) 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<<optionvalue="Portal">Portal</option>
<option value="SDNC">SDNC</option>
<optionvalueSDC">SDC</option>requirementText">Requirement Text:*</label>
<textarea | <option valueSO">SO</option>
<option value="VFC">VFC</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="VID">VID</option>
<optionvalue="VNFSDK">VNFSDK</option>
<b>*Make sure to add keyword entered in KEYWORD field in the requirement | <option value="VNFRQTS">VNFRQTS</option> <option value="VVP">VVP</option>
select> p>form>
<button style="background-color: #008CBA; color: white; border: 2px solid black; width: | <p>
100%; font-size: 24px;" onclick="formDataToObject(document.getElementById('req'))">Convert to RST</button>
<textarea style="width: 100%; margin: 8px | *Hold down the Ctrl (windows) / Command (Mac) button to select multiple options for impacts.
0; box-sizing: border-box; padding: 12px 20px;" rows="10" cols="30" id="formatted" readonly>
Formatted RST will Show here.
</textarea>
<script>
| <p>define template
var template = | <p>$('#sections .section:first').clone();
//define counter
var | <labelfor"validation_mode">Validation Mode:</label> <select style="width: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" name="validation_mode">= "https://wiki.onap.org/download/attachments/60887371/needs.json?api=v2"
$('body').on('click', '#generate', function(e) {
myFunction();
| <option value="static">static</option>});
function myFunction() {
| <option value="none">none</option>get(url).then(JSON.parse).then(function(data) {
console.log("It worked!", data);
| </select>
</p>
<p>
// Instead, this happens:
| <label for="requirementText">Requirement Text:*</label> console.log("It failed!", err);
}).then(function(data) {
| <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>
var parsedData = parseIDs(data);
var finalIDs = createIDs(1, parsedData);
console.log(finalIDs);
| </p>
<p>*Makesuretosurroundyourkeywordwith '**', for example, **MUST**// Return a new promise.
return new Promise(function(resolve, reject) | </p> </fieldset>
<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>
<textarea style="width: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" rows="10" cols="30" id="demo" readonly>
Formatted RST will Show here.
</textarea>
<script>
//define template
var req = new XMLHttpRequest();
req.open('GET', url);
req.onload = function() {
// This is called even on 404 etc
| vartemplate= $('#sections .section:first').clone();//definecounter
var sectionsCount = 1;varurl="https://wiki.onap.org/download/attachments60887371needs.json?api=v2"
$('body').on('click', '#generate', function(e) {
Resolve the promise with the response text
| myFunction(});
$('body').on('click', '#convert', function(e)convert();
});
function myFunction() {
// Otherwise reject with the status text
| get(url).then(JSON.parse).then(function(data){
// which will hopefully be a meaningful | console.log("It worked!", data);
return data reject(Error(req.statusText));
| }).catch(function(err){
//Instead,thishappens: console.log("It failed!", err);}).then(datavarparsedData = parseIDs(data reject(Error("Network Error"));
| varfinalIDs=createIDs(1,parsedData);
console.log(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>
|
|