Skip to content

Instantly share code, notes, and snippets.

@AM-R
Created May 4, 2018 15:14
Show Gist options
  • Save AM-R/a19bed09f060a6ba6ce66f504137d973 to your computer and use it in GitHub Desktop.
Save AM-R/a19bed09f060a6ba6ce66f504137d973 to your computer and use it in GitHub Desktop.
#= require jquery
# require jquery.turbolinks
#= require google.coffee
#= require init
#= require input_mask
#= require jquery-readyselector
# require jquery.fancybox.min
# require phone-codes.json
#= require phone_mask
#= require phone_mask_init
# require phones_ru.json
# require phones_en.json
# require planet.coffee.erb
# require planet
#= require planet_1
# require planet_world.json
# require test.coffee
#= require yandex_metric.coffee
#= require ymaps.coffee
#= require ytplayer.js
#= require bootstrap-sprockets
#= require jquery_ujs
#= require turbolinks
## loads all scripts from '/assets/javascripts/*.*'
#= require_tree .
doctype html
html
head
title
= "ADA #{rhost(2).upcase} (#{t("domains.#{rhost(2)}.title.#{locale}", locale: :common)})"
/= yield(:title)
= include_gon
= yield :javascripts
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
= javascript_include_tag 'application', 'data-turbolinks-track' => true
- content_for :javascripts
= javascript_include_tag 'planet.coffee.erb', 'data-turbolinks-track' => true
= javascript_include_tag 'test.coffee', 'data-turbolinks-track' => true
$(document).on 'turbolinks:load', ->
url = window.location.host
sub = url.split('.')
if sub[1] == 'ada'
$(".www.index").ready ->
width = 700
height = 700
speed = -1e-2
start = Date.now()
sphere = type: 'Sphere'
projection = d3.geo.orthographic().scale(width / 2.1).translate([
width / 2
height / 2
]).precision(.5)
graticule = d3.geo.graticule()
$('#planet').empty()
canvas = d3.select('div#planet').append('canvas').attr('width', width).attr('height', height)
context = canvas.node().getContext('2d')
path = d3.geo.path().projection(projection).context(context)
d3.json '<%= asset_path("planet_world.json") %>', (error, topo) ->
if error
throw error
land = topojson.feature(topo, topo.objects.land)
grid = graticule()
d3.timer ->
context.clearRect 0, 0, width, height
projection.rotate([
speed * (Date.now() - start)
-15
]).clipAngle 90
context.beginPath()
path sphere
context.lineWidth = 0
context.strokeStyle = 'transparent'
context.stroke()
context.fillStyle = 'transparent'
context.fill()
projection.clipAngle 180
context.beginPath()
path land
context.fillStyle = '#ddd'
context.fill()
context.beginPath()
path grid
context.lineWidth = .5
context.strokeStyle = 'rgba(111,111,111,0.2)'
context.stroke()
projection.clipAngle 90
context.beginPath()
path land
context.fillStyle = '#888'
context.fill()
context.lineWidth = 0
context.strokeStyle = 'transparent'
context.stroke()
return
return
d3.select(self.frameElement).style 'height', height + 'px'
else
$('#planet').empty()
$(document).on 'turbolinks:load', ->
$(".www.index").ready ->
alert('test')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment