{"id":17369783,"url":"https://github.com/digilive/jquery-merge-for-php-diff","last_synced_at":"2025-04-15T02:36:58.762Z","repository":{"id":5545962,"uuid":"6749956","full_name":"DigiLive/jQuery-Merge-for-php-diff","owner":"DigiLive","description":"A client side merge tool for JBlonds PHP-Diff @ https://github.com/JBlond/php-diff.","archived":false,"fork":false,"pushed_at":"2022-03-01T07:14:12.000Z","size":109,"stargazers_count":74,"open_issues_count":4,"forks_count":17,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-28T15:11:15.214Z","etag":null,"topics":["conflicts","diff","javascript","jquery","merge"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DigiLive.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-11-18T18:51:33.000Z","updated_at":"2024-03-03T17:52:11.000Z","dependencies_parsed_at":"2022-07-07T01:00:41.428Z","dependency_job_id":null,"html_url":"https://github.com/DigiLive/jQuery-Merge-for-php-diff","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigiLive%2FjQuery-Merge-for-php-diff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigiLive%2FjQuery-Merge-for-php-diff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigiLive%2FjQuery-Merge-for-php-diff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigiLive%2FjQuery-Merge-for-php-diff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DigiLive","download_url":"https://codeload.github.com/DigiLive/jQuery-Merge-for-php-diff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248995101,"owners_count":21195497,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["conflicts","diff","javascript","jquery","merge"],"created_at":"2024-10-16T00:06:49.082Z","updated_at":"2025-04-15T02:36:58.406Z","avatar_url":"https://github.com/DigiLive.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"jQuery Merge for php-diff\n=========================\n\nA client side merge tool for JBlonds' [PHP DIFF](https://github.com/JBlond/php-diff).\n[Example](http://DigiLive.github.com/jQuery-Merge-for-php-diff/)\n\n\nVersion\n-------\n\nTHIS IS A BETA RELEASE!  \nI had not the time to test this very much so if you rely on this script blindly\nyou may get some unexpected results.  \nYou may help me write some tests to be able to check things better.\n\n\nUsage\n-----\n\nThis tool requires a side-by-side or inline diff from [php-diff](https://github.com/JBlond/php-diff)\nand the full content of the compared files as a line-by-line array.\n\nI use something like this on the server side.\nAlso have a look at the [the php-diff examples](https://github.com/JBlond/php-diff/tree/master/example).\n```php\n$left = explode(\"\\n\", preg_replace('/\\r\\n|\\r/', \"\\n\", $THECONTENTOFFILE_A));\n$right = explode(\"\\n\", preg_replace('/\\r\\n|\\r/', \"\\n\", $THECONTENTOFFILE_B));\n\n$options = array(\n    //'ignoreWhitespace' =\u003e true,\n    //'ignoreCase' =\u003e true,\n);\n\n/* Initialize the diff class */\n$Diff = new \\Diff($left, $right, $options);\n\n/* Initiate the SideBySide or Inline Html renderer */\n$Renderer = new \\Diff_Renderer_Html_SideBySide;\n// $Renderer = new \\Diff_Renderer_Html_Inline;\n\n/* Render the Diff-table. */\necho $Diff-\u003erender($Renderer);\n\n/* Pass $a and $b to javascript */\necho '\u003cscript type=\"text/javascript\"\u003evar left='.json_encode($left).', right='.json_encode($right).';'\u003c/script\u003e\n```\n\nAnd this as initiation on the client side.\nHave a look at [this example](http://DigiLive.github.com/jQuery-Merge-for-php-diff/).\n```javascript\n$('.Differences').phpdiffmerge({\n    left: left,\n    right: right,\n    merged: function(merge, left, right) {\n    \t/* Do something with the merge */\n        $.post(\n        \t'ajax.php',\n        \t{\n        \t\taction: 'merge_completed',\n        \t\tmerge: merge\n        \t},\n        \tfunction() {\n        \t\tconsole.log('done');\n        \t}\n        );\n    }\n    /* Use your own \"Merge now\" button */\n    // ,button: '#myButtonId'\n    /* uncomment to see the complete merge in a pop-up window */\n    // ,pupupResult: true\n    /* uncomment to pass additional infos to the console. */\n    // ,debug: true\n});\n```\n\nPlayground\n----------\n\nIn the project folder:\n  * Run `npm install`\n  * Open a php server `php -S localhost:8080`\n  * And open the example page in a browser [localhost:8080/example](http://localhost:8080/example)\n\nIn the example folder you can find `a.txt` and `b.txt` where you can change the compared files.  \nInside the `index.php` you can change the DIFF Style from side-by-side to inline and play with the plugin-options.\n\n\nOptions\n-------\n\nCan be set by passing an object into the initiation `$('.Differences').phpdiffmerge({option: 'foo'});`.  \nOr by passing an options object to an instance of PHPDiffMerge `$('.Differences').phpdiffmerge('option', {option: 'bar'});`.\n\n**left** | _string_: \"\"  \nThe full content of the left file as an JavaScript line-by-line array.\n\n**right** | _string_: \"\"  \nThe full content of the right file as an JavaScript line-by-line array.\n\n**merged** | _function_: function(result, left, right) {}  \nA callback function that is called after the merge has completed.  \nall parameters (same as the left and right inputs) are line-by-line arrays\nremember to `.join('/n')` them if you want to use them as strings.\n\n**button** | _mixed_ {optional}  \nA Selector or element that will be used as trigger for the final merge.\nIf not set or invalid a button will be generated.\n\n**debug** | _boolean_: false  \nSet true to log the steps made while merging into the console.\n\n**pupupResult** | _boolean_: false  \nIf true a pop-up window with the new merged content will be presented after merge.\n\n**pupupSources** | _boolean_: false  \nIf true two pup-up windows with the full left and right content will be presented after merge.\n\n\nMethods\n-------\n\nCalled as string option on an instance: `$('.Differences').phpdiffmerge('method', \u003carguments\u003e);`\n\n**useRight**  \nSelects the right side of all conflicts.\n\n**useLeft**  \nSelects the left side of all conflicts.\n\n**option**\nAccepts an object, that will be extended into the current options.\n\n**merge**\nThe action called by the \"Merge\" Button \n\n\nSpecial Thanks\n--------------\n\n- To JBlond for the new PHP-DIFF version.\n- To Chris Boulton for PHP-DIFF and mentioning this project in its readme.  \n- To Robert and Martin from jimdo.com for reviewing this plugin and giving me some very useful hints.\n- To [Hannes Diercks](https://github.com/Xiphe/) for creating this library in the first place. \n\n\nChangelog\n---------\n\n### next\n\n+ Update: project dependencies\n+ Fix: Links, since the project changed the owner (new github url)\n\n### 0.2.2\n+ Add _id to PHPDiffMerge instances to make them comparable by QUnits deepEqual\n\n### 0.2.1\n+ bugfixes for multiline and inline issues\n+ new example/sandbox\n\n### 0.2\n+ complete refactoring of the plugin structure.\n\n### 0.1\n+ initial release\n\n\nTodo\n----\n\n+ write tests.\n+ spellcheck please, im not native english as you may have noticed ;)\n\n\nLicense\n-------\n\n[MIT](https://raw.github.com/DigiLive/jQuery-Merge-for-php-diff/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigilive%2Fjquery-merge-for-php-diff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigilive%2Fjquery-merge-for-php-diff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigilive%2Fjquery-merge-for-php-diff/lists"}