@@ -118,8 +118,8 @@ function createCustomApp() {
118118 saveCustomApp ( customApp ) ;
119119
120120 const card = renderAppCard ( customApp , 0 , true ) ;
121- const nonPinnedContainer = document . querySelector ( ".apps " ) ;
122- nonPinnedContainer . insertBefore ( card , nonPinnedContainer . firstChild ) ;
121+ const pinnedContainer = document . querySelector ( ".pinned " ) ;
122+ pinnedContainer . appendChild ( card ) ;
123123 }
124124}
125125
@@ -214,27 +214,13 @@ function renderAppCard(app, appIndex, isCustom = false) {
214214 link . appendChild ( paragraph ) ;
215215 columnDiv . appendChild ( link ) ;
216216
217- if ( appIndex !== 0 ) {
217+ if ( appIndex !== 0 && appIndex !== 1 ) {
218218 columnDiv . appendChild ( createPinButton ( appIndex ) ) ;
219219 }
220220
221221 return columnDiv ;
222222}
223223
224- function loadCustomApps ( ) {
225- const storedApps = getFromStorage ( "custom" ) ;
226-
227- if ( storedApps ) {
228- const apps = JSON . parse ( storedApps ) ;
229- const nonPinnedContainer = document . querySelector ( ".apps" ) ;
230-
231- Object . values ( apps ) . forEach ( app => {
232- const card = renderAppCard ( app , 0 , true ) ;
233- nonPinnedContainer . insertBefore ( card , nonPinnedContainer . firstChild ) ;
234- } ) ;
235- }
236- }
237-
238224function getJsonPath ( ) {
239225 if ( isGamesPage ) return "/assets/json/games.min.json" ;
240226 if ( isToolsPage ) return "/assets/json/t.min.json" ;
@@ -268,15 +254,25 @@ function loadAppsFromJson() {
268254 fetch ( jsonPath )
269255 . then ( response => response . json ( ) )
270256 . then ( appsList => {
257+ const nonPinnedContainer = document . querySelector ( ".apps" ) ;
258+ const pinnedContainer = document . querySelector ( ".pinned" ) ;
259+ const pinnedList = getPinnedApps ( ) ;
260+
261+ const appsContainer = document . getElementById ( "apps-container" ) ;
262+ if ( appsContainer ) {
263+ appsContainer . appendChild ( pinnedContainer ) ;
264+ appsContainer . appendChild ( nonPinnedContainer ) ;
265+ }
266+
267+ const specialCards = appsList . splice ( 0 , 2 ) ;
268+
271269 appsList . sort ( ( a , b ) => {
272270 if ( a . name . startsWith ( "[Custom]" ) ) return - 1 ;
273271 if ( b . name . startsWith ( "[Custom]" ) ) return 1 ;
274272 return a . name . localeCompare ( b . name ) ;
275273 } ) ;
276274
277- const nonPinnedContainer = document . querySelector ( ".apps" ) ;
278- const pinnedContainer = document . querySelector ( ".pinned" ) ;
279- const pinnedList = getPinnedApps ( ) ;
275+ appsList . unshift ( ...specialCards ) ;
280276
281277 let appIndex = 0 ;
282278
@@ -285,7 +281,9 @@ function loadAppsFromJson() {
285281
286282 const card = renderAppCard ( app , appIndex ) ;
287283
288- if ( appIndex !== 0 && isAppPinned ( appIndex , pinnedList ) ) {
284+ if ( appIndex === 0 || appIndex === 1 ) {
285+ pinnedContainer . appendChild ( card ) ;
286+ } else if ( pinnedList != null && isAppPinned ( appIndex , pinnedList ) ) {
289287 pinnedContainer . appendChild ( card ) ;
290288 } else {
291289 nonPinnedContainer . appendChild ( card ) ;
@@ -294,15 +292,27 @@ function loadAppsFromJson() {
294292 appIndex ++ ;
295293 } ) ;
296294
297- const appsContainer = document . getElementById ( "apps-container" ) ;
298- appsContainer . appendChild ( pinnedContainer ) ;
299- appsContainer . appendChild ( nonPinnedContainer ) ;
295+ loadCustomAppsInline ( ) ;
300296 } )
301297 . catch ( error => {
302298 console . error ( "Error fetching app data:" , error ) ;
303299 } ) ;
304300}
305301
302+ function loadCustomAppsInline ( ) {
303+ const storedApps = getFromStorage ( "custom" ) ;
304+
305+ if ( storedApps ) {
306+ const apps = JSON . parse ( storedApps ) ;
307+
308+ const pinnedContainer = document . querySelector ( ".pinned" ) ;
309+ Object . values ( apps ) . forEach ( app => {
310+ const card = renderAppCard ( app , 0 , true ) ;
311+ pinnedContainer . appendChild ( card ) ;
312+ } ) ;
313+ }
314+ }
315+
306316function filterByCategory ( ) {
307317 const selectedCategories = Array . from ( document . querySelectorAll ( "#category option:checked" ) ) . map ( option => option . value ) ;
308318
@@ -331,6 +341,5 @@ window.category = filterByCategory;
331341window . bar = filterBySearchTerm ;
332342
333343document . addEventListener ( "DOMContentLoaded" , ( ) => {
334- loadCustomApps ( ) ;
335344 loadAppsFromJson ( ) ;
336345} ) ;
0 commit comments