<commit_before>import {
  defineMessages,
} from 'react-intl';

const messages = defineMessages({
  facet_schema: {
    id: 'facet.schema',
    defaultMessage: '{count, plural, zero {Types} one {Type} two {Types} few {Types} many {Types} other {Types}}',
  },
  facet_collection_id: {
    id: 'facet.collection_id',
    defaultMessage: '{count, plural, zero {Datasets} one {Dataset} two {Datasets} few {Datasets} many {Datasets} other {Datasets}}',
  },
  facet_ibans: {
    id: 'facet.ibans',
    defaultMessage: '{count, plural, zero {IBANs} one {IBAN} two {IBANs} few {IBANs} many {IBANs} other {IBANs}}',
  },
  facet_languages: {
    id: 'facet.languages',
    defaultMessage: '{count, plural, zero {Languages} one {Language} two {Languages} few {Languages} many {Languages} other {Languages}}',
  },
  facet_emails: {
    id: 'facet.emails',
    defaultMessage: '{count, plural, zero {E-Mails} one {E-Mail} two {E-Mails} few {E-Mails} many {E-Mails} other {E-Mails}}',
  },
  facet_phones: {
    id: 'facet.phones',
    defaultMessage: '{count, plural, zero {Phone numbers} one {Phone number} two {Phone numbers} few {Phone numbers} many {Phone numbers} other {Phone numbers}}',
  },
  facet_countries: {
    id: 'facet.countries',
    defaultMessage: '{count, plural, zero {Countries} one {Country} two {Countries} few {Countries} many {Countries} other {Countries}}',
  },
  facet_names: {
    id: 'facet.names',
    defaultMessage: '{count, plural, zero {Names} one {Name} two {Names} few {Names} many {Names} other {Names}}',
  },
  facet_addresses: {
    id: 'facet.addresses',
    defaultMessage: '{count, plural, zero {Addresses} one {Address} two {Addresses} few {Addresses} many {Addresses} other {Addresses}}',
  },
  facet_mime_type: {
    id: 'facet.mimetypes',
    defaultMessage: '{count, plural, zero {File types} one {File type} two {File types} few {File types} many {File types} other {File types}}',
  },
  facet_category: {
    id: 'facet.category',
    defaultMessage: '{count, plural, zero {Categories} one {Category} two {Categories} few {Categories} many {Categories} other {Categories}}',
  },
});

const propConfigs = {
  addresses: {
    field: 'addresses',
    label: messages.facet_addresses,
    icon: 'map',
  },
  category: {
    field: 'category',
    label: messages.facet_category,
    icon: 'list',
    defaultSize: 1000,
  },
  collection_id: {
    field: 'collection_id',
    label: messages.facet_collection_id,
    icon: 'database',
  },
  match_collection_id: {
    field: 'match_collection_id',
    label: messages.facet_collection_id,
    icon: 'database',
    defaultSize: 10,
  },
  countries: {
    field: 'countries',
    label: messages.facet_countries,
    icon: 'globe',
    defaultSize: 1000,
  },
  emails: {
    field: 'emails',
    label: messages.facet_emails,
    icon: 'envelope',
  },
  ibans: {
    field: 'ibans',
    label: messages.facet_ibans,
    icon: 'credit-card',
  },
  languages: {
    field: 'languages',
    label: messages.facet_languages,
    icon: 'translate',
  },
  mimetypes: {
    field: 'mimetypes',
    label: messages.facet_mime_type,
    icon: 'document',
  },
  names: {
    field: 'names',
    label: messages.facet_names,
    icon: 'id-number',
  },
  phones: {
    field: 'phones',
    label: messages.facet_phones,
    icon: 'phone',
  },
  schema: {
    field: 'schema',
    label: messages.facet_schema,
    icon: 'list-columns',
    defaultSize: 1000,
  },
};

const getFacetConfig = (key) => (
  propConfigs[key]
);

export default getFacetConfig;
<commit_msg>removed additional breaking plural rules<commit_after>import {
  defineMessages,
} from 'react-intl';

const messages = defineMessages({
  facet_schema: {
    id: 'facet.schema',
    defaultMessage: '{count, plural, one {Type} other {Types}}',
  },
  facet_collection_id: {
    id: 'facet.collection_id',
    defaultMessage: '{count, plural, one {Dataset} other {Datasets}}',
  },
  facet_ibans: {
    id: 'facet.ibans',
    defaultMessage: '{count, plural, one {IBAN} other {IBANs}}',
  },
  facet_languages: {
    id: 'facet.languages',
    defaultMessage: '{count, plural, one {Language} other {Languages}}',
  },
  facet_emails: {
    id: 'facet.emails',
    defaultMessage: '{count, plural, one {E-Mail} other {E-Mails}}',
  },
  facet_phones: {
    id: 'facet.phones',
    defaultMessage: '{count, plural, one {Phone number} other {Phone numbers}}',
  },
  facet_countries: {
    id: 'facet.countries',
    defaultMessage: '{count, plural, one {Country} other {Countries}}',
  },
  facet_names: {
    id: 'facet.names',
    defaultMessage: '{count, plural, one {Name} other {Names}}',
  },
  facet_addresses: {
    id: 'facet.addresses',
    defaultMessage: '{count, plural, one {Address} other {Addresses}}',
  },
  facet_mime_type: {
    id: 'facet.mimetypes',
    defaultMessage: '{count, plural, one {File type} other {File types}}',
  },
  facet_category: {
    id: 'facet.category',
    defaultMessage: '{count, plural, one {Category} other {Categories}}',
  },
});

const propConfigs = {
  addresses: {
    field: 'addresses',
    label: messages.facet_addresses,
    icon: 'map',
  },
  category: {
    field: 'category',
    label: messages.facet_category,
    icon: 'list',
    defaultSize: 1000,
  },
  collection_id: {
    field: 'collection_id',
    label: messages.facet_collection_id,
    icon: 'database',
  },
  match_collection_id: {
    field: 'match_collection_id',
    label: messages.facet_collection_id,
    icon: 'database',
    defaultSize: 10,
  },
  countries: {
    field: 'countries',
    label: messages.facet_countries,
    icon: 'globe',
    defaultSize: 1000,
  },
  emails: {
    field: 'emails',
    label: messages.facet_emails,
    icon: 'envelope',
  },
  ibans: {
    field: 'ibans',
    label: messages.facet_ibans,
    icon: 'credit-card',
  },
  languages: {
    field: 'languages',
    label: messages.facet_languages,
    icon: 'translate',
  },
  mimetypes: {
    field: 'mimetypes',
    label: messages.facet_mime_type,
    icon: 'document',
  },
  names: {
    field: 'names',
    label: messages.facet_names,
    icon: 'id-number',
  },
  phones: {
    field: 'phones',
    label: messages.facet_phones,
    icon: 'phone',
  },
  schema: {
    field: 'schema',
    label: messages.facet_schema,
    icon: 'list-columns',
    defaultSize: 1000,
  },
};

const getFacetConfig = (key) => (
  propConfigs[key]
);

export default getFacetConfig;
<|endoftext|>


<commit_before>math.import(numbers,{wrap:true,silent:true});
[String,Array,Number,Object,RegExp,Date,s,_,XRegExp,Function].map(v=>Object.getOwnPropertyNames(v).map((x,y)=>v.prototype[String.fromCharCode(y+248)]=v.prototype[x]));
[math,String,Array,Number,Object,JSON,RegExp,Date,_,s,window,Function].map(v=>Object.getOwnPropertyNames(v).map((x,y)=>v[String.fromCharCode(y+248)]=v[x]));
//get function alias
var alias=(v,w)=>Object.getOwnPropertyNames(v).map((x,y)=>v[String.fromCharCode(y+248)]==v[w]?String.fromCharCode(y+248):0).join``.replace(/0/g,'');

var Ξ=[],//stack
		//I/O functions
		ô=i=>o.value+=i!=[]._?i:Ξ.join`\n`,//output
		ℹ=i=>[i=i!=[]._?c.value[i]:c.value,Ξ.push(i)][0],//source

		//stack functions
		ᵖ=(i=0,...r)=>{Ξ.push(i,...r)},
		ᵍ=i=>i!=[]._?Ξ[i<0?Ξ.length+i:i]:Ξ[Ξ.length-1],
		ʳ=(i=Ξ.length-1)=>Ξ.splice(i,1),
		ᶜ=i=>Ξ=[],

		//aliasing
		ị=Infinity,
		ʉ=[]._,
		ℇ=math.e,
		ε=Number.EPSILON,
		ᴉ=math.sqrt(-1),
		ɸ=(1+math.sqrt(5))/2,
		π=math.pi,
		τ=math.pi*2,
		М=math,
		Ϛ=String,
		Ѧ=Array,
		Ѩ=_,
		П=Number,
		Ø=Object,
		ʝ=JSON,
		ɼ=RegExp,
		Ɽ=XRegExp,
		ᶁ=Date,
		ש=window,
		ᶂ=Function,
		ß='toString',
		Ꝉ='length',
		ᶏ='apply',
		ᶊ=s,
		Ɱ=(i,f,s='',j='')=>typeof i=='object'?i.map(f):typeof i=='string'?i.split(s).map(f).join(j):eval((''+i).split(s).map(f).join(j)),
		ᴙ=i=>[...i].reverse().join``,
		String.prototype.ċ=(x,y='')=>this.replace(x,y),
		Մ=(i,r,o='',t)=>(t=i.replace(r,o),t!=i?Մ(t,r,o):t),
		ë=eval,
		Յ='0b',
		ᛪ='0x',
		nchars=`ḀḁḂḃḄḅḆḇḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋẌẍẎẏẐẑẒẓẔẕẖẗẘẙaʾẛẜẝẞẟẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹỺỻỼỽỾỿ`
		;

//compression stuff
shoco.c=i=>Array.prototype.map.call(shoco.compress(i),x=>String.fromCharCode(x)).join``;
shoco.d=i=>shoco.decompress(new Uint8Array((i.constructor==Array?i[0]:i).split``.map(x=>x.charCodeAt(0))));
var compress=i=>LZString.compress(shoco.c(i));

var Σ=c=>{
	var r='ᵖᵍʳôℹΣɘϚѦПØѨɼⱤƒᶁⱮᴙՄᶊëßᶏ\\u00f8-\\u0236',
			n='A-Za-z$_ãïîíìịʉℇεᴉɸπτ²³ⁿ√∛¼½¾⅐⅑⅒⅓⅔⅕⅖⅗⅘⅙⅚⅛⅜⅝⅞ᶀᶍ\\u1e00-\\u1eff',
			d='-?\\d+(?:\\.\\d*)?(?:e[+\\-]?\\d+)?';
	//syntax from esmin to es6
	c=c
		.replace(/ɘ(.+)#/g,(x,y)=>shoco.d(LZString.decompress(y)))
		.replace(/э([^]+)#/gm,(x,y)=>shoco.d(y))
		.replace(/Э(.+)#/g,(x,y)=>LZString.decompress(y))
		.replace(/ℍ/g,'00')
		.replace(/𝕜/g,'000')
		.replace(/𝕄/g,'000000')
		.replace(/𝔾/g,'000000000')
		.replace(/𝕋/g,'000000000000')
		.replace(/ℙ/g,'000000000000000')
		.replace(/𝔼/g,'000000000000000000')
		.replace(/ℤ/g,'000000000000000000000')
		.replace(/𝕐/g,'000000000000000000000000')
		.replace(/⊕/g,'⬯+')
		.replace(/⨝/g,'ø⬯')
		.replace(/ⓑ/g,'ß2')
		.replace(/⬮/g,'()')
		.replace(/⬯/g,'(``)')
		.replace(/⬭/g,'(` `)')
		.replace(/⬬/g,'(`\n`)')
		.replace(/␤/g,'\n')
		.replace(/␉/g,'\t')
		.replace(/␠/g,'\s')
		.replace(/⍘(.)/g,'(`$1`)')
		.replace(/⇝/g,'((a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z)=>')
		.replace(/⇀/g,'(($,_,ã)=>')
		.replace(/ª/g,'ᶏש,')
		.replace(eval(`/([${r}])(([${n}]|${d})+)/g`),'$1($2)')
		.replace(eval(`/([${r}])([^(\u00f8-\u0236ßꝈᶏ¤])/g`),'$1($2')
		.replace(/¤/g,'')
		.replace(eval(`/⎖(([${n}]|\\d)+)/g`),'[$1]')
		.replace(/([ïîíì])(\d+)/g,'$1[$2]')
		.replace(/⇏/g,'(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z)=>')
		.replace(/↛/g,'=(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z)=>')
		.replace(/↪/g,'($,_,ã)=>')
		.replace(/⤤/g,'=($,_,ã)=>')
		.replace(/→/g,'=>')
		.replace(/”/g,'`)')
		.replace(/‘/g,'\\`')
		.replace(/’/g,'\\`)')
		.replace(/⸩/g,'))')
		.replace(/⎞/g,'/)')
		.replace(/⦃/g,'${')
		.replace(/…/g,'...')
		.replace(eval(`/⟬([${n}]+)/g`),'[...$1]')
		.replace(/⟦/g,'[...')
		.replace(/˖/g,'+=')
		.replace(/⧺/g,'++')
		.replace(/˗/g,'-=')
		.replace(/‡/g,'--')
		.replace(/×/g,'*=')
		.replace(/÷/g,'/=')
		.replace(/٪/g,'%=')
		.replace(/¡/g,'!!')
		.replace(/≔/g,'==')
		.replace(/≠/g,'!=')
		.replace(/≤/g,'<=')
		.replace(/≥/g,'>=')
		.replace(/⅋/g,'&&')
		.replace(/⋎/g,'||')
		.replace(/↺/g,'for(')
		.replace(/ⱳ/g,'with(')
		.replace(/ᶉ/g,'return ')
		.replace(/ₙ/g,'new ')
		.replace(/ᕠ/g,'this')
		.replace(eval(`/(⦅.+|(([${n}]|${d})+))²/g`),'Math.pow($1,2)')
		.replace(eval(`/(⦅.+|(([${n}]|${d})+))³/g`),'Math.pow($1,3)')
		.replace(eval(`/(⦅.+|(([${n}]|${d})+))ⁿ(.+⦆|(([${n}]|${d})+))/g`),'Math.pow($1,$4)')
		.replace(eval(`/√(.+⦆|(([${n}]|${d})+))/g`),'Math.sqrt($1)')
		.replace(eval(`/∛(.+⦆|(([${n}]|${d})+))/g`),'Math.cbrt($1)')
		.replace(/[⦅⦆]/g,'')
		.replace(/½/g,'.5')
		.replace(/¼/g,'.25')
		.replace(/¾/g,'.75')
		.replace(/⅐/g,'(1/7)')
		.replace(/⅑/g,'(1/9)')
		.replace(/⅒/g,'0.1')
		.replace(/⅓/g,'(1/3)')
		.replace(/⅔/g,'(2/3)')
		.replace(/⅕/g,'.2')
		.replace(/⅖/g,'.4')
		.replace(/⅗/g,'.6')
		.replace(/⅘/g,'.8')
		.replace(/⅙/g,'(1/6)')
		.replace(/⅚/g,'(5/6)')
		.replace(/⅛/g,'(1/8)')
		.replace(/⅜/g,'(3/8)')
		.replace(/⅝/g,'(5/8)')
		.replace(/⅞/g,'(7/8)')
		.replace(/ᶀ/g,'0b')
		.replace(/ᶍ/g,'0x')
		.replace(/Ⅹ/g,'10')
		.replace(/([^.])([\u00f8-\u0236])/g,'$1["$2"]')
		.replace(/([ßꝈᶏ])/g,'[$1]')
		.replace(/⑴/g,'$1')
		.replace(/⑵/g,'$2')
		.replace(/⑶/g,'$3')
		.replace(/⊙/g,'(.)')
		.replace(/⁅/g,'[^')
		.replace(/α/g,'a-z')
		.replace(/𝚨/g,'A-Z')
		.replace(/𐄫/g,'0-9')
		.replace(/ᶌ/g,'aeiou')
		.replace(/⌿/g,'/g')
		.replace(/⍀/g,'/ig')
		.replace(/⊨/g,'true')
		.replace(/⊭/g,'false')
		.replace(/␀/g,'null')
		.replace(/«/g,'<<')
		.replace(/»/g,'>>')
		.replace(/⫸/g,'>>>')
		.replace(/˜/g,'~~')
	;
	if(!c.match(/ô/g)&&c.match(/ᵖ/g)){c+=';ô()',console.log(c),eval(c);return}
	else if(Ξ.length<1&&!c.match(/ô/g)){console.log(c),o.value=eval(c);return}
	else console.log(c),eval(c);
}
<commit_msg>bug fix<commit_after>math.import(numbers,{wrap:true,silent:true});
[String,Array,Number,Object,RegExp,Date,s,_,XRegExp,Function].map(v=>Object.getOwnPropertyNames(v).map((x,y)=>v.prototype[String.fromCharCode(y+248)]=v.prototype[x]));
[math,String,Array,Number,Object,JSON,RegExp,Date,_,s,window,Function].map(v=>Object.getOwnPropertyNames(v).map((x,y)=>v[String.fromCharCode(y+248)]=v[x]));
//get function alias
var alias=(v,w)=>Object.getOwnPropertyNames(v).map((x,y)=>v[String.fromCharCode(y+248)]==v[w]?String.fromCharCode(y+248):0).join``.replace(/0/g,'');

var Ξ=[],//stack
		//I/O functions
		ô=i=>o.value+=i!=[]._?i:Ξ.join`\n`,//output
		ℹ=i=>[i=i!=[]._?c.value[i]:c.value,Ξ.push(i)][0],//source

		//stack functions
		ᵖ=(i=0,...r)=>{Ξ.push(i,...r)},
		ᵍ=i=>i!=[]._?Ξ[i<0?Ξ.length+i:i]:Ξ[Ξ.length-1],
		ʳ=(i=Ξ.length-1)=>Ξ.splice(i,1),
		ᶜ=i=>Ξ=[],

		//aliasing
		ị=Infinity,
		ʉ=[]._,
		ℇ=math.e,
		ε=Number.EPSILON,
		ᴉ=math.sqrt(-1),
		ɸ=(1+math.sqrt(5))/2,
		π=math.pi,
		τ=math.pi*2,
		М=math,
		Ϛ=String,
		Ѧ=Array,
		Ѩ=_,
		П=Number,
		Ø=Object,
		ʝ=JSON,
		ɼ=RegExp,
		Ɽ=XRegExp,
		ᶁ=Date,
		ש=window,
		ᶂ=Function,
		ß='toString',
		Ꝉ='length',
		ᶏ='apply',
		ᶊ=s,
		Ɱ=(i,f,s='',j='')=>typeof i=='object'?i.map(f):typeof i=='string'?i.split(s).map(f).join(j):eval((''+i).split(s).map(f).join(j)),
		ᴙ=i=>[...i].reverse().join``;
String.prototype.ċ=(x,y='')=>this.replace(x,y);
var Մ=(i,r,o='',t)=>(t=i.replace(r,o),t!=i?Մ(t,r,o):t),
		ë=eval,
		Յ='0b',
		ᛪ='0x',
		nchars=`ḀḁḂḃḄḅḆḇḈḉḊḋḌḍḎḏḐḑḒḓḔḕḖḗḘḙḚḛḜḝḞḟḠḡḢḣḤḥḦḧḨḩḪḫḬḭḮḯḰḱḲḳḴḵḶḷḸḹḺḻḼḽḾḿṀṁṂṃṄṅṆṇṈṉṊṋṌṍṎṏṐṑṒṓṔṕṖṗṘṙṚṛṜṝṞṟṠṡṢṣṤṥṦṧṨṩṪṫṬṭṮṯṰṱṲṳṴṵṶṷṸṹṺṻṼṽṾṿẀẁẂẃẄẅẆẇẈẉẊẋẌẍẎẏẐẑẒẓẔẕẖẗẘẙaʾẛẜẝẞẟẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹỺỻỼỽỾỿ`
		;

//compression stuff
shoco.c=i=>Array.prototype.map.call(shoco.compress(i),x=>String.fromCharCode(x)).join``;
shoco.d=i=>shoco.decompress(new Uint8Array((i.constructor==Array?i[0]:i).split``.map(x=>x.charCodeAt(0))));
var compress=i=>LZString.compress(shoco.c(i));

var Σ=c=>{
	var r='ᵖᵍʳôℹΣɘϚѦПØѨɼⱤƒᶁⱮᴙՄᶊëßᶏ\\u00f8-\\u0236',
			n='A-Za-z$_ãïîíìịʉℇεᴉɸπτ²³ⁿ√∛¼½¾⅐⅑⅒⅓⅔⅕⅖⅗⅘⅙⅚⅛⅜⅝⅞ᶀᶍ\\u1e00-\\u1eff',
			d='-?\\d+(?:\\.\\d*)?(?:e[+\\-]?\\d+)?';
	//syntax from esmin to es6
	c=c
		.replace(/ɘ(.+)#/g,(x,y)=>shoco.d(LZString.decompress(y)))
		.replace(/э([^]+)#/gm,(x,y)=>shoco.d(y))
		.replace(/Э(.+)#/g,(x,y)=>LZString.decompress(y))
		.replace(/ℍ/g,'00')
		.replace(/𝕜/g,'000')
		.replace(/𝕄/g,'000000')
		.replace(/𝔾/g,'000000000')
		.replace(/𝕋/g,'000000000000')
		.replace(/ℙ/g,'000000000000000')
		.replace(/𝔼/g,'000000000000000000')
		.replace(/ℤ/g,'000000000000000000000')
		.replace(/𝕐/g,'000000000000000000000000')
		.replace(/⊕/g,'⬯+')
		.replace(/⨝/g,'ø⬯')
		.replace(/ⓑ/g,'ß2')
		.replace(/⬮/g,'()')
		.replace(/⬯/g,'(``)')
		.replace(/⬭/g,'(` `)')
		.replace(/⬬/g,'(`\n`)')
		.replace(/␤/g,'\n')
		.replace(/␉/g,'\t')
		.replace(/␠/g,'\s')
		.replace(/⍘(.)/g,'(`$1`)')
		.replace(/⇝/g,'((a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z)=>')
		.replace(/⇀/g,'(($,_,ã)=>')
		.replace(/ª/g,'ᶏש,')
		.replace(eval(`/([${r}])(([${n}]|${d})+)/g`),'$1($2)')
		.replace(eval(`/([${r}])([^(\u00f8-\u0236ßꝈᶏ¤])/g`),'$1($2')
		.replace(/¤/g,'')
		.replace(eval(`/⎖(([${n}]|\\d)+)/g`),'[$1]')
		.replace(/([ïîíì])(\d+)/g,'$1[$2]')
		.replace(/⇏/g,'(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z)=>')
		.replace(/↛/g,'=(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z)=>')
		.replace(/↪/g,'($,_,ã)=>')
		.replace(/⤤/g,'=($,_,ã)=>')
		.replace(/→/g,'=>')
		.replace(/”/g,'`)')
		.replace(/‘/g,'\\`')
		.replace(/’/g,'\\`)')
		.replace(/⸩/g,'))')
		.replace(/⎞/g,'/)')
		.replace(/⦃/g,'${')
		.replace(/…/g,'...')
		.replace(eval(`/⟬([${n}]+)/g`),'[...$1]')
		.replace(/⟦/g,'[...')
		.replace(/˖/g,'+=')
		.replace(/⧺/g,'++')
		.replace(/˗/g,'-=')
		.replace(/‡/g,'--')
		.replace(/×/g,'*=')
		.replace(/÷/g,'/=')
		.replace(/٪/g,'%=')
		.replace(/¡/g,'!!')
		.replace(/≔/g,'==')
		.replace(/≠/g,'!=')
		.replace(/≤/g,'<=')
		.replace(/≥/g,'>=')
		.replace(/⅋/g,'&&')
		.replace(/⋎/g,'||')
		.replace(/↺/g,'for(')
		.replace(/ⱳ/g,'with(')
		.replace(/ᶉ/g,'return ')
		.replace(/ₙ/g,'new ')
		.replace(/ᕠ/g,'this')
		.replace(eval(`/(⦅.+|(([${n}]|${d})+))²/g`),'Math.pow($1,2)')
		.replace(eval(`/(⦅.+|(([${n}]|${d})+))³/g`),'Math.pow($1,3)')
		.replace(eval(`/(⦅.+|(([${n}]|${d})+))ⁿ(.+⦆|(([${n}]|${d})+))/g`),'Math.pow($1,$4)')
		.replace(eval(`/√(.+⦆|(([${n}]|${d})+))/g`),'Math.sqrt($1)')
		.replace(eval(`/∛(.+⦆|(([${n}]|${d})+))/g`),'Math.cbrt($1)')
		.replace(/[⦅⦆]/g,'')
		.replace(/½/g,'.5')
		.replace(/¼/g,'.25')
		.replace(/¾/g,'.75')
		.replace(/⅐/g,'(1/7)')
		.replace(/⅑/g,'(1/9)')
		.replace(/⅒/g,'0.1')
		.replace(/⅓/g,'(1/3)')
		.replace(/⅔/g,'(2/3)')
		.replace(/⅕/g,'.2')
		.replace(/⅖/g,'.4')
		.replace(/⅗/g,'.6')
		.replace(/⅘/g,'.8')
		.replace(/⅙/g,'(1/6)')
		.replace(/⅚/g,'(5/6)')
		.replace(/⅛/g,'(1/8)')
		.replace(/⅜/g,'(3/8)')
		.replace(/⅝/g,'(5/8)')
		.replace(/⅞/g,'(7/8)')
		.replace(/ᶀ/g,'0b')
		.replace(/ᶍ/g,'0x')
		.replace(/Ⅹ/g,'10')
		.replace(/([^.])([\u00f8-\u0236])/g,'$1["$2"]')
		.replace(/([ßꝈᶏ])/g,'[$1]')
		.replace(/⑴/g,'$1')
		.replace(/⑵/g,'$2')
		.replace(/⑶/g,'$3')
		.replace(/⊙/g,'(.)')
		.replace(/⁅/g,'[^')
		.replace(/α/g,'a-z')
		.replace(/𝚨/g,'A-Z')
		.replace(/𐄫/g,'0-9')
		.replace(/ᶌ/g,'aeiou')
		.replace(/⌿/g,'/g')
		.replace(/⍀/g,'/ig')
		.replace(/⊨/g,'true')
		.replace(/⊭/g,'false')
		.replace(/␀/g,'null')
		.replace(/«/g,'<<')
		.replace(/»/g,'>>')
		.replace(/⫸/g,'>>>')
		.replace(/˜/g,'~~')
	;
	if(!c.match(/ô/g)&&c.match(/ᵖ/g)){c+=';ô()',console.log(c),eval(c);return}
	else if(Ξ.length<1&&!c.match(/ô/g)){console.log(c),o.value=eval(c);return}
	else console.log(c),eval(c);
}
<|endoftext|>


<commit_before>import React from 'react';

import { Anomoly, Gao, Zerotorescue, Abelito75, niseko, blazyb, JeremyDwayne } from 'CONTRIBUTORS';
import SPELLS from 'common/SPELLS';
import SpellLink from 'common/SpellLink';
import { change, date } from 'common/changelog';

export default [
  change(date(2019, 11, 25), <>Added a Essence Font healing breakdown donut. </>,Abelito75),
  change(date(2019, 11, 25), <>Fixed upwelling randomly bugging out. </>,Abelito75),
  change(date(2019, 11, 20), <>Added Uplift revival reduction to rising mist tooltip. </>,Abelito75),
  change(date(2019, 11, 16), <>Updated a few spells to use new methods. </>,Abelito75),
  change(date(2019, 11, 12), <>Big Rising Mist overhaul. Now includes extra Vivify cleaves, Enveloping Mist, and Gusts Of mist hits from Essence Font's Hot. </>,Abelito75),
  change(date(2019, 11, 9), <>Added upwelling statistic. </>,Abelito75),
  change(date(2019, 11, 9), <>Fixed Tier45 comparison if you didn't play in a way where mana would be returned/saved. </>,Abelito75),
  change(date(2019, 10, 14), <>Fixed small typos for rising mist statistic box. </>,Abelito75),
  change(date(2019, 10, 14), <>Spelling and grammar corrections in Tier 45 comparison tool. </>,JeremyDwayne),
  change(date(2019, 10, 13), <>Fixed Tier 45 comparison tool. </>,Abelito75),
  change(date(2019, 10, 13), <>New Tier 45 comparison tool to see if you picked the best talent for your playstyle. </>,Abelito75),
  change(date(2019, 10, 4), <>Added missing array declaration for enemiesHitSCK <SpellLink id={SPELLS.SPINNING_CRANE_KICK.id} />.</>, JeremyDwayne),
  change(date(2019, 10, 1), <>Bugfix for Lifecycles adding the potential mana reduction from an empowered <SpellLink id={SPELLS.VIVIFY.id} /> </>,Anomoly),
  change(date(2019, 9, 27), <>Update to date for 8.2.5 </>,Abelito75),
  change(date(2019, 8, 17), <>Fixed bug where you could have NaN mana tea overhealing.</>, Abelito75),
  change(date(2019, 8, 14), <>Wotc infographic now checks for physical damage only.</>, Abelito75),
  change(date(2019, 8, 12), 'Added essence Lucid Dreams.', [blazyb]),
  change(date(2019, 8, 10), <>Fixed bug where if you end the fight with wotc buff it said everything was 0 hps. Added more info the the wotc infographic.</>, Abelito75),
  change(date(2019, 8, 6), <>Valid for 8.2</>, Abelito75),
  change(date(2019, 8, 2), <>Fixed trait calculations being unaffected by healing increases or decreases.</>, niseko),
  change(date(2019, 7, 23), <>Fixed strange bug with mana tea where if you didn't have it selected it crashed the Overview tab</>, Abelito75),
  change(date(2019, 7, 18), <>Made <SpellLink id={SPELLS.WAY_OF_THE_CRANE.id} /> infographic.</>, Abelito75),
  change(date(2019, 7, 2), <><SpellLink id={SPELLS.MANA_TEA_TALENT.id} /> rewrite. Includes all spells</>, Abelito75),
  change(date(2019, 7, 2), <>Added <SpellLink id={SPELLS.WAY_OF_THE_CRANE.id} /> to the cooldowns tab.</>, [Anomoly]),
  change(date(2019, 6, 1), <>Added a check to make sure you using <SpellLink id={SPELLS.SOOTHING_MIST.id} /> efficiency while channeling it.</>, [Abelito75]),
  change(date(2019, 3, 30), <>Added a check to make sure you cast <SpellLink id={SPELLS.SPINNING_CRANE_KICK.id} /> when there are enough targets around.</>, [Abelito75]),
  change(date(2019, 3, 23), <>Updated <SpellLink id={SPELLS.MANA_TEA_TALENT.id} /> to check if you have innervate before counting mana.</>, [Abelito75]),
  change(date(2019, 3, 21), <>Updated mastery tracking to more accurately reflect the spell that triggered the <SpellLink id={SPELLS.GUSTS_OF_MISTS.id} />. This includes updates to the statistic and healing efficiency sections.</>, [Abelito75]),
  change(date(2019, 3, 15), <>Updated Mistweaver Spreadsheet tab to include  <SpellLink id={SPELLS.REFRESHING_JADE_WIND_TALENT.id} /> efficiency.</>, [Abelito75]),
  change(date(2019, 3, 15), <>Added SI to buffs to buffs module to track  <SpellLink id={SPELLS.SECRET_INFUSION.id} />.</>, [Abelito75]),
  change(date(2019, 3, 11), 'Added new Buffs module to track and highlight Mistweaver specific buffs on the timeline', [Anomoly]),
  change(date(2019, 3, 11), 'Updated look and feel of Mistweaver Azerite traits to conform to new 3.0 style.', [Anomoly]),
  change(date(2019, 3, 10), <>Added overhealing check for <SpellLink id={SPELLS.MANA_TEA_TALENT.id} />.</>, [Abelito75]),
  change(date(2019, 2, 25), <>Added statistics, suggestion, and checklist item for  <SpellLink id={SPELLS.SUMMON_JADE_SERPENT_STATUE_TALENT.id} /> casting uptime.</>, [Anomoly]),
  change(date(2019, 2, 21), <>Added statistics for tracking the average stat gain from <SpellLink id={SPELLS.SECRET_INFUSION.id} />.</>, [Anomoly]),
  change(date(2019, 2, 7), <>Added statistics for tracking the number of <SpellLink id={SPELLS.RENEWING_MIST.id} /> during <SpellLink id={SPELLS.VIVIFY.id} /> casts. Also, did a quick bug fix for the Monk Spreadsheet import.</>, [Anomoly]),
  change(date(2019, 2, 7), <>Added statistics, suggestions, and checklist item for tracking the number of <SpellLink id={SPELLS.RENEWING_MIST.id} /> during <SpellLink id={SPELLS.MANA_TEA_TALENT.id} />. Also, adding some additional tooltips to the Healing Efficiency page.</>, [Anomoly]),
  change(date(2019, 1, 21), <>Ignore cooldown errors caused by <SpellLink id={SPELLS.FONT_OF_LIFE.id} /> (it is not detectable in logs so we can't make it 100% accurate).</>, [Zerotorescue]),
  change(date(2019, 1, 21), <>Fixed a bug where <SpellLink id={SPELLS.SOOTHING_MIST.id} /> incorrectly triggered two GCDs, making downtime off.</>, [Zerotorescue]),
  change(date(2018, 11, 14), <>Added <SpellLink id={SPELLS.GUSTS_OF_MISTS.id}>Gusts of Mists</SpellLink> breakdown chart. Fixed bug with the ReM and Vivify mana efficiency.</>, [Gao]),
  change(date(2018, 11, 2), <>Added the mana efficiency tab. Updated the Env:Viv cast ratio picture sizes.</>, [Gao]),
  change(date(2018, 10, 30), <>Fixed an bug with <SpellLink id={SPELLS.MANA_TEA_TALENT.id} /> suggestion not displaying the correct mana saved amount.</>, [Anomoly]),
  change(date(2018, 9, 11), <>Added <SpellLink id={SPELLS.SUMMON_JADE_SERPENT_STATUE_TALENT.id} /> to spreadsheet tab for use importing into Monk spreadsheet.</>, [Anomoly]),
  change(date(2018, 9, 11), <>Fixed <SpellLink id={SPELLS.SOOTHING_MIST.id} /> channeling time to be taken into account with Downtime statistic and suggestion.</>, [Anomoly]),
  change(date(2018, 9, 11), 'Added healing contribution statistic box for the Mistweaver Specific Azerite traits.', [Anomoly]),
  change(date(2018, 9, 8), 'Updated Checklist to leverage new format and included updates to the suggestions and thresholds. Cleaned up unused legendary files also.', [Anomoly]),
  change(date(2018, 9, 7), 'Updated Player Log Data tab to include fixes and additional data needed to support the BfA Mistweaver Monk spreadsheet.', [Anomoly]),
  change(date(2018, 9, 5), <>Fixed mana cost of all spells. Updated suggestion for <SpellLink id={SPELLS.LIFECYCLES_TALENT.id} /> usage and removed <SpellLink id={SPELLS.SOOTHING_MIST.id} /> suggestion from the analyzer.</>, [Anomoly]),
  change(date(2018, 7, 22), <>Fix crash when Drape of Shame is used.</>, [Anomoly]),
  change(date(2018, 7, 20), 'Pre-Patch Updates: Removed Effuse from the analyzer as the ability was removed in BfA. Updated Mana Costs of spells to use fixed cost versus a percentage of max mana.', [Anomoly]),
  change(date(2018, 7, 19), 'Pre-Patch Updates: Removed Uplifting Trance, Updated Renewing Mist Cooldown, Removed Essence Font from Thunder Focus Tea statistics, Removed Thunder Focus Tea suggestion for now as correct use is being defined', [Anomoly]),
  change(date(2018, 7, 1), 'Trait and Artifact clean up along with GCD changes in Abilities for Battle for Azeroth', [Anomoly]),
  change(date(2018, 6, 15), 'Updated Vivify to incorporate new healing interaction with Renewing Mist. Updated Renewing Mist change to now be a 2 charge spell.', [Anomoly]),
];
<commit_msg>Changelog!<commit_after>import React from 'react';

import { Anomoly, Gao, Zerotorescue, Abelito75, niseko, blazyb, JeremyDwayne } from 'CONTRIBUTORS';
import SPELLS from 'common/SPELLS';
import SpellLink from 'common/SpellLink';
import { change, date } from 'common/changelog';

export default [
  change(date(2019, 12, 5), <>Updated stat weight calculation for <SpellLink id={SPELLS.WAY_OF_THE_CRANE.id} /> and Lucid Dreams. </>,Anomoly),
  change(date(2019, 11, 25), <>Added a Essence Font healing breakdown donut. </>,Abelito75),
  change(date(2019, 11, 25), <>Fixed upwelling randomly bugging out. </>,Abelito75),
  change(date(2019, 11, 20), <>Added Uplift revival reduction to rising mist tooltip. </>,Abelito75),
  change(date(2019, 11, 16), <>Updated a few spells to use new methods. </>,Abelito75),
  change(date(2019, 11, 12), <>Big Rising Mist overhaul. Now includes extra Vivify cleaves, Enveloping Mist, and Gusts Of mist hits from Essence Font's Hot. </>,Abelito75),
  change(date(2019, 11, 9), <>Added upwelling statistic. </>,Abelito75),
  change(date(2019, 11, 9), <>Fixed Tier45 comparison if you didn't play in a way where mana would be returned/saved. </>,Abelito75),
  change(date(2019, 10, 14), <>Fixed small typos for rising mist statistic box. </>,Abelito75),
  change(date(2019, 10, 14), <>Spelling and grammar corrections in Tier 45 comparison tool. </>,JeremyDwayne),
  change(date(2019, 10, 13), <>Fixed Tier 45 comparison tool. </>,Abelito75),
  change(date(2019, 10, 13), <>New Tier 45 comparison tool to see if you picked the best talent for your playstyle. </>,Abelito75),
  change(date(2019, 10, 4), <>Added missing array declaration for enemiesHitSCK <SpellLink id={SPELLS.SPINNING_CRANE_KICK.id} />.</>, JeremyDwayne),
  change(date(2019, 10, 1), <>Bugfix for Lifecycles adding the potential mana reduction from an empowered <SpellLink id={SPELLS.VIVIFY.id} /> </>,Anomoly),
  change(date(2019, 9, 27), <>Update to date for 8.2.5 </>,Abelito75),
  change(date(2019, 8, 17), <>Fixed bug where you could have NaN mana tea overhealing.</>, Abelito75),
  change(date(2019, 8, 14), <>Wotc infographic now checks for physical damage only.</>, Abelito75),
  change(date(2019, 8, 12), 'Added essence Lucid Dreams.', [blazyb]),
  change(date(2019, 8, 10), <>Fixed bug where if you end the fight with wotc buff it said everything was 0 hps. Added more info the the wotc infographic.</>, Abelito75),
  change(date(2019, 8, 6), <>Valid for 8.2</>, Abelito75),
  change(date(2019, 8, 2), <>Fixed trait calculations being unaffected by healing increases or decreases.</>, niseko),
  change(date(2019, 7, 23), <>Fixed strange bug with mana tea where if you didn't have it selected it crashed the Overview tab</>, Abelito75),
  change(date(2019, 7, 18), <>Made <SpellLink id={SPELLS.WAY_OF_THE_CRANE.id} /> infographic.</>, Abelito75),
  change(date(2019, 7, 2), <><SpellLink id={SPELLS.MANA_TEA_TALENT.id} /> rewrite. Includes all spells</>, Abelito75),
  change(date(2019, 7, 2), <>Added <SpellLink id={SPELLS.WAY_OF_THE_CRANE.id} /> to the cooldowns tab.</>, [Anomoly]),
  change(date(2019, 6, 1), <>Added a check to make sure you using <SpellLink id={SPELLS.SOOTHING_MIST.id} /> efficiency while channeling it.</>, [Abelito75]),
  change(date(2019, 3, 30), <>Added a check to make sure you cast <SpellLink id={SPELLS.SPINNING_CRANE_KICK.id} /> when there are enough targets around.</>, [Abelito75]),
  change(date(2019, 3, 23), <>Updated <SpellLink id={SPELLS.MANA_TEA_TALENT.id} /> to check if you have innervate before counting mana.</>, [Abelito75]),
  change(date(2019, 3, 21), <>Updated mastery tracking to more accurately reflect the spell that triggered the <SpellLink id={SPELLS.GUSTS_OF_MISTS.id} />. This includes updates to the statistic and healing efficiency sections.</>, [Abelito75]),
  change(date(2019, 3, 15), <>Updated Mistweaver Spreadsheet tab to include  <SpellLink id={SPELLS.REFRESHING_JADE_WIND_TALENT.id} /> efficiency.</>, [Abelito75]),
  change(date(2019, 3, 15), <>Added SI to buffs to buffs module to track  <SpellLink id={SPELLS.SECRET_INFUSION.id} />.</>, [Abelito75]),
  change(date(2019, 3, 11), 'Added new Buffs module to track and highlight Mistweaver specific buffs on the timeline', [Anomoly]),
  change(date(2019, 3, 11), 'Updated look and feel of Mistweaver Azerite traits to conform to new 3.0 style.', [Anomoly]),
  change(date(2019, 3, 10), <>Added overhealing check for <SpellLink id={SPELLS.MANA_TEA_TALENT.id} />.</>, [Abelito75]),
  change(date(2019, 2, 25), <>Added statistics, suggestion, and checklist item for  <SpellLink id={SPELLS.SUMMON_JADE_SERPENT_STATUE_TALENT.id} /> casting uptime.</>, [Anomoly]),
  change(date(2019, 2, 21), <>Added statistics for tracking the average stat gain from <SpellLink id={SPELLS.SECRET_INFUSION.id} />.</>, [Anomoly]),
  change(date(2019, 2, 7), <>Added statistics for tracking the number of <SpellLink id={SPELLS.RENEWING_MIST.id} /> during <SpellLink id={SPELLS.VIVIFY.id} /> casts. Also, did a quick bug fix for the Monk Spreadsheet import.</>, [Anomoly]),
  change(date(2019, 2, 7), <>Added statistics, suggestions, and checklist item for tracking the number of <SpellLink id={SPELLS.RENEWING_MIST.id} /> during <SpellLink id={SPELLS.MANA_TEA_TALENT.id} />. Also, adding some additional tooltips to the Healing Efficiency page.</>, [Anomoly]),
  change(date(2019, 1, 21), <>Ignore cooldown errors caused by <SpellLink id={SPELLS.FONT_OF_LIFE.id} /> (it is not detectable in logs so we can't make it 100% accurate).</>, [Zerotorescue]),
  change(date(2019, 1, 21), <>Fixed a bug where <SpellLink id={SPELLS.SOOTHING_MIST.id} /> incorrectly triggered two GCDs, making downtime off.</>, [Zerotorescue]),
  change(date(2018, 11, 14), <>Added <SpellLink id={SPELLS.GUSTS_OF_MISTS.id}>Gusts of Mists</SpellLink> breakdown chart. Fixed bug with the ReM and Vivify mana efficiency.</>, [Gao]),
  change(date(2018, 11, 2), <>Added the mana efficiency tab. Updated the Env:Viv cast ratio picture sizes.</>, [Gao]),
  change(date(2018, 10, 30), <>Fixed an bug with <SpellLink id={SPELLS.MANA_TEA_TALENT.id} /> suggestion not displaying the correct mana saved amount.</>, [Anomoly]),
  change(date(2018, 9, 11), <>Added <SpellLink id={SPELLS.SUMMON_JADE_SERPENT_STATUE_TALENT.id} /> to spreadsheet tab for use importing into Monk spreadsheet.</>, [Anomoly]),
  change(date(2018, 9, 11), <>Fixed <SpellLink id={SPELLS.SOOTHING_MIST.id} /> channeling time to be taken into account with Downtime statistic and suggestion.</>, [Anomoly]),
  change(date(2018, 9, 11), 'Added healing contribution statistic box for the Mistweaver Specific Azerite traits.', [Anomoly]),
  change(date(2018, 9, 8), 'Updated Checklist to leverage new format and included updates to the suggestions and thresholds. Cleaned up unused legendary files also.', [Anomoly]),
  change(date(2018, 9, 7), 'Updated Player Log Data tab to include fixes and additional data needed to support the BfA Mistweaver Monk spreadsheet.', [Anomoly]),
  change(date(2018, 9, 5), <>Fixed mana cost of all spells. Updated suggestion for <SpellLink id={SPELLS.LIFECYCLES_TALENT.id} /> usage and removed <SpellLink id={SPELLS.SOOTHING_MIST.id} /> suggestion from the analyzer.</>, [Anomoly]),
  change(date(2018, 7, 22), <>Fix crash when Drape of Shame is used.</>, [Anomoly]),
  change(date(2018, 7, 20), 'Pre-Patch Updates: Removed Effuse from the analyzer as the ability was removed in BfA. Updated Mana Costs of spells to use fixed cost versus a percentage of max mana.', [Anomoly]),
  change(date(2018, 7, 19), 'Pre-Patch Updates: Removed Uplifting Trance, Updated Renewing Mist Cooldown, Removed Essence Font from Thunder Focus Tea statistics, Removed Thunder Focus Tea suggestion for now as correct use is being defined', [Anomoly]),
  change(date(2018, 7, 1), 'Trait and Artifact clean up along with GCD changes in Abilities for Battle for Azeroth', [Anomoly]),
  change(date(2018, 6, 15), 'Updated Vivify to incorporate new healing interaction with Renewing Mist. Updated Renewing Mist change to now be a 2 charge spell.', [Anomoly]),
];
<|endoftext|>


<commit_before>dojo.provide("dojox.fx.style");
dojo.experimental("dojox.fx.style");
//
// summary: dojox.fx CSS Class _Animations:
//
// description: a set of functions to animate properties based on
// 	normalized CSS class definitions.
//
//	provides: addClass, removeClass, and toggleClass
//
dojo.require("dojox.fx._base");

// FIXME: should the call signatures match dojo.addClass/removeClass/toggleClass and extend
// 	by having a third (or fourth) param to mix in additional _Animation args for advanced
//	usage (delay: curve: repeat: easing: etc ... )

dojox.fx.addClass = function(/*dojox.fx._arg.StyleArgs*/ args){
	// summary: Animate the effects of adding a class to a node
	// description:
	//	Creates an animation that will animate
	//	the properties of a node to the properties
	//	defined in a standard CSS .class definition.
	//	(calculating the differences itself)
	//
	// example:
	// |
	// |	.bar { line-height: 12px; }
	// |	.foo { line-height: 40px; }
	// |

	// |	Multi
line
text
	// |

	// |
	// |	// animate to line-height:40px
	// |	dojo.fx.addClass({ node:"test", cssClass:"foo" }).play();
	//
	var node = (args.node = dojo.byId(args.node));

	var pushClass = (function(n){
		// summary: onEnd we want to add the class to the node
		//	(as dojo.addClass naturally would) in case our
		//	class parsing misses anything the browser would
		// 	otherwise interpret. this may cause some flicker,
		//	and will only apply the class so children can inherit
		//	after the animation is done (potentially more flicker)
		return function(){
			dojo.addClass(n, args.cssClass);
			n.style.cssText = _beforeStyle;
		}
	})(node);

	// _getCalculatedStleChanges is the core of our style/class animations
	var mixedProperties = dojox.fx._getCalculatedStyleChanges(args,true);
	var _beforeStyle = node.style.cssText;
	var _anim = dojo.animateProperty(dojo.mixin({
		properties: mixedProperties
	},args));
	dojo.connect(_anim,"onEnd",_anim,pushClass);
	return _anim; // dojo._Animation
};

dojox.fx.removeClass = function(/*dojox.fx._arg.StyleArgs*/ args){
	// summary: Animate the effects of removing a class from a node
	// description:
	//	Creates an animation that will animate the properties of a
	// 	node (args.node) to the properties calculated after removing
	//	a standard CSS className from a that node.
	//
	//	calls dojo.removeClass(args.cssClass) onEnd of animation
	//
	//	standard dojo._Animation object rules apply.
	//
	// example:
	// |	// animate the removal of "foo" from a node with id="bar"
	// |	dojox.fx.removeClass({
	// |		node: "bar",
	// |		cssClass: "foo"
	// |	}).play();

	var node = (args.node = dojo.byId(args.node));

	var pullClass = (function(n){
		// summary: onEnd we want to remove the class from the node
		//	(as dojo.removeClass naturally would) in case our class
		//	parsing misses anything the browser would otherwise
		//	interpret. this may cause some flicker, and will only
		//	apply the class so children can inherit after the
		//	animation is done (potentially more flicker)
		//
		return function(){
			dojo.removeClass(n, args.cssClass);
			n.style.cssText = _beforeStyle;
		}
	})(node);

	var mixedProperties = dojox.fx._getCalculatedStyleChanges(args,false);
	var _beforeStyle = node.style.cssText;
	var _anim = dojo.animateProperty(dojo.mixin({
		properties: mixedProperties
	},args));
	dojo.connect(_anim,"onEnd",_anim,pullClass);
	return _anim; // dojo._Animation
};

dojox.fx.toggleClass = function(/*DomNode|String*/node, /*String*/cssClass, /*Boolean?*/condition){
        // summary:
	//	Animate the effects of Toggling a class on a Node
	//
	// description:
	//	creates an animation that will animate the effect of
	//	toggling a class on or off of a node.
        //	Adds a class to node if not present, or removes if present.
        //	Pass a boolean condition if you want to explicitly add or remove.
	// node:
	//	The domNode (or string of the id) to toggle
	// cssClass:
	//	String of the classname to add to the node
        // condition:
        //	If passed, true means to add the class, false means to remove.
	//
	// example:
	// |	// add the class "sampleClass" to a node id="theNode"
	// |	dojox.fx.toggleClass("theNode","sampleClass",true).play();
	// example:
	// |	// toggle the class "sampleClass" on the node id="theNode"
	// |	dojox.fx.toggleClass("theNode","sampleClass").play();

        if(typeof condition == "undefined"){
                condition = !dojo.hasClass(node, cssClass);
        }
        return dojox.fx[(condition ? "addClass" : "removeClass")]({ node: node, cssClass:cssClass }); // dojo._Animation
	// TODO: support 4th param animMixin to allow passing of easing and duration and other _Animtion options
};

dojox.fx._allowedProperties = [
	// summary: Our pseudo map of properties we will check for.
	// description:
	//	it should be much more intuitive. a way to normalize and
	//	"predict" intent, or even something more clever ...
	//	open to suggestions.

	// no-brainers:
	"width",
	"height",
	// only if position = absolute || relative?
	"left", "top", // "right", "bottom",
	// these need to be filtered through dojo.colors?
	// "background", // normalize to:
	/* "backgroundImage", */
	// "backgroundPosition", // FIXME: to be effective, this needs "#px #px"?
	"backgroundColor",

	"color",

	// "border",
	"borderBottomColor", "borderBottomWidth",
	"borderTopColor","borderTopWidth",
	"borderLeftColor","borderLeftWidth",
	"borderRightColor","borderRightWidth",

	// "padding", // normalize to:
	"paddingLeft", "paddingRight", "paddingTop", "paddingBottom",
	// "margin", // normalize to:
	"marginLeft", "marginTop", "marginRight", "marginBottom",

	// unit import/delicate?:
	"lineHeight",
	"letterSpacing",
	"fontSize"
];

dojox.fx._getStyleSnapshot = function(/* Object */cache){
	// summary:
	//	uses a dojo.getComputedStyle(node) cache reference and
	// 	iterates through the 'documented/supported animate-able'
	// 	properties.
	//
	// returns:  Array
	//	an array of raw, calculcated values (no keys), to be normalized/compared
	//	elsewhere
	return dojo.map(dojox.fx._allowedProperties,function(style){
		return cache[style]; // String
	}); // Array
};

dojox.fx._getCalculatedStyleChanges = function(/*dojox.fx._arg.StyleArgs*/ args, /*Boolean*/addClass){
	// summary: calclate the difference in style properties between two states
	// description:
	//	calculate and normalize(?) the differences between two states
	//	of a node (args.node) by quickly adding or removing a class, and
	//	iterateing over the results of dojox.fx._getStyleSnapshot()
	//
	// addClass:
	// 	true to calculate what adding a class would do,
	// 	false to calculate what removing the class would do

	var node = (args.node = dojo.byId(args.node));
	var cs = dojo.getComputedStyle(node);

	// take our snapShots
	var _before = dojox.fx._getStyleSnapshot(cs);
	dojo[(addClass ? "addClass" : "removeClass")](node,args.cssClass);
	var _after = dojox.fx._getStyleSnapshot(cs);
	dojo[(addClass ? "removeClass" : "addClass")](node,args.cssClass);

	var calculated = {};
	var i = 0;
	dojo.forEach(dojox.fx._allowedProperties,function(prop){
		if(_before[i] != _after[i]){
			// FIXME: the static unit: px is not good, either. need to parse unit from computed style?
			calculated[prop] = { end: parseInt(_after[i]) /* start: parseInt(_before[i]), unit: 'px' */ };
		}
		i++;
	});
	return calculated;
};
<commit_msg>minor style cleanups and assume end: property for dojox.fx.style class calculations. trying to track down font size assumptions in test.<commit_after>dojo.provide("dojox.fx.style");
dojo.experimental("dojox.fx.style");
//
// summary: dojox.fx CSS Class _Animations:
//
// description: a set of functions to animate properties based on
// 	normalized CSS class definitions.
//
//	provides: addClass, removeClass, and toggleClass
//
dojo.require("dojox.fx._base");

// FIXME: should the call signatures match dojo.addClass/removeClass/toggleClass and extend
// 	by having a third (or fourth) param to mix in additional _Animation args for advanced
//	usage (delay: curve: repeat: easing: etc ... )

dojox.fx.addClass = function(/*dojox.fx._arg.StyleArgs*/ args){
	// summary: Animate the effects of adding a class to a node
	// description:
	//	Creates an animation that will animate
	//	the properties of a node to the properties
	//	defined in a standard CSS .class definition.
	//	(calculating the differences itself)
	//
	// example:
	// |
	// |	.bar { line-height: 12px; }
	// |	.foo { line-height: 40px; }
	// |

	// |	Multi
line
text
	// |

	// |
	// |	// animate to line-height:40px
	// |	dojo.fx.addClass({ node:"test", cssClass:"foo" }).play();
	//
	var node = args.node = dojo.byId(args.node);

	var pushClass = (function(n){
		// summary: onEnd we want to add the class to the node
		//	(as dojo.addClass naturally would) in case our
		//	class parsing misses anything the browser would
		// 	otherwise interpret. this may cause some flicker,
		//	and will only apply the class so children can inherit
		//	after the animation is done (potentially more flicker)
		return function(){
			dojo.addClass(n, args.cssClass);
			n.style.cssText = _beforeStyle;
		}
	})(node);

	// _getCalculatedStleChanges is the core of our style/class animations
	var mixedProperties = dojox.fx._getCalculatedStyleChanges(args,true);
	var _beforeStyle = node.style.cssText;
	var _anim = dojo.animateProperty(dojo.mixin({
		properties: mixedProperties
	},args));
	dojo.connect(_anim,"onEnd",_anim,pushClass);
	return _anim; // dojo._Animation
};

dojox.fx.removeClass = function(/*dojox.fx._arg.StyleArgs*/ args){
	// summary: Animate the effects of removing a class from a node
	// description:
	//	Creates an animation that will animate the properties of a
	// 	node (args.node) to the properties calculated after removing
	//	a standard CSS className from a that node.
	//
	//	calls dojo.removeClass(args.cssClass) onEnd of animation
	//
	//	standard dojo._Animation object rules apply.
	//
	// example:
	// |	// animate the removal of "foo" from a node with id="bar"
	// |	dojox.fx.removeClass({
	// |		node: "bar",
	// |		cssClass: "foo"
	// |	}).play();

	var node = (args.node = dojo.byId(args.node));

	var pullClass = (function(n){
		// summary: onEnd we want to remove the class from the node
		//	(as dojo.removeClass naturally would) in case our class
		//	parsing misses anything the browser would otherwise
		//	interpret. this may cause some flicker, and will only
		//	apply the class so children can inherit after the
		//	animation is done (potentially more flicker)
		//
		return function(){
			dojo.removeClass(n, args.cssClass);
			n.style.cssText = _beforeStyle;
		}
	})(node);

	var mixedProperties = dojox.fx._getCalculatedStyleChanges(args,false);
	var _beforeStyle = node.style.cssText;
	var _anim = dojo.animateProperty(dojo.mixin({
		properties: mixedProperties
	},args));
	dojo.connect(_anim,"onEnd",_anim,pullClass);
	return _anim; // dojo._Animation
};

dojox.fx.toggleClass = function(/*DomNode|String*/node, /*String*/cssClass, /*Boolean?*/condition){
        // summary:
	//	Animate the effects of Toggling a class on a Node
	//
	// description:
	//	creates an animation that will animate the effect of
	//	toggling a class on or off of a node.
        //	Adds a class to node if not present, or removes if present.
        //	Pass a boolean condition if you want to explicitly add or remove.
	// node:
	//	The domNode (or string of the id) to toggle
	// cssClass:
	//	String of the classname to add to the node
        // condition:
        //	If passed, true means to add the class, false means to remove.
	//
	// example:
	// |	// add the class "sampleClass" to a node id="theNode"
	// |	dojox.fx.toggleClass("theNode","sampleClass",true).play();
	// example:
	// |	// toggle the class "sampleClass" on the node id="theNode"
	// |	dojox.fx.toggleClass("theNode","sampleClass").play();

        if(typeof condition == "undefined"){
                condition = !dojo.hasClass(node, cssClass);
        }
        return dojox.fx[(condition ? "addClass" : "removeClass")]({ node: node, cssClass:cssClass }); // dojo._Animation
	// TODO: support 4th param animMixin to allow passing of easing and duration and other _Animtion options
};

dojox.fx._allowedProperties = [
	// summary: Our pseudo map of properties we will check for.
	// description:
	//	it should be much more intuitive. a way to normalize and
	//	"predict" intent, or even something more clever ...
	//	open to suggestions.

	// no-brainers:
	"width",
	"height",
	// only if position = absolute || relative?
	"left", "top", // "right", "bottom",
	// these need to be filtered through dojo.colors?
	// "background", // normalize to:
	/* "backgroundImage", */
	// "backgroundPosition", // FIXME: to be effective, this needs "#px #px"?
	"backgroundColor",

	"color",

	// "border",
	"borderBottomColor", "borderBottomWidth",
	"borderTopColor","borderTopWidth",
	"borderLeftColor","borderLeftWidth",
	"borderRightColor","borderRightWidth",

	// "padding", // normalize to:
	"paddingLeft", "paddingRight", "paddingTop", "paddingBottom",
	// "margin", // normalize to:
	"marginLeft", "marginTop", "marginRight", "marginBottom",

	// unit import/delicate?:
	"lineHeight",
	"letterSpacing",
	"fontSize"
];

dojox.fx._getStyleSnapshot = function(/* Object */cache){
	// summary:
	//	uses a dojo.getComputedStyle(node) cache reference and
	// 	iterates through the 'documented/supported animate-able'
	// 	properties.
	//
	// returns:  Array
	//	an array of raw, calculcated values (no keys), to be normalized/compared
	//	elsewhere
	return dojo.map(dojox.fx._allowedProperties,function(style){
		return cache[style]; // String
	}); // Array
};

dojox.fx._getCalculatedStyleChanges = function(/*dojox.fx._arg.StyleArgs*/ args, /*Boolean*/addClass){
	// summary: calclate the difference in style properties between two states
	// description:
	//	calculate and normalize(?) the differences between two states
	//	of a node (args.node) by quickly adding or removing a class, and
	//	iterateing over the results of dojox.fx._getStyleSnapshot()
	//
	// addClass:
	// 	true to calculate what adding a class would do,
	// 	false to calculate what removing the class would do

	var node = args.node = dojo.byId(args.node);
	var cs = dojo.getComputedStyle(node);

	// take our snapShots
	var _before = dojox.fx._getStyleSnapshot(cs);
	dojo[(addClass ? "addClass" : "removeClass")](node,args.cssClass);
	var _after = dojox.fx._getStyleSnapshot(cs);
	dojo[(addClass ? "removeClass" : "addClass")](node,args.cssClass);

	var calculated = {};
	var i = 0;
	dojo.forEach(dojox.fx._allowedProperties,function(prop){
		if(_before[i] != _after[i]){
			// FIXME: the static unit: px is not good, either. need to parse unit from computed style?
			calculated[prop] = parseInt(_after[i]) /* start: parseInt(_before[i]), unit: 'px' */ ;
		}
		i++;
	});
	return calculated;
};
<|endoftext|>


<commit_before>// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This file provides the ScrollAction object, which scrolls a page
// to the bottom or for a specified distance:
//   1. var action = new __ScrollAction(callback, opt_distance_func)
//   2. action.start(scroll_options)
'use strict';

(function() {
  var MAX_SCROLL_LENGTH_TIME_MS = 6250;

  function ScrollGestureOptions(opt_options) {
    if (opt_options) {
      this.element_ = opt_options.element;
      this.left_start_ratio_ = opt_options.left_start_ratio;
      this.top_start_ratio_ = opt_options.top_start_ratio;
      this.direction_ = opt_options.direction;
      this.speed_ = opt_options.speed;
      this.gesture_source_type_ = opt_options.gesture_source_type;
    } else {
      this.element_ = document.scrollingElement || document.body;
      this.left_start_ratio_ = 0.5;
      this.top_start_ratio_ = 0.5;
      this.direction_ = 'down';
      this.speed_ = 800;
      this.gesture_source_type_ = chrome.gpuBenchmarking.DEFAULT_INPUT;
    }
  }

  function supportedByBrowser() {
    return !!(window.chrome &&
              chrome.gpuBenchmarking &&
              chrome.gpuBenchmarking.smoothScrollBy &&
              chrome.gpuBenchmarking.visualViewportHeight &&
              chrome.gpuBenchmarking.visualViewportWidth);
  }

  // This class scrolls a page from the top to the bottom once.
  //
  // The page is scrolled down by a single scroll gesture.
  function ScrollAction(opt_callback, opt_distance_func) {
    var self = this;

    this.beginMeasuringHook = function() {};
    this.endMeasuringHook = function() {};

    this.callback_ = opt_callback;
    this.distance_func_ = opt_distance_func;
  }

  ScrollAction.prototype.getScrollDistanceDown_ = function() {
    var clientHeight;
    // clientHeight is "special" for the body element.
    if (this.element_ == document.body)
      clientHeight = __GestureCommon_GetWindowHeight();
    else
      clientHeight = this.element_.clientHeight;

    return this.element_.scrollHeight -
           this.element_.scrollTop -
           clientHeight;
  };

  ScrollAction.prototype.getScrollDistanceUp_ = function() {
    return this.element_.scrollTop;
  };

  ScrollAction.prototype.getScrollDistanceRight_ = function() {
    var clientWidth;
    // clientWidth is "special" for the body element.
    if (this.element_ == document.body)
      clientWidth = __GestureCommon_GetWindowWidth();
    else
      clientWidth = this.element_.clientWidth;

    return this.element_.scrollWidth - this.element_.scrollLeft - clientWidth;
  };

  ScrollAction.prototype.getScrollDistanceLeft_ = function() {
    return this.element_.scrollLeft;
  };

  ScrollAction.prototype.getScrollDistance_ = function() {
    if (this.distance_func_)
      return this.distance_func_();

    if (this.options_.direction_ == 'down') {
      return this.getScrollDistanceDown_();
    } else if (this.options_.direction_ == 'up') {
      return this.getScrollDistanceUp_();
    } else if (this.options_.direction_ == 'right') {
      return this.getScrollDistanceRight_();
    } else if (this.options_.direction_ == 'left') {
      return this.getScrollDistanceLeft_();
    } else if (this.options_.direction_ == 'upleft') {
      return Math.min(this.getScrollDistanceUp_(),
                      this.getScrollDistanceLeft_());
    } else if (this.options_.direction_ == 'upright') {
      return Math.min(this.getScrollDistanceUp_(),
                      this.getScrollDistanceRight_());
    } else if (this.options_.direction_ == 'downleft') {
      return Math.min(this.getScrollDistanceDown_(),
                      this.getScrollDistanceLeft_());
    } else if (this.options_.direction_ == 'downright') {
      return Math.min(this.getScrollDistanceDown_(),
                      this.getScrollDistanceRight_());
    }
  };

  ScrollAction.prototype.start = function(opt_options) {
    this.options_ = new ScrollGestureOptions(opt_options);
    // Assign this.element_ here instead of constructor, because the constructor
    // ensures this method will be called after the document is loaded.
    this.element_ = this.options_.element_;
    requestAnimationFrame(this.startGesture_.bind(this));
  };

  ScrollAction.prototype.startGesture_ = function() {
    this.beginMeasuringHook();

    var max_scroll_length_pixels = (MAX_SCROLL_LENGTH_TIME_MS / 1000) *
        this.options_.speed_;
    var distance = Math.min(max_scroll_length_pixels,
                            this.getScrollDistance_());

    var rect = __GestureCommon_GetBoundingVisibleRect(this.options_.element_);
    var start_left =
        rect.left + rect.width * this.options_.left_start_ratio_;
    var start_top =
        rect.top + rect.height * this.options_.top_start_ratio_;
    chrome.gpuBenchmarking.smoothScrollBy(
        distance, this.onGestureComplete_.bind(this), start_left, start_top,
        this.options_.gesture_source_type_, this.options_.direction_,
        this.options_.speed_);
  };

  ScrollAction.prototype.onGestureComplete_ = function() {
    this.endMeasuringHook();

    // We're done.
    if (this.callback_)
      this.callback_();
  };

  window.__ScrollAction = ScrollAction;
  window.__ScrollAction_SupportedByBrowser = supportedByBrowser;
})();
<commit_msg>[telemetry] Bullet proof scroll.js<commit_after>// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This file provides the ScrollAction object, which scrolls a page
// to the bottom or for a specified distance:
//   1. var action = new __ScrollAction(callback, opt_distance_func)
//   2. action.start(scroll_options)
'use strict';

(function() {
  var MAX_SCROLL_LENGTH_TIME_MS = 6250;

  function ScrollGestureOptions(opt_options) {
    if (opt_options) {
      this.element_ = opt_options.element;
      this.leftStartRatio_ = opt_options.left_start_ratio;
      this.topStartRatio_ = opt_options.top_start_ratio;
      this.direction_ = opt_options.direction;
      this.speed_ = opt_options.speed;
      this.gesture_source_type_ = opt_options.gesture_source_type;
    } else {
      this.element_ = document.scrollingElement || document.body;
      this.leftStartRatio_ = 0.5;
      this.topStartRatio_ = 0.5;
      this.direction_ = 'down';
      this.speed_ = 800;
      this.gesture_source_type_ = chrome.gpuBenchmarking.DEFAULT_INPUT;
    }
  }

  function supportedByBrowser() {
    return !!(window.chrome &&
              chrome.gpuBenchmarking &&
              chrome.gpuBenchmarking.smoothScrollBy &&
              chrome.gpuBenchmarking.visualViewportHeight &&
              chrome.gpuBenchmarking.visualViewportWidth);
  }

  // This class scrolls a page from the top to the bottom once.
  //
  // The page is scrolled down by a single scroll gesture.
  function ScrollAction(opt_callback, opt_distanceFunc) {
    var self = this;

    this.beginMeasuringHook = function() {};
    this.endMeasuringHook = function() {};

    this.callback_ = opt_callback;
    this.distance_func_ = opt_distanceFunc;
  }

  ScrollAction.prototype.getScrollDistanceDown_ = function() {
    var clientHeight;
    // clientHeight is "special" for the body element.
    if (this.element_ === document.body)
      clientHeight = __GestureCommon_GetWindowHeight();
    else
      clientHeight = this.element_.clientHeight;

    return this.element_.scrollHeight -
           this.element_.scrollTop -
           clientHeight;
  };

  ScrollAction.prototype.getScrollDistanceUp_ = function() {
    return this.element_.scrollTop;
  };

  ScrollAction.prototype.getScrollDistanceRight_ = function() {
    var clientWidth;
    // clientWidth is "special" for the body element.
    if (this.element_ === document.body)
      clientWidth = __GestureCommon_GetWindowWidth();
    else
      clientWidth = this.element_.clientWidth;

    return this.element_.scrollWidth - this.element_.scrollLeft - clientWidth;
  };

  ScrollAction.prototype.getScrollDistanceLeft_ = function() {
    return this.element_.scrollLeft;
  };

  ScrollAction.prototype.getScrollDistance_ = function() {
    if (this.distance_func_)
      return this.distance_func_();

    if (this.options_.direction_ === 'down') {
      return this.getScrollDistanceDown_();
    } else if (this.options_.direction_ === 'up') {
      return this.getScrollDistanceUp_();
    } else if (this.options_.direction_ === 'right') {
      return this.getScrollDistanceRight_();
    } else if (this.options_.direction_ === 'left') {
      return this.getScrollDistanceLeft_();
    } else if (this.options_.direction_ === 'upleft') {
      return Math.min(this.getScrollDistanceUp_(),
                      this.getScrollDistanceLeft_());
    } else if (this.options_.direction_ === 'upright') {
      return Math.min(this.getScrollDistanceUp_(),
                      this.getScrollDistanceRight_());
    } else if (this.options_.direction_ === 'downleft') {
      return Math.min(this.getScrollDistanceDown_(),
                      this.getScrollDistanceLeft_());
    } else if (this.options_.direction_ === 'downright') {
      return Math.min(this.getScrollDistanceDown_(),
                      this.getScrollDistanceRight_());
    }
  };

  ScrollAction.prototype.start = function(opt_options) {
    this.options_ = new ScrollGestureOptions(opt_options);
    // Assign this.element_ here instead of constructor, because the constructor
    // ensures this method will be called after the document is loaded.
    this.element_ = this.options_.element_;

    // Calculate scroll point.
    var rect = __GestureCommon_GetBoundingVisibleRect(this.options_.element_);
    this.startLeft = rect.left + rect.width * this.options_.leftStartRatio_;
    this.startTop = rect.top + rect.height * this.options_.topStartRatio_;

    if (rect.width === 0 || rect.height === 0) {
      throw new Error('Scroll element has zero height and/or width.');
    }

    requestAnimationFrame(this.startGesture_.bind(this));
  };

  ScrollAction.prototype.startGesture_ = function() {
    this.beginMeasuringHook();

    var maxScrollLengthPixels = (MAX_SCROLL_LENGTH_TIME_MS / 1000) *
        this.options_.speed_;
    var distance = Math.min(maxScrollLengthPixels, this.getScrollDistance_());

   chrome.gpuBenchmarking.smoothScrollBy(
        distance, this.onGestureComplete_.bind(this),
        this.startLeft, this.startTop, this.options_.gesture_source_type_,
        this.options_.direction_, this.options_.speed_);
  };

  ScrollAction.prototype.onGestureComplete_ = function() {
    this.endMeasuringHook();

    // We're done.
    if (this.callback_)
      this.callback_();
  };

  window.__ScrollAction = ScrollAction;
  window.__ScrollAction_SupportedByBrowser = supportedByBrowser;
})();
<|endoftext|>


<commit_before>'use strict';
var test = false;
angular.module('dft', ['ngSanitize', 'ui.router'])
  .config(['$stateProvider', '$urlRouterProvider', '$httpProvider'
  , function($stateProvider, $urlRouterProvider, $httpProvider) {
    $httpProvider.defaults.useXDomain = true;
    delete $httpProvider.defaults.headers.common['X-Requested-With'];

  $stateProvider.state('loggedIn', {
    url: '/'
  , controller: 'GlobalController'
  , controllerAs: 'global'
  })
  .state('home', {
    templateUrl: '/views/partials/home.html'
  , url: 'home'
  })
  .state('map', {
    template: '<roo-map></roo-map>'
  , url: '/map'
  })
  .state('about', {
    templateUrl: '/views/layouts/about.html'
  , url: '/about'
  })
  .state('data', {
    templateUrl: '/views/layouts/data.html'
  , url: '/data'
  })
  .state('login', {
    templateUrl: '/views/partials/login.html'
  , url: '/login'
  })
  .state('contact', {
    url: '/contact'
  , templateUrl: '/views/partials/contact.hml'
  })
  .state('contribute', {
    templateUrl: '/views/partials/contribute.html'
  , url: '/contribute'
  })
  .state('contribute.money', {
    url: '/money'
  })
  .state('contribute.info', {
    url: '/info'
  })
  .state('contribute.code', {
    url: '/code'
  });

    $urlRouterProvider.otherwise('/');
  }]);
<commit_msg>indent states<commit_after>'use strict';
var test = false;
angular.module('dft', ['ngSanitize', 'ui.router'])
  .config(['$stateProvider', '$urlRouterProvider', '$httpProvider'
  , function($stateProvider, $urlRouterProvider, $httpProvider) {
    $httpProvider.defaults.useXDomain = true;
    delete $httpProvider.defaults.headers.common['X-Requested-With'];

    $stateProvider.state('loggedIn', {
      url: '/'
    , controller: 'GlobalController'
    , controllerAs: 'global'
    })
    .state('home', {
      templateUrl: '/views/partials/home.html'
    , url: 'home'
    })
    .state('map', {
      template: '<roo-map></roo-map>'
    , url: '/map'
    })
    .state('about', {
      templateUrl: '/views/layouts/about.html'
    , url: '/about'
    })
    .state('data', {
      templateUrl: '/views/layouts/data.html'
    , url: '/data'
    })
    .state('login', {
      templateUrl: '/views/partials/login.html'
    , url: '/login'
    })
    .state('contact', {
      url: '/contact'
    , templateUrl: '/views/partials/contact.hml'
    })
    .state('contribute', {
      templateUrl: '/views/partials/contribute.html'
    , url: '/contribute'
    })
    .state('contribute.money', {
      url: '/money'
    })
    .state('contribute.info', {
      url: '/info'
    })
    .state('contribute.code', {
      url: '/code'
    });

    $urlRouterProvider.otherwise('/');
  }]);
<|endoftext|>


<commit_before>/*
 Copyright 2012 - $Date $ by PeopleWare n.v.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */

define(["dojo/main", "ppwcode/contracts/doh", "../AuditableObject"],
    function(dojo, doh, AuditableObject) {

      doh.register("ppwcode vernacular persistence AuditableObject", [

        function testConstructor1() {
          var persistenceId = 1;
          var createdAt = new Date();
          var createdBy = "creator";
          var lastModifiedAt = new Date();
          var lastModifiedBy = "modifier";
          var subject = new AuditableObject({persistenceId: persistenceId,
            createdAt: createdAt, createdBy: createdBy, lastModifiedAt: lastModifiedAt, lastModifiedBy: lastModifiedBy});
          doh.invars(subject);
          // post
          doh.is(createdAt, subject.get("createdAt"));
          doh.is(createdBy, subject.get("createdBy"));
          doh.is(lastModifiedAt, subject.get("lastModifiedAt"));
          doh.is(lastModifiedBy, subject.get("lastModifiedBy"));
        },

        function testConstructor2() {
          var subject = new AuditableObject({});
          doh.invars(subject);
          // post
          doh.is(null, subject.get("createdAt"));
          doh.is(null, subject.get("createdBy"));
          doh.is(null, subject.get("lastModifiedAt"));
          doh.is(null, subject.get("lastModifiedBy"));
        },

        // MUDO test events

        function testReload1() {
          var subject = new AuditableObject();
          subject.reload();

          doh.invars(subject);
          // post
          doh.is(null, subject.get("createdAt"));
          doh.is(null, subject.get("createdBy"));
          doh.is(null, subject.get("lastModifiedAt"));
          doh.is(null, subject.get("lastModifiedBy"));
        },

        function testReload2() {
          var persistenceId = 1;
          var createdAt = new Date();
          var createdBy = "creator";
          var lastModifiedAt = new Date();
          var lastModifiedBy = "modifier";
          var subject = new AuditableObject({persistenceId: persistenceId,
            createdAt: createdAt, createdBy: createdBy, lastModifiedAt: lastModifiedAt, lastModifiedBy: lastModifiedBy});
          subject.reload();

          doh.invars(subject);
          // post
          doh.is(createdAt, subject.get("createdAt"));
          doh.is(createdBy, subject.get("createdBy"));
          doh.is(lastModifiedAt, subject.get("lastModifiedAt"));
          doh.is(lastModifiedBy, subject.get("lastModifiedBy"));
        },

        function testReload3() {
          var persistenceId = 1;
          var createdAt = new Date();
          var createdBy = "creator";
          var lastModifiedAt = new Date();
          var lastModifiedBy = "modifier";
          var subject = new AuditableObject();
          subject.reload({persistenceId: persistenceId,
            createdAt: createdAt, createdBy: createdBy, lastModifiedAt: lastModifiedAt, lastModifiedBy: lastModifiedBy});

          doh.invars(subject);
          // post
          doh.is(createdAt, subject.get("createdAt"));
          doh.is(createdBy, subject.get("createdBy"));
          doh.is(lastModifiedAt, subject.get("lastModifiedAt"));
          doh.is(lastModifiedBy, subject.get("lastModifiedBy"));
        },

        function testReload4() {
          var createdAt = new Date();
          var createdBy = "creator";
          var lastModifiedAt = new Date();
          var lastModifiedBy = "modifier";
          //noinspection MagicNumberJS
          var subject = new AuditableObject({persistenceId: 666,
            createdAt: createdAt, createdBy: createdBy, lastModifiedAt: new Date(), lastModifiedBy: "jos"});
          //noinspection MagicNumberJS
          subject.reload({persistenceId: 666,
            createdAt: createdAt, createdBy: createdBy, lastModifiedAt: lastModifiedAt, lastModifiedBy: lastModifiedBy});

          doh.invars(subject);
          // post
          doh.is(createdAt, subject.createdAt);
          doh.is(createdBy, subject.createdBy);
          doh.is(lastModifiedAt, subject.lastModifiedAt);
          doh.is(lastModifiedBy, subject.lastModifiedBy);
        },

        function testToJSON() {
          var subject = new AuditableObject();
          var result = subject.toJSON();

          doh.invars(subject);
          // post

          console.log(result);
        },

        function testToJSON() {
          var subject = new AuditableObject({persistenceId: 5,
            createdAt: new Date(), createdBy: "test", lastModifiedAt: new Date(), lastModifiedBy: "another"});
          var result = subject.toJSON();

          doh.invars(subject);
          // post

          console.log(result);
        },

        function testToString1() {
          var persistenceId = 1;
          var createdAt = new Date();
          var createdBy = "creator";
          var lastModifiedAt = new Date();
          var lastModifiedBy = "modifier";
          var subject = new AuditableObject({persistenceId: persistenceId,
            createdAt: createdAt, createdBy: createdBy, lastModifiedAt: lastModifiedAt, lastModifiedBy: lastModifiedBy});
          var result = subject.toString();
          doh.isNot(null, result);
          doh.t(typeof result === "string");
          doh.isNot("", result);
          console.log(result);
        },

        function testToString2() {
          var subject = new AuditableObject({});
          var result = subject.toString();
          doh.isNot(null, result);
          doh.t(typeof result === "string");
          doh.isNot("", result);
          console.log(result);
        }

      ]);

    }
);
<commit_msg>needed to be changed after change to PersistentObject<commit_after>/*
 Copyright 2012 - $Date $ by PeopleWare n.v.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */

define(["dojo/main", "ppwcode/contracts/doh", "../AuditableObject"],
    function(dojo, doh, AuditableObject) {

      doh.register("ppwcode vernacular persistence AuditableObject", [

        function testConstructor1() {
          var persistenceId = 1;
          var createdAt = new Date();
          var createdBy = "creator";
          var lastModifiedAt = new Date();
          var lastModifiedBy = "modifier";
          var subject = new AuditableObject();
          subject.reload({persistenceId: persistenceId,
            createdAt: createdAt, createdBy: createdBy, lastModifiedAt: lastModifiedAt, lastModifiedBy: lastModifiedBy});
          doh.invars(subject);
          // post
          doh.is(createdAt, subject.get("createdAt"));
          doh.is(createdBy, subject.get("createdBy"));
          doh.is(lastModifiedAt, subject.get("lastModifiedAt"));
          doh.is(lastModifiedBy, subject.get("lastModifiedBy"));
        },

        function testConstructor2() {
          var subject = new AuditableObject();
          doh.invars(subject);
          // post
          doh.is(null, subject.get("createdAt"));
          doh.is(null, subject.get("createdBy"));
          doh.is(null, subject.get("lastModifiedAt"));
          doh.is(null, subject.get("lastModifiedBy"));
        },

        // MUDO test events

        function testReload1() {
          var subject = new AuditableObject();
          subject.reload();

          doh.invars(subject);
          // post
          doh.is(null, subject.get("createdAt"));
          doh.is(null, subject.get("createdBy"));
          doh.is(null, subject.get("lastModifiedAt"));
          doh.is(null, subject.get("lastModifiedBy"));
        },

        function testReload2() {
          var persistenceId = 1;
          var createdAt = new Date();
          var createdBy = "creator";
          var lastModifiedAt = new Date();
          var lastModifiedBy = "modifier";
          var subject = new AuditableObject({persistenceId: persistenceId,
            createdAt: createdAt, createdBy: createdBy, lastModifiedAt: lastModifiedAt, lastModifiedBy: lastModifiedBy});
          subject.reload();

          doh.invars(subject);
          // post
          doh.is(createdAt, subject.get("createdAt"));
          doh.is(createdBy, subject.get("createdBy"));
          doh.is(lastModifiedAt, subject.get("lastModifiedAt"));
          doh.is(lastModifiedBy, subject.get("lastModifiedBy"));
        },

        function testReload3() {
          var persistenceId = 1;
          var createdAt = new Date();
          var createdBy = "creator";
          var lastModifiedAt = new Date();
          var lastModifiedBy = "modifier";
          var subject = new AuditableObject();
          subject.reload({persistenceId: persistenceId,
            createdAt: createdAt, createdBy: createdBy, lastModifiedAt: lastModifiedAt, lastModifiedBy: lastModifiedBy});

          doh.invars(subject);
          // post
          doh.is(createdAt, subject.get("createdAt"));
          doh.is(createdBy, subject.get("createdBy"));
          doh.is(lastModifiedAt, subject.get("lastModifiedAt"));
          doh.is(lastModifiedBy, subject.get("lastModifiedBy"));
        },

        function testReload4() {
          var createdAt = new Date();
          var createdBy = "creator";
          var lastModifiedAt = new Date();
          var lastModifiedBy = "modifier";
          //noinspection MagicNumberJS
          var subject = new AuditableObject({persistenceId: 666,
            createdAt: createdAt, createdBy: createdBy, lastModifiedAt: new Date(), lastModifiedBy: "jos"});
          //noinspection MagicNumberJS
          subject.reload({persistenceId: 666,
            createdAt: createdAt, createdBy: createdBy, lastModifiedAt: lastModifiedAt, lastModifiedBy: lastModifiedBy});

          doh.invars(subject);
          // post
          doh.is(createdAt, subject.createdAt);
          doh.is(createdBy, subject.createdBy);
          doh.is(lastModifiedAt, subject.lastModifiedAt);
          doh.is(lastModifiedBy, subject.lastModifiedBy);
        },

        function testToJSON() {
          var subject = new AuditableObject();
          var result = subject.toJSON();

          doh.invars(subject);
          // post

          console.log(result);
        },

        function testToJSON() {
          var subject = new AuditableObject({persistenceId: 5,
            createdAt: new Date(), createdBy: "test", lastModifiedAt: new Date(), lastModifiedBy: "another"});
          var result = subject.toJSON();

          doh.invars(subject);
          // post

          console.log(result);
        },

        function testToString1() {
          var persistenceId = 1;
          var createdAt = new Date();
          var createdBy = "creator";
          var lastModifiedAt = new Date();
          var lastModifiedBy = "modifier";
          var subject = new AuditableObject();
          subject.reload({persistenceId: persistenceId,
            createdAt: createdAt, createdBy: createdBy, lastModifiedAt: lastModifiedAt, lastModifiedBy: lastModifiedBy});
          var result = subject.toString();
          doh.isNot(null, result);
          doh.t(typeof result === "string");
          doh.isNot("", result);
          console.log(result);
        },

        function testToString2() {
          var subject = new AuditableObject();
          var result = subject.toString();
          doh.isNot(null, result);
          doh.t(typeof result === "string");
          doh.isNot("", result);
          console.log(result);
        }

      ]);

    }
);
<|endoftext|>


<commit_before>var EasyAssess = require('../../easyassess.application');

EasyAssess.builders.register("esAppLookup", "textfield", function(){
	var html = '{{esLabel}}'
		+ '
'
		+ '<input ng-model="esModel" style="height:36px;" ng-readonly="esEditable" type="text" class="form-control">'
		+ ''
		+ '
'
		+ '
{{esModel}}
';
	return html;
});

EasyAssess.builders.register("esAppLookup", "button", function(){
	var html = '
'
		+ '<button ng-click="lookup()" type="button" class="btn btn-primary">'
		+ 	''
		+ 	'{{esLabel}}'
		+ '</button>'
		+ '
';
	return html;
});

EasyAssess.builders.register("esAppLookup", "link", function(){
	var html = '
'
		+ '{{esLabel}}'
		+ '
';
	return html;
});

EasyAssess.directives["esAppLookup"]
	= EasyAssess.app.directive("esAppLookup", function(ngDialog) {

	return {
		restrict: 'E',
		replace: true,
		transclude: false,
		template: function(ele, attrs) {
			var provider = "textfield";
			if (attrs["esProvider"]) {
				provider = attrs["esProvider"];
			}
			var html = '
'
				+ EasyAssess.builders.get("esAppLookup", provider)()
				+ '
';
			return html;
		},
		scope: {
			esLabel: "@",
			esEditable: "@",
			esWidth:"@",
			esResource:"@",
			esColumns: "=",
			esId:"@",
			esValueField:"@",
			esModel:"=?",
			esReadonly:"=",
			esQuery:"=?",
			esService:"@"
		},
		controller: ["$scope", function($scope, $element, $attrs){
			if (!$scope.esWidth) {
				$scope.esWidth = 200;
			}

			if (!$scope.esEditable) {
				$scope.esEditable = true;
			}

			$scope.esOptions = $scope.esColumns.filter(function(eachfield){
				return eachfield.searchable;
			}).map(function(item){
				var option = {text:"",value:"",default:false};
				option.text = item.title;
				option.value = item.field;
				option.default = item.default;
				return option;
			});

			$scope.lookup = function() {
				ngDialog.open({
					template: '
<es-app-datagrid es-service="{{service}}" es-resource="{{resource}}" es-options="options" es-columns="fields"></es-app-datagrid>
',
					plain: true,
					controller: ['$scope', function($dialog) {
						$dialog.resource = $scope.esResource;
						$dialog.fields = $scope.esColumns;
						$dialog.options = $scope.esOptions;
						$dialog.service = $scope.esService;
						$dialog.$on('$selected', function(e, model){
							$scope.$emit('$' + $scope.esId + '_selected', model);

							if ($scope.esValueField && $scope.esValueField.indexOf(".") != -1) {
								var val = model;
								var fields = $scope.esValueField.split(".")
								for (var i =0; i < fields.length; i++) {
									val = val[fields[i]];
								}
								$scope.esModel = val;
							} else {
								$scope.esModel = model[$scope.esValueField];
							}
							$dialog.closeThisDialog();
						});
					}]
				});
			}

		}]
	}
});

<commit_msg>give default service value for lookup<commit_after>var EasyAssess = require('../../easyassess.application');

EasyAssess.builders.register("esAppLookup", "textfield", function(){
	var html = '{{esLabel}}'
		+ '
'
		+ '<input ng-model="esModel" style="height:36px;" ng-readonly="esEditable" type="text" class="form-control">'
		+ ''
		+ '
'
		+ '
{{esModel}}
';
	return html;
});

EasyAssess.builders.register("esAppLookup", "button", function(){
	var html = '
'
		+ '<button ng-click="lookup()" type="button" class="btn btn-primary">'
		+ 	''
		+ 	'{{esLabel}}'
		+ '</button>'
		+ '
';
	return html;
});

EasyAssess.builders.register("esAppLookup", "link", function(){
	var html = '
'
		+ '{{esLabel}}'
		+ '
';
	return html;
});

EasyAssess.directives["esAppLookup"]
	= EasyAssess.app.directive("esAppLookup", function(ngDialog) {

	return {
		restrict: 'E',
		replace: true,
		transclude: false,
		template: function(ele, attrs) {
			var provider = "textfield";
			if (attrs["esProvider"]) {
				provider = attrs["esProvider"];
			}
			var html = '
'
				+ EasyAssess.builders.get("esAppLookup", provider)()
				+ '
';
			return html;
		},
		scope: {
			esLabel: "@",
			esEditable: "@",
			esWidth:"@",
			esResource:"@",
			esColumns: "=",
			esId:"@",
			esValueField:"@",
			esModel:"=?",
			esReadonly:"=",
			esQuery:"=?",
			esService:"@"
		},
		controller: ["$scope", function($scope, $element, $attrs){
			if (!$scope.esWidth) {
				$scope.esWidth = 200;
			}

			if (!$scope.esService) {
				$scope.esService = "pdm";
			}

			if (!$scope.esEditable) {
				$scope.esEditable = true;
			}

			$scope.esOptions = $scope.esColumns.filter(function(eachfield){
				return eachfield.searchable;
			}).map(function(item){
				var option = {text:"",value:"",default:false};
				option.text = item.title;
				option.value = item.field;
				option.default = item.default;
				return option;
			});

			$scope.lookup = function() {
				ngDialog.open({
					template: '
<es-app-datagrid es-service="{{service}}" es-resource="{{resource}}" es-options="options" es-columns="fields"></es-app-datagrid>
',
					plain: true,
					controller: ['$scope', function($dialog) {
						$dialog.resource = $scope.esResource;
						$dialog.fields = $scope.esColumns;
						$dialog.options = $scope.esOptions;
						$dialog.service = $scope.esService;
						$dialog.$on('$selected', function(e, model){
							$scope.$emit('$' + $scope.esId + '_selected', model);

							if ($scope.esValueField && $scope.esValueField.indexOf(".") != -1) {
								var val = model;
								var fields = $scope.esValueField.split(".")
								for (var i =0; i < fields.length; i++) {
									val = val[fields[i]];
								}
								$scope.esModel = val;
							} else {
								$scope.esModel = model[$scope.esValueField];
							}
							$dialog.closeThisDialog();
						});
					}]
				});
			}

		}]
	}
});

<|endoftext|>


<commit_before>var mysql = require('mysql');
var db = require('../db');
var bodyParser = require('body-parser');
var msg = {
		text: req.body.text
		};
function index(){

};

function createRoom(req, res) {
	name = req.body.name;
	db.createRoom(name);
	console.log("Room created!!!");
};

function sendInvitation(){

};

function sendMessage(){
let length = db.getData(text, 'text', 'messages');
		if (length > 0) return true;
		else return false;
		let profiles_Id =1;
		db.query(queries.insertMsg, chatroom_Id[], profiles_Id[], text[]);
};

function chatRoomMessages(){

};

exports.index = index;
exports.createRoom = createRoom;
exports.sendInvitation = sendInvitation;
exports.sendMessage = sendMessage;
<commit_msg>Delete chatroomsController.js<commit_after><|endoftext|>


<commit_before>//aync problem
var requests = ['1.json', '2.json', '3.json', '4.json', '5.json'];
var results = [];
for(var i = 0; i < requests.length; i++) {
    fetch(requests[i]).then(function(response){ //fetch creates an ajax call and returns a promise
      results.push(response.data); //collecting data
    });
}
return results; //oops! results is still empty!

//lets try again, we rewrite the fetch part...
fetch(requests[i]).then(function(response){
  results.push(response.data);

  //the addition
  if(results.length === requests.length) {
    return results; //oops!, we are returning the callback, it doesnt return a value anywhere!
  }
});

//lets revise the whole thing
var requests = ['1.json', '2.json', '3.json', '4.json', '5.json'];

function getData(requests, callback) { //a wrapper function
  var results = [];
  for(var i = 0; i < requests.length; i++) {
      fetch(requests[i]).then(function(response){ //fetch creates an ajax call and returns a promise
        results.push(response.data); //collecting data

        if(results.length === requests.length) { //checking if its the last one
          callback(results); //now that should work
        }
      });
  }
}

//how we use it?
getData(requests, function(results) {
  console.log(results); //Array[5]
});

<commit_msg>Update async.js<commit_after>//aync problem
var requests = ['1.json', '2.json', '3.json', '4.json', '5.json'];
var results = [];
for(var i = 0; i < requests.length; i++) {
    fetch(requests[i]).then(function(response){ //fetch creates an ajax call and returns a promise
      results.push(response.data); //collecting data
    });
}
return results; //oops! results is still empty!

//lets try again, we rewrite the fetch part...
fetch(requests[i]).then(function(response){
  results.push(response.data);

  //the addition
  if(results.length === requests.length) {
    return results; //oops!, we are returning the callback, it doesnt return a value anywhere!
  }
});

//lets revise the whole thing
var requests = ['1.json', '2.json', '3.json', '4.json', '5.json'];

function getData(requests, callback) { //a wrapper function
  var results = [];
  for(var i = 0; i < requests.length; i++) {
      fetch(requests[i]).then(function(response){ //fetch creates an ajax call and returns a promise
        results.push(response.data); //collecting data

        if(results.length === requests.length) { //checking if its the last one
          callback(results); //now that should work
        }
      });
  }
}

//how we use it?
getData(requests, function(results) {
  console.log(results); //Array[5]
});

// alternatively we can use promises - we will see that in the promises section
<|endoftext|>


<commit_before>$(function(){
  var searchForm = $("#searchForm");
  var queryInput = searchForm.find("input[name='query']");
  var error = $("#error");
  var result = $("#result");
  var search = $("#search");
  var searchResultTemplate = $("#searchResultTemplate").html();
  var showError = function(err){
    try{
      err = $("
" + err.responseText + "
").text();
    }
    catch(e)
    {
    }
    error.text(err);
    error.show();
  };
  searchForm.submit(function(e){
    result.empty();
    $.post("/search", {query: queryInput.val()})
      .then(function(r){
        error.hide();
        var items = r.results;
        console.log(items);
        if(!items || items.length == 0){
          result.append("
Not found
");
        }
        else{
          var list = $("

");
          list.addClass("playlist");
          result.append(list);
          _.forEach(items, function(item){
	    console.log(item.hits);
            var el  = $(_.template(searchResultTemplate, item));
            list.append(el);
            initJplayer(el, item.name, item.mediaUrl, item.hits, item.duration);
          });
        }
      }, showError);
    e.preventDefault();
  });
});

function formatTimeSpanUnit(unit){
  var text = (unit || 0).toString();
  return (text.length < 2)? "0" + text: text;
}

function formatTimeSpan(seconds){
  var fractionals = Math.round(seconds * 100);
  seconds = Math.floor(seconds);
  fractionals -= (seconds * 100);
  var minutes = Math.floor(seconds/60);
  seconds = seconds % 60;
  var text = formatTimeSpanUnit(minutes) + ":" + formatTimeSpanUnit(seconds);
  if(fractionals != 0){
    text += "." + fractionals;
  }
  return text;
}

function formatHit(hit){
  return formatTimeSpan(hit.start) + " - " + formatTimeSpan(hit.end);
}

var selectorCounter = 1;
function initJplayer(selector, title, mediaUrl, hits, duration){
  var selectorId = "searchResult" + selectorCounter ++;
  selector.attr("id", selectorId);
  var player = selector.find(".player");
  player.jPlayer({
    preload: "none",
    cssSelectorAncestor: "#" + selectorId,
    ready: function(event) {
      player.jPlayer("setMedia", {
        title: title,
        mp3: mediaUrl
      });
    },
    pause: function(){
      clearTimeout(player.tm);
    },
    stop: function(){
      clearTimeout(player.tm);
    },
    swfPath: "http://jplayer.org/latest/js"
  });
  var progress = selector.find(".jp-progress");
  var bufferOffset = 2;
  progress.find(".mark").remove();
  if(hits && hits.length > 0 && duration){
    _.forEach(hits, function(h){
      var mark = $("

");
      mark.css("left", h.start*100/duration + "%");
      progress.append(mark);
      mark.popover({
        placement: "bottom",
        container: "#" + selectorId,
        content: formatHit(h),
        trigger: "hover",
        title: h.term
      });
      mark.on("click", function(){
        var start = (h.start || 0) - bufferOffset;
        var end = (h.end || 0) + bufferOffset;
        if(start < 0) start = 0;
        player.jPlayer("pauseOthers");
        player.jPlayer("pause", 0);
        player.jPlayer("play", start);
        clearTimeout(player.tm);
        player.tm = setTimeout(function(){
          player.jPlayer("pause");
        }, 1000*(end - start) );
      });
    });
  }
  player.jPlayer("option", "cssSelector.play", ".btn-play");
  player.jPlayer("option", "cssSelector.pause", ".btn-pause");
  player.jPlayer("option", "cssSelector.stop", ".btn-stop");
  player.jPlayer("option", "cssSelector.duration", ".duration");
  player.jPlayer("option", "cssSelector.currentTime", ".current-time");
  if(duration){
    setTimeout(function(){
      selector.find(".duration").text(formatTimeSpan(Math.floor(duration)));
    }, 200);
  }
}
<commit_msg>Removed console output.<commit_after>$(function(){
  var searchForm = $("#searchForm");
  var queryInput = searchForm.find("input[name='query']");
  var error = $("#error");
  var result = $("#result");
  var search = $("#search");
  var searchResultTemplate = $("#searchResultTemplate").html();
  var showError = function(err){
    try{
      err = $("
" + err.responseText + "
").text();
    }
    catch(e)
    {
    }
    error.text(err);
    error.show();
  };
  searchForm.submit(function(e){
    result.empty();
    $.post("/search", {query: queryInput.val()})
      .then(function(r){
        error.hide();
        var items = r.results;
        if(!items || items.length == 0){
          result.append("
Not found
");
        }
        else{
          var list = $("

");
          list.addClass("playlist");
          result.append(list);
          _.forEach(items, function(item){
            var el  = $(_.template(searchResultTemplate, item));
            list.append(el);
            initJplayer(el, item.name, item.mediaUrl, item.hits, item.duration);
          });
        }
      }, showError);
    e.preventDefault();
  });
});

function formatTimeSpanUnit(unit){
  var text = (unit || 0).toString();
  return (text.length < 2)? "0" + text: text;
}

function formatTimeSpan(seconds){
  var fractionals = Math.round(seconds * 100);
  seconds = Math.floor(seconds);
  fractionals -= (seconds * 100);
  var minutes = Math.floor(seconds/60);
  seconds = seconds % 60;
  var text = formatTimeSpanUnit(minutes) + ":" + formatTimeSpanUnit(seconds);
  if(fractionals != 0){
    text += "." + fractionals;
  }
  return text;
}

function formatHit(hit){
  return formatTimeSpan(hit.start) + " - " + formatTimeSpan(hit.end);
}

var selectorCounter = 1;
function initJplayer(selector, title, mediaUrl, hits, duration){
  var selectorId = "searchResult" + selectorCounter ++;
  selector.attr("id", selectorId);
  var player = selector.find(".player");
  player.jPlayer({
    preload: "none",
    cssSelectorAncestor: "#" + selectorId,
    ready: function(event) {
      player.jPlayer("setMedia", {
        title: title,
        mp3: mediaUrl
      });
    },
    pause: function(){
      clearTimeout(player.tm);
    },
    stop: function(){
      clearTimeout(player.tm);
    },
    swfPath: "http://jplayer.org/latest/js"
  });
  var progress = selector.find(".jp-progress");
  var bufferOffset = 2;
  progress.find(".mark").remove();
  if(hits && hits.length > 0 && duration){
    _.forEach(hits, function(h){
      var mark = $("

");
      mark.css("left", h.start*100/duration + "%");
      progress.append(mark);
      mark.popover({
        placement: "bottom",
        container: "#" + selectorId,
        content: formatHit(h),
        trigger: "hover",
        title: h.term
      });
      mark.on("click", function(){
        var start = (h.start || 0) - bufferOffset;
        var end = (h.end || 0) + bufferOffset;
        if(start < 0) start = 0;
        player.jPlayer("pauseOthers");
        player.jPlayer("pause", 0);
        player.jPlayer("play", start);
        clearTimeout(player.tm);
        player.tm = setTimeout(function(){
          player.jPlayer("pause");
        }, 1000*(end - start) );
      });
    });
  }
  player.jPlayer("option", "cssSelector.play", ".btn-play");
  player.jPlayer("option", "cssSelector.pause", ".btn-pause");
  player.jPlayer("option", "cssSelector.stop", ".btn-stop");
  player.jPlayer("option", "cssSelector.duration", ".duration");
  player.jPlayer("option", "cssSelector.currentTime", ".current-time");
  if(duration){
    setTimeout(function(){
      selector.find(".duration").text(formatTimeSpan(Math.floor(duration)));
    }, 200);
  }
}
<|endoftext|>