Information Technology Questions and Answers Community

Questions/Title


   Asked Questions

Views
127
Answers
1
Action
Views
125
Answers
1
Action
Views
130
Answers
1
Action
Views
107
Answers
1
Action
Views
118
Answers
1
Action
Views
86
Answers
1
Action
Views
80
Answers
1
Action
Views
110
Answers
1
Action
Views
115
Answers
1
Action
Views
106
Answers
1
Action
Views
87
Answers
1
Action
Views
88
Answers
1
Action
Views
97
Answers
1
Action
Views
94
Answers
1
Action
Views
111
Answers
1
Action
Views
99
Answers
1
Action
Views
94
Answers
1
Action
Views
104
Answers
1
Action
Views
98
Answers
1
Action
Views
113
Answers
1
Action
Views
107
Answers
1
Action
Views
84
Answers
1
Action
Views
103
Answers
1
Action
Views
93
Answers
1
Action
Views
90
Answers
1
Action
Views
88
Answers
1
Action
Views
91
Answers
1
Action
Views
102
Answers
1
Action
Views
109
Answers
1
Action
Views
106
Answers
1
Action
Views
103
Answers
1
Action
Views
113
Answers
1
Action
Views
103
Answers
1
Action
Views
94
Answers
1
Action
Views
99
Answers
1
Action
Views
103
Answers
1
Action
Views
169
Answers
1
Action
Views
114
Answers
2
Action
Views
98
Answers
1
Action
Views
107
Answers
1
Action
Views
122
Answers
1
Action
Views
101
Answers
1
Action
Views
107
Answers
1
Action
Views
130
Answers
2
Action
Views
218
Answers
2
Action
Views
143
Answers
2
Action
Views
106
Answers
1
Action
Views
100
Answers
1
Action
Views
137
Answers
1
Action

I think my question is a little bit more complicated than what I saw on the internet because I need to make multiple filtrations on a single table. So here's my code:

 

Views
105
Answers
0
Action

I have Restful API service in asp.net, which provides code for JavaScript to use, i need to use its functions in angular. I am posting code here which has RestAPI function and it includes calls to data and it should return JSON data to calling function i believe. please if anybody familiar with the solution your response will be highly appreciated. Thank-you.

function RestAPI(){ self = this; }
RestAPI.prototype = {
    self: null,
    urlString: "http://exclusiveautosales.azurewebsites.net/ExclusiveAutoSales_Handler.ashx",
    GetFiltersMain:function(successFunction,failFunction,token) {
        var data = { 'interface': 'RestAPI', 'method': 'GetFiltersMain', 'parameters': {}, 'token': token };
        var jsonData = dojo.toJson(data);
        var xhrArgs = {
            url: self.urlString,
            handleAs: 'json',
            postData: jsonData,
            load: successFunction,
            error: failFunction };
        var deferred = dojo.xhrPost(xhrArgs);
    },
    GetMakeModelPrice:function(make_id,model_id,min_price,max_price,successFunction,failFunction,token) {
        var data = { 'interface': 'RestAPI', 'method': 'GetMakeModelPrice', 'parameters': {'make_id':make_id,'model_id':model_id,'min_price':min_price,'max_price':max_price}, 'token': token };

        var jsonData = dojo.toJson(data);
        var xhrArgs = {
            url: self.urlString,
            handleAs: 'json',
            postData: jsonData,
            load: successFunction,
            error: failFunction };
        var deferred = dojo.xhrPost(xhrArgs);
    },
    GetSearchResult:function(search_q,make_id,model_id,year_id,engine_id,color_id,body_id,transmission_id,fueltype_id,subfeature_id,minPrice,maxPrice,successFunction,failFunction,token) 
JavaScript  
angularjs  
rest  
Date Posted:06 Sep at 08:34  Posted By:0 
Views
93
Answers
0
Action
2017-09-06 11:58:16.380  WARN 8376 --- [ry:/127.0.0.1:0] o.apache.zookeeper.server.NIOServerCnxn  : caught end of stream exception

org.apache.zookeeper.server.ServerCnxn$EndOfStreamException: Unable to read additional data from client sessionid 0x15e55dfd1a70001, likely client has closed socket
    at org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:228) ~[zookeeper-3.4.9.jar:3.4.9-1757313]
    at org.apache.zookeeper.server.NIOServerCnxnFactory.run(NIOServerCnxnFactory.java:203) [zookeeper-3.4.9.jar:3.4.9-1757313]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_112]

2017-09-06 11:58:16.381  INFO 8376 --- [ry:/127.0.0.1:0] o.apache.zookeeper.server.NIOServerCnxn  : Closed socket connection for client /127.0.0.1:53191 which had sessionid 0x15e55dfd1a70001
2017-09-06 11:58:16.427  INFO 8376 --- [127.0.0.1:53184] org.I0Itec.zkclient.ZkEventThread        : Terminate ZkClient event thread.
2017-09-06 11:58:16.428  INFO 8376 --- [0 cport:53184):] o.a.z.server.
Java  
Apache  
apache-kafka  
apache-zookeeper  
Date Posted:06 Sep at 08:32  Posted By:0 
Views
121
Answers
0
Action

I have a function where I check my two (or one) input fileds if they are empty i want to let's say print alert in window but if they have vaules i want to run else but in my case alert is not popping up and if i want to submit those two fileds with data it is ok pushing it and doing alll stuff in else but whole browser is reloading. I was trying to add prevent.Default() but not working. Or return false

UPDATE: I made some changes and know when input is empty alert is popping up, but when i colse it it is still realoding whole page, same thing if else is executed all browser is reloading

 let pushBtn = document.getElementById('push-btn');

pushBtn.addEventListener('click', pushData);


 function pushData() {

let deviceVal = document.getElementById('device').value;
let powerVal = document.getElementById('power').value;

if (deviceVal != '' || powerVal != '') {
    let list = document.getElementById('list-group')
    let button = document.createElement('button');
    let ul = document.createElement('ul');
    let liFirst = document.createElement('li');
    let liSecond = document.createElement('li');
    let liThird = document.createElement('li');

    button.classList.add("list-group-item");
    ul.classList.add("desc");
    liFirst.classList.add("t-desc");
    liSecond.classList.add("t-desc2");
    liThird.classList.add("t-desc3");
    liFirst.textContent = deviceVal;
    liSecond.textContent = powerVal;
    liThird.innerHTML = `<label class="switch">
        <input type="checkbox">
        <span class="slider round"></span>
      </label>`
    modal.style.display = 'none';
    ul.append(liFirst);
    ul.append(liSecond);
    ul.append(liThird);
    button.append(ul);

    list.prepend(button);



} else {
    alert('aaa');
    return false

}

}

Views
107
Answers
1
Action
Views
79
Answers
0
Action
Views
114
Answers
0
Action
Views
131
Answers
0
Action
Views
87
Answers
0
Action
Views
114
Answers
0
Action

I have a webpack file shown at the bottom of this question. I'm trying to include a config file 'as is', with no processing, and the suggested way to do it was through using CommonsChunkPlugin, which I've implemented, and it works alright - It generates two files correctly, with one containing the config.js and one containing the rest of the bundle. However, the config.js also includes over 10,000 lines of other code that seems to be related to bundling, XHR requests, and chunking. Why? How can I remove this code from just this route, and not the main bundle? The reason to do this would be to make config.js easily editable.

const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const BUILD_DIR = path.resolve(__dirname, 'dist');
const APP_DIR = path.resolve(__dirname, 'src');

process.traceDeprecation = true;

const config = {
  entry: {
    app: APP_DIR + '/app.js',
    config: APP_DIR + '/config.js'
  },
  output: {
    path: BUILD_DIR,
    filename: 'bundle.js',
    publicPath: '/'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        include: APP_DIR,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['es2015', 'react', "stage-2"]
          }
        },
      },
      {
        test: /\.js$/,
        enforce: 'pre',
        include: APP_DIR,
        use: 'eslint-loader',
      },
      {
        test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
        use: [{
          loader:'file-loader',
          options:{limit:10000,mimetype:'application/font-woff'}
        }]
      },
      {
        test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
        use: [{
          loader:'file-loader',
          options:{limit:10000,mimetype:'application/octet-stream'}
        }]
      },
      {
        test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
        use: [{
          loader:'file-loader'
        }]
      },
      {
        test: /\.png$/,
        use: [{
          loader:'file-loader'
        }]
      },
      {
        test: /\.svg(\?v=\d+\.\d+\.\d+)?$/
JavaScript  
webpack  
ecmascript-6  
webpack-dev-server  
commonschunkplugin  
Date Posted:06 Sep at 07:46  Posted By:0 
Views
110
Answers
0
Action
Views
298
Answers
0
Action
Views
122
Answers
0
Action

I pull a list of areas to display on a google maps from my database. I would also like to show the city closest to each area using reverse geocoding but cannot get it to work. I have some experience with AngularJS and promises and have searched Stackoverflow but cannot find any solution to this problem.

HTML:

<div ng-repeat="area in vm.areas">
 <span>{{area.name}}</span>
 <span>Close to: </span> <span>{{vm.getCity(area)}}</span>
</div>

JS:

vm.getCity = function(area){
 var center = getCenter(area.paths); 
 getAddress(center[0], center[1]).then(function(city){
   console.log(city);
   return city;
 })
}

function getAddress (latitude, longitude) {
  return $q(function (resolve, reject) {
      var request = new XMLHttpRequest();

      var method = 'GET';
      var url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng=' + latitude + ',' + longitude + '&sensor=true';
      var async = true;

      request.open(method, url, async);
      request.onreadystatechange = function () {
          if (request.readyState == 4) {
              if (request.status == 200) {
                  var data = JSON.parse(request.responseText);
                  var results = data.results;
                  var returnString = ""
                  for(var i=0; i<results.length; i++){
                    var types = results[i].types;
                    if(types[0] === 'locality'){
                      returnString = results[i].address_components[0].long_name;
                    }
                  }
                  resolve(returnString);
              }
              else {
                  reject(request.status);
              
JavaScript  
angular-js  
google-maps  
google-maps-api-3  
Date Posted:06 Sep at 07:13  Posted By:0 
Views
82
Answers
0
Action

I pull a list of areas to display on a google maps from my database. I would also like to show the city closest to each area using reverse geocoding but cannot get it to work. I have some experience with AngularJS and promises and have searched Stackoverflow but cannot find any solution to this problem.

HTML:

<div ng-repeat="area in vm.areas">
 <span>{{area.name}}</span>
 <span>Close to: </span> <span>{{vm.getCity(area)}}</span>
</div>

JS:

vm.getCity = function(area){
 var center = getCenter(area.paths); 
 getAddress(center[0], center[1]).then(function(city){
   console.log(city);
   return city;
 })
}

function getAddress (latitude, longitude) {
  return $q(function (resolve, reject) {
      var request = new XMLHttpRequest();

      var method = 'GET';
      var url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng=' + latitude + ',' + longitude + '&sensor=true';
      var async = true;

      request.open(method, url, async);
      request.onreadystatechange = function () {
          if (request.readyState == 4) {
              if (request.status == 200) {
                  var data = JSON.parse(request.responseText);
                  var results = data.results;
                  var returnString = ""
                  for(var i=0; i<results.length; i++){
                    var types = results[i].types;
                    if(types[0] === 'locality'){
                      returnString = results[i].address_components[0].long_name;
                    }
                  }
                  resolve(returnString);
              }
              else {
                  reject(request.status);
              
JavaScript  
angularjs  
google-maps  
google-maps-api3  
Date Posted:06 Sep at 07:09  Posted By:0 
Views
84
Answers
0
Action

I recently added a Meteor.callPromise() function to my code, which I would like linked to my waitOn hook.

Currently my waitOn hook in my Iron Router looks like this:

client/main.js

Router.route('/paymentB2C', {
 name: 'paymentB2C',     
 template: 'paymentB2C',

    waitOn: function(){

       return Meteor.subscribe('pendingPayments');      
    },

});

server/main.js

Meteor.publish('pendingPayments', function pendingPayments(){

return recipientsDetails.find({paymentStatus:"Pending"}, {sort: {paymentDate: -1 }});

});

The code as is works perfectly well, it even displays a "loading..." animation that runs during the waitOn.

The problem is that my Meteor.callPromise() code takes a long time to complete, usually way after waitOn hook. This is because the Meteor.callPromise() function points to a HTTP.call() function.

Where do place my Meteor.callPromise() code so that the "loading..." animation plays until the Meteor.callPromise() call back function completes?

Find below my Meteor.callPromise() code

client/main.js

'click #approvePaymentButton'(event, instance) {

    var recipientsAmount = 500;
    var recipientsNumber = 0705087633;

    Meteor.callPromise('b2c', recipientsNumber, recipientsAmount).then(
        function(results) {

        Modal.show('c2bNotifications', {msg: "UGX " +recipientsAmount+ "/- was successfully paid to " +recipientsNumber});

        }).catch( function(error) {
            alert("Error!");
            }

);   

server/main.js

Meteor.methods({
'b2c': function(recipientsNumber, recipientsAmount){

            var postData = {
            "phone": recipientsNumber,
            "amount": recipientsAmount
            };

            const resultPromise = new Promise((resolve, reject) => {
                    HTTP.call('POST', 'http://88cbfe20.ngrok.io/TalkingSam/crows/b2c.php', 
                        {
                          headers: { apiKey: '27727bcccde09fa70af2f93d490e05f4eb2b28ed465e47263b4eae083b33558f' },
                          params: postData
                        },
                        function (error, response) {
                            if (error) {
                                console
JavaScript  
meteor  
ngrok  
Date Posted:06 Sep at 07:09  Posted By:0 
Views
71
Answers
0
Action
Views
141
Answers
0
Action
Views
317
Answers
0
Action

For a chrome plugin i need to retrieve messages. These messages are supplied to me through a html variable.

 

There are 2 messages in the example wich is provided below and they start with: <tr bgcolor="#FFFFFF"> and end with: </tr>

 

I retrieved the first message data but now i need to make it so it retrieves all the data from each of those <tr bgcolor="#FFFFFF"> </tr> messages.

 

What i get provided:

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

 

<html>

 

<head>

  <link rel="STYLESHEET" type="text/css" href="xxx">

  <title>Untitled</title>

</head>

 

<body class="bodySinScrollHor">

 

 

  <table width="95%" align="center">

    <tr>

      <td class="etiquetaIzquierda" colspan=6>

        <a class="etiquetaIzquierda"><img border=0 height=15 src="xxx"> &nbsp;Comunicaciones (2)</a>

      </td>

      </td>

    </tr>

    <tr>

      <td colspan=6>

        <hr size=1 width="100%">

      </td>

    </tr>

    <tr id="comunicaciones">

      <td colspan=6>

        <table width="100%" border=0 bordercolor="#000000" cellspacing=0 cellpadding=0>

 

          <tr bgcolor="#FFFFFF">

            <td width="9%" class="valorCampoSinTamFijoPeque">2017-08-31T00:00:00</td>

            <td width="9%" class="valorCampoSinTamFijoPeque">13:22</td>

            <td width="4%" align=left class="valorcampoSinTamFijoPeque">

              <img src="xxx" title=" Out"> &nbsp; &nbsp;

            </td>

            <td width="11%" class="valorCampoSinTamFijoPeque" valign=top>

              <font class="valorcampoSinTamFijoPeque"><a title="clientname" class="valorcampoSinTamFijoPeque">ClientName</a></font>

            </td>

            <td width="14%" class="valorCampoSinTamFijoPeque" width="100%">Subject</td>

            <!-- <td width="61%"class="valorCampoSinTamFijoPeque">message text here</td> -->

          </tr>

 

          <tr bgcolor="#FFFFFF">

            <td width="9%" class="valorCampoSinTamFijoPeque">2017-08-31T00:00:00</td>

            <td width="9%" class="valorCampoSinTamFijoPeque">13:21</td>

            <td width="4%" align=left class="valorcampoSinTamFijoPeque">

              <img src="xxx" title=" Out"> &nbsp; &nbsp;

            </td>

            <td width="11%" class="valorCampoSinTamFijoPeque" valign=top>

              <font class="valorcampoSinTamFijoPeque"><a title="clientname" class="valorcampoSinTamFijoPeque">ClientName</a></font>

            </td>

            <td width="14%" class="valorCampoSinTamFijoPeque" width="100%">Subject</td>

            <!-- <td width="61%"class="valorCampoSinTamFijoPeque">Message Text Here</td> -->

          </tr>

 

      </td>

    </tr>

    </table>

 

    </td>

    </tr>

  </table>

 

</body>

 

</html>

 Run code snippetExpand snippet

The code i run to retrieve the data from the first message (note that there are 2 messages in this case, but there are people that have 54 messages so it needs to loop that many times. this code //Get count of regex matches. (amount of messages)

    var count = (html1.match(/<tr bgcolor="#FFFFFF">/g) || []).length;

    console.log(count); provides that number for me) :

 

matches[0].forEach(function(match, index) {

  var cleintcode = /<div\s*class="t_seg_codCliente">(.*?)<\/div>/.exec(match)[1];

  var cleintname = /<div\s*class="t_seg_nomCliente">(.*?)<\/div>/.exec(match)[1];

  var taxId = /<div\s*class="t_seg_nifCliente">(.*?)<\/div>/.exec(match)[1];

  var date = /<div\s*class="t_seg_fechaPresCliente">(.*?)<\/div>/.exec(match)[1];

  var state = /<div\s*class="t_seg_estadoCliente">(.*?)<\/div>/.exec(match)[1];

  var expirydate = /<div\s*class="t_seg_fechaCadCliente">(.*?)<\/div>/.exec(match)[1];

  var communications = /<div\s*class="t_seg_comCliente"><a .*;">(.*?)<\/a>/.exec(match)[1];

  var comclient = /<div\s*class="t_seg_comCliente"><a href="javaScript:popupComs\('(.*?)'/.exec(match)[1];

  var messages = "xxx" + comclient;

 

  var html1 = httpGet(messages);

 

  //console.log(html1);

 

  const cleanupDocString = html1.replace(/(?:<!--|-->)/gm, '');

 

  parser = new DOMParser();

 

  htmlDoc = parser.parseFromString(cleanupDocString, "text/html");

 

  //console.log(htmlDoc);

 

  var communicationsvalue = htmlDoc.getElementsByClassName("valorCampoSinTamFijoPeque")[0].textContent;

 

  if (communicationsvalue.indexOf('No existen comunicaciones asociadas a este cliente.') !== -1) {

    console.log("This chat does not contain any communiction!");

  } else {

 

    //Get count of regex matches. (amount of messages)

    var count = (html1.match(/<tr bgcolor="#FFFFFF">/g) || []).length;

    console.log(count);

 

    var comDate = htmlDoc.getElementsByClassName("valorCampoSinTamFijoPeque")[0].textContent;

    var comTime = htmlDoc.getElementsByClassName("valorCampoSinTamFijoPeque")[1].textContent;

    var comType = htmlDoc.getElementsByTagName('img')[1].src;

    var comClient = htmlDoc.getElementsByTagName('a')[1].textContent;

    var comSubject = htmlDoc.getElementsByClassName("valorCampoSinTamFijoPeque")[6].textContent;

 

    const element = htmlDoc.getElementsByClassName('valorCampoSinTamFijoPeque')[7];

 

    var pulledMessage = element.innerHTML;

 

    var messageData = [{

        clientCode: cleintcode,

        clientName: cleintname,

        taxID: taxId,

        cleintDate: date,

        cleintState: state,

        cleintExpirydate: expirydate

      },

      {

        mesDate: comDate,

        mesTime: comTime,

        mesType: comType,

        mesClient: comClient,

        mesSubject: comSubject,

        mesText: pulledMessage

      }

    ];

    console.log(messageData);

  }

});

 Run code snippetExpand snippet

The code above gives me this console log:

 

0:

cleintDate:"31/08/17"

cleintExpirydate:"29/11/17"

cleintState:"Subject"

clientCode:"xxxxxx"

clientName:"clientName"

taxID:""

proto:Object

1:

mesClient:"ClientName"

mesDate:"2017-08-31T00:00:00"

mesSubject:"Subject "

mesText:"Message text Here"

mesTime:"13:22"

mesType:"link"

proto:Object

note that array 0 should not change because these messages are from the same person. I just need to grab the second message aswell. So i technically need a second array like array 1 containing the data from the second message.

 

Wanted result:

 

0:

cleintDate:"31/08/17"

cleintExpirydate:"29/11/17"

cleintState:"Subject"

clientCode:"xxxxxx"

clientName:"clientName"

taxID:""

proto:Object

1:

mesClient:"ClientName"

mesDate:"2017-08-31T00:00:00"

mesSubject:"Subject "

mesText:"Message text Here"

mesTime:"13:22"

mesType:"link"

proto:Object

3:

mesClient:"ClientName"

mesDate:"2017-08-31T00:00:00"

mesSubject:"Subject "

mesText:"Message text Here"

mesTime:"13:22"

mesType:"link"

proto:Object

I know i have to build a for loop but i have no idea on how do this so it looks for the second <tr bgcolor="#FFFFFF"> </tr> after the first.

 

I hope my question is clear! And i hope you guys can teach me.

 

content is slightly edited to hide personal information.

Views
79
Answers
0
Action

 

I am new in android development and trying to use ListView in my simple app. But it is not working and throwing error.

Here is the code of DisplayMessageActivity.java. I have created a String Array and putted value manually. I am calling resource ID using what we call custom adapter.

package com.example.myfirstapp;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

import java.util.List;

public class DisplayMessageActivity extends AppCompatActivity {
String[] mobileArray={"A", "B"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_display_message);
        Intent intent=getIntent();
        String message=intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
        TextView textView=(TextView) findViewById(R.id.textView);
        textView.setText(message);
        System.out.println("seq");
        ArrayAdapter adapter=new ArrayAdapter<String>(this, R.layout.activity_display_message, R.id.listView, mobileArray);
        System.out.println("seq2");
        ListView listView=(ListView) findViewById(R.id.listView);
        System.out.println("seq3");
        listView.setAdapter(adapter);
        System.out.println("seq44");
    }
}

XML of activity_display_message.xml is below where I created one ListView.


Java  
Android  
XML  
Listview  
Date Posted:06 Sep at 06:47  Posted By:Rohit Roy 
Views
103
Answers
0
Action
Views
388
Answers
4
Action
Views
507
Answers
3
Action
Views
277
Answers
1
Action
Views
278
Answers
1
Action
Views
306
Answers
1
Action
Views
297
Answers
1
Action
Edit Account
LOGIN INFORMATION
Change Settings
Email Notifications Notifications will be sent to abcd@gmail.com
Select option for your email notifications:
Mature / News Filter We'll send on email when new jobs are posted
Option 2 for email notification We'll send on email when new jobs are posted