<commit_before>package sample.snippet

import scala.xml.{NodeSeq,Text}
import net.liftweb.util.Helpers._
import net.liftweb.http.{SHtml,SessionVar,RequestVar,S}
import net.liftweb.http.js.JsCmds.{SetHtml,Alert,Noop}
import net.liftweb.http.js.jquery.JqJsCmds.{Show,Hide}

case class Book(reference: String, var title: String)

class MoreAjax {
  object stock extends SessionVar[List[Book]](List(
    Book("ABCD", "Harry Potter and the Deathly Hallows"),
    Book("EFGH", "Harry Potter and the Goblet of Fire"),
    Book("IJKL", "Scala in Depth"),
    Book("MNOP", "Lift in Action")
  ))
  
  private val bookListDiv = "book_list"
  private val editFormDiv = "edit_display"
  
  def list = {
    ".line" #> stock.is.map { b => 
      ".name" #> b.title &
      ".line [id]" #> b.reference &
      ".edit" #>((ns: NodeSeq) => SHtml.a(() => 
        SetHtml(editFormDiv, SHtml.ajaxForm(edit(b)(ns), Hide(editFormDiv, 1 seconds))) & 
        Show(editFormDiv, 1 seconds), Text("Edit"))
      )
    }
  }
  
  def edit(b: Book) = {
    "#book_name" #> SHtml.text(b.title, b.title = _) &
    "type=submit" #> SHtml.ajaxSubmit("Update", 
      () => SetHtml(b.reference, Text(b.title))) 
  }
  
}<commit_msg>Removed unused val<commit_after>package sample.snippet

import scala.xml.{NodeSeq,Text}
import net.liftweb.util.Helpers._
import net.liftweb.http.{SHtml,SessionVar}
import net.liftweb.http.js.JsCmds.SetHtml
import net.liftweb.http.js.jquery.JqJsCmds.{Show,Hide}

case class Book(reference: String, var title: String)

class MoreAjax {
  object stock extends SessionVar[List[Book]](List(
    Book("ABCD", "Harry Potter and the Deathly Hallows"),
    Book("EFGH", "Harry Potter and the Goblet of Fire"),
    Book("IJKL", "Scala in Depth"),
    Book("MNOP", "Lift in Action")
  ))
  
  private val editFormDiv = "edit_display"
  
  def list = {
    ".line" #> stock.is.map { b => 
      ".name" #> b.title &
      ".line [id]" #> b.reference &
      ".edit" #>((ns: NodeSeq) => SHtml.a(() => 
        SetHtml(editFormDiv, SHtml.ajaxForm(edit(b)(ns), Hide(editFormDiv, 1 seconds))) & 
        Show(editFormDiv, 1 seconds), Text("Edit"))
      )
    }
  }
  
  def edit(b: Book) = {
    "#book_name" #> SHtml.text(b.title, b.title = _) &
    "type=submit" #> SHtml.ajaxSubmit("Update", 
      () => SetHtml(b.reference, Text(b.title))) 
  }
  
}
{'fraction_non_alphanumeric': 0.1704399829132849, 'fraction_numerical': 0.0017086715079026058, 'mean_word_length': 3.385767790262172, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3015302', 'n_tokens_mistral': 895, 'n_tokens_neox': 859, 'n_words': 176}