<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">
<fieldset><legend>Requirement<legend>id>Requirement ID<input<select style="width: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" name=" | id" id="id" value="" type="text" readonly/</p>
<p>
<label for="keyword">Keyword:</label>
<option value="amsterdam">amsterdam</option>
| <selectstyle="width:100%;margin:8px0;box-sizing:border-box;padding:12px20px;"namekeyword> MUST>MUST< MUSTNOT">MUST NOT<selected="selected">dublin</option>
| SHOULD">SHOULD<el alto">el alto</option>
</select>
| <option value="SHOULD NOT">SHOULD NOT</option>
<option value="MAY">MAY</option> <p>
<label for="impacts">Impacts*:</ | select></p>
<p>
<select style="width: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" name="impacts" size="10" multiple>
| <labelfortarget>Target:<label><selectstyle="width: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" name="target">
<option value="AAF">AAF</option>
<option value=" | VNF>VNF< VNFC>VNFC< VNF PROVIDER">VNF PROVIDER< VNF HEAT ORCHESTRATION TEMPLATE">VNF HEAT ORCHESTRATION TEMPLATE< VNF PACKAGE">VNF PACKAGE<Documentation">Documentation</option>
| PNF>PNF< VNFor PNF>VNFor PNF< </select>
<option value="Holmes">Holmes</option>
| </p>
<p>
<option value="Integration">Integration</option>
| <labelforintroduced>Introduced:<label><selectstylewidth: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" name="introduced">Micro Bus">Micro Bus</option>
<option value="Modeling">Modeling</option>
| amsterdam">amsterdam<Multi VIM">Multi VIM</option>
| beijing>beijing< casablanca>casablanca< dublin>dublin< el alto">el alto<</select>
<option value="Usecase UI">Usecase UI</option>
| </p>
<option value="Policy">Policy</option>
| <p>
<label forimpacts">Impacts*:</label>Portal">Portal</option>
<option value="SDNC">SDNC</option>
| <selectstyle="width:100%;margin:8px0;box-sizing:border-box;padding:12px20px;" name="impacts" size10" multiple> AAI>AAI< AAF>AAF< APPC>APPC< CLAMP>CLAMP< CCSDK>CCSDK< DCAE>DCAE<<option value="Documentation">Documentation</option><option value="DCAE">DCAE</option>
<b>*Hold down the Ctrl (windows) / Command (Mac) button | <option value="ExternalAPI">External API</option>
to select multiple options for impacts.</b>
| <option value="Holmes">Holmes</option> <option value="Integration">Integration</option> <option valueLogging">Logging</option>validation_mode">Validation Mode:</label>
<select | <option valueMicroBus">Micro Bus</option>
<option value="Modeling">Modeling</option>
width: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" name="validation_mode">
<option value=" | MultiVIM">Multi VIM<" selected disabled hidden>Select Validation Mode</option>
| Music>Music< CLI>CLI<<option value="OOM">OOM</option>
<optionvalue="OOF">OOF</option>
<optionvalueUsecaseUI>Usecase UI</option>>Requirement Text:*</label>
<textarea | <option valuePolicy">Policy</option>
<option value="Portal">Portal</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="SDNC">SDNC</option>
<optionvalue="SDC">SDC</option>
<b>*Make sure to add keyword entered in KEYWORD field in the requirement | <option value="SO">SO</option> <option value="VFC">VFC</option><option value="VID">VID</option> </div>
</div>
</form>
<button | <option value="VNFSDK">VNFSDK</option>
<option value="VNFRQTS">VNFRQTS</option>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;" | <option value="VVP">VVP</option>
rows="10" cols="30" id="formatted" readonly>
Formatted RST will Show here.
</textarea>
<script>
| <select>define template
var template = $('#sections .section:first').clone();
| </p>
<p>
sectionsCount = 1;
var url = "https://wiki.onap.org/download/attachments/60887371/needs.json?api=v2"
| *Hold downtheCtrlwindows) / Command (Mac) button to select multiple options for impacts.
'body').on('click', '#generate', function(e) {
myFunction();
});
| </p>
<p>
get(url).then(JSON.parse).then(function(data) {
| <label for="validation_mode">Validation Mode:</label>console.log("It worked!", data);
| <select style="width: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" name="validation_mode">return data;
}).catch(function(err) {
// Instead, this happens:
| <optionvalue="static">static</option>
console.log("It failed!", err);
| <option value="none">none</option>}).then(function(data) {
var parsedData | </select> </p>
var finalIDs = createIDs(1, parsedData);
| <p>
<labelfor="requirementText">Requirement Text:*</label> addSection(finalIDs);
})
}
| <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>function get(url) {
// Return a new promise.
return new Promise(function(resolve, reject) | </p></fieldset>// Do the usual XHR stuff
| </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 req.open('GET', url);
req.onload = function() {
// This is called even on 404 etc
// so check the status
| vartemplate=$('#sections.section:first').clone();
//define countervarsectionsCount=1;
varurl= "https://wiki.onap.org/download/attachments/60886532/needs.json?api=v2"
$('body').on('click', '#generate', function(e) {
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){
console.log("It worked!", data);returndata;
}).catch(function(err) {
reject(Error(req.statusText));
| //Instead,thishappens:
console.log("Itfailed!",err);
}).then(function(data) {varparsedData parseIDsdata;varfinalIDs = createIDs(1, parsedData reject(Error("Network Error"));
| console.log(finalIDs)alert(finalIDs);addSectionfinalIDsgeturl//Returnapromise.
return new Promise(function(resolve, reject) {// Do the usual XHR stuff
= jsonText.current_version;
result.add(Object.keys(jsonText["versions"][version]["needs"]));
| varreq=newXMLHttpRequest req.open('GET', url)req.onload= function createIDs(numberOfIDs, parsedData) {
var addedIDs | // This is called even on 404 etc
= [];
for (x = 0; x < numberOfIDs; | // so check the status
if(req.status==200){
//Resolvethepromise with the response text
= (Math.floor(Math.random() * 999999));
if (new_id < | resolve(req.response);}else{
new_id = ('000000' + new_id).slice(-6);
| //Otherwiserejectwiththestatustext
// which will hopefully be a meaningful error
rejectError(req.statusTextparsedData.has(new_id));
addedIDs[x] = | } ; // Handle network errorsreq.onerror=() {
reject(Error("Network Error")); addSection(finalIDs) {
document.getElementById('id').value = | }//Make the requestfunction formDataToObject(elForm) {
//if | req.send()(!elForm instanceof Element) return;
var fields = elForm.querySelectorAll('input, select, | }; }
function parseIDs(jsonText)resultnew Set();
0, imax = fields.length; i < imax; ++i) {
| varversion=jsonText.current_version;
result.add(Object.keys(jsonText["versions"][version]["needs"]));
= fields[i],
sKey = field.name || | 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;
| }
break;
case 'select-multiple':
| new_id=("R-"+new_id);
}
whileparsedData.has(new_id));
addedIDs[x] = new_id;var j = 0, jmax = field.options.length; j < jmax; ++j) {
| }
return addedIDsif (field.options[j].selected) a.push(field.options[j].value);
| }
functionaddSection(finalIDs){document.getElementById('id').value=finalIDs;
}
function formDataToObject(elForm) {//if (!elForm instanceof Element) return;
varfields=elForm.querySelectorAll('input,select,textarea'),
{}for(var i = 0, imax = fields.length; i < imax; ++i) {
varfield= fields[i], //formcheck();
buildRST(o);
| sKey=field.name|| field.idiffield.type === 'button' || field.type === 'image' || field.type === 'submit' || !sKey) continueo) {
var rst = ".. req::\n";
var arrayOfLines | switch(field.type) {$('#requirementText').val().split('\n');
for (y in | case 'checkbox': o[sKey] = +field.checked;
(y == "requirementText") {
for | break;
case'radio':
if (o[sKey] === undefined) o[sKey] = '';
if(field.checked) o[sKey] = field.value;break;
case 'select-multiple':vara=[];}
document.getElementById("formatted").innerHTML = rst;
| for(varj=0,jmax=field.options.length; j < jmax; ++j function formcheck() {
var l = $(".required").length;
| if (field.options[j].selected) a.push(field.options[j].value) var result = [];
for (i = 0; i < l; i++) | } o[sKey] = a;to the array
if ($('.required').eq(i).val() == "") | break;default:result.push($('.required')[i].name);
}
| o[sKey] = field.value; }}
buildRST(o alert("Please enter a value in: " + result);
| return o;buildRSTorst = "..req::\n\n"addedTarget, addedKeword;
var | arrayOfLinestext = $('#requirementText | ').val().split('\n')
for (y in o) { if (y == "requirementText"switch (fieldClicked.id) {
case 'target':
| for(zinarrayOfLines){
rst ="\n " + arrayOfLines[z];
' ';
text.val(text.val() + | }}else{rst+=":"+y+": " + o[y] + "\n" text.val(text.val() + fieldClicked.value);
| }
}document.getElementById("demo").innerHTML = rst;}
}
</script>
</body>
</html>
|
|