-
Notifications
You must be signed in to change notification settings - Fork 0
/
shinchoku-check.html
108 lines (82 loc) · 2.51 KB
/
shinchoku-check.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!--
Copyright (c) 2014 @G2U All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<!--
This element check your Shinchoku. It's a Japanese joke.
Example:
<shinchoku-check numerator='2' denominator='5'></shinchoku-check>
Set your original message.
Example:
<shinchoku-check denominator='5' failed='うーんこの' success='あ^~いいっすね^~'></shinchoku-check>
@group Shinchoku Elements
@element shinchoku-check
@homepage github.io
-->
<link href='../polymer/polymer.html' rel='import'>
<link rel="stylesheet" href="shinchoku-check.css">
<polymer-element name='shinchoku-check' attributes='numerator denominator failed success'>
<template>
<link rel='stylesheet' href='shinchoku-check.css'>
<div id='shinchokuContainer'>
<div id='content' class="fade"><p>{{message}}</p></div>
</div>
</template>
<script>
Polymer('shinchoku-check', {
/**
* [this number / denominator] is the probability of success.
*
* @attribute numerator
* @type number
* @default 1
*/
numerator: 1,
/**
* [numerator / this number] is the probability of success.
*
* @attribute denominator
* @type number
* @default 3
*/
denominator: 3,
/**
* This text is failed message.
*
* @attribute failed
* @type string
* @default '進捗ダメです><'
*/
failed: '進捗ダメです><',
/**
* This text is success message.
*
* @attribute success
* @type string
* @default '進捗しました'
*/
success: '進捗しました!',
message: '',
fade : '',
ready: function() {
this.updateMessage();
},
/**
* Update message.
* @method updateMessage
*/
updateMessage: function(){
if(Math.floor(Math.random() * this.denominator) < this.numerator){
this.message = this.success;
}
else{
this.message = this.failed;
}
},
});
</script>
</polymer-element>