[php] hgfh

Viewer

  1. <?php 
  2. $var = 'var a = \'\';
  3. var num = [];
  4. var ans;
  5.  
  6. let result = ""
  7.  
  8. let length = 0
  9.  
  10. // All the numbers and operators input will be stored in an array "num" 
  11. function sendNum(digit){
  12.         num.push(digit);
  13.         if(num.length != 1){
  14.                 a = \'\';
  15.                 document.getElementById(\'screen\').innerHTML = a;// clearing the screen.
  16.         }
  17.  
  18.         for(i=0; i<num.length ; i++){
  19.  
  20.                 a = a + num[i];     // concatenate the elements of the array "num" into a single string, which will be displayed on the screen
  21.  
  22.         }
  23. document.getElementById(\'screen\').innerHTML = a;    // displaying the concatenated string
  24. }
  25. // When user presses "=", function "clearScr()" is called
  26. function equalTo(){
  27.         document.getElementById(\'screen\').innerHTML = \'\';
  28.  
  29.         ans = eval(a);       
  30.     result = a + " = " + ans
  31.         document.getElementById(\'screen\').innerHTML =result; // result display
  32.     length += 1
  33.     addlist(result, length)
  34.  
  35.         while(num.length > 0){
  36.             num.pop();                              // emptying the array "num"
  37.         }
  38.  
  39.         num.push(ans.toString()); //adding the result to the array "num"
  40. }
  41. // When user presses "AC", function "clearScr()" is called
  42.  
  43. function clearScr(){
  44.         document.getElementById(\'screen\').innerHTML = \'\';
  45.         while(num.length > 0){
  46.             num.pop();                              // emptying the array "num"
  47.         }
  48.         a =\'\';
  49.  
  50. }
  51.  
  52. function emptyList() {
  53.         length = 0
  54.         $(\'#ulList\').empty();
  55. }
  56.  
  57. $(document).ready(function() {
  58.         $("#ac").click(function() {
  59.                 clearScr()
  60.         })
  61.  
  62.         $("#ac").dblclick(function() {
  63.                 emptyList()
  64.         })
  65. })
  66.  
  67. let ulEl = document.getElementById("ulList");
  68.  
  69.  
  70. function addlist(each, id) {
  71.     let listEl = document.createElement("li");
  72.     listEl.classList.add("eachHistory")
  73.     listEl.textContent =length + ")  "  + each
  74.     listEl.id = id
  75.     ulEl.appendChild(listEl)
  76. }
  77.  
  78.  
  79.  
  80.  
  81. ';

Editor

You can edit this paste and save as new:


File Description
  • hgfh
  • Paste Code
  • 24 Sep-2021
  • 1.73 Kb
You can Share it: