Commit 4d098c6b authored by Thomas Lechauve's avatar Thomas Lechauve

Fix last commit

Forgot to add modified files
parent 94b89ec8
...@@ -4,15 +4,11 @@ app = Flask(__name__) ...@@ -4,15 +4,11 @@ app = Flask(__name__)
@app.route('/') @app.route('/')
def index(): def index():
return "index" return render_template("slapos.html")
@app.route('/test-mobile')
def test():
return render_template('test-mobile.html')
@app.route('/request', methods=["POST", "GET"]) @app.route('/request', methods=["POST", "GET"])
def request(): def request():
response = make_response("HELLO", 409) response = make_response("HELLO", 408)
response.headers['Access-Control-Allow-Origin'] = '*' response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Access-Control-Allow-Methods'] = '*' response.headers['Access-Control-Allow-Methods'] = '*'
return response return response
......
...@@ -3,20 +3,34 @@ ...@@ -3,20 +3,34 @@
<head> <head>
<link rel="stylesheet" href="static/css/qunit.css" type="text/css" media="screen" /> <link rel="stylesheet" href="static/css/qunit.css" type="text/css" media="screen" />
<script type="text/javascript" src="static/js/jquery-1.7.2.js"></script> <script type="text/javascript" src="static/js/jquery-1.7.2.js"></script>
<script type="text/javascript" src="static/js/modernizr-2.5.3.js"></script>
<script type="text/javascript" src="static/js/qunit.js"></script> <script type="text/javascript" src="static/js/qunit.js"></script>
<script type="text/javascript" src="static/js/sinon-1.3.2.js"></script> <script type="text/javascript" src="static/js/sinon-1.3.2.js"></script>
<script type="text/javascript" src="static/js/sinon-qunit-1.0.0.js"></script> <script type="text/javascript" src="static/js/sinon-qunit-1.0.0.js"></script>
<script type="text/javascript" src="static/js/sinon-server-1.3.2.js"></script>
<script type="text/javascript" src="static/js/slapOs.js"></script> <script type="text/javascript" src="static/js/slapOs.js"></script>
<script type="text/javascript" src="static/js/test.js"></script> <script type="text/javascript" src="static/js/test.js"></script>
<title>Test Slapos</title> <title>Test Slapos</title>
</head> </head>
<body> <body>
<div class="container"> <section>
<h1 id="qunit-header">QUnit SlapOs tests</h1> <article>
<h2 id="qunit-banner"></h2> <center>
<div id="qunit-testrunner-toolbar"></div> <form id="connect">
<h2 id="qunit-userAgent"></h2> <label for="login">Test on a real server :</label>
<ol id="qunit-tests"></ol> <input type="text" id="login" name="login" placeholder="Server url" spellcheck="false" required autofocus="autofocus"/>
<div id="qunit-fixture">test markup, will be hidden</div> <input type="submit" id="submit" value="Go!"/>
</div> </form>
</center>
<div class="container">
<h1 id="qunit-header">QUnit SlapOs tests</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup, will be hidden</div>
</div>
</article>
</section>
</body> </body>
\ No newline at end of file
...@@ -7420,6 +7420,7 @@ jQuery.extend({ ...@@ -7420,6 +7420,7 @@ jQuery.extend({
if ( state === 2 ) { if ( state === 2 ) {
if ( !responseHeaders ) { if ( !responseHeaders ) {
responseHeaders = {}; responseHeaders = {};
console.log(responseHeadersString);
while( ( match = rheaders.exec( responseHeadersString ) ) ) { while( ( match = rheaders.exec( responseHeadersString ) ) ) {
responseHeaders[ match[1].toLowerCase() ] = match[ 2 ]; responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
} }
...@@ -7483,7 +7484,6 @@ jQuery.extend({ ...@@ -7483,7 +7484,6 @@ jQuery.extend({
response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined, response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
lastModified, lastModified,
etag; etag;
// If successful, handle type chaining // If successful, handle type chaining
if ( status >= 200 && status < 300 || status === 304 ) { if ( status >= 200 && status < 300 || status === 304 ) {
......
(function(window, $) { ;(function($, window, document, undefined) {
var SlapOs = function(elem, options){ var SlapOs = function(elem, options){
this.elem = elem; this.elem = elem;
this.$elem = $(elem); this.$elem = $(elem);
...@@ -7,25 +7,52 @@ ...@@ -7,25 +7,52 @@
}; };
SlapOs.prototype = { SlapOs.prototype = {
host: '', defaults: {
host: ''
},
init: function(){ init: function(){
this.config = $.extends({}, this.defaults, this.options, this.metadata); this.config = $.extend({}, this.defaults, this.options, this.metadata);
this.store = Modernizr.localstorage ? this.lStore : this.cStore;
this.store('host', this.config.host);
return this; return this;
}, },
/* Local storage method */
lStore: function(name, value){
if(Modernizr.localstorage)
return value == undefined ? window.localStorage[name] : window.localStorage[name] = value;
return false;
},
/* Cookie storage method */
cStore: function(name, value){
if(value != undefined){
document.cookie = name+"="+value+";domain="+window.location.hostname+";path="+window.location.pathname;
}else{
var i,x,y, cookies = document.cookie.split(';');
for(i=0; i<cookies.length; i++){
x = cookies[i].substr(0, cookies[i].indexOf('='));
y = cookies[i].substr(cookies[i].indexOf('=')+1);
x=x.replace(/^\s+|\s+$/g,"");
if(x == name) return unescape(y);
}
}
},
request: function(type, url, callback, data){ request: function(type, url, callback, data){
data = data || ''; data = data || '';
return $.ajax({ $.ajax({
url: this.host+url, url: this.config.host+url,
dataType: 'json', dataType: 'json',
data: data, data: data,
context: this.$elem,
type: type, type: type,
statusCode: { }).done(callback).fail(this.failCallback);
409: function(){console.log('Status Code : 409')}, },
},
success: function(data){ callback(data); } failCallback: function(jqXHR, textStatus){
}); //console.log(jqXHR);
}, },
newInstance: function(data, callback){ newInstance: function(data, callback){
...@@ -84,4 +111,5 @@ ...@@ -84,4 +111,5 @@
}; };
window.SlapOs = SlapOs; window.SlapOs = SlapOs;
})(window, jQuery);
\ No newline at end of file })(jQuery, window , document);
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment