@@ -9,7 +9,7 @@ $(document).ready(function(){
9
9
$ ( '[data-toggle="tooltip"]' ) . tooltip ( )
10
10
} )
11
11
load ( false , true ) ;
12
- chrome . storage . sync . get ( [ "show_date" , "date" , "showed_survey_popup" ] , function ( result ) {
12
+ chrome . storage . sync . get ( [ "show_date" , "date" , "showed_survey_popup" , "showed_new_feature_report" ] , function ( result ) {
13
13
if ( ! result . hasOwnProperty ( "show_date" ) || result . show_date ) {
14
14
const date = new Date ( ) ;
15
15
let currentDate = date . toLocaleDateString ( ) ;
@@ -35,6 +35,19 @@ $(document).ready(function(){
35
35
}
36
36
} )
37
37
}
38
+
39
+ if ( ! result . hasOwnProperty ( "showed_new_feature_report" ) || ! result . showed_new_feature_report ) {
40
+ Swal . fire ( {
41
+ icon : 'info' ,
42
+ title : 'You can now report images!' ,
43
+ html : "If there are any images that you don't like or find inappropriate, press the <b>Report</b> icon on the top left to report these images and never show them again!" ,
44
+ showConfirmButton : false ,
45
+ showCloseButton : true ,
46
+ onClose : function ( ) {
47
+ chrome . storage . sync . set ( { showed_new_feature_report : true } ) ;
48
+ }
49
+ } )
50
+ }
38
51
} ) ;
39
52
40
53
$ ( ".reload" ) . click ( function ( ) {
@@ -93,7 +106,42 @@ $(document).ready(function(){
93
106
} else {
94
107
window . open ( chrome . runtime . getURL ( 'options.html' ) ) ;
95
108
}
96
- } )
109
+ } ) ;
110
+
111
+ $ ( ".report" ) . click ( function ( ) {
112
+ Swal . fire ( {
113
+ title : 'Report Image' ,
114
+ html : "If you think the image is inappropriate or you don't like it, please report the image and you will not " +
115
+ "see it anymore." ,
116
+ showConfirmButton : true ,
117
+ showCloseButton : true ,
118
+ confirmButtonText : 'Report Image' ,
119
+ showCancelButton : true ,
120
+ showLoaderOnConfirm : true ,
121
+ preConfirm : function ( ) {
122
+ const imageElm = $ ( ".background-image" ) ;
123
+ if ( imageElm . length ) {
124
+ return $ . ajax ( {
125
+ url : 'http://quran-extension-api.alwaysdata.net/blacklistImage' ,
126
+ type : 'PUT' ,
127
+ data : { image : imageElm . attr ( 'src' ) } ,
128
+ success : function ( result ) {
129
+ return result ;
130
+ }
131
+ } ) ;
132
+ }
133
+ } ,
134
+ allowOutsideClick : ( ) => ! Swal . isLoading ( )
135
+ } ) . then ( function ( ) {
136
+ load ( true , false ) ;
137
+ } )
138
+ } ) ;
139
+
140
+ $ ( ".translation-container" ) . hover ( function ( ) {
141
+ $ ( this ) . children ( ".body" ) . show ( 'fast' ) ;
142
+ } , function ( ) {
143
+ $ ( this ) . children ( ".body" ) . hide ( 'fast' ) ;
144
+ } ) ;
97
145
98
146
function load ( reload , withTopSites ) {
99
147
audio = null ;
@@ -112,32 +160,7 @@ $(document).ready(function(){
112
160
setBackgroundImage ( result . image . src ) ;
113
161
}
114
162
else {
115
- let xhr = new XMLHttpRequest ( ) ;
116
-
117
- $ . ajax ( {
118
- method : 'GET' ,
119
- url : 'https://source.unsplash.com/1600x900/?nature,mountains,landscape,animal,gradient' ,
120
- headers : {
121
- 'Access-Control-Expose-Headers' : 'ETag'
122
- } ,
123
- xhr : function ( ) {
124
- return xhr ;
125
- } ,
126
- success : function ( data ) {
127
- setBackgroundImage ( xhr . responseURL ) ;
128
- let timeout = calculateTimeout ( ) ;
129
- chrome . storage . local . set ( { image : { src : xhr . responseURL , timeout} } ) ;
130
- } ,
131
- error : function ( ) {
132
- setBackgroundImage ( '/assets/offline-image.jpg' ) ;
133
- } ,
134
- complete : function ( ) {
135
- if ( reload ) {
136
- $ ( ".reload img" ) . show ( ) ;
137
- $ ( ".reload .loader" ) . hide ( ) ;
138
- }
139
- }
140
- } ) ;
163
+ setNewImage ( reload ) ;
141
164
}
142
165
143
166
if ( result . hasOwnProperty ( 'verse' ) && result . verse && now <= result . verse . timeout && ! reload ) {
@@ -305,9 +328,40 @@ $(document).ready(function(){
305
328
}
306
329
}
307
330
308
- $ ( ".translation-container" ) . hover ( function ( ) {
309
- $ ( this ) . children ( ".body" ) . show ( 'fast' ) ;
310
- } , function ( ) {
311
- $ ( this ) . children ( ".body" ) . hide ( 'fast' ) ;
312
- } ) ;
331
+ function setNewImage ( reload ) {
332
+ let xhr = new XMLHttpRequest ( ) ;
333
+ $ . ajax ( {
334
+ method : 'GET' ,
335
+ url : 'https://source.unsplash.com/1600x900/?nature,mountains,landscape,animal' ,
336
+ headers : {
337
+ 'Access-Control-Expose-Headers' : 'ETag'
338
+ } ,
339
+ xhr : function ( ) {
340
+ return xhr ;
341
+ } ,
342
+ success : function ( data ) {
343
+ $ . getJSON ( 'http://quran-extension-api.alwaysdata.net/isImageBlacklisted?image=' + encodeURI ( xhr . responseURL ) ,
344
+ function ( json , textStatus ) {
345
+ if ( json . success ) {
346
+ if ( json . blacklisted ) {
347
+ setNewImage ( false ) ;
348
+ } else {
349
+ setBackgroundImage ( xhr . responseURL ) ;
350
+ let timeout = calculateTimeout ( ) ;
351
+ chrome . storage . local . set ( { image : { src : xhr . responseURL , timeout} } ) ;
352
+ }
353
+ }
354
+ } ) ;
355
+ } ,
356
+ error : function ( ) {
357
+ setBackgroundImage ( '/assets/offline-image.jpg' ) ;
358
+ } ,
359
+ complete : function ( ) {
360
+ if ( reload ) {
361
+ $ ( ".reload img" ) . show ( ) ;
362
+ $ ( ".reload .loader" ) . hide ( ) ;
363
+ }
364
+ }
365
+ } ) ;
366
+ }
313
367
} ) ;
0 commit comments