Issue on log4js File Appender - javascript

I am using Log4js Library to print the log message in a file. In that I am getting 2 issues. Such as:
12:00:40 PM ERROR Log4js - TypeError: netscape.security.PrivilegeManager is undefined
in Non-IE Browser. Please tell me how to fix this exception. While Using IE , It's
working fine.
How to get the CATALINA_HOME in the JavaScript part. I am using Tomcat.
To get this CATALINA_HOME in Log4j, we need to write as follow
log4j.appender.FILE.File=${catalina.base}/logs/MyLogs.log.
If I'll write the catalina.base, not working in the JavaScript.
Here is my code please have a look on my code and detect the error causing line to have the solution:
<script type="text/javascript">
function myFunction(name) {
var date = new Date();
var log = Log4js.getLogger("fileAppender");
log.setLevel(Log4js.Level.ALL);
var toAppend=date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();
var fileAppender = new Log4js.FileAppender("${catalina.base}\\logs\\JSLogging."+toAppend+".log");
log.addAppender(fileAppender);
log.debug("My Debugging");
log.info("My Information");
}
</script>

try adding <script type="text/javascript" src="log4javascript.js"></script> in the code seems it is not able to get the reference of the main script.
see if this can help you
<script type="text/javascript">
// Create the logger
var log = log4javascript.getLogger();
// Create a PopUpAppender with default options
var popUpAppender = new log4javascript.PopUpAppender();
// Change the desired configuration options
popUpAppender.setFocusPopUp(true);
popUpAppender.setNewestMessageAtTop(true);
// Add the appender to the logger
log.addAppender(popUpAppender);
// Test the logger
log.debug("Hello world!");
</script>
enter code here
use this link

Related

Google Apps Script JSON.Parse causing 'could not connect to server' on debug

I'm by no means what I would call a "developer" but dabble quite a bit. I'm working on some Apps Script code to query an API and push the results into SQL. I have most of the bits working but I've noticed that while I'm debugging in the Apps Script editor, when I step into the following line of code, the editor throws the "could not connect to server message at the top.
var response = UrlFetchApp.fetch(clientApiURL,options);
var resultSet = JSON.parse(response.getContentText()); <-- this is the line that is crashing the IDE
Anyone know how to better debug this? When I'm not debugging it, the code seems to behave and function properly. But with this API, not all objects are formatted the same way, so I like to use the debugger to inspect them. I can do that when the editor crashes.
Any help/insight would be super appreciated. I've also pasted below the value of response.getContentText()
{"result":{"lead":[{"id":"332","accountID":null,"ownerID":null,"companyName":"","title":null,"firstName":"RYAN","lastName":"CAVANAUGH","street":null,"city":null,"country":null,"state":null,"zipcode":null,"emailAddress":"email#here.com","website":null,"phoneNumber":null,"officePhoneNumber":null,"phoneNumberExtension":null,"mobilePhoneNumber":null,"faxNumber":null,"description":null,"campaignID":"789934082","trackingID":"202003_5e6fa18a87853a69eb306910","industry":null,"active":"1","isQualified":"1","isContact":"1","isCustomer":"1","status":"4","updateTimestamp":"2020-05-08 20:24:48","createTimestamp":"2020-05-03 20:23:29","leadScoreWeighted":"23","leadScore":"26","isUnsubscribed":"0","leadStatus":"customer","persona":"","product_5e554b933fb5b":""}]},"error":null,"id":"5222020","callCount":"215","queryLimit":"50000"}
This will reproduce the error:
function test(){
var obj={"result":{"lead":[{"id":"332","accountID":null,"ownerID":null,"companyName":"","title":null,"firstName":"RYAN","lastName":"CAVANAUGH","street":null,"city":null,"country":null,"state":null,"zipcode":null,"emailAddress":"email#here.com","website":null,"phoneNumber":null,"officePhoneNumber":null,"phoneNumberExtension":null,"mobilePhoneNumber":null,"faxNumber":null,"description":null,"campaignID":"789934082","trackingID":"202003_5e6fa18a87853a69eb306910","industry":null,"active":"1","isQualified":"1","isContact":"1","isCustomer":"1","status":"4","updateTimestamp":"2020-05-08 20:24:48","createTimestamp":"2020-05-03 20:23:29","leadScoreWeighted":"23","leadScore":"26","isUnsubscribed":"0","leadStatus":"customer","persona":"","product_5e554b933fb5b":""}]},"error":null,"id":"5222020","callCount":"215","queryLimit":"50000"}
var resultSet = JSON.parse(obj);
}
Taking a look at the problem:
function test(){
var obj={"result":{"lead":[{"id":"332","accountID":null,"ownerID":null,"companyName":"","title":null,"firstName":"RYAN","lastName":"CAVANAUGH","street":null,"city":null,"country":null,"state":null,"zipcode":null,"emailAddress":"email#here.com","website":null,"phoneNumber":null,"officePhoneNumber":null,"phoneNumberExtension":null,"mobilePhoneNumber":null,"faxNumber":null,"description":null,"campaignID":"789934082","trackingID":"202003_5e6fa18a87853a69eb306910","industry":null,"active":"1","isQualified":"1","isContact":"1","isCustomer":"1","status":"4","updateTimestamp":"2020-05-08 20:24:48","createTimestamp":"2020-05-03 20:23:29","leadScoreWeighted":"23","leadScore":"26","isUnsubscribed":"0","leadStatus":"customer","persona":"","product_5e554b933fb5b":""}]},"error":null,"id":"5222020","callCount":"215","queryLimit":"50000"}
var resultSet = JSON.parse(JSON.stringify(obj));
}
but so what the point of the parse is to return an object from a string not from object.
But I do see the problem. 'Cannot connect to the server'
I found that this does seem to work know:
function test(){
var obj='{"result":{"lead":[{"id":"332","accountID":"","ownerID":"","companyName":"","title":"","firstName":"RYAN","lastName":"CAVANAUGH","street":"","city":"","country":"","state":"","zipcode":"","emailAddress":"email#here.com","website":"","phoneNumber":"","officePhoneNumber":"","phoneNumberExtension":"","mobilePhoneNumber":"","faxNumber":"","description":"","campaignID":"789934082","trackingID":"202003_5e6fa18a87853a69eb306910","industry":"","active":"1","isQualified":"1","isContact":"1","isCustomer":"1","status":"4","updateTimestamp":"2020-05-08 20:24:48","createTimestamp":"2020-05-03 20:23:29","leadScoreWeighted":"23","leadScore":"26","isUnsubscribed":"0","leadStatus":"customer","persona":"","product_5e554b933fb5b":""}]},"error":"","id":"5222020","callCount":"215","queryLimit":"50000"}';
var resultSet = JSON.parse(obj);
var end="is near";//I just put this here to have a place to stop with debugger running
}
I replaced all of the null s with "".

Oracle MAF : TypeError: Object[object Object] has no method 'signature'

I am developing the mobile application using Oracle MAF. In that application I need to implement the Signature capture functionality.
For that I have downloaded the Signature Capture Demo app from this link.
And trying to integrate with my application. I did all the necessary settings mentioned in that link.
But after running the application I am getting following error
TypeError: Object[object Object] has no method 'signature'
The Piece of code as follows
<![CDATA[
<script type="text/javascript">
(function()
{
makeSig = function() {
try
{
var sigElement = document.getElementById("sig");
if (sigElement == null)
alert("sigElement not found");
var sigJq = $(sigElement);
sigJq.signature();
sigJq.signature({guideline: true});
}
catch (problem)
{
alert("Problem with verbatim code: " + problem);
}
}
window.setTimeout(makeSig, 250);
})();
</script>
<div id="sig" style="height:200px;width:99%"></div>
]]>
Please let me know why it is not able to find the signature method. I have also included all the required .js files in the project.
Thanks in Advance.
Make sure you are properly including the library:
<script type="text/javascript" src="js/jquery.signature.js"></script>
then try something like this
var sigJq = $("sig");
sigJq.signature();

Error in Assets folder while running Cordova Android App (plugin)

I'm developing a cordova android app and I'm getting an error while using a calendar plugin from github
https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin
the error is:
.....................................
my html file for including JSs
<script type=="text/javascript" src="cordova.js"></script>
<script type=="text/javascript" src="cordova_plugins.js"></script>
<script type=="text/javascript" src="JS/Calendar.js"></script>
<script src="JS/fncs.js"></script>
my fncs.js file is:
var startDate = new Date(2014,8,24,0,0,0,0,0);
var endDate = new Date(2014,8,27,0,0,0,0,0);
var title = "My nice event";
var location = "Home";
var notes = "Some notes about this event.";
var success = function(message) { document.getElementById("developers").innerHTML = "success";};
var error = function(message) { document.getElementById("developers").innerHTML = "failed";};
window.plugins.calendar.createCalendar(calendarName,success,error);
and here's my file structure:
JS folder >>
any help would be greatly appreciated .. thanks !
Cordova has not been initialised yet. So window.plugins is undefined and u´ve got a crash.
instead of plain old javascript, try to put your initialization code inside one of the initialization events such as deviceready: http://cordova.apache.org/docs/en/2.5.0/cordova_events_events.md.html#deviceready
That way you can be sure Cordova is up and running.

BrowserCouch, help with basic example

I'm trying to get a basic example of BrowserCouch working... the one shown here: http://hg.toolness.com/browser-couch/raw-file/blog-post/tutorial.html
My code:
<script type="text/javascript" src="browser-couch.js"></script>
<script type="text/javascript">
BrowserCouch.get('blog-posts',
function onRetrieveCb(db) {
blogDb = db; /* Save the DB for later. */
});
</script>
I get this error in the Chrome and FF console:
BrowserCouch is not defined
I've double checked and the browser-couch.js file is correctly src'd.
How can I get this to work?
Looks like you're using code from the blog post but using a newer version of the JavaScript and the newer one has a different API. From the github page:
var database = BrowserCouch('foo');
database.onload(function(){
database.get('bar', function(d){console.log(d)});
});
But the older version wanted what you're doing:
BrowserCouch.get('blog-posts',
function onRetrieveCb(db) {
blogDb = db; /* Save the DB for later. */
}
);
So I think you need to match your API usage to the library version.

Google API Authentication

Using the Google Javascript API I am trying to authenticate myself (locally) to create a new event in my calendar. However, I get an error (see below) stating that my "next" parameter is bad or missing when I execute the log-in portion of the script. I am following the data api interactive samples for "Create a single event".
Update 1: From the address bar I see "next" set the following way:
next=file:///C:/calext/sending_data.html
Does Google not like local files? Workaround?
Update 2: I tried running the file on my web host. The page ran (threw a few errors) but the event ended up on my calendar. So the bug lies somewhere with not liking local files. Thoughts?
Error Message:
The page you have requested cannot be
displayed. Another site was requesting
access to your Google Account, but
sent a malformed request. Please
contact the site that you were trying
to use when you received this message
to inform them of the error. A
detailed error message follows:
The "next" parameter was bad or
missing.
My page's code:
<html>
<head>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
</head>
<body>
<img src="128.png">
<script type="text/javascript">
var myService;
var feedUrl = "https://www.google.com/calendar/feeds/default/private/full";
google.load("gdata", "1");
google.setOnLoadCallback(getMyFeed); // starts process
// Create a single event example
function doExample()
{
var calendarService = myService;
// The default "private/full" feed is used to insert event to the
// primary calendar of the authenticated user
var feedUri = 'http://www.google.com/calendar/feeds/default/private/full';
// Create an instance of CalendarEventEntry representing the new event
var entry = new google.gdata.calendar.CalendarEventEntry();
// Set the title of the event
entry.setTitle(google.gdata.Text.create('JS-Client: insert event'));
// Create a When object that will be attached to the event
var when = new google.gdata.When();
// Set the start and end time of the When object
var startTime = google.gdata.DateTime.fromIso8601("2010-10-24T09:00:00.000-05:00");
var endTime = google.gdata.DateTime.fromIso8601("2010-10-24T10:00:00.000-05:00");
when.setStartTime(startTime);
when.setEndTime(endTime);
// Add the When object to the event
entry.addTime(when);
// Submit the request using the calendar service object
calendarService.insertEntry(feedUri, entry, handleMyFeed, handleError, google.gdata.calendar.CalendarEventEntry);
}
function handleMyFeed(myResultsFeedRoot)
{
alert("This feed's title is: " + myResultsFeedRoot.feed.getTitle().getText());
}
function handleError(e)
{
alert("There was an error!");
alert(e.cause ? e.cause.statusText : e.message);
}
function getMyFeed()
{
// Set up my service
myService = new google.gdata.calendar.CalendarService('GoogleInc-jsguide-1.0');
// Log me in
var scope = "https://www.google.com/calendar/feeds/";
var token = google.accounts.user.login(scope);
// Create a single event example
doExample();
// Get my feed
myService.getEventsFeed(feedUrl, handleMyFeed, handleError);
}
</script>
</body>
</html>
I assume your opening a local file which requires a local file. By default, file:// URIs cannot read other file:// URIs. Try adding this command line parameter, it is specifically made to help developers test:
chrome --allow-file-access-from-files

Categories