i am just doing my first experiences with maps api. Works great, but...
adding a click event to a marker works, adding a dblclick ... nothings happens. As if the dblclick simply doesnt fire.
So my questions:
Is a marker capable to handle a dblclick?
Sample code is as follows (the catch exception e doesnt make any change) :
try
{
if (urlfuerdoppelclick != null)
if (urlfuerdoppelclick.Length > 0)
{
eintraege = eintraege + " marker" + i.ToString() + ".addListener";
eintraege = eintraege + " ('dblclick',";
eintraege = eintraege + " function () ";
eintraege = eintraege + " { ";
eintraege = eintraege + " window.open(\"" + urlfuerdoppelclick
+ "\"); ";
eintraege = eintraege + " } ";
eintraege = eintraege + " ); ";
}
}
catch { };
try
{
if (voninnen != null)
if (voninnen.Length > 0)
{
eintraege = eintraege + " marker" + i.ToString() + ".addListener";
eintraege = eintraege + " ('click',";
eintraege = eintraege + " function () ";
eintraege = eintraege + " { ";
eintraege = eintraege + " window.open(\"" + voninnen + "\"); ";
eintraege = eintraege + " } ";
eintraege = eintraege + " ); ";
};
}
catch (Exception e) { };
Related
I have a function in a webview which has response:
var respMsg = function(e)
{
var respData = eval("(" + e.data + ")");
document.getElementById("response").innerHTML = e.origin + " SENT " + " - " +
respData.responseCode + "-" + respData.dataKey + "-" + respData.errorMessage;
document.getElementById("response").style.display = 'none';
}
My question is: how to get for example respData.dataKey in a react native value so I can use it further (for example to get it and log its value)
I'm having trouble in binding the records from json to my
script in my view but I'm getting data from console.log. Can you
please help me what am I missing? here's my code...
public JsonResult GetListOfQuestions()
{
List<Question> QuesList = _context.Question.ToList();
return Json(QuesList);
}
<div id="SetQuestionsList">
<div id="LoadingStatus">
</div>
</div>
<script>
$("#LoadingStatus").html("Loading....");
$.get("/Questions/GetListOfQuestions", null, DataBind);
function DataBind(QuesList) {
var SetData = $("#SetQuestionsList");
console.log(QuesList);
for (var i = 0; i < QuesList.length; i++) {
var aa = i + 1
var Data =
"<div class='row_{" + QuesList.QuestionId + "}'>" +
"<div class='panel panel-primary'>" +
"<div class='panel-heading'>" +
"<div class='row'>" +
"<div class='col-lg-10'>" +
"<p>Question " + aa + "</p>" +
"</div>" +
"<div class='col-lg-1'>" +
"<a href='#' class='btn btn-warning' onclick='EditQuestion({" + QuesList.QuestionId + "})'>" +
"<span class='glyphicon glyphicon-edit'></span>Update" +
"</a>" +
"</div>" +
"<div class='col-lg-1'>" +
"<a href='#' class='btn btn-danger' onclick='DeleteQuestionRecord({" + QuesList.QuestionId + "})'>" +
"<span class='glyphicon glyphicon-trash'></span>Delete" +
"</a>" +
"</div>" +
"</div>" +
"</div>" +
"<div class='panel-body'>" +
"<div class='row'>" +
"<div class='col-lg-12'>" +
"<div class='form-group'>" +
"<b>Description</b><br />" +
"<p>" + QuesList.QuestionText + "</p>" +
"</div>" +
"</div>" +
"</div>" +
"</div>" +
"</div>" +
"</div>";
SetData.append(Data);
$("#LoadingStatus").html(" ");
}
}
</script>
Assuming you are using a version of jQuery >= 1.5, the following should help you determine what's going on. The way the script is currently written, using the ajax shorthand version, if there is an error in the call, jquery will fail silently. This way, you have an option to handle an error during the call execution and view the error in the browser dev console to help you debug the issue.
Update I added a jsfiddle for you to understand it better in case the explanation isn't enough (you should provide a jsfiddle in the future)
Also, see the following json, I'm assuming your data is similar to https://api.myjson.com/bins/1fryq4. You have to take into account the data structure that is being converted into json from the backend.
function getQuestions(){
$("#LoadingStatus").show();
$.get("https://api.myjson.com/bins/1fryq4")
.done(function( data ) {
//call you binding function
DataBind(data);
})
.fail( function(err){
//handle the error in the UI, alert the user something went wrong, recover form the error
alert("GetListOfQuestions error!");
//chrome: display object in js console
console.dir(err);
})
.always(function() {
//hide loading spinner
$("#LoadingStatus").hide();
});
}
Databind js function (shortened, see jsfiddle)
function DataBind(QuesList) {
var aa = 0;
var QuestionList = $("#SetQuestionsList");
//if you need to convert json to a js object use the builtin parser
//Example: var data = JSON.parse(QuesList);
//TODO good practice to check if valid list before trying to iterate the array
//pay attention to your incoming object
QuesList.questions.forEach(function(item){
aa++;
var question =
"<div class='row_{" + item.questionId + "}'>" +
"<div class='panel panel-primary'>" +
"<div class='panel-heading'>" +
"<div class='row'>" +
"<div class='col-lg-10'>" +
"<p>Question " + aa + "</p>" +
"</div>" +
"<div class='col-lg-1'>" +
"<a href='#' class='btn btn-warning' onclick='EditQuestion({" + item.questionId + "})'>" +
"<span class='glyphicon glyphicon-edit'></span>Update" +
"</a>" +
"</div>" +
"<div class='col-lg-1'>" +
"<a href='#' class='btn btn-danger' onclick='DeleteQuestionRecord({" + item.questionId + "})'>" +
"<span class='glyphicon glyphicon-trash'></span>Delete" +
"</a>" +
"</div>" +
"</div>" +
"</div>" +
...
"<b>Description</b><br />" +
"<p>" + item.questionDescription + "</p>" +
"</div>" +
...
"</div>";
QuestionList.append(question);
});
}
<script type="text/javascript">
function getQuestions() {
$("#LoadingStatus").show();
$.get("/Questions/GetListOfQuestions")
.done(function (data) {
//call you binding function
console.log(data)
DataBind(data);
})
.fail(function (err) {
//handle the error in the UI, alert the user something went wrong, recover form the error
alert("GetListOfQuestions error!");
//chrome: display object in js console
console.dir(err);
})
.always(function () {
//hide loading spinner
$("#LoadingStatus").hide();
});
}
function DataBind(QuesList) {
var aa = 0;
var QuestionList = $("#SetQuestionsList");
console.log(QuesList);
//if you need to convert json to a js object use the builtin parser
//Example: var data = JSON.parse(QuesList);
//TODO good practice to check if valid list before trying to iterate the array
//pay attention to your incoming object
QuesList.questions.forEach(function (item) {
aa++;
var question =
"<div class='row_{" + item.QuestionId + "}'>" +
"<div class='panel panel-primary'>" +
"<div class='panel-heading'>" +
"<div class='row'>" +
"<div class='col-lg-10'>" +
"<p>Question " + aa + "</p>" +
"</div>" +
"<div class='col-lg-1'>" +
"<a href='#' class='btn btn-warning' onclick='EditQuestion({" + item.QuestionId + "})'>" +
"<span class='glyphicon glyphicon-edit'></span>Update" +
"</a>" +
"</div>" +
"<div class='col-lg-1'>" +
"<a href='#' class='btn btn-danger' onclick='DeleteQuestionRecord({" + item.QuestionId + "})'>" +
"<span class='glyphicon glyphicon-trash'></span>Delete" +
"</a>" +
"</div>" +
"</div>" +
"</div>" +
"<div class='panel-body'>" +
"<div class='row'>" +
"<div class='col-md-6'>" +
"<div class='form-group'>" +
"<b>Question Type</b><br />" +
"<text>" + item.QuestionTypeName + "</text>" +
"</div>" +
"</div>" +
"</div>" +
"<div class='row'>" +
"<div class='col-lg-12'>" +
"<div class='form-group'>" +
"<b>Description</b><br />" +
"<p>" + item.QuestionDescription + "</p>" +
"</div>" +
"</div>" +
"</div>" +
"</div>" +
"</div>" +
"</div>";
QuestionList.append(question);
});
}
</script>
Has anyone successfully created a Journal Entry in S/4HANA Cloud system via POSTMAN or Cloud Platform App?
I keep getting 401 unauthorized in POSTMAN. I tried PO GET API URL, and it is working fine.
https://:/sap/bc/srt/scs/sap/journalentrycreaterequestconfi
{
"JournalEntryBulkCreateRequest": {
"MessageHeader": { "CreationDateTime": "2018-05-27T12:50:30.45+01:00" },
"JournalEntryCreateRequest": {
"MessageHeader": { "CreationDateTime": "2018-05-27T12:50:30.45+01:00" },
"JournalEntry": {
"OriginalReferenceDocumentLogicalSystem": "",
"OriginalReferenceDocumentType": "BKPFF",
"OriginalReferenceDocument": "",
"BusinessTransactionType": "RFBU",
"AccountingDocumentType": "",
"DocumentHeaderText": "Header Value",
"CompanyCode": "US01",
"CreatedByUser": "CB9980000010",
"DocumentDate": "2018-05-27",
"PostingDate": "2018-05-27",
"item": [
{
"GLAccount": "0021517000",
"AmountInTransactionCurrency": {
"Amount": "1200.00",
"currencyCode": "USD"
},
"DocumentItemText": "Text1"
},
{
"GLAccount": "0010010000",
"AmountInTransactionCurrency": {
"Amount": "-1200.00",
"currencyCode": "USD"
},
"DocumentItemText": "Text2"
}
]
}
}
}
This is a Soap Request so you need to call by sending XML Envelop data.
var request =
"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope\"" +
" xmlns:sfin=\"http://sap.com/xi/SAPSCORE/SFIN\"><soapenv:Header/><soapenv:Body><sfin:JournalEntryBulkCreateRequest>" +
"<MessageHeader><CreationDateTime>" + currentDate.toISOString() + "</CreationDateTime></MessageHeader>" +
"<JournalEntryCreateRequest><MessageHeader><CreationDateTime>" + currentDate.toISOString() + "</CreationDateTime></MessageHeader>" +
"<JournalEntry>" +
"<OriginalReferenceDocumentType>BKPFF</OriginalReferenceDocumentType>" +
"<OriginalReferenceDocument>" + Item[1] + "</OriginalReferenceDocument>" + // Report number
"<OriginalReferenceDocumentLogicalSystem>INBOUND</OriginalReferenceDocumentLogicalSystem>" +
"<BusinessTransactionType>RFBU</BusinessTransactionType>" +
"<AccountingDocumentType>SA</AccountingDocumentType>" +
"<DocumentHeaderText>Certify NonReimbursement</DocumentHeaderText>" +
"<CreatedByUser>CC0000000001</CreatedByUser>" +
"<CompanyCode>" + Item[8] + "</CompanyCode>" +
"<DocumentDate>" + this.parseJsonDate(documentDate) + "</DocumentDate>" +
"<PostingDate>" + this.parseJsonDate(postingdate) + "</PostingDate>" +
"<Item>" +
"<CompanyCode>" + Item[8] + "</CompanyCode>" +
"<GLAccount>" + this.suffixZeros(nonExpAcc + "") + "</GLAccount>" +
"<AmountInTransactionCurrency currencyCode=\"" + Item[5] + "\">-" + Item[4] + "</AmountInTransactionCurrency>" +
"<DebitCreditCode>S</DebitCreditCode>" +
"</Item>" +
"<Item>" +
"<CompanyCode>" + Item[8] + "</CompanyCode>" +
"<GLAccount>" + this.suffixZeros(Item[3] + "") + "</GLAccount>" +
"<AmountInTransactionCurrency currencyCode=\"" + Item[5] + "\">" + Item[4] + "</AmountInTransactionCurrency>" +
"<DebitCreditCode>H</DebitCreditCode>" +
"<AccountAssignment>" +
"<CostCenter>" + this.suffixZeros(Item[7] + "") + "</CostCenter>" +
"</AccountAssignment>" +
"</Item>" +
"</JournalEntry></JournalEntryCreateRequest></sfin:JournalEntryBulkCreateRequest></soapenv:Body></soapenv:Envelope>";
I am watching an event:
var events = EthProj.Message({}, { fromBlock: 0, toBlock: 'latest'});
events.watch((error, results) => {
Inside the event I do this tempString = ((messages.split(":")[1].split(",")[0] + " (From: " + messages.split(":")[2].split("}")[0]) + ")").replace(/"/g, ''); Which, long story short, makes a string from the event giving the event from the block (i.e. It gives the event made at block 173).
I then set a <h2> element's text from each event. When this happens it sets them in a seemingly random order. What can be going on, it sets them from block 0 to the latest block, so how can this happen.
Here is the full code: https://pastebin.com/wGt5kL1Y
var events = EthProj.Message({}, { fromBlock: 0, toBlock: 'latest'});
events.watch((error, results) => {
i++;
messages = "";
messages = JSON.stringify(results.args);
if(i === messageToGet) {
if(messages.split(":")[1].split(",")[0] != '""') {
console.log(messages.split(":")[1].split(",")[0] + " (From: " + messages.split(":")[2].split(",")[0].split("}")[0].split("}")[0] + ")");
tempString = ((messages.split(":")[1].split(",")[0] + " (From: " + messages.split(":")[2].split("}")[0]) + ")").replace(/"/g, '');
} else {
console.log("(No included text)" + "(From: " + messages.split(":")[2].split(",")[0].split("}")[0] + ")");
tempString = (("(no included text) " + " (From: " + messages.split(":")[2].split("}")[0]) + ")").replace(/"/g, '');
}
if((messages.split(":")[1].split(",")[0] === undefined) || (messages.split(":")[2].split(")")[0] === undefined)) {
return;
}
if(document.getElementById("Message" + placeToSet) != null) {
document.getElementById("Message" + placeToSet).remove();
if(document.getElementById("hr" + placeToSet) != null) {
document.getElementById("hr" + placeToSet).remove();
}
}
if(document.getElementById("Message" + placeToSet) === null) {
var newh2 = document.createElement('h2');
newh2.setAttribute("id", ("Message" + placeToSet));
var text = document.createTextNode(tempString);
newh2.appendChild(text);
document.body.appendChild(newh2);
var newHR = document.createElement('hr');
newHR.setAttribute("id", ("hr" + placeToSet));
}
}
});
I'm trying set my second query to the pie chart datasource in angular and nodejs using multiple queries to get the results at same time
Someone have some idea to solve it.
Server Side
var url = require('url');
//Require express,
var express = require('express');
//and create an app
var app = express();
var mysql = require('mysql');
var connection = mysql.createConnection({
multipleStatements: true,
host: 'localhost',
user: 'hello',
password: 'passw',
database: 'db',
port: 330333
});
//var connection = mysql.createConnection({multipleStatements: true});
app.get('/home', function (req, res) {
res.send('Hello World!');
});
app.get('/sts', function (req, res) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Credentials", true);
res.header("Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept");
// res.header('Access-Control-Allow-Methods', 'POST, \n\
// GET, PUT, DELETE, OPTIONS');
connection.query(
" SELECT ST.manufacturer, ST.name, ST.model, ST.os, ST.status, " +
" SI.Coord, ST.Last_Update_Date_Time FROM " +
" ( " +
" select s.manufacturer, s.name, s.model, s.os, s. status, " +
" concat(DATE(s.last_update_date),' ',TIME(s.last_update_time)) as Last_Update_Date_Time " +
" from sts s " +
" order by Last_Update_Date_Time DESC " +
" ) AS ST JOIN " +
" ( " +
" select DISTINCT CONCAT(si.latitude, ', ', si.longitude) as Coord, " +
" concat(DATE(update_date),' ',TIME(update_time)) as Update_Date_Time " +
" from sts_info si " +
" order by Update_Date_Time DESC " +
" ) AS SI ON ST.Last_Update_Date_Time = SI.Update_Date_Time; " +
" " +
" \n\ " +
" SELECT ST.manufacturer, ST.name, ST.model, ST.os, ST.status, " +
" count(status) as CountStatus, " +
" SI.Coord, ST.Last_Update_Date_Time FROM " +
" ( " +
" select s.manufacturer, s.name, s.model, s.os, s. status, " +
" concat(DATE(s.last_update_date),' ',TIME(s.last_update_time)) as Last_Update_Date_Time " +
" from sts s " +
" order by Last_Update_Date_Time DESC " +
" ) AS ST JOIN " +
" ( " +
" select DISTINCT CONCAT(si.latitude, ', ', si.longitude) as Coord, " +
" concat(DATE(update_date),' ',TIME(update_time)) as Update_Date_Time " +
" from sts_info si " +
" order by Update_Date_Time DESC " +
" ) AS SI ON ST.Last_Update_Date_Time = SI.Update_Date_Time " +
" group by status; "
, function (err, rows) {
if (!err) {
console.log("Database is connected... \n");
console.log('The solution is: ', rows[0]);
console.log('The solution is: ', rows[1]);
} else {
console.log("Error connecting database... \n");
console.log('Error while performing Query.');
}
console.log(rows[0]);
console.log(rows[1]);
res.end(JSON.stringify(rows[0]));
res.end(JSON.stringify(rows[1]));
});
});
var server = app.listen(8000, function () {
var port = server.address().port;
var host = server.address().address;
console.log('Example app listening at http://' + host + ':' + port);
});
AngularJs
**$scope.chartOpt1 = {
bindingOptions: {
dataSource: "sts"
},**
//Exposes the current URL in the browser address bar
//Maintains synchronization between itself and the browser's URL
//Represents the URL object as a set of methods
myApp.config(function ($routeProvider) {
$routeProvider
// route for the home page
.when('/', {
templateUrl: 'pages/home.html',
controller: 'mainController'
})
// route for the about page
.when('/about', {
templateUrl: 'pages/about.html',
controller: 'aboutController'
})
// route for the contact page
.when('/contact', {
templateUrl: 'pages/contact.html',
controller: 'contactController'
})
.when('/devicessts', {
templateUrl: 'pages/devicessts.html',
controller: 'devicesController'
})
.when('/sts', {
templateUrl: 'pages/sts.html',
controller: 'stsController'
});
// $locationProvider.html5Mode(true);
});
The result of the page:
Look at the data grid and pie chart aren't being showed in the page.
How do I retrieve the results from query to the angular?
Thank you
If you want get 2 responses you should :
post 2 request
OR
replace this
res.end(JSON.stringify(rows[0]));
res.end(JSON.stringify(rows[1]));
by this
res.end(JSON.stringify([rows[0],rows[1]]));
But a single http request can't send 2 responses