答:
Try this I have edited the your jquery function UI issues due to css

$(function() {
  $(".payNow").on("click", function(e) {
    var $list = $(this).closest(".pricing-table");
      name = $list.find(".myTitle").text();
      name += $($list.find("li")[1]).text();

    console.log(name);
  });
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<section id="pricing-table">
<div class="row pricelistNew">
<div class="pricing">

<div class="col-md-4 col-sm-12 col-xs-12">
<div class="pricing-table">
<div class="pricing-header">
<p class="pricing-title myTitle">Easy Plan </p>

<p class="pricing-rate">₹ 1000 <br><span>Including All Tax</span></p>
Easy Plan
</div>

<div class="pricing-list">
<ul>
    <li>Contacts details up to : 25</li>
     <li>Bonus Contact details up to : 2</li>
     <li>Area Master Assistance : No</li>
     <li>Contact details through sms : Yes</li>
 </ul>
</div>
</div>
</div>

<div class="col-md-4 col-sm-12 col-xs-12">
<div class="pricing-table">
<div class="pricing-header">
<p class="pricing-title myTitle">Cool Plan </p>

<p class="pricing-rate">₹ 2000 <br><span>Including All Tax</span></p>
Cool Plan
</div>

<div class="pricing-list">
<ul>
    <li>Contacts details up to : 48</li>
     <li>Bonus Contact details up to : 4</li>
     <li>Area Master Assistance : Yes</li>
     <li>Contact details through sms : Yes</li>
 </ul>
</div>
</div>
</div>

<div class="col-md-4 col-sm-12 col-xs-12">
<div class="pricing-table">
<div class="pricing-header">
<p class="pricing-title myTitle">Free Plan </p>

<p class="pricing-rate">₹ 0 <br><span>Including All Tax</span></p>
Free Plan
</div>

<div class="pricing-list">
<ul>
    <li>Contacts details up to : 5</li>
     <li>Bonus Contact details up to : 00</li>
     <li>Area Master Assistance : No</li>
     <li>Contact details through sms : Yes</li>
 </ul>
</div>
</div>
</div>
</div>
</div>
</section></code>```

Title: How to get the particular div values using jQuery

Body:
Try this I have edited the your jquery function UI issues due to css

$(function() {
  $(".payNow").on("click", function(e) {
    var $list = $(this).closest(".pricing-table");
      name = $list.find(".myTitle").text();
      name += $($list.find("li")[1]).text();

    console.log(name);
  });
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<section id="pricing-table">
<div class="row pricelistNew">
<div class="pricing">

<div class="col-md-4 col-sm-12 col-xs-12">
<div class="pricing-table">
<div class="pricing-header">
<p class="pricing-title myTitle">Easy Plan </p>

<p class="pricing-rate">₹ 1000 <br><span>Including All Tax</span></p>
<a class="btn btn-custom payNow">Easy Plan</a>
</div>

<div class="pricing-list">
<ul>
    <li>Contacts details up to : 25</li>
     <li>Bonus Contact details up to : 2</li>
     <li>Area Master Assistance : No</li>
     <li>Contact details through sms : Yes</li>
 </ul>
</div>
</div>
</div>

<div class="col-md-4 col-sm-12 col-xs-12">
<div class="pricing-table">
<div class="pricing-header">
<p class="pricing-title myTitle">Cool Plan </p>

<p class="pricing-rate">₹ 2000 <br><span>Including All Tax</span></p>
<a class="btn btn-custom payNow">Cool Plan</a>
</div>

<div class="pricing-list">
<ul>
    <li>Contacts details up to : 48</li>
     <li>Bonus Contact details up to : 4</li>
     <li>Area Master Assistance : Yes</li>
     <li>Contact details through sms : Yes</li>
 </ul>
</div>
</div>
</div>

<div class="col-md-4 col-sm-12 col-xs-12">
<div class="pricing-table">
<div class="pricing-header">
<p class="pricing-title myTitle">Free Plan </p>

<p class="pricing-rate">₹ 0 <br><span>Including All Tax</span></p>
<a class="btn btn-custom payNow">Free Plan</a>
</div>

<div class="pricing-list">
<ul>
    <li>Contacts details up to : 5</li>
     <li>Bonus Contact details up to : 00</li>
     <li>Area Master Assistance : No</li>
     <li>Contact details through sms : Yes</li>
 </ul>
</div>
</div>
</div>
</div>
</div>
</section>


来源: stackexchange

问:
PHP DateTime CreateFromFormat Issue
```<code>function validateDate($date, $format = 'm-Y') {
    $d = DateTime::createFromFormat($format, $date);
    return $d && $d->format($format) == $date;
}

validateDate('09-2017', 'm-Y');
</code>```

function was copied from this answer or php.net

I'm very puzzled to why this returns false while it returns true for the previous months. Any ideas?

答:
If you are not supplying a day. current one is used; just like explained in previous answer.
But this can be quickly solved with one format sign: !, which resets all fields (year, month, day, hour, minute, second, fraction and timezone information) to the Unix Epoch; see format table.

Fix:

```<code>function validateDate($date, $format = 'm-Y') {
    $d = DateTime::createFromFormat('!'.$format, $date);
    return $d && $d->format($format) == $date;
}
</code>```

function was copied from this answer or php.net

ContentLicense: CC BY-SA 3.0

Title: PHP DateTime CreateFromFormat Issue

Body:
function validateDate($date, $format = 'm-Y') {
    $d = DateTime::createFromFormat($format, $date);
    return $d && $d->format($format) == $date;
}

validateDate('09-2017', 'm-Y');

function was copied from this answer or php.net

I'm very puzzled to why this returns false while it returns true for the previous months. Any ideas?

Body:
If you are not supplying a day. current one is used; just like explained in previous answer.
But this can be quickly solved with one format sign: !, which resets all fields (year, month, day, hour, minute, second, fraction and timezone information) to the Unix Epoch; see format table.

Fix:

function validateDate($date, $format = 'm-Y') {
    $d = DateTime::createFromFormat('!'.$format, $date);
    return $d && $d->format($format) == $date;
}

function was copied from this answer or php.net


问:
Check the date format of string if it's according to required format or not
I have the same question asked here in Java,
is it possible in swift?</p>

```<code>func stringToDate(str: String) -> Date{

    let dateFormatter = DateFormatter()
    dateFormatter.dateFormat = "dd/MM/yyyy"

    //check validation of str

    return date
}
</code>```

答:
For Swift 4 the syntax have changed a bit:</p>

```<code> func isValidDate(dateString: String) -> Bool {
    let dateFormatterGet = DateFormatter()
    dateFormatterGet.dateFormat = "yyyy-MM-dd hh:mm:ss"
    if let _ = dateFormatterGet.date(from: dateString) {
        //date parsing succeeded, if you need to do additional logic, replace _ with some variable name i.e date
        return true
    } else {
        // Invalid date
        return false
    }
}
</code>```

Body:
I have the same question asked here in Java,
is it possible in swift?

func stringToDate(str: String) -> Date{

    let dateFormatter = DateFormatter()
    dateFormatter.dateFormat = "dd/MM/yyyy"

    //check validation of str

    return date
}

Body:
For Swift 4 the syntax have changed a bit:

 func isValidDate(dateString: String) -> Bool {
    let dateFormatterGet = DateFormatter()
    dateFormatterGet.dateFormat = "yyyy-MM-dd hh:mm:ss"
    if let _ = dateFormatterGet.date(from: dateString) {
        //date parsing succeeded, if you need to do additional logic, replace _ with some variable name i.e date
        return true
    } else {
        // Invalid date
        return false
    }
}


问:
How can create a bottom curve aside bottom-border-radius
I would like to make a rounded div using css, I already used the bottom-border-radius but I dont want that, if there is any other way to achieve that please share.

I know this can be achieved by using bottom-border-radius but is there any other way?

答:
you will use shorthand border-radius property and also individually have to  give values like this

.sample1 {
 width: 100px;
 height: 100px;
 margin-bottom: 5px;
 border-radius: 0 0 50% 50%;
 background-color: #cccccc;
}
.sample2 {
 width: 100px;
 height: 100px;
 margin-bottom: 5px;
 border-bottom-left-radius: 50%;
 border-bottom-right-radius: 50%;
 background-color: #444444;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="sample1">
</div>

<div class="sample2">
</div></code>```

Body:
you will use shorthand border-radius property and also individually have to  give values like this

.sample1 {
 width: 100px;
 height: 100px;
 margin-bottom: 5px;
 border-radius: 0 0 50% 50%;
 background-color: #cccccc;
}
.sample2 {
 width: 100px;
 height: 100px;
 margin-bottom: 5px;
 border-bottom-left-radius: 50%;
 border-bottom-right-radius: 50%;
 background-color: #444444;
}

<div class="sample1">
</div>

<div class="sample2">
</div>


问:
Xamarin wont build Android application
I'm an android newbie, Installed Xamarin for visual studio, also Installed Android SDK and loads of stuff on there, however I get this error when building:

```<code>1>------ Build started: Project: WordSolverO, Configuration: Debug Any CPU ------
1>    Processing: obj\Debug\res\layout\main.xml
1>    Processing: obj\Debug\res\values\strings.xml
1>  WordSolverO -> C:\Users\Elmeri\Documents\WordSolverO\WordSolverO\bin\Debug\WordSolverO.dll
1>    Processing: obj\Debug\res\layout\main.xml
1>    Processing: obj\Debug\res\values\strings.xml
1>    Processing: obj\Debug\res\layout\main.xml
1>    Processing: obj\Debug\res\values\strings.xml
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1868,3): error MSB6006: "javac.exe" exited with code 2.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
</code>```

Heres the Xamarin Diagnostics:

```<code>[I:sdk]:                    Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidSdkDirectory found:
    Path contains adb in \platform-tools (C:\Program Files (x86)\Android\android-sdk).
[I:sdk]:                    Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidNdkDirectory found:
    Path contains ndk-stack in \. (C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r11c\).
[I:sdk]:                    Key HKCU\SOFTWARE\Novell\Mono for Android\JavaSdkDirectory found:
    Path contains jarsigner.exe in \bin (C:\Program Files\Java\jdk-9.0.1).
[I:Unknown]:              Found Xamarin.Android 7.0.2
[I:Unknown]:              Found Android SDK. API levels: 19, 20, 21, 23
[I:]:                     Tracking android devices started
[D:]:                     TrackDeviceTask got:
[D:]:                     Tracking avd started
[I:]:                     Got new device list from adb with 0 devices
[D:]:                     avd watcher *.ini path: 'C:\Users\Elmeri\.android\avd'
[D:]:                     avd watcher android path: 'C:\PROGRA~2\Android\ANDROI~1\tools\android.BAT'
[D:]:                     avd watcher: got device list from avd with 1 devices
</code>```

I've checked the JDK & SDK locations, and theyre fine it seems
https://i.imgur.com/M4DtPh3.png

So I have no Idea whats wrong, I dont see any descriptive error here..

答:
I bet that source of all these problems is DEX 64K limit + old proguard version (in case of multidex enabled).
You should upgrade Proguard, according to this topic (procedure has to be performed after each Built-Tools update by SDK-Manager):
http://stackoverflow.com/questions/39514518/xamarin-android-proguard-unsupported-class-version-number-52-0

Also check that you have only Java SDK 1.8 installed (remove any 1.7 versions if installed).

PS Don't forget to modify your mainClassesDex.bat (or your app will crash at startup @ Android 4.4 and lower, but work well @ newer versions):
http://www.jon-douglas.com/2016/09/05/xamarin-android-multidex/

Title: Xamarin wont build Android application

Body:
I'm an android newbie, Installed Xamarin for visual studio, also Installed Android SDK and loads of stuff on there, however I get this error when building:

1>------ Build started: Project: WordSolverO, Configuration: Debug Any CPU ------
1>    Processing: obj\Debug\res\layout\main.xml
1>    Processing: obj\Debug\res\values\strings.xml
1>  WordSolverO -> C:\Users\Elmeri\Documents\WordSolverO\WordSolverO\bin\Debug\WordSolverO.dll
1>    Processing: obj\Debug\res\layout\main.xml
1>    Processing: obj\Debug\res\values\strings.xml
1>    Processing: obj\Debug\res\layout\main.xml
1>    Processing: obj\Debug\res\values\strings.xml
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1868,3): error MSB6006: "javac.exe" exited with code 2.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Heres the Xamarin Diagnostics:

[I:sdk]:                    Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidSdkDirectory found:
    Path contains adb in \platform-tools (C:\Program Files (x86)\Android\android-sdk).
[I:sdk]:                    Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidNdkDirectory found:
    Path contains ndk-stack in \. (C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r11c\).
[I:sdk]:                    Key HKCU\SOFTWARE\Novell\Mono for Android\JavaSdkDirectory found:
    Path contains jarsigner.exe in \bin (C:\Program Files\Java\jdk-9.0.1).
[I:Unknown]:              Found Xamarin.Android 7.0.2
[I:Unknown]:              Found Android SDK. API levels: 19, 20, 21, 23
[I:]:                     Tracking android devices started
[D:]:                     TrackDeviceTask got:
[D:]:                     Tracking avd started
[I:]:                     Got new device list from adb with 0 devices
[D:]:                     avd watcher *.ini path: 'C:\Users\Elmeri\.android\avd'
[D:]:                     avd watcher android path: 'C:\PROGRA~2\Android\ANDROI~1\tools\android.BAT'
[D:]:                     avd watcher: got device list from avd with 1 devices

I've checked the JDK & SDK locations, and theyre fine it seems
https://i.imgur.com/M4DtPh3.png

So I have no Idea whats wrong, I dont see any descriptive error here..


问:
How i can split array in js?
How i can split string in js for result:

```<code>result = ["post_address", "location", "area"]
</code>```

This is problem? Need help with re

```<code>let re = ???
let arr = "post_address[location][area]".split(re)
</code>```

答:
Use Lodash:

const str = "post_address[location][area]";
const output = _.compact(_.split(str, /\[|\]/));
console.log(output);```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script></code>```

Title: How i can split array in js?

Body:
How i can split string in js for result:

result = ["post_address", "location", "area"]

This is problem? Need help with re

let re = ???
let arr = "post_address[location][area]".split(re)

Body:
Use Lodash:

const str = "post_address[location][area]";
const output = _.compact(_.split(str, /\[|\]/));
console.log(output);

<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script>


问:
How to mute android soft keyboard programmatically?
How to mute android soft keyboard programmatically?
I try to use </p>

```<code>AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
audio.setStreamMute(AudioManager.FX_KEY_CLICK, true);
</code>```

<p>But this doesn't help. </p>

答:
```<code>if (isSetSound) {
        AudioManager am = (AudioManager) getSystemService(AUDIO_SERVICE);
        am.playSoundEffect(AudioManager.FX_KEY_CLICK);
    } else {
        AudioManager am = (AudioManager) getSystemService(AUDIO_SERVICE);
        am.setStreamMute(AudioManager.FX_KEY_CLICK, false);
    }
</code>```

Body:
How to mute android soft keyboard programmatically?
I try to use

AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
audio.setStreamMute(AudioManager.FX_KEY_CLICK, true);

But this doesn't help.


问:
Displaying data into HTML Tables
I am able to display my data from db. I want to display in a table under tabs but then my data appears crooked. The rows are not straight. why is that happening to the table?

it is arranged kind of this way.

the updated code below doesn't provide the right format for the table
Table

```<code>  id  name
     1    James
    4   Michel
   2  Jonathan
</code>```

HTML

```<code><div class="row">
    <div class="col-md-7">

        <div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
                @foreach($items as $item)
                    <li><a href="#tab_{{ $item->id }}" data-toggle="tab" >{!!$item->name!!}</a></li>
                @endforeach
            </ul>
            <div class="tab-content">
                @foreach($items as $item)
                    <div class="tab-pane active" id="tab_{{ $item->id }}">
                        @foreach($item->products as $product)
                            <table class="table">
                                <thead>
                                    <tr>
                                        <th>No#</th>
                                        <th>Name</th>
                                        <th>Action</th>
                                    </tr>
                               </thead>
                               <tbody>
                                    <tr>
                                        <td>{{$product->id }}</td>
                                        <td>{{ $product->name}}</td>
                                    </tr>
                                </tbody>
                            </table>
                        @endforeach
                    </div>
                @endforeach
            </div>
        </div>
    </div>
</code>```

Updated Code

Update

```<code><div class="row">
    <div class="col-md-7">

        <div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
                @foreach($items as $item)
                    <li><a href="#tab_{{ $item->id }}" data-toggle="tab" >{!!$item->name!!}</a></li>
                @endforeach
            </ul>
            <div class="tab-content">
                @foreach($items as $item)
                    <div class="tab-pane active" id="tab_{{ $item->id }}">
                            <table class="table">
                                <thead>
                                    <tr>
                                        <th>No#</th>
                                        <th>Name</th>
                                        <th>Action</th>
                                    </tr>
                               </thead>
                               <tbody>
                        @foreach($item->products as $product)

                                    <tr>
                                        <td>{{$product->id }}</td>
                                        <td>{{ $product->name}}</td>
                                    </tr>
                        @endforeach

                                </tbody>
                            </table>
                    </div>
                @endforeach
            </div>
        </div>
    </div>
</code>```

答:
You need to move the @foreach() + corresponding @endforeach inside the
, otherwise you are outputting a new table for each product. This is how it should be:

```<code><table class="table">
    <thead>
        <tr>
            <th>No#</th>
            <th>Name</th>
            <th>Action</th>
        </tr>
    </thead>
    <tbody>
    @foreach($item->products as $product)
        <tr>
            <td>{{ $product->id   }}</td>
            <td>{{ $product->name }}</td>
        </tr>
    @endforeach
    </tbody>
</table>
</code>```

Title: Displaying data into HTML Tables

Body:
I am able to display my data from db. I want to display in a table under tabs but then my data appears crooked. The rows are not straight. why is that happening to the table?

it is arranged kind of this way.

the updated code below doesn't provide the right format for the table
Table

  id  name
     1    James
    4   Michel
   2  Jonathan

HTML

                @foreach($items as $item)

id }}" data-toggle="tab" >{!!$item->name!!}

                @endforeach

                @foreach($items as $item)

id }}">
                        @foreach($item->products as $product)

                                        No#
                                        Name
                                        Action

                                        {{$product->id }}
                                        {{ $product->name}}

                        @endforeach

                @endforeach

Updated Code

Update

                @foreach($items as $item)

id }}" data-toggle="tab" >{!!$item->name!!}

                @endforeach

                @foreach($items as $item)

id }}">

                                        No#
                                        Name
                                        Action

                        @foreach($item->products as $product)

                                        {{$product->id }}
                                        {{ $product->name}}

                        @endforeach

                @endforeach

Body:
You need to move the @foreach() + corresponding @endforeach inside the <tbody>, otherwise you are outputting a new table for each product. This is how it should be:

<table class="table">
    <thead>
        <tr>
            <th>No#</th>
            <th>Name</th>
            <th>Action</th>
        </tr>
    </thead>
    <tbody>
    @foreach($item->products as $product)
        <tr>
            <td>{{ $product->id   }}</td>
            <td>{{ $product->name }}</td>
        </tr>
    @endforeach
    </tbody>
</table>


问:
linear regression lines cannot show on time series plot in r
I am new in plotting time series. I downloaded a time series data and calculated a linear equation and I would like to add it in the time series plot. I want to show the year in the plot so I used index(stk) as x-axis input.

code:

```<code>library(quantmod)

stk <- suppressWarnings(getSymbols("AAPL", auto.assign = FALSE,
                                   src = "yahoo", periodicity = "daily"))
stk <- na.omit(stk)

stk.lm1 <- lm(log(Cl(stk)) ~ c(1:nrow(stk)), data = stk)
plot(index(stk), log(Cl(stk)), type = "l", lwd = 3, las = 1)
abline(coefficients(stk.lm1)[1], coefficients(stk.lm1)[2], col="blue")
</code>```

I know it is the plot using index(stk), how can I do to keep the x axis of plot in date and can I use plot.xts or other like ggplot2 to do the same things? Please advise, thank you very much.

答:
Here's a ggplot solution. You shouldn't have to calculate the linear regression coefficients yourself:

```<code># convert stk to data frame & specify your x-axis variable explicitly
stk.df <- as.data.frame(stk)
stk.df$Date <- as.Date(rownames(stk.df))

# plot
ggplot(stk.df,
       aes(x = Date, y = log(AAPL.Close))) +
  geom_line() +
  geom_smooth(method = "lm", se = FALSE) +
  labs(x = "Year", y = "log(AAPL's closing value)") +
  theme_bw()
</code>```

The geom_smooth line takes care of the regression. Set se = TRUE if you want to include a confidence interval around the line.

Body:
I am new in plotting time series. I downloaded a time series data and calculated a linear equation and I would like to add it in the time series plot. I want to show the year in the plot so I used index(stk) as x-axis input.

code:

library(quantmod)

stk <- suppressWarnings(getSymbols("AAPL", auto.assign = FALSE,
                                   src = "yahoo", periodicity = "daily"))
stk <- na.omit(stk)

stk.lm1 <- lm(log(Cl(stk)) ~ c(1:nrow(stk)), data = stk)
plot(index(stk), log(Cl(stk)), type = "l", lwd = 3, las = 1)
abline(coefficients(stk.lm1)[1], coefficients(stk.lm1)[2], col="blue")

I know it is the plot using index(stk), how can I do to keep the x axis of plot in date and can I use plot.xts or other like ggplot2 to do the same things? Please advise, thank you very much.

Body:
Here's a ggplot solution. You shouldn't have to calculate the linear regression coefficients yourself:

# convert stk to data frame & specify your x-axis variable explicitly
stk.df <- as.data.frame(stk)
stk.df$Date <- as.Date(rownames(stk.df))

# plot
ggplot(stk.df,
       aes(x = Date, y = log(AAPL.Close))) +
  geom_line() +
  geom_smooth(method = "lm", se = FALSE) +
  labs(x = "Year", y = "log(AAPL's closing value)") +
  theme_bw()

The geom_smooth line takes care of the regression. Set se = TRUE if you want to include a confidence interval around the line.


问:
TYPO3 Extbase class to handle general mysql queries
I'm looking for the best practice to do a mysql dump of a 8 tables in my Extbase CommandController.
Since an Extbase Repository handles only one specific table, it seems to be the wrong location to execute general mysql queries.

In which class should I put a raw mysql statement that affects multiple tables?

答:
My issue is solved.

I made a BackupService class and run a mysqldump command with exec().


问:
Combine two different array in javascript
I have two array data that I want to combine into one array, the first array contain only data of date and id, the second array contain name and id.

```<code>    temp_data:[
      0:{
        id:"1"
        date:"2017-11-07"
      }
      1:{
        id:"1"
        date:"2017-11-08"
      }
      2:{
        id:"2"
        date:"2017-11-07"
      }
      3:{
        id:"2"
        date:"2017-11-08"
      }
]

name:[
      0:{
       id:"1"
       name:"Pervies, Peter"
      }
      1:{
       id:"2"
       name:"Ming, Edmund"
      }
]
</code>```

I want the data to be look like this:

```<code>    data:[
    0:{
     id:"1"
     name:"Pervies, Peter"
     details:[
        {date:"2017-11-07"},
        {date:"2017-11-08"}
     ]
    }
    1:{
     id:"2"
     name:"Ming, Edmund"
     details:[
        {date:"2017-11-07"},
        {date:"2017-11-08"}
     ]
    }
]
</code>```

I have try the code below to combine the two array,it works but not in the way I expect.

```<code>  let len = temp_data.length;
    let leng = name.length;
        for (let i = 0; i < leng; ++i) {
            for (let x = 0; x < len; ++x) {
                if (name[i].id == temp_data[x].id) {
                    let id = name[i].id;
                    let details = temp_data[x];
                    data.push({id,details})
                }
            }
        }

    // ------------------------------------------------------------------------

       let dat = temp_data,
       hash = Object.create(null),
       result = [];

   dat.forEach(function (o) {
        if (!hash[o.id]) {
         hash[o.id] = [];
         result.push(hash[o.id]);
        }
          hash[o.id].push(o);
    });

        data = result;
</code>```

can you help me with this?

答:
Here's one way to do this:

Create an empty object/hash {id: {id: id, name: name, details: []}}.

Loop through the name array, and populate the hash with an object with id and name.

Loop through the temp_data array, and populate/update the hash with date values. (You'll need to check if the element already contains the details member. If not, create one. And, append the new date.)

Convert the values of the hash into an array. (Object.values())

Nothing fancy, but this will do.

Body:
I have two array data that I want to combine into one array, the first array contain only data of date and id, the second array contain name and id.

    temp_data:[
      0:{
        id:"1"
        date:"2017-11-07"
      }
      1:{
        id:"1"
        date:"2017-11-08"
      }
      2:{
        id:"2"
        date:"2017-11-07"
      }
      3:{
        id:"2"
        date:"2017-11-08"
      }
]

name:[
      0:{
       id:"1"
       name:"Pervies, Peter"
      }
      1:{
       id:"2"
       name:"Ming, Edmund"
      }
]

I want the data to be look like this:

    data:[
    0:{
     id:"1"
     name:"Pervies, Peter"
     details:[
        {date:"2017-11-07"},
        {date:"2017-11-08"}
     ]
    }
    1:{
     id:"2"
     name:"Ming, Edmund"
     details:[
        {date:"2017-11-07"},
        {date:"2017-11-08"}
     ]
    }
]

I have try the code below to combine the two array,it works but not in the way I expect.

  let len = temp_data.length;
    let leng = name.length;
        for (let i = 0; i < leng; ++i) {
            for (let x = 0; x < len; ++x) {
                if (name[i].id == temp_data[x].id) {
                    let id = name[i].id;
                    let details = temp_data[x];
                    data.push({id,details})
                }
            }
        }

    // ------------------------------------------------------------------------

       let dat = temp_data,
       hash = Object.create(null),
       result = [];

   dat.forEach(function (o) {
        if (!hash[o.id]) {
         hash[o.id] = [];
         result.push(hash[o.id]);
        }
          hash[o.id].push(o);
    });

        data = result;

can you help me with this?


问:
Selenium timeout after clicking on an element but page seems to load correctly (ChromeDriver)
I'm facing a strange problem and I can't figure out why it is happening.

My code is written on C# and I'm using ChromeDriver

I'm clicking on an element (Actually sending SendKey(Keys.ENTER) but same problem happens when I use regular .Click())

The click seems to work OK (The element is found and I'm redirected to the page that I'm expecting (This is a complex process that runs behind with SSO)) but the code doesn't continue its execution

After some time it throws exception
  http://localhost:7183/session/ca0fc76d263cb413b3a06f69fa5eff7e/element/0.8505282587588259-1/value timed out after 120 seconds.

If I run the same code with FirefoxDriver or IEDriver it works OK

答: I have a similar problem and I set this timeout manager in the ChromeDriver execution, now it will wait 60 secs before gets the timeout error.  driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(60);


问:
CodeIgniter, models, and ORM, how to deal with this?
I'm starting with CodeIgniter and after several hours diving in Google I'm a bit confused.

Let's try to explain my question with a easy example: I have a table 'car' with the fields 'name' and 'color'. Therefore I want to have a php class Car, so that my code could look finally like this:

```<code>$car = new Car('BMW', 'red'); //new $car Object
$car->save(); //this will make an SQL insert to the table 'car'

//Lets query all cars
$cars = Car::get_all();
//cars will be an array of Car objects, (not a set of rows!)
</code>```

Therefore, I am looking for something pretty similar to what you have in RubyOnRails or Django (Python). I need to handle all kind of relationships, and to be able of write code in a true OOP+MVC way.

These are my failed approaches to get it:

Using an external ORM (DataMapper, Doctrine, AcidCrud...)

They either requires too many settings, or they handle relationships in a poor way.

Using CodeIgniter classes (to extend the CodeIgniter's Model class)

```<code>class Car extends Model{
public function Car($name='',$color='')
{
    $this->name     =   $name;
    $this->color    =   $color;
    parent::Model();
}
public function save()
{
    $data = array(
                   'name'   =>  $this->name ,
                   'color'  =>  $this->color
                  );

    $this->db->insert('cars' $data);
}
</code>```

And so on... Problem with this approach is that if a do a var_dump() of a $car object, I see that it contains a lot of stuff from the CodeIgniter, such as the objects CI_Config, CI_Input, CI_Benchmark, etc. Therefore I think this is not a good solution, because each object of my class Car, it will contain a lot of repeated data, (it will have a poor performance!), isn't it?

Not using the CodeIgniter's models

I could make my models without extending them from CodeIgniter's Model class, and then using the regular PHP5 constructor (__construct() instead of function Car()), but problem in this case is: how I access to the $db object to make querys using the CodeIgniter's ActiveRecord? and, how I load the models (its classes) within the controllers?

答:
I used CodeIgniter with Propel and they really mixed well. I've used like that for a while and got a few webapps working that way. Since I found a few awful ways to do it ( some included modifiying Apache's configuration!!). I decided to publish a blog post on how to do it. You can read it here.

Hope I can help!

Body:
I'm starting with CodeIgniter and after several hours diving in Google I'm a bit confused.

Let's try to explain my question with a easy example: I have a table 'car' with the fields 'name' and 'color'. Therefore I want to have a php class Car, so that my code could look finally like this:

$car = new Car('BMW', 'red'); //new $car Object
$car->save(); //this will make an SQL insert to the table 'car'

//Lets query all cars
$cars = Car::get_all();
//cars will be an array of Car objects, (not a set of rows!)

Therefore, I am looking for something pretty similar to what you have in RubyOnRails or Django (Python). I need to handle all kind of relationships, and to be able of write code in a true OOP+MVC way.

These are my failed approaches to get it:

Using an external ORM (DataMapper, Doctrine, AcidCrud...)

They either requires too many settings, or they handle relationships in a poor way.

Using CodeIgniter classes (to extend the CodeIgniter's Model class)

class Car extends Model{
public function Car($name='',$color='')
{
    $this->name     =   $name;
    $this->color    =   $color;
    parent::Model();
}
public function save()
{
    $data = array(
                   'name'   =>  $this->name ,
                   'color'  =>  $this->color
                  );

    $this->db->insert('cars' $data);
}

And so on... Problem with this approach is that if a do a var_dump() of a $car object, I see that it contains a lot of stuff from the CodeIgniter, such as the objects CI_Config, CI_Input, CI_Benchmark, etc. Therefore I think this is not a good solution, because each object of my class Car, it will contain a lot of repeated data, (it will have a poor performance!), isn't it?

Not using the CodeIgniter's models

I could make my models without extending them from CodeIgniter's Model class, and then using the regular PHP5 constructor (__construct() instead of function Car()), but problem in this case is: how I access to the $db object to make querys using the CodeIgniter's ActiveRecord? and, how I load the models (its classes) within the controllers?

ContentLicense: CC BY-SA 2.5


问:
How do I schedule a stored procedure to run daily at certain time?
I am trying to schedule a stored procedure in Oracle, it should run daily at a certain time, for example at 11:59 pm </p>

```<code> BEGIN
 DBMS_SCHEDULER.CREATE_JOB (
 job_name           =>  'BLANKET_WO',
 job_type           =>  'STORED_PROCEDURE',
 job_action         =>  'AAKPID.BLANKET_WO_PROC',
 repeat_interval    =>  'FREQ=DAILY;BYHOUR=23;BYMINUTE=59');
 END;
 /
</code>```

<p>Will this code work? </p>

答:
Try this, it should work:</p>

```<code> BEGIN
 DBMS_SCHEDULER.CREATE_JOB (
 job_name           =>  'BLANKET_WO',
 job_type           =>  'STORED_PROCEDURE',
 job_action         =>  'AAKPID.BLANKET_WO_PROC',
 start_date         =>  '16-nov-2017 11:50:00 pm',
 repeat_interval    =>  'FREQ=DAILY;BYHOUR=23;BYMINUTE=59',
 enabled            =>  true
);
 END;
 /
</code>```

Body:
I am trying to schedule a stored procedure in Oracle, it should run daily at a certain time, for example at 11:59 pm

 BEGIN
 DBMS_SCHEDULER.CREATE_JOB (
 job_name           =>  'BLANKET_WO',
 job_type           =>  'STORED_PROCEDURE',
 job_action         =>  'AAKPID.BLANKET_WO_PROC',
 repeat_interval    =>  'FREQ=DAILY;BYHOUR=23;BYMINUTE=59');
 END;
 /

Will this code work?

Body:
Try this, it should work:

 BEGIN
 DBMS_SCHEDULER.CREATE_JOB (
 job_name           =>  'BLANKET_WO',
 job_type           =>  'STORED_PROCEDURE',
 job_action         =>  'AAKPID.BLANKET_WO_PROC',
 start_date         =>  '16-nov-2017 11:50:00 pm',
 repeat_interval    =>  'FREQ=DAILY;BYHOUR=23;BYMINUTE=59',
 enabled            =>  true
);
 END;
 /


问:
Python REST API call equivalent in Node.js
I've been recently trying to communicate with the UniProt API. As I am starting with Node.js, I have some initial problems, namely:

I am trying to conver this python request:

```<code>import urllib,urllib2

url = 'http://www.uniprot.org/uploadlists/'

params = {
'from':'ACC',
'to':'P_REFSEQ_AC',
'format':'tab',
'query':'P13368 P20806 Q9UM73 P97793 Q17192'
}

data = urllib.urlencode(params)
request = urllib2.Request(url, data)
contact = "" # Please set your email address here to help us debug in case of problems.
request.add_header('User-Agent', 'Python %s' % contact)
response = urllib2.urlopen(request)
page = response.read(200000)
</code>```

To node.js.

My attempt:

```<code>var params = {
'from':'ACC',
'to':'P_REFSEQ_AC',
'format':'json',
'query':'P13368 P20806 Q9UM73 P97793 Q17192'
}

var post_data = querystring.stringify(params);
var url = 'http://www.uniprot.org/uploadlists/'

var options = {
uri: url,
qs: post_data,
method: 'POST'
};

urllib.request(options, function (err, data, res) {
if (err) {
    throw err; // you need to handle error
}
console.log(data.toString())

cb("test") // this doesnt currently matter
});
</code>```

What am I doing wrong? Thank you.

答:
Using node-rest-client can help you achieve what you are trying.

```<code>npm i node-rest-client --save
</code>```

I believe you have a starter project for nodejs which contains package.json.

```<code>var Client = require('node-rest-client').Client;

var client = new Client();

var args = {
    data: {
        'from': 'ACC',
        'to': 'P_REFSEQ_AC',
        'format': 'json',
        'query': 'P13368 P20806 Q9UM73 P97793 Q17192'
    },
    headers: {
        "Content-Type": "application/json"//use the header that you need
    }
};

client.post("http://www.uniprot.org/uploadlists/", args, function(data, response) {
    // parsed response body as js object
    console.log(data);
    // raw response
    console.log(response);
});
</code>```

Body:
I've been recently trying to communicate with the UniProt API. As I am starting with Node.js, I have some initial problems, namely:

I am trying to conver this python request:

import urllib,urllib2

url = 'http://www.uniprot.org/uploadlists/'

params = {
'from':'ACC',
'to':'P_REFSEQ_AC',
'format':'tab',
'query':'P13368 P20806 Q9UM73 P97793 Q17192'
}

data = urllib.urlencode(params)
request = urllib2.Request(url, data)
contact = "" # Please set your email address here to help us debug in case of problems.
request.add_header('User-Agent', 'Python %s' % contact)
response = urllib2.urlopen(request)
page = response.read(200000)

To node.js.

My attempt:

var params = {
'from':'ACC',
'to':'P_REFSEQ_AC',
'format':'json',
'query':'P13368 P20806 Q9UM73 P97793 Q17192'
}

var post_data = querystring.stringify(params);
var url = 'http://www.uniprot.org/uploadlists/'

var options = {
uri: url,
qs: post_data,
method: 'POST'
};

urllib.request(options, function (err, data, res) {
if (err) {
    throw err; // you need to handle error
}
console.log(data.toString())

cb("test") // this doesnt currently matter
});

What am I doing wrong? Thank you.

Body:
Using node-rest-client can help you achieve what you are trying.

npm i node-rest-client --save

I believe you have a starter project for nodejs which contains package.json.

var Client = require('node-rest-client').Client;

var client = new Client();

var args = {
    data: {
        'from': 'ACC',
        'to': 'P_REFSEQ_AC',
        'format': 'json',
        'query': 'P13368 P20806 Q9UM73 P97793 Q17192'
    },
    headers: {
        "Content-Type": "application/json"//use the header that you need
    }
};

client.post("http://www.uniprot.org/uploadlists/", args, function(data, response) {
    // parsed response body as js object
    console.log(data);
    // raw response
    console.log(response);
});


问:
Android screen orientation to sensor
I want to force the screen orientation to landscape on button click by setting

```<code> setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
</code>```

It works fine. Now I want the application to follow the sensor so that orientation is brought back to portrait when tilted back to portrait. I know this is possible by setting setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); but don't know where to set it. If the orientation is forced to landscape, orientation will remain in landscape no matter you tilt in any direction. Can anyone specify how to reset the orientation flag?

答: I think here you should use setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)

Title: Android screen orientation to sensor

Body:
I want to force the screen orientation to landscape on button click by setting

 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

It works fine. Now I want the application to follow the sensor so that orientation is brought back to portrait when tilted back to portrait. I know this is possible by setting setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); but don't know where to set it. If the orientation is forced to landscape, orientation will remain in landscape no matter you tilt in any direction. Can anyone specify how to reset the orientation flag?


问:
Disable Submit button on selection from DropDownListFor
I am working on this code when the submit button will be enabled only when user selects values from a DropDownListFor.

```<code>      @Html.DropDownListFor(m => m.Year, Model.YearList, "--Select Year--", new { @class = "form-control",id = "Year" })
      @Html.ValidationMessageFor(m => m.Year)

 <input type="submit" id="submit" name="submit" value="Submit" class="btn btn-lg btn-success" />
</code>```

js code:

```<code>   $("#Year").change(function () {
        if ($('#Year').val()!="--Select Year--")
            $('.submit').prop("disabled", false);
        else
            $('.submit').prop("disabled", true);
    });
</code>```

No error message just the submit button is always enabled. Any help?

答:
Use this, it will work you can also use

```<code> @Html.DropDownList("ddlYear", new SelectList(mylist, "Value", "Text"), "-- Select Year--", new { @class = "form-control input-sm", onchange = "Button()" })
</code>```

or

```<code>@Html.DropDownList("ddlYear", ((List<SelectListItem>)ViewData["mylist"]), "-- Select Year--", new { @class = "form-control", onchange = "Button()" })
</code>```

Or using DropDownListFor

```<code> <script>
        $(document).ready(function () {
            document.getElementById("submit").disabled = true;
        })
        function Button()
        {
            if ($('#ddlYear').val() != "") {
                document.getElementById("submit").disabled = false;
            }
            else {
                document.getElementById("submit").disabled = true;
            }
        }
    </script>

    @Html.DropDownListFor(m => m.Year, Model.YearList, "--Select Year--", new { @class = "form-control", id = "ddlYear", onchange = "Button()" })
    @Html.ValidationMessageFor(m => m.Year)
    <input type="submit" id="submit" name="submit" value="Submit" class="btn btn-lg btn-success" onchange="Button()" />
</code>```

Body:
I am working on this code when the submit button will be enabled only when user selects values from a DropDownListFor.

      @Html.DropDownListFor(m => m.Year, Model.YearList, "--Select Year--", new { @class = "form-control",id = "Year" })
      @Html.ValidationMessageFor(m => m.Year)

 <input type="submit" id="submit" name="submit" value="Submit" class="btn btn-lg btn-success" />

js code:

   $("#Year").change(function () {
        if ($('#Year').val()!="--Select Year--")
            $('.submit').prop("disabled", false);
        else
            $('.submit').prop("disabled", true);
    });

No error message just the submit button is always enabled. Any help?

Body:
Use this, it will work you can also use

 @Html.DropDownList("ddlYear", new SelectList(mylist, "Value", "Text"), "-- Select Year--", new { @class = "form-control input-sm", onchange = "Button()" })

or

@Html.DropDownList("ddlYear", ((List<SelectListItem>)ViewData["mylist"]), "-- Select Year--", new { @class = "form-control", onchange = "Button()" })

Or using DropDownListFor

 <script>
        $(document).ready(function () {
            document.getElementById("submit").disabled = true;
        })
        function Button()
        {
            if ($('#ddlYear').val() != "") {
                document.getElementById("submit").disabled = false;
            }
            else {
                document.getElementById("submit").disabled = true;
            }
        }
    </script>

    @Html.DropDownListFor(m => m.Year, Model.YearList, "--Select Year--", new { @class = "form-control", id = "ddlYear", onchange = "Button()" })
    @Html.ValidationMessageFor(m => m.Year)
    <input type="submit" id="submit" name="submit" value="Submit" class="btn btn-lg btn-success" onchange="Button()" />


问:
How i can apply alertDialog as server response in AsyncTask
I'm trying to connect my project app with an online database through cPanel Hosting. I used the AlertDialog.Builder, setOnClickListener,
for showing the response of the server but it seems i got some error any answers will be appreciated Thanks

here is my java file.

```<code>//Calling my AsyncTask
@Override
 public void onClick(View view) {
 view.setEnabled(false);
 Intent launchactivity = new Intent(MainActivity.this,MainActivity.class);
 startActivity(launchactivity);

            tvscancontent = tvScanContent.getText().toString();
            tvscanformat = tvScanFormat.getText().toString();
            BackgroundTask backgroundTask = new BackgroundTask();
            backgroundTask.execute(tvscancontent,tvscanformat);
            finish();

            showShowView2();
           // displaynotification();

        }

    });

private class BackgroundTask extends AsyncTask<String,Void,String> { // i got crash here

        Context context;
        String add_info_url;
        private Object activity;

        public BackgroundTask() {

        }

        @Override
        protected void onPreExecute() {

            add_info_url = "http://www.d48.asia/shan/index.php";

            progressDialog = new ProgressDialog(MainActivity.this);
            progressDialog.setTitle("Processing...");
            progressDialog.setMessage("Authenticating...");
            progressDialog.setCancelable(false);
            progressDialog.setIndeterminate(true);
            progressDialog.setProgressStyle(progressDialog.STYLE_SPINNER);
            progressDialog.show();

        }

        @Override
        protected String doInBackground(String... args) {

            String tvscancontent = args[0];
            String tvscanformat = args[1];
            String response = "";
            String line = "";

            try {
                URL url = new URL(add_info_url);
                HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
                httpURLConnection.setRequestMethod("POST");
                httpURLConnection.setDoOutput(true);
                httpURLConnection.setDoInput(true);
                OutputStream outputStream = httpURLConnection.getOutputStream();
                BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
                String data_string = URLEncoder.encode("tvscancontent", "UTF-8") + "=" + URLEncoder.encode(tvscancontent, "UTF-8")+ "&" +
                        URLEncoder.encode("tvscanformat", "UTF-8") + "=" + URLEncoder.encode(tvscanformat, "UTF-8");
                bufferedWriter.write(data_string);
                bufferedWriter.flush();
                bufferedWriter.close();
                outputStream.close();
                InputStream inputStream = httpURLConnection.getInputStream();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"iso-8859-1"));

                while ((line = bufferedReader.readLine()) != null){

                    response+= line;

                }

                bufferedReader.close();
                inputStream.close();
                httpURLConnection.disconnect();

                return response;

            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }

            return null;

        }

        @Override
        protected void onProgressUpdate(Void... values) {
            super.onProgressUpdate(values);

        }

     //Server response
        @Override
        protected void onPostExecute(final String result) {
            //Toast toast =Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG);
            //toast.setGravity(Gravity.CENTER ,0,0);
            //toast.show();
                AlertDialog.Builder alert = new AlertDialog.Builder(context); // also i got crash here
                    alert.setTitle("Third Wheel Response");
                    alert.setMessage(result);
                    alert.setCancelable(false);
                    alert.setPositiveButton("ok", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                          dialogInterface.cancel();
                        }
                    });
                    AlertDialog dialogs = alert.create();
                    dialogs.show();

                if (progressDialog != null) {
                    progressDialog.dismiss();
                    SaveData.setEnabled(true);

                }
</code>```

ERRORS:

11-10 08:40:23.174 4815-4815/com.thethirdwheelproject.thirdwheel E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                Process: com.thethirdwheelproject.thirdwheel, PID: 4815
                                                                                android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@bc0afcf is not valid; is your activity running?
                                                                                at android.view.ViewRootImpl.setView(ViewRootImpl.java:678)
                                                                                at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:342)
                                                                                at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
                                                                                at android.app.Dialog.show(Dialog.java:316)
                                                                                at com.thethirdwheelproject.thirdwheel.MainActivity$BackgroundTask.onPostExecute(MainActivity.java:489)
                                                                                at com.thethirdwheelproject.thirdwheel.MainActivity$BackgroundTask.onPostExecute(MainActivity.java:389)
                                                                                at android.os.AsyncTask.finish(AsyncTask.java:660)
                                                                                at android.os.AsyncTask.-wrap1(AsyncTask.java)
                                                                                at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:677)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                at android.os.Looper.loop(Looper.java:154)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
11-10 08:40:23.733 1334-1334/? E/EGL_emulation: tid 1334: eglCreateSyncKHR(1901): error 0x3004 (EGL_BAD_ATTRIBUTE)

答:
```<code>        //Calling my AsyncTask
@Override
        public void onClick(View view) {
            view.setEnabled(false);

            tvscancontent = tvScanContent.getText().toString();
            tvscanformat = tvScanFormat.getText().toString();
            BackgroundTask backgroundTask =new BackgroundTask();
            backgroundTask.execute(tvscancontent,tvscanformat);

            showShowView2();
           // displaynotification();

        }

    });
</code>```

<p>//inserting data into database process
    private class BackgroundTask extends AsyncTask {</p>

```<code>    String add_info_url;

    public BackgroundTask() {

    }

    @Override
    protected void onPreExecute() {

        add_info_url = "http://www.d48.asia/shan/index.php";

        progressDialog = new ProgressDialog(MainActivity.this);
        progressDialog.setTitle("Authentication Process");
        progressDialog.setMessage("Loading....");
        progressDialog.setCancelable(false);
        progressDialog.setIndeterminate(true);
        progressDialog.setProgressStyle(progressDialog.STYLE_SPINNER);
        progressDialog.show();

    }

    @Override
    protected String doInBackground(String... args) {

        String tvscancontent = args[0];
        String tvscanformat = args[1];
        String response = "";
        String line = "";

        try {
            URL url = new URL(add_info_url);
            HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
            httpURLConnection.setRequestMethod("POST");
            httpURLConnection.setDoOutput(true);
            httpURLConnection.setDoInput(true);
            OutputStream outputStream = httpURLConnection.getOutputStream();
            BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
            String data_string = URLEncoder.encode("tvscancontent", "UTF-8") + "=" + URLEncoder.encode(tvscancontent, "UTF-8")+ "&" +
                    URLEncoder.encode("tvscanformat", "UTF-8") + "=" + URLEncoder.encode(tvscanformat, "UTF-8");
            bufferedWriter.write(data_string);
            bufferedWriter.flush();
            bufferedWriter.close();
            outputStream.close();
            InputStream inputStream = httpURLConnection.getInputStream();
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"iso-8859-1"));

            while ((line = bufferedReader.readLine()) != null){
                response+= line;
            }
            bufferedReader.close();
            inputStream.close();
            httpURLConnection.disconnect();

            return response;

        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return null;

    }

    @Override
    protected void onProgressUpdate(Void... values) {
        super.onProgressUpdate(values);

    }

    @Override
    protected void onPostExecute(final String result) {
        super.onPostExecute(result);
                alert = new AlertDialog.Builder(MainActivity.this);
                alert.setTitle(" Third Wheel Response");
                alert.setMessage(result);
                alert.setCancelable(false);
                alert.setPositiveButton("Thanks", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        Intent launchactivity = new Intent(MainActivity.this,MainActivity.class);
                        startActivity(launchactivity);

                    }
                });
                AlertDialog dialogs = alert.create();
                dialogs.show();

            if (progressDialog != null) {
                progressDialog.dismiss();
                SaveData.setEnabled(true);

            }

    }
</code>```

Body:
I'm trying to connect my project app with an online database through cPanel Hosting. I used the AlertDialog.Builder, setOnClickListener,
for showing the response of the server but it seems i got some error any answers will be appreciated Thanks

here is my java file.

//Calling my AsyncTask
@Override
 public void onClick(View view) {
 view.setEnabled(false);
 Intent launchactivity = new Intent(MainActivity.this,MainActivity.class);
 startActivity(launchactivity);

            tvscancontent = tvScanContent.getText().toString();
            tvscanformat = tvScanFormat.getText().toString();
            BackgroundTask backgroundTask = new BackgroundTask();
            backgroundTask.execute(tvscancontent,tvscanformat);
            finish();

            showShowView2();
           // displaynotification();

        }

    });

private class BackgroundTask extends AsyncTask<String,Void,String> { // i got crash here

        Context context;
        String add_info_url;
        private Object activity;

        public BackgroundTask() {

        }

        @Override
        protected void onPreExecute() {

            add_info_url = "http://www.d48.asia/shan/index.php";

            progressDialog = new ProgressDialog(MainActivity.this);
            progressDialog.setTitle("Processing...");
            progressDialog.setMessage("Authenticating...");
            progressDialog.setCancelable(false);
            progressDialog.setIndeterminate(true);
            progressDialog.setProgressStyle(progressDialog.STYLE_SPINNER);
            progressDialog.show();

        }

        @Override
        protected String doInBackground(String... args) {

            String tvscancontent = args[0];
            String tvscanformat = args[1];
            String response = "";
            String line = "";

            try {
                URL url = new URL(add_info_url);
                HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
                httpURLConnection.setRequestMethod("POST");
                httpURLConnection.setDoOutput(true);
                httpURLConnection.setDoInput(true);
                OutputStream outputStream = httpURLConnection.getOutputStream();
                BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
                String data_string = URLEncoder.encode("tvscancontent", "UTF-8") + "=" + URLEncoder.encode(tvscancontent, "UTF-8")+ "&" +
                        URLEncoder.encode("tvscanformat", "UTF-8") + "=" + URLEncoder.encode(tvscanformat, "UTF-8");
                bufferedWriter.write(data_string);
                bufferedWriter.flush();
                bufferedWriter.close();
                outputStream.close();
                InputStream inputStream = httpURLConnection.getInputStream();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"iso-8859-1"));

                while ((line = bufferedReader.readLine()) != null){

                    response+= line;

                }

                bufferedReader.close();
                inputStream.close();
                httpURLConnection.disconnect();

                return response;

            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }

            return null;

        }

        @Override
        protected void onProgressUpdate(Void... values) {
            super.onProgressUpdate(values);

        }

     //Server response
        @Override
        protected void onPostExecute(final String result) {
            //Toast toast =Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG);
            //toast.setGravity(Gravity.CENTER ,0,0);
            //toast.show();
                AlertDialog.Builder alert = new AlertDialog.Builder(context); // also i got crash here
                    alert.setTitle("Third Wheel Response");
                    alert.setMessage(result);
                    alert.setCancelable(false);
                    alert.setPositiveButton("ok", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                          dialogInterface.cancel();
                        }
                    });
                    AlertDialog dialogs = alert.create();
                    dialogs.show();

                if (progressDialog != null) {
                    progressDialog.dismiss();
                    SaveData.setEnabled(true);

                }

ERRORS:

11-10 08:40:23.174 4815-4815/com.thethirdwheelproject.thirdwheel E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                Process: com.thethirdwheelproject.thirdwheel, PID: 4815
                                                                                android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@bc0afcf is not valid; is your activity running?
                                                                                at android.view.ViewRootImpl.setView(ViewRootImpl.java:678)
                                                                                at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:342)
                                                                                at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
                                                                                at android.app.Dialog.show(Dialog.java:316)
                                                                                at com.thethirdwheelproject.thirdwheel.MainActivity$BackgroundTask.onPostExecute(MainActivity.java:489)
                                                                                at com.thethirdwheelproject.thirdwheel.MainActivity$BackgroundTask.onPostExecute(MainActivity.java:389)
                                                                                at android.os.AsyncTask.finish(AsyncTask.java:660)
                                                                                at android.os.AsyncTask.-wrap1(AsyncTask.java)
                                                                                at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:677)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                at android.os.Looper.loop(Looper.java:154)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
11-10 08:40:23.733 1334-1334/? E/EGL_emulation: tid 1334: eglCreateSyncKHR(1901): error 0x3004 (EGL_BAD_ATTRIBUTE)

Body:
        //Calling my AsyncTask
@Override
        public void onClick(View view) {
            view.setEnabled(false);

            tvscancontent = tvScanContent.getText().toString();
            tvscanformat = tvScanFormat.getText().toString();
            BackgroundTask backgroundTask =new BackgroundTask();
            backgroundTask.execute(tvscancontent,tvscanformat);

            showShowView2();
           // displaynotification();

        }

    });

//inserting data into database process
    private class BackgroundTask extends AsyncTask {

    String add_info_url;

    public BackgroundTask() {

    }

    @Override
    protected void onPreExecute() {

        add_info_url = "http://www.d48.asia/shan/index.php";

        progressDialog = new ProgressDialog(MainActivity.this);
        progressDialog.setTitle("Authentication Process");
        progressDialog.setMessage("Loading....");
        progressDialog.setCancelable(false);
        progressDialog.setIndeterminate(true);
        progressDialog.setProgressStyle(progressDialog.STYLE_SPINNER);
        progressDialog.show();

    }

    @Override
    protected String doInBackground(String... args) {

        String tvscancontent = args[0];
        String tvscanformat = args[1];
        String response = "";
        String line = "";

        try {
            URL url = new URL(add_info_url);
            HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
            httpURLConnection.setRequestMethod("POST");
            httpURLConnection.setDoOutput(true);
            httpURLConnection.setDoInput(true);
            OutputStream outputStream = httpURLConnection.getOutputStream();
            BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
            String data_string = URLEncoder.encode("tvscancontent", "UTF-8") + "=" + URLEncoder.encode(tvscancontent, "UTF-8")+ "&" +
                    URLEncoder.encode("tvscanformat", "UTF-8") + "=" + URLEncoder.encode(tvscanformat, "UTF-8");
            bufferedWriter.write(data_string);
            bufferedWriter.flush();
            bufferedWriter.close();
            outputStream.close();
            InputStream inputStream = httpURLConnection.getInputStream();
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"iso-8859-1"));

            while ((line = bufferedReader.readLine()) != null){
                response+= line;
            }
            bufferedReader.close();
            inputStream.close();
            httpURLConnection.disconnect();

            return response;

        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return null;

    }

    @Override
    protected void onProgressUpdate(Void... values) {
        super.onProgressUpdate(values);

    }

    @Override
    protected void onPostExecute(final String result) {
        super.onPostExecute(result);
                alert = new AlertDialog.Builder(MainActivity.this);
                alert.setTitle(" Third Wheel Response");
                alert.setMessage(result);
                alert.setCancelable(false);
                alert.setPositiveButton("Thanks", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        Intent launchactivity = new Intent(MainActivity.this,MainActivity.class);
                        startActivity(launchactivity);

                    }
                });
                AlertDialog dialogs = alert.create();
                dialogs.show();

            if (progressDialog != null) {
                progressDialog.dismiss();
                SaveData.setEnabled(true);

            }

    }


问:
Extract text from html tags using reduce in Javascript
I'm trying to concatenate the inner HTML of each paragraph tag on my page in one single string using reduce. Here's my try:

// JS
let par = Array.from(document.getElementsByTagName("p"));
document.write(par.reduce((a, b) => a + ", " + b.innerHTML));```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!-- HTML -->
<p>Apple</p>
<p>Strawberry</p>
<p>Banana</p></code>```

And here's the (wrong) output:

[object HTMLParagraphElement], Strawberry, Banana

What am I doing wrong?

Many thanks for your help!

答:
You should pass second parameter (initial value) for reduce method:

```<code>par.reduce((a,b)=>a+", "+b.innerHTML, '')
</code>```

Body:
I'm trying to concatenate the inner HTML of each paragraph tag on my page in one single string using reduce. Here's my try:

// JS
let par = Array.from(document.getElementsByTagName("p"));
document.write(par.reduce((a, b) => a + ", " + b.innerHTML));

Apple

Strawberry

Banana

And here's the (wrong) output:

[object HTMLParagraphElement], Strawberry, Banana

What am I doing wrong?

Many thanks for your help!

Body:
You should pass second parameter (initial value) for reduce method:

par.reduce((a,b)=>a+", "+b.innerHTML, '')


问:
Github Login with Graphcool
I am attempting to implement a GitHub Login with GraphCool. So far:

Steps

I've run: graphcool add-template auth/github

I uncommented the links in the graphcool.yml and typs.graphql files

I setup a GitHub OAuth app

I added my client name and secret to local environment variables.

I ran graphcool deploy

Results

Under functions it says I have loggedInUser and githubAuthentication. I also seem to have a githubUserId added to createUser

Problem

From here I am stuck. I'm not sure what to do. I am not sure where to obtain a github code. I've implemented OAuth with Github before directly via their API and with Firebase. I have the following questions:

In Github, what should I set the Authorization callback URL? Doesn't that need to point to graphcool?

How does the OAuth pop-up window get launched so I can approve my app?

How do I obtain Github user data like displayName and photoUrl. Can I add that data to a new user when createUser is ran?

I have modified the username password template to createUsers with additional fields in the past. I know I have to modify the types and .ts files in the template. It seems like I may be able to obtain specific user details around line 29 in the githubAuthentication.ts file:

```<code>const graphcool = fromEvent(event)
const api = graphcool.api('simple/v1')
const { githubCode } = event.data
const githubToken: string = await getGithubToken(githubCode)
const githubUser = await getGithubUser(githubToken)
const user: User = await getGraphcoolUser(api, githubUser.id)
  .then(r => r.User)
let userId: string | null = null
</code>```

答:
I am not sure where to obtain a github code.

Short Answer: in whichever way you would normally obtain a Github code.

Long Answer:

You can follow this guide to see how to authorize against a Github OAuth app: https://developer.github.com/apps/building-integrations/setting-up-and-registering-oauth-apps/about-authorization-options-for-oauth-apps/

Or, follow the instructions from the template README.md:

Obtaining a test code

First, update the configuration of the OAuth app on Github you just
  created:

Set the Homepage URL to http://localhost:8000/

Set the Application Callback URL to http://localhost:8000/login.html

Replace CLIENT_ID in login.html with the client id of your OAuth app

Server login.html, for example by using python -m SimpleHTTPServer

Open https://localhost:8000/login.html in a browser, open the DevTools and authenticate with your Github account

Copy the code printed in the Console of your DevTools

This being index.html:

```<code><html>

<body>
  <script>
    // Github client id
    const client_id = '__CLIENT_ID__'
    // Will extract code from current url
    const githubCode = window.location.search.substring(1).split('&')[0].split('code=')[1]
    if (githubCode) {
      // call Graphcool authenticateGithubUser mutation
      console.log(githubCode)
    }
    function getgithubCode() {
      window.location = `https://github.com/login/oauth/authorize?client_id=${client_id}&scope=user`
    }
  </script>
  <button onclick="getgithubCode();">Authenticate with Github</button>
</body>

</html>
</code>```

Title: Github Login with Graphcool

Body:
I am attempting to implement a GitHub Login with GraphCool. So far:

Steps

I've run: graphcool add-template auth/github

I uncommented the links in the graphcool.yml and typs.graphql files

I setup a GitHub OAuth app

I added my client name and secret to local environment variables.

I ran graphcool deploy

Results

Under functions it says I have loggedInUser and githubAuthentication. I also seem to have a githubUserId added to createUser

Problem

From here I am stuck. I'm not sure what to do. I am not sure where to obtain a github code. I've implemented OAuth with Github before directly via their API and with Firebase. I have the following questions:

In Github, what should I set the Authorization callback URL? Doesn't that need to point to graphcool?

How does the OAuth pop-up window get launched so I can approve my app?

How do I obtain Github user data like displayName and photoUrl. Can I add that data to a new user when createUser is ran?

I have modified the username password template to createUsers with additional fields in the past. I know I have to modify the types and .ts files in the template. It seems like I may be able to obtain specific user details around line 29 in the githubAuthentication.ts file:

const graphcool = fromEvent(event)
const api = graphcool.api('simple/v1')
const { githubCode } = event.data
const githubToken: string = await getGithubToken(githubCode)
const githubUser = await getGithubUser(githubToken)
const user: User = await getGraphcoolUser(api, githubUser.id)
  .then(r => r.User)
let userId: string | null = null

Body:
I am not sure where to obtain a github code.

Short Answer: in whichever way you would normally obtain a Github code.

Long Answer:

You can follow this guide to see how to authorize against a Github OAuth app: https://developer.github.com/apps/building-integrations/setting-up-and-registering-oauth-apps/about-authorization-options-for-oauth-apps/

Or, follow the instructions from the template README.md:

Obtaining a test code

First, update the configuration of the OAuth app on Github you just
  created:

Set the Homepage URL to http://localhost:8000/

Set the Application Callback URL to http://localhost:8000/login.html

Replace CLIENT_ID in login.html with the client id of your OAuth app

Server login.html, for example by using python -m SimpleHTTPServer

Open https://localhost:8000/login.html in a browser, open the DevTools and authenticate with your Github account

Copy the code printed in the Console of your DevTools

This being index.html:

<html>

<body>
  <script>
    // Github client id
    const client_id = '__CLIENT_ID__'
    // Will extract code from current url
    const githubCode = window.location.search.substring(1).split('&')[0].split('code=')[1]
    if (githubCode) {
      // call Graphcool authenticateGithubUser mutation
      console.log(githubCode)
    }
    function getgithubCode() {
      window.location = `https://github.com/login/oauth/authorize?client_id=${client_id}&scope=user`
    }
  </script>
  <button onclick="getgithubCode();">Authenticate with Github</button>
</body>

</html>


问:
Codeigniter: Move one row from one table to another at one time
I'm kinda stuck here! I have to two tables free_members and domstic_members and I need to move selected rows from free_members tables to the domestic_members table. why I'm saying selected rows because of I at the end of every row in free_members tables there is an upgrade option which will move that row to the domestic_members table. I have the code but it's not working the way I want. right now what is happening is when I click on upgrade option it just copies the whole table records and sends it's to the other table. this here is the code

Controller

```<code>function upgradeprofile() {
    //  $this->load->database();
    $this->load->model('freemember_model');

    $this->freemember_model->upgrade();
}
</code>```

model

```<code>function upgrade() {
    $query = $this->db->get('free_members');
    foreach ($query->result() as $row) {
        $this->db->where('id', $member_id);
        $this->db->insert('domestic_members', $row);
    }
}
</code>```

View

```<code><center>  Search Member:
                    <input type="text" name ='search' id='search' placeholder="Search a member"/></center>
                    <input type="hidden" name ='limit_from' id='limit_from'/>
                    </form>
<br><center><button type="button" onclick="CallPrint1('background12')">Print</button>
                <div id="background12" class="box-body">
                  <table id="example1" class="table table-bordered table-striped">
                    <thead>
                      <tr>
                        <th>Sr#</th>
                        <th><center>Full Name</th>

                        <th><center>Mobile Number</th>
                         <th><center>Membership# / CNIC</th>
                        <th><center>Email Address</th>

                        <th><center>Province</th>
                        <th><center>District</th>
                        <th><center>Tehsil</th>
                        <th><center>Union Council</th>
<?php /*?>  <?php if($sessiondata['deletemembers']):?><?php */?>
     <?php if($sessiondata['username'] != 'bilal.sabir'):?>
                        <th><center>Delete</th>
  <?php endif;?>

    <?php /*?><?php if($sessiondata['data_modification'] && $sessiondata['username'] != 'bilal.sabir' ):?><?php */?>
         <?php if($sessiondata['username'] != 'bilal.sabir'):?>
                        <th><center>Print</th>
                        <th><center>Edit</th>
                        <th><center>Change Pwd</th>
                        <th><center>Upgrade</th>
    <?php endif;?>

                      </tr>
                    </thead>
                    <tbody>
                    <?php $sr=0;?>
                      <?php foreach ($freemembers as $member): ?>
<tr><td><center><?php echo $sr+=1; ?></td><td><center><?php echo $member->first_name; ?></td>
<td><center><?php echo $member->mobile; ?></td><td><center><?php echo $member->cnic; ?></td>
<td><center><?php echo $member->email; ?></td>
<td><center><?php echo $member->province; ?></td><td><center><?php echo $member->district; ?></td><td><center><?php echo $member->tehsil; ?></td><td><center><?php echo $member->uc; ?></td>
<?php /*?> <?php if($sessiondata['deletemembers']):?><?php */?>
     <?php if($sessiondata['username'] != 'bilal.sabir'):?>

<td><center><a href="<?php echo base_url() . "index.php/admin/deletefreemember/" . $member->id; ?>">delete</a></td>
<?php endif;?>
  <?php /*?><?php if($sessiondata['data_modification'] && $sessiondata['username'] != 'bilal.sabir' ):?><?php */?>
       <?php if($sessiondata['username'] != 'bilal.sabir'):?>
<td><center><a href="<?php echo base_url() . "index.php/admin/printcardfree/" . $member->id; ?>">print</a></td>

<td><center><a href="<?php echo base_url() . "index.php/admin/editprofilefree/" . $member->id; ?>">edit</a></td>
<td><center><a href="<?php echo base_url() . "index.php/admin/changepasswordfree/" . $member->id; ?>">change pwd</a></td>
<td><center><a href="<?php echo base_url() . "index.php/admin/upgradeprofile/" . $member->id; ?>">Upgrade</a></td>
<?php endif;?>
</tr>
<?php endforeach; ?>
                    </tbody>
                  </table>
</code>```

this is the view of my table free_members

答:
I'm not familiar with Codeigniter but MySQL syntax should be this:

INSERT INTO table1 (table1.row1, table1.row2)
SELECT table2.row1, table2.row2
FROM table2
WHERE PUT_YOUR_CONDITION_IF_NEEDED

I've found this for Codeigniter.

Body:
I'm kinda stuck here! I have to two tables free_members and domstic_members and I need to move selected rows from free_members tables to the domestic_members table. why I'm saying selected rows because of I at the end of every row in free_members tables there is an upgrade option which will move that row to the domestic_members table. I have the code but it's not working the way I want. right now what is happening is when I click on upgrade option it just copies the whole table records and sends it's to the other table. this here is the code

Controller

function upgradeprofile() {
    //  $this->load->database();
    $this->load->model('freemember_model');

    $this->freemember_model->upgrade();
}

model

function upgrade() {
    $query = $this->db->get('free_members');
    foreach ($query->result() as $row) {
        $this->db->where('id', $member_id);
        $this->db->insert('domestic_members', $row);
    }
}

View

  Search Member:
                    <input type="text" name ='search' id='search' placeholder="Search a member"/>
                    <input type="hidden" name ='limit_from' id='limit_from'/>
                    </form>

<button type="button" onclick="CallPrint1('background12')">Print</button>

                        Sr#
                        Full Name

                        Mobile Number
                         Membership# / CNIC
                        Email Address

                        Province
                        District
                        Tehsil
                        Union Council
<?php /*?>  <?php if($sessiondata['deletemembers']):?><?php */?>
     <?php if($sessiondata['username'] != 'bilal.sabir'):?>
                        Delete
  <?php endif;?>

    <?php /*?><?php if($sessiondata['data_modification'] && $sessiondata['username'] != 'bilal.sabir' ):?><?php */?>
         <?php if($sessiondata['username'] != 'bilal.sabir'):?>
                        Print
                        Edit
                        Change Pwd
                        Upgrade
    <?php endif;?>

                    <?php $sr=0;?>
                      <?php foreach ($freemembers as $member): ?>

<?php echo $sr+=1; ?>	<?php echo $member->first_name; ?>
<?php echo $member->mobile; ?>	<?php echo $member->cnic; ?>
<?php echo $member->email; ?>
<?php echo $member->province; ?>	<?php echo $member->district; ?>	<?php echo $member->tehsil; ?>	<?php echo $member->uc; ?>
<?php /*?> <?php if($sessiondata['deletemembers']):?><?php */?>
     <?php if($sessiondata['username'] != 'bilal.sabir'):?>

<a href="<?php echo base_url() . "index.php/admin/deletefreemember/" . $member->id; ?>">delete
<?php endif;?>
  <?php /*?><?php if($sessiondata['data_modification'] && $sessiondata['username'] != 'bilal.sabir' ):?><?php */?>
       <?php if($sessiondata['username'] != 'bilal.sabir'):?>
<a href="<?php echo base_url() . "index.php/admin/printcardfree/" . $member->id; ?>">print

<a href="<?php echo base_url() . "index.php/admin/editprofilefree/" . $member->id; ?>">edit
<a href="<?php echo base_url() . "index.php/admin/changepasswordfree/" . $member->id; ?>">change pwd
<a href="<?php echo base_url() . "index.php/admin/upgradeprofile/" . $member->id; ?>">Upgrade
<?php endif;?>

<?php endforeach; ?>

this is the view of my table free_members


问:
Facing a problem with GWT Data Serialization
This is similar to the question:  GWT Data Serialization

I am using Date Object @ my client,

Here is what I tried,
I created a Date Object, showed its toString() in a Label and passed it to server via Rpc whose return value is the same Date's toString()

value passed:

```<code>Date value = new Date(2011, 0, 19);
</code>```

Output @ Hosted/Development mode : (http://127.0.0.1:8888/MyApplication.html?gwt.codesvr=127.0.0.1:9997)

Client Reads: Thu Jan 19 00:00:00 IST 3911 Server reads:Thu Jan 19 00:00:00 IST 3911

Output @ Production mode (after GWT compile) : (http://127.0.0.1:8888/MyApplication.html)

Client Reads: Thu Jan 19 00:00:00 GMT+530 3911 Server reads:Thu Jan 19 00:00:00 IST 3911

Output @ Deploying in Jboss running in the same Machine :

Client Reads: Thu Jan 19 00:00:00 GMT+530 3911 Server reads:Wed Jan 18 18:30:00 GMT 3911

What's mind boggling is that its the same machine and hence the locale, etc should ideally be the same, still @ hosted mode I see client sends IST server receiving IST, @production I see client sends GMT server receives IST and @Jboss server deploy I see client sends GMT and server receives GMT with one Day less !!

The fact that the server recieves one day less is very seriously affecting my application business logic, basically I am using iBatis thats populating my pojos from database and sending it to client and at client I am using GXT which is showing me a UI for date selection.

Using String for date is not suitable for me since its a major change in application core pojos, all database select and insert queries just because my client library does not handle Dates well.

Does anyone have a alternative to this ?

答:
You can try to use DateTimeFormat to build something that is unambiguous among machines despite locales. Format like 'yyyy-MM-dd HH:mm:ss ZZZZ' instead of using toString()</p>

```<code>Date today = new Date();
DateTimeFormat fmt = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss ZZZZ");
GWT.log(fmt.format(today));
</code>```

Body:
This is similar to the question:  GWT Data Serialization

I am using Date Object @ my client,

Here is what I tried,
I created a Date Object, showed its toString() in a Label and passed it to server via Rpc whose return value is the same Date's toString()

value passed:

Date value = new Date(2011, 0, 19);

Output @ Hosted/Development mode : (http://127.0.0.1:8888/MyApplication.html?gwt.codesvr=127.0.0.1:9997)

Client Reads: Thu Jan 19 00:00:00 IST 3911 Server reads:Thu Jan 19 00:00:00 IST 3911

Output @ Production mode (after GWT compile) : (http://127.0.0.1:8888/MyApplication.html)

Client Reads: Thu Jan 19 00:00:00 GMT+530 3911 Server reads:Thu Jan 19 00:00:00 IST 3911

Output @ Deploying in Jboss running in the same Machine :

Client Reads: Thu Jan 19 00:00:00 GMT+530 3911 Server reads:Wed Jan 18 18:30:00 GMT 3911

What's mind boggling is that its the same machine and hence the locale, etc should ideally be the same, still @ hosted mode I see client sends IST server receiving IST, @production I see client sends GMT server receives IST and @Jboss server deploy I see client sends GMT and server receives GMT with one Day less !!

The fact that the server recieves one day less is very seriously affecting my application business logic, basically I am using iBatis thats populating my pojos from database and sending it to client and at client I am using GXT which is showing me a UI for date selection.

Using String for date is not suitable for me since its a major change in application core pojos, all database select and insert queries just because my client library does not handle Dates well.

Does anyone have a alternative to this ?

Body:
You can try to use DateTimeFormat to build something that is unambiguous among machines despite locales. Format like 'yyyy-MM-dd HH:mm:ss ZZZZ' instead of using toString()

Date today = new Date();
DateTimeFormat fmt = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss ZZZZ");
GWT.log(fmt.format(today));


问:
AngularJS directive for get only scroll down event?
I got directive for getting scrolling event, but I wanna scroll down event only.</p>

```<code>.directive('whenScrolled', function() {
    return function(scope, elm, attr) {
        var raw = elm[0];

        elm.bind('scroll', function() {
            if (raw.scrollTop + raw.offsetHeight >= raw.scrollHeight) {
                scope.$apply(attr.whenScrolled);
            }
        });
    };
})
</code>```

答:
I have resolved this problem by the following code.</p>

```<code>//=========================================================================
// Custom Infinite Scoller for table edit
//=========================================================================
.directive('whenScrolled', function() {
    return function(scope, elm, attr) {
        var raw = elm[0];

        ̶e̶l̶m̶.̶b̶i̶n̶d̶(̶'̶w̶h̶e̶e̶l̶'̶,̶ ̶f̶u̶n̶c̶t̶i̶o̶n̶(̶)̶ ̶{̶
        elm.bind('wheel', function(event) {
            var delta;
            if (event.wheelDelta){
                delta = event.wheelDelta;
            }else{
                delta = -1 *event.deltaY;
            }
            if (delta < 0){
                //call whenScrolled attribute to HTML for calling function from controller --- Scroll Up
                scope.$apply(attr.whenScrolled);

            }else if (delta > 0){
                //do nothing --- Scroll Down
            }
        });

    };
})
</code>```

Body:
I got directive for getting scrolling event, but I wanna scroll down event only.

.directive('whenScrolled', function() {
    return function(scope, elm, attr) {
        var raw = elm[0];

        elm.bind('scroll', function() {
            if (raw.scrollTop + raw.offsetHeight >= raw.scrollHeight) {
                scope.$apply(attr.whenScrolled);
            }
        });
    };
})

Body:
I have resolved this problem by the following code.

//=========================================================================
// Custom Infinite Scoller for table edit
//=========================================================================
.directive('whenScrolled', function() {
    return function(scope, elm, attr) {
        var raw = elm[0];

        ̶e̶l̶m̶.̶b̶i̶n̶d̶(̶'̶w̶h̶e̶e̶l̶'̶,̶ ̶f̶u̶n̶c̶t̶i̶o̶n̶(̶)̶ ̶{̶
        elm.bind('wheel', function(event) {
            var delta;
            if (event.wheelDelta){
                delta = event.wheelDelta;
            }else{
                delta = -1 *event.deltaY;
            }
            if (delta < 0){
                //call whenScrolled attribute to HTML for calling function from controller --- Scroll Up
                scope.$apply(attr.whenScrolled);

            }else if (delta > 0){
                //do nothing --- Scroll Down
            }
        });

    };
})


问:
Fancybox iframe pops up but url is not loading
It says in cosole => Uncaught TypeError: Cannot read property 'showIframe' of undefined at HTMLIFrameElement.onload at line 1 but there are no errors
.....

```<code><script type="text/javascript" src="../src/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="../fancybox/jquery.fancybox-1.2.6.css" media="screen" />
<script type="text/javascript" src="../fancybox/jquery.fancybox-1.2.6.js"></script>
<script type="text/javascript">

  jQuery(document).ready(function($){
           $("a.iframe").fancybox({
            'zoomSpeedIn'       :   500,
            'zoomSpeedOut'      :   450,
            'frameHeight'       :   400,
            'frameWidth'        :   525,
            'overlayShow'       :   true,
            'overlayOpacity'    :   0.6,
            'type'              :  'iframe'
        });
    });
</script>
<a href="https://example.com" class="iframe">Edit</a>
</code>```

...

答: its solved I had added extra jquery.min.js in my footer. </p>

Body:
It says in cosole => Uncaught TypeError: Cannot read property 'showIframe' of undefined at HTMLIFrameElement.onload at line 1 but there are no errors
.....

<link rel="stylesheet" type="text/css" href="../fancybox/jquery.fancybox-1.2.6.css" media="screen" />

Edit

...


问:
Using the constructor in order to select on the store and ngOnInit in order to dispatch from the store
My question relates to dispatching & selecting from the ngrx store.

Let's look at the following code from the official example app:

```<code>export class CollectionPageComponent implements OnInit {
  books$: Observable<Book[]>;

  constructor(private store: Store<fromBooks.State>) {
    this.books$ = store.select(fromBooks.getBookCollection);
  }

  ngOnInit() {
    this.store.dispatch(new collection.Load());
  }
}
</code>```

I would like to understand what motivated the choice of dispatching from ngOnInit and selecting from the constructor.

Can anyone please provide an explanation?

P.S. By the way, the above is sample code from the ngrx example app that can be found here: https://github.com/ngrx/platform/blob/master/example-app/app/books/containers/collection-page.ts

答:
The constructor is executed when the class is instantiated and ensures proper initialization of the class´ fields.
This is where Angular resolves providers you may pass as arguments in your constructor.

The ngOnInit lifecycle hook is called after the data-bound properties have been checked for the first time (inputs & outputs of the component).
For a more detailed explanation see this question.

The motivation for selecting from ngrx store in the constructor and dispatching from ngOnInit as far as I understand it, is that selecting is part of initializing you component class. Since this.books$ is an Observable, it makes sense initialize it in the constructor so it is ready for use immediately after creation. Assuming the bookCollection.Load() emits a value to this.books$ you want this.books$ to be an observable of those books before an eventual value is emitted.

Since you want those values emitted to this.books$ it makes sense to dispatch the action in ngOnInit. This way you can ne certain that this.books$ is initialized.

This answer to a similar question might also be of help.

Body:
My question relates to dispatching & selecting from the ngrx store.

Let's look at the following code from the official example app:

export class CollectionPageComponent implements OnInit {
  books$: Observable<Book[]>;

  constructor(private store: Store<fromBooks.State>) {
    this.books$ = store.select(fromBooks.getBookCollection);
  }

  ngOnInit() {
    this.store.dispatch(new collection.Load());
  }
}

I would like to understand what motivated the choice of dispatching from ngOnInit and selecting from the constructor.

Can anyone please provide an explanation?

P.S. By the way, the above is sample code from the ngrx example app that can be found here: https://github.com/ngrx/platform/blob/master/example-app/app/books/containers/collection-page.ts