Commit a66b9a83 authored by jan.koester's avatar jan.koester
Browse files

test

parent 5b72f93d
Loading
Loading
Loading
Loading
+22 −0
Changes for plugins/survey/survey.cpp: 22 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -493,6 +493,19 @@ namespace blogi {
            return out;
        }

        // ----- Generate hue (0-359) from string via djb2 hash -----
        static int hueFromId(const std::string &id) {
            unsigned long h = 5381;
            for (char c : id)
                h = ((h << 5) + h) + static_cast<unsigned char>(c);
            return static_cast<int>(h % 360);
        }

        // ----- Format HSL color string -----
        static std::string hsl(int h, int s, int l) {
            return "hsl(" + std::to_string(h) + "," + std::to_string(s) + "%," + std::to_string(l) + "%)";
        }

        // ----- Build Google Sheet tab name: domain (dots->underscores) + survey name -----
        std::string buildSheetName(const std::string &surveyName) {
            std::string domain = Args->config->getDomain();
@@ -1120,6 +1133,15 @@ namespace blogi {
                html << "<div class=\"step-dot" << (i == 0 ? " active" : "") << "\" data-step=\"" << i << "\"></div>";
            html << "</div>";

            // Auto-generate accent colors from template ID
            int hue = hueFromId(tpl.id.empty() ? tpl.name : tpl.id);
            html << "<style>"
                 << ".survey-page{--blogi-accent:" << hsl(hue, 65, 45) << ";"
                 << "--blogi-accent-dark:" << hsl(hue, 65, 35) << ";"
                 << "--blogi-success-bg:" << hsl(hue, 40, 92) << ";"
                 << "--blogi-success-text:" << hsl(hue, 60, 25) << ";}"
                 << "</style>";

            html << "<form id=\"surveyForm\">";

            // Step 0: Participant info (always required)