Changeset 2132242
- Timestamp:
- 08/01/2019 04:35:43 PM (7 years ago)
- Location:
- new-nepali-calendar/trunk
- Files:
-
- 2 edited
-
NewNepaliCalendar.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
new-nepali-calendar/trunk/NewNepaliCalendar.php
r2094192 r2132242 4 4 Plugin URI: 5 5 Description: Add Nepali Calendar to your blog. 6 Version: 1. 0.06 Version: 1.1.0 7 7 Author: Blogger Nepal 8 8 Author URI: https://www.bloggernepal.com/ … … 131 131 } 132 132 } 133 134 function HTMLJS(){ 135 $html = <<<EOT 136 <div class="widget-content"> 137 <div> 138 <style> 139 .npCalendarTable { 140 width: 100%; 141 text-align: center; 142 } 143 144 .npCalendarTable td { 145 font-size: 1.5em; 146 text-align: center; 147 padding: 0 !important; 148 } 149 150 .npCalendarTable tr { 151 text-align: center; 152 padding: 0 !important; 153 } 154 155 .npCalendarPreNext { 156 color: #9e9e9e; 157 } 158 159 .npCalendarToday { 160 background: #428bca; 161 } 162 </style> 163 <table class="npCalendarTable"> 164 <thead> 165 <tr> 166 <th colspan="7" id="npMonthsYear">Nepali Calendar</th> 167 168 </tr> 169 <tr> 170 <th title="आइतवार">आइत</th> 171 <th title="सोमवार">सोम</th> 172 <th title="मगलवार">मगल</th> 173 <th title="बुधवार">बुध</th> 174 <th title="बिहिवार">बिहि</th> 175 <th title="शुक्रवार">शुक्र</th> 176 <th title="शनिवार">शनि</th> 177 </tr> 178 </thead> 179 <tbody id="npCalendarTBody"> 180 181 </tbody> 182 </table> 183 </div> 184 <script> 185 let getJSON = function(url, callback) { 186 let xmlhttp = new XMLHttpRequest(); 187 xmlhttp.open('GET', url, true); 188 xmlhttp.responseType = 'json'; 189 xmlhttp.onload = function() { 190 let status = xmlhttp.status; 191 if (status === 200) { 192 callback(null, xmlhttp.response); 193 } else { 194 callback(status, xmlhttp.response); 195 } 196 }; 197 xmlhttp.send(); 198 }; 199 200 let fetchJsonData = (err, jsonData) => { 201 const res = jsonData.res; 202 const year = res.year; 203 const month = res.name; 204 const days = res.days; 205 document.getElementById("npMonthsYear").innerText = month + " " + year; 206 var html = ''; 207 for (var i = 0; i < 42; i++) { 208 if (i == 0 || i == 7 || i == 14 || i == 21 || i == 28 || i == 35) { 209 html = html + "<tr>" 210 } 211 var thisday = days[i]; 212 var thisbs = thisday.bs; 213 var thistag = thisday.tag; 214 if (thistag == "pre" || thistag == "next") { 215 html = html + '<td class="npCalendarPreNext">'; 216 } else if (thistag == "today") { 217 html = html + '<td class="npCalendarToday">'; 218 } else { 219 html = html + '<td>'; 220 } 221 html = html + thisbs; 222 html = html + '</td>' 223 224 if (i == 6 || i == 13 || i == 20 || i == 27 || i == 34 || i == 41) { 225 html = html + "</tr>" 226 } 227 } 228 document.getElementById('npCalendarTBody').innerHTML = html; 229 } 230 //getJSON('http://localhost:4040/api/today',fetchJsonData); 231 getJSON('https://calendar.bloggernepal.com/api/today/', fetchJsonData); 232 </script> 233 </div> 234 EOT; 235 return $html; 236 } 237 133 238 function register_NewNepaliCalendar() { 134 239 register_widget( 'NewNepaliCalendar' ); 135 240 } 136 241 add_action( 'widgets_init', 'register_NewNepaliCalendar' ); 242 add_shortcode('NepaliCalendar', 'HTMLJS'); 243 add_shortcode('NewNepaliCalendar', 'HTMLJS'); 137 244 ?> -
new-nepali-calendar/trunk/readme.txt
r2094192 r2132242 2 2 Contributors: infodevkota 3 3 Requires at least: 3.0.1 4 Tested up to: 5.2. 14 Tested up to: 5.2.2 5 5 Requires PHP: 5.2.4 6 6 License: TCIY License … … 8 8 9 9 Add Nepali Calendar to your blog. 10 11 Use Shortcode NepaliCalendar to add Nepali Calendar in the body of a post or page. 12 [NepaliCalendar]
Note: See TracChangeset
for help on using the changeset viewer.