PageSourceSearch

https://inspirecms.net/js/solution-forest/inspirecms-support/diff.js?v=1.2.0.0

js inspirecms.net collected 2026-10-04 19:13:27 UTC 2,483 bytes, 1 lines download raw bytes

1document.addEventListener("alpine:init",()=>{window.Alpine.data("diffChecker",function({newValue:p,oldValue:m}){return{oldValue:m,newValue:p,diff:[],init(){this.calculateDiff()},getOldValue(){return this.oldValue||""},getNewValue(){return this.newValue||""},calculateDiff(){let e=this.getOldValue(),t=this.getNewValue();if(!e&&!t){this.diff=[];return}let i=this.tokenize(e),n=this.tokenize(t);this.diff=this.generateWordDiff(i,n)},tokenize(e){let t=[],i=/(\S+|\s+)/g,n;for(;(n=i.exec(e))!==null;)t.push(n[1]);return t},generateWordDiff(e,t){let i=[],n=0,l=0,u=this.longestCommonSubsequence(e,t),f=0;for(;n<e.length||l<t.length;){let c=e[n],s=t[l];if(n<e.length&&l<t.length&&c===s)i.push({type:"unchanged",content:c}),n++,l++;else{let h=!1,g=20;for(let o=0;o<=g&&n+o<e.length;o++){for(let d=0;d<=g&&l+d<t.length;d++)if(e[n+o]===t[l+d]&&u.includes(e[n+o])){for(let a=0;a<o;a++)i.push({type:"removed",content:e[n+a]});for(let a=0;a<d;a++)i.push({type:"added",content:t[l+a]});n+=o,l+=d,h=!0;break}if(h)break}h||(n<e.length&&l<t.length?(i.push({type:"removed",content:c}),i.push({type:"added",content:s}),n++,l++):n<e.length?(i.push({type:"removed",content:c}),n++):l<t.length&&(i.push({type:"added",content:s}),l++))}}return i},generateDiff(e,t){let i=[],n=0,l=0,u=this.longestCommonSubsequence(e,t);for(;n<e.length||l<t.length;){let f=e[n],c=t[l],s=u.includes(f)&&n<e.length,h=u.includes(c)&&l<t.length;n<e.length&&l<t.length&&f===c?(i.push({type:"unchanged",content:f,oldLineNum:n+1,newLineNum:l+1}),n++,l++):n<e.length&&(!h||l>=t.length||!s)?(i.push({type:"removed",content:f,oldLineNum:n+1,newLineNum:null}),n++):l<t.length&&(i.push({type:"added",content:c,oldLineNum:null,newLineNum:l+1}),l++)}return i},longestCommonSubsequence(e,t){let i=e.length,n=t.length,l=Array(i+1).fill().map(()=>Array(n+1).fill(0));for(let s=1;s<=i;s++)for(let h=1;h<=n;h++)e[s-1]===t[h-1]?l[s][h]=l[s-1][h-1]+1:l[s][h]=Math.max(l[s-1][h],l[s][h-1]);let u=[],f=i,c=n;for(;f>0&&c>0;)e[f-1]===t[c-1]?(u.unshift(e[f-1]),f--,c--):l[f-1][c]>l[f][c-1]?f--:c--;return u},getInlineDiff(){if(this.diff.length===0)return"";let e="";for(let t=0;t<this.diff.length;t++){let i=this.diff[t];i.type==="unchanged"?e+=this.escapeHtml(i.content):i.type==="removed"?e+=`<span class="deleted-text">${this.escapeHtml(i.content)}</span>`:i.type==="added"&&(e+=`<span class="added-text">${this.escapeHtml(i.content)}</span>`)}return e},escapeHtml(e){let t=document.createElement("div");return t.textContent=e,t.innerHTML}}})});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.