I am trying to navigate to robohelp document from react application.
I have added RoboHelp_CSH.js file under scripts folder,
// Macromedia
// Copyright� 1998-2004 eHelp� Corporation.All rights reserved.
// RoboHelp_CSH.js
// The Helper function for WebHelp Context Sensitive Help
// Syntax:
// function RH_ShowHelp(hParent, a_pszHelpFile, uCommand, dwData)
//
// hParent
// Reserved - Use 0
//
// pszHelpFile
// WebHelp:
// Path to help system start page ("http://www.myurl.com/help/help.htm" or "/help/help.htm")
// For custom windows (defined in Help project), add ">" followed by the window name ("/help/help.htm>mywin")
//
// WebHelp Enterprise:
// Path to RoboEngine server ("http://RoboEngine/roboapi.asp")
// If automatic merging is turned off in RoboEngine Configuration Manager, specify the project name in the URL ("http://RoboEngine/roboapi.asp?project=myproject")
// For custom windows (defined in Help project), add ">" followed by the window name ("http://RoboEngine/roboapi.asp>mywindow")
//
// uCommand
// Command to display help. One of the following:
// HH_HELP_CONTEXT // Displays the topic associated with the Map ID sent in dwData
// if 0, then default topic is displayed.
// The following display the default topic and the Search, Index, or TOC pane.
// Note: The pane displayed in WebHelp Enterprise will always be the window's default pane.
// HH_DISPLAY_SEARCH
// HH_DISPLAY_INDEX
// HH_DISPLAY_TOC
//
// dwData
// Map ID associated with the topic to open (if using HH_HELP_CONTEXT), otherwise 0
//
// Examples:
// <p>Click for <A HREF='javascript:RH_ShowHelp(0, "help/help.htm", 0, 10)'>Help</A> (map number 10)</p>
// <p>Click for <A HREF='javascript:RH_ShowHelp(0, "help/help.htm>mywindow", 0, 100)'>Help in custom window (map number 100)</A></p>
var gbNav6 = false;
var gbNav61 = false;
var gbNav4 = false;
var gbIE4 = false;
var gbIE = false;
var gbIE5 = false;
var gbIE55 = false;
var rbNewTab = true;
var win = null;
var gAgent = navigator.userAgent.toLowerCase();
var gbMac = (gAgent.indexOf("mac") != -1);
var gbSunOS = (gAgent.indexOf("sunos") != -1);
var gbOpera = (gAgent.indexOf("opera") != -1);
var HH_DISPLAY_TOPIC = 0;
var HH_DISPLAY_TOC = 1;
var HH_DISPLAY_INDEX = 2;
var HH_DISPLAY_SEARCH = 3;
var HH_HELP_CONTEXT = 15;
var gVersion = navigator.appVersion.toLowerCase();
var gnVerMajor = parseInt(gVersion);
var gnVerMinor = parseFloat(gVersion);
gbIE = (navigator.appName.indexOf("Microsoft") != -1);
if (gnVerMajor >= 4) {
if (navigator.appName == "Netscape") {
gbNav4 = true;
if (gnVerMajor >= 5)
gbNav6 = true;
}
gbIE4 = (navigator.appName.indexOf("Microsoft") != -1);
}
if (gbNav6) {
document.gnPageWidth = innerWidth;
document.gnPageHeight = innerHeight;
var nPos = gAgent.indexOf("netscape");
if (nPos != -1) {
var nVersion = parseFloat(gAgent.substring(nPos + 10));
if (nVersion >= 6.1)
gbNav61 = true;
}
} else if (gbIE4) {
var nPos = gAgent.indexOf("msie");
if (nPos != -1) {
var nVersion = parseFloat(gAgent.substring(nPos + 5));
if (nVersion >= 5)
gbIE5 = true;
if (nVersion >= 5.5)
gbIE55 = true;
}
}
function RH_ShowHelp(hParent, a_pszHelpFile, uCommand, dwData) {
//a_pszHelpFile = helpURL;
// this function only support WebHelp
var strHelpPath = helpURL + a_pszHelpFile;
var strWnd = "";
var nPos = a_pszHelpFile.indexOf(">");
if (nPos != -1) {
strHelpPath = helpURL + a_pszHelpFile.substring(0, nPos);
strWnd = a_pszHelpFile.substring(nPos + 1);
}
if (isServerBased(strHelpPath))
RH_ShowWebHelp_Server(hParent, strHelpPath, strWnd, uCommand, dwData);
else
RH_ShowWebHelp(hParent, strHelpPath, strWnd, uCommand, dwData);
}
function RH_ShowWebHelp_Server(hParent, strHelpPath, strWnd, uCommand, dwData) {
// hParent never used.
ShowWebHelp_Server(strHelpPath, strWnd, uCommand, dwData);
}
function RH_ShowWebHelp(hParent, strHelpPath, strWnd, uCommand, dwData) {
// hParent never used.
ShowWebHelp(strHelpPath, strWnd, uCommand, dwData);
}
function ShowWebHelp_Server(strHelpPath, strWnd, uCommand, nMapId) {
var a_pszHelpFile = "";
if (uCommand == HH_HELP_CONTEXT) {
if (strHelpPath.indexOf("?") == -1)
a_pszHelpFile = strHelpPath + "?ctxid=" + nMapId;
else
a_pszHelpFile = strHelpPath + "&ctxid=" + nMapId;
}
else {
if (strHelpPath.indexOf("?") == -1)
a_pszHelpFile = strHelpPath + "?ctxid=0";
else
a_pszHelpFile = strHelpPath + "&ctxid=0";
}
if (strWnd)
a_pszHelpFile += ">" + strWnd;
// To Open window in new tab
if (rbNewTab)
a_pszHelpFile += ">>newwnd=0";
if (gbIE5 || gbNav6) {
a_pszHelpFile += "&cmd=newwnd&rtype=iefrm";
loadData(a_pszHelpFile);
}
else if (gbNav4) {
a_pszHelpFile += "&cmd=newwnd&rtype=nswnd";
var sParam = "left=" + screen.width + ",top=" + screen.height + ",width=auto,height=auto,resizable=yes,scrollbars=yes";
win = window.open(a_pszHelpFile, "__webCshStub", sParam);
}
else {
var sParam = "left=" + screen.width + ",top=" + screen.height + ",width=auto,height=auto,resizable=yes,scrollbars=yes";
if (gbIE5)
win = window.open("about:blank", "__webCshStub", sParam);
win = window.open(a_pszHelpFile, "__webCshStub", sParam);
}
}
export function ShowWebHelp(strHelpPath, strWnd, uCommand, nMapId) {
var a_pszHelpFile = "";
if (uCommand == HH_DISPLAY_TOPIC) {
a_pszHelpFile = strHelpPath + "#<id=0";
}
if (uCommand == HH_HELP_CONTEXT) {
a_pszHelpFile = strHelpPath + "#<id=" + nMapId;
//a_pszHelpFile = strHelpPath + "?rhmapno=" + nMapId + "#<id=" + nMapId;
}
else if (uCommand == HH_DISPLAY_INDEX) {
a_pszHelpFile = strHelpPath + "#<cmd=idx";
}
else if (uCommand == HH_DISPLAY_SEARCH) {
a_pszHelpFile = strHelpPath + "#<cmd=fts";
}
else if (uCommand == HH_DISPLAY_TOC) {
a_pszHelpFile = strHelpPath + "#<cmd=toc";
}
if (strWnd)
a_pszHelpFile += ">>wnd=" + strWnd;
//To Open window in new tab
if (rbNewTab)
a_pszHelpFile += ">>newwnd=0";
if (win)
win.close();
if (a_pszHelpFile) {
//if (gbIE5 || gbNav6)
// loadData(a_pszHelpFile);
//if (gbNav4)
//{
// var sParam = "left="+screen.width+",top="+screen.height+",width=100,height=100";
// window.open(a_pszHelpFile, "__webCshStub", sParam);
//}
//else
{
// setting the properties for popup window open
var sParam = "left=" + screen.width + ",top=" + screen.height + ",width=auto,height=auto,resizable=yes,scrollbars=yes";
if (gbIE5)
win = window.open("about:blank", "__webCshStub", sParam);
win = window.open(a_pszHelpFile, "__webCshStub", sParam);
// move popup window to center of the screen.
// win.moveTo(300, 0);
}
}
if (win)
win.focus();
}
function isServerBased(a_pszHelpFile) {
if (a_pszHelpFile.length > 0) {
var nPos = a_pszHelpFile.lastIndexOf('.');
if (nPos != -1 && a_pszHelpFile.length >= nPos + 4) {
var sExt = a_pszHelpFile.substring(nPos, nPos + 4);
if (sExt.toLowerCase() == ".htm") {
return false;
}
}
}
return true;
}
function getElement(sID) {
if (document.getElementById)
return document.getElementById(sID);
else if (document.all)
return document.all(sID);
return null;
}
function loadData(sFileName) {
if (!getElement("dataDiv")) {
if (!insertDataDiv()) {
gsFileName = sFileName;
return;
}
}
var sHTML = "";
if (gbMac)
sHTML += "<iframe name=\"__WebHelpCshStub\" src=\"" + sFileName + "\"></iframe>";
else
sHTML += "<iframe name=\"__WebHelpCshStub\" style=\"visibility:hidden;width:0;height:0\" src=\"" + sFileName + "\"></iframe>";
var oDivCon = getElement("dataDiv");
if (oDivCon) {
if (gbNav6) {
if (oDivCon.getElementsByTagName && oDivCon.getElementsByTagName("iFrame").length > 0) {
oDivCon.getElementsByTagName("iFrame")[0].src = sFileName;
}
else
oDivCon.innerHTML = sHTML;
}
else
oDivCon.innerHTML = sHTML;
}
}
function insertDataDiv() {
var sHTML = "";
if (gbMac)
sHTML += "<div id=dataDiv style=\"display:none;\"></div>";
else
sHTML += "<div id=dataDiv style=\"visibility:hidden\"></div>";
var obj = document.body;
if (gbIE5) {
obj.insertAdjacentHTML("beforeEnd", sHTML);
}
else if (gbNav6) {
var r = obj.ownerDocument.createRange();
r.setStartBefore(obj);
var parsedHTML = r.createContextualFragment(sHTML);
obj.appendChild(parsedHTML);
}
return true;
}
From react tsx file i am trying to access document
First try: (by directly accessing url - i am able to load page from below url in browser)
<a className="reportsInfo marginBten" href="https://url.com/How_to_create_document.htm#%3Cid=33%3E%3Enewwnd=0" target="_new" title="Help"></a>
Second try: (from js file by passing id)
import * as webhelp from "../../../scripts/RoboHelp_CSH";
const navigateHelp = (strHelpPath: any, strWnd: any, uCommand: any, nMapId: any) => {
webhelp.ShowWebHelp(strHelpPath, strWnd, uCommand, nMapId);
}
<a onClick={() => navigateHelp(0, "How_to_create_document.htm",'HH_HELP_CONTEXT', 30)} tabIndex={-1} title="Help"></a>
i get below error when i try to do both, in RoboHelp_CSH.js file
i am not sure what is the issue.
Url is correct as same is used in other javascript project and it works fine.I am able to open the page by hitting url.
I wrote the code to speak the text of current page.
Here is my code :
$('#speak').on('click', function () {
if(!('speechSynthesis' in window)){
alert('This browser doesn\'t support this feature.\n Try again with Chrome browser');
return;
}
navigator.browserInfo= (function(){
var ua= navigator.userAgent, tem,
iOS = !!ua.match(/ip(ad|od|hone)/i),
webkit = !!ua.match(/Webkit/i),
iOSChrome = iOS && webkit && !ua.match(/Version/i) && ua.match(/CriOS/i) && !ua.match(/EdgeOS/i) && !ua.match(/OPiOS/i),
M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if(iOSChrome){
return {'browser': 'Chrome'};
}
if(/trident/i.test(M[1])){
tem= /\brv[ :]+(\d+)/g.exec(ua) || [];
return 'IE '+(tem[1] || '');
}
if(M[1]=== 'Chrome'){
tem= ua.match(/\b(OPR|Edge?)\/(\d+)/);
if(tem!= null) return tem.slice(1).join(' ').replace('OPR', 'Opera').replace('Edg ', 'Edge ');
}
M= M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
if((tem= ua.match(/version\/(\d+)/i))!= null) M.splice(1, 1, tem[1]);
return {'browser': M[0], 'version': M[1]};
})();
if(navigator.browserInfo.browser != 'Chrome'){
alert('Try again with Chrome browser.');
return;
}
if ($(this).attr('data-opt') == 'cancel') {
timer(1);
window.speechSynthesis.cancel();
$(this).attr('data-opt', 'speak');
return;
}
var text = '';
if(currentPage == 1)
text = '';
else
text = currentPage >= 35? $('.page' + (currentPage + 1))[0].innerText : $('.page' + currentPage)[0].innerText;
if (text.trim() == null || text.trim() == '') {
text = 'There is no text to speak.';
}
speak(text);
});
function timer(end) {
if (end != null) {
clearTimeout(myTimeout);
return;
}
window.speechSynthesis.pause();
window.speechSynthesis.resume();
myTimeout = setTimeout(timer, 10000);
}
function speak(text) {
if (window.speechSynthesis.speaking) {
console.error('speechSynthesis.speaking');
return;
}
window.speechSynthesis.cancel();
if(navigator.userAgent.search('Android') == -1)
myTimeout = setTimeout(timer, 10000);
var msg = new SpeechSynthesisUtterance(text);
msg.pitch = 1;
msg.rate = 1;
for (var i = 0; i < window.speechSynthesis.getVoices().length; i++) {
if (window.speechSynthesis.getVoices()[i].lang == 'ko-KR') {
msg.voice = window.speechSynthesis.getVoices()[i];
break;
}
}
msg.onend = function () {
timer(1);
$('#speak').attr('data-opt', 'speak');
};
msg.onerror = function(event){
if(navigator.userAgent.search('Mobile') == -1){
alert('An error has occurred with the speech synthesis: ' + event.error);
}else{
console.log('An error has occurred with the speech synthesis: ' + event.error);
}
timer(1);
window.speechSynthesis.cancel();
$('#speak').attr('data-opt', 'speak');
};
$.when(window.speechSynthesis.speak(msg)).then(function () {
$('#speak').attr('data-opt', 'cancel');
});
}
A brief explanation of my code : When you click the #speak button first of all the callback function start to filter if this browser support web speech API and if this browser is chrome after passing all the filtering it gets text from the current page's innerText property and finally speak the text.
It seems it works fine in the most case perfectly working on desktop.
The problem i'm facing is it just stops working on mobile especially iOS after speaking all the text or sometimes random, i don't know why it stops so suddenly without any errors..
Since i wrote the timer function i don't think it's the typical problem that appears with long text.
Any help it would be appreciated thank you in advance.
I feel like I am failing everything this semester. but I was wondering if you all could help me with a JS project. We have been tasked with essentially converting numbers to letters and vica versa using textareas in HTML. I was able to do the numbers to letters function, but am having difficulties going the other way. what I have for all is:
var $ = function(id) {
return document.getElementById(id);
};
window.onload = function() {
$("btnDecode").onclick = fnDecode;
$("btnEncode").onclick = fnEncode;
$("btnClear").onclick = fnClear;
};
function fnDecode() {
var msg = $("textin").value;
if (msg === "") {
$("textin_span").innerHTML = "* Please enter a message to decode *";
$("textin").focus;
return;
} else {
$("textin_span").innerHTML = "";
}
var nums = msg.split(",");
var outstr = "";
for(var i=0; i < nums.length; i++) {
var n2 = parseInt(nums[i]);
if (isNaN(n2)) {
outstr += "?";
} else if (isNallN(nums[i])) {
} else if (n2 === 0) {
outstr += " ";
} else if (n2 < 1 || n2 > 26) {
outstr += "?";
} else {
outstr += String.fromCharCode(n2+64);
}
$("textout").value = outstr;
}
}
function isNallN(s) {
//parse string to check all characters are digits
}
function fnEncode() {
var msg = $("textin").value.toUpperCase();
$("textin").value = msg;
if (msg === "") {
$("textin_span").innerHTML = "* Please enter numberse to decode *";
$("textin").focus;
return;
} else {
$("textin_span").innerHTML = "";
}
var c;
var outstr = "";
for (var i=0; i<msg.length; i++);
c = msg.charCodeAt(i);
if (typeof c === "number") {
outstr += "99";
}else if (c === " ") {
outstr += 0;
/*} else if (c[i] >= "A" && c[i] <= "Z") {
outstr += "99";*/
} else {
outstr += String.charCodeAt(c - 64);
}
$("textout").value = outstr;
//var x = msg.charAT(i);
}
obviously isNallN is not complete, but he promised us if we could figure out fnEncode we should be able to do isNallN with no issues (which I am hoping is true lol) What am doing wrong though in fnEncode? Every time I run it, it gives me "99" even when I put letters in.
i am currently doing a random minterm maxterm mini program.
var totalvar = getRandomInt(3,5);
var main = "";
for (var i = 1; i <= totalvar; i++) {
var test = getRandomInt(1,4);
//alert(test);
var myArray = ["A","B","C","D","A'","B'","C'","D'"];
var text ="";
for (var a = 1; a <= test; a++) {
function random(array) {
return array[Math.floor(Math.random() * array.length)]
}
var testing = random(myArray);
if (testing =="A") {
var testing2 ="A'";
} else if (testing =="A'") {
var testing2 ="A";
} else if (testing =="B") {
var testing2 ="B'";
} else if (testing =="B'") {
var testing2 ="B";
}else if (testing =="C") {
var testing2 ="C'";
} else if (testing =="C'") {
var testing2 ="C";
}else if (testing =="D") {
var testing2 ="D'";
} else if (testing =="D'") {
var testing2 ="D";
}
//alert(testing);
//alert(myArray);
text += testing
var index = myArray.indexOf(testing);
if (index > -1) {
myArray.splice(index, 1);
}
var index = myArray.indexOf(testing2);
if (index > -1) {
myArray.splice(index, 1);
}
}
var impt = totalvar - i;
var frontbracket = main.split("(").length;
var backbracket = main.split(")").length;
if (impt >= 2) {
var brackets = getRandomInt(1,3);
var chances = getRandomInt(1,3);
var chances1 = getRandomInt(1,3);
var lastLetter = main.charAt(main.length - 1);
alert(frontbracket);
alert(backbracket);
if (frontbracket == backbracket) {
if (brackets == 1) {
text = "(" + text;
if (main == "") {
main = text;
}else
main += "+" + text;
} else {
if (main == "") {
main = text;
} else if ( lastLetter == ')') {
if ( chances !== 1) {
main += text;
}else
main += "+" + text;
}else
main += "+" + text;
}
}
else if (frontbracket != backbracket){
text = text + ")";
main += "+" + text;
}
} else if (frontbracket != backbracket){
text = text + ")";
main += "+" + text;
}
else {
var brackets = getRandomInt(1,3);
var chances = getRandomInt(1,3);
var lastLetter = main.charAt(main.length - 1);
if (brackets == 1) {
text = "(" + text + ")";
if (main == "") {
main = text;
} else if ( lastLetter == ')') {
if ( chances !== '1') {
main += text;
}else
main += "+" + text;
}else
main += "+" + text;
} else {
if (main == "") {
main = text;
} else if ( lastLetter == ')') {
if ( chances !== 1) {
main += text;
}else
main += "+" + text;
}else
main += "+" + text;
}
}
}
Currently i am trying to create random questions like
(ABC+C'D'A')C+C'B'
BAC'D'+(CB'A'D)(B'A)
BCA+(B'C)(A'C')
(BC'D'A+CADB')A'DC'+B'+(D'A')
(BC'D'A+CADB')+B'+(D'A')
So based on this 4 questions, i can solve qn 2, qn 3, qn 5 by using the replace function but for qn1 and qn4,
i have to check if there is a plus sign inside the bracket and if there are variables outside the bracket, i will need to add the variables inside.
If there are no variables outside of the bracket like Qn5, i will just remove the brackets.
like this qn5
BC'D'A+CADB'+B'+D'A'
For example qn4 should look like this after the function is done with it
BC'D'AA'DC'+CADB'A'DC'+B'+D'A'
May i ask for some advice regarding this please?
on a function that checks whether there is a plus sign inside the bracket then check whether there are any variables directly outside the bracket and if there is, the variable outside must be added to the variables inside the bracket
i am trying to create a function that automatically create questions to do.
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
var totalvar = getRandomInt(2,4);
var main = "";
for (var i = 1; i <= totalvar; i++) {
var test = getRandomInt(1,3);
// alert(test);
var myArray = ["A","B","C","A'","B'","C'"];
var text ="";
for (var a = 1; a <= test; a++) {
function random(array) {
return array[Math.floor(Math.random() * array.length)]
}
var testing = random(myArray);
if (testing =="A") {
var testing2 ="A'";
} else if (testing =="A'") {
var testing2 ="A";
} else if (testing =="B") {
var testing2 ="B'";
} else if (testing =="B'") {
var testing2 ="B";
}else if (testing =="C") {
var testing2 ="C'";
} else if (testing =="C'") {
var testing2 ="C";
}
//alert(testing);
//alert(myArray);
text += testing
var index = myArray.indexOf(testing);
if (index > -1) {
myArray.splice(index, 1);
}
var index = myArray.indexOf(testing2);
if (index > -1) {
myArray.splice(index, 1);
}
}
var brackets = getRandomInt(1,3);
var chances = getRandomInt(1,3);
var lastLetter = main.charAt(main.length - 1);
if (brackets == 1) {
text = "(" + text + ")";
if (main == "") {
main = text;
} else if ( lastLetter == ')') {
if ( chances !== 1) {
main += text;
}else
main += "+" + text;
}else
main += "+" + text;
} else {
if (main == "") {
main = text;
} else if ( lastLetter == ')') {
if ( chances !== 1) {
main += text;
}else
main += "+" + text;
}else
main += "+" + text;
}
}
I have manage to get it to display questions that i want
B'C'+(A'C'B')+BCA
B+(C')(CAB)
A'BC+(C')A+AB'
B'C'+AB(A'C'B')+BCA
I am stucked as i couldnt get the function for the next step where it multiples the value outside the bracket
B'C'+A'C'B'+BCA
B+C'CAB
A'BC+C'A+AB'
B'C'+ABA'C'B'+BCA
The above is what i hope to achieve but im unable to create the function out
any tips guys?
use replace:
var str = "B'C'+(A'C'B')+BCA";
var response = str.replace(/([\(\)]+)/g, '');
console.log(response);
// output: "B'C'+A'C'B'+BCA"