/**
* Client-side UUID generation for elements without server UUIDs
*
* Exposes: SFE.GenerateClientUuid
*/
(function() {
'use strict';
window.MWP = window.MWP || {};
window.MWP.SFE = window.MWP.SFE || {};
const SFE = window.MWP.SFE;
SFE.ManagerData = SFE.ManagerData || {};
/**
* Generate a deterministic UUID for elements without server UUIDs
* @deprecated no longer generate client UUIDs on the frontend. Use server-side UUIDs instead.
*/
function generateClientUuid(postId, typeCode, element) {
// Get clean content from element (remove FrontEdit controls first)
const clone = element.cloneNode(true);
clone.querySelectorAll('[data-mwp-sfe-control]').forEach(el => el.remove());
const content = clone.textContent.trim().replace(/\s+/g, ' ');
// Generate deterministic UUID based on content
const hashInput = postId + '|' + typeCode + '|' + content;
// Simple hash function
let hash = 0;
for (let i = 0; i < hashInput.length; i++) {
const char = hashInput.charCodeAt(i);
hash = ((hash << 5) - hash) + char;
hash = hash & hash;
}
// Convert to base62 string
const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
let result = '';
let num = hash >>> 0; // Convert to unsigned 32-bit
for (let i = 0; i < 16; i++) {
result += chars[num % 62];
num = Math.floor(num / 62);
if (num === 0) num = (hash >>> 0); // Reset if depleted
}
return postId + '-' + typeCode + '-' + result;
}
SFE.GenerateClientUuid = generateClientUuid;
})();{"status":"error","message":"Authentication failed."}
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`post_id` bigint(20) unsigned NOT NULL DEFAULT '0',
`optm_status` tinyint(4) NOT NULL DEFAULT '0',
`src` text NOT NULL,
`src_filesize` int(11) NOT NULL DEFAULT '0',
`target_filesize` int(11) NOT NULL DEFAULT '0',
`webp_filesize` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `post_id` (`post_id`),
KEY `optm_status` (`optm_status`)