Calendar Sync V2
This commit is contained in:
@@ -300,6 +300,37 @@ class admin_plugin_luxtools_main extends DokuWiki_Admin_Plugin
|
||||
echo '</label><br />';
|
||||
}
|
||||
|
||||
// CalDAV Sync button (outside the save form, separate action)
|
||||
$ajaxUrl = DOKU_BASE . 'lib/exe/ajax.php';
|
||||
$sectok = getSecurityToken();
|
||||
echo '<div class="luxtools-admin-sync" style="margin: 1em 0;">';
|
||||
echo '<button type="button" class="button" id="luxtools-sync-btn">'
|
||||
. hsc($this->getLang('calendar_sync_button'))
|
||||
. '</button>';
|
||||
echo '<span id="luxtools-sync-status" style="margin-left: 1em;"></span>';
|
||||
echo '</div>';
|
||||
echo '<script>';
|
||||
echo 'document.getElementById("luxtools-sync-btn").addEventListener("click", function() {';
|
||||
echo ' var btn = this;';
|
||||
echo ' var status = document.getElementById("luxtools-sync-status");';
|
||||
echo ' btn.disabled = true;';
|
||||
echo ' status.textContent = "Syncing...";';
|
||||
echo ' var xhr = new XMLHttpRequest();';
|
||||
echo ' xhr.open("POST", ' . json_encode($ajaxUrl) . ', true);';
|
||||
echo ' xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");';
|
||||
echo ' xhr.onload = function() {';
|
||||
echo ' btn.disabled = false;';
|
||||
echo ' try {';
|
||||
echo ' var r = JSON.parse(xhr.responseText);';
|
||||
echo ' status.textContent = r.message || (r.ok ? "Done" : "Failed");';
|
||||
echo ' status.style.color = r.ok ? "green" : "red";';
|
||||
echo ' } catch(e) { status.textContent = "Error"; status.style.color = "red"; }';
|
||||
echo ' };';
|
||||
echo ' xhr.onerror = function() { btn.disabled = false; status.textContent = "Network error"; status.style.color = "red"; };';
|
||||
echo ' xhr.send("call=luxtools_calendar_sync§ok=" + encodeURIComponent(' . json_encode($sectok) . '));';
|
||||
echo '});';
|
||||
echo '</script>';
|
||||
|
||||
// pagelink_search_depth
|
||||
echo '<label class="block"><span>' . hsc($this->getLang('pagelink_search_depth')) . '</span> ';
|
||||
echo '<input type="number" class="edit" min="0" name="pagelink_search_depth" value="' . hsc((string)$this->getConf('pagelink_search_depth')) . '" />';
|
||||
|
||||
Reference in New Issue
Block a user