From 4aea964e3cb8469abab863d545619f7b57e1f446 Mon Sep 17 00:00:00 2001 From: Casey Peel Date: Tue, 23 Dec 2025 22:25:26 -0800 Subject: [PATCH] Remove JS code to open in new window Having links open in a new window without some visual indication is very unexpected and pop-up blockers often block them. The default value for i_newwin was changed to 0 in 2020, time to remove this entirely. --- SETUP/db_schema.sql | 4 - SETUP/devex/dpdev-docker/dp_db.sql | 2 +- SETUP/tests/smoketests/test_tables.sql | 2 +- .../24/20251224_alter_user_profiles.php | 24 ++++++ faq/pophelp/prefs/prefs_pophelp.inc | 28 ------- pinc/UserProfile.inc | 4 - pinc/js_newwin.inc | 52 ------------- pinc/resolution.inc | 76 ------------------- pinc/showavailablebooks.inc | 12 +-- tools/proofers/my_projects.php | 8 +- tools/proofers/my_suggestions.php | 8 +- userprefs.php | 45 +---------- 12 files changed, 33 insertions(+), 232 deletions(-) create mode 100644 SETUP/upgrade/24/20251224_alter_user_profiles.php delete mode 100644 pinc/js_newwin.inc delete mode 100644 pinc/resolution.inc diff --git a/SETUP/db_schema.sql b/SETUP/db_schema.sql index 71a8a2aca1..e0dd479921 100644 --- a/SETUP/db_schema.sql +++ b/SETUP/db_schema.sql @@ -550,12 +550,8 @@ CREATE TABLE `user_profiles` ( `id` int(10) unsigned NOT NULL auto_increment, `u_ref` int(10) unsigned NOT NULL default '0', `profilename` varchar(30) NOT NULL default 'default', - `i_res` tinyint(1) default '1', `i_type` tinyint(1) default '0', `i_layout` tinyint(1) default '0', - `i_toolbar` tinyint(1) default '0', - `i_statusbar` tinyint(1) default '0', - `i_newwin` tinyint(1) default '0', `v_fnts` tinyint(2) default '0', `v_fntf` tinyint(1) default '2', `v_fntf_other` varchar(32) default '', diff --git a/SETUP/devex/dpdev-docker/dp_db.sql b/SETUP/devex/dpdev-docker/dp_db.sql index cb43166bce..f849111b3b 100644 --- a/SETUP/devex/dpdev-docker/dp_db.sql +++ b/SETUP/devex/dpdev-docker/dp_db.sql @@ -46,7 +46,7 @@ INSERT INTO `project_events` VALUES (1,1451401587,'projectID5682a1735f76a','pm', INSERT INTO `projects` VALUES ('Demonology','Doe, John','English','pm','Match the scan, man!','html','projectID5682a1735f76a','','proofer',1451401669,1458275991,1451401587,1599454842,'','P1.proj_avail',NULL,'testingonly',NULL,1,'Other','average',0,'','',33,32,NULL,'_internal','pm','pm','',0,'',''); -INSERT INTO `user_profiles` VALUES (1,1,'default',1,0,0,0,0,1,0,0,'',50,40,65,1,0,0,0,'',35,6,70,1,0),(2,2,'default',1,0,0,0,0,1,0,0,'',50,40,65,1,0,0,0,'',35,6,70,1,0),(3,3,'default',1,0,0,0,0,1,0,2,'',50,40,65,1,0,0,0,'',35,6,70,1,0); +INSERT INTO `user_profiles` VALUES (1,1,'default',0,0,0,0,'',50,40,65,1,0,0,0,'',35,6,70,1,0),(2,2,'default',0,0,0,0,'',50,40,65,1,0,0,0,'',35,6,70,1,0),(3,3,'default',0,0,0,2,'',50,40,65,1,0,0,0,'',35,6,70,1,0); INSERT INTO `user_project_info` VALUES ('proofer','projectID5682a1735f76a',1599454853,1599454842,0,0,0,0,0,0,0,0,0); diff --git a/SETUP/tests/smoketests/test_tables.sql b/SETUP/tests/smoketests/test_tables.sql index 24c50e4353..f4efc0f87f 100644 --- a/SETUP/tests/smoketests/test_tables.sql +++ b/SETUP/tests/smoketests/test_tables.sql @@ -16,7 +16,7 @@ REPLACE INTO `users` VALUES ('userID460b20a8a8a71','BKeir','teststeel','teststee /* $up = new UserProfile(); $up->foo = bar; $up->save(); does not allow new * profiles to be created with programmatic control of id. */ -REPLACE INTO `user_profiles` VALUES (110,105,'default',4,1,1,0,0,1,5,6,'',50,40,65,1,0,5,6,'',35,20,70,1,0); +REPLACE INTO `user_profiles` VALUES (110,105,'default',1,1,5,6,'',50,40,65,1,0,5,6,'',35,20,70,1,0); /* This can be done with $s = new Settings('admin'); $s->set_true('sitemanager'); * But there's not much point until we can do some of the rest with code. diff --git a/SETUP/upgrade/24/20251224_alter_user_profiles.php b/SETUP/upgrade/24/20251224_alter_user_profiles.php new file mode 100644 index 0000000000..3c859f2ad8 --- /dev/null +++ b/SETUP/upgrade/24/20251224_alter_user_profiles.php @@ -0,0 +1,24 @@ +"), 'content' => _("

Enable/Disable wrapping of lines in the proofreading area that exceed the 'Length of Text Lines' setting.

"), ], - 'set_newwindow' => - [ - 'title' => _("Launch in New Window"), - 'content' => -_("

This setting specifies if the proofreading interface will launch in a new window or not.

"), - ], - - 'set_statusbar' => - [ - 'title' => _("Show Status Bar"), - 'content' => -_("

This setting specifies if the standard browser status bar should be displayed when 'Launch in New Window' is set to Yes.

"), - ], - - 'set_toolbar' => - [ - 'title' => _("Show Toolbar"), - 'content' => -_("

This setting specifies if the standard browser toolbars should be displayed when 'Launch in New Window' is set to Yes.

"), - ], - - // FIXME This setting, and all the code that uses it and the 1000px for calculations should die. :D - 'set_screenres' => - [ - 'title' => _("Screen Resolution"), - 'content' => _("

You may select a screen resolution from the dropdown list.

"), - ], - 'set_showspecialcolors' => [ 'title' => _("Show Special Colors"), diff --git a/pinc/UserProfile.inc b/pinc/UserProfile.inc index 38bcb4779e..f557700192 100644 --- a/pinc/UserProfile.inc +++ b/pinc/UserProfile.inc @@ -8,12 +8,8 @@ class NonexistentUserProfileException extends Exception * @property int $id; * @property int $u_ref; * @property string $profilename; - * @property int $i_res; * @property int $i_type; * @property int $i_layout; - * @property bool $i_toolbar; - * @property bool $i_statusbar; - * @property bool $i_newwin; * @property int $v_fnts; * @property int $v_fntf; * @property string $v_fntf_other; diff --git a/pinc/js_newwin.inc b/pinc/js_newwin.inc deleted file mode 100644 index d1138f3abd..0000000000 --- a/pinc/js_newwin.inc +++ /dev/null @@ -1,52 +0,0 @@ -profile->i_newwin -// (leaving aside code to save/restore/display/update it). - -include_once($relPath.'resolution.inc'); - -function get_js_for_links_to_project_pages() -{ - global $i_resolutions; - - $user = User::load_current(); - - $wSize = explode("x", $i_resolutions[$user->profile->i_res * 1]); - $window_width = (int)$wSize[0] - 20; - $window_height = (int)$wSize[1] - 80; - - return " - function newProofWin(winURL) - { - newFeatures='toolbar={$user->profile->i_toolbar},status={$user->profile->i_statusbar},location=0,directories=0,menubar=0,scrollbars=1,resizable=1,width=$window_width,height=$window_height,top=0,left=5'; - nwWin=window.open(winURL,'_blank',newFeatures); - } - "; -} - -function prep_for_links_to_project_pages() -{ - // Ensure that the guts of this function are only done once, - // because don't want to define newProofWin more than once. - static $this_func_has_been_called = false; - if ($this_func_has_been_called) { - return; - } - $this_func_has_been_called = true; - - echo ""; -} - -function get_onclick_attr_for_link_to_project_page($url) -// Get the 'onclick' attribute (if any) for an element -// that links to a project page. -{ - $user = User::load_current(); - if ($user->profile->i_newwin == 1) { - $attr = "onclick=\"newProofWin('$url'); return false;\""; - } else { - $attr = ''; - } - return $attr; -} diff --git a/pinc/resolution.inc b/pinc/resolution.inc deleted file mode 100644 index 5ac22c93c2..0000000000 --- a/pinc/resolution.inc +++ /dev/null @@ -1,76 +0,0 @@ - '600x480', - 12 => '600x800', - 22 => '640x200', - 23 => '640x240', - 24 => '640x320', - 25 => '640x350', - 26 => '640x360', - 27 => '640x400', - 0 => '640x480', - 28 => '640x512', - 16 => '720x1280', - 29 => '768x480', - 13 => '768x1024', - 30 => '800x352', - 31 => '800x400', - 32 => '800x480', - 1 => '800x600', - 33 => '960x540', - 34 => '960x640', - 17 => '960x1280', - 35 => '1024x576', - 36 => '1024x600', - 37 => '1024x640', - 2 => '1024x768', - 38 => '1024x800', - 39 => '1024x1024', - 14 => '1024x1280', - 19 => '1024x1600', - 18 => '1050x1400', - 20 => '1080x1920', - 40 => '1152x720', - 41 => '1152x768', - 3 => '1152x864', - 42 => '1152x900', - 15 => '1200x1600', - 6 => '1280x720', - 43 => '1280x768', - 44 => '1280x800', - 7 => '1280x854', - 8 => '1280x960', - 4 => '1280x1024', - 45 => '1366x768', - 9 => '1400x1050', - 46 => '1440x900', - 47 => '1440x960', - 48 => '1440x1024', - 49 => '1440x1080', - 50 => '1600x768', - 51 => '1600x900', - 10 => '1600x1024', - 5 => '1600x1200', - 52 => '1680x1050', - 53 => '1792x1344', - 54 => '1800x1440', - 55 => '1856x1392', - 11 => '1920x1080', - 56 => '1920x1200', - 57 => '1920x1400', - 58 => '1920x1440', - 59 => '2048x1152', - 60 => '2048x1536', - 61 => '2304x1440', - 62 => '2560x1440', - 63 => '2560x1600', - 64 => '2560x1920', - 65 => '2560x2048', - 66 => '2800x2100', - 67 => '3200x2048', - 68 => '3200x2400', -]; diff --git a/pinc/showavailablebooks.inc b/pinc/showavailablebooks.inc index c73aea9ba2..cc162b62bd 100644 --- a/pinc/showavailablebooks.inc +++ b/pinc/showavailablebooks.inc @@ -4,7 +4,6 @@ include_once($relPath.'Settings.inc'); include_once($relPath.'special_colors.inc'); include_once($relPath.'forum_interface.inc'); // get_forum_email_address get_url_to_compose_message_to_user include_once($relPath.'user_is.inc'); // user_is_a_sitemanager -include_once($relPath.'js_newwin.inc'); // prep_for_links_to_project_pages get_onclick_attr_for_link_to_project_page include_once($relPath.'genres.inc'); include_once($relPath.'post_processing.inc'); @@ -455,10 +454,6 @@ function show_project_listing( } $result = DPDatabase::query($query); - if (is_a($stage, 'Round')) { - prep_for_links_to_project_pages(); - } - // Start the table. echo "\n"; echo ""; @@ -522,12 +517,7 @@ function show_project_listing( } } elseif ($col_id == "nameofwork") { $eURL = "$code_url/project.php?id={$book['projectid']}&expected_state={$book['state']}"; - $onclick_attr = ( - is_a($stage, 'Round') - ? get_onclick_attr_for_link_to_project_page($eURL) - : "" - ); - $cell = "" . html_safe($book['nameofwork']) . ""; + $cell = "" . html_safe($book['nameofwork']) . ""; } elseif ($col_id == "genre") { $genre = $book['trans_genre']; if ($book['difficulty'] == "beginner") { diff --git a/tools/proofers/my_projects.php b/tools/proofers/my_projects.php index 95985705f4..a1a2426060 100644 --- a/tools/proofers/my_projects.php +++ b/tools/proofers/my_projects.php @@ -4,7 +4,6 @@ include_once($relPath.'theme.inc'); include_once($relPath.'Project.inc'); include_once($relPath.'User.inc'); -include_once($relPath.'js_newwin.inc'); // get_js_for_links_to_project_pages(), get_onclick_attr_for_link_to_project_page() include_once($relPath.'Settings.inc'); include_once($relPath.'pg.inc'); // get_pg_catalog_link_for_etext() include_once($relPath.'gradual.inc'); // maybe_output_new_proofer_message() @@ -65,9 +64,7 @@ "text_other" => sprintf(_("%s's Projects"), $username), ]; -$extra_args['js_data'] = get_js_for_links_to_project_pages(); - -output_header(get_usertext($page_header), NO_STATSBAR, $extra_args); +output_header(get_usertext($page_header), NO_STATSBAR); output_link_box($username); @@ -166,8 +163,7 @@ echo html_safe($orig_nameofwork) . " " . _("merged into") . " "; } $url = "$code_url/project.php?id=$projectid"; - $onclick_attr = get_onclick_attr_for_link_to_project_page($url); - echo "" . html_safe($nameofwork) . ""; + echo "" . html_safe($nameofwork) . ""; echo "\n"; if (isset($colspecs['state'])) { diff --git a/tools/proofers/my_suggestions.php b/tools/proofers/my_suggestions.php index 1394d9677b..5591507882 100644 --- a/tools/proofers/my_suggestions.php +++ b/tools/proofers/my_suggestions.php @@ -4,7 +4,6 @@ include_once($relPath.'theme.inc'); include_once($relPath.'Project.inc'); include_once($relPath.'User.inc'); -include_once($relPath.'js_newwin.inc'); // get_js_for_links_to_project_pages(), get_onclick_attr_for_link_to_project_page() include_once($relPath.'gradual.inc'); // get_pages_proofed_maybe_simulated() include_once($relPath.'graph_data.inc'); // get_round_backlog_stats() @@ -49,9 +48,7 @@ $title = sprintf(_("%s's Suggestions"), $username); } -$extra_args['js_data'] = get_js_for_links_to_project_pages(); - -output_header($title, NO_STATSBAR, $extra_args); +output_header($title, NO_STATSBAR); output_link_box($username, $verbose); @@ -245,8 +242,7 @@ function output_suggestion_table($projects, $colspecs, $username) echo "\n"; if (isset($colspecs['round'])) { diff --git a/userprefs.php b/userprefs.php index e7923fbd4c..b467a00d61 100644 --- a/userprefs.php +++ b/userprefs.php @@ -2,7 +2,6 @@ $relPath = "./pinc/"; include_once($relPath.'base.inc'); include_once($relPath.'metarefresh.inc'); -include_once($relPath.'resolution.inc'); include_once($relPath.'prefs_options.inc'); include_once($relPath.'languages.inc'); // bilingual_name() include_once($relPath.'theme.inc'); @@ -443,8 +442,6 @@ function save_general_tab(User $user): void function echo_proofreading_tab(User $user): void { - global $i_resolutions; - // see if they already have 10 profiles, etc. $profiles = UserProfile::load_user_profiles($user->u_id); @@ -481,25 +478,6 @@ function echo_proofreading_tab(User $user): void th_label_long(6, _('Profile details')); echo "\n"; - echo "\n"; - show_preference( - _('Screen Resolution'), - 'i_res', - 'screenres', - $user->profile->i_res, - 'dropdown', - $i_resolutions - ); - show_preference( - _('Launch in New Window'), - 'i_newwin', - 'newwindow', - $user->profile->i_newwin, - 'radio_group', - [1 => _("Yes"), 0 => _("No")] - ); - echo "\n"; - echo "\n"; show_preference( _('Interface Type'), @@ -509,17 +487,6 @@ function echo_proofreading_tab(User $user): void 'radio_group', [0 => _("Standard"), 1 => _("Enhanced")] ); - show_preference( - _('Show Toolbar'), - 'i_toolbar', - 'toolbar', - $user->profile->i_toolbar, - 'radio_group', - [1 => _("Yes"), 0 => _("No")] - ); - echo "\n"; - - echo "\n"; show_preference( _('Interface Layout'), 'i_layout', @@ -531,14 +498,6 @@ function echo_proofreading_tab(User $user): void 0 => ''.attr_safe(_(', ] ); - show_preference( - _('Show Status Bar'), - 'i_statusbar', - 'statusbar', - $user->profile->i_statusbar, - 'radio_group', - [1 => _("Yes"), 0 => _("No")] - ); echo "\n"; echo "\n"; @@ -745,8 +704,8 @@ function save_proofreading_tab(User $user): void } $profile_fields = [ - "profilename", "v_fntf_other", "h_fntf_other", "i_res", "i_type", - "i_layout", "i_newwin", "i_toolbar", "i_statusbar", "v_fntf", "v_fnts", + "profilename", "v_fntf_other", "h_fntf_other", "i_type", + "i_layout", "v_fntf", "v_fnts", "v_tframe", "v_tscroll", "v_tlines", "v_tchars", "v_twrap", "h_fntf", "h_fnts", "h_tframe", "h_tscroll", "h_tlines", "h_tchars", "h_twrap",
"; $url = "$code_url/project.php?id=" . $row["projectid"]; - $onclick_attr = get_onclick_attr_for_link_to_project_page($url); - echo "" . html_safe($row["nameofwork"]) . ""; + echo "" . html_safe($row["nameofwork"]) . ""; echo "