いやまったく何てことないググれば1分で見つかるやつなんだけど、
jsも久しぶりすぎてググったり昔のソース漁ったりめんどくさいので備忘録。
url見てjson内部のurlと照らし合わせて合ってたらその内容でdom書き換え。
setup : ()->
@url = location.href
@hash = location.hash
@jsonCall()
return
jsonCall : =>
@$.ajax
url: './common/language.json'
type: 'GET'
dataType: 'json'
success: (jdata, status, xhr) =>
countrys = jdata.country
t1 = ""
t2 = ""
for value, index in countrys
console.log value.url
if @url.indexOf(value.url) != -1
t1 = value.txt1
t2 = value.txt2
if t1.length==0
t1 = countrys[0].txt1
t2 = countrys[0].txt2
$("#l2txt").html(t1.replace(/[\n\r]/g, "
"))
$("#l3txt").html(t2.replace(/[\n\r]/g, "
"))
error: (xhr, status, error) =>
console.log status
return
当たり前だけどもこいうのも書かないと忘れるね。
you