<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">
VNF or PNF CSAR PACKAGE">VNF or PNF CSAR PACKAGE</option>
| <fieldset>
<p>DOCUMENTATION PACKAGE">VNF DOCUMENTATION PACKAGE</option>
| <labelforid">Requirement ID:</label>PNF DOCUMENTATION PACKAGE">PNF DOCUMENTATION PACKAGE</option>
| <inputstyle="width: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" name="id" id="id" value="" type="text" readonly/>value="VNF or PNF DOCUMENTATION PACKAGE">VNF or PNF DOCUMENTATION PACKAGE</option>
</select>
</p>
<p>
<label for="keyword">Keyword:</label>
<select onchange="buildReq(keyword)" style="width: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" name="keyword" id="keyword" class=" | keywordrequired">
<option value="" hidden>Select Keyword</option>
<option value="**MUST**">MUST</option>
| <option value="**MUST NOT**">MUST NOT</option>
| <option value="**SHOULD**">SHOULD</option>
| <option value="**SHOULD NOT**">SHOULD NOT</option>
| <option value="**MAY**">MAY</option>
</select>
</p>
<p>
<label for=" | target>Target>Introduced:</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>: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" name="introduced">
| VNF PROVIDER">VNF PROVIDER<amsterdam">amsterdam</option>
| VNF HEAT ORCHESTRATION TEMPLATE">VNF HEAT ORCHESTRATION TEMPLATE<beijing">beijing</option>
| VNF PACKAGE">VNF PACKAGE<casablanca">casablanca</option>
| PNF">PNF<dublin" selected="selected">dublin</option>
| VNFor PNF>VNFor PNF<alto</option>
</select>
</p>
<p>
<label for=" | introduced>Introduced>Impacts*:</label>
<select style="width: 100%; margin: 8px 0; box-sizing: border-box; padding | : 12px 20px;" name="introduced">
: 12px 20px;" name="impacts" size="10" multiple>
<option value="AAI">AAI</option>
<option value="AAF">AAF</option>
<option value=" | amsterdam>amsterdam< beijing>beijing< casablanca>casablanca< dublin" selected="selected">dublin< el alto">el alto<Documentation">Documentation</option>
| </select>
<option value="DCAE">DCAE</option>
<option value="External API">External API</option>
| </p>
<p><option value="Holmes">Holmes</option>
| <labelforimpacts">Impacts*:</label>Integration">Integration</option>
| <selectstylewidth: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" name="impacts" size="10" multiple>
Logging">Logging</option>
<option value="Micro Bus">Micro Bus</option>
<option value=" | AAI>AAI< AAF">AAF<Multi VIM">Multi VIM</option>
| APPC>APPC< CLAMP>CLAMP< CCSDK>CCSDK< DCAE>DCAE< Documentation">Documentation<Usecase UI">Usecase UI</option>
| DCAE>DCAE< ExternalAPI>External API< Holmes>Holmes< Integration>Integration< Logging>Logging< MicroBus>Micro Bus< Modeling>Modeling< MultiVIM>Multi VIM< Music>Music< CLI>CLI<<optionvalue="OOM">OOM</option>
<option value="OOF">OOF</option><option value="UsecaseUI">Usecase UI</option>
the Ctrl (windows) / Command (Mac) button to select multiple options for impacts.</b>
| <optionvalue="Policy">Policy</option>
<option value="Portal">Portal</option> <option valueSDNC">SDNC</option>
validation_mode">Validation Mode:</label>
| <option value="SDC">SDC</option>
<select style="width: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px | <optionvalueSO">SO</option> VFC">VFC<" selected disabled hidden>Select Validation Mode</option>
| VID>VID< VNFSDK>VNFSDK< <option value="VNFRQTS">VNFRQTS</option>
<option value="VVP">VVP</option></select>
<label for="requirementText">Requirement Text:*</ | p><p>
<textarea style="width: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" | <b>*Hold down the Ctrl (windows) / Command (Mac) button to select multiple options for impacts.</b>id="requirementText" rows="10" cols="30" class="required" value="" type="text"></textarea>
</p>
| </p><p>
<b>*Make sure to add keyword entered in KEYWORD field in the requirement | <label for="validation_mode">Validation Mode:</label>
<select style="width: 100%; margin: 8px 0; box-sizing: border-box; padding: 12px 20px;" name="validation_mode">
</p>
</fieldset>
</div>
</div>
| <option value="static">static</option> </form>
<button style="background-color: #008CBA; color: white; border: 2px solid black; width: 100%; | <option value="none">none</option>font-size: 24px;" onclick="formDataToObject(document.getElementById('req'))">Convert to RST</button>
<textarea style="width: 100%; margin: 8px 0; box-sizing: border-box; padding: | </select>
</p>12px 20px;" rows="10" cols="30" id="formatted" readonly>
Formatted RST will Show here.
</textarea>
<script>
//define | <p> <label for="requirementText">Requirement Text:*</label>$('#sections .section:first').clone();
//define counter
| <textarea style="width:100%;margin:8px0; box-sizing: border-box; padding: 12px 20px;" name="requirementText" id="requirementText" rows="10" cols="30" value="" type="text">Enter Requirement text.</textarea>sectionsCount = 1;
var url = "https://wiki.onap.org/download/attachments/60887371/needs.json?api=v2"
$('body').on('click', '#generate', function(e) {
| </p>
<p>});
function myFunction() {
| <b>*Makesure to add keyword entered in KEYWORD field in the requirement in CAPS.</b> get(url).then(JSON.parse).then(function(data) {
console.log("It worked!", data);
| </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 console.log("It failed!", err);
}).then(function(data) {
var parsedData = parseIDs(data);
var finalIDs = createIDs(1, parsedData);
console.log(finalIDs);
| vartemplate=$('#sections .section:first').clone(//definecounter
varsectionsCount = 1;varurl= "https://wiki.onap.org/download/attachments/60887371/needs.json?api=v2"
$('body').on('click', '#generate', function(ereturn new Promise(function(resolve, reject) {
| myFunction();
}); // Do the usual XHR stuff
| $('body').on('click', '#convert', function(e){
convert});
functionmyFunction(){
get(url).then(JSON.parse).then(dataconsole.log("Itworked!", data);
return data; // This is called even on 404 etc
| }).catch(function(err){
// Instead, this happens:
console.log("It failed!", err);}).then(function(data){
// Resolve the promise with | varparsedData= parseIDs(data);
varfinalIDs=createIDs(1, parsedData console.log(finalIDs);
addSection(finalIDs);
})
}
functionget(url){
Returnanewpromise.
returnnewPromise(function(resolve,reject){
reject(Error(req.statusText));
| //Dotheusual XHR stuff
varreq=newXMLHttpRequest() req.open('GET', url);// Handle network errors
req. | onload // This is called even on 404 etc
reject(Error("Network Error"));
};
// | socheck status if(status == 200) {
//Resolvethepromisewiththe response textfunction parseIDs(jsonText) {
var result = new | resolve(req.response } else {= jsonText.current_version;
| // Otherwise reject with the status textresult.add(Object.keys(jsonText["versions"][version]["needs"]));
console.log(result);
return result;
| //whichwillhopefullybeameaningfulerror
function createIDs(numberOfIDs, parsedData) {
var addedIDs | reject(Error(req.statusText))}
};// Handle network errorsreq.onerror = function() {
reject(Error("Network Error"(Math.floor(Math.random() * 999999));
| };
//Maketherequest
req.send(('000000' + new_id).slice(-6);
} | );}
functionparseIDs(jsonText) {varresult = new Set();varversion=jsonText.current_version(parsedData.has(new_id));
| result.add(Object.keys(jsonText["versions"][version]["needs"]))console.log(result);resultcreateIDs(numberOfIDs, parsedDatavar addedIDsdocument.getElementById('id').value = | []for(x=0;x < numberOfIDs; x++function formDataToObject(elForm) {
| var new_id = ""//if (!elForm instanceof Element) return;
var fields | do {
= elForm.querySelectorAll('input, select, textarea'),
| new_id (Math.floor(Math.random() * 999999));
{};
for (var i = 0, imax = | if (new_id100000 new_id = ('000000' + new_id).slice(-6);
fields[i],
sKey = field.name | } new_id = ("R-" + new_id);
}(field.type === 'button' || field.type === 'image' || field.type === 'submit' || !sKey) continue;
| whileparsedData.has(new_id));addedIDs[x] = new_id;}
return addedIDs}
functionaddSection(finalIDs) {
document.getElementById(id').value = finalIDs;
}
functionformDataToObject(elForm) {
(o[sKey] === undefined) o[sKey] = '';
| //if(!elForminstanceofElement)return;
var fields = elForm.querySelectorAll('input, select, textarea'),
(field.checked) o[sKey] = field.value;
| o={}for(vari=0, imax = fields.length; i < imax; ++i) {
case 'select-multiple':
var | fieldfieldsi,sKey=field.name || field.id;
if (field.type === 'button' || field.type === 'image' || field.type === 'submit' || !sKey) continue;
for (var j = 0, jmax = field.options.length; j < jmax; ++j) {
if | switch (field.type) {
(field.options[j].selected) a.push(field.options[j].value);
| case'checkbox':+field.checkedcase 'radio' if(== undefined) o[sKey] = '';iffield.checked) o[sKey] = field.value);
buildRST(o);
return o;
| break;case'select-multiple':
var rst = ".. req::\n";
var | a[]$('#requirementText').val().split('\n');
for (y in o) {
| for(varj=0,jmax=field.options.length; j < jmax; ++j if (y == "requirementText") {
for (z in arrayOfLines) | if (field.options[j].selected) a.push(field.options[j].value);
}
+= "\n " + arrayOfLines[z];
| o[sKey]=a;
break;default:
sKey= field.valuebuildRST(o)document.getElementById("formatted").innerHTML = rst;
}
| returno;
}
functionbuildRST(o) {$(".required").length;
var | rst"..req::\n\n"vararrayOfLines $('#requirementText').val().split('\n');var keyW = document.getElementById("keyword"); //Push each element to the array
| varkeyWord= keyW.options[keyW.selectedIndex].text;if ($('.required').eq(i).val() == "") {
| for(yin o) { result.push($('.required')[i].name);
| if(y=="requirementText"){
forz in arrayOfLinesresult.length != 0) {
alert("Please enter a value in: " | var finLine = boldString(arrayOfLines[z], keyWordrst+="\n" + finLine;function buildReq(fieldClicked) {
var | }addedTarget, addedKeword;
var text | } else {= $('#requirementText');
switch (fieldClicked.id) {
| rst+=":"+y + ": " + o[y] + "\n";
case 'target':
addedTarget = | }
'The ' + fieldClicked.value + ' ';
| }
document.getElementById("demo").innerHTML = rst;
text.val(text.val() + addedTarget);
| }
functionboldString(str, find) {varre=new RegExp(find, 'g' text.val(text.val() + fieldClicked.value);
break;
| returnstr.replace(re,'**'+find+ '**'); }
}
</script>
</body>
</html> |
|