All Projects → Xiphe → jQuery-Merge-for-php-diff

Xiphe / jQuery-Merge-for-php-diff

Licence: MIT license
A client side merge tool for JBlonds PHP-Diff @ https://github.com/JBlond/php-diff.

Programming Languages

javascript
184084 projects - #8 most used programming language
coffeescript
4710 projects
PHP
23972 projects - #3 most used programming language
CSS
56736 projects
Less
1899 projects

Projects that are alternatives of or similar to jQuery-Merge-for-php-diff

Aehnlich
Show/Merge differences in directories and their content (text files) in Light/Dark designs
Stars: ✭ 73 (-1.35%)
Mutual labels:  diff, merge
TreeWalker
PHP JSON diff
Stars: ✭ 58 (-21.62%)
Mutual labels:  diff, merge
Nbdime
Tools for diffing and merging of Jupyter notebooks.
Stars: ✭ 2,135 (+2785.14%)
Mutual labels:  diff, merge
winmerge2011
Fork of WinMerge which has a different set of features
Stars: ✭ 36 (-51.35%)
Mutual labels:  diff, merge
treediff-rs
Extract differences between arbitrary datastructures
Stars: ✭ 52 (-29.73%)
Mutual labels:  diff, merge
Winmerge
WinMerge is an Open Source differencing and merging tool for Windows. WinMerge can compare both folders and files, presenting differences in a visual text format that is easy to understand and handle.
Stars: ✭ 2,358 (+3086.49%)
Mutual labels:  diff, merge
diffy
Tools for finding and manipulating differences between files
Stars: ✭ 47 (-36.49%)
Mutual labels:  diff, merge
visual-differ
A Node-based diffing tool to compare an array of URLs and flag differences between them
Stars: ✭ 18 (-75.68%)
Mutual labels:  diff
go-patchutils
go-patchutils is a library written in Go to show differences in source and diff files.
Stars: ✭ 19 (-74.32%)
Mutual labels:  diff
lcs-image-diff-rs
🖼 Image diff tool with LCS algorithm
Stars: ✭ 67 (-9.46%)
Mutual labels:  diff
deepmerge-ts
Deeply merge 2 or more objects respecting type information.
Stars: ✭ 102 (+37.84%)
Mutual labels:  merge
unidiff-rs
Unified diff parsing/metadata extraction library for Rust
Stars: ✭ 19 (-74.32%)
Mutual labels:  diff
AnyDiff
A CSharp (C#) diff library that allows you to diff two objects and get a list of the differences back.
Stars: ✭ 80 (+8.11%)
Mutual labels:  diff
got
An enjoyable golang test framework.
Stars: ✭ 234 (+216.22%)
Mutual labels:  diff
devops-ninja
This is a collection of some very useful command-line commands that eases the life of a DevOps Engineer.
Stars: ✭ 27 (-63.51%)
Mutual labels:  diff
open-md-gateway
Diff协议行情网关, 支持实时行情和历史行情
Stars: ✭ 18 (-75.68%)
Mutual labels:  diff
DPVideoMerger
Multiple videos merge in one video with manage scale & aspect ratio and also merge 4 videos to grid layou for Objective C.
Stars: ✭ 12 (-83.78%)
Mutual labels:  merge
ecomparatio
eComparatio: text diff and support for digital edition
Stars: ✭ 21 (-71.62%)
Mutual labels:  diff
atom-hg
Mercurial support for Atom text editor. Works on Linux, Mac OS X and Windows.
Stars: ✭ 27 (-63.51%)
Mutual labels:  diff
v-code-diff
A vue code diff display plugin, support Vue2 / Vue3
Stars: ✭ 93 (+25.68%)
Mutual labels:  diff

jQuery Merge for php-diff

A client side merge tool for JBlonds' PHP DIFF. Example

Version

THIS IS A BETA RELEASE!
I had not the time to test this very much so if you rely on this script blindly you may get some unexpected results.
You may help me write some tests to be able to check things better.

Usage

This tool requires a side-by-side or inline diff from php-diff and the full content of the compared files as a line-by-line array.

I use something like this on the server side. Also have a look at the the php-diff examples.

$left = explode("\n", preg_replace('/\r\n|\r/', "\n", $THECONTENTOFFILE_A));
$right = explode("\n", preg_replace('/\r\n|\r/', "\n", $THECONTENTOFFILE_B));

$options = array(
    //'ignoreWhitespace' => true,
    //'ignoreCase' => true,
);

/* Initialize the diff class */
$Diff = new \Diff($left, $right, $options);

/* Initiate the SideBySide or Inline Html renderer */
$Renderer = new \Diff_Renderer_Html_SideBySide;
// $Renderer = new \Diff_Renderer_Html_Inline;

/* Render the Diff-table. */
echo $Diff->render($Renderer);

/* Pass $a and $b to javascript */
echo '<script type="text/javascript">var left='.json_encode($left).', right='.json_encode($right).';'</script>

And this as initiation on the client side. Have a look at this example.

$('.Differences').phpdiffmerge({
    left: left,
    right: right,
    merged: function(merge, left, right) {
    	/* Do something with the merge */
        $.post(
        	'ajax.php',
        	{
        		action: 'merge_completed',
        		merge: merge
        	},
        	function() {
        		console.log('done');
        	}
        );
    }
    /* Use your own "Merge now" button */
    // ,button: '#myButtonId'
    /* uncomment to see the complete merge in a pop-up window */
    // ,pupupResult: true
    /* uncomment to pass additional infos to the console. */
    // ,debug: true
});

Playground

In the project folder:

  • Run npm install
  • Open a php server php -S localhost:8080
  • And open the example page in a browser localhost:8080/example

In the example folder you can find a.txt and b.txt where you can change the compared files.
Inside the index.php you can change the DIFF Style from side-by-side to inline and play with the plugin-options.

Options

Can be set by passing an object into the initiation $('.Differences').phpdiffmerge({option: 'foo'});.
Or by passing an options object to an instance of PHPDiffMerge $('.Differences').phpdiffmerge('option', {option: 'bar'});.

left | string: ""
The full content of the left file as an JavaScript line-by-line array.

right | string: ""
The full content of the right file as an JavaScript line-by-line array.

merged | function: function(result, left, right) {}
A callback function that is called after the merge has completed.
all parameters (same as the left and right inputs) are line-by-line arrays remember to .join('/n') them if you want to use them as strings.

button | mixed {optional}
A Selector or element that will be used as trigger for the final merge. If not set or invalid a button will be generated.

debug | boolean: false
Set true to log the steps made while merging into the console.

pupupResult | boolean: false
If true a pop-up window with the new merged content will be presented after merge.

pupupSources | boolean: false
If true two pup-up windows with the full left and right content will be presented after merge.

Methods

Called as string option on an instance: $('.Differences').phpdiffmerge('method', <arguments>);

useRight
Selects the right side of all conflicts.

useLeft
Selects the left side of all conflicts.

option Accepts an object, that will be extended into the current options.

merge The action called by the "Merge" Button

Special Thanks

  • To JBlond for the new PHP-DIFF version.
  • To Chris Boulton for PHP-DIFF and mentioning this project in its readme.
  • To Robert and Martin from jimdo.com for reviewing this plugin and giving me some very useful hints.
  • To Hannes Diercks for creating this library in the first place.

Changelog

next

  • Update: project dependencies
  • Fix: Links, since the project changed the owner (new github url)

0.2.2

  • Add _id to PHPDiffMerge instances to make them comparable by QUnits deepEqual

0.2.1

  • bugfixes for multiline and inline issues
  • new example/sandbox

0.2

  • complete refactoring of the plugin structure.

0.1

  • initial release

Todo

  • write tests.
  • spellcheck please, im not native english as you may have noticed ;)

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].