خرید بک لینک
I got alittle bug here where i am getting this error...


Quote:

Uncaught DOMException: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string.
i do understand that the dom can only be set by the program but im trying to get the value on change.


Code:


  $("input[name='vidfile[]']").change(function(){

        var t = this.files[0].size;



here is the whole thing... still cant find the issue thats causing the dom error

Code:

{literal}
<script type="text/javascript">

var speed = {/literal} '{$uplspeed}' {literal};
var speedcfg = {/literal} '{$uplspeedcfg}' {literal};
var dispopt = {/literal} '{$dispopt}' {literal};


$(document).ready(function(){
 
    var sec;
    var maxsec;
    var zippo;
 
   
    $("input[name='vidfile[]']").change(function(){

        var t = this.files[0].size;
   
        sec = getseconds(t, '0'); //default value
       
        maxsec = parseInt(sec);
 
          //if the text value of this is 'count'
          if(dispopt == 'count')
          {
           
            startprogress(maxsec); //countdown opt
       
          }else{
           
                  zippo = 0;
       
                  startProgressBar(zippo, maxsec, $('#progressBar')); //progress bar option
             
                }//close else
    });
   
 
    //if they have and change userspeed
    //then the field exists so we know 
    //the speed config setting is set to [userset]
   
    if(speedcfg == 'userset')
    {
   
      $("input[name='userspeed']").change(function(){
         
          speed = document.getElementsByName("userspeed")[0].value;
 
          if(speed == 'undefined')
          {
              speed = '3'; //default
          }
         
          sec = getseconds(t, speed);
       
          maxsec = parseInt(sec);
 
          //dispopt = {/literal} '{$dispopt}' {literal};
 
 
          if(dispopt == 'count')
          {
           
            startprogress(maxsec); //countdown opt
       
          }else{
           
                  zippo = 0;
       
                  startProgressBar(zippo, maxsec, $('#progressBar')); //progress bar option
             
                }//close else
      });
     
    }//close if speedcfg
   
});


/* counter */
function startprogress(seconds)
{

  $("form[name='viduploadForm']").submit(function(){
     
      var cname = document.getElementsByClassName("error");
      var isreq;
      var iserr;
     
      //check the object
      for(i=0;i < cname.length;i++)
      {
         
        isreq = cname[i].ierHTML;
       
        if(isreq == 'Required')
        {
            iserr = '1';
            break;
          }
         
      }//close for loop
     

  if(iserr != '1')
  {

    display = document.querySelector('#ultime');
    startTimer(seconds, display);
   
  }

  });   

}//close function


/* progress bar */

function startProgressBar(begin, totaltime, $element)
{
   
  $("form[name='viduploadForm']").submit(function(){
     
      var pbcname = document.getElementsByClassName("error");
      var pbisreq;
      var pbiserr;
     
      //check the object
      for(i=0;i < pbcname.length;i++)
      {
         
        pbisreq = pbcname[i].ierHTML;
       
        if(pbisreq == 'Required')
        {
            pbiserr = '1';
            break;
          }
         
      }//close for loop
     

/* displays motion bar for the progress bar */

  if(pbiserr != '1')
  { 
     
    var defval = parseInt(begin);
    var totaltimesec = parseInt(totaltime); //total secs to do the upload
 
    //default first appearance   
    var progressBarWidth = defval * $element.width() / 100;
    $element.find('div').animate({ width: progressBarWidth }, 500).html(defval + "% ");
   
    startTimerBar(totaltime, $element);
   
    }//close if
 
  });
 
   
}//close function

</script>
{/literal}

and here is the remote js file

Code:


function startTimer(duration, display)
{
    var start = Date.now(),
        diff,
        minutes,
        seconds;

    function timer() {
        /* get the number of seconds that have elapsed since */
        /* startTimer() was called */
        diff = duration - (((Date.now() - start) / 1000) | 0);

        /* does the same job as parseInt truncates the float */
        minutes = (diff / 60) | 0;
        seconds = (diff % 60) | 0;

        minutes = minutes < 10 ? "0" + minutes : minutes;
        seconds = seconds < 10 ? "0" + seconds : seconds;

    if(minutes == 0 && seconds == 1)
    {
      minutes = 0;
      seconds = 0;
      display.textContent = minutes + ":" + seconds;
      clearInterval(si);

    }else{
 
            display.textContent = minutes + ":" + seconds; 
 
            /*  add one second so that the count down starts at the full duration */
            /* example 05:00 not 04:59 */           
            if (diff <= 0)
            {
              start = Date.now() + 1000;
            }

        }//close else

  };
  timer(); 
  var si = setInterval(timer, 1000);
   
}//close function


function getseconds(filesize, userspeed)
{
   
    //userspeed should be 0 if speedcfg is set to [userset]
    //because we are going to run this again anyway when the field is
    //changed
   
    //initialize the var to avoid scope warning
    var howlong;
    var avg;
   
  /* this will be how many minutes it should take */ 
 
  if(userspeed > 0)
  {
     
    var mb = 1024 * 1024;
    var newspeed = userspeed * mb;
     
    avg = filesize / newspeed;
    avg = Math.ceil(avg);
    avg = parseInt(avg);
     
  }else{
     
        //this is the default 3MB per min
         
          avg = filesize / 3145728;
          avg = Math.ceil(avg);
          avg = parseInt(avg); 
         
         
        }//close else

  if(avg < 1.00)
  {

    howlong = 40; /* under a min should only take 40 sec to upload */

    }else{

          howlong = Math.ceil(avg*60); /* number of seconds */

          }

return howlong;

}//close function


function startTimerBar(howlong, $element)
{
   
    var totalsec = parseInt(howlong);  //total sec it will take
    var count = 0;
 
    function timerbar()
    {
       
      count = count + 1;
       
      if(count < totalsec)
      {
        //continue the loop
        progressBarWidth = count * $element.width() / totalsec;
        $element.find('div').animate({ width: progressBarWidth }, 500).html(count + "% ");
         
      }else{
             
              clearInterval(sb);
         
            }//close else

  };
  timerbar(); 
  var sb = setInterval(timerbar, 1000);
   
}//close function

برچسب: نویسنده: آیلین رضوانی تاريخ: پنجشنبه 21 دی 1396 ساعت: 6:15

صفحه بندی