CINXE.COM

Diktaturens fortsatta utveckling - Uppslagsverk - NE.se

<!DOCTYPE html> <html lang="sv" xml:lang="sv" tenant="ne"> <head> <title>Diktaturens fortsatta utveckling - Uppslagsverk - NE.se</title> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" type="text/css" href="//cloud.typography.com/7584252/7846992/css/fonts.css"> <link rel="stylesheet" href="https://use.typekit.net/wif7hrv.css"> <!--[if !IE]><!--> <link rel="stylesheet" type="text/css" href="//masala-ux.ne.se/masala-ux/current/dist/css/masala-ux.min.css"> <link rel="stylesheet" type="text/css" href="//masala-ux.ne.se/masala-ux/current/dist/fonts/fontawesome/css/all-prefixed.css"> <!--<![endif]--> <!--[if lte IE 9]> <link rel="stylesheet" type="text/css" href="//masala-ux.ne.se/masala-ux/current/dist/css/masala-ux.split.min.css"> <link rel="stylesheet" type="text/css" href="//masala-ux.ne.se/masala-ux/current/dist/css/ie9.min.css"> <![endif]--> <link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png"/> <link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114x114.png"/> <link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-72x72.png"/> <link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144x144.png"/> <link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png"/> <link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png"/> <link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon-76x76.png"/> <link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png"/> <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon-180x180.png"/> <link rel="icon" type="image/png" href="/favicon-192x192.png" sizes="192x192"/> <link rel="icon" type="image/png" href="/favicon-160x160.png" sizes="160x160"/> <link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96"/> <link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16"/> <link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32"/> <meta name="msapplication-TileColor" content="#2d89ef"/> <meta name="msapplication-TileImage" content="/mstile-144x144.png"/> <meta name="msapplication-TileColor" content="#2d89ef"> <meta name="msapplication-TileImage" content="/mstile-144x144.png"> <!--[if lt IE 9]> <script src="//oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="//oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> <![endif]--> <script> ; // Workaround to fix a FOUC bug in Firefox when using autofocus. See: https://bugzilla.mozilla.org/show_bug.cgi?id=712130 </script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//masala-ux.ne.se/masala-ux/current/dist/fonts/import.min.css"> <style> /* Chatbox Styles */ #chatbox { max-width: 500px; min-width: 320px; width: 100%; border: 1px solid #ccc; position: fixed; bottom: 0; right: 0; background-color: #fff; display: flex; flex-direction: column; z-index: 1000; height: 600px; /* Set a fixed height for the entire chatbox */ } #chat-header { background-color: #f5f5f5; padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; } #chat-header h3 { margin: 0; font-size: 16px; } #chat-header button, #assistant-info-popup button { background: none; border: none; font-size: 16px; cursor: pointer; } #title-section { display: flex; align-items: center; } #title-section .fa { font-size: 14px; vertical-align: text-top; } /* Adjust the chat-messages area */ #chat-messages { flex: 1; padding: 10px 16px; overflow-y: auto; background-color: #f9f9f9; display: flex; flex-direction: column; } /* Ensure messages stack from top to bottom */ #chat-messages .message { flex-shrink: 0; margin-bottom: 16px; } #chat-input { display: flex; padding: 12px; background-color: #f5f5f5; } #message-input { flex: 1; padding: 5px; border: 1px solid #ccc; border-radius: 4px; } #message-input:focus { outline: none; } #send-button { padding: 5px 10px; margin-left: 10px; background-color: #18bdd4; border: none; color: #fff; border-radius: 4px; cursor: pointer; } #send-button:hover { background-color: #1394a6; } #send-button:disabled { background-color: #167784; } .message { margin-bottom: 16px; padding: 12px; border-radius: 4px; max-width: 80%; min-width: 100px; } .message.user { background-color: #18bdd4; color: #fff; align-self: flex-end; } .message.ai { background-color: #e9ecef; color: #000; align-self: flex-start; text-align: left; } .message p { margin-bottom: 0; } .author-label { font-size: 12px; } /* Typing Indicator Styles */ #typing-indicator { display: flex; align-items: center; font-style: italic; color: #555; margin-top: auto; /* Pushes the typing indicator to the bottom */ margin-bottom: 10px; } /* Animated Dots */ @keyframes blink { 0% { opacity: 0; } 50% { opacity: 1; } 100% { opacity: 0; } } #typing-dots { display: inline-block; margin-left: 5px; } #typing-dots span { opacity: 0; animation: blink 1s infinite; } #typing-dots span:nth-child(2) { animation-delay: 0.2s; } #typing-dots span:nth-child(3) { animation-delay: 0.4s; } #disabled-chat-button { cursor: not-allowed; color: #c7c7c7; } #assistant-info-popup { position: fixed; min-width: 600px; top: 50%; left: 50%; padding: 20px; display: flex; flex-direction: column; transform: translate(-50%, -50%); background-color: #fff; border: 1px solid #ccc; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } .popup-header { display: flex; justify-content: space-between; align-items: center; } .popup-header h2 { font-size: 1.5em; margin: 0; } .close-btn { font-size: 1.2em; background: none; border: none; cursor: pointer; } .divider { margin: 15px 0; border: none; border-top: 1px solid #ddd; } .popup-content { display: flex; gap: 20px; } .section { flex: 1; } .section h3 { font-size: 1.1em; font-weight: bold; margin: 0 0 10px; display: flex; align-items: center; } .section .fa { margin-right: 8px; font-size: 24px; } .section .fa.fa-comment { color: #18bdd4; } .section .fa.fa-info-circle { color: #09550F; } .icon { font-size: 1.3em; margin-right: 8px; } .section ul { list-style-type: disc; padding-left: 24px; margin: 0; } .section ul li { margin-bottom: 8px; } .learn-more-link { display: inline-block; margin-top: 15px; font-size: 0.9em; color: #007bff; text-decoration: none; } #retry-button { margin-top: 10px; background-color: #18bdd4; color: #fff; padding: 5px 10px; border: none; cursor: pointer; border-radius: 4px; } </style> <script> // remove fromSearch getParameter if (window.location.search.indexOf("fromSearch=true") > 0) { var url = window.location.href.replace(/[?&]fromSearch=true/,""); history.replaceState(null, null, url); } </script> </head> <body class="encyklopedia scrollup" id="articleView"> <!-- Google Tag Manager --> <noscript> <iframe src="//www.googletagmanager.com/ns.html?id=GTM-KRK9SR" height="0" width="0" style="display:none;visibility:hidden"></iframe> </noscript> <script>(function (w, d, s, l, i) { w[l] = w[l] || []; w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' }); var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src = '//www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f); })(window, document, 'script', 'dataLayer', 'GTM-KRK9SR');</script> <!-- End Google Tag Manager --> <header role="banner" style="" > <nav class="navigation"> <div class="container"> <div class="row"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".js-navigation-collapsed" aria-expanded="false"> <span class="sr-only">Visa navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a href="/uppslagsverk/login" class="btn btn-primary navbar-btn-mobile">Logga in</a> <a class="navbar-logo" href="/" title="脜terg氓 till startsidan f枚r NE.se"> <h1 class="sr-only">NE.se</h1> <i class="icon-ne-logo"></i> </a> </div> <div class="collapse navbar-collapse js-navigation-collapsed"> <ul class="nav navbar-nav"> <li> <a href="/info/skolor">Skolor</a></li> <li> <a href="/info/bibliotek">Bibliotek</a> </li> <li> <a href="/info/f枚retag">F枚retag</a> </li> <li> <a href="/info/myndigheter">Myndigheter</a> </li> <li> <a href="/info/privat">Privat</a> </li> </ul> <div class="navbar-right"> <ul class="nav navbar-nav"> <li><a class="mr-sm" href="/info/kontakt/"> Kontakta oss </a></li> </ul> <a href="/uppslagsverk/login" class="btn btn-primary navbar-btn hidden-xs"> Logga in </a> </div> </div> </div> </div> </nav> </header> <nav class="navigation-slim init-navigation-slim" id="navigation-slim"> <div class="navigation-slim-inner"> <ul class="navigation-breadcrumbs has-search"> <li>Uppslagsverket</li> <li>Diktaturens fortsatta utveckling</li> </ul> </div> </nav> <main> <section class="banner light border-bottom"> <div class="container"> <div class="row"> <div class="search-container"> <div class="search-heading"> <h2><a href="/uppslagsverk/">Uppslagsverket</a></h2> </div> <div class="search-input"> <div class="searchbar searchbar-authenticated" role="search" data-component="searchbar-static" data-activesearch-url="/s枚k/aktiv/"> <form id="search" action="/s枚k/" > <div class="form-group"> <div class="input-group"> <div class="input-group-btn sources"> <label class="btn dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" aria-haspopup="true"> <span class="selected-source"> Uppslagsverk </span> <i class="fa fa-fw fa-caret-down"></i> </label> <ul class="dropdown-menu"> <li role="presentation" class="dropdown-header">S脰KK脛LLOR</li> <div class="btn-group-vertical" data-toggle="buttons"> <label class="btn btn-link text-left active"> <input type="radio" name="t" value="uppslagsverk" checked> Uppslagsverk </label> <label class="btn btn-link text-left "> <input type="radio" name="t" value="enzy" > Enzyklop盲die </label> <label class="btn btn-link text-left "> <input type="radio" name="t" value="illustrationer" > Uppslagsverk </label> <label class="btn btn-link text-left "> <input type="radio" name="t" value="kartor" > Uppslagsverk </label> </div> </ul> </div> <label for="q" class="sr-only">S枚k</label> <input type="text" name="q" id="q" class="form-control input-lg typeahead" autocomplete="off" placeholder="S枚k i uppslagsverket ..." value=""> <div class="input-group-btn"> <button class="btn btn-lg" type="submit" title="S枚k"> <i class="fa fa-search"></i><span class="sr-only">S枚k</span> </button> </div> </div> </div> </form> </div> </div> </div> </div> </div> </section> <div class="container"> <div class="row"> <article class="article"> <header class="page-header"> <h1> <span>Diktaturens fortsatta utveckling</span> </h1> <nav role="navigation"> <ol class="breadcrumb"> <li> <a href="/uppslagsverk/encyklopedi/l氓ng/diktatur">diktatur</a> </li> </ol> </nav> </header> <p>Diktaturen 盲r <a href="/uppslagsverk/encyklopedi/l氓ng/demokrati">demokratins</a>聽motsats. Det finns dock m氓nga former av icke-demokratiska politiska system med varierande inslag av auktorit盲rt styre. Bara en del av dessa kan kallas f枚r diktaturer. K盲nnetecknande f枚r diktaturen 盲r att den politiska makten koncentrerats till en person eller en grupp och att lagliga m枚jligheter till ansvarsutkr盲vande saknas.</p> <p>Det finns olika former av diktaturer. En diktatur kan utg枚ras av en monarki d盲r makten 盲r koncentrerad till kungahuset eller till den styrande fursten. Historiskt har man d氓 ofta talat</p><span class="limited-document">(80 av 741 ord)</span> <section id="promotion" class="promotion-container mt-sm mb-md"> <div class="pitch"> Vill du f氓 tillg氓ng till hela artikeln? </div> <div class="actions"> <a id="skaffane1" class="btn btn-primary" href="/info/privat">Testa NE.se gratis</a> <span class="ml-xs mr-xs">eller</span> <a href="/uppslagsverk/login">Logga in</a> </div> </section> <ul class="list-grouped list-grouped-authors hidden"> <li class="list-grouped-header">F枚rfattare:</li> <li>Nils Andr茅n</li> <li>Anders Sannerstedt</li> </ul> <hr> <div class="article-info-expand mb-sm mt-sm"> <h4 class="mr-xs"> <i class="fa fa-info-circle mr-xs"></i> Information om artikeln <a data-toggle="collapse" class="btn btn-info btn-sm article-info-toggle ml-xs collapsed" href="#collapse-article-info"> <i class="fa fa-chevron-circle-down mr-xs"></i> <span class="article-info-span show-text">Visa</span> <span class="article-info-span hide-text">St盲ng</span> </a> </h4> </div> <div id="collapse-article-info" class="collapse"> <h4 class="h4 mt-sm"> Medverkande </h4> <ul class="list-grouped list-grouped-authors"> <li>Anders Sannerstedt</li> <li>Nils Andr茅n</li> </ul> <section class="section"> <div class="source-reference-title">K盲llangivelse</div> <div class="reference" id="source-reference"> <span class="reference-source">Nationalencyklopedin,</span> <span class="reference-article">Diktaturens fortsatta utveckling.</span> <span class="reference-url">http://www.ne.se/uppslagsverk/encyklopedi/l氓ng/diktatur/diktaturens-fortsatta-utveckling</span> <time class="reference-date" datetime="2024-11-25">(h盲mtad 2024-11-25)</time> </div> </section> </div> </article> <aside class="article-toc"> <nav class="toc"> </nav> </aside> <aside class="article-aside complementary"> <div class="panel-group mb-none"> <div class="panel article-aside-tools"> <div id="tools" class="panel-collapse collapse in"> <div class="tool"> <a href="javascript:window.print()" role="button"> <i class="fa fa-print"></i>&emsp;Skriv ut artikel </a> </div> <div class="tool"> <a href="javascript:launchImmersiveReader('sv-SE')" role="button"> <svg style="fill:#737373; height:auto; width: 16px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M560.51 225.9L528.75 98.64C522.05 71.78 495.01 32 443.33 32c-15.63 0-23.03 2.94-43.02 9.6-8.39 2.79-12.92 11.86-10.12 20.24l5.06 15.18c2.24 6.7 8.48 10.94 15.18 10.94 3.54 0 4.82-.74 18.23-5.21 26.07-8.68 48.2 6.13 53.53 27.54l29.67 118.68C490.97 215.88 466.47 208 440 208c-55.09 0-102.27 32.91-123.65 80h-56.7c-21.38-47.09-68.56-80-123.65-80-26.47 0-50.97 7.88-71.86 20.96l29.67-118.68c5.32-21.41 27.46-36.22 53.53-27.54 13.42 4.47 14.7 5.21 18.23 5.21 6.7 0 12.94-4.24 15.18-10.94l5.06-15.18c2.8-8.38-1.73-17.45-10.12-20.24C155.7 34.94 148.3 32 132.67 32 81 32 53.95 71.78 47.25 98.64L15.49 225.9C2.16 279.34 0 300.12 0 344c0 75.11 60.89 136 136 136 72.37 0 130.97-56.69 135.19-128h33.61c4.22 71.31 62.82 128 135.19 128 75.11 0 136-60.89 136-136 .01-43.88-2.15-64.66-15.48-118.1zM136 416c-39.7 0-72-32.3-72-72s32.3-72 72-72 72 32.3 72 72-32.3 72-72 72zm304 0c-39.7 0-72-32.3-72-72s32.3-72 72-72 72 32.3 72 72-32.3 72-72 72z"/></svg>&emsp;L盲shj盲lp </a> </div> </div> </div> <nav class="panel article-aside-related" role="navigation"> <h3>L盲s 盲ven om</h3> <div id="related" class=""> <div class="panel-body pt-none"> <ul> <li><a href="/uppslagsverk/encyklopedi/l氓ng/josef-stalin">Josef Stalin</a></li> <li><a href="/uppslagsverk/encyklopedi/l氓ng/adolf-hitler">Adolf Hitler</a></li> <li><a href="/uppslagsverk/encyklopedi/l氓ng/pol-pot">Pol Pot</a></li> <li><a href="/uppslagsverk/encyklopedi/l氓ng/augusto-pinochet">Augusto Pinochet</a></li> <li><a href="/uppslagsverk/encyklopedi/l氓ng/r枚da-khmererna">r枚da khmererna</a></li> <li><a href="/uppslagsverk/encyklopedi/l氓ng/caesar">Caesar</a></li> <li><a href="/uppslagsverk/encyklopedi/l氓ng/mobutu-sese-seko">Mobutu Sese Seko</a></li> <li><a href="/uppslagsverk/encyklopedi/l氓ng/saddam-hussein">Saddam Hussein</a></li> <li><a href="/uppslagsverk/encyklopedi/l氓ng/tito">Tito</a></li> <li><a href="/uppslagsverk/encyklopedi/l氓ng/demokratisering">demokratisering</a></li> </ul> </div> </div> </nav> </div> </aside> </div> </div> </main> <div id="permalinkModal" class="modal fade" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4 class="modal-title">Permalink</h4> </div> <div class="modal-body"> <h3><i class="fa fa-spinner fa-spin"></i> Skapar permalink, var god v盲nta!</h3> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">St盲ng</button> </div> </div> </div> </div> <div id="citationModal" class="modal fade" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4 class="modal-title">???i18n.citation.modal.title???</h4> </div> <div class="modal-body"> <h3><i class="fa fa-spinner fa-spin"></i> Skapar permalink, var god v盲nta!</h3> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">???i18n.citation.modal.close???</button> </div> </div> </div> </div> <footer class="page-footer" role="contentinfo"> <style> .footer-container { align-items: center; display: flex; flex-direction: column; margin: 20px 0; row-gap: 20px; } @media (min-width: 660px) { .footer-container { flex-direction: row; } } </style> <div style="background: #fff; border-top: 1px solid rgba(0, 0, 0, 0.12); color: rgb(51, 51, 51);"> <div class="container"> <div class="footer-container"> <div style=" display: flex; align-items: center; column-gap: 10px; flex-grow: 1; " > <a href="/" ><h1 style=" border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; white-space: nowrap; width: 1px; " ></h1> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 456 327" style="height: 37px; width: 52px" aria-label="Home Page" > <path d="M0 0v327h456V0H0zm447 320H9V7h438v313z"></path> <path d="M436 20H20v287h416V20zm-46.746 251h-141.7l-137.52-167.601c-.642-1.929-2.568-.905-3.212-.261l-.322 142.047c.644 7.711 6.746 16.469 13.818 19.681 3.854 1.287 7.068 3.134 10.282 3.134H72.12c9.639-4 10.924-14.767 14.78-23.763l-.082-167.394C84.248 64.63 72.12 57.349 61.195 53.495L60.552 52h54.622l132.379 164.887 1.287-1.421-.16-134.615c0-12.211-12.691-22.661-22.973-27.158L227.634 52H377v43.804c-2-9.638-8.621-19.276-18.259-24.417C352.714 66.726 282 68.172 282 68.172V142h76.086c7.07-2 13.412-9.441 17.914-13.941 0 0 .079 31.154.079 46.577C371.58 168.852 364.51 160 356.16 160H282v90.274c32-.639 64.509 4.901 92.785-4.094 10.926-5.782 14.784-16.828 19.284-26.47.643 16.067-2.886 33.29-4.815 51.29z" ></path></svg ></a> <div>&copy;2023 NE Nationalencyklopedin AB</div> </div> <div style="display: flex; align-items: center; column-gap: 20px"> <a href="https://www.ne.se/info/skola/">Om tj盲nsten</a> <a href="https://faq.ne.se/">Fr氓gor och svar</a> <a href="https://www.ne.se/info/kontaktsida/">Kontakta oss</a> </div> </div> </div> </div> </footer> <div class="modal fade" id="noTigtagAccessModal" role="dialog"> <div class="modal-dialog modal-sm"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4>Tigtag</h4> <div>F枚r att anv盲nda tj盲nsten Tigtag m氓ste du vara inloggad med ett personligt konto.</div> </div> <div class="modal-body"> <a href="/login" class="btn btn-primary btn-block">Logga in med personligt konto</a> <div class="mt-xs mb-xs text-center">eller</div> <a href="/account/create?signup=nese" class="btn btn-default btn-block">Skapa personligt konto</a> </div> <div class="modal-footer"> <button type="submit" class="btn btn-disabled pull-left" data-dismiss="modal">Avbryt</button> </div> </div> </div> </div> <script>window.jQuery || document.write('<script src="//masala-ux.ne.se/masala-ux/current/dist/js/jquery.min.js"><\/script>')</script> <script src="/content/core/index/scripts/footerScripts.js"></script> <script src="//masala-ux.ne.se/masala-ux/current/dist/js/jwplayer.js"></script> <script src="//masala-ux.ne.se/masala-ux/current/dist/js/masala-ux.min.js"></script> <script> if(document.getElementById("navigation-pusher") != null) { document.getElementById("navigation-pusher").style.height = "80px"; } </script> <script src="//masala-ux.ne.se/masala-ux/current/dist/js/clipboard.min.js"></script> <script src="/uppslagsverk/assets/js/encyklopedia-web.js"></script> <script src="/uppslagsverk/assets/js/immersive-reader-sdk-1.1.0.js"></script> <script src="/uppslagsverk/assets/js/immersive-reader.js"></script> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script> var path = "/encyklopedi/l氓ng/diktatur/diktaturens-fortsatta-utveckling"; var subType = "l氓ng"; var type = "encyklopedi"; $(document).ready(function() { let threadId = null; let isLoading = false; let lastUserMessage = null; const inputField = $('#message-input'); const sendButton = $('#send-button'); $('#send-button').on('click', sendMessage); $('#message-input').on('keypress', function(e) { if (e.key === 'Enter') { sendMessage(); } }); $('#close-chat').on('click', function() { resetChat(); $('#chatbox').hide(); }); function resetChat(clearThread = true) { if (clearThread) { $('#chat-messages').children('.message').not('#ai-setup-indicator, #typing-indicator').remove(); threadId = null; } $('#error-message').hide(); showAISetupIndicator(); } function appendMessage(content, sender) { const messageContainer = $('<div>').addClass('message').addClass(sender); const label = sender === 'ai' ? 'AI-Martin' : 'Du'; const formattedContent = sender === 'ai' ? content.replace(/\n/g, '<br>') : $('<div>').text(content).html().replace(/\n/g, '<br>'); messageContainer.html(formattedContent + ' <p class="author-label">' + label + '</p>'); $('#chat-messages').append(messageContainer); $('#typing-indicator').before(messageContainer); scrollChatToBottom(); } function showAISetupIndicator() { $('#ai-setup-indicator').show(); scrollChatToBottom(); } function hideAISetupIndicator() { $('#ai-setup-indicator').hide(); } function showTypingIndicator() { $('#typing-indicator').show(); scrollChatToBottom(); } function hideTypingIndicator() { $('#typing-indicator').hide(); } function scrollChatToBottom() { const chatMessages = $('#chat-messages'); chatMessages.scrollTop(chatMessages[0].scrollHeight); } function displayErrorMessage() { const isThreadInitialized = threadId !== null; const buttonLabel = isThreadInitialized ? 'Skicka igen' : 'Starta om'; $('#retry-button').text(buttonLabel).show(); $('#error-message').show(); $('#retry-button').off('click').on('click', function() { $('#error-message').hide(); if (isThreadInitialized) { retryLastMessage(); } else { setupAIAssistant(); } }); } function setupAIAssistant() { resetChat(false); inputField.prop('disabled', true); sendButton.prop('disabled', true); inputField.val(''); $('#error-message').hide(); isLoading = true; showAISetupIndicator(); $.ajax({ type: 'POST', url: '/uppslagsverk/api/v1/gpt/threads', contentType: 'application/json; charset=UTF-8', data: JSON.stringify({ articleExcerpt: "", path: path, subType: subType, type: type, }), success: function(response) { isLoading = false; threadId = response.id; hideAISetupIndicator(); inputField.prop('disabled', false); sendButton.prop('disabled', false); appendMessage(response.content, 'ai'); }, error: function() { isLoading = false; hideAISetupIndicator(); inputField.prop('disabled', false); sendButton.prop('disabled', false); displayErrorMessage(); } }); } function sendMessage() { $('#error-message').hide(); const message = inputField.val().trim(); if (message === '') return; lastUserMessage = message; appendMessage(message, 'user'); inputField.val(''); isLoading = true; showTypingIndicator(); inputField.prop('disabled', true); sendButton.prop('disabled', true); if (!threadId) { setupAIAssistant(); } else { $.ajax({ type: 'POST', url: '/uppslagsverk/api/v1/gpt/messages', contentType: 'application/json; charset=UTF-8', data: JSON.stringify({ content: message, threadId: threadId }), success: function(response) { isLoading = false; hideTypingIndicator(); inputField.prop('disabled', false); sendButton.prop('disabled', false); appendMessage(response.content, 'ai'); }, error: function() { isLoading = false; hideTypingIndicator(); inputField.prop('disabled', false); sendButton.prop('disabled', false); displayErrorMessage(); } }); } } function retryLastMessage() { if (!lastUserMessage) return; appendMessage(lastUserMessage, 'user'); isLoading = true; showTypingIndicator(); inputField.prop('disabled', true); sendButton.prop('disabled', true); ajaxRequest = $.ajax({ type: 'POST', url: '/uppslagsverk/api/v1/gpt/messages', contentType: 'application/json; charset=UTF-8', data: JSON.stringify({ content: lastUserMessage, threadId: threadId }), success: function(response) { isLoading = false; hideTypingIndicator(); inputField.prop('disabled', false); sendButton.prop('disabled', false); appendMessage(response.content, 'ai'); }, error: function() { isLoading = false; hideTypingIndicator(); inputField.prop('disabled', false); sendButton.prop('disabled', false); displayErrorMessage(); } }); } $(document).on('click', '.start-chat-button', function(e) { e.preventDefault(); $('#chatbox').show(); setupAIAssistant(); }); $('#show-assistant-info').on('click', function() { $('#assistant-info-popup').show(); }); $('#close-assistant-info').on('click', function() { $('#assistant-info-popup').hide(); }); $('#close-popup').on('click', function() { $('#help-popup').hide(); }); }); </script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10