annotate index.html @ 0:3c9ac4a429a5

Initial import.
author nanaya <me@myconan.net>
date Thu, 11 Jun 2015 16:43:21 +0900
parents
children b48d5c9c2ce8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
1 <!doctype html>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
2 <head>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
3 <title>Kalkulator</title>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
4 <meta name="viewport" content="width=device-width">
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
5 <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
6 <style type="text/css">
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
7 body {
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
8 font-size: 12px;
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
9 font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
10 line-height: 1.5;
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
11 margin: 0px;
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
12 background-color: #eee;
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
13 }
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
14 #content {
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
15 width: 100%;
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
16 min-height: 100vh;
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
17 padding: 10px;
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
18 margin: auto;
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
19 background-color: #fff;
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
20 }
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
21 @media (min-width: 600px) {
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
22 #content {
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
23 width: 500px;
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
24 }
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
25 }
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
26 * { box-sizing: border-box; }
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
27 ul { padding-left: 20px; }
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
28 #n, .js { display: none; }
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
29 input, button, select, option, .js { font-size: 150%; }
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
30 </style>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
31 </head>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
32 <body>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
33 <div id="content">
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
34 <h1>Konversi buat nitip</h1>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
35 <form>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
36 <p>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
37 <label for="x">Jumlah dalam yen:</label>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
38 <br>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
39 <input id="x" name="x" type="number" autofocus>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
40 </p>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
41 <p>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
42 <button type="submit">Hitung</button>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
43 <button type="reset">Hapus</button>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
44 </p>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
45 </form>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
46 <div class="js" id="loading">
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
47 <p>Memuat data nilai tukar...</p>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
48 </div>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
49 <div class="js" id="ok">
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
50 <p>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
51 Biaya:
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
52 </p>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
53 <ul>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
54 <li>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
55 Bank transfer:
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
56 <span id="result-bank"></span> IDR
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
57 (<span id="rate-text"></span> IDR/JPY)
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
58 </li>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
59 <li>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
60 PayPal:
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
61 <span id="result-paypal"></span> JPY
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
62 </li>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
63 </ul>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
64 </div>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
65 <div class="js" id="error">
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
66 <p>Koneksi ke server nilai tukar bermasalah.</p>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
67 </div>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
68
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
69 <hr>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
70 <ul>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
71 <li>Ongkir, cukai, dll tidak termasuk.</li>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
72 <li>Berhubung sudah punya timbangan, ongkir (estimasi) bisa dihitung sebelum dikirim.</li>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
73 <li><a href="http://www.post.japanpost.jp/int/charge/list/ems1_en.html">Tabel ongkir EMS</a>.</li>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
74 <li>Perhitungan:
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
75 <ul>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
76 <li>Bank: <code>jumlah &times; 1.07 &times; nilai_tukar</code>, dibulatkan ke seribuan terdekat.</li>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
77 <li>PayPal: <code>jumlah &times; 1.05</code>, dibulatkan ke satuan terdekat.</li>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
78 </ul>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
79 </li>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
80 <li>Jangan lupa memastikan jumlah setelah pajak dan ongkir (lokal).</li>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
81 <li>Data nilai tukar didapat dari layanan <a href="http://fixer.io/">Fixer.io</a>.</li>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
82 </ul>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
83
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
84 <pre id="n"><code>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
85 location = /calc {
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
86 root /home/edho/public_html;
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
87 try_files /calc.html =404;
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
88 }
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
89 location = /calc/get {
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
90 return 302 http://www.wolframalpha.com/input/?i=ceil%28%28$arg_x+*+1.07+jpy+in+idr%29%2F1000%29*1000;
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
91 }
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
92 </code></pre>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
93 </div>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
94
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
95 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
96 <script>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
97 // best javascript ahead. Proceed with care.
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
98 var
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
99 displayResult = function(x, rate) {
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
100 $("#rate-text").text(rate.toLocaleString())
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
101 $("#result-bank").text((Math.round(x * 1.07 * rate / 1000) * 1000).toLocaleString())
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
102 $("#result-paypal").text((Math.round(x * 1.05)).toLocaleString())
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
103 $("#ok").show()
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
104 },
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
105 loading = $("#loading"),
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
106 doButton = $("button[type=submit]"),
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
107 clearButton = $("button[type=reset]"),
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
108 unlock = function() {
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
109 loading.hide()
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
110 doButton.attr("disabled", false)
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
111 },
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
112 lock = function() {
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
113 loading.show()
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
114 doButton.attr("disabled", true)
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
115 },
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
116 xForm = $("#x"),
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
117 action = function(e) {
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
118 e.preventDefault()
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
119 $(".js").hide()
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
120 var x = parseFloat(xForm.val())
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
121 if (x === NaN || x === undefined) { return false; }
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
122
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
123 if (window.rate === undefined) {
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
124 lock()
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
125 $.getJSON("https://api.fixer.io/latest", { base: "JPY", symbols: "IDR" })
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
126 .done(function(data) {
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
127 window.rate = data.rates["IDR"]
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
128 displayResult(x, window.rate)
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
129 })
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
130 .fail(function() {
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
131 $("#error").show()
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
132 })
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
133 .always(function() {
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
134 unlock()
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
135 })
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
136 } else {
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
137 displayResult(x, window.rate)
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
138 }
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
139 }
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
140 clearButton.click(function(e) { xForm.focus() })
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
141 doButton.click(action)
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
142 $("form").submit(action)
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
143 </script>
3c9ac4a429a5 Initial import.
nanaya <me@myconan.net>
parents:
diff changeset
144 </body>