Browse Source

Fix #694

pull/697/head
Timothée Jaussoin 7 years ago
parent
commit
1b06ed61b5
  1. 11
      app/widgets/AdminMain/AdminMain.php
  2. 43
      app/widgets/AdminMain/admin.js
  3. 5
      app/widgets/AdminTest/admintest.css

11
app/widgets/AdminMain/AdminMain.php

@ -6,8 +6,6 @@ class AdminMain extends \Movim\Widget\Base
{
function load()
{
$this->addjs('admin.js');
$form = $_POST;
$configuration = Configuration::get();
@ -39,14 +37,6 @@ class AdminMain extends \Movim\Widget\Base
return requestURL($url, 1);
}
public function date($timezone)
{
$t = new DateTimeZone($timezone);
$c = new DateTime(null, $t);
$current_time = $c->format('D M j Y G:i:s');
return $current_time;
}
function display()
{
$l = Movim\i18n\Locale::start();
@ -58,7 +48,6 @@ class AdminMain extends \Movim\Widget\Base
2 => $this->__('log.syslog_files')
]);
$this->view->assign('timezones', generateTimezoneList());
$this->view->assign('langs', $l->getList());
$this->view->assign('countries', getCountries());
}

43
app/widgets/AdminMain/admin.js

@ -1,43 +0,0 @@
var tz_list;
var original = true;
var operators = {
'+': function(a, b) { return a + b },
'-': function(a, b) { return a - b },
};
function update(elt){
if (elt.selectedIndex == -1)
return null;
//Get the offset from the selected option
text = elt.options[elt.selectedIndex].text;
//Determine if it is a positive or negative offset
sign = text.indexOf("+") > -1 ? "+" : "-";
//Seperate hours and minutes and get the offset in ms
h_m = text.split(sign)[1].split(")")[0].split(":");
tzOffset = parseInt(h_m[0]) * 3600000 + parseInt(h_m[1]) * 60000;
//Get the offset between your computer and UTC
pcOffset = new Date().getTimezoneOffset() * 60000;
return new Date(operators[sign]((new Date().getTime() + pcOffset), tzOffset));
}
movim_add_onload(function()
{
tz_list = document.querySelector("#timezone");
tz_list.onchange = function(e){
newTime = update(tz_list);
formatDate(newTime);
}
setInterval(
function(){ //increment time each second
date = new Date(document.querySelector(".dTimezone").innerHTML).getTime() + 1000;
date = formatDate(new Date(date));
}
,1000);
formatDate = function (newTime){
h = newTime.getHours()<10 ? "0" + newTime.getHours() : newTime.getHours();
m = newTime.getMinutes()<10 ? "0" + newTime.getMinutes() : newTime.getMinutes();
s = newTime.getSeconds()<10 ? "0" + newTime.getSeconds() : newTime.getSeconds();
document.querySelector(".dTimezone").innerHTML = newTime.toDateString() + " " + h+ ":" + m + ":" + s;
}
});

5
app/widgets/AdminTest/admintest.css

@ -44,15 +44,14 @@ figure div#api_block { left: 85%; top: 50%; }
figure div.link {
width: 0;
height: 0;
border-radius: 1em;
padding: 0.25em;
line-height: 0em;
line-height: 1rem;
overflow: initial;
}
figure div.link i {
background-color: #FFF;
margin-top: -3rem;
margin-top: -2rem;
padding: 1.5rem 1rem;
border-radius: 6rem;
font-size: 3rem;

Loading…
Cancel
Save