Initialize is a framework for buiding web applications.
- Using CDN
- Create a file config.js
var APP_ID = ""; // Your APP unique ID
var WEBSITE_URL = ""; // Your website root URL
var API_URL = ""; // Your website API URL
if (location.hostname === "localhost" || location.hostname === "127.0.0.1" || location.hostname === "") {
WEBSITE_URL = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port;
}- Add to your webpage after the JQuery library
<script src="jquery.js"></script>
<script src="config.js"></script>
<script src="https://cdn.jsdelivr.net/gh/lesichkovm/[email protected]/initialize.js"></script>- Manual
- Create a file config.js
var APP_ID = ""; // Your APP unique ID
var WEBSITE_URL = ""; // Your website root URL
var API_URL = ""; // Your website API URL
if (location.hostname === "localhost" || location.hostname === "127.0.0.1" || location.hostname === "") {
WEBSITE_URL = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port;
}- Download the initialize.js library and add to your webpage after JQuery
<script src="jquery.js"></script>
<script src="config.js"></script>
<script src="initialize.js"></script>- If may want to download using Gulp so that you may use locally
gulp.task('web', function (done) {
var url = "https://cdn.jsdelivr.net/gh/lesichkovm/web@latest/initialize.js";
download(url)
.pipe(gulp.dest("js/"));
done();
});Initialize registers itself under the $$ name.
$(function(){
var name = $$.getUrlParam('name');
alert('Your name is ' + name);
});Returns a key from registry or NULL if not set
Sets a key-value pair to registry or NULL if not set
Returns a hash parameter or NULL if not set
Returns the current URL
Returns a single query parameter or NULL if not set
var name = $$.getUrlParam("name");
alert("Hi" + (name==null ? "Stranger" : name));
Returns the query parameters from the current URL
Returns the language or 'en' if not set
Sets the language
Returns the authentication token or NULL
Sets the authentication token. To remove set it to NULL
Returns the authenticated user or NULL
Sets the authenticated user. To remove set it to NULL
Redirects to current webpage to the specified URL (relative or absolute)
Calls the API with the specified action and data. Returns a promise
var p = $$.ws('login',{username:"",password:""});
p.done(function(response){ }); // Call successful
p.fail(function(error){ console.log(error) }); // Call failed
p.always(function(){ }); // After call is completed
If the API_URL ends with / or .json . The actions will be send like this:
api.url.com/?command=action
Otherwise they will be send using nice URLs
api.url.com/action
Logs message to console, if debug is enabled
The registry provides persistence across requests using Local Storage.
Gets a key from the registry
Sets a key in the registry. Optional expiration time in seconds
Removes a key from the registry
Empties the registry