Browse Source

Layout changes. Beginnings of js language support

Nathaniel van Diepen 10 years ago
parent
commit
f5ab452a06

+ 3 - 0
header.php

@@ -3,6 +3,9 @@
 	ini_set("display_errors", 1);
 	session_start();
 	define('DIR',dirname(__FILE__));
+	setlocale(LC_ALL,Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']));
+	bindtextdomain('omninet',DIR.'/lang');
+	textdomain('omninet');
 	require_once(DIR.'/config.php');
 	require_once(DIR."/lib/irc.php");
 	require_once(DIR."/lib/security.php");

+ 406 - 0
lang/en_US.po

@@ -0,0 +1,406 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: Omninet Control panel\n"
+"POT-Creation-Date: 2014-02-20 14:05-0700\n"
+"PO-Revision-Date: 2014-02-20 14:05-0700\n"
+"Last-Translator: \n"
+"Language-Team: Omnimaga <[email protected]>\n"
+"Language: en_US\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.6.4\n"
+"X-Poedit-Basepath: .\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Poedit-SearchPath-0: ..\n"
+
+#: ../site/api/index.php:18
+msgid "Missing username and/or password"
+msgstr ""
+
+#: ../site/api/index.php:19
+msgid "Missing user type"
+msgstr ""
+
+#: ../site/api/index.php:28
+msgid "No token set"
+msgstr ""
+
+#: ../site/api/index.php:40 ../site/api/index.php:73 ../site/api/index.php:101
+#: ../site/api/index.php:150 ../site/api/index.php:164
+#: ../site/api/index.php:226 ../site/api/index.php:241
+#: ../site/api/index.php:249
+msgid "You have been logged out"
+msgstr ""
+
+#: ../site/api/index.php:69
+msgid "Cannot fetch memos"
+msgstr ""
+
+#: ../site/api/index.php:97
+msgid "Cannot fetch news"
+msgstr ""
+
+#: ../site/api/index.php:113
+msgid "Voice"
+msgstr ""
+
+#: ../site/api/index.php:114
+msgid "Automatic voice"
+msgstr ""
+
+#: ../site/api/index.php:115
+msgid "Halfop"
+msgstr ""
+
+#: ../site/api/index.php:116
+msgid "Automatic Halfop"
+msgstr ""
+
+#: ../site/api/index.php:117
+msgid "Op"
+msgstr ""
+
+#: ../site/api/index.php:118
+msgid "Automatic Op"
+msgstr ""
+
+#: ../site/api/index.php:119
+msgid "Admin"
+msgstr ""
+
+#: ../site/api/index.php:120
+msgid "Owner"
+msgstr ""
+
+#: ../site/api/index.php:121
+msgid "Set"
+msgstr ""
+
+#: ../site/api/index.php:122
+msgid "Invite/Getkey"
+msgstr ""
+
+#: ../site/api/index.php:123
+msgid "Kick/Ban"
+msgstr ""
+
+#: ../site/api/index.php:124
+msgid "Recover/Clear"
+msgstr ""
+
+#: ../site/api/index.php:125
+msgid "Modify access lists"
+msgstr ""
+
+#: ../site/api/index.php:126
+msgid "Topic"
+msgstr ""
+
+#: ../site/api/index.php:127
+msgid "View access lists"
+msgstr ""
+
+#: ../site/api/index.php:128
+msgid "Founder"
+msgstr ""
+
+#: ../site/api/index.php:129
+msgid "Banned"
+msgstr ""
+
+#: ../site/api/index.php:146
+msgid "Cannot fetch channels"
+msgstr ""
+
+#: ../site/api/index.php:151
+msgid "No message or user entered"
+msgstr ""
+
+#: ../site/api/index.php:155 ../site/index.php:348 ../site/index.php:402
+msgid "User"
+msgstr ""
+
+#: ../site/api/index.php:155
+msgid "does not exist"
+msgstr ""
+
+#: ../site/api/index.php:157
+msgid "Memo Sent"
+msgstr ""
+
+#: ../site/api/index.php:160 ../site/api/index.php:168
+msgid "Cannot send memo"
+msgstr ""
+
+#: ../site/api/index.php:165
+msgid "No id given"
+msgstr ""
+
+#: ../site/api/index.php:201
+msgid "Failed to add email"
+msgstr ""
+
+#: ../site/api/index.php:201
+msgid "to user"
+msgstr ""
+
+#: ../site/api/index.php:203
+msgid "Email does not match any users"
+msgstr ""
+
+#: ../site/api/index.php:227
+msgid "No ID set"
+msgstr ""
+
+#: ../site/api/index.php:229
+msgid "Could not remove email address"
+msgstr ""
+
+#: ../site/api/index.php:246
+msgid "2-factor disabled."
+msgstr ""
+
+#: ../site/api/index.php:253 ../site/api/index.php:268
+#: ../site/api/index.php:279
+msgid "Make sure that everything is filled in. Try reloading if it is."
+msgstr ""
+
+#: ../site/api/index.php:254
+msgid "Invalid password"
+msgstr ""
+
+#: ../site/api/index.php:259
+msgid "Could not update password with nickserv"
+msgstr ""
+
+#: ../site/api/index.php:269
+msgid "Not Logged in to use"
+msgstr ""
+
+#: ../site/api/index.php:269
+msgid "with key"
+msgstr ""
+
+#: ../site/api/index.php:270
+msgid "Must be logged in with type user to sync pass"
+msgstr ""
+
+#: ../site/api/index.php:273
+msgid "Could not verify with nickserv"
+msgstr ""
+
+#: ../site/api/index.php:276
+msgid "Nickserv password synchronized with main account"
+msgstr ""
+
+#: ../site/api/index.php:284 ../site/api/index.php:297
+#: ../site/api/index.php:316
+msgid "Not logged in"
+msgstr ""
+
+#: ../site/api/index.php:285 ../site/api/index.php:298
+msgid "No user set."
+msgstr ""
+
+#: ../site/api/index.php:286
+msgid "No email set."
+msgstr ""
+
+#: ../site/api/index.php:287
+msgid "No real name set."
+msgstr ""
+
+#: ../site/api/index.php:288 ../site/api/index.php:299
+msgid "No nick set."
+msgstr ""
+
+#: ../site/api/index.php:289
+msgid "User with id"
+msgstr ""
+
+#: ../site/api/index.php:289 ../site/api/index.php:301
+msgid "does not exist. You should reload the page."
+msgstr ""
+
+#: ../site/api/index.php:293
+msgid "Unable to update user"
+msgstr ""
+
+#: ../site/api/index.php:300
+msgid "No profile set."
+msgstr ""
+
+#: ../site/api/index.php:301
+msgid "Oper with id"
+msgstr ""
+
+#: ../site/api/index.php:303 ../site/api/index.php:305
+msgid "Unable to update oper"
+msgstr ""
+
+#: ../site/api/index.php:311
+msgid "Failed to update setting"
+msgstr ""
+
+#: ../site/api/index.php:311
+msgid "with value"
+msgstr ""
+
+#: ../site/api/index.php:320
+msgid "Invalid Action"
+msgstr ""
+
+#: ../site/index.php:65 ../site/index.php:66 ../site/index.php:110
+#: ../site/index.php:111 ../site/index.php:141 ../site/index.php:142
+msgid "Refresh"
+msgstr ""
+
+#: ../site/index.php:68 ../site/index.php:69
+msgid "New Memo"
+msgstr ""
+
+#: ../site/index.php:71 ../site/index.php:72
+msgid "Delete All"
+msgstr ""
+
+#: ../site/index.php:78 ../site/index.php:120
+msgid "From"
+msgstr ""
+
+#: ../site/index.php:86 ../site/index.php:128
+msgid "Sent"
+msgstr ""
+
+#: ../site/index.php:94
+msgid "Body"
+msgstr ""
+
+#: ../site/index.php:100 ../site/index.php:101
+msgid "Reply"
+msgstr ""
+
+#: ../site/index.php:103 ../site/index.php:104 ../site/index.php:157
+#: ../site/index.php:158
+msgid "Delete"
+msgstr ""
+
+#: ../site/index.php:144 ../site/index.php:145
+msgid "New Channel"
+msgstr ""
+
+#: ../site/index.php:151
+msgid "Flags:"
+msgstr ""
+
+#: ../site/index.php:176
+msgid "News"
+msgstr ""
+
+#: ../site/index.php:177
+msgid "Memos"
+msgstr ""
+
+#: ../site/index.php:178
+msgid "Channels"
+msgstr ""
+
+#: ../site/index.php:180
+msgid "Servers"
+msgstr ""
+
+#: ../site/index.php:181
+msgid "Opers"
+msgstr ""
+
+#: ../site/index.php:182
+msgid "Configuration"
+msgstr ""
+
+#: ../site/index.php:184
+msgid "Profile"
+msgstr ""
+
+#: ../site/index.php:219
+msgid "To"
+msgstr ""
+
+#: ../site/index.php:225
+msgid "Message"
+msgstr ""
+
+#: ../site/index.php:247
+msgid "Country"
+msgstr ""
+
+#: ../site/index.php:255
+msgid "Cell #"
+msgstr ""
+
+#: ../site/index.php:278
+msgid "Token"
+msgstr ""
+
+#: ../site/index.php:293
+msgid "Disable 2-factor"
+msgstr ""
+
+#: ../site/index.php:299
+msgid "Link Persona"
+msgstr ""
+
+#: ../site/index.php:302
+msgid "Remove"
+msgstr ""
+
+#: ../site/index.php:310
+msgid "Switch Role"
+msgstr ""
+
+#: ../site/index.php:312
+msgid "Rehash"
+msgstr ""
+
+#: ../site/index.php:314 ../site/index.php:325
+msgid "Change Password"
+msgstr ""
+
+#: ../site/index.php:316
+msgid "Sync Password"
+msgstr ""
+
+#: ../site/index.php:318
+msgid "Logout"
+msgstr ""
+
+#: ../site/index.php:329 ../site/index.php:427
+msgid "Password"
+msgstr ""
+
+#: ../site/index.php:335
+msgid "New Password"
+msgstr ""
+
+#: ../site/index.php:359
+msgid "Switch"
+msgstr ""
+
+#: ../site/index.php:363 ../site/index.php:433
+msgid "Type"
+msgstr ""
+
+#: ../site/index.php:381 ../site/index.php:413
+msgid "Login"
+msgstr ""
+
+#: ../site/index.php:385
+msgid "2-Factor Verification"
+msgstr ""
+
+#: ../site/index.php:417
+msgid "Persona"
+msgstr ""
+
+#: ../site/index.php:421
+msgid "Username"
+msgstr ""

+ 6 - 5
site/index.php

@@ -21,15 +21,16 @@
 			__HOSTNAME__ = '<?php echo HOSTNAME; ?>';
 		</script>
 		<link href="<?php echo HOSTNAME; ?>site/favicon.ico" rel="icon" type="image/x-icon" />
-		<script src="<?php echo HOSTNAME; ?>site/Modernizr.js"></script>
+		<script src="<?php echo HOSTNAME; ?>site/js/pomo.min.js"></script>
+		<script src="<?php echo HOSTNAME; ?>site/js/Modernizr.js"></script>
 		<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
 		<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
 		<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.0/jquery.cookie.min.js"></script>
 		<script src="//cdnjs.cloudflare.com/ajax/libs/selectize.js/0.8.5/js/selectize.min.js"></script>
-		<script src="<?php echo HOSTNAME; ?>site/jquery.treegrid.js"></script>
+		<script src="<?php echo HOSTNAME; ?>site/js/jquery.treegrid.js"></script>
 		<script src="//cdnjs.cloudflare.com/ajax/libs/history.js/1.8/bundled/html5/jquery.history.min.js"></script>
-		<script src="<?php echo HOSTNAME; ?>site/jquery.timepicker.js"></script>
-		<script src="<?php echo HOSTNAME; ?>site/jquery.ba-resize.min.js"></script>
+		<script src="<?php echo HOSTNAME; ?>site/js/jquery.timepicker.js"></script>
+		<script src="<?php echo HOSTNAME; ?>site/js/jquery.ba-resize.min.js"></script>
 		<?php if(get_conf('2-factor-method') == 'authy'){ ?>
 			<script src="//cdnjs.cloudflare.com/ajax/libs/authy-forms.js/2.0/form.authy.min.js"></script>
 		<?php } ?>
@@ -38,7 +39,7 @@
 		<?php if(get_conf('persona-endpoint') != 'none'){ ?>
 			<script src="//login.persona.org/include.js"></script>
 		<?php } ?>
-		<script src="<?php echo HOSTNAME; ?>site/index.js"></script>
+		<script src="<?php echo HOSTNAME; ?>site/js/index.js"></script>
 		<link href="//code.jquery.com/ui/1.10.4/themes/dot-luv/jquery-ui.css" rel="stylesheet"/>
 		<link href="//cdnjs.cloudflare.com/ajax/libs/selectize.js/0.8.5/css/selectize.css" rel="stylesheet"/>
 		<link href="//cdnjs.cloudflare.com/ajax/libs/selectize.js/0.8.5/css/selectize.default.css" rel="stylesheet"/>

+ 0 - 0
site/Modernizr.js → site/js/Modernizr.js


+ 2 - 1
site/index.js → site/js/index.js

@@ -2,7 +2,8 @@ $(function(){
 	if(location.host != purl(__HOSTNAME__).attr('host')){
 		location.href = __HOSTNAME__;
 	}
-	var dialogs = $('#dialogs').children('div'),
+	var _ = window._ = Pomo.getText,
+		dialogs = $('#dialogs').children('div'),
 		memos,
 		news,
 		templates = [],

+ 0 - 0
site/jquery.ba-resize.min.js → site/js/jquery.ba-resize.min.js


+ 0 - 0
site/jquery.timepicker.js → site/js/jquery.timepicker.js


+ 0 - 0
site/jquery.treegrid.js → site/js/jquery.treegrid.js


+ 14 - 0
site/js/pomo.min.js

@@ -0,0 +1,14 @@
+(function(q){function u(j,h,f){this.bindFunction=function(f,a){return function(){return f.apply(a,[a])}};this.stateChange=function(){4===this.request.readyState&&this.callbackFunction(this.request.responseText)};this.getRequest=function(){return window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):window.XMLHttpRequest?new XMLHttpRequest:!1};this.postBody=f||"";this.callbackFunction=h;this.url=j;if(this.request=this.getRequest())h=this.request,h.onreadystatechange=this.bindFunction(this.stateChange,
+this),""!==this.postBody?(h.open("POST",j,!0),h.setRequestHeader("X-Requested-With","XMLHttpRequest"),h.setRequestHeader("Content-type","application/x-www-form-urlencoded"),h.setRequestHeader("Connection","close")):h.open("GET",j,!0),h.send(this.postBody)}var r,t=function(j){return Object.prototype.toString.call(j).slice(8,-1).toLowerCase()},m=function(){m.cache.hasOwnProperty(arguments[0])||(m.cache[arguments[0]]=m.parse(arguments[0]));return m.format.call(null,m.cache[arguments[0]],arguments)};
+m.format=function(j,h){var f=1,k=j.length,a="",p=[],c,b,d,g;for(c=0;c<k;c++)if(a=t(j[c]),"string"===a)p.push(j[c]);else if("array"===a){d=j[c];if(d[2]){a=h[f];for(b=0;b<d[2].length;b++){if(!a.hasOwnProperty(d[2][b]))throw r('[sprintf] property "%s" does not exist',d[2][b]);a=a[d[2][b]]}}else a=d[1]?h[d[1]]:h[f++];if(/[^s]/.test(d[8])&&"number"!=t(a))throw r("[sprintf] expecting number but found %s",t(a));switch(d[8]){case "b":a=a.toString(2);break;case "c":a=String.fromCharCode(a);break;case "d":a>>=
+0;break;case "e":a=d[7]?a.toExponential(d[7]):a.toExponential();break;case "f":a=d[7]?parseFloat(a).toFixed(d[7]):parseFloat(a);break;case "o":a=a.toString(8);break;case "s":a=(a=String(a))&&d[7]?a.substring(0,d[7]):a;break;case "u":a=Math.abs(a);break;case "x":a=a.toString(16);break;case "X":a=a.toString(16).toUpperCase()}a=/[def]/.test(d[8])&&d[3]&&0<=a?"+"+a:a;b=d[4]?"0"===d[4]?"0":d[4].charAt(1):" ";g=d[6]-String(a).length;if(d[6]){for(var e=[];0<g;e[--g]=b);b=e.join("")}else b="";p.push(d[5]?
+a+b:b+a)}return p.join("")};m.cache={};m.parse=function(j){for(var h=[],f=[],k=0;j;){if(null!==(h=/^[^\x25]+/.exec(j)))f.push(h[0]);else if(null!==(h=/^\x25{2}/.exec(j)))f.push("%");else if(null!==(h=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(j))){if(h[2]){var k=k|1,a=[],p=h[2],c=[];if(null!==(c=/^([a-z_][a-z_\d]*)/i.exec(p)))for(a.push(c[1]);""!==(p=p.substring(c[0].length));)if(null!==(c=/^\.([a-z_][a-z_\d]*)/i.exec(p)))a.push(c[1]);else if(null!==
+(c=/^\[(\d+)\]/.exec(p)))a.push(c[1]);else throw"[sprintf] huh?";else throw"[sprintf] huh?";h[2]=a}else k|=2;if(3===k)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";f.push(h)}else throw"[sprintf] huh?";j=j.substring(h[0].length)}return f};r=m;q.Pomo=new function(){this.VERSION="0.1.0";this.domain="messages";this.unescapeStrings=this.returnStrings=!1;var j=function(a){var c;a.constructor!=String()&&(c=a);a.replace&&(c=a.replace(/[\"]/g,'\\"').replace(/[\\]/g,"\\").replace(/[\/]/g,
+"/").replace(/[\b]/g,"\\b").replace(/[\f]/g,"\\f").replace(/[\n]/g,"\\n").replace(/[\r]/g,"\\r").replace(/[\t]/g,"\\t"));return c},h=function(a){var c;a.replace&&(c=a.replace("\\n","\n").replace("\\r","\r").replace("\\t","\t").replace("\\f","\f").replace("\\b","\b").replace("\\r","\r"));return c},f=this;q.String.prototype.trim||(q.String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")});f.storage={};f.Parser={};f.Parser.Object=function(a){var c=1,b;for(b in a)this[b]=a[b];this.setCount=
+function(a){c=a>>0};this.toString=function(){var a;this.isPlural?a=this.translation:(a=f.storage.calculatePluralIndex(c),a=this.plural_forms[a]);return a}};f.Parser.po={parse:function(a,c){var b=function(a){a=a.split("\n");for(var b=0,c=a.length;b<c;b++)if(0===a[b].indexOf('"Plural-Forms: nplurals')){var d=a[b].substring(14).slice(0,-1);f.storage.calculatePluralIndex=function(){eval(h(d));"undefined"===typeof plural&&(plural=0);return plural}}},d={},g,e,s="undefined"===typeof c?"messages":c,n=[],
+k=0;a=a.replace(/\r\n|\r/g,"\n");d[s]={};n=a.split(/\n\n/);e=n.shift();for((g=b(e))?f.storage.header_info=b(g):n.unshift(e);g=n.shift();){b={};g=g?g.split(/\n/):[];for(e="";e=g.shift();){e=e.trim();var l=g.slice(0,-1)[0],m=e.substring(0,12).split(" ")[0].trim();l&&l.substring(0,12).split(" ")[0].trim();switch(m){case "msgctxt":b.context=e.substring(9).slice(0,-1);break;case "msgid_plural":b.isPlural=!0;b.plural_id=e.substring(14).slice(0,-1);break;case "msgid":if(0===e.indexOf('msgid ""')){if(e=l.trim(),
+0===e.indexOf('"')){for(l=[];e=g.shift();)if(e=e.trim(),0===e.indexOf('"'))l.push(e.substring(1).slice(0,-1));else{g.unshift(e);break}b.id=l.join("")}}else b.id=e.substr(7).slice(0,-1);continue;case "msgstr":if(0===e.indexOf('msgstr ""')){for(l=[];e=g.shift();)if(e=e.trim(),0===e.indexOf('"'))l.push(e.substr(1).slice(0,-1));else{g.unshift(e);break}b.translation=l.join("")}else b.translation=e.substr(8).slice(0,-1);break;case "#:":case "#.":case "#":continue;case "#,":break;default:if(e&&e.match(/msgstr\[[0-9]\]/)){for(l=
+[];e&&e.match(/msgstr\[[0-9]\]/);)l.push(e.substring(10).slice(0,-1)),e=g.shift();b.plural_forms=l;b.translation=l[0]}}}b.id&&b.translation&&(b=new f.Parser.Object(b),d[s][b.id]?d[s][j(b.id)].push(b):d[s][j(b.id)]=[b]);k++}return d},generate:function(){throw"Feature unimplemented";}};var k=function(a,c,b){this.waiting=!0;switch(c){case "po":a=f.Parser.po.parse(a,b);break;default:case "mo":throw"Unimplemented format";}this.waiting=!1;f.storage.contents=a},a=function(a,c,b){f.waiting=!0;return u(a,
+function(a){f.waiting=!1;return k(a,c,b)})};this.noConflict=function(){q.__Pomo=q.Pomo;delete q.Pomo;return q.__Pomo};this.load=function(h,c){c=!c?{}:c;var b=c.format?c.format:!1,d=c.translation_domain?c.translation_domain:"messages";switch(c.mode?c.mode:!1){case "literal":k(h,b,d);break;case "link":var g=document.getElementById(h);g&&(g.type&&"text/x-gettext-translation"===g.type)&&a(g.href,b,d);break;case "ajax":a(h,b,d);break;default:throw"specify a "+b+" files acquisition mode";}var e={ready:function(a){f.waiting?
+window.setTimeout(function(){e.ready(a)},20):a.apply(f,[])}};return e};this.getText=function(a,c){c=!c?{}:c;var b=c.variables?c.variables:[],d=c.context?c.context:!1,g=c.domain?c.domain:"messages",e=c.count?c.count:!1,k=j(a);!g&&!f.domain?g="messages":f.domain&&(g=f.domain);if(f.storage.contents[g]&&f.storage.contents[g][k]){var n=f.storage.contents[g][k];if(d)for(var m=0,l=f.storage.contents[g][k].length;m<l&&!(n.context&&n.context===d);m++);f.storage.contents[g][k].unshift&&(n=f.storage.contents[g][k][0]);
+d=n;e&&n.setCount(e);e=n.constructor===String();f.returnStrings&&(d=n.toString());b&&(b.unshift(e?d:d.translation),b=r.apply(null,b),e?d=b:d.translation=b);e&&f.unescapeStrings?d=h(d):f.unescapeStrings&&!e&&(d.translation=h(d.translation));return d}throw"Unknown id "+msgid;};this.getMap=function(){return f.storage.contents}}})(window,document);