Skip to content

Instantly share code, notes, and snippets.

View jslegers's full-sized avatar

John Slegers jslegers

View GitHub Profile
@jslegers
jslegers / jquery.qsParameters.js
Created February 21, 2016 17:24 — forked from EldonMcGuinness/jquery.qsParameters.js
JQuery Querystring Parser
(function ( $ ) {
$.qsParameters = function(str) {
var qso = {};
var qs = (str || document.location.search)
// Check for an empty querystring
if (qs == ""){
return qso;
}
function contains($haystack, $needle, $caseSensitive = false) {
return $caseSensitive?
(strpos($haystack, $needle) === FALSE ? FALSE : TRUE):
(stripos($haystack, $needle) === FALSE ? FALSE : TRUE);
}
var_dump(contains('bare','are')); // Outputs : bool(true)
var_dump(contains('stare', 'are')); // Outputs : bool(true)
var_dump(contains('stare', 'Are')); // Outputs : bool(true)
var_dump(contains('stare', 'Are', true)); // Outputs : bool(false)
var helper = {};
helper.string = {
contains : function (haystack, needle) {
return !!~haystack.indexOf(needle);
},
...
};
@jslegers
jslegers / dynamics.odata.services.php
Last active October 28, 2022 12:48
A pretty basic but effective class that can be used to do CRUD operations on Microsoft Dynamics NAV's Odata service for the customer entity
<?php
// A pretty basic but effective class that can be used for doing CRUD operations on Microsoft Dynamics NAV's Odata services
error_reporting(E_ALL);
ini_set("display_errors", 1);
class http_request {
protected $_handle = NULL;
@jslegers
jslegers / parsequery.js
Last active April 10, 2018 14:17
How to parse a query string
function parseQuery(str) {
var qso = {};
var qs = (str || document.location.search);
// Check for an empty querystring
if (qs == "") {
return qso;
}
// Normalize the querystring
qs = qs.replace(/(^\?)/, '').replace(/;/g, '&');
while (qs.indexOf("&&") != -1) {