<commit_before>import { Template } from 'meteor/templating';
import { Currencies, LocalCurrencies } from '/imports/api/indexDB.js';

import scrollmagic from 'scrollmagic';
import './returnedCurrencies.html'
import './currency.js'

Template.returnedCurrencies.onCreated(function bodyOnCreated() {
  var self = this
  self.autorun(function(){
    SubsCache.subscribe('approvedcurrencies');
  })
  this.searchInputFilter = new ReactiveVar(undefined); 
  this.filterCount = new ReactiveVar(undefined);
  this.increment = 15
  this.limit = new ReactiveVar(this.increment)
  this.countReady = new ReactiveVar(false)
  this.filter = new ReactiveVar({})
  this.count = new ReactiveVar(undefined)
  this.everythingLoaded = new ReactiveVar(false)
  //necessery as tracker doesn't appear to recognize that collection is different (try modifying LocalCurrencies records before swap)
  this.TransitoryCollection = new ReactiveVar(Currencies)

	//logic for receiving benefits of fast-render and yet using nonreactive data from method
  if (!LocalCurrencies.find().count()) {
		Meteor.call('fetchCurrencies', (err, res) => {
			res.forEach(x => {
				LocalCurrencies.insert(x)
      })
      this.countReady.set(true)
			this.TransitoryCollection.set(LocalCurrencies)
		})
	} else {
		this.TransitoryCollection.set(LocalCurrencies)
  }
  
  //resets limit and calculates filter parameters for query
  this.autorun(()=>{
    var templ = Template.instance()
    let searchInputFilter = templ.searchInputFilter.get();
    templ.limit.set(templ.increment)
    this.filter.set({
        $or: [{
            currencyName: { $regex: new RegExp(searchInputFilter, "i") }
        }, {
            currencySymbol: { $regex: new RegExp(searchInputFilter, "i") }
        }, {
            'previousNames.tag': new RegExp(searchInputFilter, 'gi')
        }]
    })
  })

  //calculates count, and if all records are loaded
  this.autorun(()=>{
    var templ = Template.instance()
    if (templ.countReady.get() == true) {
      let filter = templ.filter.get()
      templ.count.set(templ.TransitoryCollection.get().find(filter).count())
      if (typeof templ.count.get() != 'string' && templ.count.get() <= templ.limit.get()){
        templ.everythingLoaded.set(true)
      } else {
        templ.everythingLoaded.set(false)
      }
    } else {
       templ.count.set('...')
    }
  })

});

Template.returnedCurrencies.onRendered( function () {	
	// init controller
	this.controller = new ScrollMagic.Controller();
  var templ = Template.instance()
	// build scene
	 var scene = new ScrollMagic.Scene({triggerElement: "#loader", triggerHook: "onEnter"})
					.addTo(templ.controller)
					.on("enter", function (e) {<commit_msg>Problem : Error: ScrollMagic is not defined Solution : Solution : change ScrollMagic to scrollmagic<commit_after>import { Template } from 'meteor/templating';
import { Currencies, LocalCurrencies } from '/imports/api/indexDB.js';

import scrollmagic from 'scrollmagic';
import './returnedCurrencies.html'
import './currency.js'

Template.returnedCurrencies.onCreated(function bodyOnCreated() {
  var self = this
  self.autorun(function(){
    SubsCache.subscribe('approvedcurrencies');
  })
  this.searchInputFilter = new ReactiveVar(undefined); 
  this.filterCount = new ReactiveVar(undefined);
  this.increment = 15
  this.limit = new ReactiveVar(this.increment)
  this.countReady = new ReactiveVar(false)
  this.filter = new ReactiveVar({})
  this.count = new ReactiveVar(undefined)
  this.everythingLoaded = new ReactiveVar(false)
  //necessery as tracker doesn't appear to recognize that collection is different (try modifying LocalCurrencies records before swap)
  this.TransitoryCollection = new ReactiveVar(Currencies)

	//logic for receiving benefits of fast-render and yet using nonreactive data from method
  if (!LocalCurrencies.find().count()) {
		Meteor.call('fetchCurrencies', (err, res) => {
			res.forEach(x => {
				LocalCurrencies.insert(x)
      })
      this.countReady.set(true)
			this.TransitoryCollection.set(LocalCurrencies)
		})
	} else {
		this.TransitoryCollection.set(LocalCurrencies)
  }
  
  //resets limit and calculates filter parameters for query
  this.autorun(()=>{
    var templ = Template.instance()
    let searchInputFilter = templ.searchInputFilter.get();
    templ.limit.set(templ.increment)
    this.filter.set({
        $or: [{
            currencyName: { $regex: new RegExp(searchInputFilter, "i") }
        }, {
            currencySymbol: { $regex: new RegExp(searchInputFilter, "i") }
        }, {
            'previousNames.tag': new RegExp(searchInputFilter, 'gi')
        }]
    })
  })

  //calculates count, and if all records are loaded
  this.autorun(()=>{
    var templ = Template.instance()
    if (templ.countReady.get() == true) {
      let filter = templ.filter.get()
      templ.count.set(templ.TransitoryCollection.get().find(filter).count())
      if (typeof templ.count.get() != 'string' && templ.count.get() <= templ.limit.get()){
        templ.everythingLoaded.set(true)
      } else {
        templ.everythingLoaded.set(false)
      }
    } else {
       templ.count.set('...')
    }
  })

});

Template.returnedCurrencies.onRendered( function () {	
	// init controller
	this.controller = new scrollmagic.Controller();
  var templ = Template.instance()
	// build scene
	 var scene = new scrollmagic.Scene({triggerElement: "#loader", triggerHook: "onEnter"})
					.addTo(templ.controller)
					.on("enter", function (e) {
{'fraction_non_alphanumeric': 0.131511839708561, 'fraction_numerical': 0.0007285974499089253, 'mean_word_length': 3.564422277639235, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '1084418', 'n_tokens_mistral': 1739, 'n_tokens_neox': 1652, 'n_words': 363}