Store speed dial as JSON instead of actual HTML source

This will make it possible to change the layout of the page
without losing shortcuts.
This commit is contained in:
Jean-François Guchens 2009-05-13 23:56:55 +02:00 committed by Christian Dywan
parent 0e9803a31c
commit 760553f374
7 changed files with 270 additions and 172 deletions

View file

@ -1,3 +1,5 @@
//MooTools, <http://mootools.net>, My Object Oriented (JavaScript) Tools. Copyright (c) 2006-2009 Valerio Proietti, <http://mad4milk.net>, MIT Style License.
var MooTools={version:"1.2.2",build:"f0491d62fbb7e906789aa3733d6a67d43e5af7c9"};var Native=function(k){k=k||{};var a=k.name;var i=k.legacy;var b=k.protect; var MooTools={version:"1.2.2",build:"f0491d62fbb7e906789aa3733d6a67d43e5af7c9"};var Native=function(k){k=k||{};var a=k.name;var i=k.legacy;var b=k.protect;
var c=k.implement;var h=k.generics;var f=k.initialize;var g=k.afterImplement||function(){};var d=f||i;h=h!==false;d.constructor=Native;d.$family={name:"native"}; var c=k.implement;var h=k.generics;var f=k.initialize;var g=k.afterImplement||function(){};var d=f||i;h=h!==false;d.constructor=Native;d.$family={name:"native"};
if(i&&f){d.prototype=i.prototype;}d.prototype.constructor=d;if(a){var e=a.toLowerCase();d.prototype.$family={name:e};Native.typize(d,e);}var j=function(n,l,o,m){if(!b||m||!n.prototype[l]){n.prototype[l]=o; if(i&&f){d.prototype=i.prototype;}d.prototype.constructor=d;if(a){var e=a.toLowerCase();d.prototype.$family={name:e};Native.typize(d,e);}var j=function(n,l,o,m){if(!b||m||!n.prototype[l]){n.prototype[l]=o;
@ -86,7 +88,27 @@ break;case"mouseout":l=a.relatedTarget||a.toElement;}if(!(function(){while(l&&l.
}}}}return $extend(this,{event:a,type:j,page:i,client:c,rightClick:e,wheel:h,relatedTarget:l,target:g,code:b,key:m,shift:a.shiftKey,control:a.ctrlKey,alt:a.altKey,meta:a.metaKey}); }}}}return $extend(this,{event:a,type:j,page:i,client:c,rightClick:e,wheel:h,relatedTarget:l,target:g,code:b,key:m,shift:a.shiftKey,control:a.ctrlKey,alt:a.altKey,meta:a.metaKey});
}});Event.Keys=new Hash({enter:13,up:38,down:40,left:37,right:39,esc:27,space:32,backspace:8,tab:9,"delete":46});Event.implement({stop:function(){return this.stopPropagation().preventDefault(); }});Event.Keys=new Hash({enter:13,up:38,down:40,left:37,right:39,esc:27,space:32,backspace:8,tab:9,"delete":46});Event.implement({stop:function(){return this.stopPropagation().preventDefault();
},stopPropagation:function(){if(this.event.stopPropagation){this.event.stopPropagation();}else{this.event.cancelBubble=true;}return this;},preventDefault:function(){if(this.event.preventDefault){this.event.preventDefault(); },stopPropagation:function(){if(this.event.stopPropagation){this.event.stopPropagation();}else{this.event.cancelBubble=true;}return this;},preventDefault:function(){if(this.event.preventDefault){this.event.preventDefault();
}else{this.event.returnValue=false;}return this;}});var Element=new Native({name:"Element",legacy:window.Element,initialize:function(a,b){var c=Element.Constructors.get(a); }else{this.event.returnValue=false;}return this;}});function Class(b){if(b instanceof Function){b={initialize:b};}var a=function(){Object.reset(this);if(a._prototyping){return this;
}this._current=$empty;var c=(this.initialize)?this.initialize.apply(this,arguments):this;delete this._current;delete this.caller;return c;}.extend(this);
a.implement(b);a.constructor=Class;a.prototype.constructor=a;return a;}Function.prototype.protect=function(){this._protected=true;return this;};Object.reset=function(a,c){if(c==null){for(var e in a){Object.reset(a,e);
}return a;}delete a[c];switch($type(a[c])){case"object":var d=function(){};d.prototype=a[c];var b=new d;a[c]=Object.reset(b);break;case"array":a[c]=$unlink(a[c]);
break;}return a;};new Native({name:"Class",initialize:Class}).extend({instantiate:function(b){b._prototyping=true;var a=new b;delete b._prototyping;return a;
},wrap:function(a,b,c){if(c._origin){c=c._origin;}return function(){if(c._protected&&this._current==null){throw new Error('The method "'+b+'" cannot be called.');
}var e=this.caller,f=this._current;this.caller=f;this._current=arguments.callee;var d=c.apply(this,arguments);this._current=f;this.caller=e;return d;}.extend({_owner:a,_origin:c,_name:b});
}});Class.implement({implement:function(a,d){if($type(a)=="object"){for(var e in a){this.implement(e,a[e]);}return this;}var f=Class.Mutators[a];if(f){d=f.call(this,d);
if(d==null){return this;}}var c=this.prototype;switch($type(d)){case"function":if(d._hidden){return this;}c[a]=Class.wrap(this,a,d);break;case"object":var b=c[a];
if($type(b)=="object"){$mixin(b,d);}else{c[a]=$unlink(d);}break;case"array":c[a]=$unlink(d);break;default:c[a]=d;}return this;}});Class.Mutators={Extends:function(a){this.parent=a;
this.prototype=Class.instantiate(a);this.implement("parent",function(){var b=this.caller._name,c=this.caller._owner.parent.prototype[b];if(!c){throw new Error('The method "'+b+'" has no parent.');
}return c.apply(this,arguments);}.protect());},Implements:function(a){$splat(a).each(function(b){if(b instanceof Function){b=Class.instantiate(b);}this.implement(b);
},this);}};var Chain=new Class({$chain:[],chain:function(){this.$chain.extend(Array.flatten(arguments));return this;},callChain:function(){return(this.$chain.length)?this.$chain.shift().apply(this,arguments):false;
},clearChain:function(){this.$chain.empty();return this;}});var Events=new Class({$events:{},addEvent:function(c,b,a){c=Events.removeOn(c);if(b!=$empty){this.$events[c]=this.$events[c]||[];
this.$events[c].include(b);if(a){b.internal=true;}}return this;},addEvents:function(a){for(var b in a){this.addEvent(b,a[b]);}return this;},fireEvent:function(c,b,a){c=Events.removeOn(c);
if(!this.$events||!this.$events[c]){return this;}this.$events[c].each(function(d){d.create({bind:this,delay:a,"arguments":b})();},this);return this;},removeEvent:function(b,a){b=Events.removeOn(b);
if(!this.$events[b]){return this;}if(!a.internal){this.$events[b].erase(a);}return this;},removeEvents:function(c){var d;if($type(c)=="object"){for(d in c){this.removeEvent(d,c[d]);
}return this;}if(c){c=Events.removeOn(c);}for(d in this.$events){if(c&&c!=d){continue;}var b=this.$events[d];for(var a=b.length;a--;a){this.removeEvent(d,b[a]);
}}return this;}});Events.removeOn=function(a){return a.replace(/^on([A-Z])/,function(b,c){return c.toLowerCase();});};var Options=new Class({setOptions:function(){this.options=$merge.run([this.options].extend(arguments));
if(!this.addEvent){return this;}for(var a in this.options){if($type(this.options[a])!="function"||!(/^on[A-Z]/).test(a)){continue;}this.addEvent(a,this.options[a]);
delete this.options[a];}return this;}});var Element=new Native({name:"Element",legacy:window.Element,initialize:function(a,b){var c=Element.Constructors.get(a);
if(c){return c(b);}if(typeof a=="string"){return document.newElement(a,b);}return $(a).set(b);},afterImplement:function(a,b){Element.Prototype[a]=b;if(Array[a]){return; if(c){return c(b);}if(typeof a=="string"){return document.newElement(a,b);}return $(a).set(b);},afterImplement:function(a,b){Element.Prototype[a]=b;if(Array[a]){return;
}Elements.implement(a,function(){var c=[],g=true;for(var e=0,d=this.length;e<d;e++){var f=this[e][a].apply(this[e],arguments);c.push(f);if(g){g=($type(f)=="element"); }Elements.implement(a,function(){var c=[],g=true;for(var e=0,d=this.length;e<d;e++){var f=this[e][a].apply(this[e],arguments);c.push(f);if(g){g=($type(f)=="element");
}}return(g)?new Elements(c):c;});}});Element.Prototype={$family:{name:"element"}};Element.Constructors=new Hash;var IFrame=new Native({name:"IFrame",generics:false,initialize:function(){var e=Array.link(arguments,{properties:Object.type,iframe:$defined}); }}return(g)?new Elements(c):c;});}});Element.Prototype={$family:{name:"element"}};Element.Constructors=new Hash;var IFrame=new Native({name:"IFrame",generics:false,initialize:function(){var e=Array.link(arguments,{properties:Object.type,iframe:$defined});
@ -179,26 +201,7 @@ b.each(function(h){d+=this.getStyle("border-"+h+"-width").toInt()+this.getStyle(
}return this;},getStyles:function(){var a={};Array.each(arguments,function(b){a[b]=this.getStyle(b);},this);return a;}});Element.Styles=new Hash({left:"@px",top:"@px",bottom:"@px",right:"@px",width:"@px",height:"@px",maxWidth:"@px",maxHeight:"@px",minWidth:"@px",minHeight:"@px",backgroundColor:"rgb(@, @, @)",backgroundPosition:"@px @px",color:"rgb(@, @, @)",fontSize:"@px",letterSpacing:"@px",lineHeight:"@px",clip:"rect(@px @px @px @px)",margin:"@px @px @px @px",padding:"@px @px @px @px",border:"@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)",borderWidth:"@px @px @px @px",borderStyle:"@ @ @ @",borderColor:"rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)",zIndex:"@",zoom:"@",fontWeight:"@",textIndent:"@px",opacity:"@"}); }return this;},getStyles:function(){var a={};Array.each(arguments,function(b){a[b]=this.getStyle(b);},this);return a;}});Element.Styles=new Hash({left:"@px",top:"@px",bottom:"@px",right:"@px",width:"@px",height:"@px",maxWidth:"@px",maxHeight:"@px",minWidth:"@px",minHeight:"@px",backgroundColor:"rgb(@, @, @)",backgroundPosition:"@px @px",color:"rgb(@, @, @)",fontSize:"@px",letterSpacing:"@px",lineHeight:"@px",clip:"rect(@px @px @px @px)",margin:"@px @px @px @px",padding:"@px @px @px @px",border:"@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)",borderWidth:"@px @px @px @px",borderStyle:"@ @ @ @",borderColor:"rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)",zIndex:"@",zoom:"@",fontWeight:"@",textIndent:"@px",opacity:"@"});
Element.ShortStyles={margin:{},padding:{},border:{},borderWidth:{},borderStyle:{},borderColor:{}};["Top","Right","Bottom","Left"].each(function(g){var f=Element.ShortStyles; Element.ShortStyles={margin:{},padding:{},border:{},borderWidth:{},borderStyle:{},borderColor:{}};["Top","Right","Bottom","Left"].each(function(g){var f=Element.ShortStyles;
var b=Element.Styles;["margin","padding"].each(function(h){var i=h+g;f[h][i]=b[i]="@px";});var e="border"+g;f.border[e]=b[e]="@px @ rgb(@, @, @)";var d=e+"Width",a=e+"Style",c=e+"Color"; var b=Element.Styles;["margin","padding"].each(function(h){var i=h+g;f[h][i]=b[i]="@px";});var e="border"+g;f.border[e]=b[e]="@px @ rgb(@, @, @)";var d=e+"Width",a=e+"Style",c=e+"Color";
f[e]={};f.borderWidth[d]=f[e][d]=b[d]="@px";f.borderStyle[a]=f[e][a]=b[a]="@";f.borderColor[c]=f[e][c]=b[c]="rgb(@, @, @)";});(function(){Element.implement({scrollTo:function(h,i){if(b(this)){this.getWindow().scrollTo(h,i); f[e]={};f.borderWidth[d]=f[e][d]=b[d]="@px";f.borderStyle[a]=f[e][a]=b[a]="@";f.borderColor[c]=f[e][c]=b[c]="rgb(@, @, @)";});Native.implement([Document,Element],{getElements:function(h,g){h=h.split(",");
}else{this.scrollLeft=h;this.scrollTop=i;}return this;},getSize:function(){if(b(this)){return this.getWindow().getSize();}return{x:this.offsetWidth,y:this.offsetHeight};
},getScrollSize:function(){if(b(this)){return this.getWindow().getScrollSize();}return{x:this.scrollWidth,y:this.scrollHeight};},getScroll:function(){if(b(this)){return this.getWindow().getScroll();
}return{x:this.scrollLeft,y:this.scrollTop};},getScrolls:function(){var i=this,h={x:0,y:0};while(i&&!b(i)){h.x+=i.scrollLeft;h.y+=i.scrollTop;i=i.parentNode;
}return h;},getOffsetParent:function(){var h=this;if(b(h)){return null;}if(!Browser.Engine.trident){return h.offsetParent;}while((h=h.parentNode)&&!b(h)){if(d(h,"position")!="static"){return h;
}}return null;},getOffsets:function(){if(Browser.Engine.trident){var l=this.getBoundingClientRect(),j=this.getDocument().documentElement;var m=d(this,"position")=="fixed";
return{x:l.left+((m)?0:j.scrollLeft)-j.clientLeft,y:l.top+((m)?0:j.scrollTop)-j.clientTop};}var i=this,h={x:0,y:0};if(b(this)){return h;}while(i&&!b(i)){h.x+=i.offsetLeft;
h.y+=i.offsetTop;if(Browser.Engine.gecko){if(!f(i)){h.x+=c(i);h.y+=g(i);}var k=i.parentNode;if(k&&d(k,"overflow")!="visible"){h.x+=c(k);h.y+=g(k);}}else{if(i!=this&&Browser.Engine.webkit){h.x+=c(i);
h.y+=g(i);}}i=i.offsetParent;}if(Browser.Engine.gecko&&!f(this)){h.x-=c(this);h.y-=g(this);}return h;},getPosition:function(k){if(b(this)){return{x:0,y:0};
}var l=this.getOffsets(),i=this.getScrolls();var h={x:l.x-i.x,y:l.y-i.y};var j=(k&&(k=$(k)))?k.getPosition():{x:0,y:0};return{x:h.x-j.x,y:h.y-j.y};},getCoordinates:function(j){if(b(this)){return this.getWindow().getCoordinates();
}var h=this.getPosition(j),i=this.getSize();var k={left:h.x,top:h.y,width:i.x,height:i.y};k.right=k.left+k.width;k.bottom=k.top+k.height;return k;},computePosition:function(h){return{left:h.x-e(this,"margin-left"),top:h.y-e(this,"margin-top")};
},position:function(h){return this.setStyles(this.computePosition(h));}});Native.implement([Document,Window],{getSize:function(){if(Browser.Engine.presto||Browser.Engine.webkit){var i=this.getWindow();
return{x:i.innerWidth,y:i.innerHeight};}var h=a(this);return{x:h.clientWidth,y:h.clientHeight};},getScroll:function(){var i=this.getWindow(),h=a(this);
return{x:i.pageXOffset||h.scrollLeft,y:i.pageYOffset||h.scrollTop};},getScrollSize:function(){var i=a(this),h=this.getSize();return{x:Math.max(i.scrollWidth,h.x),y:Math.max(i.scrollHeight,h.y)};
},getPosition:function(){return{x:0,y:0};},getCoordinates:function(){var h=this.getSize();return{top:0,left:0,bottom:h.y,right:h.x,height:h.y,width:h.x};
}});var d=Element.getComputedStyle;function e(h,i){return d(h,i).toInt()||0;}function f(h){return d(h,"-moz-box-sizing")=="border-box";}function g(h){return e(h,"border-top-width");
}function c(h){return e(h,"border-left-width");}function b(h){return(/^(?:body|html)$/i).test(h.tagName);}function a(h){var i=h.getDocument();return(!i.compatMode||i.compatMode=="CSS1Compat")?i.html:i.body;
}})();Native.implement([Window,Document,Element],{getHeight:function(){return this.getSize().y;},getWidth:function(){return this.getSize().x;},getScrollTop:function(){return this.getScroll().y;
},getScrollLeft:function(){return this.getScroll().x;},getScrollHeight:function(){return this.getScrollSize().y;},getScrollWidth:function(){return this.getScrollSize().x;
},getTop:function(){return this.getPosition().y;},getLeft:function(){return this.getPosition().x;}});Native.implement([Document,Element],{getElements:function(h,g){h=h.split(",");
var c,e={};for(var d=0,b=h.length;d<b;d++){var a=h[d],f=Selectors.Utils.search(this,a,e);if(d!=0&&f.item){f=$A(f);}c=(d==0)?f:(c.item)?$A(c).concat(f):c.concat(f); var c,e={};for(var d=0,b=h.length;d<b;d++){var a=h[d],f=Selectors.Utils.search(this,a,e);if(d!=0&&f.item){f=$A(f);}c=(d==0)?f:(c.item)?$A(c).concat(f):c.concat(f);
}return new Elements(c,{ddup:(h.length>1),cash:!g});}});Element.implement({match:function(b){if(!b||(b==this)){return true;}var d=Selectors.Utils.parseTagAndID(b); }return new Elements(c,{ddup:(h.length>1),cash:!g});}});Element.implement({match:function(b){if(!b||(b==this)){return true;}var d=Selectors.Utils.parseTagAndID(b);
var a=d[0],e=d[1];if(!Selectors.Filters.byID(this,e)||!Selectors.Filters.byTag(this,a)){return false;}var c=Selectors.Utils.parseSelector(b);return(c)?Selectors.Utils.filter(this,c,{}):true; var a=d[0],e=d[1];if(!Selectors.Filters.byID(this,e)||!Selectors.Filters.byTag(this,a)){return false;}var c=Selectors.Utils.parseSelector(b);return(c)?Selectors.Utils.filter(this,c,{}):true;
@ -242,4 +245,69 @@ while((b=b.previousSibling)){if(b.nodeType!=1){continue;}f++;var a=e.positions[$
},encode:function(b){switch($type(b)){case"string":return'"'+b.replace(/[\x00-\x1f\\"]/g,JSON.$replaceChars)+'"';case"array":return"["+String(b.map(JSON.encode).filter($defined))+"]"; },encode:function(b){switch($type(b)){case"string":return'"'+b.replace(/[\x00-\x1f\\"]/g,JSON.$replaceChars)+'"';case"array":return"["+String(b.map(JSON.encode).filter($defined))+"]";
case"object":case"hash":var a=[];Hash.each(b,function(e,d){var c=JSON.encode(e);if(c){a.push(JSON.encode(d)+":"+c);}});return"{"+a+"}";case"number":case"boolean":return String(b); case"object":case"hash":var a=[];Hash.each(b,function(e,d){var c=JSON.encode(e);if(c){a.push(JSON.encode(d)+":"+c);}});return"{"+a+"}";case"number":case"boolean":return String(b);
case false:return"null";}return null;},decode:function(string,secure){if($type(string)!="string"||!string.length){return null;}if(secure&&!(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,""))){return null; case false:return"null";}return null;},decode:function(string,secure){if($type(string)!="string"||!string.length){return null;}if(secure&&!(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,""))){return null;
}return eval("("+string+")");}});Native.implement([Hash,Array,String,Number],{toJSON:function(){return JSON.encode(this);}}); }return eval("("+string+")");}});Native.implement([Hash,Array,String,Number],{toJSON:function(){return JSON.encode(this);}});var Cookie=new Class({Implements:Options,options:{path:false,domain:false,duration:false,secure:false,document:document},initialize:function(b,a){this.key=b;
this.setOptions(a);},write:function(b){b=encodeURIComponent(b);if(this.options.domain){b+="; domain="+this.options.domain;}if(this.options.path){b+="; path="+this.options.path;
}if(this.options.duration){var a=new Date();a.setTime(a.getTime()+this.options.duration*24*60*60*1000);b+="; expires="+a.toGMTString();}if(this.options.secure){b+="; secure";
}this.options.document.cookie=this.key+"="+b;return this;},read:function(){var a=this.options.document.cookie.match("(?:^|;)\\s*"+this.key.escapeRegExp()+"=([^;]*)");
return(a)?decodeURIComponent(a[1]):null;},dispose:function(){new Cookie(this.key,$merge(this.options,{duration:-1})).write("");return this;}});Cookie.write=function(b,c,a){return new Cookie(b,a).write(c);
};Cookie.read=function(a){return new Cookie(a).read();};Cookie.dispose=function(b,a){return new Cookie(b,a).dispose();};var Fx=new Class({Implements:[Chain,Events,Options],options:{fps:50,unit:false,duration:500,link:"ignore"},initialize:function(a){this.subject=this.subject||this;
this.setOptions(a);this.options.duration=Fx.Durations[this.options.duration]||this.options.duration.toInt();var b=this.options.wait;if(b===false){this.options.link="cancel";
}},getTransition:function(){return function(a){return -(Math.cos(Math.PI*a)-1)/2;};},step:function(){var a=$time();if(a<this.time+this.options.duration){var b=this.transition((a-this.time)/this.options.duration);
this.set(this.compute(this.from,this.to,b));}else{this.set(this.compute(this.from,this.to,1));this.complete();}},set:function(a){return a;},compute:function(c,b,a){return Fx.compute(c,b,a);
},check:function(){if(!this.timer){return true;}switch(this.options.link){case"cancel":this.cancel();return true;case"chain":this.chain(this.caller.bind(this,arguments));
return false;}return false;},start:function(b,a){if(!this.check(b,a)){return this;}this.from=b;this.to=a;this.time=0;this.transition=this.getTransition();
this.startTimer();this.onStart();return this;},complete:function(){if(this.stopTimer()){this.onComplete();}return this;},cancel:function(){if(this.stopTimer()){this.onCancel();
}return this;},onStart:function(){this.fireEvent("start",this.subject);},onComplete:function(){this.fireEvent("complete",this.subject);if(!this.callChain()){this.fireEvent("chainComplete",this.subject);
}},onCancel:function(){this.fireEvent("cancel",this.subject).clearChain();},pause:function(){this.stopTimer();return this;},resume:function(){this.startTimer();
return this;},stopTimer:function(){if(!this.timer){return false;}this.time=$time()-this.time;this.timer=$clear(this.timer);return true;},startTimer:function(){if(this.timer){return false;
}this.time=$time()-this.time;this.timer=this.step.periodical(Math.round(1000/this.options.fps),this);return true;}});Fx.compute=function(c,b,a){return(b-c)*a+c;
};Fx.Durations={"short":250,normal:500,"long":1000};Fx.CSS=new Class({Extends:Fx,prepare:function(d,e,b){b=$splat(b);var c=b[1];if(!$chk(c)){b[1]=b[0];
b[0]=d.getStyle(e);}var a=b.map(this.parse);return{from:a[0],to:a[1]};},parse:function(a){a=$lambda(a)();a=(typeof a=="string")?a.split(" "):$splat(a);
return a.map(function(c){c=String(c);var b=false;Fx.CSS.Parsers.each(function(f,e){if(b){return;}var d=f.parse(c);if($chk(d)){b={value:d,parser:f};}});
b=b||{value:c,parser:Fx.CSS.Parsers.String};return b;});},compute:function(d,c,b){var a=[];(Math.min(d.length,c.length)).times(function(e){a.push({value:d[e].parser.compute(d[e].value,c[e].value,b),parser:d[e].parser});
});a.$family={name:"fx:css:value"};return a;},serve:function(c,b){if($type(c)!="fx:css:value"){c=this.parse(c);}var a=[];c.each(function(d){a=a.concat(d.parser.serve(d.value,b));
});return a;},render:function(a,d,c,b){a.setStyle(d,this.serve(c,b));},search:function(a){if(Fx.CSS.Cache[a]){return Fx.CSS.Cache[a];}var b={};Array.each(document.styleSheets,function(e,d){var c=e.href;
if(c&&c.contains("://")&&!c.contains(document.domain)){return;}var f=e.rules||e.cssRules;Array.each(f,function(j,g){if(!j.style){return;}var h=(j.selectorText)?j.selectorText.replace(/^\w+/,function(i){return i.toLowerCase();
}):null;if(!h||!h.test("^"+a+"$")){return;}Element.Styles.each(function(k,i){if(!j.style[i]||Element.ShortStyles[i]){return;}k=String(j.style[i]);b[i]=(k.test(/^rgb/))?k.rgbToHex():k;
});});});return Fx.CSS.Cache[a]=b;}});Fx.CSS.Cache={};Fx.CSS.Parsers=new Hash({Color:{parse:function(a){if(a.match(/^#[0-9a-f]{3,6}$/i)){return a.hexToRgb(true);
}return((a=a.match(/(\d+),\s*(\d+),\s*(\d+)/)))?[a[1],a[2],a[3]]:false;},compute:function(c,b,a){return c.map(function(e,d){return Math.round(Fx.compute(c[d],b[d],a));
});},serve:function(a){return a.map(Number);}},Number:{parse:parseFloat,compute:Fx.compute,serve:function(b,a){return(a)?b+a:b;}},String:{parse:$lambda(false),compute:$arguments(1),serve:$arguments(0)}});
Fx.Tween=new Class({Extends:Fx.CSS,initialize:function(b,a){this.element=this.subject=$(b);this.parent(a);},set:function(b,a){if(arguments.length==1){a=b;
b=this.property||this.options.property;}this.render(this.element,b,a,this.options.unit);return this;},start:function(c,e,d){if(!this.check(c,e,d)){return this;
}var b=Array.flatten(arguments);this.property=this.options.property||b.shift();var a=this.prepare(this.element,this.property,b);return this.parent(a.from,a.to);
}});Element.Properties.tween={set:function(a){var b=this.retrieve("tween");if(b){b.cancel();}return this.eliminate("tween").store("tween:options",$extend({link:"cancel"},a));
},get:function(a){if(a||!this.retrieve("tween")){if(a||!this.retrieve("tween:options")){this.set("tween",a);}this.store("tween",new Fx.Tween(this,this.retrieve("tween:options")));
}return this.retrieve("tween");}};Element.implement({tween:function(a,c,b){this.get("tween").start(arguments);return this;},fade:function(c){var e=this.get("tween"),d="opacity",a;
c=$pick(c,"toggle");switch(c){case"in":e.start(d,1);break;case"out":e.start(d,0);break;case"show":e.set(d,1);break;case"hide":e.set(d,0);break;case"toggle":var b=this.retrieve("fade:flag",this.get("opacity")==1);
e.start(d,(b)?0:1);this.store("fade:flag",!b);a=true;break;default:e.start(d,arguments);}if(!a){this.eliminate("fade:flag");}return this;},highlight:function(c,a){if(!a){a=this.retrieve("highlight:original",this.getStyle("background-color"));
a=(a=="transparent")?"#fff":a;}var b=this.get("tween");b.start("background-color",c||"#ffff88",a).chain(function(){this.setStyle("background-color",this.retrieve("highlight:original"));
b.callChain();}.bind(this));return this;}});Fx.Morph=new Class({Extends:Fx.CSS,initialize:function(b,a){this.element=this.subject=$(b);this.parent(a);},set:function(a){if(typeof a=="string"){a=this.search(a);
}for(var b in a){this.render(this.element,b,a[b],this.options.unit);}return this;},compute:function(e,d,c){var a={};for(var b in e){a[b]=this.parent(e[b],d[b],c);
}return a;},start:function(b){if(!this.check(b)){return this;}if(typeof b=="string"){b=this.search(b);}var e={},d={};for(var c in b){var a=this.prepare(this.element,c,b[c]);
e[c]=a.from;d[c]=a.to;}return this.parent(e,d);}});Element.Properties.morph={set:function(a){var b=this.retrieve("morph");if(b){b.cancel();}return this.eliminate("morph").store("morph:options",$extend({link:"cancel"},a));
},get:function(a){if(a||!this.retrieve("morph")){if(a||!this.retrieve("morph:options")){this.set("morph",a);}this.store("morph",new Fx.Morph(this,this.retrieve("morph:options")));
}return this.retrieve("morph");}};Element.implement({morph:function(a){this.get("morph").start(a);return this;}});Fx.implement({getTransition:function(){var a=this.options.transition||Fx.Transitions.Sine.easeInOut;
if(typeof a=="string"){var b=a.split(":");a=Fx.Transitions;a=a[b[0]]||a[b[0].capitalize()];if(b[1]){a=a["ease"+b[1].capitalize()+(b[2]?b[2].capitalize():"")];
}}return a;}});Fx.Transition=function(b,a){a=$splat(a);return $extend(b,{easeIn:function(c){return b(c,a);},easeOut:function(c){return 1-b(1-c,a);},easeInOut:function(c){return(c<=0.5)?b(2*c,a)/2:(2-b(2*(1-c),a))/2;
}});};Fx.Transitions=new Hash({linear:$arguments(0)});Fx.Transitions.extend=function(a){for(var b in a){Fx.Transitions[b]=new Fx.Transition(a[b]);}};Fx.Transitions.extend({Pow:function(b,a){return Math.pow(b,a[0]||6);
},Expo:function(a){return Math.pow(2,8*(a-1));},Circ:function(a){return 1-Math.sin(Math.acos(a));},Sine:function(a){return 1-Math.sin((1-a)*Math.PI/2);
},Back:function(b,a){a=a[0]||1.618;return Math.pow(b,2)*((a+1)*b-a);},Bounce:function(f){var e;for(var d=0,c=1;1;d+=c,c/=2){if(f>=(7-4*d)/11){e=c*c-Math.pow((11-6*d-11*f)/4,2);
break;}}return e;},Elastic:function(b,a){return Math.pow(2,10*--b)*Math.cos(20*b*Math.PI*(a[0]||1)/3);}});["Quad","Cubic","Quart","Quint"].each(function(b,a){Fx.Transitions[b]=new Fx.Transition(function(c){return Math.pow(c,[a+2]);
});});var Request=new Class({Implements:[Chain,Events,Options],options:{url:"",data:"",headers:{"X-Requested-With":"XMLHttpRequest",Accept:"text/javascript, text/html, application/xml, text/xml, */*"},async:true,format:false,method:"post",link:"ignore",isSuccess:null,emulation:true,urlEncoded:true,encoding:"utf-8",evalScripts:false,evalResponse:false,noCache:false},initialize:function(a){this.xhr=new Browser.Request();
this.setOptions(a);this.options.isSuccess=this.options.isSuccess||this.isSuccess;this.headers=new Hash(this.options.headers);},onStateChange:function(){if(this.xhr.readyState!=4||!this.running){return;
}this.running=false;this.status=0;$try(function(){this.status=this.xhr.status;}.bind(this));if(this.options.isSuccess.call(this,this.status)){this.response={text:this.xhr.responseText,xml:this.xhr.responseXML};
this.success(this.response.text,this.response.xml);}else{this.response={text:null,xml:null};this.failure();}this.xhr.onreadystatechange=$empty;},isSuccess:function(){return((this.status>=200)&&(this.status<300));
},processScripts:function(a){if(this.options.evalResponse||(/(ecma|java)script/).test(this.getHeader("Content-type"))){return $exec(a);}return a.stripScripts(this.options.evalScripts);
},success:function(b,a){this.onSuccess(this.processScripts(b),a);},onSuccess:function(){this.fireEvent("complete",arguments).fireEvent("success",arguments).callChain();
},failure:function(){this.onFailure();},onFailure:function(){this.fireEvent("complete").fireEvent("failure",this.xhr);},setHeader:function(a,b){this.headers.set(a,b);
return this;},getHeader:function(a){return $try(function(){return this.xhr.getResponseHeader(a);}.bind(this));},check:function(){if(!this.running){return true;
}switch(this.options.link){case"cancel":this.cancel();return true;case"chain":this.chain(this.caller.bind(this,arguments));return false;}return false;},send:function(j){if(!this.check(j)){return this;
}this.running=true;var h=$type(j);if(h=="string"||h=="element"){j={data:j};}var d=this.options;j=$extend({data:d.data,url:d.url,method:d.method},j);var f=j.data,b=j.url,a=j.method;
switch($type(f)){case"element":f=$(f).toQueryString();break;case"object":case"hash":f=Hash.toQueryString(f);}if(this.options.format){var i="format="+this.options.format;
f=(f)?i+"&"+f:i;}if(this.options.emulation&&["put","delete"].contains(a)){var g="_method="+a;f=(f)?g+"&"+f:g;a="post";}if(this.options.urlEncoded&&a=="post"){var c=(this.options.encoding)?"; charset="+this.options.encoding:"";
this.headers.set("Content-type","application/x-www-form-urlencoded"+c);}if(this.options.noCache){var e="noCache="+new Date().getTime();f=(f)?e+"&"+f:e;
}if(f&&a=="get"){b=b+(b.contains("?")?"&":"?")+f;f=null;}this.xhr.open(a.toUpperCase(),b,this.options.async);this.xhr.onreadystatechange=this.onStateChange.bind(this);
this.headers.each(function(l,k){try{this.xhr.setRequestHeader(k,l);}catch(m){this.fireEvent("exception",[k,l]);}},this);this.fireEvent("request");this.xhr.send(f);
if(!this.options.async){this.onStateChange();}return this;},cancel:function(){if(!this.running){return this;}this.running=false;this.xhr.abort();this.xhr.onreadystatechange=$empty;
this.xhr=new Browser.Request();this.fireEvent("cancel");return this;}});(function(){var a={};["get","post","put","delete","GET","POST","PUT","DELETE"].each(function(b){a[b]=function(){var c=Array.link(arguments,{url:String.type,data:$defined});
return this.send($extend(c,{method:b.toLowerCase()}));};});Request.implement(a);})();

View file

@ -1,65 +0,0 @@
<!--
Speed Dial head template for Midori.
Copyright (C) 2009 Jean-François Guchens <zcx000@gmail.com>
This file is licensed under the terms of the expat license, see the file EXPAT.
-->
<div id="content">
<div class="shortcut top" id="s1">
<a href="#" onclick="javascript:return getAction('s1');">
<h1>1</h1><h4><span/></h4>
</a>
<p> </p>
</div>
<div class="shortcut top" id="s2">
<a href="#" onclick="javascript:return getAction('s2');">
<h1>2</h1><h4><span/></h4>
</a>
<p> </p>
</div>
<div class="shortcut top right" id="s3">
<a href="#" onclick="javascript:return getAction('s3');">
<h1>3</h1><h4><span/></h4>
</a>
<p> </p>
</div>
<div class="shortcut" id="s4">
<a href="#" onclick="javascript:return getAction('s4');">
<h1>4</h1><h4><span/></h4>
</a>
<p> </p>
</div>
<div class="shortcut" id="s5">
<a href="#" onclick="javascript:return getAction('s5');">
<h1>5</h1><h4><span/></h4>
</a>
<p> </p>
</div>
<div class="shortcut right" id="s6">
<a href="#" onclick="javascript:return getAction('s6');">
<h1>6</h1><h4><span/></h4>
</a>
<p> </p>
</div>
<div class="shortcut" id="s7">
<a href="#" onclick="javascript:return getAction('s7');">
<h1>7</h1><h4><span/></h4>
</a>
<p> </p>
</div>
<div class="shortcut" id="s8">
<a href="#" onclick="javascript:return getAction('s8');">
<h1>8</h1><h4><span/></h4>
</a>
<p> </p>
</div>
<div class="shortcut right" id="s9">
<a href="#" onclick="javascript:return getAction('s9');">
<h1>9</h1><h4><span/></h4>
</a>
<p> </p>
</div>
</div> <!-- #wrap -->
<div class="clear"></div>
</div> <!-- #content -->
</body>
</html>

View file

@ -11,6 +11,12 @@
<script type="text/javascript" src="{res}/mootools.js"></script> <script type="text/javascript" src="{res}/mootools.js"></script>
<style> <style>
html, body, #content {
margin: 0px;
padding: 0px
}
body { body {
text-align: center; text-align: center;
background-color: #fefefe; background-color: #fefefe;
@ -19,7 +25,7 @@
#wrap { #wrap {
width: 660px; width: 660px;
height: 570px; height: 550px;
margin: 0px auto; margin: 0px auto;
text-align: center; text-align: center;
} }
@ -30,7 +36,7 @@
position: relative; position: relative;
width: 200px; width: 200px;
height: 150px; height: 150px;
margin: 25px 25px 0px 0px; margin: 20px 20px 0px 0px;
background-color: #fff; background-color: #fff;
-webkit-border-radius: 10px; -webkit-border-radius: 10px;
} }
@ -106,12 +112,20 @@
input[type=text] { input[type=text] {
color: #ddd; color: #ddd;
vertical-align: middle;
font-size: 13px;
} }
input[type=text]:active, input[type=text]:focus { input[type=text]:active, input[type=text]:focus {
color: #222; color: #222;
} }
button {
font-size: 12px;
padding: 5px 7px;
vertical-align: middle;
}
div.activated { div.activated {
background-color: #f5f5f5; background-color: #f5f5f5;
} }
@ -139,15 +153,24 @@
.activated p { .activated p {
cursor: text; cursor: text;
background: url({stock}/gtk-edit) 98% 65% no-repeat; background: url({stock}/gtk-edit) 98% 70% no-repeat;
-webkit-background-size: 12px 15px; -webkit-background-size: 16px 15px;
opacity: 0.6;
color: rgba(0,0,0,1);
}
.activated p:hover {
opacity: 1;
color: rgba(0,0,0,0.5);
} }
</style> </style>
<script type="text/javascript"> <script type="text/javascript">
sc = JSON.decode ({json_data});
var getAction = function (id) var getAction = function (id)
{ {
var a = $(id).getFirst (); var a = $(id).getFirst ();
if (a.getProperty ('href') != "#" ) if (a.getProperty ('href') != "#" )
return true; return true;
@ -161,6 +184,9 @@
a.setProperty('href', url); a.setProperty('href', url);
a.getNext().set('text', name); a.getNext().set('text', name);
var num = id.charAt (1) - 1;
sc.shortcuts[num].title = name;
a.empty(); a.empty();
var im = new Element('img', { src: '{stock}/throbber.gif' }); var im = new Element('img', { src: '{stock}/throbber.gif' });
@ -173,7 +199,7 @@
var getThumbnail = function (id, url) var getThumbnail = function (id, url)
{ {
console.log ("speeddial-get-thumbnail " + id + " " + url); console.log ("speed_dial-get-thumbnail " + id + " " + url);
return false; return false;
} }
@ -192,18 +218,27 @@
$(id).addClass ('activated'); $(id).addClass ('activated');
var p = a.getNext(); var p = a.getNext ();
p.setProperty('onclick', 'javascript:rename_shortcut("' + id + '");'); p.setProperty('onclick', 'javascript:renameShortcut("' + id + '");');
var num = id.charAt (1) - 1;
sc.shortcuts[num].href = href;
sc.shortcuts[num].img = data;
console.log ("speed_dial-save '" + JSON.encode (sc) + "'");
} }
var rename_shortcut = function (id) var renameShortcut = function (id)
{ {
var name = prompt ("{enter_shortcut_name}", ""); var name = prompt ("{enter_shortcut_name}", "");
if (!name) return; if (!name) return;
$(id).getLast ().set ('html', name); var num = id.charAt (1) - 1;
console.log ("speeddial-save"); $(id).getLast ().set ('html', name);
sc.shortcuts[num].title = name;
console.log ("speed_dial-save '" + JSON.encode (sc) + "'");
} }
var clearShortcut = function (id) var clearShortcut = function (id)
@ -212,39 +247,90 @@
return; return;
var num = id.charAt (1); var num = id.charAt (1);
var sc = $(id); var div = $(id);
var cross = sc.getFirst (); var cross = div.getFirst ();
var a = cross.getNext (); var a = cross.getNext ();
var p = a.getNext (); var p = a.getNext ();
cross.dispose (); cross.dispose ();
sc.removeClass ('activated'); div.removeClass ('activated');
a.empty (); a.empty ();
cross.dispose (); cross.dispose ();
sc.removeClass ('activated'); div.removeClass ('activated');
a.empty ().set ('html', '<h1>' + num + '</h1><h4><span/></h4>'); a.empty ().set ('html', '<h1>' + num + '</h1><h4><span/></h4>');
a.setProperty ('href', '#'); a.setProperty ('href', '#');
p.empty ().removeProperty ('onclick'); p.empty ().removeProperty ('onclick');
console.log ("speeddial-save"); num -= 1;
sc.shortcuts[num].href = "#";
sc.shortcuts[num].title = "";
sc.shortcuts[num].img = "";
console.log ("speed_dial-save '" + JSON.encode (sc) + "'");
} }
var speeddialSearch = function () var speeddialSearch = function ()
{ {
var reg = new RegExp("%s", "g"); var reg = new RegExp ("%s", "g");
var search_url = $('search_bar').getProperty ('action'); var search_url = $('search_bar').getProperty ('action');
var search_content = $('search_bar').getFirst ().get ('value'); var search_content = $('search_bar').getFirst ().get ('value');
window.location.href = search_url.replace (reg, encodeURIComponent (search_content)); window.location.href = search_url.replace (reg, encodeURIComponent (search_content));
return false; return false;
} }
var getSpeeddialContent = function() var buildSpeeddial = function ()
{ {
var content = $('content').get ('html'); sc.shortcuts.each (function (item, index, sc)
return '<div id="content">' + content + '</div></div></body></html>'; {
var cl = "shortcut";
if (index == 0 || index == 1 || index == 2)
cl += " top";
if (index == 2 || index == 5 || index == 8)
cl += " right";
var div = new Element ('div', {
'class': cl,
'id': item.id
});
var a = new Element ('a', {
'href': item.href,
'events': {
'click': function () {
return getAction (item.id);
}
}
});
var p = new Element ('p', {
'text': item.title
});
if (item.href == "#")
a.set ('html', '<h1>' + item.id.charAt (1) + '</h1><h4><span/></h4>');
else
{
div.addClass ('activated');
var im = new Element ('img', { src: 'data:image/png;base64,' + item.img });
var cross = new Element ('div', { 'html': 'x' });
cross.setProperty ('onclick', 'clearShortcut("' + item.id + '");');
cross.addClass ('cross');
cross.inject (div, 'top');
a.grab (im);
p.setProperty('onclick', 'javascript:renameShortcut("' + item.id + '");');
}
div.grab (a);
div.grab (p);
$('content').grab (div);
});
} }
window.addEvent ('domready', function () {
buildSpeeddial ();
});
</script> </script>
</head> </head>
<body> <body>
@ -255,4 +341,9 @@
onblur="javascript:if(this.value=='') this.value='{search_title}';" /> onblur="javascript:if(this.value=='') this.value='{search_title}';" />
<button>{search}</button> <button>{search}</button>
</form> </form>
<div id="content">
</div>
</div>
</body>
</html>

1
data/speeddial.json Normal file
View file

@ -0,0 +1 @@
'{"shortcuts": [ { "id": "s1", "href": "#", "title": "", "img": "" }, { "id": "s2", "href": "#", "title": "", "img": "" }, { "id": "s3", "href": "#", "title": "", "img": "" }, { "id": "s4", "href": "#", "title": "", "img": "" }, { "id": "s5", "href": "#", "title": "", "img": "" }, { "id": "s6", "href": "#", "title": "", "img": "" }, { "id": "s7", "href": "#", "title": "", "img": "" }, { "id": "s8", "href": "#", "title": "", "img": "" }, { "id": "s9", "href": "#", "title": "", "img": "" } ] }'

View file

@ -874,33 +874,45 @@ midori_view_save_as_cb (GtkWidget* menuitem,
static gchar* static gchar*
midori_browser_speed_dial_get_next_free_slot (void) midori_browser_speed_dial_get_next_free_slot (void)
{ {
GRegex* regex;
GMatchInfo* match_info;
gchar* speed_dial_body; gchar* speed_dial_body;
gchar* body_fname; gchar* body_fname;
gchar* slot_id = NULL; gchar* slot_id = NULL;
gchar* p = NULL;
body_fname = g_build_filename (sokoke_set_config_dir (NULL), body_fname = g_build_filename (sokoke_set_config_dir (NULL),
"speeddial-body.html", NULL); "speeddial.json", NULL);
if (!g_file_test (body_fname, G_FILE_TEST_EXISTS)) if (!g_file_test (body_fname, G_FILE_TEST_EXISTS))
{ {
g_file_get_contents (DATADIR "/midori/res/speeddial-body.html", if (g_file_get_contents (DATADIR "/midori/res/speeddial.json",
&speed_dial_body, NULL, NULL); &speed_dial_body, NULL, NULL))
g_file_set_contents (body_fname, speed_dial_body, -1, NULL); {
g_file_set_contents (body_fname, speed_dial_body, -1, NULL);
g_free (speed_dial_body);
}
g_free (body_fname);
return g_strdup ("s1");
} }
else else
g_file_get_contents (body_fname, &speed_dial_body, NULL, NULL); g_file_get_contents (body_fname, &speed_dial_body, NULL, NULL);
p = g_strstr_len (speed_dial_body, -1, "<h1>"); regex = g_regex_new ("\"id\":[ \t]*\"(s[0-9])\"[ \t]*,[ \t]*\"href\":\"#\"",
G_REGEX_MULTILINE, 0, NULL);
if (p != NULL) if (g_regex_match (regex, speed_dial_body, 0, &match_info))
{ {
p = g_strndup ((p+4), 1); slot_id = g_match_info_fetch (match_info, 1);
slot_id = g_strdup_printf ("s%s", p); g_match_info_free (match_info);
g_free (p);
} }
if (!g_strcmp0 (slot_id, ""))
g_free (slot_id);
g_free (body_fname); g_free (body_fname);
g_free (speed_dial_body); g_free (speed_dial_body);
g_free (regex);
return slot_id; return slot_id;
} }
@ -954,45 +966,37 @@ midori_browser_add_speed_dial (MidoriBrowser* browser)
gsize sz; gsize sz;
body_fname = g_build_filename (sokoke_set_config_dir (NULL), body_fname = g_build_filename (sokoke_set_config_dir (NULL),
"speeddial-body.html", NULL); "speeddial.json", NULL);
g_file_get_contents (body_fname, &speed_dial_body, NULL, NULL); if (g_file_get_contents (body_fname, &speed_dial_body, NULL, NULL))
{
img = gdk_pixbuf_new_from_file_at_scale (filename, 160, 107, FALSE, NULL);
gdk_pixbuf_save_to_buffer (img, &file_content, &sz, "png", NULL, NULL);
encoded = g_base64_encode ((guchar *)file_content, sz);
img = gdk_pixbuf_new_from_file_at_scale (filename, 160, 107, FALSE, NULL); replace_from = g_strdup_printf (
gdk_pixbuf_save_to_buffer (img, &file_content, &sz, "png", NULL, NULL); "\\{[ \t]*\"id\"[ \t]*:[ \t]*\"%s\"[ \t]*,[ \t]*\"href\"[ \t]*"\
encoded = g_base64_encode ((guchar *)file_content, sz); "[ \t]*:[ \t]*\"#\"[ \t]*,[ \t]*\"title\"[ \t]*:[ \t]*\"\"[ \t]*,"\
"\"img\"[ \t]*:[ \t]*\"\"[ \t]*\\}", slot_id);
replace_by = g_strdup_printf (
"{\"id\":\"%s\",\"href\":\"%s\",\"title\":\"%s\",\"img\":\"%s\"}",
slot_id, uri, title, encoded);
replace_from = g_strdup_printf ( regex = g_regex_new (replace_from, G_REGEX_MULTILINE, 0, NULL);
"<div class=\"(.+)\" id=\"%s\">[ \r\n\t]*"\ replace = g_regex_replace (regex, speed_dial_body, -1,
"<a href=\"#\" onclick=\""\ 1, replace_by, 0, NULL);
"javascript:return getAction\\('%s'\\);\".*>[ \r\n\t]*<h1>"\ g_file_set_contents (body_fname, replace, -1, NULL);
"%s</h1><h4>.+</h4>[ \r\n\t]*</a>[ \r\n\t]*<p>[ ]*</p>[ \r\t\n]*</div>",
slot_id, slot_id, (slot_id+1));
replace_by = g_strdup_printf ( g_object_unref (img);
"<div class=\"\\1 activated\" id=\"%s\">"\ g_regex_unref (regex);
"<div onclick=\"clearShortcut"\ g_free (encoded);
"('%s');\" class=\"cross\">x</div><a href=\"%s\" onclick="\ g_free (file_content);
"\"javascript:return getAction('%s');\"><img src="\ g_free (speed_dial_body);
"\"data:image/png;base64,%s\" /></a><p onclick="\ g_free (replace_from);
"\"javascript:rename_shortcut('%s');\">%s</p></div>", g_free (replace_by);
slot_id, slot_id, uri, slot_id, encoded, slot_id, title); g_free (replace);
}
regex = g_regex_new (replace_from, G_REGEX_MULTILINE, 0, NULL);
replace = g_regex_replace (regex, speed_dial_body, -1,
1, replace_by, 0, NULL);
g_file_set_contents (body_fname, replace, -1, NULL);
g_object_unref (img);
g_regex_unref (regex);
g_free (encoded);
g_free (file_content);
g_free (body_fname); g_free (body_fname);
g_free (speed_dial_body);
g_free (replace_by);
g_free (replace_from);
g_free (replace);
} }
g_free (thumb); g_free (thumb);

View file

@ -185,7 +185,9 @@ midori_view_speed_dial_get_thumb (GtkWidget* web_view,
MidoriView* view); MidoriView* view);
static void static void
midori_view_speed_dial_save (GtkWidget* web_view); midori_view_speed_dial_save (GtkWidget* web_view,
const gchar* message);
static void static void
midori_view_class_init (MidoriViewClass* class) midori_view_class_init (MidoriViewClass* class)
@ -1470,7 +1472,7 @@ webkit_web_view_console_message_cb (GtkWidget* web_view,
if (!strncmp (message, "speed_dial-get-thumbnail", 22)) if (!strncmp (message, "speed_dial-get-thumbnail", 22))
midori_view_speed_dial_get_thumb (web_view, message, view); midori_view_speed_dial_get_thumb (web_view, message, view);
else if (!strncmp (message, "speed_dial-save", 13)) else if (!strncmp (message, "speed_dial-save", 13))
midori_view_speed_dial_save (web_view); midori_view_speed_dial_save (web_view, message);
else else
g_signal_emit (view, signals[CONSOLE_MESSAGE], 0, message, line, source_id); g_signal_emit (view, signals[CONSOLE_MESSAGE], 0, message, line, source_id);
return TRUE; return TRUE;
@ -1980,7 +1982,6 @@ midori_view_set_uri (MidoriView* view,
gchar* res_root; gchar* res_root;
gchar* speed_dial_head; gchar* speed_dial_head;
gchar* speed_dial_body; gchar* speed_dial_body;
gchar* speed_dial_html;
gchar* body_fname; gchar* body_fname;
gchar* location_entry_search; gchar* location_entry_search;
gchar* stock_root; gchar* stock_root;
@ -1995,25 +1996,27 @@ midori_view_set_uri (MidoriView* view,
res_root = g_strdup_printf ("http://localhost:%d/res", port); res_root = g_strdup_printf ("http://localhost:%d/res", port);
stock_root = g_strdup_printf ("http://localhost:%d/stock", port); stock_root = g_strdup_printf ("http://localhost:%d/stock", port);
body_fname = g_build_filename (sokoke_set_config_dir (NULL), body_fname = g_build_filename (sokoke_set_config_dir (NULL),
"speeddial-body.html", NULL); "speeddial.json", NULL);
if (!g_file_test (body_fname, G_FILE_TEST_EXISTS)) if (!g_file_test (body_fname, G_FILE_TEST_EXISTS))
{ {
g_file_get_contents (DATADIR "/midori/res/speeddial-body.html", if (g_file_get_contents (DATADIR "/midori/res/speeddial.json",
&speed_dial_body, NULL, NULL ); &speed_dial_body, NULL, NULL))
g_file_set_contents (body_fname, speed_dial_body, -1, NULL ); g_file_set_contents (body_fname, speed_dial_body, -1, NULL);
else
speed_dial_body = g_strdup ("");
} }
else else
g_file_get_contents (body_fname, &speed_dial_body, NULL, NULL); g_file_get_contents (body_fname, &speed_dial_body, NULL, NULL);
speed_dial_html = g_strconcat (speed_dial_head, speed_dial_body, NULL);
g_object_get (view->settings, "location-entry-search", g_object_get (view->settings, "location-entry-search",
&location_entry_search, NULL); &location_entry_search, NULL);
data = sokoke_replace_variables (speed_dial_html, data = sokoke_replace_variables (speed_dial_head,
"{res}", res_root, "{res}", res_root,
"{stock}", stock_root, "{stock}", stock_root,
"{json_data}", speed_dial_body,
"{title}", _("Blank page"), "{title}", _("Blank page"),
"{search_uri}", location_entry_search, "{search_uri}", location_entry_search,
"{search_title}", _("Search"), "{search_title}", _("Search"),
@ -2036,7 +2039,6 @@ midori_view_set_uri (MidoriView* view,
g_free (res_root); g_free (res_root);
g_free (stock_root); g_free (stock_root);
g_free (data); g_free (data);
g_free (speed_dial_html);
g_free (speed_dial_head); g_free (speed_dial_head);
g_free (speed_dial_body); g_free (speed_dial_body);
g_free (body_fname); g_free (body_fname);
@ -2956,7 +2958,7 @@ midori_view_speed_dial_inject_thumb (MidoriView* view,
return; return;
img = gdk_pixbuf_new_from_file_at_scale (filename, 160, 107, FALSE, NULL); img = gdk_pixbuf_new_from_file_at_scale (filename, 160, 107, FALSE, NULL);
gdk_pixbuf_save_to_buffer (img, &file_content, &sz, "png", NULL, NULL); gdk_pixbuf_save_to_buffer (img, &file_content, &sz, "png", NULL, "compression", "7", NULL);
encoded = g_base64_encode ( (guchar *)file_content, sz ); encoded = g_base64_encode ( (guchar *)file_content, sz );
/* Call Javascript function to replace shortcut's content */ /* Call Javascript function to replace shortcut's content */
@ -2965,8 +2967,6 @@ midori_view_speed_dial_inject_thumb (MidoriView* view,
free (js); free (js);
g_object_unref (img); g_object_unref (img);
midori_view_speed_dial_save (view->web_view);
g_free (url); g_free (url);
g_free (dom_id); g_free (dom_id);
g_free (encoded); g_free (encoded);
@ -3018,14 +3018,13 @@ midori_view_speed_dial_get_thumb (GtkWidget* web_view,
* *
**/ **/
static void static void
midori_view_speed_dial_save (GtkWidget* web_view) midori_view_speed_dial_save (GtkWidget* web_view,
const gchar* message)
{ {
JSContextRef js_context = webkit_web_frame_get_global_context ( gchar* json = g_strdup (message + 15);
webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view)));
gchar* newdom = sokoke_js_script_eval (js_context,"getSpeeddialContent()", NULL);
gchar* fname = g_build_filename (sokoke_set_config_dir (NULL), gchar* fname = g_build_filename (sokoke_set_config_dir (NULL),
"speeddial-body.html", NULL); "speeddial.json", NULL);
g_file_set_contents (fname, newdom, -1, NULL); g_file_set_contents (fname, json, -1, NULL);
g_free (fname); g_free (fname);
g_free (newdom); g_free (json);
} }

View file

@ -340,7 +340,7 @@ def build (bld):
Utils.pprint ('BLUE', "logo-shade could not be rasterized.") Utils.pprint ('BLUE', "logo-shade could not be rasterized.")
bld.install_files ('${DATADIR}/' + APPNAME + '/res', 'data/error.html') bld.install_files ('${DATADIR}/' + APPNAME + '/res', 'data/error.html')
bld.install_files ('${DATADIR}/' + APPNAME + '/res', 'data/speeddial-head.html') bld.install_files ('${DATADIR}/' + APPNAME + '/res', 'data/speeddial-head.html')
bld.install_files ('${DATADIR}/' + APPNAME + '/res', 'data/speeddial-body.html') bld.install_files ('${DATADIR}/' + APPNAME + '/res', 'data/speeddial.json')
bld.install_files ('${DATADIR}/' + APPNAME + '/res', 'data/mootools.js') bld.install_files ('${DATADIR}/' + APPNAME + '/res', 'data/mootools.js')
if Options.commands['check']: if Options.commands['check']: