rails_client_checker 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c65d2c580900caea34f459d47ab4fd5b8a0a364e
4
+ data.tar.gz: 1be126f12587caff83c81eaad77bc8e93f3f2369
5
+ SHA512:
6
+ metadata.gz: a17ff2275d2d6accb739ecaa34929a3de5951a92a534d758de442c10dbd1bcbc2d6970954586b1d272570098d4ad0162b1a7984cfc851bcc9ef46122b3b6da7f
7
+ data.tar.gz: 05284e1c42e258751decb536c68dff8c684abc3e49785e28138d67a37cecaf6f5279e7947a7a11cc4373605d214116d82aa5c04bbc7abc6d7244c615b8b8a440
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ref_parsers.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,17 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ref_parsers (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.1.0)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 1.3)
16
+ rake
17
+ ref_parsers!
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Hossam Hammady
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,153 @@
1
+ # Rails Client Checker
2
+
3
+ ### Problem
4
+ Even with 100% coverage integration tests, your Rails application may not work for all users. These are some causes for such situation:
5
+
6
+ - Some users will be using weird or outdated browsers.
7
+ - Cookies may be disabled.
8
+ - There could be firewalls blocking access to your asset host, or to third party services
9
+ like NewRelic, Google Analytics, Pusher, ...
10
+ - Web-sockets could be blocked by ISP, company firewall or by domain-managed computers.
11
+ - ...
12
+
13
+ It is troublesome to write client-side code
14
+ in your apps to check these things. You may also spend hours with customers in support
15
+ channels trying to identify why it does not work for them.
16
+
17
+ ### Solution
18
+ This is a Rails gem offering end-users a page to check their browsers compatibility
19
+ with your application. The page is configurable and it works by running several checker modules in their browsers.
20
+ Standard modules are: browser name/version, cookies, asset loading and [Pusher](https://pusher.com) connectivity.
21
+ You can easily enable/disable standard modules and add custom modules logic purely using Javascript.
22
+
23
+ ### Demo
24
+ This gem was extracted from [Rayyan](http://rayyan.qcri.org/) web application and a real client checker page exists [there](http://rayyan.qcri.org/check).
25
+
26
+
27
+ ## Installation
28
+
29
+ The gem was tested on Rails 4.1 and 3.2. If you have a different version and it does not work for you, please create a github issue.
30
+
31
+ Add this line to your application's Gemfile:
32
+
33
+ gem 'rails_client_checker'
34
+
35
+ And then execute:
36
+
37
+ $ bundle
38
+
39
+ Or install it yourself as:
40
+
41
+ $ gem install rails_client_checker
42
+
43
+ ## Basic Usage
44
+
45
+ Just add the following to your `config/routes.rb`:
46
+
47
+ # config/routes.rb
48
+ YourApp::Application.routes.draw do
49
+ ...
50
+ mount RailsClientChecker::Engine => '/checker'
51
+ ...
52
+ end
53
+
54
+ This will generate 3 new routes:
55
+
56
+ 1. `/checker/check` that loads the checker page,
57
+ 2. `/checker/set_cookie` and
58
+ 3. `/checker/get_cookie`, both used in the cookie test.
59
+
60
+ You can also mount the routes on `'/'` instead of `'/checker'` if you don't have any conflicting routes in your application. This will make your routes simpler, for example `/check` instead of `/checker/check`.
61
+
62
+ It is a good idea to insert a link for your brand new checker page in your app. In any ERB template insert the following:
63
+
64
+ <%= link_to "Check your browser compatibility", rails_client_checker.check_path %>
65
+
66
+ It is recommended to place this link in your sign in/sign up page. If you are using [devise](https://github.com/plataformatec/devise) for authentication, [generate the views](https://github.com/plataformatec/devise#configuring-views) then insert the link at the end of `app/views/devise/shared/_links.erb`.
67
+
68
+
69
+ ## Configuration
70
+ By default 3 standard checker modules are enabled:
71
+
72
+ 1. Browser name/version checker
73
+ 2. Asset loading checker
74
+ 3. Cookies checker
75
+
76
+ The Pusher standard checker is disabled by default.
77
+
78
+ To enable/disable modules and set other configuration options, generate an initializer:
79
+
80
+ rails generate rails_client_checker:initializer
81
+
82
+ This will generate `config/initializers/rails_client_checker.rb`. Check it for all configuration options. You should restart your rails servers after
83
+ changing this file.
84
+
85
+ ### Advanced view customization
86
+ If you want to change the look and feel of the checker page, you can easily do this by running the view generator:
87
+
88
+ rails generate rails_client_checker:view
89
+
90
+ This will generate the following:
91
+
92
+ 1. `check.html.erb` for editing the page HTML
93
+ 2. `check.css`: for editing the page stylesheets
94
+ 3. `_noscript.html.erb` for editing the text that appears in browsers that do not support Javascript (or having it disabled)
95
+
96
+ ### Adding custom checkers in Javascript
97
+ You can add any checker logic to the checkers workflow by defining your `custom_checkers` array.
98
+ You can check the [standard checkers implementation](https://github.com/hammady/rails_client_checker/blob/master/app/assets/javascripts/check.js) to get ideas, just look for `checkers.push(...)` in that file.
99
+
100
+ Assume we want to add a checker called "my random checker" that fails randomly 50% of the time:
101
+
102
+ # app/assets/javascripts/custom_checkers.js
103
+ custom_checkers = [
104
+ {
105
+ display: "my random checker",
106
+ worker: function(callback){
107
+ if (Math.random() >= 0.5)
108
+ callback(null)
109
+ else
110
+ callback("50% random error, LOL :)")
111
+ }
112
+ }
113
+ ];
114
+
115
+ Basically, `custom_checkers` is an array of objects, each has 2 attributes:
116
+
117
+ 1. `display` that defines the text that appears in the page
118
+ 2. `worker` function that does the checker work. You can write any Javascript code inside this function, e.g. do ajax calls, call your own application routes, ... To communicate back the checker result, call the `callback` function with `null` to denote success or any string to describe the error.
119
+
120
+ ## Tips and Tricks
121
+
122
+ You can reuse the `<noscript>` tag that appears when the user browser
123
+ does not support Javascript in all your pages, without generating
124
+ the gem views. Simply include the following in your layout `application.html.erb`:
125
+
126
+ # app/views/layouts/application.html.erb
127
+ ...
128
+ <body>
129
+ ...
130
+ <%= render partial: 'rails_client_checker/checker/noscript' %>
131
+ ...
132
+
133
+ ## Contributing
134
+
135
+ 1. Fork it
136
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
137
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
138
+ 4. Push to the branch (`git push origin my-new-feature`)
139
+ 5. Create new Pull Request
140
+
141
+ ## About
142
+ This gem was developed by Hossam Hammady at [Qatar Computing Research Institute, Data Analytics](http://da.qcri.org).
143
+
144
+ Reach me at:
145
+
146
+ - Twitter: [@hammady](http://www.twitter.com/hammady)
147
+ - Email: hhammady@qf[dot]org[dot]qa
148
+
149
+ The browser compatibility module was taken as is from [Browser-Update.org](http://browser-update.org)
150
+ with minor modifications to fit in the gem workflow.
151
+
152
+ ## License
153
+ MIT
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,288 @@
1
+ //browser-update.org notification script, <browser-update.org>
2
+ //Copyright (c) 2007-2015, MIT Style License <browser-update.org/LICENSE.txt>
3
+ //It is RECOMMEDED to directly link to this file and not to use a local copy
4
+ //because we update and maintain the detection code
5
+ var $buo = function(op,test) {
6
+ var jsv=17;
7
+ var n = window.navigator,b;
8
+ this.op=op||{};
9
+ //options DerGer4etZ4elt!
10
+ this.op.l = op.l||(n.languages ? n.languages[0] : null) || n.language || n.browserLanguage || n.userLanguage||document.documentElement.getAttribute("lang")||"en";
11
+ var ll=this.op.l.substr(0,2);
12
+ this.op.vsakt = {i:11,f:36,o:28,s:8,n:20,c:41};
13
+ this.op.vsdefault = {i:9,f:34,o:12.1,s:6.1,n:12,c:39};
14
+ this.op.vsmin={i:8,f:5,o:12,s:5.1,n:12};
15
+ var myvs=op.vs||{};
16
+ this.op.vs =op.vs||this.op.vsdefault;
17
+ for (b in this.op.vsakt) {
18
+ if (this.op.vs[b]>=this.op.vsakt[b])
19
+ this.op.vs[b]=this.op.vsakt[b]-0.2;
20
+ if (!this.op.vs[b])
21
+ this.op.vs[b]=this.op.vsdefault[b];
22
+ if (this.op.vs[b]<this.op.vsmin[b])
23
+ this.op.vs[b]=this.op.vsmin[b];
24
+ }
25
+ if (op.reminder<0.1 || op.reminder===0)
26
+ this.op.reminder=0;
27
+ else
28
+ this.op.reminder=op.reminder||24;
29
+ this.op.reminderClosed=op.reminderClosed||(24*7);
30
+ this.op.onshow = op.onshow||function(o){};
31
+ this.op.onpass = op.onpass||function(o){};
32
+ this.op.onclick = op.onclick||function(o){};
33
+ this.op.onclose = op.onclose||function(o){};
34
+ this.op.url= op.url||"http://browser-update.org/update-browser.html#"+jsv+"@"+(location.hostname||"x");
35
+ if (op.l)
36
+ this.op.url= op.url||"http://browser-update.org/"+ll+"/update-browser.html#"+jsv+"@"+(location.hostname||"x");
37
+ this.op.pageurl = op.pageurl || window.location.hostname || "unknown";
38
+ this.op.newwindow=(op.newwindow!==false);
39
+
40
+ this.op.test=test||op.test||false;
41
+ if (window.location.hash=="#test-bu")
42
+ this.op.test=true;
43
+ /*
44
+ if (op.exp && !this.op.test && Math.round(Math.random()*100)<1) {
45
+ var ix = new Image();
46
+ ix.src="//browser-update.org/uas.php";
47
+ }
48
+ */
49
+
50
+ function getBrowser(ua_str) {
51
+ var n,v,t,ua=ua_str||navigator.userAgent;
52
+ var names={i:'Internet Explorer',f:'Firefox',o:'Opera',s:'Apple Safari',n:'Netscape Navigator', c:"Chrome", x:"Other"};
53
+ if (/bot|googlebot|facebook|slurp|wii|silk|blackberry|maxthon|maxton|mediapartners|dolfin|dolphin|adsbot|silk|android|phone|bingbot|google web preview|like firefox|chromeframe|seamonkey|opera mini|min|meego|netfront|moblin|maemo|arora|camino|flot|k-meleon|fennec|kazehakase|galeon|android|mobile|iphone|ipod|ipad|epiphany|konqueror|rekonq|symbian|webos|coolnovo|blackberry|bb10|RIM|PlayBook|PaleMoon|QupZilla|YaBrowser/i.test(ua)) n="x";
54
+ else if (/Trident.*rv:(\d+\.\d+)/i.test(ua)) n="i";
55
+ else if (/Trident.(\d+\.\d+)/i.test(ua)) n="io";
56
+ else if (/MSIE.(\d+\.\d+)/i.test(ua)) n="i";
57
+ else if (/OPR.(\d+\.\d+)/i.test(ua)) n="o";
58
+ else if (/Chrome.(\d+\.\d+)/i.test(ua)) n="c";
59
+ else if (/Firefox.(\d+\.\d+)/i.test(ua)) n="f";
60
+ else if (/Version.(\d+.\d+).{0,10}Safari/i.test(ua)) n="s";
61
+ else if (/Safari.(\d+)/i.test(ua)) n="so";
62
+ else if (/Opera.*Version.(\d+\.\d+)/i.test(ua)) n="o";
63
+ else if (/Opera.(\d+\.?\d+)/i.test(ua)) n="o";
64
+ else if (/Netscape.(\d+)/i.test(ua)) n="n";
65
+ else return {n:"x",v:0,t:names[n]};
66
+
67
+ var v= parseFloat(RegExp.$1);
68
+ var donotnotify=false;
69
+ //do not notify ver old systems since their is no up-to-date browser available
70
+ if (/windows.nt.5.0|windows.nt.4.0|windows.98|os x 10.4|os x 10.5|os x 10.3|os x 10.2/.test(ua)) donotnotify="oldOS";
71
+
72
+ //do not notify firefox ESR
73
+ if (n=="f" && (Math.round(v)==24 || Math.round(v)==31))
74
+ donotnotify="ESR";
75
+ //do not notify opera 12 on linux since it is the latest version
76
+ if (/linux|x11|unix|bsd/.test(ua) && n=="o" && v>12)
77
+ donotnotify="Opera12Linux";
78
+
79
+ if (n=="x") return {n:"x",v:v||0,t:names[n],donotnotify:donotnotify};
80
+
81
+
82
+ if (n=="so") {
83
+ v=((v<100) && 1.0) || ((v<130) && 1.2) || ((v<320) && 1.3) || ((v<520) && 2.0) || ((v<524) && 3.0) || ((v<526) && 3.2) ||4.0;
84
+ n="s";
85
+ }
86
+ if (n=="i" && v==7 && window.XDomainRequest) {
87
+ v=8;
88
+ }
89
+ if (n=="io") {
90
+ n="i";
91
+ if (v>6) v=11;
92
+ else if (v>5) v=10;
93
+ else if (v>4) v=9;
94
+ else if (v>3.1) v=8;
95
+ else if (v>3) v=7;
96
+ else v=9;
97
+ }
98
+ return {n:n,v:v,t:names[n]+" "+v,donotnotify:donotnotify};
99
+ }
100
+
101
+ this.op.browser=getBrowser();
102
+ if (!this.op.test && (!this.op.browser || !this.op.browser.n || this.op.browser.n=="x" || this.op.browser.donotnotify!==false || (document.cookie.indexOf("browserupdateorg=pause")>-1 && this.op.reminder>0) || this.op.browser.v>this.op.vs[this.op.browser.n])) {
103
+ this.op.onpass()
104
+ return;
105
+ }
106
+
107
+
108
+ if (!this.op.test && Math.round(Math.random()*100)<1) {
109
+ var i = new Image();
110
+ i.src="//browser-update.org/viewcount.php?n="+this.op.browser.n+"&v="+this.op.browser.v + "&p="+ escape(this.op.pageurl) + "&jsv="+jsv+ "&inv="+this.op.v+"&vs="+myvs.i+","+myvs.f+","+myvs.o+","+myvs.s;
111
+ }
112
+
113
+ function setCookie(hours) {
114
+ var d = new Date(new Date().getTime() +1000*3600*hours);
115
+ document.cookie = 'browserupdateorg=pause; expires='+d.toGMTString()+'; path=/';
116
+ }
117
+ if (this.op.reminder>0) {
118
+ setCookie(this.op.reminder);
119
+ }
120
+
121
+ var languages = "xx,jp,sl,id,uk,rm,da,ca,sv,hu,fa,gl";
122
+ if (languages.indexOf(ll)>0)
123
+ this.op.url="http://browser-update.org/update.html#"+jsv+"@"+(location.hostname||"x");
124
+ var tar="";
125
+ if (this.op.newwindow)
126
+ tar=' target="_blank"';
127
+
128
+ function busprintf() {
129
+ var args=arguments;
130
+ var data = args[ 0 ];
131
+ for( var k=1; k<args.length; ++k ) {
132
+ data = data.replace( /%s/, args[ k ] );
133
+ }
134
+ return data;
135
+ }
136
+
137
+ var t = 'This website would like to remind you: Your browser (%s) is <b>out of date</b>.\
138
+ <a%s>Update your browser</a> for more security, comfort and the best experience on this site.';
139
+ if (ll=="de")
140
+ t = 'Sie verwenden einen <b>veralteten Browser</b> (%s) mit <b>Sicherheitsschwachstellen</b> und <b>k&ouml;nnen nicht alle Funktionen dieser Webseite nutzen</b>. \
141
+ <a%s>Hier erfahren Sie, wie einfach Sie Ihren Browser aktualisieren k&ouml;nnen</a>.';
142
+ else if (ll=="it")
143
+ t = 'Il tuo browser (%s) <b>non è aggiornato</b>. Ha delle <b>falle di sicurezza</b> e potrebbe <b>non visualizzare correttamente</b> le \
144
+ pagine di questo e altri siti. \
145
+ <a%s>Aggiorna il tuo browser</a>!';
146
+ else if (ll=="pl")
147
+ t = 'Przeglądarka (%s), której używasz, jest przestarzała. Posiada ona udokumentowane <b>luki bezpieczeństwa, inne wady</b> oraz <b>ograniczoną funkcjonalność</b>. Tracisz możliwość skorzystania z pełni możliwości oferowanych przez niektóre strony internetowe. <a%s>Dowiedz się jak zaktualizować swoją przeglądarkę</a>.';
148
+ else if (ll=="es")
149
+ t = 'Su navegador (%s) <b>no está actualizado</b>. Tiene <b>fallos de seguridad</b> conocidos y podría <b>no mostrar todas las características</b> de este y otros sitios web. <a%s>Averigüe cómo actualizar su navegador.</a>';
150
+ else if (ll=="nl")
151
+ t = 'Uw browser (%s) is <b>oud</b>. Het heeft bekende <b>veiligheidsissues</b> en kan <b>niet alle mogelijkheden</b> weergeven van deze of andere websites. <a%s>Lees meer over hoe uw browser te upgraden</a>';
152
+ else if (ll=="pt")
153
+ t = 'Seu navegador (%s) está <b>desatualizado</b>. Ele possui <b>falhas de segurança</b> e pode <b>apresentar problemas</b> para exibir este e outros websites. <a%s>Veja como atualizar o seu navegador</a>';
154
+ else if (ll=="sl")
155
+ t = 'Vaš brskalnik (%s) je <b>zastarel</b>. Ima več <b>varnostnih pomankljivosti</b> in morda <b>ne bo pravilno prikazal</b> te ali drugih strani. \
156
+ <a%s>Poglejte kako lahko posodobite svoj brskalnik</a>';
157
+ else if (ll=="ru")
158
+ t = 'Ваш браузер (%s) <b>устарел</b>. Он имеет <b>уязвимости в безопасности</b> и может <b>не показывать все возможности</b> на этом и других сайтах. <a%s>Узнайте, как обновить Ваш браузер</a>';
159
+ else if (ll=="id")
160
+ t = 'Browser Anda (%s) sudah <b>kedaluarsa</b>. Browser yang Anda pakai memiliki <b>kelemahan keamanan</b> dan mungkin <b>tidak dapat menampilkan semua fitur</b> dari situs Web ini dan lainnya. <a%s> Pelajari cara memperbarui browser Anda</a>';
161
+ else if (ll=="uk")
162
+ t = 'Ваш браузер (%s) <b>застарів</b>. Він <b>уразливий</b> й може <b>не відображати всі можливості</b> на цьому й інших сайтах. <a%s>Дізнайтесь, як оновити Ваш браузер</a>';
163
+ else if (ll=="ko")
164
+ t = '지금 사용하고 계신 브라우저(%s)는 <b>오래되었습니다.</b> 알려진 <b>보안 취약점</b>이 존재하며, 새로운 웹 사이트가 <b>깨져 보일 수도</b> 있습니다. <a%s>브라우저를 어떻게 업데이트하나요?</a>';
165
+ else if (ll=="rm")
166
+ t = 'Tes navigatur (%s) è <b>antiquà</b>. El cuntegna <b>problems da segirezza</b> enconuschents e mussa eventualmain <b>betg tut las funcziuns</b> da questa ed autras websites. <a%s>Emprenda sco actualisar tes navigatur</a>.';
167
+ else if (ll=="ja")
168
+ t = 'お使いのブラウザ「%s」は、<b>時代遅れ</b>のバージョンです。既知の<b>脆弱性</b>が存在するばかりか、<b>機能不足</b>によって、サイトが正常に表示できない可能性があります。 \
169
+ <a%s>ブラウザを更新する方法を確認する</a>';
170
+ else if (ll=="fr")
171
+ t = 'Votre navigateur (%s) est <b>périmé</b>. Il contient des <b>failles de sécurité</b> et pourrait <b>ne pas afficher certaines fonctionalités</b> des sites internet récents. <a%s>Découvrez comment mettre votre navigateur à jour</a>';
172
+ else if (ll=="da")
173
+ t = 'Din browser (%s) er <b>for&aelig;ldet</b>. Den har kendte <b>sikkerhedshuller</b> og kan m&aring;ske <b>ikke vise alle funktioner</b> p&aring; dette og andre websteder. <a%s>Se hvordan du opdaterer din browser</a>';
174
+ else if (ll=="sq")
175
+ t = 'Shfletuesi juaj (%s) është <b>ca i vjetër</b>. Ai ka <b>të meta sigurie</b> të njohura dhe mundet të <b>mos i shfaqë të gjitha karakteristikat</b> e kësaj dhe shumë faqeve web të tjera. <a%s>Mësoni se si të përditësoni shfletuesin tuaj</a>';
176
+ else if (ll=="ca")
177
+ t = 'El teu navegador (%s) està <b>desactualitzat</b>. Té <b>vulnerabilitats</b> conegudes i pot <b>no mostrar totes les característiques</b> d\'aquest i altres llocs web. <a%s>Aprèn a actualitzar el navegador</a>';
178
+ else if (ll=="tr")
179
+ t = 'Tarayıcınız (%s) <b>güncel değildir.</b>. Eski versiyon olduğu için <b>güvenlik açıkları</b> vardır ve görmek istediğiniz bu web sitesinin ve diğer web sitelerinin <b>tüm özelliklerini hatasız bir şekilde</b> gösteremeyecektir. \
180
+ <a%s>Tarayıcınızı nasıl güncelleyeceğinizi öğrenin!</a>';
181
+ else if (ll=="fa")
182
+ t = 'مرورگر شما (%s) <b>از رده خارج شده</b> می باشد. این مرورگر دارای <b>مشکلات امنیتی شناخته شده</b> می باشد و <b>نمی تواند تمامی ویژگی های این</b> وب سایت و دیگر وب سایت ها را به خوبی نمایش دهد. \
183
+ <a%s>در خصوص گرفتن راهنمایی درخصوص نحوه ی به روز رسانی مرورگر خود اینجا کلیک کنید.</a>';
184
+ else if (ll=="sv")
185
+ t = 'Din webbläsare (%s) är <b>föråldrad</b>. Den har kända <b>säkerhetshål</b> och <b>kan inte visa alla funktioner korrekt</b> på denna och på andra webbsidor. <a%s>Uppdatera din webbläsare idag</a>';
186
+ else if (ll=="hu")
187
+ t = 'Az Ön böngészője (%s) <b>elavult</b>. Ismert <b>biztonsági hiányosságai</b> vannak és esetlegesen <b>nem tud minden funkciót megjeleníteni</b> ezen vagy más weboldalakon. <a%s>Itt talál bővebb információt a böngészőjének frissítésével kapcsolatban</a> ';
188
+ else if (ll=="gl")
189
+ t = 'O seu navegador (%s) está <b>desactualizado</b>. Ten coñecidos <b>fallos de seguranza</b> e podería <b>non mostrar tódalas características</b> deste e outros sitios web. <a%s>Aprenda como pode actualizar o seu navegador</a>';
190
+ else if (ll=="cs")
191
+ t = 'Váš prohlížeč (%s) je <b>zastaralý</b>. Jsou známy <b>bezpečnostní rizika</b> a možná <b>nedokáže zobrazit všechny prvky</b> této a dalších webových stránek. <a%s>Naučte se, jak aktualizovat svůj prohlížeč</a>';
192
+ else if (ll=="he")
193
+ t = 'הדפדפן שלך (%s) <b>אינו מעודכן</b>. יש לו <b>בעיות אבטחה ידועות</b> ועשוי <b>לא להציג את כל התכונות</b> של אתר זה ואתרים אחרים. <a%s>למד כיצד לעדכן את הדפדפן שלך</a>';
194
+ else if (ll=="nb")
195
+ t='Nettleseren din (%s) er <b>utdatert</b>. Den har kjente <b>sikkerhetshull</b> og <b>kan ikke vise alle funksjonene</b> på denne og andre websider. <a%s>Lær hvordan du kan oppdatere din nettleser</a>';
196
+ else if (ll=="zh")
197
+ t='您的浏览器(%s) 需要更新。该浏览器有诸多安全漏洞,无法显示本网站的所有功能。 <a%s>了解如何更新浏览器</a>';
198
+ else if (ll=="fi")
199
+ t='Selaimesi (%s) on <b>vanhentunut</b>. Siinä on tunnettuja tietoturvaongelmia eikä se välttämättä tue kaikkia ominaisuuksia tällä tai muilla sivustoilla. <a%s>Lue lisää siitä kuinka päivität selaimesi</a>.';
200
+ else if (ll=="tr")
201
+ t='Tarayıcınız (%s) <b>güncel değil</b>. Eski versiyon olduğu için <b>güvenlik açıkları</b> vardır ve görmek istediğiniz bu web sitesinin ve diğer web sitelerinin <b>tüm özelliklerini hatasız bir şekilde</b> gösteremeyecektir. <a%s>Tarayıcınızı nasıl güncelleyebileceğinizi öğrenin</a>';
202
+ else if (ll=="ro")
203
+ t='Browser-ul (%s) tau este <b>invechit</b>. Detine <b>probleme de securitate</b> cunoscute si poate <b>sa nu afiseze corect</b> toate elementele acestui si altor site-uri. <a%s>Invata cum sa-ti actualizezi browserul.</a>';
204
+ else if (ll=="bg")
205
+ t='Вашият браузър (%s) <b>не е актуален</b>. Известно е, че има <b>пропуски в сигурността</b> и може <b>да не покаже правилно</b> този или други сайтове. <a%s>Научете как да актуализирате браузъра си</a>.';
206
+ else if (ll=="el")
207
+ t = 'Αυτός ο ιστότοπος σας υπενθυμίζει: Ο φυλλομετρητής σας (%s) είναι <b>παρωχημένος</b>.\
208
+ <a%s>Ενημερώστε το πρόγραμμα περιήγησής σας</a> για μεγαλύτερη ασφάλεια και άνεση σε αυτήν την ιστοσελίδα.';
209
+
210
+
211
+ if (op.text)
212
+ t = op.text;
213
+ if (op["text_"+ll])
214
+ t = op["text_"+ll];
215
+
216
+ this.op.text=busprintf(t,this.op.browser.t,' href="'+this.op.url+'"'+tar);
217
+
218
+ var div = document.createElement("div");
219
+ this.op.div = div;
220
+ div.id="buorg";
221
+ div.className="buorg";
222
+ div.innerHTML= '<div>' + this.op.text + '<div id="buorgclose">&times;</div></div>';
223
+
224
+ var sheet = document.createElement("style");
225
+ //sheet.setAttribute("type", "text/css");
226
+ var style = ".buorg {position:absolute;position:fixed;z-index:111111;\
227
+ width:100%; top:0px; left:0px; \
228
+ border-bottom:1px solid #A29330; \
229
+ background:#FDF2AB no-repeat 13px center url(//browser-update.org/img/small/"+this.op.browser.n+".gif);\
230
+ text-align:left; cursor:pointer; \
231
+ font-family: Arial,Helvetica,sans-serif; color:#000; font-size: 12px;}\
232
+ .buorg div { padding:5px 36px 5px 40px; } \
233
+ .buorg a,.buorg a:visited {color:#E25600; text-decoration: underline;}\
234
+ #buorgclose { position: absolute; right: 6px; top:-2px; height: 20px; width: 12px; font-weight: bold;font-size:18px; padding:0; }";
235
+ document.body.insertBefore(div,document.body.firstChild);
236
+ document.getElementsByTagName("head")[0].appendChild(sheet);
237
+ try {
238
+ sheet.innerText=style;
239
+ sheet.innerHTML=style;
240
+ }
241
+ catch(e) {
242
+ try {
243
+ sheet.styleSheet.cssText=style;
244
+ }
245
+ catch(e) {
246
+ return;
247
+ }
248
+ }
249
+ var me=this;
250
+ div.onclick=function(){
251
+ if (me.op.newwindow)
252
+ window.open(me.op.url,"_blank");
253
+ else
254
+ window.location.href=me.op.url;
255
+ setCookie(me.op.reminderClosed);
256
+ me.op.onclick(me.op);
257
+ return false;
258
+ };
259
+ try {
260
+ div.getElementsByTagName("a")[0].onclick = function(e) {
261
+ var e = e || window.event;
262
+ if (e.stopPropagation) e.stopPropagation();
263
+ else e.cancelBubble = true;
264
+ me.op.onclick(me.op);
265
+ return true;
266
+ };
267
+ }
268
+ catch(e) {}
269
+
270
+ var hm=document.getElementsByTagName("html")[0]||document.body;
271
+ this.op.bodymt = hm.style.marginTop;
272
+ hm.style.marginTop = (div.clientHeight)+"px";
273
+ (function(me) {
274
+ document.getElementById("buorgclose").onclick = function(e) {
275
+ var e = e || window.event;
276
+ if (e.stopPropagation) e.stopPropagation();
277
+ else e.cancelBubble = true;
278
+ me.op.div.style.display = "none";
279
+ hm.style.marginTop = me.op.bodymt;
280
+ me.op.onclose(me.op);
281
+ setCookie(me.op.reminderClosed);
282
+ return true;
283
+ };
284
+ })(me);
285
+
286
+ op.onshow(this.op);
287
+
288
+ };
@@ -0,0 +1,159 @@
1
+ // checking engine (no need to modify to edit checkers)
2
+
3
+ var checkers = custom_checkers.reverse()
4
+
5
+ $(document).ready(function()
6
+ {
7
+ var run_engine = function()
8
+ {
9
+ try {
10
+ // run all checkers
11
+ var count = checkers.length
12
+ var errors = 0
13
+ $.each(checkers, function(id, checker){
14
+ // initialize checker display
15
+ checker.div = $(
16
+ "<div class='checker'>" +
17
+ "<span class='display'>Checking "+checker.display+"</span>" +
18
+ "<span class='status'>...</span>" +
19
+ "<div class='error'></div>" +
20
+ "</div>"
21
+ ).prependTo($("#checkers_report"))
22
+
23
+ // call worker
24
+ checker.worker(function(error){
25
+ count--
26
+ if (error) {
27
+ errors++
28
+ // show error
29
+ $(".status", checker.div).addClass("no").html("&#215")
30
+ $(".error", checker.div).html(error)
31
+ }
32
+ else {
33
+ // show success
34
+ $(".status", checker.div).addClass("ok").html("&#10004")
35
+ }
36
+ // completion
37
+ if (count == 0) {
38
+ if (errors == 0) {
39
+ // show overall success
40
+ $(".summary.success").show()
41
+ }
42
+ else {
43
+ // show overall errors
44
+ $(".summary.failure").show()
45
+ }
46
+ }
47
+ })
48
+ })
49
+ }
50
+ catch(e) {
51
+ // show engine error
52
+ }
53
+ }
54
+
55
+ // add/delete checkers by just pushing object to checkers
56
+
57
+ if ($.inArray("pusher", checkers_list) >= 0) {
58
+ checkers.push({
59
+ display: "push connectivity",
60
+ worker: function(callback){
61
+ try {
62
+ var pusher = new Pusher($("#pusher_key").html());
63
+ var channel = pusher.subscribe('test_channel');
64
+ channel.bind('pusher:subscription_succeeded', function() {
65
+ callback(null)
66
+ });
67
+ }
68
+ catch(e) {
69
+ callback(e)
70
+ }
71
+ }
72
+ })
73
+ }
74
+
75
+ if ($.inArray("cookies", checkers_list) >= 0) {
76
+ checkers.push({
77
+ display: "cookies",
78
+ worker: function(callback){
79
+ var key = 'test_cookie', val = 'test_value'
80
+ $.ajax({
81
+ url: $("#set_cookie_path").html(),
82
+ data: {
83
+ key: key,
84
+ val: val
85
+ },
86
+ success: function(){
87
+ $.ajax({
88
+ url: $("#get_cookie_path").html(),
89
+ data: {
90
+ key: key
91
+ },
92
+ success: function(data){
93
+ if (data[key] == val)
94
+ callback(null)
95
+ else
96
+ callback("Cookies not set correctly")
97
+ },
98
+ error: function(jqXHR, textStatus, errorThrown){
99
+ callback(textStatus + " " + (errorThrown || ""))
100
+ }
101
+ })
102
+ },
103
+ error: function(jqXHR, textStatus, errorThrown){
104
+ callback(textStatus + " " + (errorThrown || ""))
105
+ }
106
+ })
107
+ }
108
+ })
109
+ }
110
+
111
+ if ($.inArray("assets", checkers_list) >= 0) {
112
+ checkers.push({
113
+ display: "static assets loading",
114
+ worker: function(callback){
115
+ $.ajax({
116
+ url: $("#dummy_asset_path").html(),
117
+ dataType: "script",
118
+ success: function(){
119
+ if (typeof DUMMY_JS_VARIABLE == 'undefined')
120
+ callback("Content error")
121
+ else
122
+ callback(null)
123
+ },
124
+ error: function(jqXHR, textStatus, errorThrown){
125
+ callback(textStatus + " " + (errorThrown || ""))
126
+ }
127
+ })
128
+ }
129
+ })
130
+ }
131
+
132
+ if ($.inArray("browser", checkers_list) >= 0) {
133
+ checkers.push({
134
+ display: "browser compatability",
135
+ worker: function(callback){
136
+ // modern browser check (check http://browser-update.org/customize.html)
137
+ // FF version history: http://en.wikipedia.org/wiki/Firefox_release_history
138
+ // FF 27 official on Feb 2014
139
+ $buo({
140
+ // vs: {f:27},
141
+ reminder: 0,
142
+ reminderClosed: 0,
143
+ newwindow: false,
144
+ onshow: function(op){
145
+ callback("Upgrade your browser")
146
+ },
147
+ onpass: function(){
148
+ callback(null)
149
+ },
150
+ text: ""
151
+ });
152
+ }
153
+ })
154
+ }
155
+
156
+ // TODO: SSL checker (SSL assets using AWS CloudFront)
157
+
158
+ run_engine()
159
+ })
@@ -0,0 +1 @@
1
+ var DUMMY_JS_VARIABLE = 1;
@@ -0,0 +1 @@
1
+ custom_checkers = [];