Skip to content
Snippets Groups Projects
Commit 432506a6 authored by Olivier Cots's avatar Olivier Cots
Browse files

Merge branch 'master' of gitlab.irit.fr:toc/etu-n7/automatique

parents f4b47ee7 83a7695b
Branches
No related tags found
No related merge requests found
Showing
with 2682 additions and 0 deletions
"use strict";
/**
* Dahuapp core module.
*
* @param window window javascript object.
* @param $ jQuery
* @returns dahuapp core module.
*/
(function (window, $) {
var dahuapp = (function () {
var self = {};
/* private API */
var DahuScreencastGenerator = function () {
/*
* Format the specified string in a readable format.
*/
function htmlFormat(htmlString) {
var i;
var readableHTML = htmlString;
var lb = '\n';
var htags = ["<html", "</html>", "</head>", "<title", "</title>", "<meta", "<link", "</body>"];
for (i = 0; i < htags.length; ++i) {
var hhh = htags[i];
readableHTML = readableHTML.replace(new RegExp(hhh, 'gi'), lb + hhh);
}
var btags = ["</div>", "</section>", "</span>", "<br>", "<br />", "<blockquote", "</blockquote>", "<ul", "</ul>", "<ol", "</ol>", "<li", "<\!--", "<script", "</script>"];
for (i = 0; i < btags.length; ++i) {
var bbb = btags[i];
readableHTML = readableHTML.replace(new RegExp(bbb, 'gi'), lb + bbb);
}
var ftags = ["<img", "<legend", "</legend>", "<button", "</button>"];
for (i = 0; i < ftags.length; ++i) {
var fff = ftags[i];
readableHTML = readableHTML.replace(new RegExp(fff, 'gi'), lb + fff);
}
var xtags = ["<body", "<head", "<div", "<section", "<span", "<p"];
for (i = 0; i < xtags.length; ++i) {
var xxx = xtags[i];
readableHTML = readableHTML.replace(new RegExp(xxx, 'gi'), lb + lb + xxx);
}
return readableHTML;
}
/*
* Generates the html header.
*/
var generateHtmlHeader = function ($generated, cssGen) {
$('head', $generated)
.append($(document.createElement('title'))
.append("Dahu Presentation"))/* TODO: make this customizable */
.append($(document.createElement('meta'))
.attr({'charset': 'utf-8'}))
.append($(document.createElement('script'))
.attr({'src': 'http://code.jquery.com/jquery-1.9.1.min.js'})
.attr({'type': 'text/javascript'}))
.append($(document.createElement('script'))
.attr({'src': 'parse-search.js'})
.attr({'type': 'text/javascript'}))
.append($(document.createElement('link'))
.attr({'rel': 'stylesheet', 'href': 'dahuapp.viewer.css'}))
.append($(document.createElement('style'))
.append(cssGen));
};
/*
* Generates the objects.
*/
var generateHtmlBackgroundImage = function ($generated, object) {
$('.object-list', $generated)
.append($(document.createElement('img'))
.attr({'src': object.img, 'alt': object.img, 'class': 'background ' + object.id}));
};
var generateHtmlTooltip = function ($generated, object) {
$('.object-list', $generated)
.append($(document.createElement('div'))
.attr({'class': 'tooltip ' + object.id})
.append(object.text));
};
var generateCssTooltip = function ($generated, object) {
var style = [];
if( object.color != null ) {
style.push('background-color: ' + object.color);
}
if( object.width != null ) {
style.push('width: ' + object.width);
}
if( style.length != 0 ) {
$generated.append(
'.' + object.id + '{' + style.join(';') + '}\n');
}
return $generated;
};
/*
* Returns the code used to call the viewer to the presentation.
*/
var getBasicCallCode = function (jsonModel) {
var code = '(function($) {\n';
code += ' var myPresentation = dahuapp.viewer.createDahuViewer("#my-dahu-presentation", window.getParams);\n';
code += ' myPresentation.load(' + jsonModel + ');\n';
code += ' myPresentation.start();\n';
code += '})(jQuery);\n';
return code;
};
/*
* Generates the html body.
*/
var generateHtmlBody = function ($generated, jsonModel, jsonGen) {
$('body', $generated)
/* We could use a <section> here too, but it does not work with MS IE 8.
Alternatively, adding this in the header would work:
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
*/
.append($(document.createElement('div'))
.attr({'id': 'my-dahu-presentation'}))
.append($(document.createElement('script'))
.attr({'src': 'dahuapp.js'})
.attr({'type': 'text/javascript'}))
.append($(document.createElement('script'))
.attr({'src': 'dahuapp.viewer.js'})
.attr({'type': 'text/javascript'}))
.append($(document.createElement('script'))
.attr({'type': 'text/javascript'})
.append(getBasicCallCode(jsonGen)));
$('#my-dahu-presentation', $generated)
.append($(document.createElement('div'))
.attr({'id': 'loading'}).append("Loading presentation..."))
.append($(document.createElement('div'))
.attr({'class': 'object-list',
'style': 'display: none'}))
.append($(document.createElement('div'))
.attr({'class': 'control'}));
/* Adding the objects to the page */
$.each(jsonModel.getObjectList(), function (id, object) {
switch (object.type) {
case "background":
generateHtmlBackgroundImage($generated, object);
break;
case "tooltip":
generateHtmlTooltip($generated, object);
break;
/* no mouse image generated here */
}
});
/* Warning here, i'm not sure if $.each is always over, here */
/* Adding the control buttons to the page */
$('.control', $generated)
.css({'top': (jsonModel.getImageHeight() + 16) + 'px'})
.append($(document.createElement('button'))
.attr({'class': 'previous'})
.append('Previous'))
.append($(document.createElement('button'))
.attr({'class': 'next'})
.append('Next'));
/* Adding the mouse cursor image */
$('.object-list', $generated)
.append($(document.createElement('div'))
.attr({'class': 'mouse-cursor'})
.append($(document.createElement('img'))
.attr({'src': 'img/cursor.png', 'alt': 'img/cursor.png', 'class': 'mouse-cursor-normal'}))
.append($(document.createElement('img'))
.attr({'src': 'img/cursor-pause.png', 'alt': 'img/cursor-pause.png',
'style': 'display: none', 'class': 'mouse-cursor-pause'})));
};
/*
* Generates the css String with the Json model.
*/
this.generateCssString = function (jsonModel) {
var $generated = $('<style></style>');
/* Going through each object */
$.each(jsonModel.getObjectList(), function (id, object) {
switch (object.type) {
case "tooltip":
generateCssTooltip($generated, object);
break;
/* no mouse image generated here */
}
});
return $generated.text();
}
/*
* Generates the html String with the Json model.
*/
this.generateHtmlString = function (jsonModel, jsonGen, cssGen) {
/* Initialising the compilation area */
var $generated = $(document.createElement('div'));
/* We create the html using the json */
$generated.append($(document.createElement('html'))
.attr({'lang': 'en'}));
$('html', $generated)
.append($(document.createElement('head')))
.append($(document.createElement('body')));
generateHtmlHeader($generated, cssGen);
generateHtmlBody($generated, jsonModel, jsonGen);
var result = htmlFormat($generated.html());
return '<!DOCTYPE html>\n' + result;
};
/*
* Generates the generated JSON using the JSONmodel.
* @param {object} jsonModel The json model to transform.
* @param {java.awt.Dimension} imgDim The dimension of images.
*/
this.generateJsonString = function (jsonModel, imgDim) {
var generated = self.createScreencastGeneratedModel();
generated.setImageSize(imgDim.width, imgDim.height);
generated.setInitialBackground(jsonModel.getInitialBackground());
generated.setInitialMousePos(jsonModel.getInitialMousePos());
for (var i = 0; i < jsonModel.getNbSlide(); i++) {
var actionList = jsonModel.getActionList(i);
for (var j = 0; j < actionList.length; j++) {
/*
* We don't add the two first actions of the first slide
* because they are present in the presentation metadata.
* It corresponds to the mouse initial pos and first background.
*/
if (i > 0 || j > 1) {
generated.addAction(actionList[j], imgDim.width, imgDim.height);
}
}
}
return generated.getJson();
};
};
/*
* Model for a JSON object that will only be used by the viewer, never
* saved on a file, used to transform the properties of actions
* specified on the JSON file of a presentation to executable
* functions for each action.
*/
var DahuScreencastExecutableModel = function () {
/* Private API */
var json = {
metaData: {},
action: new Array()
};
/*
* Creates a functions representing the specified action, and adds
* it to this object.
* @param {object} action
*/
var addExecutableAction = function (action) {
var executableAction = {
'id': action.id,
'trigger': action.trigger,
'target': action.target,
'delayAfter': action.delayAfter,
'doneFunction': function (events, selector) {
setTimeout(function () {
events.onActionOver.publish(events, selector);
}, this.delayAfter);
}
};
if (executableAction.delayAfter == null) {
executableAction.delayAfter = 200;
}
switch (action.type.toLowerCase()) {
case "appear":
executableAction.abs = (action.abs * json.metaData.imageWidth) + 'px';
executableAction.ord = (action.ord * json.metaData.imageHeight) + 'px';
executableAction.duration = action.duration;
executableAction.execute = function (events, selector) {
events.onActionStart.publish(events, selector);
var sel = selector + ' .' + this.target;
$(sel).css({
'left': this.abs,
'top': this.ord
});
$(sel).show(this.duration, function () {
executableAction.doneFunction(events, selector);
});
};
executableAction.executeReverse = function (selector) {
$(selector + ' .' + this.target).hide();
};
executableAction.executeImmediately = function (selector) {
var sel = selector + ' .' + this.target;
$(sel).css({
'left': this.abs,
'top': this.ord
});
$(sel).show();
};
break;
case "disappear":
executableAction.duration = action.duration;
executableAction.execute = function (events, selector) {
events.onActionStart.publish(events, selector);
$(selector + ' .' + this.target).hide(this.duration, function () {
executableAction.doneFunction(events, selector);
});
};
executableAction.executeReverse = function (selector) {
$(selector + ' .' + this.target).show();
};
executableAction.executeImmediately = function (selector) {
$(selector + ' .' + this.target).hide();
};
break;
case "move":
executableAction.finalAbs = (action.finalAbs * json.metaData.imageWidth) + 'px';
executableAction.finalOrd = (action.finalOrd * json.metaData.imageHeight) + 'px';
executableAction.duration = action.duration;
executableAction.speed = action.speed;
executableAction.execute = function (events, selector) {
events.onActionStart.publish(events, selector);
var sel = selector + ' .' + this.target;
this.initialAbs = $(sel).css('left');
this.initialOrd = $(sel).css('top');
if (this.duration == null) {
var initialAbsPix = this.initialAbs.replace('px', '');
var initialOrdPix = this.initialOrd.replace('px', '');
var finalAbsPix = this.finalAbs.replace('px', '');
var finalOrdPix = this.finalOrd.replace('px', '');
var distance = Math.sqrt(Math.pow(finalAbsPix - initialAbsPix, 2) +
Math.pow(finalOrdPix - initialOrdPix, 2));
if (!this.speed) {
this.speed = .8; // in pixel per milisecond: fast, but not too much.
}
this.duration = distance + this.speed;
if (this.duration < 200) { // Slow down a bit for short distances.
this.duration = 200;
}
}
$(sel).animate({
'left': this.finalAbs,
'top': this.finalOrd
}, this.duration, 'linear', function () {
executableAction.doneFunction(events, selector);
});
};
executableAction.executeReverse = function (selector) {
$(selector + ' .' + this.target).css({
'left': this.initialAbs,
'top': this.initialOrd
});
};
executableAction.executeImmediately = function (selector) {
var sel = selector + ' .' + this.target;
this.initialAbs = $(sel).css('left');
this.initialOrd = $(sel).css('top');
$(sel).css({
'left': this.finalAbs,
'top': this.finalOrd
});
};
break;
case "delay":
executableAction.duration = action.duration;
executableAction.execute = function (events, selector) {
events.onActionStart.publish(events, selector);
setTimeout(function () {
events.onActionOver.publish(events, selector);
}, this.duration);
};
executableAction.executeReverse = function (selector) {
// Nothing!
};
executableAction.executeImmediately = function (selector) {
// Nothing too!
};
break;
}
json.action.push(executableAction);
};
/* Public API */
/*
* Loads the specified JSON read from a 'presentation.json' file,
* and stores the functions representing each actions in an object.
* @param {object} jsonToLoad
*/
this.loadJson = function (jsonToLoad) {
json.metaData = jsonToLoad.metaData;
for (var i = 0; i < jsonToLoad.action.length; i++) {
addExecutableAction(jsonToLoad.action[i]);
}
};
/*
* Returns the object containing the functions.
*/
this.getJson = function () {
return json;
};
};
/*
* Used to transform the 'dahu' file to a JSON file used by the viewer,
* which only contains some metaData and a list of actions.
*/
var DahuScreencastGeneratedModel = function () {
/* Private API */
var json = {
metaData: {},
action: new Array()
};
/* Public API */
/*
* Returns a string representation of this json.
* @returns {String}
*/
this.getJson = function () {
return JSON.stringify(json, null, ' ');
};
/*
* Setters for the generated json metadata.
*/
this.setImageSize = function (width, height) {
json.metaData.imageWidth = width;
json.metaData.imageHeight = height;
};
this.setInitialMousePos = function (pos) {
json.metaData.initialMouseX = pos.x;
json.metaData.initialMouseY = pos.y;
};
this.setInitialBackground = function (id) {
json.metaData.initialBackgroundId = id;
};
this.addAction = function (action) {
json.action.push(action);
};
/*
* Transforms a JSON containing action properties to a JSON containing
* the execution functions.
* @param {Object} json
* @returns {Object} A json object containing the execution functions
* for all the actions of the presentation.
*/
this.toExecutableList = function (json) {
var executableList = {
metaData: json.metaData,
action: new Array()
};
for (var i = 0; i < json.action.length; i++) {
addExecutableAction(executableList, json.action[i]);
}
return executableList;
};
};
/*
* Represents a 'dahu' file for a project.
*/
var DahuScreencastModel = function () {
/* Private API */
var json = {};
/*
* Generates a unique action ID.
*
* With this implementation, this ID is unique as long as the user
* doesn't replace it manually with a not kind value or replace
* the nextUniqueId with bad intentions.
* But maybe that a UUID is a bit tiresome to put as an anchor...
*/
var generateUniqueActionId = function () {
json.metaData.nextUniqueId++;
return json.metaData.nextUniqueId.toString();
};
/*
* This method checks if the json representing a dahu project is
* in the good version. It's in case a project file was created
* with a previous version of Dahu, and that some fields are
* missing.
*
* It doesn't control each field (at the moment) but only the
* fields that can be missing due to a new Dahu version and not
* to a manual editing.
*
* This method doesn't check any Json syntax or something like that.
*/
var upgradeJsonVersion = function () {
// Checks if unique IDs are in the project file
if (!json.metaData.nextUniqueId) {
var currentId = 0;
for (var i = 0; i < json.data.length; i++) {
for (var j = 0; j < json.data[i].action.length; j++) {
json.data[i].action[j].id = currentId.toString();
currentId++;
}
}
json.metaData.nextUniqueId = currentId;
}
};
/* Public API */
/*
* json variable generated from a JSON file.
* @param String stringJson String loaded from JSON file.
*/
this.loadJson = function (stringJson) {
json = JSON.parse(stringJson);
upgradeJsonVersion();
};
/*
* Create a new presentation variable in the JSON file which will contain slides.
*/
this.createPresentation = function (width, height) {
json.metaData = {};
json.metaData.imageWidth = width;
json.metaData.imageHeight = height;
json.metaData.nextUniqueId = 0;
json.data = new Array();
};
/*
* Add a new slide in the presentation variable of the JSON file.
* @param int index wanted for the slide.
* @param String idSlide Unique identifier for the slide.
* @param String img Related to pathname of the image.
* @param double mouseX Abscissa mouse position in %.
* @param double mouseY Ordinate mouse position in %.
* @return Index of the newly added slide.
*/
this.addSlide = function (indexSlide, idSlide, img, mouseX, mouseY, speed) {
var slide = {
"object": new Array(),
"action": new Array()
};
json.data.splice(indexSlide, 0, slide);
this.addObject(indexSlide, "background", idSlide, img);
this.addObject(indexSlide, "mouse");
this.addAction(indexSlide, "move", json.data[indexSlide].object[1].id, "onClick", mouseX, mouseY, speed);
this.addAction(indexSlide, "appear", json.data[indexSlide].object[0].id, "afterPrevious");
};
/*
* Object factory.
* Add a new Object in the slide idSlide.
* @param int idSlide
* @param string type
* Other params can be specified depending on the object's type.
*/
this.addObject = function (idSlide, type) {
var object = {
"type": type
};
switch (type.toLowerCase()) {
case "background":
object.id = arguments[2] + json.data[idSlide].object.length;
object.img = arguments[3] || "";
break;
case "mouse":
object.id = "mouse-cursor";
break;
case "tooltip":
/*
* TODO: we'll need a more robust unique name
* when we start actually using this.
*/
object.id = "s" + idSlide + "-o" + json.data[idSlide].object.length;
object.text = arguments[2] || "";
object.color = arguments[3] || null;
object.width = arguments[4] || "";
json.data[idSlide].object.push(object);
var objectLength = json.data[idSlide].object.length;
var last = json.data[idSlide].object[objectLength-1];
json.data[idSlide].object[objectLength-1] =
json.data[idSlide].object[objectLength-2];
json.data[idSlide].object[objectLength-2] = last;
break;
}
if(type.toLowerCase() != "tooltip"){
json.data[idSlide].object.push(object);
}
};
/*
* Action factory.
* Add a new Action in the slide idSlide whose target is the id of an object.
* Three types of trigger : "withPrevious", "afterPrevious", "onClick".
* @param int idSlide
* @param string type
* @param string target
* @param string trigger
* Other params can be specified depending on the object's type.
*/
this.addAction = function (idSlide, type, target, trigger) {
var action = {
"id": generateUniqueActionId(),
"type": type,
"target": target,
"trigger": trigger
};
switch (type.toLowerCase()) {
case "appear":
action.abs = arguments[4] || 0.0;
action.ord = arguments[5] || 0.0;
action.duration = arguments[6] || 0;
break;
case "disappear":
action.duration = arguments[4] || 0;
break;
case "move":
action.finalAbs = arguments[4] || 0.0;
action.finalOrd = arguments[5] || 0.0;
action.speed = arguments[6] || 0;
break;
}
json.data[idSlide].action.push(action);
};
this.editMouse = function (idSlide, idAction, mouseX, mouseY) {
json.data[idSlide].action[idAction].finalAbs = mouseX;
json.data[idSlide].action[idAction].finalOrd = mouseY;
};
/*
* Sets a title for the presentation.
* @param String title Title to set.
*/
this.setTitle = function (title) {
json.metaData.title = title;
};
/*
* Sets an annotation for the presentation.
* @param String annotation Annotation to set.
*/
this.setAnnotation = function (annotation) {
json.metaData.annotation = annotation;
};
/*
* Inverts the two slides (their positions on the table).
* @param int idSlide1 Index of the first slide.
* @param int idSlide2 Index of the second slide.
*/
this.invertSlides = function (idSlide1, idSlide2) {
var tmp = json.data[idSlide1];
json.data[idSlide1] = json.data[idSlide2];
json.data[idSlide2] = tmp;
};
/*
* Inverts the two actions (their positions on the table).
* @param int idSlide
* @param int idAction1
* @param int idAction2
*/
this.invertActions = function (idSlide, idAction1, idAction2) {
var tmp = json.data[idSlide].action[idAction1];
json.data[idSlide].action[idAction1] = json.data[idSlide].action[idAction2];
json.data[idSlide].action[idAction2] = tmp;
};
/*
* Returns the actions on the specified slide.
* @returns {Array}
*/
this.getActionList = function (idSlide) {
return json.data[idSlide].action;
};
/*
* Catches all the objects of the presentation
* @returns {Array} List of objects of the presentation
*/
this.getObjectList = function () {
var objectList = new Array();
var indexSlide = 0;
while (json.data[indexSlide]) {
var indexObject = 0;
while (json.data[indexSlide].object[indexObject]) {
objectList.push(json.data[indexSlide].object[indexObject]);
indexObject++;
}
indexSlide++;
}
return objectList;
};
/*
* Returns an array containing all the background images.
* @returns {Array} List of background images.
*/
this.getImageList = function () {
var list = new Array();
var indexSlide = 0;
while (json.data[indexSlide]) {
list.push(json.data[indexSlide].object[0].img);
indexSlide++;
}
;
return list;
};
/*
* Returns an object containing the id of the first background.
* @returns {string} Id of the first background.
*/
this.getInitialBackground = function () {
return json.data[0].object[0].id;
};
/*
* Returns an object containing the initial mouse position.
* @returns {object} Initial position of mouse.
*/
this.getInitialMousePos = function () {
var pos = {};
pos.x = json.data[0].action[0].finalAbs;
pos.y = json.data[0].action[0].finalOrd;
return pos;
};
/*
* Removes the slide at the specified index.
* @param {int} idSlide
*/
this.removeSlide = function (idSlide) {
json.data.splice(idSlide, 1);
};
/*
* Removes the action at the specified slide.
* @param {int} idSlide
* @param {int} idAction
*/
this.removeAction = function (idSlide, idAction) {
json.data[idSlide].action.splice(idAction, 1);
};
/*
* Removes the specified object from the slide.
* Also removes all the actions attached to this object.
* @param {int} idSlide
* @param {int} idObject
*/
this.removeObject = function (idSlide, idObject) {
var removed = json.data[idSlide].object.splice(idObject, 1);
for (var i = 0; i < json.data.length; i++) {
var j = 0;
while (json.data[i].action[j]) {
if (json.data[i].action[j].target === removed.id) {
json.data[i].action.splice(j, 1);
} else {
j++;
}
}
}
};
/*
* @returns {String}
*/
this.getJson = function () {
return JSON.stringify(json, null, ' ');
};
/*
* @returns {String} returns the index for the next slide.
*/
this.getNbSlide = function () {
return json.data.length;
};
/*
* @return {object} returns the object identified by idSlide
*/
this.getSlide = function (idSlide) {
return json.data[idSlide];
};
/*
* Sets the size of images for the generated presentation.
* The parameters can be null : it means there are no
* requirement for this dimension.
* @param {int} width New width for the generated images.
* @param {int} height New height for the generated images.
*/
this.setImageSizeRequirements = function (width, height) {
json.metaData.imageWidth = width;
json.metaData.imageHeight = height;
};
/*
* Gets the width of images for the generated presentation.
* @return {int or null} Width of generated images.
*/
this.getImageWidth = function () {
return json.metaData.imageWidth;
};
/*
* Gets the height of images for the generated presentation.
* @return {int or null} Height of generated images.
*/
this.getImageHeight = function () {
return json.metaData.imageHeight;
};
/*
* Gets a background image (no one in particular, the first met).
* @return {string} The name of a background image.
*/
this.getABackgroundImage = function () {
for (var i = 0; i < json.data.length; i++) {
for (var j = 0; j < json.data[i].object.length; j++) {
if (json.data[i].object[j].type === "background") {
return json.data[i].object[j].img;
}
}
}
return null;
};
};
/* public API */
self.version = "0.0.1";
self.createScreencastGenerator = function createScreencastGenerator() {
return new DahuScreencastGenerator();
};
self.createScreencastModel = function createScreencastModel() {
return new DahuScreencastModel();
};
self.createScreencastExecutableModel = function createScreencastExecutableModel() {
return new DahuScreencastExecutableModel();
};
self.createScreencastGeneratedModel = function createScreencastGeneratedModel() {
return new DahuScreencastGeneratedModel();
};
return self;
})();
window.dahuapp = dahuapp;
})(window, jQuery);
\ No newline at end of file
.object-list {
position: absolute;
margin: 0px;
padding: 0px;
}
.mouse-cursor {
position: absolute;
}
.control {
position: relative;
}
.background {
position: absolute;
}
.tooltip {
position: absolute;
width: 100px;
padding: 4px;
margin: 2px;
border: 2px black solid;
}
\ No newline at end of file
"use strict";
/**
* Dahuapp viewer module.
*
* @param dahuapp dahuapp object to augment with module.
* @param $ jQuery
* @returns dahuapp extended with viewer module.
*/
(function(dahuapp, $) {
var viewer = (function() {
var self = {};
var DahuViewerModel = function(select, getParams) {
/* Private API */
var json = null;
var selector = select;
var parseAutoOption = function(name, defaultValue) {
var res = getParams[name];
if (res == null) {
if (name == 'auto') {
return false;
} else {
return parseAutoOption('auto', defaultValue);
}
}
if (res.toLowerCase() === 'false') {
return false;
}
res = parseInt(res);
if (isNaN(res)) {
// e.g. ?autoplay or ?autoplay=true
return defaultValue;
}
return res;
}
/* Whether to wait for "next" event between actions */
var autoPlay = parseAutoOption('autoplay', 5000);
/* Whether to wait for "next" event on page load */
var autoStart = parseAutoOption('autostart', 5000);
/* Whether to loop back to start at the end of presentation */
var autoLoop = parseAutoOption('autoloop', 5000);
var events = (function() {
var self = {};
/*
* Creates a generic event.
*/
var createEvent = function() {
var callbacks = $.Callbacks();
return {
publish: callbacks.fire,
subscribe: callbacks.add,
unsubscribe: callbacks.remove,
unsubscribeAll: callbacks.empty
};
};
/*
* Called when the button next is pressed.
*/
self.onNext = createEvent();
/*
* Called when the button previous is pressed.
*/
self.onPrevious = createEvent();
/*
* Called when an action is over.
*/
self.onActionOver = createEvent();
/*
* Called when an action starts.
*/
self.onActionStart = createEvent();
/*
* Called when at least one action was running and has finished.
*/
self.onAllActionFinish = createEvent();
return self;
})();
/*
* Variables used like index for methodes subscribed.
*/
var currentAction = 0; /* Action currently running */
var nextAction = 0; /* Action to execute on 'Next' click */
var nbActionsRunning = 0;
var previousAnchor = -1; /* Last entered anchor, only used in
* case the 'onhashchange' event is
* not supported by the web browser */
/*
* Functions to reinitialise running actions and subscribed
* callbacks (reinitialise is called once without stopping
* all the actions, so the two functions are separated).
*/
var stopAllActions = function() {
$(selector + " .object-list").children().stop(true, true);
reinitialiseCallbackLists();
nbActionsRunning = 0;
};
var reinitialiseCallbackLists = function() {
events.onActionStart.unsubscribeAll();
events.onActionStart.subscribe(onActionStartEventHandler);
events.onAllActionFinish.unsubscribeAll();
};
/*
* Timer used to program onNext event in autoplay mode.
*/
var playTimer = 0;
/*
* Function used when an "onNextEvent" event is caught.
*/
var onNextEventHandler = function() {
/*
* If the user pressed "next" before an autoplay event
* is triggered, it replaces the autoplay event, hence
* cancels it:
*/
window.clearTimeout(playTimer);
enterAnimationMode();
stopAllActions();
var tmpAction = nextAction;
var onlyWithPrevious = true;
nextAction++;
currentAction = nextAction;
while (json.action[currentAction] && onlyWithPrevious) {
switch (json.action[currentAction].trigger) {
case 'onClick':
nextAction = currentAction;
onlyWithPrevious = false;
break;
case 'withPrevious':
var tmp = currentAction;
/*
* We can't directly pass 'execute' as callback because we
* allow the 'execute' function to reference a property of the
* object (by using 'this.property') so we have to call the
* function in the containing object to make that available
*/
events.onActionStart.subscribe(function(events, selector) {
json.action[tmp].execute(events, selector);
});
break;
case 'afterPrevious':
var tmp = currentAction;
events.onAllActionFinish.subscribe(function(events, selector) {
json.action[tmp].execute(events, selector);
});
while (json.action[nextAction] && json.action[nextAction].trigger !== 'onClick') {
nextAction++;
}
onlyWithPrevious = false;
break;
}
currentAction++;
}
if (json.action[tmpAction]) {
launch(json.action[tmpAction]);
}
if (nextAction > json.action.length) {
nextAction = json.action.length;
}
};
/*
* Function used when an "onPreviousEvent" event is caught.
*/
var onPreviousEventHandler = function() {
stopAllActions();
currentAction = nextAction - 1;
while (json.action[currentAction] && json.action[currentAction].trigger !== 'onClick') {
launchReverse(json.action[currentAction]);
currentAction--;
}
/* currentAction = -1 means that it's the beginning */
if (currentAction > -1) {
launchReverse(json.action[currentAction]);
}
if (currentAction < 0) {
currentAction = 0;
}
nextAction = currentAction;
};
/*
* Function used when an "onActionOverEvent" event is caught.
*/
var onActionOverEventHandler = function() {
nbActionsRunning--;
if (nbActionsRunning === 0) {
events.onAllActionFinish.publish(events, selector);
reinitialiseCallbackLists();
while (json.action[currentAction]) {
switch (json.action[currentAction].trigger) {
case 'onClick':
leaveAnimationMode();
if (autoPlay && nbActionsRunning === 0) {
playTimer = setTimeout(function () {
events.onNext.publish();
}, autoPlay);
}
return;
case 'withPrevious':
var tmp = currentAction;
events.onActionStart.subscribe(function(events, selector) {
json.action[tmp].execute(events, selector);
});
break;
case 'afterPrevious':
var tmp = currentAction;
events.onAllActionFinish.subscribe(function(events, selector) {
json.action[tmp].execute(events, selector);
});
currentAction++;
return;
}
currentAction++;
}
if (autoLoop && nbActionsRunning === 0) {
setTimeout(function () {
resetPresentation();
startPresentationMaybe();
}, autoLoop);
}
}
leaveAnimationMode();
};
/*
* Function used when an "onActionStartEvent" event is caught.
*/
var onActionStartEventHandler = function() {
nbActionsRunning++;
};
/*
* Enter and leave "animation" mode. The viewer is in
* animation mode when something is going on without human
* interaction (i.e. executing actions before the next
* "onClick").
*/
var enterAnimationMode = function () {
$(selector + ' .mouse-cursor-pause').hide();
$(selector + ' .mouse-cursor-normal').show();
};
var leaveAnimationMode = function () {
$(selector + ' .mouse-cursor-pause').show();
$(selector + ' .mouse-cursor-normal').hide();
};
/*
* Function used to perform actions.
*/
var launch = function(action) {
action.execute(events, selector);
};
var launchReverse = function(action) {
action.executeReverse(selector);
};
/*
* The two following methods each returns an array containing the
* actions to execute to reach the given anchor (respectively
* forward or backwards).
*
* If the given anchor matches none of the actions, then an empty
* array is returned.
*/
var getActionsToJumpForward = function(anchor) {
var actions = new Array();
for (var i = nextAction; i < json.action.length; i++) {
// '==' and not '===' because we compare indifferently a
// number or a string or anything else
if (json.action[i].id == anchor) {
return actions;
} else {
actions.push(json.action[i]);
}
}
// Here, the anchor has not been found during the action scan
return null;
};
var getActionsToJumpBackwards = function(anchor) {
var actions = new Array();
for (var i = nextAction - 1; i >= 0; i--) {
// '==' and not '===' because we compare indifferently a
// number or a string or anything else
actions.push(json.action[i]);
if (json.action[i].id == anchor) {
return actions;
}
}
// Here, the anchor has not been found during the action scan
return null;
};
/*
* Updates the position of the presentation depending on the
* given anchor (next action wanted).
*/
var jumpToAnchor = function(anchor) {
if (anchor !== '') {
stopAllActions();
if (anchor > nextAction) {
// forward
var actions = getActionsToJumpForward(anchor);
for (var i = 0; i < actions.length; i++) {
actions[i].executeImmediately(selector);
}
nextAction += actions.length;
} else {
// backwards
var actions = getActionsToJumpBackwards(anchor);
for (var i = 0; i < actions.length; i++) {
actions[i].executeReverse(selector);
}
nextAction -= actions.length;
}
}
};
var resetPresentation = function() {
window.clearTimeout(playTimer);
currentAction = 0;
nextAction = 0;
nbActionsRunning = 0;
/*
* At the beginning, the visible image is the first one of the presentation
*/
$(selector + " .object-list").children().hide();
$(selector + " ." + json.metaData.initialBackgroundId).show();
$(selector + " .mouse-cursor").css({
'top': (json.metaData.initialMouseY * json.metaData.imageHeight) + "px",
'left': (json.metaData.initialMouseX * json.metaData.imageWidth) + "px"
});
$(selector + " .mouse-cursor").show();
}
var startPresentationMaybe = function() {
if (autoStart) {
playTimer = setTimeout(function () {
events.onNext.publish();
}, autoStart);
}
}
/* Public API */
this.loadUrl = function(url) {
var dataJson;
$.ajax({
'async': false,
'global': false,
'url': url,
'dataType': "json",
'success': function(data) {
dataJson = data;
}
});
load(dataJson);
};
this.load = function(dataJson) {
/* Transforms data JSON to executable functions for actions */
var execModel = dahuapp.createScreencastExecutableModel();
execModel.loadJson(dataJson);
json = execModel.getJson();
};
this.start = function() {
/*
* Subscription of methods to their events.
*/
events.onNext.subscribe(onNextEventHandler);
events.onPrevious.subscribe(onPreviousEventHandler);
events.onActionOver.subscribe(onActionOverEventHandler);
events.onActionStart.subscribe(onActionStartEventHandler);
resetPresentation();
/*
* If an anchor has been specified, we place the presentation
* in the right position.
*/
jumpToAnchor(window.location.hash.substring(1));
/*
* If the anchor changes during the presentation, then the
* presentation is updated
*/
if ("onhashchange" in window) {
// event supported
window.onhashchange = function () {
jumpToAnchor(window.location.hash.substring(1));
};
} else {
// event not supported : periodical check
window.setInterval(function () {
if (window.location.hash.substring(1) !== previousAnchor) {
previousAnchor = window.location.hash.substring(1);
jumpToAnchor(window.location.hash.substring(1));
}
}, 100);
}
/*
* A click on the "next" button publishes a nextSlide event
*/
$(selector + " .next").click(function() {
events.onNext.publish();
});
/*
* A click on the "previous" button publishes a previousSlide event
*/
$(selector + " .previous").click(function() {
events.onPrevious.publish();
});
/*
* Everything is ready, show the presentation
* (hidden with style="display: none" from HTML).
*/
$("#loading").hide();
$(selector + " .object-list").show();
startPresentationMaybe();
};
};
self.createDahuViewer = function(selector, getParams) {
return new DahuViewerModel(selector, getParams);
};
return self;
})();
dahuapp.viewer = viewer;
})(dahuapp || {}, jQuery);
TP/TP01/P01/img/04821769-3cf8-3d93-1512-390866bc0347.png

362 KiB

TP/TP01/P01/img/38164498-3401-469c-2d51-be0716f10da6.png

386 KiB

TP/TP01/P01/img/474855e6-20f7-77f4-1868-0dba1ebf98f3.png

362 KiB

TP/TP01/P01/img/4e3c77eb-c2c2-46ed-31d5-e4f233330135.png

679 KiB

TP/TP01/P01/img/78f85c35-2c9b-3a8b-24e8-e6fce4becebd.png

505 KiB

TP/TP01/P01/img/7beb5165-3202-df48-c03b-507674983fce.png

371 KiB

TP/TP01/P01/img/a30bf35e-dffb-6d60-d1dd-32bf5a9e9be2.png

383 KiB

TP/TP01/P01/img/bdfa5054-0bc1-d7be-5906-15afa7ed845a.png

366 KiB

TP/TP01/P01/img/cc0bda09-26de-1127-e7fb-f8c52fb215a7.png

366 KiB

TP/TP01/P01/img/cursor-pause.png

691 B

TP/TP01/P01/img/cursor.png

872 B

TP/TP01/P01/img/d32cc79e-d5bc-5af1-2e81-c555a9ac549e.png

681 KiB

TP/TP01/P01/img/e3ab3ff3-9c0e-b7c9-6ebe-9b724e0b4020.png

512 KiB

TP/TP01/P01/img/f94c5951-79d1-3d55-ce8b-e7de32fab48d.png

382 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<title>Dahu Presentation
</title>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.9.1.min.js" type="text/javascript">
</script>
<script src="parse-search.js" type="text/javascript">
</script>
<link rel="stylesheet" href="dahuapp.viewer.css"><style>.s0-o2{background-color: #FFFFDD;width: 240px}
.s1-o2{background-color: #FFFFDD;width: 240px}
.s2-o2{background-color: #FFFFDD;width: 240px}
.s3-o2{background-color: #FFFFDD;width: 240px}
.s4-o2{background-color: #FFFFDD;width: 240px}
.s5-o2{background-color: #FFFFDD;width: 240px}
.s6-o2{background-color: #FFFFDD;width: 240px}
.s7-o2{background-color: #FFFFDD;width: 240px}
.s8-o2{background-color: #FFFFDD;width: 240px}
.s9-o2{background-color: #FFFFDD;width: 240px}
.s10-o2{background-color: #FFFFDD;width: 240px}
.s11-o2{background-color: #FFFFDD;width: 240px}
</style>
</head>
<body>
<div id="my-dahu-presentation">
<div id="loading">Loading presentation...
</div>
<div class="object-list" style="display: none">
<img src="img/78f85c35-2c9b-3a8b-24e8-e6fce4becebd.png" alt="img/78f85c35-2c9b-3a8b-24e8-e6fce4becebd.png" class="background 78f85c35-2c9b-3a8b-24e8-e6fce4becebd0">
<div class="tooltip s0-o2">Démarrer l'application MatLab avec la commande usuelle. Vérifier qu'il s'agit d'une version supérieure à 2012a.
</div>
<img src="img/e3ab3ff3-9c0e-b7c9-6ebe-9b724e0b4020.png" alt="img/e3ab3ff3-9c0e-b7c9-6ebe-9b724e0b4020.png" class="background e3ab3ff3-9c0e-b7c9-6ebe-9b724e0b40200">
<div class="tooltip s1-o2">Créer un modèle Simulink depuis le menu New et l'entrée Simulink Model.
</div>
<img src="img/4e3c77eb-c2c2-46ed-31d5-e4f233330135.png" alt="img/4e3c77eb-c2c2-46ed-31d5-e4f233330135.png" class="background 4e3c77eb-c2c2-46ed-31d5-e4f2333301350">
<div class="tooltip s2-o2">Voici un modèle Simulink vide.
</div>
<img src="img/d32cc79e-d5bc-5af1-2e81-c555a9ac549e.png" alt="img/d32cc79e-d5bc-5af1-2e81-c555a9ac549e.png" class="background d32cc79e-d5bc-5af1-2e81-c555a9ac549e0">
<div class="tooltip s3-o2">Ouvrir la boite à outils Simulink.
</div>
<img src="img/f94c5951-79d1-3d55-ce8b-e7de32fab48d.png" alt="img/f94c5951-79d1-3d55-ce8b-e7de32fab48d.png" class="background f94c5951-79d1-3d55-ce8b-e7de32fab48d0">
<div class="tooltip s4-o2">Ouvrir l'onglet Source.
</div>
<img src="img/38164498-3401-469c-2d51-be0716f10da6.png" alt="img/38164498-3401-469c-2d51-be0716f10da6.png" class="background 38164498-3401-469c-2d51-be0716f10da60">
<div class="tooltip s5-o2">Sélectionner le bloc Générateur de Sinusoïde.
</div>
<img src="img/a30bf35e-dffb-6d60-d1dd-32bf5a9e9be2.png" alt="img/a30bf35e-dffb-6d60-d1dd-32bf5a9e9be2.png" class="background a30bf35e-dffb-6d60-d1dd-32bf5a9e9be20">
<div class="tooltip s6-o2">Déposer un bloc Générateur de Sinusoïde dans votre modèle.
</div>
<img src="img/cc0bda09-26de-1127-e7fb-f8c52fb215a7.png" alt="img/cc0bda09-26de-1127-e7fb-f8c52fb215a7.png" class="background cc0bda09-26de-1127-e7fb-f8c52fb215a70">
<div class="tooltip s7-o2">Ouvrir l'onglet Sink (puit de données).
</div>
<img src="img/bdfa5054-0bc1-d7be-5906-15afa7ed845a.png" alt="img/bdfa5054-0bc1-d7be-5906-15afa7ed845a.png" class="background bdfa5054-0bc1-d7be-5906-15afa7ed845a0">
<div class="tooltip s8-o2">Sélectionner le bloc Oscilloscope.
</div>
<img src="img/474855e6-20f7-77f4-1868-0dba1ebf98f3.png" alt="img/474855e6-20f7-77f4-1868-0dba1ebf98f3.png" class="background 474855e6-20f7-77f4-1868-0dba1ebf98f30">
<div class="tooltip s9-o2">Déposer un bloc Oscilloscope dans votre modèle.
</div>
<img src="img/04821769-3cf8-3d93-1512-390866bc0347.png" alt="img/04821769-3cf8-3d93-1512-390866bc0347.png" class="background 04821769-3cf8-3d93-1512-390866bc03470">
<div class="tooltip s10-o2">Connecter l'entrée du bloc Oscilloscope avec la sortie du bloc Générateur de Sinusoïde.
</div>
<img src="img/7beb5165-3202-df48-c03b-507674983fce.png" alt="img/7beb5165-3202-df48-c03b-507674983fce.png" class="background 7beb5165-3202-df48-c03b-507674983fce0">
<div class="tooltip s11-o2">Sauvegarder votre modèle.
</div>
<div class="mouse-cursor">
<img src="img/cursor.png" alt="img/cursor.png" class="mouse-cursor-normal">
<img src="img/cursor-pause.png" alt="img/cursor-pause.png" style="display: none" class="mouse-cursor-pause">
</div>
</div>
<div class="control" style="top: 616px;">
<button class="previous">Previous
</button>
<button class="next">Next
</button>
</div>
</div>
<script src="dahuapp.js" type="text/javascript">
</script>
<script src="dahuapp.viewer.js" type="text/javascript">
</script>
<script type="text/javascript">(function($) {
var myPresentation = dahuapp.viewer.createDahuViewer("#my-dahu-presentation", window.getParams);
myPresentation.load({
"metaData": {
"imageWidth": 800,
"imageHeight": 600,
"initialBackgroundId": "78f85c35-2c9b-3a8b-24e8-e6fce4becebd0",
"initialMouseX": 0.33541666666666664,
"initialMouseY": 0.4444444444444444
},
"action": [
{
"id": "25",
"type": "appear",
"target": "s0-o2",
"trigger": "afterPrevious",
"abs": 0.305,
"ord": 0.1625,
"duration": 400
},
{
"id": "3",
"type": "move",
"target": "mouse-cursor",
"trigger": "onClick",
"finalAbs": 0.06666666666666667,
"finalOrd": 0.4766666666666667,
"speed": 0.8
},
{
"id": "4",
"type": "appear",
"target": "e3ab3ff3-9c0e-b7c9-6ebe-9b724e0b40200",
"trigger": "afterPrevious",
"abs": 0,
"ord": 0,
"duration": 0
},
{
"id": "26",
"type": "appear",
"target": "s1-o2",
"trigger": "afterPrevious",
"abs": 0.17666666666666667,
"ord": 0.1525,
"duration": 400
},
{
"id": "5",
"type": "move",
"target": "mouse-cursor",
"trigger": "onClick",
"finalAbs": 0.23333333333333334,
"finalOrd": 0.29444444444444445,
"speed": 0.8
},
{
"id": "6",
"type": "appear",
"target": "4e3c77eb-c2c2-46ed-31d5-e4f2333301350",
"trigger": "afterPrevious",
"abs": 0,
"ord": 0,
"duration": 0
},
{
"id": "27",
"type": "appear",
"target": "s2-o2",
"trigger": "afterPrevious",
"abs": 0.25,
"ord": 0.1575,
"duration": 400
},
{
"id": "7",
"type": "move",
"target": "mouse-cursor",
"trigger": "onClick",
"finalAbs": 0.175,
"finalOrd": 0.09666666666666666,
"speed": 0.8
},
{
"id": "8",
"type": "appear",
"target": "d32cc79e-d5bc-5af1-2e81-c555a9ac549e0",
"trigger": "afterPrevious",
"abs": 0,
"ord": 0,
"duration": 0
},
{
"id": "28",
"type": "appear",
"target": "s3-o2",
"trigger": "afterPrevious",
"abs": 0.2,
"ord": 0.0875,
"duration": 400
},
{
"id": "9",
"type": "move",
"target": "mouse-cursor",
"trigger": "onClick",
"finalAbs": 0.8951388888888889,
"finalOrd": 0.4888888888888889,
"speed": 0.8
},
{
"id": "10",
"type": "appear",
"target": "f94c5951-79d1-3d55-ce8b-e7de32fab48d0",
"trigger": "afterPrevious",
"abs": 0,
"ord": 0,
"duration": 0
},
{
"id": "29",
"type": "appear",
"target": "s4-o2",
"trigger": "afterPrevious",
"abs": 0.42,
"ord": 0.26375,
"duration": 400
},
{
"id": "11",
"type": "move",
"target": "mouse-cursor",
"trigger": "onClick",
"finalAbs": 0.7805555555555556,
"finalOrd": 0.6944444444444444,
"speed": 0.8
},
{
"id": "12",
"type": "appear",
"target": "38164498-3401-469c-2d51-be0716f10da60",
"trigger": "afterPrevious",
"abs": 0,
"ord": 0,
"duration": 0
},
{
"id": "30",
"type": "appear",
"target": "s5-o2",
"trigger": "afterPrevious",
"abs": 0.34833333333333333,
"ord": 0.32125,
"duration": 400
},
{
"id": "13",
"type": "move",
"target": "mouse-cursor",
"trigger": "onClick",
"finalAbs": 0.19027777777777777,
"finalOrd": 0.26,
"speed": 0.8
},
{
"id": "14",
"type": "appear",
"target": "a30bf35e-dffb-6d60-d1dd-32bf5a9e9be20",
"trigger": "afterPrevious",
"abs": 0,
"ord": 0,
"duration": 0
},
{
"id": "31",
"type": "appear",
"target": "s6-o2",
"trigger": "afterPrevious",
"abs": 0.165,
"ord": 0.1475,
"duration": 400
},
{
"id": "15",
"type": "move",
"target": "mouse-cursor",
"trigger": "onClick",
"finalAbs": 0.6513888888888889,
"finalOrd": 0.4033333333333333,
"speed": 0.8
},
{
"id": "16",
"type": "appear",
"target": "cc0bda09-26de-1127-e7fb-f8c52fb215a70",
"trigger": "afterPrevious",
"abs": 0,
"ord": 0,
"duration": 0
},
{
"id": "33",
"type": "appear",
"target": "s7-o2",
"trigger": "afterPrevious",
"abs": 0.38666666666666666,
"ord": 0.19625,
"duration": 400
},
{
"id": "17",
"type": "move",
"target": "mouse-cursor",
"trigger": "onClick",
"finalAbs": 0.9,
"finalOrd": 0.21666666666666667,
"speed": 0.8
},
{
"id": "18",
"type": "appear",
"target": "bdfa5054-0bc1-d7be-5906-15afa7ed845a0",
"trigger": "afterPrevious",
"abs": 0,
"ord": 0,
"duration": 0
},
{
"id": "32",
"type": "appear",
"target": "s8-o2",
"trigger": "afterPrevious",
"abs": 0.3516666666666667,
"ord": 0.2725,
"duration": 400
},
{
"id": "19",
"type": "move",
"target": "mouse-cursor",
"trigger": "onClick",
"finalAbs": 0.31666666666666665,
"finalOrd": 0.2611111111111111,
"speed": 0.8
},
{
"id": "20",
"type": "appear",
"target": "474855e6-20f7-77f4-1868-0dba1ebf98f30",
"trigger": "afterPrevious",
"abs": 0,
"ord": 0,
"duration": 0
},
{
"id": "34",
"type": "appear",
"target": "s9-o2",
"trigger": "afterPrevious",
"abs": 0.10833333333333334,
"ord": 0.15,
"duration": 400
},
{
"id": "21",
"type": "move",
"target": "mouse-cursor",
"trigger": "onClick",
"finalAbs": 0.20347222222222222,
"finalOrd": 0.26666666666666666,
"speed": 0.8
},
{
"id": "22",
"type": "appear",
"target": "04821769-3cf8-3d93-1512-390866bc03470",
"trigger": "afterPrevious",
"abs": 0,
"ord": 0,
"duration": 0
},
{
"id": "35",
"type": "appear",
"target": "s10-o2",
"trigger": "afterPrevious",
"abs": 0.17,
"ord": 0.14625,
"duration": 400
},
{
"id": "23",
"type": "move",
"target": "mouse-cursor",
"trigger": "onClick",
"finalAbs": 0.03819444444444445,
"finalOrd": 0.16666666666666666,
"speed": 0.8
},
{
"id": "24",
"type": "appear",
"target": "7beb5165-3202-df48-c03b-507674983fce0",
"trigger": "afterPrevious",
"abs": 0,
"ord": 0,
"duration": 0
},
{
"id": "36",
"type": "appear",
"target": "s11-o2",
"trigger": "afterPrevious",
"abs": 0.195,
"ord": 0.145,
"duration": 400
}
]
});
myPresentation.start();
})(jQuery);
</script>
</body>
</html>
\ No newline at end of file
// Adapted from http://stackoverflow.com/questions/3234125/creating-array-from-window-location-hash
(function () {
var search = window.location.search.slice(1);
var array = search.split("&");
var values, form_data = {};
for (var i = 0; i < array.length; i += 1) {
values = array[i].split("=");
form_data[values[0]] = unescape(values[1]);
}
window.getParams = form_data;
}())
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment