customisable seconds in the widget
This commit is contained in:
parent
ea64a55218
commit
235b11259a
|
@ -3,7 +3,7 @@
|
||||||
Plugin Name: Discordian Date Function
|
Plugin Name: Discordian Date Function
|
||||||
Plugin URI: https://is3.soundragon.su/discordian-date-function
|
Plugin URI: https://is3.soundragon.su/discordian-date-function
|
||||||
Description: Convert dates in Wordpress to customizable Discordian dates and time (decimal). Also, this plugin provides shortcode and widget used to display the current erisian date with notification of 70 holidays. Based on the Discordian Date plugin by Dan Johnson.
|
Description: Convert dates in Wordpress to customizable Discordian dates and time (decimal). Also, this plugin provides shortcode and widget used to display the current erisian date with notification of 70 holidays. Based on the Discordian Date plugin by Dan Johnson.
|
||||||
Version: 2.555
|
Version: 2.5555
|
||||||
Author: ivan zlax
|
Author: ivan zlax
|
||||||
Author URI: https://is3.soundragon.su/about
|
Author URI: https://is3.soundragon.su/about
|
||||||
*/
|
*/
|
||||||
|
@ -284,7 +284,13 @@ class Discordian_Date_Widget extends WP_Widget {
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
echo "<div class=\"discordian_date_func\" style=\"width:100%;text-align:center;font-size:18px;line-height:36px;padding-top:40px;padding-bottom:40px;\">";
|
echo "<div class=\"discordian_date_func\" style=\"width:100%;text-align:center;font-size:18px;line-height:36px;padding-top:40px;padding-bottom:40px;\">";
|
||||||
if (get_option('dtime_widget')) echo "<h1 style=\"font-size: 255%\" id=\"dtime\"></h1>";
|
if (get_option('dtime_widget')) {
|
||||||
|
if (get_option('dtime_convert'))
|
||||||
|
echo "<script type=\"text/javascript\">var eastertime = true;</script>";
|
||||||
|
if (get_option('dtime_widgetsec'))
|
||||||
|
echo "<script type=\"text/javascript\">var widgetsec = true;</script>";
|
||||||
|
echo "<h1 style=\"font-size: 255%\" id=\"dtime\"></h1>";
|
||||||
|
}
|
||||||
echo "Today is ";
|
echo "Today is ";
|
||||||
echo get_ddate($content, $format, "now").".";
|
echo get_ddate($content, $format, "now").".";
|
||||||
if ($holiday) echo "<br><b>".$holiday."</b>";
|
if ($holiday) echo "<br><b>".$holiday."</b>";
|
||||||
|
@ -372,6 +378,10 @@ function ddatefunc_admin() {
|
||||||
update_option('dtime_widget', "1");
|
update_option('dtime_widget', "1");
|
||||||
else
|
else
|
||||||
update_option('dtime_widget', "0");
|
update_option('dtime_widget', "0");
|
||||||
|
if (isset($_POST['dtime_widgetsec_checkbox']))
|
||||||
|
update_option('dtime_widgetsec', "1");
|
||||||
|
else
|
||||||
|
update_option('dtime_widgetsec', "0");
|
||||||
echo '<div id="setting-error-settings_updated" class="updated settings-error"><p><b>'.__('Settings saved.').'</b></p></div>';
|
echo '<div id="setting-error-settings_updated" class="updated settings-error"><p><b>'.__('Settings saved.').'</b></p></div>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -459,6 +469,19 @@ Examples<br>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<th scope="row">Display seconds in erisian time clock in the widget:</th>
|
||||||
|
<td>
|
||||||
|
<fieldset>
|
||||||
|
<legend class="screen-reader-text">
|
||||||
|
<span>Seconds in the widget</span>
|
||||||
|
</legend>
|
||||||
|
<label for="users_can_register">
|
||||||
|
<input name="dtime_widgetsec_checkbox" id="users_can_register" type="checkbox" value="1" <?php if(get_option('dtime_widgetsec')==1) { echo 'checked="checked"'; } ?>>
|
||||||
|
</label>
|
||||||
|
</fieldset>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<div class="submit">
|
<div class="submit">
|
||||||
<input name="save" type="submit" class="button-primary" value="<?php echo __('Save Cganges'); ?>" />
|
<input name="save" type="submit" class="button-primary" value="<?php echo __('Save Cganges'); ?>" />
|
||||||
|
@ -483,6 +506,7 @@ function ddatefunc_deinstall() {
|
||||||
delete_option('dtimefunc_change');
|
delete_option('dtimefunc_change');
|
||||||
delete_option('dtime_convert');
|
delete_option('dtime_convert');
|
||||||
delete_option('dtime_widget');
|
delete_option('dtime_widget');
|
||||||
|
delete_option('dtime_widgetsec');
|
||||||
}
|
}
|
||||||
|
|
||||||
function ddatefunc_init() {
|
function ddatefunc_init() {
|
||||||
|
@ -496,6 +520,7 @@ add_option('ddatefunc_change', '1');
|
||||||
add_option('dtimefunc_change', '1');
|
add_option('dtimefunc_change', '1');
|
||||||
add_option('dtime_convert', '1');
|
add_option('dtime_convert', '1');
|
||||||
add_option('dtime_widget', '1');
|
add_option('dtime_widget', '1');
|
||||||
|
add_option('dtime_widgetsec', '1');
|
||||||
|
|
||||||
add_filter('plugin_action_links', 'ddatefunc_settings', 10, 2);
|
add_filter('plugin_action_links', 'ddatefunc_settings', 10, 2);
|
||||||
add_action('admin_menu', 'ddatefunc_add_admin');
|
add_action('admin_menu', 'ddatefunc_add_admin');
|
||||||
|
|
45
dtime.js
45
dtime.js
|
@ -3,35 +3,48 @@
|
||||||
* https://gitlab.com/zlax/dtime-js
|
* https://gitlab.com/zlax/dtime-js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function az(x) {
|
function addZero(numeral) {
|
||||||
if (x < 10)
|
if (numeral < 10)
|
||||||
return "0"+x;
|
return "0"+numeral;
|
||||||
return x;
|
return numeral;
|
||||||
}
|
}
|
||||||
|
|
||||||
function dtime(gregorianDate,resultar="default") {
|
function dtime(gregorianDate,resultar="default") {
|
||||||
// Easter Island Winter Time Zone offset (-5*60*60*1000)
|
if (typeof eastertime != "undefined") {
|
||||||
var date = new Date(gregorianDate.getTime()-18000000);
|
// Easter Island Winter Time Zone offset (-5*60*60*1000)
|
||||||
var christianMSDay = date.valueOf() % 86400000;
|
var date = new Date(gregorianDate.getTime()-18000000);
|
||||||
var ds = (1 / (864 / christianMSDay));
|
var christianMSDay = date.valueOf() % 86400000;
|
||||||
var h = Math.floor(ds/10000);
|
} else {
|
||||||
ds%= 10000;
|
// Christian Time Zone calculation
|
||||||
var m = Math.floor(ds/100);
|
var date = new Date(gregorianDate.getTime());
|
||||||
ds%= 100;
|
var h = date.getHours();
|
||||||
var s = Math.floor(ds);
|
var m = date.getMinutes();
|
||||||
|
var s = date.getSeconds();
|
||||||
|
var ms = date.getMilliseconds();
|
||||||
|
var christianMSDay = h*3600000+m*60000+s*1000+ms;
|
||||||
|
}
|
||||||
|
var erisianSecondsDay = (christianMSDay/864);
|
||||||
|
var hour = Math.floor(erisianSecondsDay/10000);
|
||||||
|
erisianSecondsDay %= 10000;
|
||||||
|
var minute = Math.floor(erisianSecondsDay/100);
|
||||||
|
erisianSecondsDay %= 100;
|
||||||
|
var second = Math.floor(erisianSecondsDay);
|
||||||
|
|
||||||
switch (resultar) {
|
switch (resultar) {
|
||||||
case "seconds":
|
case "seconds":
|
||||||
return h+":"+az(m)+":"+az(s);
|
return hour+":"+addZero(minute)+":"+addZero(second);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return h+":"+az(m);
|
return hour+":"+addZero(minute);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function go() {
|
function go() {
|
||||||
document.getElementById("dtime").innerHTML = dtime(new Date(), "seconds");
|
if (typeof widgetsec != "undefined")
|
||||||
|
document.getElementById("dtime").innerHTML = dtime(new Date(), "seconds");
|
||||||
|
else
|
||||||
|
document.getElementById("dtime").innerHTML = dtime(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
|
|
Loading…
Reference in New Issue