Fix a issue where when on SSI, this would become undefined.
jdarwood007

jdarwood007 commited on 2023-03-15 17:55:01
Showing 2 changed files, with 11 additions and 20 deletions.

... ...
@@ -30,28 +30,15 @@ class ErrorPopup
30 30
 		if (empty($context['user']['is_admin']))
31 31
 			return;
32 32
 
33
-		/* SMF calls this is in setupMenuContext
34
-			var user_menus = new smc_PopupMenu();
35
-
36
-			This is the pure Javasript logic.
33
+		// We are loaded via SSI, we can fake it.
34
+		if (SMF == 'SSI')
37 35
 			addInlineJavaScript('
38
-		orgErrorLog = document.querySelector(\'li.button_admin ul a[href*="errorlog"]\');
39
-		if (typeof orgErrorLog !== "undefined" && orgErrorLog !== null)
40
-		{
41
-			errorLI = orgErrorLog.parentElement.outerHTML;
42
-			errorLI += \'<div id="error_menu" class="top_menu scrollable" style="width: 90vw; max-width: 1200px;"></div>\';
43
-
44
-			topInfo = document.querySelector(\'ul#top_info\');
45
-			topInfo.innerHTML += errorLI;
46
-
47
-			document.querySelector(\'ul#top_info a[href*="errorlog"]\').setAttribute("id", "error_menu_top");
48
-
49
-			user_menus.add("error", "' . $scripturl . '?action=admin;area=logs;sa=errorlog");
50
-		}', true);
51
-		*/
36
+			var errorLI = \'<li class=""><a href="' . $scripturl . '?action=admin;area=logs;sa=errorlog;desc">' . $txt['errorlog'] . ' <span class="amt">' . ($context['num_errors'] ?? 0) . '</span></a></li>\';');
37
+		else
52 38
 			addInlineJavaScript('
39
+			var errorLI = $("li.button_admin ul").find(\'a[href*="errorlog"]\').parent().prop("outerHTML");', true);
53 40
 
54
-			var errorLI = $("li.button_admin ul").find(\'a[href*="errorlog"]\').parent().prop("outerHTML");
41
+			addInlineJavaScript('
55 42
 			errorLI += \'<div id="error_menu" class="top_menu scrollable" style="width: 90vw; max-width: 1200px;"></div>\';
56 43
 			$("ul#top_info").append(errorLI);
57 44
 			$("ul#top_info").find(\'a[href*="errorlog"]\').attr("id", "error_menu_top");
... ...
@@ -2,7 +2,7 @@
2 2
 <package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
3 3
 	<id>sleepy:errorpup</id>
4 4
 	<name>Error Log Popup</name>
5
-	<version>1.0</version>
5
+	<version>1.1</version>
6 6
 	<type>modification</type>
7 7
 
8 8
 	<install for="SMF 2.1.*">
... ...
@@ -22,4 +22,8 @@
22 22
 		<remove-file name="$sourcedir/ErrorPopup.php" />
23 23
 	</uninstall>
24 24
 
25
+	<upgrade from="1.0" for="2.1.*">
26
+		<require-file name="ErrorPopup.php" destination="$sourcedir" />
27
+	</upgrade>
28
+
25 29
 </package-info>
26 30
\ No newline at end of file
27 31