new Promise(()=>{
 "use strict";

window.nlMovieFetcherList = {
  /* popThumb_FAのような表示にする */
  use_ThumbData: true,
/*******************************************/
  intervalTime: 1000,
  cachingItems: 60,
  fetchList: {},
  cacheInfo: {},
  Arr: {},
  oldSize: {},
  fetchingList: {},
  LLI_count: 0,
  LLI_offset: 0,
/*******************************************/
  init() {
    this
      .$XHR('/cache/fetch?json')
      .then(r => {
        const json = JSON.parse(r.responseText);
        this.fetchList = json;
        return json;
      })
      .then(json => this.$XHR(`/cache/info/v2?${Object.keys(json)}`))
      .then(r => {
        const json = JSON.parse(r.responseText);
        this.cacheInfo = json;
      })
      .then(() => [this.makeFetchedList.bind(this), this.popFetchStatusList.bind(this)].forEach(aValue => Promise.resolve(aValue())))
      .then(() => window.addEventListener("scroll", window.nlMovieFetcherList.LazyLoadImage, false));
  },
/*******************************************/
  makeFetchedList() {
    const
      fetchedList = this.fetchList
      ,fetchedList_Keys = Object.keys(fetchedList)
      ,fetchedList_Len = fetchedList_Keys.length;
    
    if (this.use_ThumbData) {
      document.getElementById('DisplayType').classList.add('ThumbDataType');
      document.getElementsByClassName('content_right')[0].classList.add('ThumbData');
    }
    document.getElementById('DisplaySwitchingTD').style.display='table-cell';
    
    document.getElementById('count').textContent = fetchedList_Len;
    if (!fetchedList_Len) {
      document.getElementsByClassName('content_right')[0].insertAdjacentHTML("BeforeEnd",'<div style="margin-top:1em; font-size:20px;">未視聴の動画はありません</div>');
      return;
    }
    
    return Promise
      .all([for(i of fetchedList_Keys) new Promise(r => r(i)).then(this.make0.bind(this))])
      .then(elements => document.getElementsByClassName('content_right')[0].insertAdjacentHTML("BeforeEnd", elements.join('')))
      .then(() => this.LazyLoadImage());
  },
/*******************************************/
  make0(smid) {
    const
      DATA = window.popThumb.data
      ,cacheInfo = this.cacheInfo[smid]
      ,elem = (DATA[`obj_${smid}`] ?this.make_from_object(smid) :'');
    
    var
      preferred = null
      ,isDmc = false
      ,isEconomy = false;
    if (cacheInfo) {
      preferred = cacheInfo["preferred"];
      if (preferred) {
        isDmc = cacheInfo["caches"][preferred]["dmc"];
        isEconomy = cacheInfo["caches"][preferred]["economy"];
      }
    }
    
    return `<div id="${smid}" class="thumb_box ` +
      (preferred ?
        (isDmc?
          !isEconomy? 'type_dmcCache': 'type_dmcEconomy'
          :!isEconomy? 'type_Cache': 'type_Economy'
        )
      :'type_None') +
      `">${this.make(smid) + elem}</div>`;
  },
/*******************************************/
  make(smid) {
    const
      fetchedList = this.fetchList
      ,title = fetchedList[smid]
      ,id = smid.substring(2);
    
    return '<div class="thumb_frm simple">' +
        '<div class="thumb_frm_left">' +
          `<a href="watch/${smid}" target="_blank" class="thumb_img_"><span data-img-src="http://tn-skr1.smilevideo.jp/smile?i=${id}" class="thumb_img"></span></a>` +
          '<div class="cacheIcon"></div>' +
        '</div>' +
        '<div class="thumb_frm_right">' +
          `<a class="watch title" href="watch/${smid}" target="_blank" onclick="window.nlMovieFetcherList.removeFetched(this)" onMouseOver="return popThumb2('${smid}', 0, 0)" onMouseOut="return nd()">${title}</a>` +
          '<div><input title="取得動画リストからこの動画を削除します" class="submit" type="submit" value="視聴済" onclick="window.nlMovieFetcherList.removeFetched(this)" style="margin:2px 0px; padding:1px;">' +
          `<span class="fetch">| <a href="javascript:void(0);" onclick="nicofetch(this,'${smid}')" style="text-decoration:none; font-size:small; margin-left:5px;">fetch</a></span>` +
          '</div>' +
          `<p class="font12" style=" margin:4px;"><a href="javascript:void(0);" onclick="window.nlMovieFetcherList.getThumbData('${smid}')" style="text-decoration:none;" class="nl_Desc" nl-smid="${smid}">サムネイルデータ表示</a></p>` +
        '</div>' +
      '</div>';
  },
/*******************************************/
  make_from_object(pop_smid) {
    const
      popThumb = window.popThumb
      ,object = popThumb.data[`obj_${pop_smid}`][1]
      ,HttpRequest = popThumb.HttpRequest
      ,addFigure = this.addFigure
      ,cacheInfo = this.cacheInfo[pop_smid]
      ,{
        thumbnail_url,
        title,
        description,
        description_videoarray,
        video_id,
        length,
        length_in_seconds,
        view_counter,
        mylist_counter,
        comment_counter,
        movie_type,
        tags,
        user_id,
        user_nickname,
        deleted,
        first_retrieve,
        usingAPI:{videoarray, getthumbinfo,},
      } = object
      ,length_split = length.split(':')
      ,length_ = `${('0' +((length_split[0] /60) |0)).slice(-2)}:${('0' +(length_split[0] %60)).slice(-2)}:${length_split[1]}`
      ,[, year, month, day, time,] = first_retrieve.match(/20(\d{2})-(\d{2})-(\d{2})T(.{8}).+/);
    
    var
      preferred = null
      ,isDmc = false
      ,isEconomy = false
      ,dmcMovieType = {}
      ,dmcSizeMiB = '';
    
    if (cacheInfo) {
      preferred = cacheInfo["preferred"];
      if (preferred) {
        let preferredInfo = cacheInfo["caches"][preferred];
        
        isDmc = preferredInfo["dmc"];
        isEconomy = preferredInfo["economy"];
        
        object.cache = (isDmc? (!isEconomy? 'dmcCache': 'dmcEconomy'): (!isEconomy? 'cache': 'economy'));
        if (isDmc) {
          object["dmcMovieType"] = preferredInfo["dmcMovieType"];
          object["dmcMovieType"]["size"] = preferredInfo["size"];
          
          dmcMovieType = preferredInfo["dmcMovieType"];
          dmcSizeMiB = (preferredInfo["size"] /1024 /1024) +'';
        }
        window.setTimeout(window.popThumb.save, 1000);
      }
    }
    
    var desc = description;
    if (popThumb.use_cachedVideoArrayAPI && description_videoarray) {
      desc = description_videoarray;
    }
    //if (!video_id && /^[a-z]{2}/.test(pop_smid)) video_id = pop_smid;
    
    var
      size_high = '(不明)'
      ,size_low = 0
      ,bit_rate = '(不明)';
    
    if (object.size_high) {
      size_high = ((object.size_high /1024 /1024 *10) |0) /10;
      bit_rate = ((object.size_high /1024 *8 /length_in_seconds) |0);
    }
    if (object.size_low) {
      size_low = ((object.size_low /1024 /1024 *10) |0) /10;
    }
    
    var
      tags_len = tags.length
      ,tags_Arr = [`<li class="TagItem"><strong>TAG</strong>:[ jp:${tags_len} ]</li>`];
    if (tags_len) {
      for (let tag_obj of tags) {
        const
          res = []
          ,tag_encode = tag_obj.text || ''
          ,tag_text = tag_encode.replace(/<[^<>]+>/g, '');
        
        res.push(`<span class="TagType${tag_obj.lock? ' TagLock': ''}${tag_obj.category? ' TagCategory': ''}"></span>`);
        //if (popThumb.use_in_JS_to_link) tag_encode = popThumb.desc_to_link(tag_encode,'popThumb_FA_link',pop_smid);
        
        res.push(tag_encode.replace(/(^|<\/[^>]+>)([^<>]+)/, '$1<a href="http://www.nicovideo.jp/tag/'+tag_text+'">$2</a>'));
        
        if (tag_obj.dic || (popThumb.dic && popThumb.dic[tag_encode])) {
          res.push(`<a href="http://dic.nicovideo.jp/a/${tag_encode}" class="TagDic"></a>`);
        } else if (tag_obj.dic === 0) {
          res.push(`<a href="http://dic.nicovideo.jp/a/${tag_encode}" class="TagNoDic"></a>`);
        }
        tags_Arr.push(`<li class="TagItem">${res.join('')}</li>`);
      }
    }else{
      tags_Arr.push('<li class="TagItem">タグがありません</li>');
    }
    
    var
      getTag = tags_Arr.join('')
      ,owner_link = '<span style="color:orange;">community !</span>';
    
    if (user_id) {
      owner_link = `<a onmouseover="return popThumb('thumb_user/${user_id}', 0)" onmouseout="return nd();" title="プロフィールへ" href="http://www.nicovideo.jp/user/${user_id}">投稿者ID: ${user_id}</a> ： <a title = ニコニコチャートへ href="http://www.nicochart.jp/name/?s=${encodeURIComponent(user_nickname)}" style="color:#F30; font-weight: bold;">${user_nickname}</a>`;
    } else if (!videoarray && !getthumbinfo) {
      owner_link = '<span style="color:orange;">APIの仕様で投稿ユーザー不明</span>';
    }
    
    return (
      '<div class="thumb_frm custom">' +
        '<p class="font10">' +
          `<a href="http://www.nicochart.jp/watch/${video_id}" title="NicoChart : ${video_id}">${pop_smid}</a>` +
          `<a style="margin-left:10px;" href="javascript:void(nlMovieFetcherList.getNewThumbData('${pop_smid}'))" title="ThumbDataの更新">更新</a>` +
          `<a style="margin-left:10px;" href="http://www.nicovideo.jp/openlist/${video_id}" title="公開マイリストを検索">Op-ML</a>` +
          `<a style="margin-left:10px;" href="http://dic.nicovideo.jp/v/${video_id}" title="この動画の大百科">DIC</a>` +
          `<a style="margin-left:10px; color:red;" title="キャッシュを消します(NicoCache_nl)" href="http://www.nicovideo.jp/cache/rmall?${video_id}" onclick="return nlMovieFetcherList.delCache('${video_id}', 0, this);">DEL</a>` +
          `<a style="margin-left:10px;" href="javascript:void(0);" title="クリックでキャッシュ移動用セレクトボックスが出ます(NicoCache_nl)" onclick="popThumb.cacheMove_init(this, '${video_id}', '${pop_smid}'); return false;">移動</a>` +
        '</p>' +
        `<p class="font10"> 再生：<strong>${addFigure(view_counter)}</strong> コメント：<strong>${addFigure(comment_counter)}</strong> マイリスト：<strong>${addFigure(mylist_counter)}</strong></p>` +
        '<table border="0" cellpadding="0" cellspacing="0" summary="" style="margin-top:2px;"><tr valign="top">' +
          '<td class="font10">' +
            '<p style="position:relative;">' +
              `<a href="http://www.nicovideo.jp/watch/${pop_smid}" target="_blank" class="thumb_img_"><span data-img-src="`+
                (!(deleted -0)? thumbnail_url: `http://tn-skr.smilevideo.jp/smile?i=${video_id.replace(/^[sn]m(\d+)$/, '$+')}`) +
                '" class="thumb_img"></span></a>' +
              '<div class="cacheIcon"></div>' +
              ((deleted -0)? '<div class="cacheIcon deleteIconImg"></div>': '') +
            '</p>' +
            `<strong style="line-height:1.5em;">${length_}</strong>` +
            '<table border="0" cellpadding="0" cellspacing="0" class="movie_type font10"><tbody>'+
              (!dmcMovieType.videoMode?
                (getthumbinfo?
                  `<tr><td>通常画質</td><td>：</td><td>${size_high}MB</td></tr>` +
                  `<tr><td>レート</td><td>：</td><td>${bit_rate}kbps</td></tr>`
                  :'') +
                `<tr style="color:${!size_low? 'blue': 'red'}"><td>エコノミー</td>  <td>：</td><td>${size_low}MB</td></tr>` +
                `<tr><td>動画形式</td><td>：</td><td class="${movie_type}">${movie_type}</td></tr>`
              
                :`<tr><td>dmcモード</td><td>：</td><td>${dmcMovieType.videoMode}</td></tr>` +
                  `<tr><td>dmc映像</td><td>：</td><td>${dmcMovieType.videoBitrate} kbps</td></tr>` +
                  `<tr><td>dmc音声</td><td>：</td><td>${dmcMovieType.audioBitrate} kbps</td></tr>` +
                  `<tr><td>サイズ</td><td>：</td><td>${dmcSizeMiB.slice(0, dmcSizeMiB.indexOf('.') +2)} MiB</td></tr>`
              ) +
            '</tbody></table>' +
          '</td>' +
          '<td style="padding-left:4px; width:100%;">' +
            '<p class="font10">' +
              '<span style="display:inline-block;">' +
                `<span class="postTime" style="margin-right:5px;"><strong>${year}/${month}/${day} ${time}</strong> 投稿</span>` +
                `<a href="javascript:void(0)" class="fetch" onclick="nicofetch(this, '${pop_smid}', 7)" style="margin-right:5px;">fetch</a>` +
                '<a href="javascript:void(0)" onclick="nlMovieFetcherList.removeFetched(this)" title="取得動画リストからこの動画を削除します" style="margin-right:5px;">視聴済</a>' +
              '</span>' +
              `<span style="display:inline-block;">${owner_link}</span>` +
            '</p>' +
            `<p class="font12"><a href="http://www.nicovideo.jp/watch/${pop_smid}" class="watch title" target="_blank" onclick="nlMovieFetcherList.removeFetched(this)" onMouseOver="return popThumb2('${pop_smid}', 0, 0)" onMouseOut="return nd()">${title}</a></p>` +
            `<ul class="TagList font12">${getTag}</ul>` +
            `<p class="font12 description">${desc}</p>` +
          '</td>' +
        '</tr></table>'+
      '</div>'
    );
  },
/*******************************************/
  delCache(smid, fn, elem) {
    const thumbBox = elem.parentNode.parentNode.parentNode.classList;
    
    thumbBox.remove('type_dmcCache', 'type_dmcEconomy', 'type_Cache', 'type_Economy');
    thumbBox.add('type_None');
    
    delete this.cacheInfo[smid];
    return window.popThumb.delCache(smid, fn, elem);
  },
/*******************************************/
  getThumbData(smid) {
    const elem = document.getElementById(smid);
    elem.firstElementChild.classList.add('hide');
    if (elem.lastElementChild.classList.contains('custom')) {
      elem.lastElementChild.classList.add('block');
    } else {
      window.popThumb.HttpRequest(`/pr_Redirect_ext.nicovideo.jp/api/getthumbinfo/${smid}?nlFilter`, (res, [elem, smid]) => {
        elem.insertAdjacentHTML("BeforeEnd", this.make_from_object(smid).replace('custom"', 'custom block"').replace(/(data-img-src="([^"]+)")/, '$1 style="background-image:url($2);"'))
      }, true, [elem, smid], ['api', smid]);
    }
  },
/*******************************************/
  getNewThumbData(smid) {
    window.popThumb.HttpRequest(`/pr_Redirect_ext.nicovideo.jp/api/getthumbinfo/${smid}?nlFilter`, (res, smid) => {
      document.getElementById(smid).lastElementChild.outerHTML = this.make_from_object(smid).replace(/(data-img-src="([^"]+)")/,'$1 style="background-image:url($2);"');
    }, true, smid, ['api', smid]);
  },
/*******************************************/
  removeFetched(elem) {
    while (!elem.classList.contains('thumb_box')) elem = elem.parentNode;
    const smid = elem.id;
    
    this.$XHR(`/cache/fetch?rm=${smid}`, smid)
      .then(([r, smid]) => {
        if (!r.responseText.indexOf('OK')) {
          document.getElementById(smid).setAttribute('style', 'display:none;');
          --document.getElementById('count').textContent;
          this.LLI_offset = 0;
          this.LazyLoadImage();
        }
      });
  },
/*******************************************/
  removeFetchedAll(input) {
    if (!confirm(`${input.title}よ？`)) return;
    this.$XHR('/cache/fetch?rm=all')
      .then(r => {
        if (!r.responseText.indexOf('OK')) {
          document.getElementsByClassName('content_right')[0].innerHTML = '<div style="margin-top:1em; font-size:20px;">未視聴の動画はありません</div>';
          this.fetchedList = {};
          document.getElementById('count').textContent = 0;
        }
      });
  },
/*******************************************/
  cancelFetchRequest(smid) {
    this.$XHR(`/cache/fetch?cancel=${smid}`, smid)
      .then(([r, smid]) => {
        if (smid === 'all') alert('リクエストを全てキャンセルしました');
      });
  },
/*******************************************/
  popFetchStatusList(param) {
    const RI = document.getElementById('RequestInfo_TD');
    if (param === 'updatelow' || !RI.classList.contains('pop_status')) {
      if (param === 'updatelow') {
        this.$XHR('/cache/fetch?updatelow')
          .then(() => this.$XHR('/cache/fetch?status=all'))
          .then(r => this.popFetchLoadStatus(r));
      } else {
       this.$XHR('/cache/fetch?status=all')
         .then(r => this.popFetchLoadStatus(r));
      }
      RI.classList.add('pop_status');
    } else {
      RI.classList.remove('pop_status');
      clearTimeout(this.LoadStatusTimeout);
    }
  },
/*******************************************/
  popFetchLoadStatus(r) {
    const
      popFetchStatus = document.getElementById('pop_fetch_status')
      ,popThumb = window.popThumb
      ,fetchingList = {};
    
    for (let RS of r.responseText.split(/\r\n/)) {
      if (RS === '') continue;
      let [id, value] = RS.split(': ');
      fetchingList[id] = value;
    }
    
    const
      fetchingList_keys = Object.keys(fetchingList)
      ,fetchingList_Len = fetchingList_keys.length;
    
    if (!fetchingList_Len) {
      document.getElementById('RequestCount').textContent = fetchingList_Len;
      popFetchStatus.innerHTML = '<div class="fetchStatusFrame"> no request.</div>';
    } else {
      let A = [];
      
      let getInfoArr = [];
      for (let [id, value] in Iterator(fetchingList)) {
        if (~value.indexOf('%')
            || (~value.indexOf('done') && !!this.fetchingList[id] && ~this.fetchingList[id].indexOf('%'))
            ) {
          getInfoArr.push(id);
          
        }
      }
      this.fetchingList = fetchingList;
      
      if (!getInfoArr.length) {
        Promise
          .all([for(id of fetchingList_keys) new Promise(r => r(id)).then(this.popFetchLoadList.bind(this))])
          .then(e => {
            const
              popFetchStatus = document.getElementById('pop_fetch_status');
            
            popFetchStatus.innerHTML = e.join('');
          });
      } else {
        this.$XHR(`/cache/info/v2?${getInfoArr.join(',')}`)
          .then(r => {
            const
              json = Iterator(JSON.parse(r.responseText))
              ,J = [];
            
            for (let [id, value] in json) {
              this.cacheInfo[id] = value;
              J.push([id, value]);
            }
            
            Promise
              .all([for(j of J) new Promise(r => r(j)).then(this.popFetchDoneId.bind(this))])
              .then(e => {
                const elem = e.join('');
                if (elem === '') return;
                document.getElementsByClassName('content_right')[0].insertAdjacentHTML("BeforeEnd", elem);
                this.LLI_offset = 0;
                this.LazyLoadImage();
              });
          })
          .then(() => Promise.all([for(id of fetchingList_keys) new Promise(r => r(id)).then(this.popFetchLoadList.bind(this))]))
          .then(e => {
            const
              popFetchStatus = document.getElementById('pop_fetch_status');
            
            popFetchStatus.innerHTML = e.join('');
          });
      }
      
      document.getElementById('RequestCount').textContent = fetchingList_Len;
      
      this.LoadStatusTimeout = setTimeout(function(){
        window.nlMovieFetcherList
          .$XHR('/cache/fetch?status=all')
          .then(window.nlMovieFetcherList.popFetchLoadStatus.bind(window.nlMovieFetcherList));
      }, this.intervalTime);
    };
  },
/*******************************************/
  popFetchDoneId([aId, aValue]) {
    if (~this.fetchingList[aId].indexOf('done')) {
      delete this.Arr[aId];
      delete this.oldSize[aId];
      
      const
        cacheInfo = aValue
        ,preferred = cacheInfo["preferred"]
        ,CacheDATA = cacheInfo["caches"][preferred];
      
      if (!this.fetchList[aId]) {
        console.log(`${aId}: newCache`);
        this.fetchList[aId] = CacheDATA["title"];
      } else {
        console.log(`${aId}: updateCache`);
        document.getElementsByClassName('content_right')[0].removeChild(document.getElementById(aId));
        this.LLI_count--;
      }
      return this.make0(aId);
    }
    return '';
  },
/*******************************************/
  popFetchLoadList(aId) {
    if (aId === 'updatelow') {
      return `<div class="fetchStatusFrame">${aId}</div>`;
    }
    
    const
      fetchingList = this.fetchingList
      ,value = fetchingList[aId];
    
    if (!~value.indexOf('%')) {
      const
        _value = value.match(/^(.+) (\(.+\))$/);
      var
        status = value
        ,reserve = '';
      if (_value) [, status, reserve] = _value;
      
      return `<a class="fS_id" href="/watch/${aId}" target="_tab" onMouseOver="return popThumb2('${aId}', 0)" onMouseOut="return nd()">${aId}</a><span class="fS_sep">:</span><span class="fS_value"><span class="fS_value_status">${status}</span><span class="fS_value_reserve">${reserve}</span></span>`;
    } else {
      
      if (!this.Arr[aId]) {
        this.Arr[aId] = [];
        this.oldSize[aId] = 0;
      }
      
      const
        cacheInfo = this.cacheInfo[aId]
        ,cachingsId = cacheInfo["cachings"][0]
        ,CacheDATA = cacheInfo["caches"][cachingsId]
        ,cachingSize = CacheDATA["cachingSize"]
        ,size = CacheDATA["size"]
        ,Arr = this.Arr[aId]
        ,oldSize = this.oldSize[aId]
        ,TIME = () => {
          if (!Arr.length) return '';
          const
            _TIME = ((size -cachingSize) /(this.ave(Arr) /(this.intervalTime /1000))) |0
            ,_TIME2 = (_TIME > 60)? `${(_TIME /60) |0}分${_TIME %60}秒`: `${_TIME}秒`;
          return `<span class="fS_id">予想完了時間</span><span class="fS_sep">:</span><span class="fS_value"><span class="fS_value_time">${_TIME2}</span><span class="fS_value_bps">[${((cachingSize -oldSize) /1024)|0} Kbps]</span></span>`;
        };
      
      if (oldSize) {
        Arr.unshift(cachingSize -oldSize);
        this.Arr[aId] = Arr.slice(0, this.cachingItems);
      }
      this.oldSize[aId] = cachingSize;
      
      return '<div class="fetchStatusWrap">' +
        `<a class="fS_id" href="/watch/${aId}" target="_tab" onMouseOver="return popThumb2('${aId}', 0)" onMouseOut="return nd()">${aId}</a><span class="fS_sep">:</span><span class="fS_value">${value}</span>` +
        `${TIME()}` +
      '</div>';
    }
  },
/*******************************************/
  DSwitch() {
    const DT_classList = document.getElementById('DisplayType').classList;
    
    DT_classList.toggle('ThumbDataType');
    document.getElementsByClassName('content_right')[0].classList.toggle('ThumbData');
    
    if (!DT_classList.contains('ThumbDataType')) {
      for (let E of document.getElementsByClassName('thumb_frm')) {
        E.classList.remove('hide', 'block');
      }
      this.LLI_offset = 0;
      this.LazyLoadImage();
    }
  },
/*******************************************/
  addFigure(str) { return (str-0).toLocaleString()},
/*******************************************/
  ave(aArray) {
    const SUM = aArray.reduce((previousValue, currentValue, index, array) => previousValue + currentValue);
    return (SUM /aArray.length) |0;
  },
/*******************************************/
  $XHR(aUrl, aParam) {
    return new Promise((resolve, reject) => {
      var httpObj = new XMLHttpRequest();
      httpObj.open('GET', aUrl, true);
      httpObj.onload = () => resolve((aParam === undefined)? httpObj: [httpObj, aParam]);
      httpObj.onerror = () => reject(httpObj.error);
      httpObj.send();
    });
  },
/*******************************************/
  LazyLoadImage() {
    const
      nlMFL = window.nlMovieFetcherList
      ,LLI = () => {
        const bottom = (window.scrollY || document.documentElement.scrollTop) + (window.innerHeight || document.documentElement.clientHeight);
        
        if ((nlMFL.LLI_offset || 0) > bottom) return;
        
        var
          i = (nlMFL.LLI_count || 0)
          ,elem = document.getElementsByClassName('thumb_box');
        
        for (let len = elem.length; i < len; i++) {
          let
            elem2 = elem[i]
            ,offset = elem2.offsetTop;
          
          if (offset < bottom) {
            let elem3 = elem2.getElementsByClassName('thumb_img');
            for (let elem3i of elem3) {
              elem3i.setAttribute('style', `background-image:url(${elem3i.getAttribute('data-img-src')})`)
            }
            if (!~(i-len)) {
              window.removeEventListener("scroll", nlMFL.LazyLoadImage, false);
            }
          } else {
            nlMFL.LLI_count = i;
            nlMFL.LLI_offset = offset;
            return;
          }
        }
      }
    clearTimeout(nlMFL.LLI_timeout);
    nlMFL.LLI_timeout = setTimeout(LLI, 200);
  },
/*******************************************/
};

//window.nlMovieFetcherList.init.call(window.nlMovieFetcherList);
document.addEventListener("DOMContentLoaded", window.nlMovieFetcherList.init.bind(window.nlMovieFetcherList), false);

});