r87921 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87920‎ | r87921 | r87922 >
Date:18:34, 12 May 2011
Author:hashar
Status:ok (Comments)
Tags:
Comment:
remove jquery.json from InlineEditor (dupe)

The jQuery JSON Pluing is provided by MediaWiki since r86657
It uses the same version 2.1 (2009-08-14) making it redundant with
the one provided by InlineEditor.
Modified paths:
  • /trunk/extensions/InlineEditor/InlineEditor.php (modified) (history)
  • /trunk/extensions/InlineEditor/jquery.json.js (deleted) (history)

Diff [purge]

Index: trunk/extensions/InlineEditor/jquery.json.js
@@ -1,152 +0,0 @@
2 -/*
3 - * jQuery JSON Plugin
4 - * version: 2.1 (2009-08-14)
5 - *
6 - * This document is licensed as free software under the terms of the
7 - * MIT License: http://www.opensource.org/licenses/mit-license.php
8 - *
9 - * Brantley Harris wrote this plugin. It is based somewhat on the JSON.org
10 - * website's http://www.json.org/json2.js, which proclaims:
11 - * "NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.", a sentiment that
12 - * I uphold.
13 - *
14 - * It is also influenced heavily by MochiKit's serializeJSON, which is
15 - * copyrighted 2005 by Bob Ippolito.
16 - *
17 - * The script has been modified by Jan Paul Posma by removing $.evalJSON, because jQuery
18 - * already includes $.parseJSON, and moving variables into functions.
19 - */
20 -
21 -(function($) {
22 - /** jQuery.toJSON( json-serializble )
23 - Converts the given argument into a JSON respresentation.
24 -
25 - If an object has a "toJSON" function, that will be used to get the representation.
26 - Non-integer/string keys are skipped in the object, as are keys that point to a function.
27 -
28 - json-serializble:
29 - The *thing* to be converted.
30 - **/
31 - $.toJSON = function(o)
32 - {
33 - if (typeof window.JSON == 'object' && window.JSON.stringify)
34 - return window.JSON.stringify(o);
35 -
36 - var type = typeof(o);
37 -
38 - if (o === null)
39 - return "null";
40 -
41 - if (type == "undefined")
42 - return undefined;
43 -
44 - if (type == "number" || type == "boolean")
45 - return o + "";
46 -
47 - if (type == "string")
48 - return $.quoteString(o);
49 -
50 - if (type == 'object')
51 - {
52 - if (typeof o.toJSON == "function")
53 - return $.toJSON( o.toJSON() );
54 -
55 - if (o.constructor === Date)
56 - {
57 - var month = o.getUTCMonth() + 1;
58 - if (month < 10) month = '0' + month;
59 -
60 - var day = o.getUTCDate();
61 - if (day < 10) day = '0' + day;
62 -
63 - var year = o.getUTCFullYear();
64 -
65 - var hours = o.getUTCHours();
66 - if (hours < 10) hours = '0' + hours;
67 -
68 - var minutes = o.getUTCMinutes();
69 - if (minutes < 10) minutes = '0' + minutes;
70 -
71 - var seconds = o.getUTCSeconds();
72 - if (seconds < 10) seconds = '0' + seconds;
73 -
74 - var milli = o.getUTCMilliseconds();
75 - if (milli < 100) milli = '0' + milli;
76 - if (milli < 10) milli = '0' + milli;
77 -
78 - return '"' + year + '-' + month + '-' + day + 'T' +
79 - hours + ':' + minutes + ':' + seconds +
80 - '.' + milli + 'Z"';
81 - }
82 -
83 - if (o.constructor === Array)
84 - {
85 - var ret = [];
86 - for (var i = 0; i < o.length; i++)
87 - ret.push( $.toJSON(o[i]) || "null" );
88 -
89 - return "[" + ret.join(",") + "]";
90 - }
91 -
92 - var pairs = [];
93 - for (var k in o) {
94 - var name;
95 - var type = typeof k;
96 -
97 - if (type == "number")
98 - name = '"' + k + '"';
99 - else if (type == "string")
100 - name = $.quoteString(k);
101 - else
102 - continue; //skip non-string or number keys
103 -
104 - if (typeof o[k] == "function")
105 - continue; //skip pairs where the value is a function.
106 -
107 - var val = $.toJSON(o[k]);
108 -
109 - pairs.push(name + ":" + val);
110 - }
111 -
112 - return "{" + pairs.join(", ") + "}";
113 - }
114 - };
115 -
116 - /** jQuery.quoteString(string)
117 - Returns a string-repr of a string, escaping quotes intelligently.
118 - Mostly a support function for toJSON.
119 -
120 - Examples:
121 - >>> jQuery.quoteString("apple")
122 - "apple"
123 -
124 - >>> jQuery.quoteString('"Where are we going?", she asked.')
125 - "\"Where are we going?\", she asked."
126 - **/
127 - $.quoteString = function(string)
128 - {
129 - var _escapeable = /["\\\x00-\x1f\x7f-\x9f]/g;
130 -
131 - var _meta = {
132 - '\b': '\\b',
133 - '\t': '\\t',
134 - '\n': '\\n',
135 - '\f': '\\f',
136 - '\r': '\\r',
137 - '"' : '\\"',
138 - '\\': '\\\\'
139 - };
140 -
141 - if (string.match(_escapeable))
142 - {
143 - return '"' + string.replace(_escapeable, function (a)
144 - {
145 - var c = _meta[a];
146 - if (typeof c === 'string') return c;
147 - c = a.charCodeAt();
148 - return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
149 - }) + '"';
150 - }
151 - return '"' + string + '"';
152 - };
153 -})(jQuery);
Index: trunk/extensions/InlineEditor/InlineEditor.php
@@ -100,7 +100,4 @@
101101 'jquery.elastic' => $inlineEditorTpl + array(
102102 'scripts' => 'jquery.elastic.js',
103103 ),
104 - 'jquery.json' => $inlineEditorTpl + array(
105 - 'scripts' => 'jquery.json.js',
106 - ),
107104 );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r86657Added jquery.json library to core.tparscal19:33, 21 April 2011

Comments

#Comment by JanPaul123 (talk | contribs)   21:54, 12 May 2011

Sweet, thanks, was just about to do this. :D

Status & tagging log