问:
When I click on the button the hidden content doesn't show, why is this?
I am trying create a read more read less button. My content that is hidden is in a span tag. I used some javascript to make this work. Currently, when I click on the button nothing happens. My goal is to create a news section that shows more news when you click on the button.

This was working for me before, I used the exact same code and just merged it with some other code and it stopped working.

     $(document).ready(function () {

 var windowHeight = window.innerHeight;

 var navOpen = false;
 var onCloseBtn = false;
 var onAccordian = false;

 $("#hamburger").mouseover(function(){
  if(!navOpen){
   openMenu();
  }
  onCloseBtn = true;
 });

 $("#hamburger").mouseout(function(){
  onCloseBtn = false;
 });

 $("#hamburger").click(function(){
  toggleNav();
  console.log("clickedHam");
 });

 $("#navMenu").mouseover(function(){
  if(!navOpen && !onCloseBtn){
   keepOpen();
  }
 });

 $("#activeSpace").mouseleave(function(){
   console.log("navMenu Mouseout");
   closeMenu();
 });

 function toggleNav(){
  if(navOpen){
   closeMenu();

  } else {
   openMenu();
  }
 }
 function keepOpen(){
  console.log("keepOpen");
  navOpen = true;
  $('#hamburger').html('×');
  $('#hamburger').css("color","black");
  $("#navMenu").css("visibility","visible");
  $("#navMenu").css("height","auto");
  $("#navMenu").css("max-height", windowHeight);
 }

 function openMenu(){
  console.log("open");
  navOpen = true;
  $('#hamburger').html('×');
  $('#hamburger').css("color","black");
  $("#navMenu").css("visibility","visible");
  $("#navMenu").css("max-height", "250px"); ///change this depending on the max
 }

 function closeMenu(){
  closePanels();
  navOpen = false;
  console.log("close")
  $('#hamburger').html('☰');
  $('#hamburger').css("color","white");
  $("#navMenu").css("max-height", "0");
  $("#navMenu").css("visibility","hidden");
 }

 $(document).on('scroll', function() {
  if($(this).scrollTop()>=$('#changeNavColor').position().top - 40 && !navOpen){
   $(hamburger).css("color","black");
  }
  if($(this).scrollTop()<$('#changeNavColor').position().top - 40 && !navOpen){
   $(hamburger).css("color","white");
  }
 });

 var acc = document.getElementsByClassName("mobile-accordian");
 var i;

 for (i = 0; i < acc.length; i++) {
  acc[i].addEventListener("click", function() {
   //this.classList.toggle("active");
   $("#navMenu").css("height","auto");
   $("#navMenu").css("max-height", windowHeight);

   var panel = this.nextElementSibling;
   if (panel.style.maxHeight) {
    panel.style.maxHeight = null;
   } else {
     panel.style.maxHeight = panel.scrollHeight + "px";
   }
  });
 }

 function closePanels() {
  var panels = document.getElementsByClassName("mobile-accordian-panel");
  var j;

  for (j = 0; j < panels.length; j++){
   panels[j].style.maxHeight = null;
  }
 }

function toggleNewsButton() {
  var moreText = document.getElementById("more");
  var btnText = document.getElementById("myBtn");

  if (!moreText.style.display || moreText.style.display === "none") {
    btnText.innerHTML = "Read less";
    moreText.style.display = "block";
  } else {
    btnText.innerHTML = "Read more";
    moreText.style.display = "none";
  }
}

});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>     html, body{
  width: 100%;
  height: 100%;
  font-family: 'Roboto', sans-serif;
 }

 h1{
  font-size: 3em;
 }
 h2{
  font-size: 1.5em;
 }

 h3{
  font-size: 0.75em;
  font-weight:400;
  text-transform: uppercase;
 }

 .FullsizeImg{
  background-repeat: no-repeat;
  background-size: 30%;
  background-position: right;

 }
 #more {
   display: none;
 }

 #myBtn {
   color: black;
   background: #fff;
   border: 1px solid black;
   font-size: 17px;
   padding: 7px 12px;
   font-weight: normal;
   margin: 6px 0;
   margin-right: 12px;
 }

 .centerButton {
   text-align: center;
 }

 #myBtn:hover,
 #myBtn:active {
   background: black;
   color: white;
 }

 .allStories{
  margin-left:20px;
  margin-right:20px;
 }

 #hamburger{
  z-index: 11;
  display: block;
  visibility: visible;
  position: fixed;
  top: 10px;
  left: 10px;
  color: white;
  transition: all 0.25 ease;
 }

 #closeBtn{
  display:block;
  position:fixed;
  top:10px;
  left:10px;
 }

 #navMenu{
  z-index: 10;
  display: block;
  overflow:hidden;
  position: fixed;
  top: 0;
  left: 0;
  color: black;
  background-color: white;
  box-shadow: 0 0 8px rgba(33,33,33,.6);
  max-height: 0;
  width: 100%;
  -webkit-transition: 1s ease;
  -moz-transition: 1s ease;
  -o-transition: 1s ease;
  -ms-transition: 1s ease;
  transition: 1s ease;
  visibility: hidden;
 }

 .nav ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
 }

 .nav ul li {
  color: grey;
  font-size: 14px;
  font-weight: regular;
  font-family: inherit;
  padding: 5px 0px 5px 0px;
  cursor: pointer;
  transition: .5s ease;
  -webkit-transition: .5s ease;
  -moz-transition: .5s ease;
 }

 .nav li:hover {
  color: lightgrey;
  font-weight: bold;
  transition: .5s ease;
  -webkit-transition: .5s ease;
  -moz-transition: .5s ease;
 }

 .mainMargins{
  margin-left: 10%;
  margin-right: 10%;
 }

 .smallSpacer{
  height: 25px;
 }

 .bigSpacer{
  height: 100px;
 }

 .txtAlignRight{

 }

 .AlwaysFullScreen{
  width: 100%;
  height: 100%;
 }

 .fullScreen{
  width: 100%;
  height: 100%;
 }

 .withBGImg{
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
 }

 .jumbo-title{
  font-weight: bold;
  letter-spacing: 0.02em;
 }

 .jumbo-caption{
  font-weight: 300;
  font-size:
 }

 .jumbo-container{
  color: white;
 }

 .verticalCentreParent{
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  transform-style: preserve-3d;
 }

 .verticalCentreChild{
  position: relative;
  top: 50%;
  transform: translateY(-50%);
 }

 .content-verticalCentreParent{
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  transform-style: preserve-3d;
 }

 .content-verticalCentreChild{
  position: relative;
  top: 50%;
  transform: translateY(-50%);
 }

 .iconContainer{
  text-align: center;
 }
 .mediumIcons{
  height: 100px;
 }

 .scrollCard{
  box-shadow: 0 0 8px rgba(33,33,33,.2);
  width: 200px;
  height: 250px;
  border-radius: 10px;
  -webkit-transition: .3s ease;
  -moz-transition: .3s ease;
  -o-transition: .3s ease;
  -ms-transition: .3s ease;
  transition: .3s ease;
 }

 .scrollCard:hover{
  box-shadow: 0 0 11px rgba(33,33,33,.5);
 }

 .scrollCardBar {
  display: flex;
  min-width: 100%;
  min-height: 200px;
  overflow-x: auto;
  margin: 0;
 }

 .scrollCard {
  min-width: 300px;
  margin: 8px;
 }
 .scrollCardContainer{
  display: flex;
  margin-left: 10%;
  margin-right: 10%;
 }

 .scrollCardBar::-webkit-scrollbar {
  display: none;
 }

 .endOfScroll{
  width: 100px;
 }

 .line{
  margin-top: 10px;
  margin-bottom: 35px;
  background-color: white;
  height: 1px;
 }

 footer{
  height: auto;
  background-color: #5388EF;
  color: white;
   width: 100%;
   position: relative;
 }

 footer ul{
  font-weight: 300;
  list-style-type: none;

  margin-top: 20px;
  padding: 0;
 }

 footer li{
  padding: 10px 0px 5px 0px;
 }

 footer .row{
  margin: auto;
 }

 footer .footer-column{
  width: calc(100% / 6);
    height: auto;
    float: left;
    box-sizing: border-box;
   -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  padding: 0px 20px 20px 20px;
  margin-top: 20px;
 }

 @media only screen and (min-width: 2000px){
  .mainMargins{
   margin-left: 25%;
   margin-right: 25%;
  }
  .scrollCardContainer{
   margin-left: 25%;
   margin-right: 25%;
  }
 }

 @media only screen and (max-height: 1000px){
  .fullScreen{
   height: auto;
   width: auto;
  }

  .content-verticalCentreChild{
   position: relative;
   top: 100%;
   transform: none;
  }
 }

 @media only screen and (max-width: 1400px) {
  footer .footer-column{
   width: calc(100% / 3);
  }
 }

 @media only screen and (max-width: 600px) {
  h1{
   font-size: 2em;
  }

  h2{
   font-size: 1em;
  }

  #hamburger{
   top: 5px;
  left: px;
  }

  .mobile-accordian-panel{
  max-height: 0;
  overflow: hidden;
  -webkit-transition: .3s ease;
  -moz-transition: .3s ease;
  -o-transition: .3s ease;
  -ms-transition: .3s ease;
  transition: .3s ease;

  }

  .mainMargins{
   margin-left: 8%;
   margin-right: 8%;
  }

  .content-verticalCentreChild{
   position: relative;
   top: 100%;
   transform: none;
  }
  .scrollCardContainer{
   margin-left: 8%;
   margin-right: 8%;
  }
  .endOfScroll{
   width: 16px;
  }
  footer .footer-column{
   width: 100%
  }

 }</code>```

<!DOCTYPE html>

   <title></title>

<meta charset="utf-8" />

 <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

<link rel="stylesheet" href="/css/style.css">

<meta name="viewport" content="width=device-width, initial-scale=1" />

  <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,700&display=swap" rel="stylesheet">

   ☰

Title

About

Mission

Services

Social

Get in touch

Title

About

Mission

Title

About

Mission

Services

Social

Title

About

Mission

Services

Catchy Headline That Spans Multiple Lines

Headline Caption (Optional)

Title

This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking). This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking).

Title

This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking). This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking).

Title

This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking). This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking).

Title

This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking). This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking).

Title

This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking). This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking).

 Meet Our Reseachers

This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking).

        A groundbreaking blueprint for store-program computers. Though a complete version of the ACE was never built, its concept has been used as a model by tech corporations worldwide for several years

        He first addressed the issue of artificial intelligence in his 1950 paper, "Computing machinery and intelligence". If an AI can convice a human that is it human, it should be considered intelligent.

        The highest acheivable award in the field of computer science. Named after Alan Turing for his grand contributions and is equivalent to the Noble Prize.

 News

 Read the Storie’s of sTTARR’s reseachers and users.

Jan, 01, 2019

        Title of the news article will be diplayed under the photo.

Jan, 01, 2019

        Title of the news article will be diplayed under the photo.

Jan, 01, 2019

        Title of the news article will be diplayed under the photo.

 All Stories

Jan, 01, 2019

          Title of the news article will be diplayed under the photo.

Jan, 01, 2019

        Title of the news article will be diplayed under the photo.

Jan, 01, 2019

      Title of the news article will be diplayed under the photo.

Jan, 01, 2019

      Title of the news article will be diplayed under the photo.

Jan, 01, 2019

    Title of the news article will be diplayed under the photo.

Jan, 01, 2019

  Title of the news article will be diplayed under the photo.

 <button onclick="toggleNewsButton()" id="myBtn">Read more</button>

 Updates

 Here is a live twitter update.Here is a live twitter update.Here is a live twitter update.Here is a live twitter update.

        Tweets from UHN

Title

About

Mission

Services

Social

Get in touch

Title

About

Mission

Services

Social

Get in touch

Title

About

Mission

Services

Social

Get in touch

Title

About

Mission

Services

Social

Get in touch

Title

About

Mission

Services

Social

Get in touch

```

EXPECTED: button should show the information in the read more tag.

ACTUAL: button doesn't do anything when you click it.

答:
Replace <button onclick="myFunction()" id="myBtn">Read more</button> with <button onclick="toggleNewsButton()" id="myBtn">Read more</button>

You did put the wrong function

function toggleNewsButton() {
    var readmore = document.getElementById("readmore");
    var moreText = document.getElementById("more");
    var btnText = document.getElementById("myBtn");

      if (readmore.style.display === "none") {
      readmore.style.display = "inline";
      btnText.innerHTML = "Read more";
       moreText.style.display = "none";
        } else {
      readmore.style.display = "none";
       btnText.innerHTML = "Read less";
       moreText.style.display = "inline";
        }
      }```
<pre class="snippet-code-css lang-css prettyprint-override"><code>#more {display: none;}

    #myBtn{
 color:black;
 background:#fff;
 border: 1px solid black;
 font-size: 17px;
 padding: 7px 12px;
 font-weight: normal;
 margin: 6px 0;
 margin-right: 12px;

    }

     .centerButton{
  text-align: center;
     }

      #myBtn:hover, #myBtn:active {
  background:black;
  color:white;

    }</code>```

 All Stories

Jan, 01, 2019

            Title of the news article will be diplayed under the photo.

Jan, 01, 2019

          Title of the news article will be diplayed under the photo.

Jan, 01, 2019

        Title of the news article will be diplayed under the photo.

Jan, 01, 2019

            Title of the news article will be diplayed under the photo.

Jan, 01, 2019

          Title of the news article will be diplayed under the photo.

Jan, 01, 2019

        Title of the news article will be diplayed under the photo.

      <button onclick="toggleNewsButton()" id="myBtn">Read more</button>

```

Body:
I am trying create a read more read less button. My content that is hidden is in a span tag. I used some javascript to make this work. Currently, when I click on the button nothing happens. My goal is to create a news section that shows more news when you click on the button.

This was working for me before, I used the exact same code and just merged it with some other code and it stopped working.

     $(document).ready(function () {

 var windowHeight = window.innerHeight;

 var navOpen = false;
 var onCloseBtn = false;
 var onAccordian = false;

 $("#hamburger").mouseover(function(){
  if(!navOpen){
   openMenu();
  }
  onCloseBtn = true;
 });

 $("#hamburger").mouseout(function(){
  onCloseBtn = false;
 });

 $("#hamburger").click(function(){
  toggleNav();
  console.log("clickedHam");
 });

 $("#navMenu").mouseover(function(){
  if(!navOpen && !onCloseBtn){
   keepOpen();
  }
 });

 $("#activeSpace").mouseleave(function(){
   console.log("navMenu Mouseout");
   closeMenu();
 });

 function toggleNav(){
  if(navOpen){
   closeMenu();

  } else {
   openMenu();
  }
 }
 function keepOpen(){
  console.log("keepOpen");
  navOpen = true;
  $('#hamburger').html('×');
  $('#hamburger').css("color","black");
  $("#navMenu").css("visibility","visible");
  $("#navMenu").css("height","auto");
  $("#navMenu").css("max-height", windowHeight);
 }

 function openMenu(){
  console.log("open");
  navOpen = true;
  $('#hamburger').html('×');
  $('#hamburger').css("color","black");
  $("#navMenu").css("visibility","visible");
  $("#navMenu").css("max-height", "250px"); ///change this depending on the max
 }

 function closeMenu(){
  closePanels();
  navOpen = false;
  console.log("close")
  $('#hamburger').html('☰');
  $('#hamburger').css("color","white");
  $("#navMenu").css("max-height", "0");
  $("#navMenu").css("visibility","hidden");
 }

 $(document).on('scroll', function() {
  if($(this).scrollTop()>=$('#changeNavColor').position().top - 40 && !navOpen){
   $(hamburger).css("color","black");
  }
  if($(this).scrollTop()<$('#changeNavColor').position().top - 40 && !navOpen){
   $(hamburger).css("color","white");
  }
 });

 var acc = document.getElementsByClassName("mobile-accordian");
 var i;

 for (i = 0; i < acc.length; i++) {
  acc[i].addEventListener("click", function() {
   //this.classList.toggle("active");
   $("#navMenu").css("height","auto");
   $("#navMenu").css("max-height", windowHeight);

   var panel = this.nextElementSibling;
   if (panel.style.maxHeight) {
    panel.style.maxHeight = null;
   } else {
     panel.style.maxHeight = panel.scrollHeight + "px";
   }
  });
 }

 function closePanels() {
  var panels = document.getElementsByClassName("mobile-accordian-panel");
  var j;

  for (j = 0; j < panels.length; j++){
   panels[j].style.maxHeight = null;
  }
 }

function toggleNewsButton() {
  var moreText = document.getElementById("more");
  var btnText = document.getElementById("myBtn");

  if (!moreText.style.display || moreText.style.display === "none") {
    btnText.innerHTML = "Read less";
    moreText.style.display = "block";
  } else {
    btnText.innerHTML = "Read more";
    moreText.style.display = "none";
  }
}

});

     html, body{
  width: 100%;
  height: 100%;
  font-family: 'Roboto', sans-serif;
 }

 h1{
  font-size: 3em;
 }
 h2{
  font-size: 1.5em;
 }

 h3{
  font-size: 0.75em;
  font-weight:400;
  text-transform: uppercase;
 }

 .FullsizeImg{
  background-repeat: no-repeat;
  background-size: 30%;
  background-position: right;

 }
 #more {
   display: none;
 }

 #myBtn {
   color: black;
   background: #fff;
   border: 1px solid black;
   font-size: 17px;
   padding: 7px 12px;
   font-weight: normal;
   margin: 6px 0;
   margin-right: 12px;
 }

 .centerButton {
   text-align: center;
 }

 #myBtn:hover,
 #myBtn:active {
   background: black;
   color: white;
 }

 .allStories{
  margin-left:20px;
  margin-right:20px;
 }

 #hamburger{
  z-index: 11;
  display: block;
  visibility: visible;
  position: fixed;
  top: 10px;
  left: 10px;
  color: white;
  transition: all 0.25 ease;
 }

 #closeBtn{
  display:block;
  position:fixed;
  top:10px;
  left:10px;
 }

 #navMenu{
  z-index: 10;
  display: block;
  overflow:hidden;
  position: fixed;
  top: 0;
  left: 0;
  color: black;
  background-color: white;
  box-shadow: 0 0 8px rgba(33,33,33,.6);
  max-height: 0;
  width: 100%;
  -webkit-transition: 1s ease;
  -moz-transition: 1s ease;
  -o-transition: 1s ease;
  -ms-transition: 1s ease;
  transition: 1s ease;
  visibility: hidden;
 }

 .nav ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
 }

 .nav ul li {
  color: grey;
  font-size: 14px;
  font-weight: regular;
  font-family: inherit;
  padding: 5px 0px 5px 0px;
  cursor: pointer;
  transition: .5s ease;
  -webkit-transition: .5s ease;
  -moz-transition: .5s ease;
 }

 .nav li:hover {
  color: lightgrey;
  font-weight: bold;
  transition: .5s ease;
  -webkit-transition: .5s ease;
  -moz-transition: .5s ease;
 }

 .mainMargins{
  margin-left: 10%;
  margin-right: 10%;
 }

 .smallSpacer{
  height: 25px;
 }

 .bigSpacer{
  height: 100px;
 }

 .txtAlignRight{

 }

 .AlwaysFullScreen{
  width: 100%;
  height: 100%;
 }

 .fullScreen{
  width: 100%;
  height: 100%;
 }

 .withBGImg{
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
 }

 .jumbo-title{
  font-weight: bold;
  letter-spacing: 0.02em;
 }

 .jumbo-caption{
  font-weight: 300;
  font-size:
 }

 .jumbo-container{
  color: white;
 }

 .verticalCentreParent{
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  transform-style: preserve-3d;
 }

 .verticalCentreChild{
  position: relative;
  top: 50%;
  transform: translateY(-50%);
 }

 .content-verticalCentreParent{
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  transform-style: preserve-3d;
 }

 .content-verticalCentreChild{
  position: relative;
  top: 50%;
  transform: translateY(-50%);
 }

 .iconContainer{
  text-align: center;
 }
 .mediumIcons{
  height: 100px;
 }

 .scrollCard{
  box-shadow: 0 0 8px rgba(33,33,33,.2);
  width: 200px;
  height: 250px;
  border-radius: 10px;
  -webkit-transition: .3s ease;
  -moz-transition: .3s ease;
  -o-transition: .3s ease;
  -ms-transition: .3s ease;
  transition: .3s ease;
 }

 .scrollCard:hover{
  box-shadow: 0 0 11px rgba(33,33,33,.5);
 }

 .scrollCardBar {
  display: flex;
  min-width: 100%;
  min-height: 200px;
  overflow-x: auto;
  margin: 0;
 }

 .scrollCard {
  min-width: 300px;
  margin: 8px;
 }
 .scrollCardContainer{
  display: flex;
  margin-left: 10%;
  margin-right: 10%;
 }

 .scrollCardBar::-webkit-scrollbar {
  display: none;
 }

 .endOfScroll{
  width: 100px;
 }

 .line{
  margin-top: 10px;
  margin-bottom: 35px;
  background-color: white;
  height: 1px;
 }

 footer{
  height: auto;
  background-color: #5388EF;
  color: white;
   width: 100%;
   position: relative;
 }

 footer ul{
  font-weight: 300;
  list-style-type: none;

  margin-top: 20px;
  padding: 0;
 }

 footer li{
  padding: 10px 0px 5px 0px;
 }

 footer .row{
  margin: auto;
 }

 footer .footer-column{
  width: calc(100% / 6);
    height: auto;
    float: left;
    box-sizing: border-box;
   -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  padding: 0px 20px 20px 20px;
  margin-top: 20px;
 }

 @media only screen and (min-width: 2000px){
  .mainMargins{
   margin-left: 25%;
   margin-right: 25%;
  }
  .scrollCardContainer{
   margin-left: 25%;
   margin-right: 25%;
  }
 }

 @media only screen and (max-height: 1000px){
  .fullScreen{
   height: auto;
   width: auto;
  }

  .content-verticalCentreChild{
   position: relative;
   top: 100%;
   transform: none;
  }
 }

 @media only screen and (max-width: 1400px) {
  footer .footer-column{
   width: calc(100% / 3);
  }
 }

 @media only screen and (max-width: 600px) {
  h1{
   font-size: 2em;
  }

  h2{
   font-size: 1em;
  }

  #hamburger{
   top: 5px;
  left: px;
  }

  .mobile-accordian-panel{
  max-height: 0;
  overflow: hidden;
  -webkit-transition: .3s ease;
  -moz-transition: .3s ease;
  -o-transition: .3s ease;
  -ms-transition: .3s ease;
  transition: .3s ease;

  }

  .mainMargins{
   margin-left: 8%;
   margin-right: 8%;
  }

  .content-verticalCentreChild{
   position: relative;
   top: 100%;
   transform: none;
  }
  .scrollCardContainer{
   margin-left: 8%;
   margin-right: 8%;
  }
  .endOfScroll{
   width: 16px;
  }
  footer .footer-column{
   width: 100%
  }

 }

<!DOCTYPE html>

   <title></title>

<meta charset="utf-8" />

 <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

<link rel="stylesheet" href="/css/style.css">

<meta name="viewport" content="width=device-width, initial-scale=1" />

  <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,700&display=swap" rel="stylesheet">

   ☰

Title

About

Mission

Services

Social

Get in touch

Title

About

Mission

Title

About

Mission

Services

Social

Title

About

Mission

Services

Catchy Headline That Spans Multiple Lines

Headline Caption (Optional)

Title

This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking). This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking).

Title

This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking). This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking).

Title

This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking). This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking).

Title

This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking). This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking).

Title

This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking). This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking).

 Meet Our Reseachers

This is paragraph text. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document without relying on meaningful content (also called greeking).

        A groundbreaking blueprint for store-program computers. Though a complete version of the ACE was never built, its concept has been used as a model by tech corporations worldwide for several years

        He first addressed the issue of artificial intelligence in his 1950 paper, "Computing machinery and intelligence". If an AI can convice a human that is it human, it should be considered intelligent.

        The highest acheivable award in the field of computer science. Named after Alan Turing for his grand contributions and is equivalent to the Noble Prize.

 News

 Read the Storie’s of sTTARR’s reseachers and users.

Jan, 01, 2019

        Title of the news article will be diplayed under the photo.

Jan, 01, 2019

        Title of the news article will be diplayed under the photo.

Jan, 01, 2019

        Title of the news article will be diplayed under the photo.

 All Stories

Jan, 01, 2019

          Title of the news article will be diplayed under the photo.

Jan, 01, 2019

        Title of the news article will be diplayed under the photo.

Jan, 01, 2019

      Title of the news article will be diplayed under the photo.

Jan, 01, 2019

      Title of the news article will be diplayed under the photo.

Jan, 01, 2019

    Title of the news article will be diplayed under the photo.

Jan, 01, 2019

  Title of the news article will be diplayed under the photo.

 <button onclick="toggleNewsButton()" id="myBtn">Read more</button>

 Updates

 Here is a live twitter update.Here is a live twitter update.Here is a live twitter update.Here is a live twitter update.

        Tweets from UHN

Title

About

Mission

Services

Social

Get in touch

Title

About

Mission

Services

Social

Get in touch

Title

About

Mission

Services

Social

Get in touch

Title

About

Mission

Services

Social

Get in touch

Title

About

Mission

Services

Social

Get in touch

EXPECTED: button should show the information in the read more tag.

ACTUAL: button doesn't do anything when you click it.

Body:
Replace <button onclick="myFunction()" id="myBtn">Read more</button> with <button onclick="toggleNewsButton()" id="myBtn">Read more</button>

You did put the wrong function

function toggleNewsButton() {
    var readmore = document.getElementById("readmore");
    var moreText = document.getElementById("more");
    var btnText = document.getElementById("myBtn");

      if (readmore.style.display === "none") {
      readmore.style.display = "inline";
      btnText.innerHTML = "Read more";
       moreText.style.display = "none";
        } else {
      readmore.style.display = "none";
       btnText.innerHTML = "Read less";
       moreText.style.display = "inline";
        }
      }

#more {display: none;}

    #myBtn{
 color:black;
 background:#fff;
 border: 1px solid black;
 font-size: 17px;
 padding: 7px 12px;
 font-weight: normal;
 margin: 6px 0;
 margin-right: 12px;

    }

     .centerButton{
  text-align: center;
     }

      #myBtn:hover, #myBtn:active {
  background:black;
  color:white;

    }

<section id="#" class="">

    <div class="allStories">
        <hr>
        <h2 style = "text-align:center;" > All Stories</h2>
        <hr>
        <div class="smallSpacer"></div>

        <div class="row">
          <div class ="col-sm-6" style = "text-align:left;">
            <p class="#"  style = "color:lightgray;">Jan, 01, 2019 </p>
            <small>Title of the news article will be diplayed under the photo. </small>
          </div>
          <div class ="col-sm-6" style = "text-align: right;">
           <img src = "/images/news1.jpg" style = "height:200px; width:300px;">
         </div>
       </div>

       <hr>

       <div class="row">
        <div class ="col-sm-6" style = "text-align:left;">
          <p class="#"  style = "color:lightgray;  ">Jan, 01, 2019 </p>
          <small>Title of the news article will be diplayed under the photo. </small>
        </div>
        <div class ="col-sm-6" style = "text-align: right;">
         <img src = "/images/news2.jpg" style = "height:200px; width:300px; ">
       </div>
     </div>

       <hr>

       <div class="row">
      <div class ="col-sm-6" style = "text-align:left;">
        <p class="#"  style = "color:lightgray;  ">Jan, 01, 2019 </p>
        <small>Title of the news article will be diplayed under the photo. </small>
      </div>
      <div class ="col-sm-6" style = "text-align: right;">
       <img src = "/images/news3.jpg" style = "height:200px; width:300px; ">
       </div>
       </div>

      <hr>

      <span id="readmore"></span>

         <span id="more">

          <div class="row">
          <div class ="col-sm-6" style = "text-align:left;">
            <p class="#"  style = "color:lightgray;">Jan, 01, 2019 </p>
            <small>Title of the news article will be diplayed under the photo. </small>
          </div>
          <div class ="col-sm-6" style = "text-align: right;">
           <img src = "/images/news1.jpg" style = "height:200px; width:300px;">
         </div>
       </div>

       <hr>

       <div class="row">
        <div class ="col-sm-6" style = "text-align:left;">
          <p class="#"  style = "color:lightgray;  ">Jan, 01, 2019 </p>
          <small>Title of the news article will be diplayed under the photo. </small>
        </div>
        <div class ="col-sm-6" style = "text-align: right;">
         <img src = "/images/news2.jpg" style = "height:200px; width:300px; ">
       </div>
     </div>

     <hr>

     <div class="row">
      <div class ="col-sm-6" style = "text-align:left;">
        <p class="#"  style = "color:lightgray;  ">Jan, 01, 2019 </p>
        <small>Title of the news article will be diplayed under the photo. </small>
      </div>
      <div class ="col-sm-6" style = "text-align: right;">
       <img src = "/images/news3.jpg" style = "height:200px; width:300px; ">

       </div>
       </div>
       </span>

       </div>
      </div>

      <div class="centerButton">
      <button onclick="toggleNewsButton()" id="myBtn">Read more</button>
      </div>

      </section>


来源: stackexchange

问:
How to apply div inserted into another div to all elements with same class name
I want to insert or wrap my second div into another new div container but it was not applying through all same class name. Please check and give my idea what is missing.

```<code><div class="section" id="section1">
  <div id="myDIV"> --> I want to wrap this into a new div
   asdasd
  </div>
</div>

<div class="section" id="section1">
 <div id="myDIV">
  cbcvbcvb
 </div>
</div>

<script>
//org_html = document.getElementById("section1").innerHTML;
//new_html = "<div class='mydiv-container'>" + org_html + "</div>";
//document.getElementById("section1").innerHTML = new_html;

const parentObject = document.getElementById('section1').innerHTML;

[...parentObject].forEach((parent, i) => {
  //const childElement = document.createElement('div');
  const childElement = "<div class='slidesInner'>" + parentObject + </div>";
  document.getElementById("section1").innerHTML = childElement;

});
</script>
</code>```

Result should be like this:

```<code> <div class="section" id="section1">
  <div class="mydiv-container">
   <div id="myDIV">
    cbcvbcvb
   </div>
  </div>
</div>

<div class="section" id="section1">
 <div class="mydiv-container"> <-- this is not showing in the second section
  <div id="myDIV">
   cbcvbcvb
  </div>
 </div>
</div>
</code>```

答:
First there is a typo here "
" + parentObject +
"; . You can see closing
" has no opening quote ".

Secondly you need not to iterate over the content of innerHTML. Since innerHTML will give the content like
asdasd
. You can get this using querySelectorAll and use template literals to create a new wrapper div and set the innerHTML

const parentObject = document.querySelectorAll('.section');
parentObject.forEach(function(item, index) {
  item.innerHTML = `<div class='slidesInner' id='subSection_${index}'>${item.innerHTML}</div>`;
})```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.slidesInner {
  color: green;
}</code>```

    asdasd

    cbcvbcvb

```

ContentLicense: CC BY-SA 4.0

Body:
I want to insert or wrap my second div into another new div container but it was not applying through all same class name. Please check and give my idea what is missing.

 --> I want to wrap this into a new div
   asdasd

  cbcvbcvb

Result should be like this:

    cbcvbcvb

 <-- this is not showing in the second section

   cbcvbcvb

Body:
First there is a typo here "<div class='slidesInner'>" + parentObject + </div>"; . You can see closing </div>" has no opening quote ".

Secondly you need not to iterate over the content of innerHTML. Since innerHTML will give the content like <div id="myDIV">asdasd</div>. You can get this using querySelectorAll and use template literals to create a new wrapper div and set the innerHTML

const parentObject = document.querySelectorAll('.section');
parentObject.forEach(function(item, index) {
  item.innerHTML = `<div class='slidesInner' id='subSection_${index}'>${item.innerHTML}</div>`;
})

.slidesInner {
  color: green;
}

<div class="section" id="section1">
  <div id="myDIV">
    asdasd
  </div>
</div>

<div class="section" id="section2">
  <div id="myDIV2">
    cbcvbcvb
  </div>
</div>


问:
Describe me how in this code works Symbol.iterator
I am currently reading Eloquent Javascript.And I can not understand this part.

I do not understand Symbol.iterator part.Can  you explain me how it works.Thanks

```<code>class MatrixIterator {
  constructor(matrix) {
    this.x = 0;
    this.y = 0;
    this.matrix = matrix;
  }
  next() {
    if (this.y == this.matrix.height) return {
      done: true
    };
    let value = {
      x: this.x,
      y: this.y,
      value: this.matrix.get(this.x, this.y)
    };
    this.x++;
    if (this.x == this.matrix.width) {
      this.x = 0;
      this.y++;
    }
    return {
      value,
      done: false
    };
  }
}

Matrix.prototype[Symbol.iterator] = function() {
  return new MatrixIterator(this);
};
</code>```

答:
Symbol.iterator is a well-known symbol (which just means it's defined in the spec and available as a property of Symbol) that's the key for the method that JavaScript looks for when it needs to get an iterator from an object. Iterators are used by for-of, ... (on arrays), and such to loop through the contents of an object.

For instance, in this code:

const a = [1, 2, 3];
for (const value of a) {
    console.log(value);
}```
</div>
</div>
</p>

<p>the JavaScript engine calls the <code>[Symbol.iterator]</code> method on <code>a</code> to get the iterator to use for the <code>for-of</code> loop.</p>

<p>Here's that same example (roughly) using the iterator directly rather than letting <code>for-of</code> handle it for us:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const a = [1, 2, 3];
// Get the iterator
const it = a[Symbol.iterator]();
// Get the first result object from it
let result = it.next();
// While the result object doesn't have done = true...
while (!result.done) {
    // Get and show this iteration's value
    const value = result.value;
    console.log(value);

    // Get the next result
    result = it.next();
}</code>```

The great thing about iterators, and having a common defined way to get the iterator for an object, is that it makes things like for-of possible regardless of what the object is that's being iterated. Strings are iterable, for instance (you get one character at a time). Maps are iterable (each value you get is a [key, value] array). Etc. The object defines both how it's iterated and what values it provides during iteration. You could write a simple linked list class and make it iterable, and code using it wouldn't care that it was a linked list instead of an array or whatever.

With that context, this code:

```<code>Matrix.prototype[Symbol.iterator] = function() {
  return new MatrixIterator(this);
};
</code>```

creates that method on the prototype that will be assigned to objects created via new Matrix so that calling it returns a new MatrixIterator for the matrix instance it was called on.

More on MDN

Body:
I am currently reading Eloquent Javascript.And I can not understand this part.

I do not understand Symbol.iterator part.Can  you explain me how it works.Thanks

class MatrixIterator {
  constructor(matrix) {
    this.x = 0;
    this.y = 0;
    this.matrix = matrix;
  }
  next() {
    if (this.y == this.matrix.height) return {
      done: true
    };
    let value = {
      x: this.x,
      y: this.y,
      value: this.matrix.get(this.x, this.y)
    };
    this.x++;
    if (this.x == this.matrix.width) {
      this.x = 0;
      this.y++;
    }
    return {
      value,
      done: false
    };
  }
}

Matrix.prototype[Symbol.iterator] = function() {
  return new MatrixIterator(this);
};

Body:
Symbol.iterator is a well-known symbol (which just means it's defined in the spec and available as a property of Symbol) that's the key for the method that JavaScript looks for when it needs to get an iterator from an object. Iterators are used by for-of, ... (on arrays), and such to loop through the contents of an object.

For instance, in this code:

const a = [1, 2, 3];
for (const value of a) {
    console.log(value);
}

the JavaScript engine calls the [Symbol.iterator] method on a to get the iterator to use for the for-of loop.

Here's that same example (roughly) using the iterator directly rather than letting for-of handle it for us:

const a = [1, 2, 3];
// Get the iterator
const it = a[Symbol.iterator]();
// Get the first result object from it
let result = it.next();
// While the result object doesn't have done = true...
while (!result.done) {
    // Get and show this iteration's value
    const value = result.value;
    console.log(value);

    // Get the next result
    result = it.next();
}

The great thing about iterators, and having a common defined way to get the iterator for an object, is that it makes things like for-of possible regardless of what the object is that's being iterated. Strings are iterable, for instance (you get one character at a time). Maps are iterable (each value you get is a [key, value] array). Etc. The object defines both how it's iterated and what values it provides during iteration. You could write a simple linked list class and make it iterable, and code using it wouldn't care that it was a linked list instead of an array or whatever.

With that context, this code:

Matrix.prototype[Symbol.iterator] = function() {
  return new MatrixIterator(this);
};

creates that method on the prototype that will be assigned to objects created via new Matrix so that calling it returns a new MatrixIterator for the matrix instance it was called on.

More on MDN


问:
Can a sequential always block be triggered by a short pulse from a combi block
Could a sequential always block be triggered by a short lived pulse coming from a combi block ?

I have tried to trigger the always block, by assigning a value and set the value back to 0 in an attempt to trigger the sequential always block but to no avail, below is the pseudo code

```<code>
always_comb begin
 ...some code...
pulse_trigger = 1;
load_var= driver_var // assigning some values
pulse_trigger = 0;
 ...some code...
end

always @(pulse_trigger)begin
 ...some code part 2...
end

</code>```

I expect by assigning 1 to pulse_trigger the "always@(pulse_trigger)" block to get activated, but in my VCS simulation this does not seem to be the case.

Maybe this is because the pulse trigger is assigned 1 and unassigned 1 in the same combi block, which takes 0 simulation time, so pulse_trigger might not appear to have changed values. Or this method should've triggered "always@(pulse_trigger)" and executed "...some code part 2..", because I am looking at the wrong values ?

答:
In verilog simulation only a single always block can be evaluated at a time. So, until your always_comb finishes, no other always block can be evaluated. Therefore, no pulse_trigger change will be detected by simulation (because all changes happen inside  a single always block.

You can do something like that by adding delays (assuming this is not a synthesizable code):

```<code>always @* begin
  pulse_trigger = 1;
  load_var= driver_var // assigning some values
  #1 // << this will stop execution of the block for 1 time unit and allow others.
  pulse_trigger = 0;
end
</code>```

However, the above code is not synthesizable but it can be a part of a test bench.
Also, it is not allowed within always_comb.

Body:
Could a sequential always block be triggered by a short lived pulse coming from a combi block ?

I have tried to trigger the always block, by assigning a value and set the value back to 0 in an attempt to trigger the sequential always block but to no avail, below is the pseudo code

always_comb begin
 ...some code...
pulse_trigger = 1;
load_var= driver_var // assigning some values
pulse_trigger = 0;
 ...some code...
end

always @(pulse_trigger)begin
 ...some code part 2...
end

I expect by assigning 1 to pulse_trigger the "always@(pulse_trigger)" block to get activated, but in my VCS simulation this does not seem to be the case.

Maybe this is because the pulse trigger is assigned 1 and unassigned 1 in the same combi block, which takes 0 simulation time, so pulse_trigger might not appear to have changed values. Or this method should've triggered "always@(pulse_trigger)" and executed "...some code part 2..", because I am looking at the wrong values ?

Body:
In verilog simulation only a single always block can be evaluated at a time. So, until your always_comb finishes, no other always block can be evaluated. Therefore, no pulse_trigger change will be detected by simulation (because all changes happen inside  a single always block.

You can do something like that by adding delays (assuming this is not a synthesizable code):

always @* begin
  pulse_trigger = 1;
  load_var= driver_var // assigning some values
  #1 // << this will stop execution of the block for 1 time unit and allow others.
  pulse_trigger = 0;
end

However, the above code is not synthesizable but it can be a part of a test bench.
Also, it is not allowed within always_comb.


问:
CMS to manage Mobile website and main website
Can someone shed some light onto the area of content management for a website that has a mobile version as well as a main version.

How do you manage these? Do you create 2 versions of the site or do you use conditional selection if the site is mobile, then show XYZ?

Lloyds has the following, mobile and main websites:

As you can see not all of the assets are included on the mobile versiuon.

mobile:

Main website:

答: You need a CMS that can function as a mobile CMS so that you can control your content on your website and on mobile. ButterCMS is a headless CMS that can achieve this and here is a blog post about how you can create your own mobile CMS solution using ButterCMS and Flutter by Google. </p>

ContentLicense: CC BY-SA 3.0


问:
How to create a new clock trigger on another document
I have 30+ users each with their own spreadsheet.  Each user's bound script references a custom library script that I use to keep my code centralized and easy to update.

I'm trying to use apps script to create triggers that run a specific function at a specific time.  However, I can't figure out how to specify which script document the clock trigger is installed on.

Here's what I tried first:

```<code>createTimeTrigger("sendTimesheetsToHeads",1440);

function createTimeTrigger(functionToRun,minutesToWait) {
  ScriptApp.newTrigger(functionToRun)
  .timeBased()
  .at(new Date(new Date().getTime()+minutesToWait*60*1000))
  .create();
}
</code>```

The above code is in the library file, but since the user is running the code, it installs the trigger on the user's container-bound script file, and not the library file.  When the trigger runs, it fails because the trigger uses a function in the library that the user doesn't have direct reference to.

I need to be able to install the trigger programmatically on the independent library script file just like I can do manually. So after reviewing the apps script documentation (https://developers.google.com/apps-script/reference/script/trigger-builder#forDocument(String)), I found the forDocument() function for the trigger builder and tried this:

```<code>createTimeTrigger("sendTimesheetsToHeads",1440);

function createTimeTrigger(functionToRun,minutesToWait) {
  ScriptApp.newTrigger(functionToRun)
  .forDocument(<library script id here>)
  .timeBased()
  .at(new Date(new Date().getTime()+minutesToWait*60*1000))
  .create();
}
</code>```

But the above code produces the following error: "TypeError: Cannot find function timeBased in object DocumentTriggerBuilder."

So then I tried switching the order around:

```<code>function createTimeTrigger(functionToRun,minutesToWait) {
  ScriptApp.newTrigger(functionToRun)
  .timeBased()
  .at(new Date(new Date().getTime()+minutesToWait*60*1000))
  .forDocument(<library script id here>)
  .create();
}
</code>```

And received this error: "TypeError: Cannot find function forDocument in object ClockTriggerBuilder."  It looks like the forDocument() and timeBased() functions are incompatible in the trigger builder?

Is it possible to do what I'm asking with apps script?

答:
Please, take a look at the TriggerBuilder reference again - your function createTimeTrigger() should create two triggers, one with timeBased() and the other with forDocument(). Both methods, when invoked, return different class instances - ClockTriggerBuilder and DocumentTriggerBuilder respectively (so, the answer to your first question is - yes, they are incompatible.

Wrapper function

First approach assumes you have access to user document's apps script project or can otherwise add the wrapperInDoc() function to the document (this solution is retained in case someone needs it):

the user to run your library script yourLib.createTimeTrigger();

the time-based trigger to be installed on user document;

the time-based trigger to fire a function in library;

Your library function should create a trigger to run wrapper function with a name common for all user documents that references target function in your library. Like so:

Library-scoped sample

```<code>function createTimeTrigger(functionToRun,minutesToWait) {
  ScriptApp.newTrigger('wrapperInDoc').timeBased().at(yourCond).create();
}

function wrapperInLib() {
  sendTimesheetsToHeads(); //function calls go here;
}
</code>```

Document-scoped sample

```<code>function wrapperInDoc() {
  yourLib.wrapperInLib();
}
</code>```

Self-calling library

As clarified in comments, you want:

the user to run your library script yourLib.createTimeTrigger();

createTimeTrigger() to install the time-based trigger on yourLib;

the time-based trigger to fire a function in library;

Container-bound sample

```<code>function testLib() {
 var r = PG.createTimeTrigger(); //PG is how I named lib in my project;
 //do anything else;
}
</code>```

Library sample

I set an arbitrary offset of 1 minute from "now" to trigger, just create your trigger as needed. Also, make sure that your script is published as a WebApp and anyone, even anonymous access is set on it (which should be ok as you use it as a library). You should use deployment Url for the fetch (the one with /exec).

```<code>/**
 * Runs on a get request;
 * @param {Object} e event object;
 * @returns {Content} text output to conform to being a web app;
 */
function doGet(e) {
  createTrigger();
  return ContentService.createTextOutput('success!');
}

/**
 * Self-run library project;
 */
function createTimeTrigger() {
  UrlFetchApp.fetch('yourLibraryUrl');
}

/**
 * Create trigger on self;
 */
function createTrigger() {
  var tr = ScriptApp.newTrigger('doSomething');
      tr.timeBased().at(new Date(new Date().valueOf()+60000)).create();
}

/**
 * Actual trigger callback;
 */
function doSomething() {
  //do something;
}
</code>```

Body:
I have 30+ users each with their own spreadsheet.  Each user's bound script references a custom library script that I use to keep my code centralized and easy to update.

I'm trying to use apps script to create triggers that run a specific function at a specific time.  However, I can't figure out how to specify which script document the clock trigger is installed on.

Here's what I tried first:

createTimeTrigger("sendTimesheetsToHeads",1440);

function createTimeTrigger(functionToRun,minutesToWait) {
  ScriptApp.newTrigger(functionToRun)
  .timeBased()
  .at(new Date(new Date().getTime()+minutesToWait*60*1000))
  .create();
}

The above code is in the library file, but since the user is running the code, it installs the trigger on the user's container-bound script file, and not the library file.  When the trigger runs, it fails because the trigger uses a function in the library that the user doesn't have direct reference to.

I need to be able to install the trigger programmatically on the independent library script file just like I can do manually. So after reviewing the apps script documentation (https://developers.google.com/apps-script/reference/script/trigger-builder#forDocument(String)), I found the forDocument() function for the trigger builder and tried this:

createTimeTrigger("sendTimesheetsToHeads",1440);

function createTimeTrigger(functionToRun,minutesToWait) {
  ScriptApp.newTrigger(functionToRun)
  .forDocument(<library script id here>)
  .timeBased()
  .at(new Date(new Date().getTime()+minutesToWait*60*1000))
  .create();
}

But the above code produces the following error: "TypeError: Cannot find function timeBased in object DocumentTriggerBuilder."

So then I tried switching the order around:

function createTimeTrigger(functionToRun,minutesToWait) {
  ScriptApp.newTrigger(functionToRun)
  .timeBased()
  .at(new Date(new Date().getTime()+minutesToWait*60*1000))
  .forDocument(<library script id here>)
  .create();
}

And received this error: "TypeError: Cannot find function forDocument in object ClockTriggerBuilder."  It looks like the forDocument() and timeBased() functions are incompatible in the trigger builder?

Is it possible to do what I'm asking with apps script?

Body:
Please, take a look at the TriggerBuilder reference again - your function createTimeTrigger() should create two triggers, one with timeBased() and the other with forDocument(). Both methods, when invoked, return different class instances - ClockTriggerBuilder and DocumentTriggerBuilder respectively (so, the answer to your first question is - yes, they are incompatible.

Wrapper function

First approach assumes you have access to user document's apps script project or can otherwise add the wrapperInDoc() function to the document (this solution is retained in case someone needs it):

the user to run your library script yourLib.createTimeTrigger();

the time-based trigger to be installed on user document;

the time-based trigger to fire a function in library;

Your library function should create a trigger to run wrapper function with a name common for all user documents that references target function in your library. Like so:

Library-scoped sample

function createTimeTrigger(functionToRun,minutesToWait) {
  ScriptApp.newTrigger('wrapperInDoc').timeBased().at(yourCond).create();
}

function wrapperInLib() {
  sendTimesheetsToHeads(); //function calls go here;
}

Document-scoped sample

function wrapperInDoc() {
  yourLib.wrapperInLib();
}

Self-calling library

As clarified in comments, you want:

the user to run your library script yourLib.createTimeTrigger();

createTimeTrigger() to install the time-based trigger on yourLib;

the time-based trigger to fire a function in library;

Container-bound sample

function testLib() {
 var r = PG.createTimeTrigger(); //PG is how I named lib in my project;
 //do anything else;
}

Library sample

I set an arbitrary offset of 1 minute from "now" to trigger, just create your trigger as needed. Also, make sure that your script is published as a WebApp and anyone, even anonymous access is set on it (which should be ok as you use it as a library). You should use deployment Url for the fetch (the one with /exec).

/**
 * Runs on a get request;
 * @param {Object} e event object;
 * @returns {Content} text output to conform to being a web app;
 */
function doGet(e) {
  createTrigger();
  return ContentService.createTextOutput('success!');
}

/**
 * Self-run library project;
 */
function createTimeTrigger() {
  UrlFetchApp.fetch('yourLibraryUrl');
}

/**
 * Create trigger on self;
 */
function createTrigger() {
  var tr = ScriptApp.newTrigger('doSomething');
      tr.timeBased().at(new Date(new Date().valueOf()+60000)).create();
}

/**
 * Actual trigger callback;
 */
function doSomething() {
  //do something;
}


问:
Apple Pay is not available in "APP"
Thanks in advance

I am using Apple Pay in my application, i registered new merchant id in Apple and certificate from payment gateway.

By using this merchant id, payment summery sheet is opening but when i select pay getting error message as below

Apple Pay is not available in "APP" - check the settings in this app and make sure it was designed to use Apple Pay.

What could be the problem, and how much time it will take to activate the merchant id with Apple & payment gateway.

答:
You need to create a certificate and assign to your app.

Follow the step Create a payment processing certificate:

https://help.apple.com/developer-account/#/devb2e62b839

Title: Apple Pay is not available in "APP"


问:
Cant onClick event do
 tag React
I have a sideBar that opens when I click on a button and i have
 items there.

I want do add an onCLick event to those items but, onClick event fires when page is loaded and when ever I click on  elements.

Any information is helpful, thank you.

```<code>const Sidedraw = props => {
  let drawClass = "sideDraw";
  if (props.show) {
    drawClass = "sideDraw open";
  }
  return (
    <nav className={drawClass}>
      <ul>
        <li className="matches" onclick={console.log("work work")}>
          Pro matches
        </li>
        <li className="matches">Public mathes</li>
        <li className="matches">Players</li>
        <li className="matches">Teams</li>
      </ul>
    </nav>
  );
};
</code>```

答:
You’re setting the onClick to the result of the console.log call, not the function itself. You want:

```<code>onClick={() => console.log("work work")}
</code>```

Title: Cant onClick event do <li> tag React

Body:
I have a sideBar that opens when I click on a button and i have
 items there.

I want do add an onCLick event to those items but, onClick event fires when page is loaded and when ever I click on  elements.

Any information is helpful, thank you.

const Sidedraw = props => {
  let drawClass = "sideDraw";
  if (props.show) {
    drawClass = "sideDraw open";
  }
  return (

          Pro matches

Public mathes

Players

Teams

  );
};

Body:
You’re setting the onClick to the result of the console.log call, not the function itself. You want:

onClick={() => console.log("work work")}


问:
How to copy file to folders and edit variable in file based on folder name
I have an .xml file that needs to be copied into every subfolder of a folder. There is a variable within that file that needs to be changed to reflect the name of the folder (without the path).

The code I have generates new folders within a selected master folder. It does this by getting the name of  files (ex .jpgs) within that folder, and creating new folders with the same name and putting each .jpg in its respective folder. I then now need it to edit a variable within the xml, which I have set up as "vID", and then copy it to each file.

```<code>tell application "Finder"

    set selected to selection
    set current_folder to item 1 of selected
    set mlist to every file of current_folder
    set theFile to choose file (* XML file with variable *)
    set MyFolder to current_folder

    repeat with this_file in mlist
        set cur_ext to name extension of this_file
        set new_name to text 1 thru -((length of cur_ext) + 2) of (name of this_file as text)

        set stringToFind to "vID"
        set stringToReplace to new_name
        set theContent to read theFile as «class utf8»
        set {oldTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, stringToFind}
        set ti to every text item of theContent
        set AppleScript's text item delimiters to stringToReplace
        set newContent to ti as string
        set AppleScript's text item delimiters to oldTID
        try
            set fd to open for access theFile with write permission
            set eof of fd to 0
            write newContent to fd as «class utf8»
            close access fd
        on error
            close access theFile
        end try

        set new_folder to make new folder with properties {name:new_name} at current_folder

        move this_file to new_folder

        duplicate MyFile to new_folder

    end repeat

end tell
</code>```

Currently, the code correctly generates the folders, moves the .jpgs into their folders, edits the xml and duplicates it into each folder. The issue is that the variable is not reflective of each folder. It is just changed to the name of the last folder. Please let me know if you need further clarification.

答:
Your XML file is not getting updated because you overwrote the template, which replaced the placeholder string.  You can either make a copy of the template and then edit the copy, or just write the new XML contents directly:</p>

```<code>global base_template -- this will be the master template to copy
set base_template to (choose file with prompt "Choose the template file:" of type "com.apple.property-list") -- XML file with placeholder text to replace

tell application "Finder"
  set current_folder to item 1 of (get selection)
  repeat with this_file in (get files of current_folder)
    set {file_name, file_extension} to my getNamePieces(this_file)
    set new_folder to make new folder with properties {name:file_name} at current_folder
    move this_file to new_folder
    set new_template to (new_folder as text) & (name of base_template)
    my copyTemplate(file_name, new_template)
  end repeat
end tell

to copyTemplate(name_text, new_template) -- write edited copy of template
  set placeholder_text to "vID"
  set base_content to read base_template as «class utf8»
  set {temp_TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, placeholder_text}
  set {item_list, AppleScript's text item delimiters} to {text items of base_content, name_text}
  set {new_content, AppleScript's text item delimiters} to {item_list as text, temp_TID}
  try
    set fd to (open for access file new_template with write permission)
    write new_content to fd as «class utf8»
    close access fd
  on error errmess -- oops, make sure file gets closed
    log errmess
    close access fd
  end try
end copyTemplate

to getNamePieces(file_item) -- get base file name and extension
  tell application "System Events" to tell disk item (file_item as text) to set {_name, _extension} to {name, name extension}
  if _extension is not "" then
    set _name to text 1 thru -((count _extension) + 2) of _name
    set _extension to "." & _extension
  end if
  return {_name, _extension}
end getNamePieces
</code>```

Body:
I have an .xml file that needs to be copied into every subfolder of a folder. There is a variable within that file that needs to be changed to reflect the name of the folder (without the path).

The code I have generates new folders within a selected master folder. It does this by getting the name of  files (ex .jpgs) within that folder, and creating new folders with the same name and putting each .jpg in its respective folder. I then now need it to edit a variable within the xml, which I have set up as "vID", and then copy it to each file.

tell application "Finder"

    set selected to selection
    set current_folder to item 1 of selected
    set mlist to every file of current_folder
    set theFile to choose file (* XML file with variable *)
    set MyFolder to current_folder

    repeat with this_file in mlist
        set cur_ext to name extension of this_file
        set new_name to text 1 thru -((length of cur_ext) + 2) of (name of this_file as text)

        set stringToFind to "vID"
        set stringToReplace to new_name
        set theContent to read theFile as «class utf8»
        set {oldTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, stringToFind}
        set ti to every text item of theContent
        set AppleScript's text item delimiters to stringToReplace
        set newContent to ti as string
        set AppleScript's text item delimiters to oldTID
        try
            set fd to open for access theFile with write permission
            set eof of fd to 0
            write newContent to fd as «class utf8»
            close access fd
        on error
            close access theFile
        end try

        set new_folder to make new folder with properties {name:new_name} at current_folder

        move this_file to new_folder

        duplicate MyFile to new_folder

    end repeat

end tell

Currently, the code correctly generates the folders, moves the .jpgs into their folders, edits the xml and duplicates it into each folder. The issue is that the variable is not reflective of each folder. It is just changed to the name of the last folder. Please let me know if you need further clarification.

Body:
Your XML file is not getting updated because you overwrote the template, which replaced the placeholder string.  You can either make a copy of the template and then edit the copy, or just write the new XML contents directly:

global base_template -- this will be the master template to copy
set base_template to (choose file with prompt "Choose the template file:" of type "com.apple.property-list") -- XML file with placeholder text to replace

tell application "Finder"
  set current_folder to item 1 of (get selection)
  repeat with this_file in (get files of current_folder)
    set {file_name, file_extension} to my getNamePieces(this_file)
    set new_folder to make new folder with properties {name:file_name} at current_folder
    move this_file to new_folder
    set new_template to (new_folder as text) & (name of base_template)
    my copyTemplate(file_name, new_template)
  end repeat
end tell

to copyTemplate(name_text, new_template) -- write edited copy of template
  set placeholder_text to "vID"
  set base_content to read base_template as «class utf8»
  set {temp_TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, placeholder_text}
  set {item_list, AppleScript's text item delimiters} to {text items of base_content, name_text}
  set {new_content, AppleScript's text item delimiters} to {item_list as text, temp_TID}
  try
    set fd to (open for access file new_template with write permission)
    write new_content to fd as «class utf8»
    close access fd
  on error errmess -- oops, make sure file gets closed
    log errmess
    close access fd
  end try
end copyTemplate

to getNamePieces(file_item) -- get base file name and extension
  tell application "System Events" to tell disk item (file_item as text) to set {_name, _extension} to {name, name extension}
  if _extension is not "" then
    set _name to text 1 thru -((count _extension) + 2) of _name
    set _extension to "." & _extension
  end if
  return {_name, _extension}
end getNamePieces


问:
Understanding max_features parameter in RandomForestRegressor
While constructing each tree in the random forest using bootstrapped samples, for each terminal node, we select m variables at random from p variables to find the best split (p is the total number of features in your data). My questions (for RandomForestRegressor) are:

1) What does max_features correspond to (m or p or something else)?

2) Are m variables selected at random from max_features variables (what is the value of m)?

3) If max_features corresponds to m, then why would I want to set it equal to p for regression (the default)? Where is the randomness with this setting (i.e., how is it different from bagging)?

Thanks.

答: @lynnyi, max_features is the number of features that are considered on a per-split level, rather than on the entire decision tree construction. More clear, during the construction of each decision tree, RF will still use all the features (n_features), but it only consider number of "max_features" features for node splitting. And the "max_features" features are randomly selected from the entire features. You could confirm this by plotting one decision tree from a RF with max_features=1, and check all the nodes of that tree to count the number of features involved.</p>


问:
hive + too many connection to PostgreSQL DB
We have ambari cluster with Hadoop version – 2.6.4

When we run query in order to verify connections in PostgreSQL DB , we found many hive connection – in our case around 90

This cause other application problems

So we suspect that hiveserver2 is not cleaning up connections like it should and files are not being released.

Any suggestion why hive is with a lot connection? to postgresql ? ,
And what is the solution for that?

One option that we found is to update the file /etc/security/limits.conf ( according to the answer in the link

https://community.hortonworks.com/questions/48351/hiveserver2-hive-users-nofile-ulimit-above-64000.html )

other interesting post is from - https://community.hortonworks.com/questions/48351/hiveserver2-hive-users-nofile-ulimit-above-64000.html

But we are not sure that this is the solution

```<code>su postgres
bash-4.2$ psql
psql (9.2.13)
Type "help" for help.

postgres=#
postgres=# select pid as process_id,
postgres-#        usename as username,
postgres-#        datname as database_name,
postgres-#        client_addr as client_address,
postgres-#        application_name,
postgres-#        backend_start,
postgres-#        state,
postgres-#        state_change
postgres-# from pg_stat_activity;
 process_id | username | database_name | client_address | application_name |         backend_start         |        state        |         state_change
------------+----------+---------------+----------------+------------------+-------------------------------+---------------------+-------------------------------
      24182 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:12.136194+00 | idle                | 2019-05-29 13:36:53.660075+00
      24184 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:12.330268+00 | idle                | 2019-05-29 14:06:24.794683+00
      24185 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:12.346594+00 | idle                | 2019-05-29 14:06:57.014266+00
      24186 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:12.352127+00 | idle                | 2019-05-29 14:07:01.373678+00
      24192 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:14.736059+00 | idle                | 2019-05-29 14:06:37.701989+00
      24499 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:47.801281+00 | idle                | 2019-05-29 14:06:37.701784+00
      24500 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:47.801537+00 | idle                | 2019-05-29 14:06:37.701784+00
      24501 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:47.801818+00 | idle                | 2019-05-29 14:06:37.701956+00
      24502 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:47.934395+00 | idle                | 2019-05-29 14:06:54.125167+00
      24628 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:12.959034+00 | idle                | 2019-05-29 14:06:11.004364+00
      24620 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:10.674515+00 | idle                | 2019-05-29 14:06:10.697886+00
      24621 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:10.866393+00 | idle                | 2019-05-29 14:06:10.900711+00
      24624 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:12.11398+00  | idle                | 2019-05-29 14:05:46.928607+00
      24625 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:12.139117+00 | idle                | 2019-05-29 14:06:14.719214+00
      24629 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:12.980466+00 | idle                | 2019-05-29 14:06:11.005997+00
      24750 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:17.681669+00 | idle                | 2019-05-29 14:06:14.713394+00
      24751 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:17.68909+00  | idle                | 2019-05-29 14:06:14.618542+00
      25223 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:27.016383+00 | idle                | 2019-05-29 14:06:22.918908+00
      25293 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:27.394022+00 | idle                | 2019-05-29 14:06:22.933555+00
      24818 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.344101+00 | idle                | 2019-05-29 13:54:22.786162+00
      24819 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.364094+00 | idle                | 2019-05-29 13:54:22.937269+00
      24820 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.377741+00 | idle                | 2019-05-29 13:57:22.797683+00
      24821 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.389561+00 | idle                | 2019-05-29 13:57:22.928034+00
      24822 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.397512+00 | idle                | 2019-05-29 14:00:22.808355+00
      24823 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.411604+00 | idle                | 2019-05-29 14:00:22.930902+00
      24824 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.420796+00 | idle                | 2019-05-29 14:03:22.872217+00
      24825 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.42768+00  | idle                | 2019-05-29 14:03:23.033186+00
      25196 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:25.651445+00 | idle                | 2019-05-29 14:06:22.79415+00
      24881 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:24.131849+00 | idle                | 2019-05-29 14:06:26.752754+00
      24884 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:24.16027+00  | idle                | 2019-05-29 14:06:26.754117+00
</code>```

答:
Most all Hadoop services tend to have a lot of open files.  It's not uncommon for a production environment to have a 100K-200K open file descriptor limit.

The easiest solution is to raise the file descriptor limit.

Reference:

https://unix.stackexchange.com/questions/8945/how-can-i-increase-open-files-limit-for-all-processes

Body:
We have ambari cluster with Hadoop version – 2.6.4

When we run query in order to verify connections in PostgreSQL DB , we found many hive connection – in our case around 90

This cause other application problems

So we suspect that hiveserver2 is not cleaning up connections like it should and files are not being released.

Any suggestion why hive is with a lot connection? to postgresql ? ,
And what is the solution for that?

One option that we found is to update the file /etc/security/limits.conf ( according to the answer in the link

https://community.hortonworks.com/questions/48351/hiveserver2-hive-users-nofile-ulimit-above-64000.html )

other interesting post is from - https://community.hortonworks.com/questions/48351/hiveserver2-hive-users-nofile-ulimit-above-64000.html

But we are not sure that this is the solution

su postgres
bash-4.2$ psql
psql (9.2.13)
Type "help" for help.

postgres=#
postgres=# select pid as process_id,
postgres-#        usename as username,
postgres-#        datname as database_name,
postgres-#        client_addr as client_address,
postgres-#        application_name,
postgres-#        backend_start,
postgres-#        state,
postgres-#        state_change
postgres-# from pg_stat_activity;
 process_id | username | database_name | client_address | application_name |         backend_start         |        state        |         state_change
------------+----------+---------------+----------------+------------------+-------------------------------+---------------------+-------------------------------
      24182 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:12.136194+00 | idle                | 2019-05-29 13:36:53.660075+00
      24184 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:12.330268+00 | idle                | 2019-05-29 14:06:24.794683+00
      24185 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:12.346594+00 | idle                | 2019-05-29 14:06:57.014266+00
      24186 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:12.352127+00 | idle                | 2019-05-29 14:07:01.373678+00
      24192 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:14.736059+00 | idle                | 2019-05-29 14:06:37.701989+00
      24499 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:47.801281+00 | idle                | 2019-05-29 14:06:37.701784+00
      24500 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:47.801537+00 | idle                | 2019-05-29 14:06:37.701784+00
      24501 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:47.801818+00 | idle                | 2019-05-29 14:06:37.701956+00
      24502 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:47.934395+00 | idle                | 2019-05-29 14:06:54.125167+00
      24628 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:12.959034+00 | idle                | 2019-05-29 14:06:11.004364+00
      24620 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:10.674515+00 | idle                | 2019-05-29 14:06:10.697886+00
      24621 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:10.866393+00 | idle                | 2019-05-29 14:06:10.900711+00
      24624 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:12.11398+00  | idle                | 2019-05-29 14:05:46.928607+00
      24625 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:12.139117+00 | idle                | 2019-05-29 14:06:14.719214+00
      24629 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:12.980466+00 | idle                | 2019-05-29 14:06:11.005997+00
      24750 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:17.681669+00 | idle                | 2019-05-29 14:06:14.713394+00
      24751 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:17.68909+00  | idle                | 2019-05-29 14:06:14.618542+00
      25223 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:27.016383+00 | idle                | 2019-05-29 14:06:22.918908+00
      25293 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:27.394022+00 | idle                | 2019-05-29 14:06:22.933555+00
      24818 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.344101+00 | idle                | 2019-05-29 13:54:22.786162+00
      24819 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.364094+00 | idle                | 2019-05-29 13:54:22.937269+00
      24820 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.377741+00 | idle                | 2019-05-29 13:57:22.797683+00
      24821 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.389561+00 | idle                | 2019-05-29 13:57:22.928034+00
      24822 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.397512+00 | idle                | 2019-05-29 14:00:22.808355+00
      24823 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.411604+00 | idle                | 2019-05-29 14:00:22.930902+00
      24824 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.420796+00 | idle                | 2019-05-29 14:03:22.872217+00
      24825 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.42768+00  | idle                | 2019-05-29 14:03:23.033186+00
      25196 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:25.651445+00 | idle                | 2019-05-29 14:06:22.79415+00
      24881 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:24.131849+00 | idle                | 2019-05-29 14:06:26.752754+00
      24884 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:24.16027+00  | idle                | 2019-05-29 14:06:26.754117+00


问:
clock.js, conditionally set eastern or central time
I have a perfectly functioning clock.js widget that I'm using  to display date and time on multiple displays throughout our offices in several states.

The offices in the Eastern timezone have no issue, as this defaults to eastern time (our server running the screens for every display is eastern).

However, I want to add a conditional in here (say if $screenID == 3 {... so that on the screens in the Central time zone it shows the proper central time.

How should I go about adding a block in here for that condition to show central rather than eastern?

```<code> function startTime() {
    var today = new Date();
    var hr = today.getHours();
    var min = today.getMinutes();
    // var sec = today.getSeconds();
    ap = (hr < 12) ? "<span>AM</span>" : "<span>PM</span>";
    hr = (hr == 0) ? 12 : hr;
    hr = (hr > 12) ? hr - 12 : hr;
    //Add a zero in front of numbers<10
    hr = checkTime(hr);
    min = checkTime(min);
    // sec = checkTime(sec);
    document.getElementById("clock").innerHTML = hr + ":" + min + " " + ap;

    var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
    var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
    var curWeekDay = days[today.getDay()];
    var curDay = today.getDate();
    var curMonth = months[today.getMonth()];
    // var curYear = today.getFullYear();
    var date = curWeekDay+", "+curDay+" "+curMonth;
    document.getElementById("date").innerHTML = date;

    var time = setTimeout(function(){ startTime() }, 500);
}
function checkTime(i) {
    if (i < 10) {
        i = "0" + i;
    }
    return i;
}
</code>```

答:
Use timezones.

function startTime(screen, loc) {
  var timeZone = "America/Chicago";
  if (screen === 1)
    timeZone = "America/New_York";

  var dateOptions = { weekday: 'long', day: 'numeric', month: 'long', timeZone: timeZone };
  var timeOptions = { hour: 'numeric', minute: 'numeric', timeZone: timeZone };
  var dt = new Date();

  document.getElementById("myclock" + loc).innerHTML = dt.toLocaleString("en-US", timeOptions);
  document.getElementById("mydate" + loc).innerHTML = dt.toLocaleString("en-NZ", dateOptions);
}

startTime(0, 1);
startTime(1, 2);```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="myclock1">asdf</div>
<div id="mydate1">asdf</div>
<hr>
<div id="myclock2">asdf</div>
<div id="mydate2">asdf</div></code>```

Body:
I have a perfectly functioning clock.js widget that I'm using  to display date and time on multiple displays throughout our offices in several states.

The offices in the Eastern timezone have no issue, as this defaults to eastern time (our server running the screens for every display is eastern).

However, I want to add a conditional in here (say if $screenID == 3 {... so that on the screens in the Central time zone it shows the proper central time.

How should I go about adding a block in here for that condition to show central rather than eastern?

 function startTime() {
    var today = new Date();
    var hr = today.getHours();
    var min = today.getMinutes();
    // var sec = today.getSeconds();
    ap = (hr < 12) ? "AM" : "PM";
    hr = (hr == 0) ? 12 : hr;
    hr = (hr > 12) ? hr - 12 : hr;
    //Add a zero in front of numbers<10
    hr = checkTime(hr);
    min = checkTime(min);
    // sec = checkTime(sec);
    document.getElementById("clock").innerHTML = hr + ":" + min + " " + ap;

    var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
    var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
    var curWeekDay = days[today.getDay()];
    var curDay = today.getDate();
    var curMonth = months[today.getMonth()];
    // var curYear = today.getFullYear();
    var date = curWeekDay+", "+curDay+" "+curMonth;
    document.getElementById("date").innerHTML = date;

    var time = setTimeout(function(){ startTime() }, 500);
}
function checkTime(i) {
    if (i < 10) {
        i = "0" + i;
    }
    return i;
}

Body:
Use timezones.

function startTime(screen, loc) {
  var timeZone = "America/Chicago";
  if (screen === 1)
    timeZone = "America/New_York";

  var dateOptions = { weekday: 'long', day: 'numeric', month: 'long', timeZone: timeZone };
  var timeOptions = { hour: 'numeric', minute: 'numeric', timeZone: timeZone };
  var dt = new Date();

  document.getElementById("myclock" + loc).innerHTML = dt.toLocaleString("en-US", timeOptions);
  document.getElementById("mydate" + loc).innerHTML = dt.toLocaleString("en-NZ", dateOptions);
}

startTime(0, 1);
startTime(1, 2);

<div id="myclock1">asdf</div>
<div id="mydate1">asdf</div>
<hr>
<div id="myclock2">asdf</div>
<div id="mydate2">asdf</div>


答:
Check out the docs for Handling events.

Also, you might want to move your click handler into its own function so that you can easily add it to all nav items.

const Sidedraw = props => {
  let drawClass = "sideDraw";
  if (props.show) {
    drawClass = "sideDraw open";
  }
  function clickHandler(evt) {
    console.log(evt.target)
  }
  return (

Pro matches

Public mathes

Players

Teams

  );
};```

Stackblitz

Title: Cant onClick event do <li> tag React

Body:
Check out the docs for Handling events.

Also, you might want to move your click handler into its own function so that you can easily add it to all nav items.

const Sidedraw = props => {
  let drawClass = "sideDraw";
  if (props.show) {
    drawClass = "sideDraw open";
  }
  function clickHandler(evt) {
    console.log(evt.target)
  }
  return (
    <nav className={drawClass}>
      <ul>
        <li className="matches" onClick={clickHandler}>Pro matches</li>
        <li className="matches" onClick={clickHandler}>Public mathes</li>
        <li className="matches" onClick={clickHandler}>Players</li>
        <li className="matches" onClick={clickHandler}>Teams</li>
      </ul>
    </nav>
  );
};

Stackblitz


问:
pysvn on a webserver
Are there any web hosting providers who have pysvn (http://pysvn.tigris.org/) included in their python modules, or who allow you to add additional modules such that I can install it myself? Many thanks.</p>

答:
If you have shell access you can install pretty much anything to your home directory.  Just make sure the path you install the module to is added to your PYTHONPATH environment variable.

say /home/harry is your home directory, you install pysvn to /home/harry/lib in your .bash_profile add:

```<code>PYTHONPATH=/home/harry/lib:$PYTHONPATH
export PYTHONPATH
</code>```

login and log out again.  This will put it into the environment and python will find the modules in /home/harry/lib  see the python docs on modules for more info on how python searches for modules.

The only real caveat is, if your host doesn't have all the files needed to build pysvn (such as svn header files), you'll have to install them also.

with that said I like webfaction (which is nice towards these things and python development) and this question might be better in webmasters.stackexchange.com

Title: pysvn on a webserver

Body:
If you have shell access you can install pretty much anything to your home directory.  Just make sure the path you install the module to is added to your PYTHONPATH environment variable.

say /home/harry is your home directory, you install pysvn to /home/harry/lib in your .bash_profile add:

PYTHONPATH=/home/harry/lib:$PYTHONPATH
export PYTHONPATH

login and log out again.  This will put it into the environment and python will find the modules in /home/harry/lib  see the python docs on modules for more info on how python searches for modules.

The only real caveat is, if your host doesn't have all the files needed to build pysvn (such as svn header files), you'll have to install them also.

with that said I like webfaction (which is nice towards these things and python development) and this question might be better in webmasters.stackexchange.com


问:
How do I create a timer for 1 second in java?
I need to make an image bounce on the screen. I am trying to do this by shifting the image up 5 units, then taking a one second break, then shifting another 5 units up, etc. I am trying to shift up 5 times and then shifting down 5 times, with a one second break between each shift. I need help making the timer for one second so it acts like a break between each shift. I need to write the time() method. </p>

```<code>public void moveIt(KeyEvent evt) throws InterruptedException {
    switch (evt.getKeyCode()) {
    case KeyEvent.VK_DOWN:
        myY += 0;
        break;
    case KeyEvent.VK_UP:
        for (int i = 1; i <= 10; i++) {
            if (i <= 5) {
                bounceUp();
            } else {
                bounceDown();
            }
            time();
        }
        break;
    case KeyEvent.VK_LEFT:
        myX -= 5;
        break;
    case KeyEvent.VK_RIGHT:
        myX += 5;
        break;
    }

    repaint();
}

Timer timer = new Timer();

public void bounceUp() throws InterruptedException {
    myY -= 10;
}

public void bounceDown() throws InterruptedException {
    myY += 10;
}

public void time() {
}
</code>```

答:
Try this:</p>

```<code>try{

   Thread.sleep(1000);

}catch(InterruptedException e) {

}
</code>```

Body:
I need to make an image bounce on the screen. I am trying to do this by shifting the image up 5 units, then taking a one second break, then shifting another 5 units up, etc. I am trying to shift up 5 times and then shifting down 5 times, with a one second break between each shift. I need help making the timer for one second so it acts like a break between each shift. I need to write the time() method.

public void moveIt(KeyEvent evt) throws InterruptedException {
    switch (evt.getKeyCode()) {
    case KeyEvent.VK_DOWN:
        myY += 0;
        break;
    case KeyEvent.VK_UP:
        for (int i = 1; i <= 10; i++) {
            if (i <= 5) {
                bounceUp();
            } else {
                bounceDown();
            }
            time();
        }
        break;
    case KeyEvent.VK_LEFT:
        myX -= 5;
        break;
    case KeyEvent.VK_RIGHT:
        myX += 5;
        break;
    }

    repaint();
}

Timer timer = new Timer();

public void bounceUp() throws InterruptedException {
    myY -= 10;
}

public void bounceDown() throws InterruptedException {
    myY += 10;
}

public void time() {
}

Body:
Try this:

try{

   Thread.sleep(1000);

}catch(InterruptedException e) {

}


问:
Making Django-Jet autocomplete with TabularInlines
My team has been using "django-jet" as a skin to the admin in our django application.

We have inlines with very large select widgets, so as the django-jet documentation recommends, we added autocomplete fields to our models.

The problem is that it doesn't support TabularInlines. Inspecting django-jet's code you can see how what to change to make the widget work:

Copy Django's admin "tabular.html" in your template dirs.

Load jet_tags in the first line.

Add the filter jet_select2_lookup to the fields.

tabular.html

```<code>1 {% load i18n admin_urls static admin_modify jet_tags %}
...
...
55               {% if field.is_readonly %}
56                   <p>{{ field.contents }}</p>
57               {% else %}
58                   {{ field.field.errors.as_ul }}
59                   {{ field.field|jet_select2_lookups }}
60               {% endif %}
</code>```

This approach works to add the autocomplete widget, but it fails with a "invalid option" error.

At the same time, the widget doesn't seems to use the formfield_for_foreignkey method defined in the admin, so the queryset isn't filtered.

Has anyone successfully added autocomplete to a TabularInline using django-jet?

答:
In fact this is not an answer, but a comment to Paulo's PR.

With Paulo's code and Without filters I received an error (Django 2.2.1):

```<code>ERROR Internal Server Error: /jet/model_lookup/
Traceback (most recent call last):
  File "/home/mirek/dj/rian/ve_rian/lib/python3.7/site-packages/django/utils/datastructures.py", line 78, in __getitem__
list_ = super().__getitem__(key)
KeyError: 'filters'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mirek/dj/rian/ve_rian/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/mirek/dj/rian/ve_rian/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/mirek/dj/rian/ve_rian/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/mirek/dj/rian/ve_rian/lib/python3.7/site-packages/django/views/decorators/http.py", line 40, in inner
    return func(request, *args, **kwargs)
  File "/home/mirek/dj/rian/isms/django-jet/jet/views.py", line 64, in model_lookup_view
    items, total = form.lookup()
  File "/home/mirek/dj/rian/isms/django-jet/jet/forms.py", line 135, in lookup
    qs.query.__dict__ = pickle.loads(codecs.decode(self.data['filters'].encode(), 'base64'))
  File "/home/mirek/dj/rian/ve_rian/lib/python3.7/site-packages/django/utils/datastructures.py", line 80, in __getitem__
    raise MultiValueDictKeyError(key)
django.utils.datastructures.MultiValueDictKeyError: 'filters'
</code>```

This error no longer occurs if I change your code in jet/forms.py:

```<code>def lookup(self):
    # patch: https://github.com/geex-arts/django-jet/pull/329/files https://stackoverflow.com/questions/45065632/making-django-jet-autocomplete-with-tabularinlines
    if 'filters' in self.data:
        qs = self.model_cls.objects.all()
        qs.query.__dict__ = pickle.loads(codecs.decode(self.data['filters'].encode(), 'base64'))
    else:
        qs = self.model_cls.objects
</code>```

However I don't know if everything works well with the filter (I have not tested it, because I don't use the filter).

Body:
My team has been using "django-jet" as a skin to the admin in our django application.

We have inlines with very large select widgets, so as the django-jet documentation recommends, we added autocomplete fields to our models.

The problem is that it doesn't support TabularInlines. Inspecting django-jet's code you can see how what to change to make the widget work:

Copy Django's admin "tabular.html" in your template dirs.

Load jet_tags in the first line.

Add the filter jet_select2_lookup to the fields.

tabular.html

1 {% load i18n admin_urls static admin_modify jet_tags %}
...
...
55               {% if field.is_readonly %}
56
{{ field.contents }}

57               {% else %}
58                   {{ field.field.errors.as_ul }}
59                   {{ field.field|jet_select2_lookups }}
60               {% endif %}

This approach works to add the autocomplete widget, but it fails with a "invalid option" error.

At the same time, the widget doesn't seems to use the formfield_for_foreignkey method defined in the admin, so the queryset isn't filtered.

Has anyone successfully added autocomplete to a TabularInline using django-jet?

Body:
In fact this is not an answer, but a comment to Paulo's PR.

With Paulo's code and Without filters I received an error (Django 2.2.1):

ERROR Internal Server Error: /jet/model_lookup/
Traceback (most recent call last):
  File "/home/mirek/dj/rian/ve_rian/lib/python3.7/site-packages/django/utils/datastructures.py", line 78, in __getitem__
list_ = super().__getitem__(key)
KeyError: 'filters'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mirek/dj/rian/ve_rian/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/mirek/dj/rian/ve_rian/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/mirek/dj/rian/ve_rian/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/mirek/dj/rian/ve_rian/lib/python3.7/site-packages/django/views/decorators/http.py", line 40, in inner
    return func(request, *args, **kwargs)
  File "/home/mirek/dj/rian/isms/django-jet/jet/views.py", line 64, in model_lookup_view
    items, total = form.lookup()
  File "/home/mirek/dj/rian/isms/django-jet/jet/forms.py", line 135, in lookup
    qs.query.__dict__ = pickle.loads(codecs.decode(self.data['filters'].encode(), 'base64'))
  File "/home/mirek/dj/rian/ve_rian/lib/python3.7/site-packages/django/utils/datastructures.py", line 80, in __getitem__
    raise MultiValueDictKeyError(key)
django.utils.datastructures.MultiValueDictKeyError: 'filters'

This error no longer occurs if I change your code in jet/forms.py:

def lookup(self):
    # patch: https://github.com/geex-arts/django-jet/pull/329/files https://stackoverflow.com/questions/45065632/making-django-jet-autocomplete-with-tabularinlines
    if 'filters' in self.data:
        qs = self.model_cls.objects.all()
        qs.query.__dict__ = pickle.loads(codecs.decode(self.data['filters'].encode(), 'base64'))
    else:
        qs = self.model_cls.objects

However I don't know if everything works well with the filter (I have not tested it, because I don't use the filter).