Rewrite Bookmark javascript

This commit is contained in:
sparkyx 2025-01-15 16:43:01 +01:00
parent bb0a779e1f
commit 24151ef568
4 changed files with 44 additions and 16 deletions

1
.gitignore vendored
View file

@ -47,3 +47,4 @@ local/*
.idea/*
include/tfpdf/font/unifont/*
html/ads.html
doc/code/*

View file

@ -2423,12 +2423,20 @@ function set_preference(p_dossier) {
}
}
////////////////////////////////////////////////////////
/**
*@class Bookmark
*/
////////////////////////////////////////////////////////
var Bookmark = function() {
}
/**
* Display user's bookmark
*
* @param p_dossier {int} Dossier id
*/
function show_bookmark(p_dossier) {
Bookmark.prototype.show = function (p_dossier) {
try {
waiting_box();
removeDiv('bookmark_div');
@ -2449,6 +2457,7 @@ function show_bookmark(p_dossier) {
} catch (e) {
alert_box(content[53] + "\n" + e.message);
}
id$('lk_bookmark_tb').focus();
}
}
@ -2458,11 +2467,10 @@ function show_bookmark(p_dossier) {
}
}
/**
* save the bookmark
*/
function save_bookmark() {
Bookmark.prototype.save = function () {
try {
waiting_box();
var queryString = "op=bookmark&" + id$("bookmark_frm").serialize();
@ -2494,7 +2502,7 @@ function save_bookmark() {
/**
* remove selected bookmark
*/
function remove_bookmark() {
Bookmark.prototype.remove= function () {
try {
waiting_box();
var queryString = "op=bookmark&" + id$("bookmark_del_frm").serialize();
@ -3302,9 +3310,9 @@ function show_all_row(p_table_id) {
* @class
* Periode handling
* Variables :
* - id of the row of the periode row_per_(p_periode_id) , attribute exercice =per_exercice,periode_id=p_id
* - (this.dialog)
* - id of the table with the rows : periode_tbl
* id of the row of the periode row_per_(p_periode_id) , attribute exercice =per_exercice,periode_id=p_id
* # (this.dialog)
* # id of the table with the rows : periode_tbl
*
* Members :
* - periode_id the concerned Periode , 0 none
@ -4377,11 +4385,11 @@ function activate_plugin(elt)
alert_box(e.message);
}
}
/**********************************************************************************************************************/
/**********************************************************************************************/
/**
* @class Widget
*/
/**********************************************************************************************************************/
*
*************************************************************************************************************/
Widget = function(dossier_id) {
this.dossier_id=dossier_id;
@ -4698,4 +4706,6 @@ Widget.prototype.toggle_full_size=function (widget_domid) {
(function(){window.addEventListener("beforeunload", (event) => {waiting_box()});})();
(function(){window.addEventListener("onload", (event) => {remove_waiting_box()});})();
*/
*/
var bookmark=new Bookmark();

View file

@ -24,6 +24,10 @@
* @file
* @brief user's bookmark
*/
/**
* @var $cn Database inherited
* @var $g_user User_Noalyss inherited
*/
if ( ! defined ('ALLOWED')) die('Appel direct ne sont pas permis');
echo HtmlInput::title_box(_("Favoris"), "bookmark_div");
if (! isset($_GET['ac'])) {
@ -32,7 +36,10 @@ if (! isset($_GET['ac'])) {
*/
$_GET['ac']= find_default_module();
}
//-------------------------------------------------------------------------------------------
//
// Add bookmark
//-------------------------------------------------------------------------------------------
if (isset($_GET['bookmark_add'])){
$count=$cn->get_value("select count(*) from bookmark"
. " where b_action=$1 and login=$2",
@ -47,7 +54,10 @@ if (isset($_GET['bookmark_add'])){
echo create_script($js);
}
}
//-------------------------------------------------------------------------------------------
// remove bookmark
//
//-------------------------------------------------------------------------------------------
if (isset($_GET['bookmark_delete']) && isset ($_GET['book'])){
$a_book=$_GET['book'];
for ($e=0;$e<count($a_book);$e++)
@ -64,12 +74,16 @@ $bookmark_sql="select distinct b_id,b_action,b_order,me_code,me_description, jav
. "login=$1 order by me_code";
$a_bookmark=$cn->get_array($bookmark_sql,array($g_user->login));
$url="do.php?gDossier=".Dossier::id()."&ac=";
//-------------------------------------------------------------------------------------------
// Display content
//-------------------------------------------------------------------------------------------
?>
<div class="content">
<form id="bookmark_del_frm" method="get" onsubmit="remove_bookmark();return false">
<?=\HtmlInput::filter_table("bookmark_tb","1,2",0)?>
<form id="bookmark_del_frm" method="get" onsubmit="bookmark.remove();return false">
<?php echo HtmlInput::array_to_hidden(array("gDossier",'ac'), $_REQUEST); ?>
<table class="result">
<table id="bookmark_tb" class="result">
<?php for ($i=0;$i<count($a_bookmark);$i++): ?>
<?php
/*
@ -104,7 +118,7 @@ if ( count($a_bookmark) > 0) :
endif;
?>
</form>
<form id="bookmark_frm" method="get" onsubmit="save_bookmark();return false">
<form id="bookmark_frm" method="get" onsubmit="bookmark.save();return false">
<?php
echo _("Menu actuel")." : ".hb($_GET['ac']);
echo HtmlInput::array_to_hidden(array("gDossier","ac"), $_REQUEST);
@ -114,4 +128,4 @@ echo HtmlInput::array_to_hidden(array("gDossier","ac"), $_REQUEST);
</form>
</div>
</div>

View file

@ -5,3 +5,6 @@ update parm_appearance set a_value='#FAFAFA' where a_code='FOLDER' and lower(a_v
update parm_appearance set a_value='#506cb8 ' where a_code='MENU1-SELECTED' and lower(a_value)='#000074 ';
ALTER TABLE public.todo_list ALTER COLUMN tl_date drop NOT NULL;
update menu_ref set me_javascript='bookmark.show(<DOSSIER>)' where me_code='BOOKMARK';