@@ -37,96 +37,3 @@ const currentLanguage = (localStorage && localStorage[window.lsPrefix + 'current
37
37
38
38
const currentCategory = ( localStorage && localStorage [ window . lsPrefix + 'currentCategory' ] ) ?
39
39
localStorage [ window . lsPrefix + 'currentCategory' ] : 'all' ;
40
-
41
- const ractive = new Ractive ( {
42
- el : '#ractive-target' ,
43
- template : reactiveTemplate ,
44
- computed : {
45
- languages ( ) {
46
- return Object . entries ( this . get ( 'languageMappings' ) ) ;
47
- } ,
48
- categories ( ) {
49
- const lang = this . get ( 'selectedLanguage' ) ;
50
- const sims = this . get ( `simulationsByLanguage.${ lang } ` ) ;
51
- const makeCategoryId = this . get ( 'makeCategoryId' ) ;
52
- return sims . reduce ( ( acc , sim ) => acc . concat ( sim . categories ) , [ ] )
53
- . sort ( ( a , b ) => makeCategoryId ( a ) < makeCategoryId ( b ) ? - 1 : 1 )
54
- . filter ( ( val , index , arr ) => makeCategoryId ( val ) !== makeCategoryId ( arr [ index - 1 ] || [ ] ) ) ;
55
- } ,
56
- simulations ( ) {
57
- const lang = this . get ( 'selectedLanguage' ) ;
58
- const sims = this . get ( `simulationsByLanguage.${ lang } ` ) ;
59
- const category = this . get ( 'selectedCategory' ) || 'all' ;
60
-
61
- if ( category === 'all' ) {
62
- return sims ;
63
- } else {
64
- return sims . filter ( sim => {
65
- return ! ! ~ sim . categories . map ( c => c . slug ) . indexOf ( category ) ;
66
- } ) ;
67
- }
68
- }
69
- } ,
70
- data : {
71
- simulationsByLanguage : window . importedData . simsByLanguage ,
72
- selectedLanguage : currentLanguage ,
73
- selectedCategory : currentCategory ,
74
- languageMappings : window . importedData . languageMappings ,
75
-
76
- makeCategoryId ( category : Category ) {
77
- return category . slug ;
78
- } ,
79
- makeCategoryName ( category : Category ) {
80
- return category . title ;
81
- } ,
82
- getSlug : ( item ) => {
83
- return JSON . stringify ( item ) ;
84
- }
85
- } ,
86
- oninit ( ) {
87
- this . observe ( 'selectedLanguage' , function ( selectedLanguage ) {
88
- if ( localStorage ) localStorage [ window . lsPrefix + 'currentLanguage' ] = selectedLanguage ;
89
- } ) ;
90
- this . observe ( 'selectedCategory' , function ( selectedCategory ) {
91
- if ( localStorage ) localStorage [ window . lsPrefix + 'currentCategory' ] = selectedCategory ;
92
- } ) ;
93
- this . on ( 'showConfirm' , function ( ev ) {
94
- const simulation : Simulation = ev . context ;
95
-
96
- const categoryHTML = simulation . categories . map ( cat => `<li>${ cat . title } </li>` ) . join ( '' ) ;
97
- const topicsHTML = simulation . topics . map ( t => `<li>${ t } </li>` ) . join ( '' ) ;
98
-
99
- swal . fire ( {
100
- title : `${ simulation . title } ` ,
101
- html : `
102
- <div>
103
- <img src='../I/${ simulation . id } .png' />
104
- </div>
105
- <div class='flex-cont'>
106
- <div>
107
- <span>Categories</span>
108
- <ul>${ categoryHTML } </ul>
109
- </div>
110
- <div>
111
- <span>Topics</span>
112
- <ul class='topics'>${ topicsHTML } </ul>
113
- </div>
114
- </div>
115
- <div class='description'>${ simulation . description } </div>` ,
116
- showCloseButton : true ,
117
- showCancelButton : true ,
118
- confirmButtonText : 'Load'
119
- } ) . then ( ( { dismiss} ) => {
120
- const reasonsToCancel = [
121
- swal . DismissReason . cancel ,
122
- swal . DismissReason . close ,
123
- swal . DismissReason . esc ,
124
- ] ;
125
- if ( reasonsToCancel . includes ( dismiss ) ) return ;
126
- const a = document . createElement ( 'a' ) ;
127
- a . href = `${ simulation . id } _${ simulation . language } .html` ;
128
- document . body . appendChild ( a ) . click ( ) ;
129
- } ) ;
130
- } ) ;
131
- }
132
- } ) ;
0 commit comments