Created
September 18, 2012 13:43
Revisions
-
dommmel revised this gist
Sep 18, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ greeting_for = "default" : "Hi" "DE" : "default" : "Hallo" "Baden-Wurttemberg" : "Grüß Gottle" "Bayern" : "Servus" "Hamburg" : "Moin" "CH" : "Grüezi" -
dommmel revised this gist
Sep 18, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ # Usage: # <span id="sayhi">привет</span> # <script> # replace_text_with_greeting("#sayhi"); # </script> @@ -23,6 +23,7 @@ greeting_for = "Bayern" : "Servus" "Hamburg" : "Moin" "CH" : "Grüezi" "AT" : "Habe die Ehre" "FR" : "Salut" "US" : "Hello" @@ -34,4 +35,3 @@ replace_text_with_greeting = (selector) -> else greeting_for["default"] ) -
dommmel revised this gist
Sep 18, 2012 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,6 +21,8 @@ greeting_for = "default" : "Hallo" "Baden-Wurttemberg" : "Hallöle" "Bayern" : "Servus" "Hamburg" : "Moin" "CH" : "Grüezi" "FR" : "Salut" "US" : "Hello" @@ -33,4 +35,3 @@ replace_text_with_greeting = (selector) -> greeting_for["default"] ) -
dommmel renamed this gist
Sep 18, 2012 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
dommmel created this gist
Sep 18, 2012 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ ################################################################## # # # Copyright (C) 2012 Dommmel <dommmel@gmail.com> # # This code is released under WTFPL, version 2.0. # # # ################################################################## # Usage: # <span id="sayhi">привет</span> # <script> # replace_text_with_greeting("#sayhi") # </script> # country codes should have the ISO 3166 format. # See http://en.wikipedia.org/wiki/ISO_3166-2 greeting_for = "default" : "Hi" "DE" : "default" : "Hallo" "Baden-Wurttemberg" : "Hallöle" "Bayern" : "Servus" "FR" : "Salut" "US" : "Hello" replace_text_with_greeting = (selector) -> $.getJSON "http://freegeoip.net/json/?callback=?", (resp) -> $(selector).text( if greeting_for[resp.country_code]? greeting_for[resp.country_code][resp.region_name] or greeting_for[resp.country_code]["default"] or greeting_for[resp.country_code] else greeting_for["default"] )