问:
Umbraco outputting filesize
I'm trying to output the correct size for pdf files that has been uploaded.
But the only output is 0 - what am I doing wrong?</p>

```<code><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:umbraco.contour="urn:umbraco.contour"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets umbraco.contour ">

<xsl:output method="xml" omit-xml-declaration="yes" />

<xsl:param name="currentPage"/>

<xsl:variable name="documentTypeAlias" select="string('PdfItem')"/>

<xsl:variable name="size" select="@currentpage/data [@alias = 'umbracoBytes']" />
<xsl:variable name="sizeAndSuffix">
        <xsl:choose>
                <xsl:when test="$size >= 1073741824">
                        <xsl:value-of select="format-number($size div 1073741824,'#,###')"/>
                        <xsl:text>GB</xsl:text>
                </xsl:when>
                <xsl:when test="$size >= 1048576">
                        <xsl:value-of select="format-number($size div 1048576,'#,###')"/>
                        <xsl:text>MB</xsl:text>
                </xsl:when>
                <xsl:when test="$size >= 1024">
                        <xsl:value-of select="format-number($size div 1024,'#,###')"/>
                        <xsl:text>KB</xsl:text>
                </xsl:when>
                <xsl:when test="$size > 0 and $size < 1024">
                        <xsl:value-of select="format-number($size div 0,'#,###')"/>
                        <xsl:text> Bytes</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                        <xsl:text>0 Bytes</xsl:text>
                </xsl:otherwise>
        </xsl:choose>
</xsl:variable>

<xsl:template match="/">
<xsl:for-each select="$currentPage/node [@nodeTypeAlias = $documentTypeAlias and string(data [@alias='umbracoNaviHide']) != '0']">
    <div class="pdf">
        <a>
<xsl:attribute name="class">pdfmenu</xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="umbraco.library:GetMedia(./data[@alias='pdf'], 0)/data [@alias = 'umbracoFile']"/></xsl:attribute>

            <strong><xsl:value-of select="@nodeName"/><span>
            (<xsl:value-of select="$sizeAndSuffix"/>)</span></strong>
            <em><xsl:value-of select="data [@alias = 'PDFBeskrivelse']"/></em>
        <img>
        <xsl:attribute name="src"><xsl:value-of select="data [@alias = 'PDFBillede']"/></xsl:attribute>
        <xsl:attribute name="alt"></xsl:attribute>
        <xsl:attribute name="height">200</xsl:attribute>
        <xsl:attribute name="width">141</xsl:attribute>
        </img>
        </a>
    </div>

</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
</code>```

答:
Alright, I've move the size variable into the for-each loop, as it varies per file and fixed a few typos:

```<code><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY nbsp " ">
]>
<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:umbraco.contour="urn:umbraco.contour"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets umbraco.contour ">

  <xsl:output method="xml" omit-xml-declaration="yes" />

  <xsl:param name="currentPage"/>

  <xsl:variable name="documentTypeAlias" select="string('PdfItem')"/>

  <xsl:template match="/">
    <xsl:for-each select="$currentPage/node [@nodeTypeAlias = $documentTypeAlias and string(data [@alias='umbracoNaviHide']) != '0']">
      <xsl:if test="string(data [@alias = 'pdf']) != ''">

        <xsl:variable name="size" select="umbraco.library:GetMedia(data[@alias='pdf'], 0)/data [@alias = 'umbracoFile']" />

        <xsl:variable name="sizeAndSuffix">
          <xsl:choose>
            <xsl:when test="$size >= 1073741824">
              <xsl:value-of select="format-number($size div 1073741824,'#,###')"/>
              <xsl:text>GB</xsl:text>
            </xsl:when>
            <xsl:when test="$size >= 1048576">
              <xsl:value-of select="format-number($size div 1048576,'#,###')"/>
              <xsl:text>MB</xsl:text>
            </xsl:when>
            <xsl:when test="$size >= 1024">
              <xsl:value-of select="format-number($size div 1024,'#,###')"/>
              <xsl:text>KB</xsl:text>
            </xsl:when>
            <xsl:when test="$size > 0 and $size < 1024">
              <xsl:value-of select="format-number($size div 0,'#,###')"/>
              <xsl:text> Bytes</xsl:text>
            </xsl:when>
            <xsl:otherwise>
              <xsl:text>0 Bytes</xsl:text>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:variable>

        <div class="pdf">
          <a>
            <xsl:attribute name="class">pdfmenu</xsl:attribute>
            <xsl:attribute name="href">
              <xsl:value-of select="umbraco.library:GetMedia(data[@alias='pdf'], 0)/data [@alias = 'umbracoFile']"/>
            </xsl:attribute>

            <strong>
              <xsl:value-of select="@nodeName"/>
              <span>
                (<xsl:value-of select="$sizeAndSuffix"/>)
              </span>
            </strong>
            <em>
              <xsl:value-of select="data [@alias = 'PDFBeskrivelse']"/>
            </em>
            <img>
              <xsl:attribute name="src">
                <xsl:value-of select="data [@alias = 'PDFBillede']"/>
              </xsl:attribute>
              <xsl:attribute name="alt"></xsl:attribute>
              <xsl:attribute name="height">200</xsl:attribute>
              <xsl:attribute name="width">141</xsl:attribute>
            </img>
          </a>
        </div>

      </xsl:if>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>
</code>```

That should do the trick.

Title: Umbraco outputting filesize

Body:
I'm trying to output the correct size for pdf files that has been uploaded.
But the only output is 0 - what am I doing wrong?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:umbraco.contour="urn:umbraco.contour"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets umbraco.contour ">

<xsl:output method="xml" omit-xml-declaration="yes" />

<xsl:param name="currentPage"/>

<xsl:variable name="documentTypeAlias" select="string('PdfItem')"/>

<xsl:variable name="size" select="@currentpage/data [@alias = 'umbracoBytes']" />
<xsl:variable name="sizeAndSuffix">
        <xsl:choose>
                <xsl:when test="$size >= 1073741824">
                        <xsl:value-of select="format-number($size div 1073741824,'#,###')"/>
                        <xsl:text>GB</xsl:text>
                </xsl:when>
                <xsl:when test="$size >= 1048576">
                        <xsl:value-of select="format-number($size div 1048576,'#,###')"/>
                        <xsl:text>MB</xsl:text>
                </xsl:when>
                <xsl:when test="$size >= 1024">
                        <xsl:value-of select="format-number($size div 1024,'#,###')"/>
                        <xsl:text>KB</xsl:text>
                </xsl:when>
                <xsl:when test="$size > 0 and $size < 1024">
                        <xsl:value-of select="format-number($size div 0,'#,###')"/>
                        <xsl:text> Bytes</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                        <xsl:text>0 Bytes</xsl:text>
                </xsl:otherwise>
        </xsl:choose>
</xsl:variable>

<xsl:template match="/">
<xsl:for-each select="$currentPage/node [@nodeTypeAlias = $documentTypeAlias and string(data [@alias='umbracoNaviHide']) != '0']">

<xsl:attribute name="class">pdfmenu</xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="umbraco.library:GetMedia(./data[@alias='pdf'], 0)/data [@alias = 'umbracoFile']"/></xsl:attribute>

            <xsl:value-of select="@nodeName"/>
            (<xsl:value-of select="$sizeAndSuffix"/>)
            <xsl:value-of select="data [@alias = 'PDFBeskrivelse']"/>

        <xsl:attribute name="src"><xsl:value-of select="data [@alias = 'PDFBillede']"/></xsl:attribute>
        <xsl:attribute name="alt"></xsl:attribute>
        <xsl:attribute name="height">200</xsl:attribute>
        <xsl:attribute name="width">141</xsl:attribute>

</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Body:
Alright, I've move the size variable into the for-each loop, as it varies per file and fixed a few typos:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY nbsp "&#x00A0;">
]>
<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:umbraco.contour="urn:umbraco.contour"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets umbraco.contour ">

  <xsl:output method="xml" omit-xml-declaration="yes" />

  <xsl:param name="currentPage"/>

  <xsl:variable name="documentTypeAlias" select="string('PdfItem')"/>

  <xsl:template match="/">
    <xsl:for-each select="$currentPage/node [@nodeTypeAlias = $documentTypeAlias and string(data [@alias='umbracoNaviHide']) != '0']">
      <xsl:if test="string(data [@alias = 'pdf']) != ''">

        <xsl:variable name="size" select="umbraco.library:GetMedia(data[@alias='pdf'], 0)/data [@alias = 'umbracoFile']" />

        <xsl:variable name="sizeAndSuffix">
          <xsl:choose>
            <xsl:when test="$size &gt;= 1073741824">
              <xsl:value-of select="format-number($size div 1073741824,'#,###')"/>
              <xsl:text>GB</xsl:text>
            </xsl:when>
            <xsl:when test="$size &gt;= 1048576">
              <xsl:value-of select="format-number($size div 1048576,'#,###')"/>
              <xsl:text>MB</xsl:text>
            </xsl:when>
            <xsl:when test="$size &gt;= 1024">
              <xsl:value-of select="format-number($size div 1024,'#,###')"/>
              <xsl:text>KB</xsl:text>
            </xsl:when>
            <xsl:when test="$size &gt; 0 and $size &lt; 1024">
              <xsl:value-of select="format-number($size div 0,'#,###')"/>
              <xsl:text> Bytes</xsl:text>
            </xsl:when>
            <xsl:otherwise>
              <xsl:text>0 Bytes</xsl:text>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:variable>

        <div class="pdf">
          <a>
            <xsl:attribute name="class">pdfmenu</xsl:attribute>
            <xsl:attribute name="href">
              <xsl:value-of select="umbraco.library:GetMedia(data[@alias='pdf'], 0)/data [@alias = 'umbracoFile']"/>
            </xsl:attribute>

            <strong>
              <xsl:value-of select="@nodeName"/>
              <span>
                (<xsl:value-of select="$sizeAndSuffix"/>)
              </span>
            </strong>
            <em>
              <xsl:value-of select="data [@alias = 'PDFBeskrivelse']"/>
            </em>
            <img>
              <xsl:attribute name="src">
                <xsl:value-of select="data [@alias = 'PDFBillede']"/>
              </xsl:attribute>
              <xsl:attribute name="alt"></xsl:attribute>
              <xsl:attribute name="height">200</xsl:attribute>
              <xsl:attribute name="width">141</xsl:attribute>
            </img>
          </a>
        </div>

      </xsl:if>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

That should do the trick.


来源: stackexchange

问:
Get WebSocket Error: Network Error 12030 when using File.Copy with SignalR
I downloaded Sample SignalR Progress Bar solution. It simulates a long running process on the server keeps updating the client using SignalR. It was working perfectly on IISExpress until I added a File.Copy(source, destination, true) to my method in the controller (see below).

```<code>public JsonResult LongRunningProcess()
{
    string directory = Server.MapPath("~/bin/") + @"\";

    string source = directory + @"Templates\Template.xlsx";
    string destination = directory + @"Spreadsheets\output file.xlsx";
    System.IO.File.Copy(source, destination, true);

    for (int i = 0; i <= 50; i++)
    {
        Thread.Sleep(500);
        Functions.SendProgress("Process in progress...", i , 50);
    }

    return Json("", JsonRequestBehavior.AllowGet);
}
</code>```

Now I receive a WebSocketException on server-side:

```<code>SignalR.Transports.WebSocketTransport Error: 0 : OnError(7bdc2904-8f12-4324-898f-58e4a9f4e686, System.Net.WebSockets.WebSocketException (0x800703E3): The I/O operation has been aborted because of either a thread exit or an application request
   at System.Web.WebSockets.WebSocketPipe.<>c__DisplayClass9_0.<ReadFragmentAsync>b__0(Int32 hrError, Int32 cbIO, Boolean fUtf8Encoded, Boolean fFinalFragment, Boolean fClose)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.WebSockets.AspNetWebSocket.<DoWork>d__45`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.WebSockets.AspNetWebSocket.<>c__DisplayClass36_0.<<ReceiveAsyncImpl>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNet.SignalR.WebSockets.WebSocketMessageReader.<ReadMessageAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNet.SignalR.WebSockets.WebSocketHandler.<ProcessWebSocketRequestAsync>d__25.MoveNext())
</code>```

and a WebSocket error on client-side:

```<code>SCRIPT12030: WebSocket Error: Network Error 12030, The connection with the server was terminated abnormally
[time] SignalR: Unclean disconnect from websocket:
[time] SignalR: Closing the Websocket.
</code>```

When I checked jQuery.signalr-2.2.1.js, when onclose event raised, error code is 1000.

I also raised an issue on SignalR website. I'll be grateful if you can suggest any way to find out where/why this is happening.

More information:

It's happening in Internet Explorer as well as Google Chrome as I
tested.

I'm using SignalR 2.2.1 and .NET Framework 4.5.2 on Visual    Studio
2015 but I also tried a different SignalR version (2.0.2).

答:
I finally found out how to solve the problem. My attempt to make changes in Bin folder here:

```<code>string directory = Server.MapPath("~/bin/") + @"\";

string source = directory + @"Templates\Template.xlsx";
string destination = directory + @"Spreadsheets\output file.xlsx";
System.IO.File.Copy(source, destination, true);
</code>```

was resulting in IIS recycling application domain and as a result, SignalR connection reset and throwing a WebSocketException. So, changing the first line to:

```<code>string directory = Server.MapPath("~/") + @"\";
</code>```

solved my problem.

ContentLicense: CC BY-SA 3.0

Body:
I downloaded Sample SignalR Progress Bar solution. It simulates a long running process on the server keeps updating the client using SignalR. It was working perfectly on IISExpress until I added a File.Copy(source, destination, true) to my method in the controller (see below).

public JsonResult LongRunningProcess()
{
    string directory = Server.MapPath("~/bin/") + @"\";

    string source = directory + @"Templates\Template.xlsx";
    string destination = directory + @"Spreadsheets\output file.xlsx";
    System.IO.File.Copy(source, destination, true);

    for (int i = 0; i <= 50; i++)
    {
        Thread.Sleep(500);
        Functions.SendProgress("Process in progress...", i , 50);
    }

    return Json("", JsonRequestBehavior.AllowGet);
}

Now I receive a WebSocketException on server-side:

SignalR.Transports.WebSocketTransport Error: 0 : OnError(7bdc2904-8f12-4324-898f-58e4a9f4e686, System.Net.WebSockets.WebSocketException (0x800703E3): The I/O operation has been aborted because of either a thread exit or an application request
   at System.Web.WebSockets.WebSocketPipe.<>c__DisplayClass9_0.<ReadFragmentAsync>b__0(Int32 hrError, Int32 cbIO, Boolean fUtf8Encoded, Boolean fFinalFragment, Boolean fClose)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.WebSockets.AspNetWebSocket.<DoWork>d__45`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.WebSockets.AspNetWebSocket.<>c__DisplayClass36_0.<<ReceiveAsyncImpl>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNet.SignalR.WebSockets.WebSocketMessageReader.<ReadMessageAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNet.SignalR.WebSockets.WebSocketHandler.<ProcessWebSocketRequestAsync>d__25.MoveNext())

and a WebSocket error on client-side:

SCRIPT12030: WebSocket Error: Network Error 12030, The connection with the server was terminated abnormally
[time] SignalR: Unclean disconnect from websocket:
[time] SignalR: Closing the Websocket.

When I checked jQuery.signalr-2.2.1.js, when onclose event raised, error code is 1000.

I also raised an issue on SignalR website. I'll be grateful if you can suggest any way to find out where/why this is happening.

More information:

It's happening in Internet Explorer as well as Google Chrome as I
tested.

I'm using SignalR 2.2.1 and .NET Framework 4.5.2 on Visual    Studio
2015 but I also tried a different SignalR version (2.0.2).

Body:
I finally found out how to solve the problem. My attempt to make changes in Bin folder here:

string directory = Server.MapPath("~/bin/") + @"\";

string source = directory + @"Templates\Template.xlsx";
string destination = directory + @"Spreadsheets\output file.xlsx";
System.IO.File.Copy(source, destination, true);

was resulting in IIS recycling application domain and as a result, SignalR connection reset and throwing a WebSocketException. So, changing the first line to:

string directory = Server.MapPath("~/") + @"\";

solved my problem.


问:
Need help for my search bar php
I have been following this link as a guideline for my search bar
https://www.youtube.com/watch?v=Wvs6sbLN3NI&t=678s

Im a beginner in php and sql please help me with this one.
i dont know what to do in sql syntax.
the error is, Notice: Undefined variable: q in C:\xampp\htdocs\login-system\search.php on line 21
thanks in advance.

```<code><?php

    $con = mysql_connect('localhost','root','');
    $db = mysql_select_db('accounts');

?>
<!DOCTYPE html>
<html>
<head>
        <title> Search Form </title>
        <link rel="stylesheet" type="text/css" href="css/stylesearch.css">

</head>
<body>

    <form action = "search.php" method ="GET" id="searchForm">
        <input type="text" name="q" id="searchBox" placeholder="Search Here" value="" /><input type="submit" id="searchBtn" value ="GO" />
    </form>

    <?php
        $query = mysql_query("SELECT * FROM provider WHERE provider LIKE '%$q%' OR broker LIKE '%$q%' OR deductible LIKE '%$q%' OR deductible_waiver LIKE '%$q%' OR accredited_banks LIKE '%$q%' OR can_not_offer_mortgaged_with LIKE '%$q%' OR casa_eligibility LIKE '%$q%' OR depreciation LIKE '%$q%' OR special_quotes LIKE '%$q%' OR unit_age_limit LIKE '%$q%' OR provider_information LIKE '%$q%' OR provider_branches LIKE '%$q%' OR mmx_exclusive LIKE '%$q%' OR disclaimer LIKE '%$q%' OR accredited_shops LIKE '%$q%' OR roadside_assistance_number LIKE '%$q%' OR roadside_assistance_coverage LIKE '%$q%' OR check_addressee LIKE '%$q%' OR accounts_details LIKE '%$q%' OR cancellation_charge LIKE '%$q%'");
        $num_rows = mysql_num_rows($query);

        while($row = mysql_fetch_array($query))
        {
            $id = $row['id'];
            $prov = $row['provider'];
            $brok = $row['broker'];
            $deduc = $row['deductible'];
            $deduc_waiver = $row['deductible_waiver'];
            $accre_banks = $row['accredited_banks'];
            $mort = $row['can_not_offer_mortgaged_with'];
            $casa_elig = $row['casa_eligibility'];
            $depre = $row['depreciation'];
            $s_quotes = $row['special_quotes'];
            $age = $row['unit_age_limit'];
            $prov_info = $row['provider_information'];
            $prov_branch = $row['provider_branches'];
            $mmx_exclusive = $row['mmx_exclusive'];
            $disclaimer = $row['disclaimer'];
            $accre_shops = $row['accredited_shops'];
            $roadside_assist_no = $row['roadside_assistance_number'];
            $roadside_assist_cov = $row['roadside_assistance_coverage'];
            $check_addressee = $row['check_addressee'];
            $acc_details = $row['accounts_details'];
            $can_charge = $row['cancellation_charge'];

            echo '<h3>' .$prov .'</h3><p>'. $brok.'<br>'. $deduc.'<br>'. $deduc_waiver.'<br>'. $accre_banks.'<br>'. $mort.'<br>'. $casa_elig.'<br>'. $depre.'<br>'. $s_quotes.'<br>'. $age.'<br>'. $prov_info.'<br>'. $prov_branch.'<br>'. $mmx_exclusive.'<br>'. $disclaimer.'<br>'. $accre_shops.'<br>'. $roadside_assist_no.'<br>'. $roadside_assist_cov.'<br>'. $acc_details.'<br>'. $check_addressee.'<br>'. $can_charge.'</p><br />';
        }
    ?>

</body>
</html>
</code>```

答:
Warning mysql_query, mysql_fetch_array,mysql_connect etc.. extensions were deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0.
  Instead, the MySQLi or PDO_MySQL extension should be used.

1) Try to use mysqli_* or PDO prepared statement

2) first of all follow my sample code

3) Where from your getting variable $q . you have to assign the post value to $q variable like this $q =$_GET['q']; otherwise you will get $q undefined error

```<code>        //db connection

        global $conn;

        $servername = "localhost";  //host name

        $username = "username"; //username

        $password = "password"; //password

        $mysql_database = "dbname"; //database name

    //mysqli prepared statement

        $conn = mysqli_connect($servername, $username, $password) or die("Connection failed: " . mysqli_connect_error());

       mysqli_select_db($conn,$mysql_database) or die("Opps some thing went wrong");

         $stmt = $conn->prepare("SELECT * FROM provider
                                WHERE provider LIKE %'".$q."'%
                                OR broker LIKE %'".$q."'%
                                OR deductible LIKE %'".$q."'%
                                OR deductible_waiver LIKE %'".$q."'%
                                OR accredited_banks LIKE %'".$q."'%
                                OR can_not_offer_mortgaged_with LIKE %'".$q."'%
                                OR casa_eligibility LIKE %'".$q."'%
                                OR depreciation LIKE %'".$q."'%
                                OR special_quotes LIKE %'".$q."'%
                                OR unit_age_limit LIKE %'".$q."'%
                                OR provider_information LIKE %'".$q."'%
                                OR provider_branches LIKE %'".$q."'%
                                OR mmx_exclusive LIKE %'".$q."'%
                                OR disclaimer LIKE %'".$q."'%
                                OR accredited_shops LIKE %'".$q."'%
                                OR roadside_assistance_number LIKE %'".$q."'%
                                OR roadside_assistance_coverage LIKE %'".$q."'%
                                OR check_addressee LIKE %'".$q."'%
                                OR accounts_details LIKE %'".$q."'%
                                OR cancellation_charge LIKE %'".$q."'%");

                            $stmt->execute();

                            $get_result =$stmt->get_result();

                            $row_count= $get_result->num_rows;

    ?>

    <!DOCTYPE html>
    <html>
    <head>
            <title> Search Form </title>
            <link rel="stylesheet" type="text/css" href="css/stylesearch.css">

    </head>
    <body>

        <form action = "search.php" method ="GET" id="searchForm">
            <input type="text" name="q" id="searchBox" placeholder="Search Here" value="" /><input type="submit" id="searchBtn" value ="GO" />
        </form>

        <?php
            if($row_count>0)
            {
                while($row = $get_result->fetch_assoc() )
                {
                    $id = $row['id'];
                    $prov = $row['provider'];
                    $brok = $row['broker'];
                    $deduc = $row['deductible'];
                    $deduc_waiver = $row['deductible_waiver'];
                    $accre_banks = $row['accredited_banks'];
                    $mort = $row['can_not_offer_mortgaged_with'];
                    $casa_elig = $row['casa_eligibility'];
                    $depre = $row['depreciation'];
                    $s_quotes = $row['special_quotes'];
                    $age = $row['unit_age_limit'];
                    $prov_info = $row['provider_information'];
                    $prov_branch = $row['provider_branches'];
                    $mmx_exclusive = $row['mmx_exclusive'];
                    $disclaimer = $row['disclaimer'];
                    $accre_shops = $row['accredited_shops'];
                    $roadside_assist_no = $row['roadside_assistance_number'];
                    $roadside_assist_cov = $row['roadside_assistance_coverage'];
                    $check_addressee = $row['check_addressee'];
                    $acc_details = $row['accounts_details'];
                    $can_charge = $row['cancellation_charge'];

                    echo '<h3>' .$prov .'</h3><p>'. $brok.'<br>'. $deduc.'<br>'. $deduc_waiver.'<br>'. $accre_banks.'<br>'. $mort.'<br>'. $casa_elig.'<br>'. $depre.'<br>'. $s_quotes.'<br>'. $age.'<br>'. $prov_info.'<br>'. $prov_branch.'<br>'. $mmx_exclusive.'<br>'. $disclaimer.'<br>'. $accre_shops.'<br>'. $roadside_assist_no.'<br>'. $roadside_assist_cov.'<br>'. $acc_details.'<br>'. $check_addressee.'<br>'. $can_charge.'</p><br />';
                }

            }

            $stmt->close();
            $conn->close();
        ?>

    </body>
    </html>
</code>```

Title: Need help for my search bar php

Body:
I have been following this link as a guideline for my search bar
https://www.youtube.com/watch?v=Wvs6sbLN3NI&t=678s

Im a beginner in php and sql please help me with this one.
i dont know what to do in sql syntax.
the error is, Notice: Undefined variable: q in C:\xampp\htdocs\login-system\search.php on line 21
thanks in advance.

<?php

    $con = mysql_connect('localhost','root','');
    $db = mysql_select_db('accounts');

?>
<!DOCTYPE html>

        <title> Search Form </title>
        <link rel="stylesheet" type="text/css" href="css/stylesearch.css">

    <form action = "search.php" method ="GET" id="searchForm">
        <input type="text" name="q" id="searchBox" placeholder="Search Here" value="" /><input type="submit" id="searchBtn" value ="GO" />
    </form>

    <?php
        $query = mysql_query("SELECT * FROM provider WHERE provider LIKE '%$q%' OR broker LIKE '%$q%' OR deductible LIKE '%$q%' OR deductible_waiver LIKE '%$q%' OR accredited_banks LIKE '%$q%' OR can_not_offer_mortgaged_with LIKE '%$q%' OR casa_eligibility LIKE '%$q%' OR depreciation LIKE '%$q%' OR special_quotes LIKE '%$q%' OR unit_age_limit LIKE '%$q%' OR provider_information LIKE '%$q%' OR provider_branches LIKE '%$q%' OR mmx_exclusive LIKE '%$q%' OR disclaimer LIKE '%$q%' OR accredited_shops LIKE '%$q%' OR roadside_assistance_number LIKE '%$q%' OR roadside_assistance_coverage LIKE '%$q%' OR check_addressee LIKE '%$q%' OR accounts_details LIKE '%$q%' OR cancellation_charge LIKE '%$q%'");
        $num_rows = mysql_num_rows($query);

        while($row = mysql_fetch_array($query))
        {
            $id = $row['id'];
            $prov = $row['provider'];
            $brok = $row['broker'];
            $deduc = $row['deductible'];
            $deduc_waiver = $row['deductible_waiver'];
            $accre_banks = $row['accredited_banks'];
            $mort = $row['can_not_offer_mortgaged_with'];
            $casa_elig = $row['casa_eligibility'];
            $depre = $row['depreciation'];
            $s_quotes = $row['special_quotes'];
            $age = $row['unit_age_limit'];
            $prov_info = $row['provider_information'];
            $prov_branch = $row['provider_branches'];
            $mmx_exclusive = $row['mmx_exclusive'];
            $disclaimer = $row['disclaimer'];
            $accre_shops = $row['accredited_shops'];
            $roadside_assist_no = $row['roadside_assistance_number'];
            $roadside_assist_cov = $row['roadside_assistance_coverage'];
            $check_addressee = $row['check_addressee'];
            $acc_details = $row['accounts_details'];
            $can_charge = $row['cancellation_charge'];

            echo '
' .$prov .'

'. $brok.'
'. $deduc.'
'. $deduc_waiver.'
'. $accre_banks.'
'. $mort.'
'. $casa_elig.'
'. $depre.'
'. $s_quotes.'
'. $age.'
'. $prov_info.'
'. $prov_branch.'
'. $mmx_exclusive.'
'. $disclaimer.'
'. $accre_shops.'
'. $roadside_assist_no.'
'. $roadside_assist_cov.'
'. $acc_details.'
'. $check_addressee.'
'. $can_charge.'

';
        }
    ?>

Body:
Warning mysql_query, mysql_fetch_array,mysql_connect etc.. extensions were deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0.
  Instead, the MySQLi or PDO_MySQL extension should be used.

1) Try to use mysqli_* or PDO prepared statement

2) first of all follow my sample code

3) Where from your getting variable $q . you have to assign the post value to $q variable like this $q =$_GET['q']; otherwise you will get $q undefined error

        //db connection

        global $conn;

        $servername = "localhost";  //host name

        $username = "username"; //username

        $password = "password"; //password

        $mysql_database = "dbname"; //database name

    //mysqli prepared statement

        $conn = mysqli_connect($servername, $username, $password) or die("Connection failed: " . mysqli_connect_error());

       mysqli_select_db($conn,$mysql_database) or die("Opps some thing went wrong");

         $stmt = $conn->prepare("SELECT * FROM provider
                                WHERE provider LIKE %'".$q."'%
                                OR broker LIKE %'".$q."'%
                                OR deductible LIKE %'".$q."'%
                                OR deductible_waiver LIKE %'".$q."'%
                                OR accredited_banks LIKE %'".$q."'%
                                OR can_not_offer_mortgaged_with LIKE %'".$q."'%
                                OR casa_eligibility LIKE %'".$q."'%
                                OR depreciation LIKE %'".$q."'%
                                OR special_quotes LIKE %'".$q."'%
                                OR unit_age_limit LIKE %'".$q."'%
                                OR provider_information LIKE %'".$q."'%
                                OR provider_branches LIKE %'".$q."'%
                                OR mmx_exclusive LIKE %'".$q."'%
                                OR disclaimer LIKE %'".$q."'%
                                OR accredited_shops LIKE %'".$q."'%
                                OR roadside_assistance_number LIKE %'".$q."'%
                                OR roadside_assistance_coverage LIKE %'".$q."'%
                                OR check_addressee LIKE %'".$q."'%
                                OR accounts_details LIKE %'".$q."'%
                                OR cancellation_charge LIKE %'".$q."'%");

                            $stmt->execute();

                            $get_result =$stmt->get_result();

                            $row_count= $get_result->num_rows;

    ?>

    <!DOCTYPE html>
    <html>
    <head>
            <title> Search Form </title>
            <link rel="stylesheet" type="text/css" href="css/stylesearch.css">

    </head>
    <body>

        <form action = "search.php" method ="GET" id="searchForm">
            <input type="text" name="q" id="searchBox" placeholder="Search Here" value="" /><input type="submit" id="searchBtn" value ="GO" />
        </form>

        <?php
            if($row_count>0)
            {
                while($row = $get_result->fetch_assoc() )
                {
                    $id = $row['id'];
                    $prov = $row['provider'];
                    $brok = $row['broker'];
                    $deduc = $row['deductible'];
                    $deduc_waiver = $row['deductible_waiver'];
                    $accre_banks = $row['accredited_banks'];
                    $mort = $row['can_not_offer_mortgaged_with'];
                    $casa_elig = $row['casa_eligibility'];
                    $depre = $row['depreciation'];
                    $s_quotes = $row['special_quotes'];
                    $age = $row['unit_age_limit'];
                    $prov_info = $row['provider_information'];
                    $prov_branch = $row['provider_branches'];
                    $mmx_exclusive = $row['mmx_exclusive'];
                    $disclaimer = $row['disclaimer'];
                    $accre_shops = $row['accredited_shops'];
                    $roadside_assist_no = $row['roadside_assistance_number'];
                    $roadside_assist_cov = $row['roadside_assistance_coverage'];
                    $check_addressee = $row['check_addressee'];
                    $acc_details = $row['accounts_details'];
                    $can_charge = $row['cancellation_charge'];

                    echo '<h3>' .$prov .'</h3><p>'. $brok.'<br>'. $deduc.'<br>'. $deduc_waiver.'<br>'. $accre_banks.'<br>'. $mort.'<br>'. $casa_elig.'<br>'. $depre.'<br>'. $s_quotes.'<br>'. $age.'<br>'. $prov_info.'<br>'. $prov_branch.'<br>'. $mmx_exclusive.'<br>'. $disclaimer.'<br>'. $accre_shops.'<br>'. $roadside_assist_no.'<br>'. $roadside_assist_cov.'<br>'. $acc_details.'<br>'. $check_addressee.'<br>'. $can_charge.'</p><br />';
                }

            }

            $stmt->close();
            $conn->close();
        ?>

    </body>
    </html>


问:
Calculate RecyclerView item visibility percentage inside Adapter
I want to know the item visibility percentage inside recycler view adapter. Is there any event when item is attached to the recyclerView? Or how can I highlight the middle item (which is visible) in vertical recyclerView.

Actually I want to change the background colour of cardView if its visibility turns 100%.

Thanks

答:
You can find visible item from the command</p>

```<code>int findFirstVisibleItemPosition();
int findFirstCompletelyVisibleItemPosition();
int findLastVisibleItemPosition();
int findLastCompletelyVisibleItemPosition();
</code>```

Body:
You can find visible item from the command

int findFirstVisibleItemPosition();
int findFirstCompletelyVisibleItemPosition();
int findLastVisibleItemPosition();
int findLastCompletelyVisibleItemPosition();


问:
RSS2 - getting browser readers to display it
I have a simple and validated RSS2 test document with two "items".

I have an RSS "link" element in the head section of a web page pointing to the RSS2 XML page.

I have an RSS button in the content of that web page, with a normal href pointing to the RSS2 XML page.

In Safari --

if I click on Safari's "RSS" icon in the browser address bar, I get the Safari RSS reader as expected, but only the first of the two "items" appears (if I comment out that first item, then the second item appears instead)

if I click on my content RSS button, I get the raw XML code in the browser window

In Firefox --

if I click on either Firefox's syndication icon in the browser address bar, or on my content RSS button, I get "This XML file does not appear to have any style information associated with it. The document tree is shown below."

答: Maybe a different browser would solve your problems.</p>

ContentLicense: CC BY-SA 2.5


问:
Check if timestamp older than 30 seconds
I am trying to determine if a timestamp is older than 30 seconds, but for some reason it is coming back as older than 30 seconds when it hasn't even been a couple seconds. </p>

<p>Example: https://ideone.com/KLIIBz </p>

```<code>public static Boolean cooldown(int id) {

    Calendar now = Calendar.getInstance();
    now.add(Calendar.SECOND, -secondsAgo);
    long timeAgo = now.getTimeInMillis();
    if ( cooldown.containsKey(id) ) {

        System.out.println(cooldown.get(id) + " | " + timeAgo);

        // Stored timestamp always older than timeAgo
        if ( cooldown.get(id) < timeAgo ) {

            cooldown.remove(id);

        } else {

            // This code should be executed, as I am running the function one after another from same UUID not even a second or two apart.
            return false;

        }

    }

    now = Calendar.getInstance();
    cooldown.put(id, now.getTimeInMillis());

    return true;

}
</code>```

答:
Try this:</p>

```<code>public class JavaApplication11
{
    public static void main(String[] args)
    {
        // TODO code application logic here
        Calendar now = Calendar.getInstance();
        now.add(Calendar.SECOND, -30);//Set Calendar 30 seconds in the past.

        System.out.println(has30SecsPassed(now));
    }

    static boolean has30SecsPassed(Calendar calendar)
    {
        Long numberOfMilliSec = Calendar.getInstance().getTimeInMillis() - calendar.getTimeInMillis();
        double numberOfSecondsPassed = numberOfMilliSec / 1000.0;
        System.out.println("seconds passed: " + numberOfSecondsPassed);
        return numberOfSecondsPassed >= 30;
    }

}
</code>```

Body:
I am trying to determine if a timestamp is older than 30 seconds, but for some reason it is coming back as older than 30 seconds when it hasn't even been a couple seconds.

Example: https://ideone.com/KLIIBz

public static Boolean cooldown(int id) {

    Calendar now = Calendar.getInstance();
    now.add(Calendar.SECOND, -secondsAgo);
    long timeAgo = now.getTimeInMillis();
    if ( cooldown.containsKey(id) ) {

        System.out.println(cooldown.get(id) + " | " + timeAgo);

        // Stored timestamp always older than timeAgo
        if ( cooldown.get(id) < timeAgo ) {

            cooldown.remove(id);

        } else {

            // This code should be executed, as I am running the function one after another from same UUID not even a second or two apart.
            return false;

        }

    }

    now = Calendar.getInstance();
    cooldown.put(id, now.getTimeInMillis());

    return true;

}

Body:
Try this:

public class JavaApplication11
{
    public static void main(String[] args)
    {
        // TODO code application logic here
        Calendar now = Calendar.getInstance();
        now.add(Calendar.SECOND, -30);//Set Calendar 30 seconds in the past.

        System.out.println(has30SecsPassed(now));
    }

    static boolean has30SecsPassed(Calendar calendar)
    {
        Long numberOfMilliSec = Calendar.getInstance().getTimeInMillis() - calendar.getTimeInMillis();
        double numberOfSecondsPassed = numberOfMilliSec / 1000.0;
        System.out.println("seconds passed: " + numberOfSecondsPassed);
        return numberOfSecondsPassed >= 30;
    }

}


问:
Simple validation for  element.
I have a table which consists of data from MYSQL, and whenever I make changes in an element in table, my database will be updated by ajax.
This is my javascript code to send the data in editable row.

```<code>        function saveToDatabase(editableObj,column,id) {
        $(editableObj).css("background","#FFF url(images/loaderIcon.gif) no-repeat right");
        $("#tabs-1").load(location.href + " #tabs-1");
            $.ajax({
                url: "saveedit.php",
                type: "POST",
                data:'column='+column+'&editval='+editableObj.innerHTML+'&id='+id,
                success: function(data){
                    $(editableObj).css("background","#FDFDFD");
                }
           });
    }
</code>```

After the function above, saveedit.php will deal with updating the database and it's functional.

Then, this is my table in html and these table elements are editable.

```<code>        <?php
            $result = FUNCTION_TO_RETRIEVE_DATA_FROM_DB;
            foreach($result as $k=>$v){
        ?>
        <tr>
            <td><?php echo $k+1; ?></td>
            <td contenteditable="true" onBlur="saveToDatabase(this, 'memberID', '<?php echo $result[$k]["memberID"]; ?>')"><?php echo $result[$k]["memberID"]; ?></td>

            <td contenteditable="true" onBlur="saveToDatabase(this, 'surname', '<?php echo $result[$k]["memberID"]; ?>')"><?php echo $result[$k]["surname"]; ?></td>

            <td contenteditable="true" onBlur="saveToDatabase(this, 'forename', '<?php echo $result[$k]["memberID"]; ?>')"><?php echo $result[$k]["forename"]; ?></td>

            <td contenteditable="true" onBlur="saveToDatabase(this, 'address', '<?php echo $result[$k]["memberID"]; ?>')"><?php echo $result[$k]["address"]; ?></td>

            <td contenteditable="true" onBlur="saveToDatabase(this, 'gradeID', '<?php echo $result[$k]["memberID"]; ?>')"><?php echo $result[$k]["gradeID"]; ?></td>
        </tr>
        <?php
            }
        ?>
</code>```

This code is working, but the question I would like to ask is, how can I validate the data entered by the user into this  element? For example, what if I would like to check the initial column, memberID, cannot be longer than 6 characters, or if it is required or not. What I am trying to do is to validate entered data before sending it using AJAX but now but I have no idea how validation can be done in the table element.

答:
Before calling ajax validate your column by putting condition before it.</p>

```<code>` function saveToDatabase(editableObj,column,id) {
    $(editableObj).css("background","#FFF url(images/loaderIcon.gif) no-repeat right");
        $("#tabs-1").load(location.href + " #tabs-1");
           if(column == "memberID"){
               if(editableObj.innerHTML.length > 6 ) {
                      alert("cannot be longer than 6 characters");
                      return false;
                }else{
                      $.ajax({
                        url: "saveedit.php",
                        type: "POST",
                        data:'column='+column+'&editval='+editableObj.innerHTML+'&id='+id,
                        success: function(data){
                        $(editableObj).css("background","#FDFDFD");
                       }
                    });
                   }
                 }
    }`
</code>```

Title: Simple validation for <td contenteditable="true"> element.

Body:
I have a table which consists of data from MYSQL, and whenever I make changes in an element in table, my database will be updated by ajax.
This is my javascript code to send the data in editable row.

        function saveToDatabase(editableObj,column,id) {
        $(editableObj).css("background","#FFF url(images/loaderIcon.gif) no-repeat right");
        $("#tabs-1").load(location.href + " #tabs-1");
            $.ajax({
                url: "saveedit.php",
                type: "POST",
                data:'column='+column+'&editval='+editableObj.innerHTML+'&id='+id,
                success: function(data){
                    $(editableObj).css("background","#FDFDFD");
                }
           });
    }

After the function above, saveedit.php will deal with updating the database and it's functional.

Then, this is my table in html and these table elements are editable.

        <?php
            $result = FUNCTION_TO_RETRIEVE_DATA_FROM_DB;
            foreach($result as $k=>$v){
        ?>

            <?php echo $k+1; ?>
            <td contenteditable="true" onBlur="saveToDatabase(this, 'memberID', '<?php echo $result[$k]["memberID"]; ?>')"><?php echo $result[$k]["memberID"]; ?>

            <td contenteditable="true" onBlur="saveToDatabase(this, 'surname', '<?php echo $result[$k]["memberID"]; ?>')"><?php echo $result[$k]["surname"]; ?>

            <td contenteditable="true" onBlur="saveToDatabase(this, 'forename', '<?php echo $result[$k]["memberID"]; ?>')"><?php echo $result[$k]["forename"]; ?>

            <td contenteditable="true" onBlur="saveToDatabase(this, 'address', '<?php echo $result[$k]["memberID"]; ?>')"><?php echo $result[$k]["address"]; ?>

            <td contenteditable="true" onBlur="saveToDatabase(this, 'gradeID', '<?php echo $result[$k]["memberID"]; ?>')"><?php echo $result[$k]["gradeID"]; ?>

        <?php
            }
        ?>

This code is working, but the question I would like to ask is, how can I validate the data entered by the user into this  element? For example, what if I would like to check the initial column, memberID, cannot be longer than 6 characters, or if it is required or not. What I am trying to do is to validate entered data before sending it using AJAX but now but I have no idea how validation can be done in the table element.

Body:
Before calling ajax validate your column by putting condition before it.

` function saveToDatabase(editableObj,column,id) {
    $(editableObj).css("background","#FFF url(images/loaderIcon.gif) no-repeat right");
        $("#tabs-1").load(location.href + " #tabs-1");
           if(column == "memberID"){
               if(editableObj.innerHTML.length > 6 ) {
                      alert("cannot be longer than 6 characters");
                      return false;
                }else{
                      $.ajax({
                        url: "saveedit.php",
                        type: "POST",
                        data:'column='+column+'&editval='+editableObj.innerHTML+'&id='+id,
                        success: function(data){
                        $(editableObj).css("background","#FDFDFD");
                       }
                    });
                   }
                 }
    }`


问:
rails i18n lazy lookup for module controller
If I have a controller with module Api::V1 like this

```<code>class Api::V1::UsersController < Api::ApiController
  def index
    print I18n.t('.messages')
    ...
  end
end
</code>```

how can I write the localization file en.yml so that I can utilize lazy lookup feature inside my controller file?

I have tried

```<code>en:
  api/v1/users:
    index:
      messages: test message
</code>```

But it was not working. Any kind of suggestion will be appreciated. Thank you!

答:
I'm not sure about this. But can you try </p>

```<code>en:
  api:
    v1:
      users:
        index:
          messages: test message
</code>```

Body:
If I have a controller with module Api::V1 like this

class Api::V1::UsersController < Api::ApiController
  def index
    print I18n.t('.messages')
    ...
  end
end

how can I write the localization file en.yml so that I can utilize lazy lookup feature inside my controller file?

I have tried

en:
  api/v1/users:
    index:
      messages: test message

But it was not working. Any kind of suggestion will be appreciated. Thank you!

Body:
I'm not sure about this. But can you try

en:
  api:
    v1:
      users:
        index:
          messages: test message


问:
How to change Action Bar/Title Bar font?
Not sure if this is called the action bar or the title bar but I need to change the font to a font I have in my assets folder. How do I do this?

答:
You can make a custom toolbar. below is code snapshot

```<code><android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    app:popupTheme="@style/AppTheme.PopupOverlay">

    <TextView
        android:id="@+id/toolbar_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/app_name"
        android:textColor="@color/white"
        android:textSize="17sp"
        android:textStyle="bold" />
</android.support.v7.widget.Toolbar>
</code>```

and then you can access toolbar_title in your java class(Activity or Fragment) and set a custom font style.

Body:
You can make a custom toolbar. below is code snapshot

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    app:popupTheme="@style/AppTheme.PopupOverlay">

    <TextView
        android:id="@+id/toolbar_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/app_name"
        android:textColor="@color/white"
        android:textSize="17sp"
        android:textStyle="bold" />
</android.support.v7.widget.Toolbar>

and then you can access toolbar_title in your java class(Activity or Fragment) and set a custom font style.


问:
Why is decoding time more for animated webP?
I am experimenting with animated webP to compare compression with GIF. I have observed that loading animated webP on internet has some delay as compared to gif for same animation. So there must have been time in decoding webP on browser(chrome in this case).

Going through documentation on google developers I came across:

"In the absence of seeking, straight-line decoding of WebP is more CPU-intensive than GIF. Lossy WebP takes 2.2x as much decode time as GIF, while lossless WebP takes 1.5x as much."

First of all what is seeking?
And secondly, is it possible to introduce seeking in webP while transcoding from gif to reduce decode time?

答: Seeking is when you decode frame 0 and then seek ahead to frame 2 instead of "straight line" decoding of frame 1. Seeking has to move around in the file while decoding frame 1 after frame 0 is faster since the file is already at the location where data for frame 1 is located.</p>


问:
Create closure in Elixir
I have a Sequence struct that consists of a state and a generator function which generates the new state from the old one. I want to write a limit function that returns a new sequence that should return the new state exactly n times at max and every n + k time it should return nil. The code so far is:

```<code>defmodule Sequence do
  defstruct [:state, :generator]

  def generate(%Sequence{state: nil}) do
    nil
  end

  def generate(%Sequence{state: state , generator: generator } = seq) do
    {old_state, new_state} = generator.(state)
    { old_state,  %Sequence{ seq | state: new_state } }
  end

  def limit(%Sequence{ generator: generator } = seq, n) when n > -1 do
    lim_gen = create_limit_gen(generator, n)
    %Sequence{ seq | generator: lim_gen }
  end

  defp create_limit_gen(generator, n) do
    lim_gen = fn
                  nil ->
                    nil
                  _ when n == 0 ->
                    nil
                  st ->
                    IO.puts(n) # no closure happens here
                    n = n - 1
                    generator.(st)
              end
    lim_gen
  end

end
</code>```

I want to have the following results:

```<code>iex> seq = %Sequence{state: 0, generator: &{&1, &1 + 1}} |> Sequence.limit 2
iex> {n, seq} = seq |> Sequence.generate; n
0
iex> {n, seq} = seq |> Sequence.generate; n
1
iex> seq |> Sequence.generate
nil
iex> seq = %Sequence{state: 0, generator: &{&1, nil}} |> Sequence.limit 2
iex> {n, seq} = seq |> Sequence.generate; n
0
iex> seq |> Sequence.generate
nil
</code>```

The problem is that the IO.puts prints always the same number, meaning it doesn't change. However my limit generator depends on that value and it changing in the closure. What is the problem here and how can I fix it ? Any help is welcomed :)

PS: I'm not allowed to add new fields to the structure and I don't want to use things like GenServer and ETS

答:
In most cases, it makes sense to create an MCVE to locate a problem and understand what’s going on. Let’s do it:

```<code>iex|1 ▶ defmodule Test do
...|1 ▶   def closure(n) do
...|1 ▶     fn
...|1 ▶       _ when is_nil(n) or n == 0 -> IO.puts("NIL")
...|1 ▶       _ ->
...|1 ▶         IO.puts(n)
...|1 ▶         closure(n - 1).(n - 1) # or something else
...|1 ▶     end
...|1 ▶   end
...|1 ▶ end
</code>```

OK, let’s test it:

```<code>iex|2 ▶ Test.closure(2).(2)
2
1
NIL
:ok
</code>```

Cool, it works as expected. Now let’s turn back to your code:

```<code>st ->
  IO.puts(n) # no closure happens here
  n = n - 1
  generator.(st)
</code>```

The second line in the clause has no effect at all, since everything in Elixir is immutable. n = n - 1 rebounds local variable n to the new value, but it’s dropped (GC’d) immediately after, since generator receives st and n is not used anymore anywhere.

The code is quite cumbersome, but I would suggest you don’t need to accumulate the current n in create_limit_gen, what you see currently is exactly how closures work: n is being assigned once, when a closure was created, and it does not change along time. To change it, one should change it explicitly, e.g. by passing n through (as shown in my first snippet for MCVE.)

Something like

```<code>generator.(n, create_limit_gen(generator, n - 1))
</code>```

and proper handling the result should do the trick.

Title: Create closure in Elixir

Body:
I have a Sequence struct that consists of a state and a generator function which generates the new state from the old one. I want to write a limit function that returns a new sequence that should return the new state exactly n times at max and every n + k time it should return nil. The code so far is:

defmodule Sequence do
  defstruct [:state, :generator]

  def generate(%Sequence{state: nil}) do
    nil
  end

  def generate(%Sequence{state: state , generator: generator } = seq) do
    {old_state, new_state} = generator.(state)
    { old_state,  %Sequence{ seq | state: new_state } }
  end

  def limit(%Sequence{ generator: generator } = seq, n) when n > -1 do
    lim_gen = create_limit_gen(generator, n)
    %Sequence{ seq | generator: lim_gen }
  end

  defp create_limit_gen(generator, n) do
    lim_gen = fn
                  nil ->
                    nil
                  _ when n == 0 ->
                    nil
                  st ->
                    IO.puts(n) # no closure happens here
                    n = n - 1
                    generator.(st)
              end
    lim_gen
  end

end

I want to have the following results:

iex> seq = %Sequence{state: 0, generator: &{&1, &1 + 1}} |> Sequence.limit 2
iex> {n, seq} = seq |> Sequence.generate; n
0
iex> {n, seq} = seq |> Sequence.generate; n
1
iex> seq |> Sequence.generate
nil
iex> seq = %Sequence{state: 0, generator: &{&1, nil}} |> Sequence.limit 2
iex> {n, seq} = seq |> Sequence.generate; n
0
iex> seq |> Sequence.generate
nil

The problem is that the IO.puts prints always the same number, meaning it doesn't change. However my limit generator depends on that value and it changing in the closure. What is the problem here and how can I fix it ? Any help is welcomed :)

PS: I'm not allowed to add new fields to the structure and I don't want to use things like GenServer and ETS

Body:
In most cases, it makes sense to create an MCVE to locate a problem and understand what’s going on. Let’s do it:

iex|1 ▶ defmodule Test do
...|1 ▶   def closure(n) do
...|1 ▶     fn
...|1 ▶       _ when is_nil(n) or n == 0 -> IO.puts("NIL")
...|1 ▶       _ ->
...|1 ▶         IO.puts(n)
...|1 ▶         closure(n - 1).(n - 1) # or something else
...|1 ▶     end
...|1 ▶   end
...|1 ▶ end

OK, let’s test it:

iex|2 ▶ Test.closure(2).(2)
2
1
NIL
:ok

Cool, it works as expected. Now let’s turn back to your code:

st ->
  IO.puts(n) # no closure happens here
  n = n - 1
  generator.(st)

The second line in the clause has no effect at all, since everything in Elixir is immutable. n = n - 1 rebounds local variable n to the new value, but it’s dropped (GC’d) immediately after, since generator receives st and n is not used anymore anywhere.

The code is quite cumbersome, but I would suggest you don’t need to accumulate the current n in create_limit_gen, what you see currently is exactly how closures work: n is being assigned once, when a closure was created, and it does not change along time. To change it, one should change it explicitly, e.g. by passing n through (as shown in my first snippet for MCVE.)

Something like

generator.(n, create_limit_gen(generator, n - 1))

and proper handling the result should do the trick.


问:
Printing Out Repeated Numbers
so I'm working on a program that takes two strings. For instance [2,3,4] and [1,4,5] and outprints 1,1,4,4,4,5,5,5,5. I don't really have a working code. So, I'm just looking for tips, not a complete code.</p>

答:
You can use Array.prototype.entries(), for..of loop, spread element, Array.prototype.fill() to create array having .length set by value of element at first array, filled with value at second array at same index

let [len, arr, res] = [[2,3,4], [1,4,5], []];

for (let [key, prop] of arr.entries()) res.push(...Array(len[key]).fill(prop));

console.log(res);```

Title: Printing Out Repeated Numbers


问:
Python Json. Getting only the last element in the json array
I just started trying out python, and right now i am in a little bit of a dilemma.

I am trying to print from a json documents, and i am only getting the last element in the array.

```<code>[{
    "FullMeasure": "1/2 cup",
    "FullWeight": "",
    "IngredientGridHeaders": null,
    "IngredientID": 1142,
    "IngredientName": "frozen corn",
    "IngredientStep": 10,
    "LanguageId": 0,
    "PostPreparation": ", thawed, drained",
    "PrePreparation": "",
    "QuantityNum": 0,
    "QuantityText": "1/2",
    "QuantityUnit": "cup",
    "RecipeIngredientID": 6291555,
    "TrialMeasure": "",
    "TrialWeight": ""
  },
  {
    "FullMeasure": "1/4 cup",
    "FullWeight": "",
    "IngredientGridHeaders": null,
    "IngredientID": 1523,
    "IngredientName": "red pepper",
    "IngredientStep": 20,
    "LanguageId": 0,
    "PostPreparation": "s",
    "PrePreparation": "chopped",
    "QuantityNum": 0,
    "QuantityText": "1/4",
    "QuantityUnit": "cup",
    "RecipeIngredientID": 6291554,
    "TrialMeasure": "",
    "TrialWeight": ""
  },
  {
    "FullMeasure": "2 Tbsp.",
    "FullWeight": "",
    "IngredientGridHeaders": null,
    "IngredientID": 20197,
    "IngredientName": "chopped green chiles",
    "IngredientStep": 30,
    "LanguageId": 0,
    "PostPreparation": ", drained",
    "PrePreparation": "canned ",
    "QuantityNum": 2,
    "QuantityText": "2",
    "QuantityUnit": "Tbsp.",
    "RecipeIngredientID": 6291552,
    "TrialMeasure": "",
    "TrialWeight": ""
  },
{
    "FullMeasure": "",
    "FullWeight": "",
    "IngredientGridHeaders": null,
    "IngredientID": 19682,
    "IngredientName": "KRAFT DELI DELUXE Process American Cheese Slice",
    "IngredientStep": 80,
    "LanguageId": 0,
    "PostPreparation": "s",
    "PrePreparation": "",
    "QuantityNum": 4,
    "QuantityText": "4",
    "QuantityUnit": "",
    "RecipeIngredientID": 6291558,
    "TrialMeasure": "",
    "TrialWeight": ""
  }
]
</code>```

I will like to get all the  ingredientID, so i wrote this little piece of code to grab the IngredientID

```<code>rec = recipes['Recipes'][0]['Ingredients']
        for records in rec:
            value = {
                        'Ingredient ID': records['IngredientID']
                    }
</code>```

when i return the value, i get

```<code>{
  "Ingreient ID": 19682
}
</code>```

I am trying to get the ingredient ID of each element and i just can't seem to figure it out. Any pointers will be well appreciated. Thank you

答:
Yet another approach, the defaultdict</p>

```<code>from collections import defaultdict
recipe_ids = defaultdict(list)
for records in rec:
    recipe_ids['recipe id'].append(records.get('IngredientID'))
</code>```

Body:
I just started trying out python, and right now i am in a little bit of a dilemma.

I am trying to print from a json documents, and i am only getting the last element in the array.

[{
    "FullMeasure": "1/2 cup",
    "FullWeight": "",
    "IngredientGridHeaders": null,
    "IngredientID": 1142,
    "IngredientName": "frozen corn",
    "IngredientStep": 10,
    "LanguageId": 0,
    "PostPreparation": ", thawed, drained",
    "PrePreparation": "",
    "QuantityNum": 0,
    "QuantityText": "1/2",
    "QuantityUnit": "cup",
    "RecipeIngredientID": 6291555,
    "TrialMeasure": "",
    "TrialWeight": ""
  },
  {
    "FullMeasure": "1/4 cup",
    "FullWeight": "",
    "IngredientGridHeaders": null,
    "IngredientID": 1523,
    "IngredientName": "red pepper",
    "IngredientStep": 20,
    "LanguageId": 0,
    "PostPreparation": "s",
    "PrePreparation": "chopped",
    "QuantityNum": 0,
    "QuantityText": "1/4",
    "QuantityUnit": "cup",
    "RecipeIngredientID": 6291554,
    "TrialMeasure": "",
    "TrialWeight": ""
  },
  {
    "FullMeasure": "2 Tbsp.",
    "FullWeight": "",
    "IngredientGridHeaders": null,
    "IngredientID": 20197,
    "IngredientName": "chopped green chiles",
    "IngredientStep": 30,
    "LanguageId": 0,
    "PostPreparation": ", drained",
    "PrePreparation": "canned ",
    "QuantityNum": 2,
    "QuantityText": "2",
    "QuantityUnit": "Tbsp.",
    "RecipeIngredientID": 6291552,
    "TrialMeasure": "",
    "TrialWeight": ""
  },
{
    "FullMeasure": "",
    "FullWeight": "",
    "IngredientGridHeaders": null,
    "IngredientID": 19682,
    "IngredientName": "KRAFT DELI DELUXE Process American Cheese Slice",
    "IngredientStep": 80,
    "LanguageId": 0,
    "PostPreparation": "s",
    "PrePreparation": "",
    "QuantityNum": 4,
    "QuantityText": "4",
    "QuantityUnit": "",
    "RecipeIngredientID": 6291558,
    "TrialMeasure": "",
    "TrialWeight": ""
  }
]

I will like to get all the  ingredientID, so i wrote this little piece of code to grab the IngredientID

rec = recipes['Recipes'][0]['Ingredients']
        for records in rec:
            value = {
                        'Ingredient ID': records['IngredientID']
                    }

when i return the value, i get

{
  "Ingreient ID": 19682
}

I am trying to get the ingredient ID of each element and i just can't seem to figure it out. Any pointers will be well appreciated. Thank you

Body:
Yet another approach, the defaultdict

from collections import defaultdict
recipe_ids = defaultdict(list)
for records in rec:
    recipe_ids['recipe id'].append(records.get('IngredientID'))


问:
Automate captcha using webdriver?
How to automate captcha using WebDriver?

Is there any alternate method to automate Captcha using Webdriver?

答:
I came across Death By Captcha.

They have good reviews and also provides API to decode image captchas.

It is a paid service.

Title: Automate captcha using webdriver?


问:
angularjs push function not working
Hi I am trying to make a single page angular js application but while adding to the list "schedulelist" only the latest record are getting pushed into the list and all the previous records are getting replaced by the latest record

This is my Html:

```<code> <table class="table1" cellspacing=2 cellpadding=5 border=0>
  <div ng-repeat="scheduleDTO in schedules">
<tr>
<td>
       <SELECT id="days" name="days" class="form-right" style="width:90%" ng-model="scheduleDTO.day_of_the_week" required>

                    <OPTION selected value="Monday">Monday</OPTION>
                    <OPTION value="Tuesday">Tuesday</OPTION>
                    <OPTION value="Wednesday">Wednesday</OPTION>
                    <OPTION value="Thursday">Thursday</OPTION>
                    <OPTION value="Friday">Friday</OPTION>
                    <OPTION value="Saturday">Saturday</OPTION>
                    <OPTION value="Sunday">Sunday</OPTION>
        </SELECT>

</td>
<td>
       <SELECT id="start_time" name="Start" class="form-right" style="width:90%" ng-model="scheduleDTO.start_time" required>
                    <OPTION value="1:00">01:00</OPTION>
                    <OPTION value="2:00">02:00</OPTION>
                    <OPTION value="3:00">03:00</OPTION>
                    <OPTION value="4:00">04:00</OPTION>
                    <OPTION value="5:00">05:00</OPTION>
                    <OPTION value="6:00">06:00</OPTION>
                    <OPTION value="7:00">07:00</OPTION>
                    <OPTION value="8:00">08:00</OPTION>
                    <OPTION selected value="9:00">09:00</OPTION>
                    <OPTION value="10:00">10:00</OPTION>
                    <OPTION value="11:00">11:00</OPTION>
                    <OPTION value="12:00">12:00</OPTION>
        </SELECT>

</td>
<td>
<SELECT id="start" name="am" class="form-right" style="width:90%" ng-model="scheduleDTO.start_time_meridiem"required>
                    <OPTION selected value="AM">AM</OPTION>
                    <OPTION value="PM">PM</OPTION>
</SELECT>

<td><SELECT  id="end_time"class="form-right" name="end" style="width:90%" ng-model="scheduleDTO.end_time" required>
                    <OPTION value="1:00">01:00</OPTION>
                    <OPTION value="2:00">02:00</OPTION>
                    <OPTION value="3:00">03:00</OPTION>
                    <OPTION value="4:00">04:00</OPTION>
                    <OPTION selected value="5:00">05:00</OPTION>
                    <OPTION value="6:00">06:00</OPTION>
                    <OPTION value="7:00">07:00</OPTION>
                    <OPTION value="8:00">08:00</OPTION>
                    <OPTION value="9:00">09:00</OPTION>
                    <OPTION value="10:00">10:00</OPTION>
                    <OPTION value="11:00">11:00</OPTION>
                    <OPTION value="12:00">12:00</OPTION>
        </SELECT>

        </td>
<td>

<SELECT id="end" name="pm" class="form-right" style="width:90%" ng-model="scheduleDTO.end_time_meridiem" required>
                    <OPTION value="AM">AM</OPTION>
                    <OPTION selected value="PM">PM</OPTION>
</SELECT>

</td>
<td><input type="button" class="addSch" ng-click="add(scheduleDTO)" value="Add Schedule" style="width:90%"> <!-- add_schedule(); -->

</td>
</tr>
</div>
</table>
<table align='center' class="table1" cellspacing=2 cellpadding=5 id="table" border=0>

<tr ng-repeat="ScheduleDTO in schedulelist">

<td>{{scheduleDTO.day_of_the_week}}</td>
<td>{{scheduleDTO.start_time}}</td>
<td>{{scheduleDTO.start_time_meridiem}}</td><td>To</td>
<td>{{scheduleDTO.end_time}}</td>
<td>{{scheduleDTO.end_time_meridiem}}</td>
<td><input type='button' value='Delete' class='delete' ng-click="remove(scheduleDTO)"></td>

</table>
</code>```

This is rthe controller:

```<code>$scope.schedulelist = [

    ];

    $scope.add = function (schedule)
            {                   schedule.volunteer_id="";
                                schedule.sid="";
                   $scope.schedulelist.push({"ScheduleDTO":schedule});
                    alert(angular.toJson($scope.schedulelist));
            };
    $scope.remove = function(schedule) {
                var index = $scope.schedulelist.indexOf(schedule);
                $scope.schedulelist.splice(index, 1);
                    alert(angular.toJson($scope.schedulelist));
            };
</code>```

答:
there is only one instance of an object in javascript if you create an object there will be single reference to it, i.e if you change in the object all the values will be changed so even you are changing the value every time it all the values pushed in the array will refer to the same object.
better solution will be</p>

```<code> $scope.add = function (scheduleValue)
        {
          var schedule=angular.copy(scheduleValue);
               schedule.volunteer_id="";
                            schedule.sid="";
               $scope.schedulelist.push({"ScheduleDTO":schedule});
                alert(angular.toJson($scope.schedulelist));
        };
</code>```

Title: angularjs push function not working

Body:
Hi I am trying to make a single page angular js application but while adding to the list "schedulelist" only the latest record are getting pushed into the list and all the previous records are getting replaced by the latest record

This is my Html:

       <SELECT id="days" name="days" class="form-right" style="width:90%" ng-model="scheduleDTO.day_of_the_week" required>

                    <OPTION selected value="Monday">Monday</OPTION>
                    <OPTION value="Tuesday">Tuesday</OPTION>
                    <OPTION value="Wednesday">Wednesday</OPTION>
                    <OPTION value="Thursday">Thursday</OPTION>
                    <OPTION value="Friday">Friday</OPTION>
                    <OPTION value="Saturday">Saturday</OPTION>
                    <OPTION value="Sunday">Sunday</OPTION>
        </SELECT>

       <SELECT id="start_time" name="Start" class="form-right" style="width:90%" ng-model="scheduleDTO.start_time" required>
                    <OPTION value="1:00">01:00</OPTION>
                    <OPTION value="2:00">02:00</OPTION>
                    <OPTION value="3:00">03:00</OPTION>
                    <OPTION value="4:00">04:00</OPTION>
                    <OPTION value="5:00">05:00</OPTION>
                    <OPTION value="6:00">06:00</OPTION>
                    <OPTION value="7:00">07:00</OPTION>
                    <OPTION value="8:00">08:00</OPTION>
                    <OPTION selected value="9:00">09:00</OPTION>
                    <OPTION value="10:00">10:00</OPTION>
                    <OPTION value="11:00">11:00</OPTION>
                    <OPTION value="12:00">12:00</OPTION>
        </SELECT>

<SELECT id="start" name="am" class="form-right" style="width:90%" ng-model="scheduleDTO.start_time_meridiem"required>
                    <OPTION selected value="AM">AM</OPTION>
                    <OPTION value="PM">PM</OPTION>
</SELECT>

<SELECT  id="end_time"class="form-right" name="end" style="width:90%" ng-model="scheduleDTO.end_time" required>
                    <OPTION value="1:00">01:00</OPTION>
                    <OPTION value="2:00">02:00</OPTION>
                    <OPTION value="3:00">03:00</OPTION>
                    <OPTION value="4:00">04:00</OPTION>
                    <OPTION selected value="5:00">05:00</OPTION>
                    <OPTION value="6:00">06:00</OPTION>
                    <OPTION value="7:00">07:00</OPTION>
                    <OPTION value="8:00">08:00</OPTION>
                    <OPTION value="9:00">09:00</OPTION>
                    <OPTION value="10:00">10:00</OPTION>
                    <OPTION value="11:00">11:00</OPTION>
                    <OPTION value="12:00">12:00</OPTION>
        </SELECT>

<SELECT id="end" name="pm" class="form-right" style="width:90%" ng-model="scheduleDTO.end_time_meridiem" required>
                    <OPTION value="AM">AM</OPTION>
                    <OPTION selected value="PM">PM</OPTION>
</SELECT>

<input type="button" class="addSch" ng-click="add(scheduleDTO)" value="Add Schedule" style="width:90%">

{{scheduleDTO.day_of_the_week}}
{{scheduleDTO.start_time}}
{{scheduleDTO.start_time_meridiem}}	To
{{scheduleDTO.end_time}}
{{scheduleDTO.end_time_meridiem}}
<input type='button' value='Delete' class='delete' ng-click="remove(scheduleDTO)">

This is rthe controller:

$scope.schedulelist = [

    ];

    $scope.add = function (schedule)
            {                   schedule.volunteer_id="";
                                schedule.sid="";
                   $scope.schedulelist.push({"ScheduleDTO":schedule});
                    alert(angular.toJson($scope.schedulelist));
            };
    $scope.remove = function(schedule) {
                var index = $scope.schedulelist.indexOf(schedule);
                $scope.schedulelist.splice(index, 1);
                    alert(angular.toJson($scope.schedulelist));
            };

Body:
there is only one instance of an object in javascript if you create an object there will be single reference to it, i.e if you change in the object all the values will be changed so even you are changing the value every time it all the values pushed in the array will refer to the same object.
better solution will be

 $scope.add = function (scheduleValue)
        {
          var schedule=angular.copy(scheduleValue);
               schedule.volunteer_id="";
                            schedule.sid="";
               $scope.schedulelist.push({"ScheduleDTO":schedule});
                alert(angular.toJson($scope.schedulelist));
        };


问:
VHS: no image rendered with <v:media.image additionalAttributes
I am using T3 8.6 and VHS 4.1.0. I want to render the pictures from tx_news using srcset, sizes etc. It all works well as long as i Use additionalAttributes to get the sizes. No Image is rendered anymore.

Here is my partial:

```<code>{namespace v=FluidTYPO3\Vhs\ViewHelpers}
<v:media.image
src="{newsItem.falMediaPreviews.0}"
alt="{mediaElement.originalResource.alternative}"
class="float-sm-none float-md-left news_header"
srcset="300,600,900,1200"
treatIdAsReference="1"
additionalAttributes="{sizes:'(min-width: 90em) 900px,(min-width: 64em) 600px,(min-width: 30em) 100px,100vw'}"
</code>```

Any Ideas what's wrong there?

答:
It's Working Fine. Just Closed the tag. with using Latest version of flux , fluidcontent and vhs

```<code><v:media.image
    src="{newsItem.falMediaPreviews.0}"
    alt="{mediaElement.originalResource.alternative}"
    class="float-sm-none float-md-left news_header"
    srcset="300,600,900,1200"
    treatIdAsReference="1"
    additionalAttributes="{sizes:'(min-width: 90em) 900px,(min-width: 64em) 600px,(min-width: 30em) 100px,100vw'}" />
</code>```

Body:
I am using T3 8.6 and VHS 4.1.0. I want to render the pictures from tx_news using srcset, sizes etc. It all works well as long as i Use additionalAttributes to get the sizes. No Image is rendered anymore.

Here is my partial:

{namespace v=FluidTYPO3\Vhs\ViewHelpers}
<v:media.image
src="{newsItem.falMediaPreviews.0}"
alt="{mediaElement.originalResource.alternative}"
class="float-sm-none float-md-left news_header"
srcset="300,600,900,1200"
treatIdAsReference="1"
additionalAttributes="{sizes:'(min-width: 90em) 900px,(min-width: 64em) 600px,(min-width: 30em) 100px,100vw'}"

Any Ideas what's wrong there?

Body:
It's Working Fine. Just Closed the tag. with using Latest version of flux , fluidcontent and vhs

<v:media.image
    src="{newsItem.falMediaPreviews.0}"
    alt="{mediaElement.originalResource.alternative}"
    class="float-sm-none float-md-left news_header"
    srcset="300,600,900,1200"
    treatIdAsReference="1"
    additionalAttributes="{sizes:'(min-width: 90em) 900px,(min-width: 64em) 600px,(min-width: 30em) 100px,100vw'}" />