Dotclear

Changeset 3912:326f9c53acae


Ignore:
Timestamp:
11/03/18 09:32:26 (7 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Switching from inline JS variables to JSON script. More to come…

Location:
inc
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • inc/admin/lib.dc.page.php

    r3903 r3912  
    166166        '  <meta name="viewport" content="width=device-width, initial-scale=1.0" />' . "\n" . 
    167167        '  <title>' . $title . ' - ' . html::escapeHTML($core->blog->name) . ' - ' . html::escapeHTML(DC_VENDOR_NAME) . ' - ' . DC_VERSION . '</title>' . "\n"; 
     168 
     169        echo self::jsUtil(); 
    168170 
    169171        if ($core->auth->user_prefs->interface->darkmode) { 
     
    454456        '  <meta name="GOOGLEBOT" content="NOSNIPPET" />' . "\n"; 
    455457 
     458        echo self::jsUtil(); 
     459 
    456460        if ($core->auth->user_prefs->interface->darkmode) { 
    457461            echo self::jsVars(['dotclear_darkMode' => 1]); 
     
    740744 
    741745        return $ret; 
     746    } 
     747 
     748    public static function jsUtil() 
     749    { 
     750        return self::jsLoad($core->blog->getPF('util.js')); 
    742751    } 
    743752 
  • inc/core/class.dc.utils.php

    r3874 r3912  
    133133    { 
    134134        return dcUtils::jsVars([$n => $v]); 
     135    } 
     136 
     137    public static function jsJson($id, $vars) 
     138    { 
     139        // Use dcUtils::jsLoad($core->blog->getPF('util.js')) to use the JS getData() decoder 
     140        $ret = '<script type="application/json" id="' . html::escapeHTML($id) . '-data">' . "\n" . 
     141            json_encode($vars, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES) . "\n" . '</script>'; 
     142        return $ret; 
    135143    } 
    136144 
Note: See TracChangeset for help on using the changeset viewer.

Sites map