forked from mdarif/JavaScript-Boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
231 lines (214 loc) · 10.1 KB
/
Copy pathindex.html
File metadata and controls
231 lines (214 loc) · 10.1 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>JavaScript Boilerplate</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<!-- build:css(.tmp) css/style.min.css -->
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/prism.css">
<!-- endbuild -->
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div id="main" class="my_element">
<section>
<article>
<h2>Public/Private Variables and Methods</h2>
<ul>
<li>
<strong>Private variables</strong>
are declared with the <code class="language-javascript">'var'</code> keyword inside the object, and can only be accessed by private functions and privileged methods.
</li>
<li>
<strong>Private functions</strong>
are declared inline inside the object's constructor (or alternatively may be defined via <code class="language-javascript"> var functionName=function(){...}) </code>and may only be called by privileged methods (including the object's constructor).
</li>
<li>
<strong>Privileged methods</strong>
are declared with <code class="language-javascript">this.methodName=function(){...}</code> and may invoked by code external to the object.
</li>
<li>
<strong>Public properties</strong>
are declared with <code class="language-javascript">this.variableName</code> and may be read/written from outside the object.
</li>
<li>
<strong>Public methods</strong>
are defined by <code class="language-javascript">Classname.prototype.methodName = function(){...}</code> and may be called from outside the object.
</li>
<li>
<strong>Prototype properties</strong>
are defined by <code class="language-javascript">Classname.prototype.propertyName = someValue</code>
</li>
<li>
<strong>Static properties</strong>
are defined by <code class="language-javascript">Classname.propertyName = someValue</code>
</li>
</ul>
</article>
</section>
<section>
<h2>Privileged methods/Helper Functions</h2>
<article>
<h3>multiReplace(str, hash)</h3>
<p>
Replace multiple value in a single string. Return the new string at the end. You can pass regExe also.
</p>
<section class="example">
<pre><code class="language-javascript">var str = "http://localhost.com/mywebsite/?name=NAME&age=AGE&company=COMPANY";
JSB.helper.multiReplace(str, {
"NAME" : "Sam",
"AGE" : "26yrs",
"COMPANY" : "Sapient"
});</code></pre>
<strong>Final Output :</strong>
<pre><code class="language-javascript">http://localhost.com/mywebsite/?name=Sam&age=26yrs&company=Sapient</code></pre>
</section>
</article>
<article>
<h3>setCSS(el, styles)</h3>
<p>
Apply css to any element. Pass the name of element and the CSS in JSON format.
</p>
<section class="example">
<pre><code class="language-javascript">JSB.helper.setCSS("main", {
"width" : "300px",
"background" : "red",
"padding" : "10px"
});</code></pre>
</section>
</article>
<article>
<h3>hasClass(el, name)</h3>
<p>
Check if the given element has given class assign or not.
</p>
<section class="example">
<pre><code class="language-javascript">JSB.helper.hasClass("main", "my_element");</code></pre>
</section>
</article>
<article>
<h3>addClass(el, name)</h3>
<p>
Add class to the given element.
</p>
<section class="example">
<pre><code class="language-javascript">JSB.helper.addClass("main", "my_element2");</code></pre>
</section>
</article>
<article>
<h3>removeClass(el, name)</h3>
<p>
Remove class from the given element.
</p>
<section class="example">
<pre><code class="language-javascript">JSB.helper.removeClass("main", "my_element2");</code></pre>
</section>
</article>
<article>
<h3>getDomain()</h3>
<p>
Return the URI of site. Return protocol, hostname and port if found.
</p>
<section class="example">
<pre><code class="language-javascript">JSB.helper.getDomain();</code></pre>
</section>
</article>
<article>
<h3>getQueryString(name, default_)</h3>
<p>
This method will return the query string from the URL of the website.
</p>
<section class="example">
<pre>Copy "?name=Arif&age=32" and paste this at the address bar of the website and press enter.</pre>
<pre><code class="language-javascript">JSB.subHelper.getQueryString("name");</code></pre>
</section>
</article>
<article>
<h3>isBlank(string)</h3>
<p>
This method will check for blank value in the provided string. This will return true if provided string contain blank value and false if not.
</p>
<section class="example">
<pre><code class="language-javascript">var test = " ";
JSB.helper.isBlank(test);</code></pre>
</section>
</article>
<article>
<h3>setInfo(name, value)</h3>
<p>
Store information to client machine using HTML5 localStorate method.
</p>
<section class="example">
<pre><code class="language-javascript">JSB.helper.setInfo("name", "RSR");</code></pre>
</section>
</article>
<article>
<h3>getInfo(name, checkCookie)</h3>
<p>
Get information from client machine. Get information for HTML5 localstorage if available else get information from cookie.
</p>
<section class="example">
<pre><code class="language-javascript">JSB.helper.getInfo("name");</code></pre>
</section>
</article>
<article>
<h3>removeInfo(name, checkCookie)</h3>
<p>
Remove information from client machine.
</p>
<section class="example">
<pre><code class="language-javascript">JSB.helper.removeInfo("name");</code></pre>
</section>
</article>
</section>
<section>
<h2>Private methods</h2>
<article>
<h3>id(el)</h3>
<p>
This method return the element using javaScript getElementById() method.
</p>
</article>
<article>
<h3>setCookie(name,value,days)</h3>
<p>
Store informaiton in a cookie on user machine.
</p>
</article>
<article>
<h3>getCookie(name)</h3>
<p>
Get value of cookie by using its name from user machine.
</p>
</article>
<article>
<h3>removeCookie(name)</h3>
<p>
Remove or delete cookie from user machine by its name.
</p>
</article>
</section>
</div>
<!-- JavaScript at the bottom for fast page loading -->
<!-- build:js js/vendor.js -->
<script src="js/libs/jquery.js"></script>
<script src="js/libs/prism.js"></script>
<!-- endbuild -->
<!-- build:js js/javascript-boilerplate.min.js -->
<!-- Project specfic config goes here - projectname.config.js -->
<script src="js/_.config.js"></script>
<!-- Main is the JS Boilerplate for the project - projectname.main.js -->
<script src="js/_.main.js"></script>
<!-- Common functions can be placed in helper file - projectname.helper.js -->
<script src="js/_.helper.js"></script>
<!-- endbuild -->
</body>
</html>